SGI Example
Published online by Cambridge University Press: 12 December 2009
Summary
The SGI Power C compiler (PCA) does not allow more threads than processors (cf. the document “Multiprocessing C Compiler Directives”). In this sense, programs execute like the fork() programming model.
The keyword critical corresponds most closely with mutex in that only one thread at a time can execute this code and all threads execute it. The keyword synchronize corresponds most closely with barrier in that all threads must arrive at this point before any thread can go on.
There are also additional directives. The directive one processor means that the first thread to reach this code executes it meanwhile other threads wait. After execution by the first thread, the code is skipped by subsequent threads. There is an enter gate and corresponding exit gate directive. Threads must wait at the exit gate until all threads have passed the matching enter gate.
Loops to run in parallel must be marked with the pfor directive. It takes the argument iterate (start index; number of times through the loop; increment/decrement amount).
A reduction variable is local to each thread and their contributions must be added in a critical section.
- Type
- Chapter
- Information
- An Introduction to Parallel and Vector Scientific Computation , pp. 282 - 284Publisher: Cambridge University PressPrint publication year: 2006