A variable named in a COPYIN clause was not previously assigned in this parallel region.
The COPYIN clause copies the value of the master thread's copy of a threadprivate variable to the copy of that variable belonging to the other threads in the team that is about to execute a parallel region. This diagnostic is emitted if the master thread's copy was not last assigned outside of another parallel region.
If an earlier assignment the THREADPRIVATE variable within another parallel region could reach this use, then the program is probably in error. The problem is that the assignment(s) within the earlier parallel region may be done on different threads and, therefore, the effect on the master thread's copy is indeterminate. This can produce different behavior in parallel and sequential mode.
ID |
Observation |
Description |
---|---|---|
1 |
Uninitialized read |
Location of the COPYIN clause |
#include <stdio.h> #include <omp.h> int a[1000]; #pragma omp threadprivate (a) int sum; void fgood() { int i; int b[1000]; for (i = 0; i < 1000; i++) { b[i] = i; } for (i = 10; i < 1000; i++) { a[i] = b[i] + 1; } } void fbad() { int i; int b[1000]; for (i = 0; i < 1000; i++) { b[i] = i; } #pragma omp parallel for for (i = 10; i < 1000; i++) { a[i] = b[i] + 1; } } void mycopyin() { int i; // a is not properly initialized // if fbad was called earlier #pragma omp parallel for reduction (+:sum) copyin(a) for (i = 10; i < 1000; i++) { sum = sum + a[i]; } } int main(int argc, char **argc) { int i; sum = 0; if (argc < 10) fgood(); else fbad(); mycopyin(); printf("%d\n", sum); return 0; }
Copyright © 2010, Intel Corporation. All rights reserved.