共享我有一個結構如果指針(和指針的指針......)在OpenMP的
typedef struct mystruct {
int* a;
float** b;
} mystruct;
mystruct* s = (mystruct*) calloc(1, sizeof(mystruct));
s->a = (int*) calloc(100, sizeof(int));
s->b = (float**) calloc(100, sizeof(float*));
for (int i=0; i<100; i++)
s->b[i] = (float*) calloc(100, sizeof(float));
如果我聲明s
在OpenMP的共享作爲什麼將被分享:
#pragma omp parallel for shared(s) schedule(auto)
將全部在存儲器中的以下變量的所有線程共享:
指針
a
陣列指向
a
,即a[i], i=0,...,99
指針
b
陣列通過
b
指向,即b[i], i=0,...,99
陣列指向
b[i], i=0,...,99
,即b[i][j], j=0,...,99
如果在OpenMP中共享指針(以及指向...的指針),將共享什麼
謝謝!
然後它中的所有內容都被共享。如果它被宣佈爲私有,我會更感興趣知道會發生什麼。 – Medinoc
@Medinoc,你可以在這裏找到你的答案http://stackoverflow.com/questions/22204495/local-pointers-in-openmp/22221504#22221504。查看動態數組和私有部分。 –