1 /* { dg-do run } */ 2 /* { dg-set-target-env-var OMP_CANCELLATION "true" } */ 3 4 #include <omp.h> 5 #include <unistd.h> 6 7 static inline void do_some_work(void)8do_some_work (void) 9 { 10 asm volatile ("" : : : "memory"); 11 } 12 13 int main()14main () 15 { 16 omp_set_dynamic (0); 17 omp_set_schedule (omp_sched_static, 1); 18 #pragma omp parallel num_threads (16) 19 { 20 int i, j; 21 do_some_work (); 22 #pragma omp barrier 23 if (omp_get_thread_num () == 1) 24 { 25 sleep (2); 26 #pragma omp cancellation point parallel 27 } 28 for (j = 3; j <= 16; j++) 29 #pragma omp for schedule (runtime) nowait 30 for (i = 0; i < j; i++) 31 do_some_work (); 32 if (omp_get_thread_num () == 0) 33 { 34 sleep (1); 35 #pragma omp cancel parallel 36 } 37 } 38 return 0; 39 } 40