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