testsuite/libgomp.c/task-4.c

Go to the documentation of this file.
00001 /* { dg-do run } */
00002 
00003 #include <omp.h>
00004 #include <stdlib.h>
00005 #include <string.h>
00006 
00007 int e;
00008 
00009 void __attribute__((noinline))
00010 baz (int i, int *p, int j, int *q)
00011 {
00012   if (p[0] != 1 || p[i] != 3 || q[0] != 2 || q[j] != 4)
00013     #pragma omp atomic
00014       e++;
00015 }
00016 
00017 void __attribute__((noinline))
00018 foo (int i, int j)
00019 {
00020   int p[i + 1];
00021   int q[j + 1];
00022   memset (p, 0, sizeof (p));
00023   memset (q, 0, sizeof (q));
00024   p[0] = 1;
00025   p[i] = 3;
00026   q[0] = 2;
00027   q[j] = 4;
00028   #pragma omp task firstprivate (p, q)
00029     baz (i, p, j, q);
00030 }
00031 
00032 int
00033 main (void)
00034 {
00035   #pragma omp parallel num_threads (4)
00036     foo (5 + omp_get_thread_num (), 7 + omp_get_thread_num ());
00037   if (e)
00038     abort ();
00039   return 0;
00040 }

Generated on Fri Apr 5 05:38:10 2013 for Libgomp by  doxygen 1.4.7