00001 /* { dg-do run { target *-*-linux* } } */ 00002 00003 #ifndef _GNU_SOURCE 00004 #define _GNU_SOURCE 1 00005 #endif 00006 #include <pthread.h> 00007 #include <omp.h> 00008 #include <stdio.h> 00009 #include <stdlib.h> 00010 00011 pthread_barrier_t bar; 00012 00013 void *tf (void *p) 00014 { 00015 int l; 00016 if (p) 00017 omp_set_num_threads (3); 00018 pthread_barrier_wait (&bar); 00019 if (!p) 00020 omp_set_num_threads (6); 00021 pthread_barrier_wait (&bar); 00022 omp_set_dynamic (0); 00023 if (omp_get_max_threads () != (p ? 3 : 6)) 00024 abort (); 00025 l = 0; 00026 #pragma omp parallel num_threads (6) reduction (|:l) 00027 { 00028 l |= omp_get_max_threads () != (p ? 3 : 6); 00029 omp_set_num_threads ((p ? 3 : 6) + omp_get_thread_num ()); 00030 l |= omp_get_max_threads () != ((p ? 3 : 6) + omp_get_thread_num ()); 00031 } 00032 if (l) 00033 abort (); 00034 return NULL; 00035 } 00036 00037 int 00038 main (void) 00039 { 00040 pthread_t th; 00041 pthread_barrier_init (&bar, NULL, 2); 00042 pthread_create (&th, NULL, tf, NULL); 00043 tf (""); 00044 pthread_join (th, NULL); 00045 return 0; 00046 }