I am working in C with openMP using gcc on a Linux machine. In the openmp parallel loop, I can declare a statically allocated array as closed. Consider a piece of code:
int a[10]; #pragma omp parallel for shared(none) firstprivate(a) for(i=0;i<4;i++){
And everything works as expected. But if instead I allocate dynamically,
int * a = (int *) malloc(10*sizeof(int)); #pragma omp parallel for shared(none) firstprivate(a)
the values ββof a (at least [1 ... 9]) are not protected, but act as if they were separated. This is understandable because nothing in the pragma command tells omp how large the array a is to be closed. How to transfer this information to openmp? How to declare an entire dynamically allocated array as closed?
c malloc parallel-processing openmp
cboettig Feb 28 '10 at 22:13 2010-02-28 22:13
source share