LLVM OpenMP
22.0.0git
runtime
test
ompt
synchronization
reduction
tree_reduce.c
Go to the documentation of this file.
1
// clang-format off
2
// RUN: %libomp-compile-and-run | %sort-threads | FileCheck %s
3
// RUN: %libomp-compile -DNOWAIT && %libomp-run | %sort-threads | FileCheck %s
4
// REQUIRES: ompt
5
// UNSUPPORTED: gcc
6
// clang-format on
7
#include "
callback.h
"
8
#include <omp.h>
9
10
#ifdef NOWAIT
11
#define FOR_CLAUSE nowait
12
#else
13
#define FOR_CLAUSE
14
#endif
15
16
int
main
() {
17
int
sum
= 0,
a
= 0,
b
= 0;
18
int
i
;
19
#pragma omp parallel num_threads(5)
20
// for 32-bit architecture we need at least 3 variables to trigger tree
21
#pragma omp for reduction(+ : sum, a, b) FOR_CLAUSE
22
for
(
i
= 0;
i
< 10000;
i
++) {
23
a
=
b
=
sum
+=
i
;
24
}
25
26
printf(
"%i\n"
,
sum
);
27
// clang-format off
28
// CHECK: 0: NULL_POINTER=[[NULL:.*$]]
29
30
// CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_parallel_begin:
31
// CHECK-SAME: parallel_id=[[PARALLEL_ID:[0-f]+]]
32
// CHECK: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_begin:
33
// CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[TASK_ID:[0-f]+]]
34
35
// order and distribution to threads not determined
36
// CHECK: {{^}}{{[0-f]+}}: ompt_event_reduction_begin:
37
// CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id={{[0-f]+}}
38
// CHECK: {{^}}{{[0-f]+}}: ompt_event_reduction_end:
39
// CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id={{[0-f]+}}
40
// CHECK: {{^}}{{[0-f]+}}: ompt_event_reduction_begin:
41
// CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id={{[0-f]+}}
42
// CHECK: {{^}}{{[0-f]+}}: ompt_event_reduction_end:
43
// CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id={{[0-f]+}}
44
// CHECK: {{^}}{{[0-f]+}}: ompt_event_reduction_begin:
45
// CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id={{[0-f]+}}
46
// CHECK: {{^}}{{[0-f]+}}: ompt_event_reduction_end:
47
// CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id={{[0-f]+}}
48
// CHECK: {{^}}{{[0-f]+}}: ompt_event_reduction_begin:
49
// CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id={{[0-f]+}}
50
// CHECK: {{^}}{{[0-f]+}}: ompt_event_reduction_end:
51
// CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id={{[0-f]+}}
52
// clang-format on
53
54
return
0;
55
}
callback.h
b
int b
Definition
kmp_set_dispatch_buf.c:27
i
#define i
Definition
kmp_stub.cpp:87
a
int a
Definition
llvm-issue-80664.c:20
sum
int sum
Definition
omp_for_schedule_runtime.c:19
main
int main()
Definition
tree_reduce.c:16
Generated on
for LLVM OpenMP by
1.14.0