Skip to content

Commit 9d4dd72

Browse files
[SYCL][E2E] Minor refactor for xpti collector tests (#11038)
1 parent 4b321e9 commit 9d4dd72

File tree

2 files changed

+33
-140
lines changed

2 files changed

+33
-140
lines changed

sycl/test-e2e/XPTI/Inputs/memory_info_collector.cpp

Lines changed: 22 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -30,116 +30,40 @@ XPTI_CALLBACK_API void xptiTraceInit(unsigned int MajorVersion,
3030
std::cout << "xptiTraceInit: Stream Name = " << StreamName << "\n";
3131
std::string_view NameView{StreamName};
3232

33+
using type = xpti::trace_point_type_t;
3334
if (NameView == "sycl.experimental.mem_alloc") {
3435
uint8_t StreamID = xptiRegisterStream(StreamName);
35-
xptiRegisterCallback(
36-
StreamID,
37-
static_cast<uint16_t>(xpti::trace_point_type_t::mem_alloc_begin),
38-
memCallback);
39-
xptiRegisterCallback(
40-
StreamID,
41-
static_cast<uint16_t>(xpti::trace_point_type_t::mem_alloc_end),
42-
memCallback);
43-
xptiRegisterCallback(
44-
StreamID,
45-
static_cast<uint16_t>(xpti::trace_point_type_t::mem_release_begin),
46-
memCallback);
47-
xptiRegisterCallback(
48-
StreamID,
49-
static_cast<uint16_t>(xpti::trace_point_type_t::mem_release_end),
50-
memCallback);
36+
for (type t : std::initializer_list<type>{
37+
type::mem_alloc_begin, type::mem_alloc_end,
38+
type::mem_release_begin, type::mem_release_end})
39+
xptiRegisterCallback(StreamID, static_cast<uint16_t>(t), memCallback);
5140
}
5241

42+
auto buffer_image_traces = std::initializer_list<type>{
43+
type::offload_alloc_memory_object_construct,
44+
type::offload_alloc_memory_object_associate,
45+
type::offload_alloc_memory_object_release,
46+
type::offload_alloc_memory_object_destruct, type::offload_alloc_accessor};
5347
if (NameView == "sycl.experimental.buffer") {
5448
uint8_t StreamID = xptiRegisterStream(StreamName);
55-
xptiRegisterCallback(
56-
StreamID,
57-
static_cast<uint16_t>(
58-
xpti::trace_point_type_t::offload_alloc_memory_object_construct),
59-
syclBufferCallback);
60-
xptiRegisterCallback(
61-
StreamID,
62-
static_cast<uint16_t>(
63-
xpti::trace_point_type_t::offload_alloc_memory_object_associate),
64-
syclBufferCallback);
65-
xptiRegisterCallback(
66-
StreamID,
67-
static_cast<uint16_t>(
68-
xpti::trace_point_type_t::offload_alloc_memory_object_release),
69-
syclBufferCallback);
70-
xptiRegisterCallback(
71-
StreamID,
72-
static_cast<uint16_t>(
73-
xpti::trace_point_type_t::offload_alloc_memory_object_destruct),
74-
syclBufferCallback);
75-
xptiRegisterCallback(
76-
StreamID,
77-
static_cast<uint16_t>(xpti::trace_point_type_t::offload_alloc_accessor),
78-
syclBufferCallback);
49+
for (type t : buffer_image_traces)
50+
xptiRegisterCallback(StreamID, static_cast<uint16_t>(t),
51+
syclBufferCallback);
7952
}
8053
if (NameView == "sycl.experimental.image") {
8154
uint8_t StreamID = xptiRegisterStream(StreamName);
82-
xptiRegisterCallback(
83-
StreamID,
84-
static_cast<uint16_t>(
85-
xpti::trace_point_type_t::offload_alloc_memory_object_construct),
86-
syclImageCallback);
87-
xptiRegisterCallback(
88-
StreamID,
89-
static_cast<uint16_t>(
90-
xpti::trace_point_type_t::offload_alloc_memory_object_associate),
91-
syclImageCallback);
92-
xptiRegisterCallback(
93-
StreamID,
94-
static_cast<uint16_t>(
95-
xpti::trace_point_type_t::offload_alloc_memory_object_release),
96-
syclImageCallback);
97-
xptiRegisterCallback(
98-
StreamID,
99-
static_cast<uint16_t>(
100-
xpti::trace_point_type_t::offload_alloc_memory_object_destruct),
101-
syclImageCallback);
102-
xptiRegisterCallback(
103-
StreamID,
104-
static_cast<uint16_t>(xpti::trace_point_type_t::offload_alloc_accessor),
105-
syclImageCallback);
55+
for (type t : buffer_image_traces)
56+
xptiRegisterCallback(StreamID, static_cast<uint16_t>(t),
57+
syclImageCallback);
10658
}
10759
if (NameView == "sycl") {
10860
uint8_t StreamID = xptiRegisterStream(StreamName);
109-
xptiRegisterCallback(
110-
StreamID, static_cast<uint16_t>(xpti::trace_point_type_t::graph_create),
111-
syclCallback);
112-
xptiRegisterCallback(
113-
StreamID, static_cast<uint16_t>(xpti::trace_point_type_t::node_create),
114-
syclCallback);
115-
xptiRegisterCallback(
116-
StreamID, static_cast<uint16_t>(xpti::trace_point_type_t::edge_create),
117-
syclCallback);
118-
xptiRegisterCallback(
119-
StreamID, static_cast<uint16_t>(xpti::trace_point_type_t::task_begin),
120-
syclCallback);
121-
xptiRegisterCallback(
122-
StreamID, static_cast<uint16_t>(xpti::trace_point_type_t::task_end),
123-
syclCallback);
124-
xptiRegisterCallback(
125-
StreamID, static_cast<uint16_t>(xpti::trace_point_type_t::signal),
126-
syclCallback);
127-
xptiRegisterCallback(
128-
StreamID,
129-
static_cast<uint16_t>(xpti::trace_point_type_t::barrier_begin),
130-
syclCallback);
131-
xptiRegisterCallback(
132-
StreamID, static_cast<uint16_t>(xpti::trace_point_type_t::barrier_end),
133-
syclCallback);
134-
xptiRegisterCallback(
135-
StreamID, static_cast<uint16_t>(xpti::trace_point_type_t::wait_begin),
136-
syclCallback);
137-
xptiRegisterCallback(
138-
StreamID, static_cast<uint16_t>(xpti::trace_point_type_t::wait_end),
139-
syclCallback);
140-
xptiRegisterCallback(
141-
StreamID, static_cast<uint16_t>(xpti::trace_point_type_t::signal),
142-
syclCallback);
61+
for (type t : std::initializer_list<type>{
62+
type::graph_create, type::node_create, type::edge_create,
63+
type::task_begin, type::task_end, type::signal, type::wait_begin,
64+
type::wait_end, type::barrier_begin, type::barrier_end,
65+
type::diagnostics})
66+
xptiRegisterCallback(StreamID, static_cast<uint16_t>(t), syclCallback);
14367
}
14468
}
14569

sycl/test-e2e/XPTI/Inputs/test_collector.cpp

Lines changed: 11 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -19,54 +19,23 @@ XPTI_CALLBACK_API void xptiTraceInit(unsigned int MajorVersion,
1919
const char *StreamName) {
2020
std::cout << "xptiTraceInit: Stream Name = " << StreamName << "\n";
2121
std::string_view NameView{StreamName};
22+
using type = xpti::trace_point_type_t;
2223

2324
if (NameView == "sycl.pi") {
2425
uint8_t StreamID = xptiRegisterStream(StreamName);
25-
xptiRegisterCallback(
26-
StreamID,
27-
static_cast<uint16_t>(xpti::trace_point_type_t::function_begin),
28-
syclPiCallback);
29-
xptiRegisterCallback(
30-
StreamID,
31-
static_cast<uint16_t>(xpti::trace_point_type_t::function_with_args_end),
32-
syclPiCallback);
26+
for (type t : std::initializer_list<type>{type::function_begin,
27+
type::function_with_args_end})
28+
xptiRegisterCallback(StreamID, static_cast<uint16_t>(t), syclPiCallback);
3329
}
3430
if (NameView == "sycl") {
3531
uint8_t StreamID = xptiRegisterStream(StreamName);
36-
xptiRegisterCallback(
37-
StreamID, static_cast<uint16_t>(xpti::trace_point_type_t::graph_create),
38-
syclCallback);
39-
xptiRegisterCallback(
40-
StreamID, static_cast<uint16_t>(xpti::trace_point_type_t::node_create),
41-
syclCallback);
42-
xptiRegisterCallback(
43-
StreamID, static_cast<uint16_t>(xpti::trace_point_type_t::edge_create),
44-
syclCallback);
45-
xptiRegisterCallback(
46-
StreamID, static_cast<uint16_t>(xpti::trace_point_type_t::task_begin),
47-
syclCallback);
48-
xptiRegisterCallback(
49-
StreamID, static_cast<uint16_t>(xpti::trace_point_type_t::task_end),
50-
syclCallback);
51-
xptiRegisterCallback(
52-
StreamID, static_cast<uint16_t>(xpti::trace_point_type_t::signal),
53-
syclCallback);
54-
xptiRegisterCallback(
55-
StreamID,
56-
static_cast<uint16_t>(xpti::trace_point_type_t::barrier_begin),
57-
syclCallback);
58-
xptiRegisterCallback(
59-
StreamID, static_cast<uint16_t>(xpti::trace_point_type_t::barrier_end),
60-
syclCallback);
61-
xptiRegisterCallback(
62-
StreamID, static_cast<uint16_t>(xpti::trace_point_type_t::wait_begin),
63-
syclCallback);
64-
xptiRegisterCallback(
65-
StreamID, static_cast<uint16_t>(xpti::trace_point_type_t::wait_end),
66-
syclCallback);
67-
xptiRegisterCallback(
68-
StreamID, static_cast<uint16_t>(xpti::trace_point_type_t::signal),
69-
syclCallback);
32+
33+
for (type t : std::initializer_list<type>{
34+
type::graph_create, type::node_create, type::edge_create,
35+
type::task_begin, type::task_end, type::signal,
36+
type::barrier_begin, type::barrier_end, type::wait_begin,
37+
type::wait_end})
38+
xptiRegisterCallback(StreamID, static_cast<uint16_t>(t), syclCallback);
7039
}
7140
}
7241

0 commit comments

Comments
 (0)