Skip to content

Commit 98dd188

Browse files
[OpenMP][Test][NFC] output tool data as hex to improve readibility (llvm#152757)
Using hex format allows to better interpret IDs: the first digits represent the thread number, the last digits represent the ID within a thread The main change is in callback.h: PRIu64 -> PRIx64 The patch also guards RUN/CHECK lines in openmp/runtime/tests/ompt with clang-format on/off comments and clang-formats the directory. --------- Co-authored-by: Kaloyan Ignatov <[email protected]>
1 parent ce5276f commit 98dd188

File tree

111 files changed

+1865
-1659
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+1865
-1659
lines changed

openmp/runtime/test/ompt/callback.h

Lines changed: 459 additions & 512 deletions
Large diffs are not rendered by default.
Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,46 @@
1+
// clang-format off
12
// RUN: %libomp-compile && env OMP_CANCELLATION=true %libomp-run | %sort-threads | FileCheck %s
23
// REQUIRES: ompt
34
// Current GOMP interface implementation does not support cancellation
45
// XFAIL: gcc
6+
// clang-format on
57

68
#include "callback.h"
79
#include "omp.h"
810

911
int main() {
10-
#pragma omp parallel num_threads(2)
12+
#pragma omp parallel num_threads(2)
1113
{
1214
if (omp_get_thread_num() == 0) {
1315
print_fuzzy_address_blocks(get_ompt_label_address(1));
14-
#pragma omp cancel parallel
16+
#pragma omp cancel parallel
1517
define_ompt_label(1);
16-
// We cannot print at this location because the parallel region is cancelled!
18+
// We cannot print at this location because the parallel region is
19+
// cancelled!
1720
} else {
1821
delay(100);
1922
print_fuzzy_address_blocks(get_ompt_label_address(2));
20-
#pragma omp cancellation point parallel
23+
#pragma omp cancellation point parallel
2124
define_ompt_label(2);
22-
// We cannot print at this location because the parallel region is cancelled!
25+
// We cannot print at this location because the parallel region is
26+
// cancelled!
2327
}
2428
}
2529

30+
// clang-format off
2631
// Check if libomp supports the callbacks for this test.
2732
// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_implicit_task'
2833
// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_cancel'
2934

3035
// CHECK: {{^}}0: NULL_POINTER=[[NULL:.*$]]
31-
// CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_initial_task_begin: parallel_id={{[0-9]+}}, task_id={{[0-9]+}}, actual_parallelism=1, index=1, flags=1
32-
// CHECK-DAG: {{^}}[[MASTER_ID]]: ompt_event_cancel: task_data=[[TASK_ID:[0-9]+]], flags=ompt_cancel_parallel|ompt_cancel_activated=17, codeptr_ra=[[RETURN_ADDRESS:(0x)?[0-f]+]]{{[0-f][0-f]}}
36+
// CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_initial_task_begin: parallel_id={{[0-f]+}}, task_id={{[0-f]+}}, actual_parallelism=1, index=1, flags=1
37+
// CHECK-DAG: {{^}}[[MASTER_ID]]: ompt_event_cancel: task_id=[[TASK_ID:[0-f]+]], flags=ompt_cancel_parallel|ompt_cancel_activated=17, codeptr_ra=[[RETURN_ADDRESS:(0x)?[0-f]+]]{{[0-f][0-f]}}
3338
// CHECK-DAG: {{^}}[[MASTER_ID]]: fuzzy_address={{.*}}[[RETURN_ADDRESS]]
3439

3540
// CHECK: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_implicit_task_begin
36-
// CHECK-DAG: {{^}}[[THREAD_ID]]: ompt_event_cancel: task_data=[[TASK_ID:[0-9]+]], flags=ompt_cancel_parallel|ompt_cancel_detected=33, codeptr_ra=[[OTHER_RETURN_ADDRESS:(0x)?[0-f]+]]{{[0-f][0-f]}}
41+
// CHECK-DAG: {{^}}[[THREAD_ID]]: ompt_event_cancel: task_id=[[TASK_ID:[0-f]+]], flags=ompt_cancel_parallel|ompt_cancel_detected=33, codeptr_ra=[[OTHER_RETURN_ADDRESS:(0x)?[0-f]+]]{{[0-f][0-f]}}
3742
// CHECK-DAG: {{^}}[[THREAD_ID]]: fuzzy_address={{.*}}[[OTHER_RETURN_ADDRESS]]
43+
// clang-format on
3844

3945
return 0;
4046
}
Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,65 @@
1+
// clang-format off
12
// RUN: %libomp-compile && env OMP_CANCELLATION=true %libomp-run | %sort-threads | FileCheck %s
23
// REQUIRES: ompt
34
// UNSUPPORTED: clang-3, clang-4.0.0
45
// Current GOMP interface implementation does not support cancellation; icc 16 has a bug
56
// XFAIL: gcc, icc-16
7+
// clang-format on
68

79
#include "callback.h"
8-
#include <unistd.h>
10+
#include <unistd.h>
911
#include <stdio.h>
1012

11-
int main()
12-
{
13-
int condition=0;
14-
#pragma omp parallel num_threads(2)
13+
int main() {
14+
int condition = 0;
15+
#pragma omp parallel num_threads(2)
1516
{}
1617

1718
print_frame(0);
18-
#pragma omp parallel num_threads(2)
19+
#pragma omp parallel num_threads(2)
1920
{
20-
#pragma omp master
21+
#pragma omp master
2122
{
22-
#pragma omp taskgroup
23+
#pragma omp taskgroup
2324
{
24-
#pragma omp task shared(condition)
25+
#pragma omp task shared(condition)
2526
{
2627
printf("start execute task 1\n");
2728
OMPT_SIGNAL(condition);
28-
OMPT_WAIT(condition,2);
29-
#pragma omp cancellation point taskgroup
29+
OMPT_WAIT(condition, 2);
30+
#pragma omp cancellation point taskgroup
3031
printf("end execute task 1\n");
3132
}
32-
#pragma omp task shared(condition)
33+
#pragma omp task shared(condition)
3334
{
3435
printf("start execute task 2\n");
3536
OMPT_SIGNAL(condition);
36-
OMPT_WAIT(condition,2);
37-
#pragma omp cancellation point taskgroup
37+
OMPT_WAIT(condition, 2);
38+
#pragma omp cancellation point taskgroup
3839
printf("end execute task 2\n");
3940
}
40-
#pragma omp task shared(condition)
41+
#pragma omp task shared(condition)
4142
{
4243
printf("start execute task 3\n");
4344
OMPT_SIGNAL(condition);
44-
OMPT_WAIT(condition,2);
45-
#pragma omp cancellation point taskgroup
45+
OMPT_WAIT(condition, 2);
46+
#pragma omp cancellation point taskgroup
4647
printf("end execute task 3\n");
4748
}
48-
#pragma omp task if(0) shared(condition)
49+
#pragma omp task if (0) shared(condition)
4950
{
5051
printf("start execute task 4\n");
51-
OMPT_WAIT(condition,1);
52-
#pragma omp cancel taskgroup
52+
OMPT_WAIT(condition, 1);
53+
#pragma omp cancel taskgroup
5354
printf("end execute task 4\n");
5455
}
5556
OMPT_SIGNAL(condition);
5657
}
5758
}
58-
#pragma omp barrier
59+
#pragma omp barrier
5960
}
6061

62+
// clang-format off
6163
// Check if libomp supports the callbacks for this test.
6264
// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_masked'
6365
// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_task_create'
@@ -67,24 +69,25 @@ int main()
6769

6870
// CHECK: {{^}}0: NULL_POINTER=[[NULL:.*$]]
6971
// CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_masked_begin:
70-
// CHECK-SAME: parallel_id=[[PARALLEL_ID:[0-9]+]],
71-
// CHECK-SAME: task_id=[[PARENT_TASK_ID:[0-9]+]],
72+
// CHECK-SAME: parallel_id=[[PARALLEL_ID:[0-f]+]],
73+
// CHECK-SAME: task_id=[[PARENT_TASK_ID:[0-f]+]],
7274
// CHECK-SAME: codeptr_ra={{(0x)?[0-f]*}}
7375

74-
// CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create: parent_task_id=[[PARENT_TASK_ID]], parent_task_frame.exit={{(0x)?[0-f]*}}, parent_task_frame.reenter={{(0x)?[0-f]*}}, new_task_id=[[FIRST_TASK_ID:[0-9]+]], codeptr_ra={{(0x)?[0-f]*}}, task_type=ompt_task_explicit=4, has_dependences=no
75-
// CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create: parent_task_id=[[PARENT_TASK_ID]], parent_task_frame.exit={{(0x)?[0-f]*}}, parent_task_frame.reenter={{(0x)?[0-f]*}}, new_task_id=[[SECOND_TASK_ID:[0-9]+]], codeptr_ra={{(0x)?[0-f]*}}, task_type=ompt_task_explicit=4, has_dependences=no
76-
// CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create: parent_task_id=[[PARENT_TASK_ID]], parent_task_frame.exit={{(0x)?[0-f]*}}, parent_task_frame.reenter={{(0x)?[0-f]*}}, new_task_id=[[THIRD_TASK_ID:[0-9]+]], codeptr_ra={{(0x)?[0-f]*}}, task_type=ompt_task_explicit=4, has_dependences=no
76+
// CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create: parent_task_id=[[PARENT_TASK_ID]], parent_task_frame.exit={{(0x)?[0-f]*}}, parent_task_frame.reenter={{(0x)?[0-f]*}}, new_task_id=[[FIRST_TASK_ID:[0-f]+]], codeptr_ra={{(0x)?[0-f]*}}, task_type=ompt_task_explicit=4, has_dependences=no
77+
// CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create: parent_task_id=[[PARENT_TASK_ID]], parent_task_frame.exit={{(0x)?[0-f]*}}, parent_task_frame.reenter={{(0x)?[0-f]*}}, new_task_id=[[SECOND_TASK_ID:[0-f]+]], codeptr_ra={{(0x)?[0-f]*}}, task_type=ompt_task_explicit=4, has_dependences=no
78+
// CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create: parent_task_id=[[PARENT_TASK_ID]], parent_task_frame.exit={{(0x)?[0-f]*}}, parent_task_frame.reenter={{(0x)?[0-f]*}}, new_task_id=[[THIRD_TASK_ID:[0-f]+]], codeptr_ra={{(0x)?[0-f]*}}, task_type=ompt_task_explicit=4, has_dependences=no
7779

78-
// CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create: parent_task_id=[[PARENT_TASK_ID]], parent_task_frame.exit={{(0x)?[0-f]*}}, parent_task_frame.reenter={{(0x)?[0-f]*}}, new_task_id=[[CANCEL_TASK_ID:[0-9]+]], codeptr_ra={{(0x)?[0-f]*}}, task_type=ompt_task_explicit|ompt_task_undeferred=134217732, has_dependences=no
80+
// CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create: parent_task_id=[[PARENT_TASK_ID]], parent_task_frame.exit={{(0x)?[0-f]*}}, parent_task_frame.reenter={{(0x)?[0-f]*}}, new_task_id=[[CANCEL_TASK_ID:[0-f]+]], codeptr_ra={{(0x)?[0-f]*}}, task_type=ompt_task_explicit|ompt_task_undeferred=134217732, has_dependences=no
7981
// CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_schedule: first_task_id=[[PARENT_TASK_ID]], second_task_id=[[CANCEL_TASK_ID]], prior_task_status=ompt_task_switch=7
80-
// CHECK: {{^}}[[MASTER_ID]]: ompt_event_cancel: task_data=[[CANCEL_TASK_ID]], flags=ompt_cancel_taskgroup|ompt_cancel_activated=24, codeptr_ra={{(0x)?[0-f]*}}
82+
// CHECK: {{^}}[[MASTER_ID]]: ompt_event_cancel: task_id=[[CANCEL_TASK_ID]], flags=ompt_cancel_taskgroup|ompt_cancel_activated=24, codeptr_ra={{(0x)?[0-f]*}}
8183
// CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_schedule: first_task_id=[[CANCEL_TASK_ID]], second_task_id=[[PARENT_TASK_ID]], prior_task_status=ompt_task_cancel=3
8284

83-
// CHECK-DAG: {{^}}{{[0-9]+}}: ompt_event_cancel: task_data={{[0-9]+}}, flags=ompt_cancel_taskgroup|ompt_cancel_discarded_task=72, codeptr_ra=[[NULL]]
84-
// CHECK-DAG: {{^}}{{[0-9]+}}: ompt_event_cancel: task_data={{[0-9]+}}, flags=ompt_cancel_taskgroup|ompt_cancel_discarded_task=72, codeptr_ra=[[NULL]]
85+
// CHECK-DAG: {{^}}{{[0-9]+}}: ompt_event_cancel: task_id={{[0-f]+}}, flags=ompt_cancel_taskgroup|ompt_cancel_discarded_task=72, codeptr_ra=[[NULL]]
86+
// CHECK-DAG: {{^}}{{[0-9]+}}: ompt_event_cancel: task_id={{[0-f]+}}, flags=ompt_cancel_taskgroup|ompt_cancel_discarded_task=72, codeptr_ra=[[NULL]]
8587

8688
// CHECK-DAG: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_thread_begin: thread_type=ompt_thread_worker=2, thread_id=[[THREAD_ID]]
87-
// CHECK-DAG: {{^}}[[THREAD_ID]]: ompt_event_cancel: task_data={{[0-9]+}}, flags=ompt_cancel_taskgroup|ompt_cancel_detected=40, codeptr_ra={{(0x)?[0-f]*}}
89+
// CHECK-DAG: {{^}}[[THREAD_ID]]: ompt_event_cancel: task_id={{[0-f]+}}, flags=ompt_cancel_taskgroup|ompt_cancel_detected=40, codeptr_ra={{(0x)?[0-f]*}}
90+
// clang-format on
8891

8992
return 0;
9093
}
Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,65 @@
1+
// clang-format off
12
// RUN: %libomp-compile && env OMP_CANCELLATION=true %libomp-run | %sort-threads | FileCheck %s
23
// REQUIRES: ompt
34
// Current GOMP interface implementation does not support cancellation; icc 16 does not distinguish between sections and loops
45
// XFAIL: icc-16
6+
// clang-format on
57

68
#include "callback.h"
79
#include <unistd.h>
810

9-
int main()
10-
{
11-
int condition=0;
12-
#pragma omp parallel num_threads(2)
11+
int main() {
12+
int condition = 0;
13+
#pragma omp parallel num_threads(2)
1314
{
1415
int x = 0;
1516
int i;
16-
#pragma omp for
17-
for(i = 0; i < 2; i++)
18-
{
19-
if(i == 0)
20-
{
17+
#pragma omp for
18+
for (i = 0; i < 2; i++) {
19+
if (i == 0) {
2120
x++;
2221
OMPT_SIGNAL(condition);
23-
#pragma omp cancel for
24-
}
25-
else
26-
{
22+
#pragma omp cancel for
23+
} else {
2724
x++;
28-
OMPT_WAIT(condition,1);
25+
OMPT_WAIT(condition, 1);
2926
delay(10000);
30-
#pragma omp cancellation point for
27+
#pragma omp cancellation point for
3128
}
3229
}
3330
}
34-
#pragma omp parallel num_threads(2)
31+
#pragma omp parallel num_threads(2)
3532
{
36-
#pragma omp sections
33+
#pragma omp sections
3734
{
38-
#pragma omp section
35+
#pragma omp section
3936
{
4037
OMPT_SIGNAL(condition);
41-
#pragma omp cancel sections
38+
#pragma omp cancel sections
4239
}
43-
#pragma omp section
40+
#pragma omp section
4441
{
45-
OMPT_WAIT(condition,2);
42+
OMPT_WAIT(condition, 2);
4643
delay(10000);
47-
#pragma omp cancellation point sections
44+
#pragma omp cancellation point sections
4845
}
4946
}
5047
}
5148

52-
49+
// clang-format off
5350
// Check if libomp supports the callbacks for this test.
5451
// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_implicit_task'
5552
// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_cancel'
5653

5754
// CHECK: {{^}}0: NULL_POINTER=[[NULL:.*$]]
58-
// CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_initial_task_begin: parallel_id={{[0-9]+}}, task_id={{[0-9]+}}, actual_parallelism=1, index=1, flags=1
55+
// CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_initial_task_begin: parallel_id={{[0-f]+}}, task_id={{[0-f]+}}, actual_parallelism=1, index=1, flags=1
5956

6057
// cancel for and sections
61-
// CHECK: {{^}}[[MASTER_ID]]: ompt_event_cancel: task_data=[[TASK_ID:[0-9]+]], flags=ompt_cancel_loop|ompt_cancel_activated=20, codeptr_ra={{(0x)?[0-f]*}}
62-
// CHECK: {{^}}[[MASTER_ID]]: ompt_event_cancel: task_data=[[TASK_ID:[0-9]+]], flags=ompt_cancel_sections|ompt_cancel_{{activated=18|detected=34}}, codeptr_ra={{(0x)?[0-f]*}}
63-
// CHECK: {{^}}[[OTHER_THREAD_ID:[0-9]+]]: ompt_event_cancel: task_data=[[TASK_ID:[0-9]+]], flags=ompt_cancel_loop|ompt_cancel_detected=36, codeptr_ra={{(0x)?[0-f]*}}
64-
// CHECK: {{^}}[[OTHER_THREAD_ID:[0-9]+]]: ompt_event_cancel: task_data=[[TASK_ID:[0-9]+]], flags=ompt_cancel_sections|ompt_cancel_{{activated=18|detected=34}}, codeptr_ra={{(0x)?[0-f]*}}
58+
// CHECK: {{^}}[[MASTER_ID]]: ompt_event_cancel: task_id=[[TASK_ID:[0-f]+]], flags=ompt_cancel_loop|ompt_cancel_activated=20, codeptr_ra={{(0x)?[0-f]*}}
59+
// CHECK: {{^}}[[MASTER_ID]]: ompt_event_cancel: task_id=[[TASK_ID:[0-f]+]], flags=ompt_cancel_sections|ompt_cancel_{{activated=18|detected=34}}, codeptr_ra={{(0x)?[0-f]*}}
60+
// CHECK: {{^}}[[OTHER_THREAD_ID:[0-9]+]]: ompt_event_cancel: task_id=[[TASK_ID:[0-f]+]], flags=ompt_cancel_loop|ompt_cancel_detected=36, codeptr_ra={{(0x)?[0-f]*}}
61+
// CHECK: {{^}}[[OTHER_THREAD_ID:[0-9]+]]: ompt_event_cancel: task_id=[[TASK_ID:[0-f]+]], flags=ompt_cancel_sections|ompt_cancel_{{activated=18|detected=34}}, codeptr_ra={{(0x)?[0-f]*}}
62+
// clang-format on
6563

6664
return 0;
6765
}

openmp/runtime/test/ompt/loadtool/tool_available.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// clang-format off
12
// The OpenMP standard defines 3 ways of providing ompt_start_tool:
23

34
// RUN: mkdir -p %t.tool_dir
@@ -74,6 +75,7 @@
7475

7576

7677
// REQUIRES: ompt
78+
// clang-format on
7779

7880
/*
7981
* This file contains code for an OMPT shared library tool to be
@@ -82,6 +84,7 @@
8284
* -DCODE enables the code for the executable during compilation
8385
*/
8486

87+
// clang-format off
8588
// Check if libomp supports the callbacks for this test.
8689
// CHECK-NOT: {{^}}0: Could not register callback
8790

@@ -99,21 +102,23 @@
99102
// TOOLLIB-SAME: [[PARENTPATH]]/tool.so... Success.
100103
// TOOLLIB-NEXT: Tool was started and is using the OMPT interface.
101104
// TOOLLIB-NEXT: ----- END LOGGING OF TOOL REGISTRATION -----
105+
// clang-format on
102106

103107
#ifdef CODE
104108
#include "omp.h"
105109

106-
int main()
107-
{
108-
#pragma omp parallel num_threads(2)
110+
int main() {
111+
#pragma omp parallel num_threads(2)
109112
{
110113
}
111114

115+
// clang-format off
112116
// CHECK-NOT: ----- START LOGGING OF TOOL REGISTRATION -----
113117
// CHECK-NOT: ----- END LOGGING OF TOOL REGISTRATION -----
114118

115119
// CHECK: {{^}}0: NULL_POINTER=[[NULL:.*$]]
116120
// CHECK: {{^}}0: ompt_event_runtime_shutdown
121+
// clang-format on
117122

118123
return 0;
119124
}
@@ -127,20 +132,18 @@ int main()
127132

128133
int ompt_initialize(ompt_function_lookup_t lookup, int initial_device_num,
129134
ompt_data_t *tool_data) {
130-
printf("0: NULL_POINTER=%p\n", (void*)NULL);
131-
return 1; //success
135+
printf("0: NULL_POINTER=%p\n", (void *)NULL);
136+
return 1; // success
132137
}
133138

134-
void ompt_finalize(ompt_data_t* tool_data)
135-
{
139+
void ompt_finalize(ompt_data_t *tool_data) {
136140
printf("0: ompt_event_runtime_shutdown\n");
137141
}
138142

139-
ompt_start_tool_result_t* ompt_start_tool(
140-
unsigned int omp_version,
141-
const char *runtime_version)
142-
{
143-
static ompt_start_tool_result_t ompt_start_tool_result = {&ompt_initialize,&ompt_finalize, 0};
143+
ompt_start_tool_result_t *ompt_start_tool(unsigned int omp_version,
144+
const char *runtime_version) {
145+
static ompt_start_tool_result_t ompt_start_tool_result = {&ompt_initialize,
146+
&ompt_finalize, 0};
144147
return &ompt_start_tool_result;
145148
}
146149
#endif /* TOOL */

0 commit comments

Comments
 (0)