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

source code of openmp/runtime/test/ompt/parallel/nested_serialized_task_frames.c