Parallel Loop Model in C
Note threads, shared, local
main() {
#pragma omp parallel for \
shared(A)private(i)
for( i=1; i<=100; i++ ) {
. . .
}
}
A is shared
Parallel for
i=1
i=2
i=3
i=4
i=5
i=6
A
Several, e.g. 4, threads
created on entry
Iterations
scheduled
on threads
i is local
Threads
barrier at end
Threads either spin or
sleep between regions
Previous slide
Next slide
Back to first slide
View graphic version