Questions about Chapel
- What's the minimal subset of the language capable of representing all chapel programs?
- What subset of the language will we concern ourselves with?
Questions for the Chapel Dev Team
- If a given thread for a forall loop is assigned iterations 1, 3 and 7, will they necessarily be assigned in that order?
- How do/will parallel iterators affect the assignment of threads to iterations of a forall loop.
Chapel Constructs
Concepts
- Tasks
Types
- int
- bool
- range
- rectangular domain
- array
- sync
Have hidden state, empty or full. Read blocks on empty, write blocks on full (Has other methods, writeXX(), readXX() etc.)
- single
Write once, reads block until written to (Error condition if written to more than once)
Statements
- sync <statement>
Wait for all tasks created in the statement to complete
- serial <expression> <statement>
If expression is true, serializes all code in statement
- atomic <statement>
A transaction
- for
- forall
Like coforall, but iterations distributed among tasks in any way, including, possibly, one task
- coforall
Assign one task to each iteration, wait for all iterations to complete
- begin
Launch task to execute statement, proceed without blocking
- cobegin
Assign one task to each statement, wait for all to complete
- call
- assignment
- if
- block
- select
- expression
- (do)while
- return
- procedure declaration
- variable declaration
- yield
Expressions
- Literal
- Variable
- Function call
- L-Value
- Parenthesis
- Unary operators
- - (Negation)
- Binary Operators
- + (Addition)
- - (Subtraction)
- / (Integer/Rational Divide)
- * (Times)
- % (Modulus)
- | | (Logical Or)
- & & (Logical and)
- = (Assignment)
Iterators and for/forall
The use of iterators in for/forall loops can be implemented using a manager-worker strategy. When an iterator is encountered, the caller ("manager") spawns a new process to run the iterator. In addition to any declared parameters, the iterator has an extra parameter for the process ID of the manager. Whenever the iterator encounters a yield statement, it sends the yielded value to the manager. The manager then non-deterministically distributes the yielded value to one of n worker threads, which sets the loop variable to that value and runs the loop. When the end of the iterator is reached, it sends a special termination message. The manager then sends termination messages to all works and waits for them to complete.
