testsuite/libgomp.c++/loop-10.C

Go to the documentation of this file.
00001 // { dg-do run }
00002 
00003 #include <omp.h>
00004 
00005 extern "C" void abort (void);
00006 
00007 #define LLONG_MAX __LONG_LONG_MAX__
00008 #define ULLONG_MAX (LLONG_MAX * 2ULL + 1)
00009 #define INT_MAX __INT_MAX__
00010 
00011 int v;
00012 
00013 int
00014 test1 (void)
00015 {
00016   int e = 0, cnt = 0;
00017   long long i;
00018   unsigned long long j;
00019   char buf[6], *p;
00020 
00021   #pragma omp for schedule(dynamic,1) collapse(2) nowait
00022   for (i = LLONG_MAX - 30001; i <= LLONG_MAX - 10001; i += 10000)
00023     for (j = 20; j <= LLONG_MAX - 70; j += LLONG_MAX + 50ULL)
00024       if ((i != LLONG_MAX - 30001
00025        && i != LLONG_MAX - 20001
00026        && i != LLONG_MAX - 10001)
00027       || j != 20)
00028     e = 1;
00029       else
00030     cnt++;
00031   if (e || cnt != 3)
00032     abort ();
00033   else
00034     cnt = 0;
00035 
00036   #pragma omp for schedule(guided,1) collapse(2) nowait
00037   for (i = -LLONG_MAX + 30000; i >= -LLONG_MAX + 10000; i -= 10000)
00038     for (j = ULLONG_MAX - 3; j >= LLONG_MAX + 70ULL; j -= LLONG_MAX + 50ULL)
00039       if ((i != -LLONG_MAX + 30000
00040        && i != -LLONG_MAX + 20000
00041        && i != -LLONG_MAX + 10000)
00042       || j != ULLONG_MAX - 3)
00043     e = 1;
00044       else
00045     cnt++;
00046   if (e || cnt != 3)
00047     abort ();
00048   else
00049     cnt = 0;
00050 
00051   #pragma omp for schedule(static,1) collapse(2) nowait
00052   for (i = LLONG_MAX - 30001; i <= LLONG_MAX - 10001; i += 10000)
00053     for (j = 20; j <= LLONG_MAX - 70 + v; j += LLONG_MAX + 50ULL)
00054       if ((i != LLONG_MAX - 30001
00055        && i != LLONG_MAX - 20001
00056        && i != LLONG_MAX - 10001)
00057       || j != 20)
00058     e = 1;
00059       else
00060     cnt++;
00061   if (e || cnt != 3)
00062     abort ();
00063   else
00064     cnt = 0;
00065 
00066   #pragma omp for schedule(static) collapse(2) nowait
00067   for (i = -LLONG_MAX + 30000 + v; i >= -LLONG_MAX + 10000; i -= 10000)
00068     for (j = ULLONG_MAX - 3; j >= LLONG_MAX + 70ULL; j -= LLONG_MAX + 50ULL)
00069       if ((i != -LLONG_MAX + 30000
00070        && i != -LLONG_MAX + 20000
00071        && i != -LLONG_MAX + 10000)
00072       || j != ULLONG_MAX - 3)
00073     e = 1;
00074       else
00075     cnt++;
00076   if (e || cnt != 3)
00077     abort ();
00078   else
00079     cnt = 0;
00080 
00081   #pragma omp for schedule(runtime) collapse(2) nowait
00082   for (i = 10; i < 30; i++)
00083     for (p = buf; p <= buf + 4; p += 2)
00084       if (i < 10 || i >= 30 || (p != buf && p != buf + 2 && p != buf + 4))
00085     e = 1;
00086       else
00087     cnt++;
00088   if (e || cnt != 60)
00089     abort ();
00090   else
00091     cnt = 0;
00092 
00093   return 0;
00094 }
00095 
00096 int
00097 main (void)
00098 {
00099   if (2 * sizeof (int) != sizeof (long long))
00100     return 0;
00101   asm volatile ("" : "+r" (v));
00102   omp_set_schedule (omp_sched_dynamic, 1);
00103   test1 ();
00104   return 0;
00105 }

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