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