1*404b540aSrobert /* { dg-do run } */ 2*404b540aSrobert /* { dg-options "-O2" } */ 3*404b540aSrobert /* { dg-require-effective-target tls_runtime } */ 4*404b540aSrobert 5*404b540aSrobert #include <omp.h> 6*404b540aSrobert #include <stdlib.h> 7*404b540aSrobert 8*404b540aSrobert int thr; 9*404b540aSrobert #pragma omp threadprivate (thr) 10*404b540aSrobert 11*404b540aSrobert int test(int l)12*404b540aSroberttest (int l) 13*404b540aSrobert { 14*404b540aSrobert return l || (thr != omp_get_thread_num () * 2); 15*404b540aSrobert } 16*404b540aSrobert 17*404b540aSrobert int main(void)18*404b540aSrobertmain (void) 19*404b540aSrobert { 20*404b540aSrobert int l = 0; 21*404b540aSrobert 22*404b540aSrobert omp_set_dynamic (0); 23*404b540aSrobert omp_set_num_threads (6); 24*404b540aSrobert 25*404b540aSrobert thr = 8; 26*404b540aSrobert /* Broadcast the value to all threads. */ 27*404b540aSrobert #pragma omp parallel copyin (thr) 28*404b540aSrobert ; 29*404b540aSrobert 30*404b540aSrobert #pragma omp parallel reduction (||:l) 31*404b540aSrobert { 32*404b540aSrobert /* Now test if the broadcast succeeded. */ 33*404b540aSrobert l = thr != 8; 34*404b540aSrobert thr = omp_get_thread_num () * 2; 35*404b540aSrobert #pragma omp barrier 36*404b540aSrobert l = test (l); 37*404b540aSrobert } 38*404b540aSrobert 39*404b540aSrobert if (l) 40*404b540aSrobert abort (); 41*404b540aSrobert return 0; 42*404b540aSrobert } 43