A variable is not marked as THREADPRIVATE at all its declarations.
The THREADPRIVATE directive must appear after every declaration of THREADPRIVATE variable.
ID |
Observation |
Description |
---|---|---|
1 |
Definition |
The place the variable was defined |
2 |
Definition |
The other place the variable was defined |
#include <omp.h> // myArray is threadprivate in file1.c int myArray[10]; #pragma omp threadprivate(myArray) int myFunc() { return myArray[0]; }file2.c:
#include <stdio.h> #include <omp.h> // myArray is NOT threadprivate in file2.c extern int myArray[10]; extern int myFunc(); int main(int argc, char **argv) { int i; int y; omp_set_num_threads(3); #pragma omp parallel for ordered private(y) for (i = 0; i < 10; i++) { myArray[i] = i + 11; y = myFunc(); #pragma omp ordered printf("i = %d, #threads = %d, y = %d\n", i, omp_get_thread_num(), y); } return 0; }
Copyright © 2010, Intel Corporation. All rights reserved.