1 | // RUN: %libomp-compile-and-run | FileCheck %s |
2 | // REQUIRES: ompt |
3 | #include "callback.h" |
4 | #include <omp.h> |
5 | |
6 | int main() |
7 | { |
8 | //need to use an OpenMP construct so that OMPT will be initialized |
9 | #pragma omp parallel num_threads(1) |
10 | print_ids(0); |
11 | |
12 | omp_lock_t lock; |
13 | printf("%" PRIu64 ": &lock: %" PRIu64 "\n" , ompt_get_thread_data()->value, (ompt_wait_id_t)(uintptr_t) &lock); |
14 | omp_init_lock(&lock); |
15 | print_fuzzy_address(1); |
16 | omp_set_lock(&lock); |
17 | print_fuzzy_address(2); |
18 | omp_unset_lock(&lock); |
19 | print_fuzzy_address(3); |
20 | omp_destroy_lock(&lock); |
21 | print_fuzzy_address(4); |
22 | |
23 | |
24 | // Check if libomp supports the callbacks for this test. |
25 | // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_mutex_acquire' |
26 | // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_mutex_acquired' |
27 | // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_mutex_released' |
28 | // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_nest_lock' |
29 | |
30 | // CHECK: 0: NULL_POINTER=[[NULL:.*$]] |
31 | |
32 | // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: &lock: [[WAIT_ID:[0-9]+]] |
33 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_init_lock: wait_id=[[WAIT_ID]], hint={{[0-9]+}}, impl={{[0-9]+}}, codeptr_ra=[[RETURN_ADDRESS:0x[0-f]+]]{{[0-f][0-f]}} |
34 | // CHECK-NEXT: {{^}}[[MASTER_ID]]: fuzzy_address={{.*}}[[RETURN_ADDRESS]] |
35 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_wait_lock: wait_id=[[WAIT_ID]], hint={{[0-9]+}}, impl={{[0-9]+}}, codeptr_ra=[[RETURN_ADDRESS:0x[0-f]+]]{{[0-f][0-f]}} |
36 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_acquired_lock: wait_id=[[WAIT_ID]], codeptr_ra=[[RETURN_ADDRESS:0x[0-f]+]]{{[0-f][0-f]}} |
37 | // CHECK-NEXT: {{^}}[[MASTER_ID]]: fuzzy_address={{.*}}[[RETURN_ADDRESS]] |
38 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_release_lock: wait_id=[[WAIT_ID]], codeptr_ra=[[RETURN_ADDRESS:0x[0-f]+]]{{[0-f][0-f]}} |
39 | // CHECK-NEXT: {{^}}[[MASTER_ID]]: fuzzy_address={{.*}}[[RETURN_ADDRESS]] |
40 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_destroy_lock: wait_id=[[WAIT_ID]], codeptr_ra=[[RETURN_ADDRESS:0x[0-f]+]]{{[0-f][0-f]}} |
41 | // CHECK-NEXT: {{^}}[[MASTER_ID]]: fuzzy_address={{.*}}[[RETURN_ADDRESS]] |
42 | |
43 | return 0; |
44 | } |
45 | |