1 // RUN: %libomp-compile-and-run 2 #include <stdio.h> 3 #include "omp_testsuite.h" 4 test_omp_master()5int test_omp_master() 6 { 7 int nthreads; 8 int executing_thread; 9 10 nthreads = 0; 11 executing_thread = -1; 12 13 #pragma omp parallel 14 { 15 #pragma omp master 16 { 17 #pragma omp critical 18 { 19 nthreads++; 20 } 21 executing_thread = omp_get_thread_num(); 22 } /* end of master*/ 23 } /* end of parallel*/ 24 return ((nthreads == 1) && (executing_thread == 0)); 25 } 26 main()27int main() 28 { 29 int i; 30 int num_failed=0; 31 32 for(i = 0; i < REPETITIONS; i++) { 33 if(!test_omp_master()) { 34 num_failed++; 35 } 36 } 37 return num_failed; 38 } 39