Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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));
- #pragma omp parallel for shared(s) schedule(auto)
- int *p;
- #pragma omp parallel private(p)
- {
- ...
- }
- #pragma omp parallel
- {
- int *p;
- ...
- }
- int *a = malloc(10 * sizeof(int));
- #pragma omp parallel private(a)
- {
- a[1] = ... // <--- WRONG - no memory allocated automatically by OpenMP
- }
- #pragma omp parallel
- {
- int *a = malloc(10 * sizeof(int));
- ...
- free(a);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement