1// RUN: %libomp-compile-and-run | %sort-threads | FileCheck %s
2// REQUIRES: ompt
3// XFAIL: gcc
4// GCC doesn't call runtime for static schedule
5
6#include "callback.h"
7
8#define WORK_SIZE 64
9
10int main() {
11 int i;
12 int wait_s = 0;
13
14#pragma omp parallel num_threads(4)
15 {
16 int wait_id = 0;
17 int team_size = omp_get_num_threads();
18#pragma omp for schedule(static, WORK_SIZE / 4)
19 for (i = 0; i < WORK_SIZE; i++) {}
20
21#pragma omp for schedule(dynamic)
22 for (i = 0; i < WORK_SIZE; i++) {
23 if (wait_id == 0) {
24 // Wait until every thread has at least one iteration assigned
25 OMPT_SIGNAL(wait_s);
26 OMPT_WAIT(wait_s, team_size);
27 wait_id++;
28 }
29 }
30
31#pragma omp for schedule(guided)
32 for (i = 0; i < WORK_SIZE; i++) {
33 if (wait_id == 1) {
34 // Wait until every thread has at least one iteration assigned
35 OMPT_SIGNAL(wait_s);
36 OMPT_WAIT(wait_s, 2 * team_size);
37 wait_id++;
38 }
39 }
40 }
41
42 return 0;
43}
44
45// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_parallel_begin'
46// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_implicit_task'
47// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_work'
48// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_dispatch'
49
50// CHECK: 0: NULL_POINTER=[[NULL:.*$]]
51// CHECK: {{^}}[[THREAD_ID0:[0-9]+]]: ompt_event_parallel_begin:
52// CHECK-SAME: parallel_id=[[PARALLEL_ID:[0-9]+]]
53
54// Each thread should have at least one ws-loop-chunk-begin event for each
55// for loop.
56
57// CHECK: {{^}}[[THREAD_ID0]]: ompt_event_implicit_task_begin:
58// CHECK-SAME: task_id=[[TASK_ID0:[0-9]+]]
59// CHECK: {{^}}[[THREAD_ID0]]: ompt_event_loop_begin:
60// CHECK-SAME: parallel_id=[[PARALLEL_ID]], parent_task_id=[[TASK_ID0]]
61// CHECK: {{^}}[[THREAD_ID0]]: ompt_event_ws_loop_chunk_begin:
62// CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[TASK_ID0]]
63// CHECK-SAME: chunk_start={{[0-9]+}}, chunk_iterations=16
64// CHECK: {{^}}[[THREAD_ID0]]: ompt_event_loop_begin:
65// CHECK-SAME: parallel_id=[[PARALLEL_ID]], parent_task_id=[[TASK_ID0]]
66// CHECK: {{^}}[[THREAD_ID0]]: ompt_event_ws_loop_chunk_begin:
67// CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[TASK_ID0]]
68// CHECK-SAME: chunk_start={{[0-9]+}}, chunk_iterations=1
69// CHECK: {{^}}[[THREAD_ID0]]: ompt_event_loop_begin:
70// CHECK-SAME: parallel_id=[[PARALLEL_ID]], parent_task_id=[[TASK_ID0]]
71// CHECK: {{^}}[[THREAD_ID0]]: ompt_event_ws_loop_chunk_begin:
72// CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[TASK_ID0]]
73// CHECK-SAME: chunk_start={{[0-9]+}}, chunk_iterations={{[1-9][0-9]*}}
74
75// CHECK: {{^}}[[THREAD_ID1:[0-9]+]]: ompt_event_implicit_task_begin:
76// CHECK-SAME: task_id=[[TASK_ID1:[0-9]+]]
77// CHECK: {{^}}[[THREAD_ID1]]: ompt_event_loop_begin:
78// CHECK-SAME: parallel_id=[[PARALLEL_ID]], parent_task_id=[[TASK_ID1]]
79// CHECK: {{^}}[[THREAD_ID1]]: ompt_event_ws_loop_chunk_begin:
80// CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[TASK_ID1]]
81// CHECK-SAME: chunk_start={{[0-9]+}}, chunk_iterations=16
82// CHECK: {{^}}[[THREAD_ID1]]: ompt_event_loop_begin:
83// CHECK-SAME: parallel_id=[[PARALLEL_ID]], parent_task_id=[[TASK_ID1]]
84// CHECK: {{^}}[[THREAD_ID1]]: ompt_event_ws_loop_chunk_begin:
85// CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[TASK_ID1]]
86// CHECK-SAME: chunk_start={{[0-9]+}}, chunk_iterations=1
87// CHECK: {{^}}[[THREAD_ID1]]: ompt_event_loop_begin:
88// CHECK-SAME: parallel_id=[[PARALLEL_ID]], parent_task_id=[[TASK_ID1]]
89// CHECK: {{^}}[[THREAD_ID1]]: ompt_event_ws_loop_chunk_begin:
90// CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[TASK_ID1]]
91// CHECK-SAME: chunk_start={{[0-9]+}}, chunk_iterations={{[1-9][0-9]*}}
92
93// CHECK: {{^}}[[THREAD_ID2:[0-9]+]]: ompt_event_implicit_task_begin:
94// CHECK-SAME: task_id=[[TASK_ID2:[0-9]+]]
95// CHECK: {{^}}[[THREAD_ID2]]: ompt_event_loop_begin:
96// CHECK-SAME: parallel_id=[[PARALLEL_ID]], parent_task_id=[[TASK_ID2]]
97// CHECK: {{^}}[[THREAD_ID2]]: ompt_event_ws_loop_chunk_begin:
98// CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[TASK_ID2]]
99// CHECK-SAME: chunk_start={{[0-9]+}}, chunk_iterations=16
100// CHECK: {{^}}[[THREAD_ID2]]: ompt_event_loop_begin:
101// CHECK-SAME: parallel_id=[[PARALLEL_ID]], parent_task_id=[[TASK_ID2]]
102// CHECK: {{^}}[[THREAD_ID2]]: ompt_event_ws_loop_chunk_begin:
103// CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[TASK_ID2]]
104// CHECK-SAME: chunk_start={{[0-9]+}}, chunk_iterations=1
105// CHECK: {{^}}[[THREAD_ID2]]: ompt_event_loop_begin:
106// CHECK-SAME: parallel_id=[[PARALLEL_ID]], parent_task_id=[[TASK_ID2]]
107// CHECK: {{^}}[[THREAD_ID2]]: ompt_event_ws_loop_chunk_begin:
108// CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[TASK_ID2]]
109// CHECK-SAME: chunk_start={{[0-9]+}}, chunk_iterations={{[1-9][0-9]*}}
110
111// CHECK: {{^}}[[THREAD_ID3:[0-9]+]]: ompt_event_implicit_task_begin:
112// CHECK-SAME: task_id=[[TASK_ID3:[0-9]+]]
113// CHECK: {{^}}[[THREAD_ID3]]: ompt_event_loop_begin:
114// CHECK-SAME: parallel_id=[[PARALLEL_ID]], parent_task_id=[[TASK_ID3]]
115// CHECK: {{^}}[[THREAD_ID3]]: ompt_event_ws_loop_chunk_begin:
116// CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[TASK_ID3]]
117// CHECK-SAME: chunk_start={{[0-9]+}}, chunk_iterations=16
118// CHECK: {{^}}[[THREAD_ID3]]: ompt_event_loop_begin:
119// CHECK-SAME: parallel_id=[[PARALLEL_ID]], parent_task_id=[[TASK_ID3]]
120// CHECK: {{^}}[[THREAD_ID3]]: ompt_event_ws_loop_chunk_begin:
121// CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[TASK_ID3]]
122// CHECK-SAME: chunk_start={{[0-9]+}}, chunk_iterations=1
123// CHECK: {{^}}[[THREAD_ID3]]: ompt_event_loop_begin:
124// CHECK-SAME: parallel_id=[[PARALLEL_ID]], parent_task_id=[[TASK_ID3]]
125// CHECK: {{^}}[[THREAD_ID3]]: ompt_event_ws_loop_chunk_begin:
126// CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[TASK_ID3]]
127// CHECK-SAME: chunk_start={{[0-9]+}}, chunk_iterations={{[1-9][0-9]*}}
128

source code of openmp/runtime/test/ompt/worksharing/for/loop_dispatch.c