testsuite/libgomp.c/reduction-5.c

Go to the documentation of this file.
00001 /* PR middle-end/36506 */
00002 
00003 extern void abort (void);
00004 
00005 int
00006 main (void)
00007 {
00008   int sum = 0, prod = 1;
00009 #pragma omp parallel
00010   #pragma omp sections reduction (+:sum)
00011     {
00012     #pragma omp section
00013       sum += 2;
00014     #pragma omp section
00015       sum += 2;
00016     #pragma omp section
00017       sum += 2;
00018     }
00019   if (sum != 6)
00020     abort ();
00021   sum = 0;
00022 #pragma omp parallel sections reduction (+:sum)
00023   {
00024   #pragma omp section
00025     sum += 2;
00026   #pragma omp section
00027     sum += 2;
00028   #pragma omp section
00029     sum += 2;
00030   }
00031   if (sum != 6)
00032     abort ();
00033   sum = 0;
00034 #pragma omp parallel
00035   #pragma omp sections reduction (+:sum) reduction (*:prod)
00036     {
00037     #pragma omp section
00038       {
00039     sum += 2;
00040     prod *= 2;
00041       }
00042     #pragma omp section
00043       {
00044     sum += 2;
00045     prod *= 2;
00046       }
00047     #pragma omp section
00048       {
00049     sum += 2;
00050     prod *= 2;
00051       }
00052     }
00053   if (sum != 6 || prod != 8)
00054     abort ();
00055   sum = 0;
00056   prod = 1;
00057 #pragma omp parallel sections reduction (+:sum) reduction (*:prod)
00058   {
00059   #pragma omp section
00060     {
00061       sum += 2;
00062       prod *= 2;
00063     }
00064   #pragma omp section
00065     {
00066       sum += 2;
00067       prod *= 2;
00068     }
00069   #pragma omp section
00070     {
00071       sum += 2;
00072       prod *= 2;
00073     }
00074   }
00075   if (sum != 6 || prod != 8)
00076     abort ();
00077   return 0;
00078 }

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