00001
00002
00003 #include <omp.h>
00004 #include <stdlib.h>
00005
00006 int
00007 main (void)
00008 {
00009 int a = 1, b = 2, c = 3;
00010 void
00011 foo (void)
00012 {
00013 int l = 0;
00014 #pragma omp parallel shared (a) private (b) firstprivate (c) \
00015 num_threads (2) reduction (||:l)
00016 {
00017 if (a != 1 || c != 3) l = 1;
00018 #pragma omp barrier
00019 if (omp_get_thread_num () == 0)
00020 {
00021 a = 4;
00022 b = 5;
00023 c = 6;
00024 }
00025 #pragma omp barrier
00026 if (omp_get_thread_num () == 1)
00027 {
00028 if (a != 4 || c != 3) l = 1;
00029 a = 7;
00030 b = 8;
00031 c = 9;
00032 }
00033 else if (omp_get_num_threads () == 1)
00034 a = 7;
00035 #pragma omp barrier
00036 if (omp_get_thread_num () == 0)
00037 if (a != 7 || b != 5 || c != 6) l = 1;
00038 #pragma omp barrier
00039 if (omp_get_thread_num () == 1)
00040 if (a != 7 || b != 8 || c != 9) l = 1;
00041 }
00042 if (l)
00043 abort ();
00044 }
00045 foo ();
00046 if (a != 7)
00047 abort ();
00048 return 0;
00049 }