Debian Codegraph @

openmp/runtime/test/ompt/synchronization/test_nest_lock_parallel.c

raw
1 // clang-format off
2 // RUN: %libomp-compile-and-run | %sort-threads | FileCheck %s
3 // REQUIRES: ompt
4 // UNSUPPORTED: gcc-4, gcc-5, gcc-6, gcc-7
5 // clang-format on
6 #include "callback.h"
7 #include <omp.h>
8
9 int main() {
10 omp_nest_lock_t nest_lock;
11 omp_init_nest_lock(&nest_lock);
12
13 #pragma omp parallel num_threads(2)
14 {
15 #pragma omp master
16 {
17 omp_set_nest_lock(&nest_lock);
18 print_fuzzy_address(1);
19 }
20 #pragma omp barrier
21 omp_test_nest_lock(&nest_lock); // should fail for non-master
22 print_fuzzy_address(2);
23 #pragma omp barrier
24 #pragma omp master
25 {
26 omp_unset_nest_lock(&nest_lock);
27 print_fuzzy_address(3);
28 omp_unset_nest_lock(&nest_lock);
29 print_fuzzy_address(4);
30 }
31 }
32
33 omp_destroy_nest_lock(&nest_lock);
34
35 // clang-format off
36 // Check if libomp supports the callbacks for this test.
37 // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_mutex_acquire'
38 // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_mutex_acquired'
39 // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_mutex_released'
40 // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_nest_lock'
41
42 // CHECK: 0: NULL_POINTER=[[NULL:.*$]]
43
44 // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_wait_nest_lock: wait_id=[[WAIT_ID:[0-9]+]], hint=0, impl={{[0-9]+}}, codeptr_ra=[[RETURN_ADDRESS:(0x)?[0-f]+]]{{[0-f][0-f]}}
45 // CHECK: {{^}}[[MASTER_ID]]: ompt_event_acquired_nest_lock_first: wait_id=[[WAIT_ID]], codeptr_ra=[[RETURN_ADDRESS]]{{[0-f][0-f]}}
46 // CHECK-NEXT: {{^}}[[MASTER_ID]]: fuzzy_address={{.*}}[[RETURN_ADDRESS]]
47 // CHECK: {{^}}[[MASTER_ID]]: ompt_event_wait_test_nest_lock: wait_id=[[WAIT_ID]], hint=0, impl={{[0-9]+}}, codeptr_ra=[[RETURN_ADDRESS:(0x)?[0-f]+]]{{[0-f][0-f]}}
48 // CHECK: {{^}}[[MASTER_ID]]: ompt_event_acquired_nest_lock_next: wait_id=[[WAIT_ID]], codeptr_ra=[[RETURN_ADDRESS]]{{[0-f][0-f]}}
49 // CHECK-NEXT: {{^}}[[MASTER_ID]]: fuzzy_address={{.*}}[[RETURN_ADDRESS]]
50 // CHECK: {{^}}[[MASTER_ID]]: ompt_event_release_nest_lock_prev: wait_id=[[WAIT_ID]], codeptr_ra=[[RETURN_ADDRESS:(0x)?[0-f]+]]{{[0-f][0-f]}}
51 // CHECK-NEXT: {{^}}[[MASTER_ID]]: fuzzy_address={{.*}}[[RETURN_ADDRESS]]
52 // CHECK: {{^}}[[MASTER_ID]]: ompt_event_release_nest_lock_last: wait_id=[[WAIT_ID]], codeptr_ra=[[RETURN_ADDRESS:(0x)?[0-f]+]]{{[0-f][0-f]}}
53 // CHECK-NEXT: {{^}}[[MASTER_ID]]: fuzzy_address={{.*}}[[RETURN_ADDRESS]]
54
55 // CHECK: {{^}}[[MASTER_ID]]: ompt_event_destroy_nest_lock: wait_id=[[WAIT_ID]]
56
57 // CHECK: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_wait_test_nest_lock: wait_id=[[WAIT_ID]], hint=0, impl={{[0-9]+}}, codeptr_ra=[[RETURN_ADDRESS:(0x)?[0-f]+]]{{[0-f][0-f]}}
58 // CHECK-NOT: {{^}}[[THREAD_ID]]: ompt_event_acquired_test_nest_lock_next: wait_id=[[WAIT_ID]]
59 // CHECK-NEXT: {{^}}[[THREAD_ID]]: fuzzy_address={{.*}}[[RETURN_ADDRESS]]
60 // clang-format on
61
62 return 0;
63 }