testsuite/libgomp.c/copyin-3.c

Go to the documentation of this file.
00001 /* { dg-do run } */
00002 /* { dg-options "-O2" } */
00003 /* { dg-require-effective-target tls_runtime } */
00004 
00005 #include <omp.h>
00006 #include <stdlib.h>
00007 
00008 int thr;
00009 #pragma omp threadprivate (thr)
00010 
00011 int
00012 test (int l)
00013 {
00014   return l || (thr != omp_get_thread_num () * 2);
00015 }
00016 
00017 int
00018 main (void)
00019 {
00020   int l = 0;
00021 
00022   omp_set_dynamic (0);
00023   omp_set_num_threads (6);
00024 
00025   thr = 8;
00026   /* Broadcast the value to all threads.  */
00027 #pragma omp parallel copyin (thr)
00028   ;
00029 
00030 #pragma omp parallel reduction (||:l)
00031   {
00032     /* Now test if the broadcast succeeded.  */
00033     l = thr != 8;
00034     thr = omp_get_thread_num () * 2;
00035 #pragma omp barrier
00036     l = test (l);
00037   }
00038 
00039   if (l)
00040     abort ();
00041   return 0;
00042 }

Generated on Fri Apr 5 05:38:10 2013 for Libgomp by  doxygen 1.4.7