SLIDE 4 Clauses
FIRSTPRIVATE (list) – gives the private variable an initialized value of the original variable when entering the parallel region LASTPRIVATE (list) – gives the exiting private variable the value of the last iteration or final section REDUCTION (operator:list) – to ensure that a shared variable location is written to one thread at a time; each thread has a private copy
- f the shared variable that gets updated at the end of the parallel
region; operators include +, *, ‐, .AND., .OR., .EQV., .NEQV., MAX, MIN, IAND, IOR or IEOR IF (scalar logical expression) – allows the parallel region to be run sequentially if the expression is false NUM THREADS (scalar integer expression) – allows the number of threads the region is fork into to be declared (still an optional command that is not needed)
Clauses
SCHEDULE (type, chunk) – type can be static, dynamic, or guided; help determine the efficiency of the code
- Static ‐ divides the iterations statically in the beginning between the
threads; if a chunk size is set the last thread may have a different number of iterations then the others; offers the best performance if all the iterations require the same computational time
- Dynamic – each thread is given a small amount of work the size of chunk
and when it is done it is given more; if the chunk is not specified the default is one; obviously increases overhead
- Guided – gives a combination of the two by handing out large loads at
first and then handing out smaller loads decreasing exponentially NOWAIT – an end_clause causing the threads not to wait at the end of a work‐sharing region, but to continue on to the next work‐sharing region; without this clause there is an implied barrier for all the threads to catch up and synchronize with each other