00001 #include <omp.h>
00002 #include <stdlib.h>
00003
00004 int
00005 main (void)
00006 {
00007 int i = 0, j = 0, k = 0, l = 0;
00008 #pragma omp parallel num_threads(4) reduction(-:i) reduction(|:k) \
00009 reduction(^:l)
00010 {
00011 if (i != 0 || k != 0 || l != 0)
00012 #pragma omp atomic
00013 j |= 1;
00014
00015 if (omp_get_num_threads () != 4)
00016 #pragma omp atomic
00017 j |= 2;
00018
00019 i = omp_get_thread_num ();
00020 k = 1 << (2 * i);
00021 l = 0xea << (3 * i);
00022 }
00023
00024 if (j & 1)
00025 abort ();
00026 if ((j & 2) == 0)
00027 {
00028 if (i != (0 + 1 + 2 + 3))
00029 abort ();
00030 if (k != 0x55)
00031 abort ();
00032 if (l != 0x1e93a)
00033 abort ();
00034 }
00035 return 0;
00036 }