00001 #include <omp.h> 00002 extern "C" void *memset (void *, int, __SIZE_TYPE__); 00003 extern "C" void abort (void); 00004 00005 int e; 00006 00007 void 00008 baz (int i, int *p, int j, int *q) 00009 { 00010 if (p[0] != 1 || p[i] != 3 || q[0] != 2 || q[j] != 4) 00011 #pragma omp atomic 00012 e++; 00013 } 00014 00015 void 00016 foo (int i, int j) 00017 { 00018 int p[i + 1]; 00019 int q[j + 1]; 00020 memset (p, 0, sizeof (p)); 00021 memset (q, 0, sizeof (q)); 00022 p[0] = 1; 00023 p[i] = 3; 00024 q[0] = 2; 00025 q[j] = 4; 00026 #pragma omp task firstprivate (p, q) 00027 baz (i, p, j, q); 00028 } 00029 00030 int 00031 main () 00032 { 00033 #pragma omp parallel num_threads (4) 00034 foo (5 + omp_get_thread_num (), 7 + omp_get_thread_num ()); 00035 if (e) 00036 abort (); 00037 }