00001
00002
00003
00004 extern int omp_set_dynamic (int);
00005 extern int omp_get_thread_num (void);
00006 extern void abort (void);
00007
00008 int a = 8, b = 12, c = 16, d = 20, j = 0, l = 0;
00009 char e[10] = "a", f[10] = "b", g[10] = "c", h[10] = "d";
00010 volatile int k;
00011
00012 int
00013 main (void)
00014 {
00015 int i;
00016 omp_set_dynamic (0);
00017 omp_set_nested (1);
00018 #pragma omp parallel num_threads (2) reduction (+:l)
00019 if (k == omp_get_thread_num ())
00020 {
00021 #pragma omp parallel for shared (a, e) firstprivate (b, f) \
00022 lastprivate (c, g) private (d, h) \
00023 schedule (static, 1) num_threads (4) \
00024 reduction (+:j)
00025 for (i = 0; i < 4; i++)
00026 {
00027 if (a != 8 || b != 12 || e[0] != 'a' || f[0] != 'b')
00028 j++;
00029 #pragma omp barrier
00030 #pragma omp atomic
00031 a += i;
00032 b += i;
00033 c = i;
00034 d = i;
00035 #pragma omp atomic
00036 e[0] += i;
00037 f[0] += i;
00038 g[0] = 'g' + i;
00039 h[0] = 'h' + i;
00040 #pragma omp barrier
00041 if (a != 8 + 6 || b != 12 + i || c != i || d != i)
00042 j += 8;
00043 if (e[0] != 'a' + 6 || f[0] != 'b' + i || g[0] != 'g' + i)
00044 j += 64;
00045 if (h[0] != 'h' + i)
00046 j += 512;
00047 }
00048 if (j || a != 8 + 6 || b != 12 || c != 3 || d != 20)
00049 ++l;
00050 if (e[0] != 'a' + 6 || f[0] != 'b' || g[0] != 'g' + 3 || h[0] != 'd')
00051 l += 8;
00052 }
00053 if (l)
00054 abort ();
00055 return 0;
00056 }