Open MP2
Open MP2
CS3006
Lecture 9
OpenMP-II
4th April 2022
Comments:
Here the private variable j is undefined -
when this parallel construct is entered
when this parallel construct is exited
lastprivate:
consider the following code
s = complex_function();
#pragma omp parallel for private(j) firstprivate(s)
for (i = 0 ; i < n ; i ++) (
s += 1
}
printf(“s after join:%d\n”,s); //undefined value
--------------------------------------------------------------------------------------------------
s = complex_function();
#pragma omp parallel for private(j) firstprivate(s) lastprivate(s)
for (i = 0 ; i < n ; i ++) (
s +=1;
}
printf(“s after join:%d\n”,s);//value of s as it was for last iteration of the loop
Operators
+ Sum
* Product
& Bitwise and
| Bitwise or
^ Bitwise exclusive or
&& Logical and
|| Logical or
CS3006 - Spring 2022
Reduction clause
3. Guided:
schedule(guided, C): dynamic allocation of chunks to tasks
using guided self-scheduling heuristic. Initial chunks are
bigger, later chunks are smaller, minimum chunk size is C.
schedule(guided): guided self-scheduling with minimum
chunk size 1
a b
v = alpha();
W = beta();
x = gamma(v,w);
y = delta();
g d
printf(“%6.2f\n”,epsilon(x,y));
a b
v = alpha();
W = beta();
x = gamma(v,w);
y = delta();
g d
printf(“%6.2f\n”,epsilon(x,y));