testsuite/libgomp.c++/task-6.C

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

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