Synchronization Constructs: “barrier” Directive
Format: barrier |
#pragma omp barrier |
- A thread will wait at barrier until all other threads have reached that barrier. All threads then resume executing in parallel the code that follows the barrier
Synchronization Constructs: “ordered” directive
- Used within a DO/for loop with and ordered clause
- The ordered directive specifies that iterations of the enclosed loop will be executed in the same order as if they were executed on a serial processor.
Format |
#pragma omp ordered
structured block |
Example
|
#pragma omp parallel for ordered
for(I = 0 ; I < N ; I++){
tmp = NEAT STUFF(I);
#pragma omp ordered
res += consume(tmp);
} |
Synchronization Constructs: “flush” Directive
Format |
# pragma omp flush (list) |
- Defines a sequence point at which a thread is guaranteed to see a consistent view of memory with respect to the “flush
set”
- The flush set is :
- List of variables
- In absence of list all thread visible variable are in list
- Flush forces data to be updated in memory so other threads see the most recent value
|