19
edits
Changes
→Data Parallelism
'''Forall-loop:''' important concept in Chapel for data parallelism. Like the coforall-loops, the forall-loop is also a parallel version of a for-loop in Chapel. The motivation behind forall-loops is to be able to handle a large number of iterations without having to create a task for every iteration like the coforall-loop.
const n = 1000000; var iterations: [1..n] real;
Each task will be responsible for a single iteration. Significant performance hit caused by creating, scheduling, and destroying each individual task which will outweigh the benefits of each task handling little computation.
coforall it in iterations do { it += 1.0; }
Automatically creates an appropriate number of tasks specific to each system and assigns an equal amount of loop iterations to each task. The number of tasks created is generally based on the number of cores that the system’s processor has. For example: a quad-core processor running this program with 1,000,000 iterations would cause 4 tasks to be created and assign 250,000 iterations to each individual task.
forall it in iterations do { it += 1.0; }
[[File:Chapel_loops.png]]