testsuite/libgomp.c/task-1.c

Go to the documentation of this file.
00001 extern void abort (void);
00002 
00003 int a = 18;
00004 
00005 void
00006 f1 (int i, int j, int k)
00007 {
00008   int l = 6, m = 7, n = 8;
00009 #pragma omp task private(j, m) shared(k, n)
00010   {
00011     j = 6;
00012     m = 5;
00013     if (++a != 19 || ++i != 9 || j != 6 || ++l != 7 || m != 5 || ++n != 9)
00014       #pragma omp atomic
00015     k++;
00016   }
00017 #pragma omp taskwait
00018   if (a != 19 || i != 8 || j != 26 || k != 0 || l != 6 || m != 7 || n != 9)
00019     abort ();
00020 }
00021 
00022 int v1 = 1, v2 = 2, v5 = 5;
00023 int err;
00024 
00025 void
00026 f2 (void)
00027 {
00028   int v3 = 3;
00029 #pragma omp sections private (v1) firstprivate (v2)
00030   {
00031   #pragma omp section
00032     {
00033       int v4 = 4;
00034       v1 = 7;
00035       #pragma omp task
00036     {
00037       if (++v1 != 8 || ++v2 != 3 || ++v3 != 4 || ++v4 != 5 || ++v5 != 6)
00038         err = 1;
00039     }
00040       #pragma omp taskwait
00041       if (v1 != 7 || v2 != 2 || v3 != 3 || v4 != 4 || v5 != 6)
00042     abort ();
00043       if (err)
00044     abort ();
00045     }
00046   }
00047 }
00048 
00049 void
00050 f3 (int i, int j, int k)
00051 {
00052   int l = 6, m = 7, n = 8;
00053 #pragma omp task private(j, m) shared(k, n) untied
00054   {
00055     j = 6;
00056     m = 5;
00057     if (++a != 19 || ++i != 9 || j != 6 || ++l != 7 || m != 5 || ++n != 9)
00058       #pragma omp atomic
00059     k++;
00060   }
00061 #pragma omp taskwait
00062   if (a != 19 || i != 8 || j != 26 || k != 0 || l != 6 || m != 7 || n != 9)
00063     abort ();
00064 }
00065 
00066 int
00067 main (void)
00068 {
00069   f1 (8, 26, 0);
00070   f2 ();
00071   a = 18;
00072   f3 (8, 26, 0);
00073   a = 18;
00074 #pragma omp parallel num_threads(4)
00075   {
00076     #pragma omp master
00077       {
00078     f1 (8, 26, 0);
00079     a = 18;
00080     f3 (8, 26, 0);
00081       }
00082   }
00083   return 0;
00084 }

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