1 #include <omp.h> 2 #include <stdlib.h> 3 4 int main(void)5main (void) 6 { 7 int l = 0; 8 omp_nest_lock_t lock; 9 omp_init_nest_lock (&lock); 10 #pragma omp parallel reduction (+:l) num_threads (1) 11 { 12 if (omp_test_nest_lock (&lock) != 1) 13 l++; 14 if (omp_test_nest_lock (&lock) != 2) 15 l++; 16 #pragma omp task if (0) shared (lock, l) 17 { 18 if (omp_test_nest_lock (&lock) != 0) 19 l++; 20 } 21 #pragma omp taskwait 22 if (omp_test_nest_lock (&lock) != 3) 23 l++; 24 omp_unset_nest_lock (&lock); 25 omp_unset_nest_lock (&lock); 26 omp_unset_nest_lock (&lock); 27 } 28 if (l) 29 abort (); 30 omp_destroy_nest_lock (&lock); 31 return 0; 32 } 33