Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. typedef struct mystruct {
  2. int* a;
  3. float** b;
  4. } mystruct;
  5.  
  6.  
  7. mystruct* s = (mystruct*) calloc(1, sizeof(mystruct));
  8. s->a = (int*) calloc(100, sizeof(int));
  9. s->b = (float**) calloc(100, sizeof(float*));
  10.  
  11. for (int i=0; i<100; i++)
  12. s->b[i] = (float*) calloc(100, sizeof(float));
  13.  
  14. #pragma omp parallel for shared(s) schedule(auto)
  15.  
  16. int *p;
  17.  
  18. #pragma omp parallel private(p)
  19. {
  20. ...
  21. }
  22.  
  23. #pragma omp parallel
  24. {
  25. int *p;
  26. ...
  27. }
  28.  
  29. int *a = malloc(10 * sizeof(int));
  30.  
  31. #pragma omp parallel private(a)
  32. {
  33. a[1] = ... // <--- WRONG - no memory allocated automatically by OpenMP
  34. }
  35.  
  36. #pragma omp parallel
  37. {
  38. int *a = malloc(10 * sizeof(int));
  39. ...
  40. free(a);
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement