| 1 | // RUN: %libomp-compile-and-run | %sort-threads | FileCheck %s |
| 2 | // REQUIRES: ompt |
| 3 | |
| 4 | #include "callback.h" |
| 5 | #include <omp.h> |
| 6 | |
| 7 | int main() |
| 8 | { |
| 9 | #pragma omp parallel num_threads(2) |
| 10 | { |
| 11 | if (omp_get_thread_num() == 0) { |
| 12 | // region 0 |
| 13 | #pragma omp task if(0) |
| 14 | { |
| 15 | // explicit task immediately executed by the initial master thread |
| 16 | #pragma omp parallel num_threads(2) |
| 17 | { |
| 18 | if (omp_get_thread_num() == 0) { |
| 19 | // Note that this is executed by the initial master thread |
| 20 | // region 1 |
| 21 | // region 1's implicit task |
| 22 | print_ids(0); |
| 23 | // explicit task |
| 24 | print_ids(1); |
| 25 | // region 0's implicit task |
| 26 | print_ids(2); |
| 27 | // initial task |
| 28 | print_ids(3); |
| 29 | } |
| 30 | } |
| 31 | } |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | // Check if libomp supports the callbacks for this test. |
| 36 | // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_task_create' |
| 37 | // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_implicit_task' |
| 38 | |
| 39 | |
| 40 | // CHECK: {{^}}0: NULL_POINTER=[[NULL:.*$]] |
| 41 | // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_initial_task_begin: parallel_id=[[INITIAL_PARALLEL_ID:[0-9]+]], task_id=[[INITIAL_TASK_ID:[0-9]+]], actual_parallelism=1, index=1, flags=1 |
| 42 | |
| 43 | // region 0 |
| 44 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_parallel_begin |
| 45 | // CHECK-SAME: parent_task_frame.exit=[[NULL]], parent_task_frame.reenter=[[INITIAL_TASK_FRAME_ENTER:(0x)?[0-f]+]], |
| 46 | // CHECK-SAME: parallel_id=[[PARALLEL_ID_0:[0-9]+]] |
| 47 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_begin: parallel_id=[[PARALLEL_ID_0]], task_id=[[TASK_ID_0:[0-9]+]] |
| 48 | |
| 49 | // explicit task |
| 50 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create: parent_task_id=[[TASK_ID_0]] |
| 51 | // CHECK-SAME: parent_task_frame.exit=[[REGION_0_FRAME_EXIT:(0x)?[0-f]+]] |
| 52 | // CHECK-SAME: parent_task_frame.reenter=[[REGION_0_FRAME_ENTER:(0x)?[0-f]+]] |
| 53 | // CHECK-SAME: new_task_id=[[TASK_ID_1:[0-9]+]] |
| 54 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_schedule: first_task_id=[[TASK_ID_0]], second_task_id=[[TASK_ID_1]] |
| 55 | |
| 56 | // region 1 |
| 57 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_parallel_begin |
| 58 | // CHECK-SAME: parent_task_frame.exit=[[EXPLICIT_TASK_FRAME_EXIT:(0x)?[0-f]+]], parent_task_frame.reenter=[[EXPLICIT_TASK_FRAME_ENTER:(0x)?[0-f]+]], |
| 59 | // CHECK-SAME: parallel_id=[[PARALLEL_ID_1:[0-9]+]] |
| 60 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_begin: parallel_id=[[PARALLEL_ID_1]], task_id=[[TASK_ID_2:[0-9]+]] |
| 61 | |
| 62 | // region 1's implicit task information (exit frame should be set, while enter should be NULL) |
| 63 | // CHECK: {{^}}[[MASTER_ID]]: task level 0: parallel_id=[[PARALLEL_ID_1]], task_id=[[TASK_ID_2]] |
| 64 | // CHECK-SAME: exit_frame={{(0x)?[0-f]+}} |
| 65 | // CHECK-SAME: reenter_frame=[[NULL]] |
| 66 | // CHECK-SAME: task_type=ompt_task_implicit |
| 67 | |
| 68 | // explicit task information (both exit and enter frames should be set) |
| 69 | // CHECK: {{^}}[[MASTER_ID]]: task level 1: parallel_id=[[PARALLEL_ID_0]], task_id=[[TASK_ID_1]] |
| 70 | // CHECK-SAME: exit_frame=[[EXPLICIT_TASK_FRAME_EXIT]] |
| 71 | // CHECK-SAME: reenter_frame=[[EXPLICIT_TASK_FRAME_ENTER]] |
| 72 | // CHECK-SAME: task_type=ompt_task_explicit |
| 73 | |
| 74 | // region 0's implicit task information (both exit and enter frames should be set) |
| 75 | // CHECK: {{^}}[[MASTER_ID]]: task level 2: parallel_id=[[PARALLEL_ID_0]], task_id=[[TASK_ID_0]] |
| 76 | // CHECK-SAME: exit_frame=[[REGION_0_FRAME_EXIT]] |
| 77 | // CHECK-SAME: reenter_frame=[[REGION_0_FRAME_ENTER]] |
| 78 | // CHECK-SAME: task_type=ompt_task_implicit |
| 79 | |
| 80 | // region 0's initial task information (both exit and enter frames should be set) |
| 81 | // CHECK: {{^}}[[MASTER_ID]]: task level 3: parallel_id=[[INITIAL_PARALLEL_ID]], task_id=[[INITIAL_TASK_ID]] |
| 82 | // CHECK-SAME: exit_frame=[[NULL]] |
| 83 | // CHECK-SAME: reenter_frame=[[INITIAL_TASK_FRAME_ENTER]] |
| 84 | // CHECK-SAME: task_type=ompt_task_initial |
| 85 | |
| 86 | return 0; |
| 87 | } |