|
|
От: | barmale-y | |
| Дата: | 10.09.10 09:33 | ||
| Оценка: | |||
Restrictions:
* Variables in the list must be named scalar variables. They can not be array or structure type variables. They must also be declared SHARED in the enclosing context.
#include <stdio.h>
main() {
int s = 0, i;
#pragma omp parallel for shared(s) private(i) reduction(+:s)
for(i=0; i<100; ++i) {
s += i;
}
printf("s=%i",s);
}
error: ‘s’ appears more than once in data clauses
|
|
От: |
remark
|
http://www.1024cores.net/ |
| Дата: | 10.09.10 09:44 | ||
| Оценка: | |||
The restrictions to the reduction clause are as follows:
The type of the variables in the reduction clause must be valid for the reduction operator except that pointer types and reference types are never permitted.
A variable that is specified in the reduction clause must not be const-qualified.
Variables that are private within a parallel region or that appear in the reduction clause of a parallel directive cannot be specified in a reduction clause on a work-sharing directive that binds to the parallel construct.
#pragma omp parallel private(y) { /* ERROR - private variable y cannot be specified in a reduction clause */ #pragma omp for reduction(+: y) for (i=0; i<n; i++) y += b[i]; } /* ERROR - variable x cannot be specified in both a shared and a reduction clause */ #pragma omp parallel for shared(x) reduction(+: x)