00001
00002
00003
00004 #include <omp.h>
00005
00006 extern void abort (void);
00007
00008 int
00009 main (void)
00010 {
00011 int i = 5, j, l = 0;
00012 int foo (void)
00013 {
00014 return i == 6;
00015 }
00016 int bar (void)
00017 {
00018 return i - 3;
00019 }
00020
00021 omp_set_dynamic (0);
00022
00023 #pragma omp parallel if (foo ()) num_threads (2)
00024 if (omp_get_num_threads () != 1)
00025 #pragma omp atomic
00026 l++;
00027
00028 #pragma omp parallel for schedule (static, bar ()) num_threads (2) \
00029 reduction (|:l)
00030 for (j = 0; j < 4; j++)
00031 if (omp_get_thread_num () != (j >= 2))
00032 #pragma omp atomic
00033 l++;
00034
00035 i++;
00036
00037 #pragma omp parallel if (foo ()) num_threads (2)
00038 if (omp_get_num_threads () != 2)
00039 #pragma omp atomic
00040 l++;
00041
00042 #pragma omp parallel for schedule (static, bar ()) num_threads (2) \
00043 reduction (|:l)
00044 for (j = 0; j < 6; j++)
00045 if (omp_get_thread_num () != (j >= 3))
00046 #pragma omp atomic
00047 l++;
00048
00049 #pragma omp parallel num_threads (4) reduction (|:l)
00050 if (!foo () || bar () != 3)
00051 #pragma omp atomic
00052 l++;
00053
00054 i++;
00055
00056 #pragma omp parallel num_threads (4) reduction (|:l)
00057 if (foo () || bar () != 4)
00058 #pragma omp atomic
00059 l++;
00060
00061 if (l)
00062 abort ();
00063
00064 return 0;
00065 }