Skip to content

Commit e58f60b

Browse files
smaslov-intelagainull
authored andcommitted
[SYCL] enhanced PI tracing to print output (pointer) arguments
Signed-off-by: Artur Gainullin <[email protected]>
1 parent 86acff3 commit e58f60b

File tree

2 files changed

+71
-1
lines changed

2 files changed

+71
-1
lines changed

sycl/include/CL/sycl/detail/pi.hpp

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,29 @@ template <> inline void print<>(PiPlatform val) {
155155
std::cout << "pi_platform : " << val << std::endl;
156156
}
157157

158+
template <> inline void print<>(PiEvent val) {
159+
std::cout << "pi_event : " << val << std::endl;
160+
}
161+
162+
template <> inline void print<>(PiMem val) {
163+
std::cout << "pi_mem : " << val << std::endl;
164+
}
165+
166+
template <> inline void print<>(PiEvent *val) {
167+
std::cout << "pi_event * : " << val;
168+
if (val) {
169+
std::cout << "[ " << *val << " ... ]";
170+
}
171+
std::cout << std::endl;
172+
}
173+
174+
template <> inline void print<>(const PiEvent *val) {
175+
std::cout << "const pi_event * : " << val;
176+
if (val) {
177+
std::cout << "[ " << *val << " ... ]";
178+
}
179+
std::cout << std::endl;
180+
}
158181
template <> inline void print<>(PiResult val) {
159182
std::cout << "pi_result : ";
160183
if (val == PI_SUCCESS)
@@ -169,11 +192,56 @@ template <> inline void print<>(std::nullptr_t val) { print<void *>(val); }
169192
inline void printArgs(void) {}
170193
template <typename Arg0, typename... Args>
171194
void printArgs(Arg0 arg0, Args... args) {
172-
std::cout << " ";
195+
std::cout << "\t";
173196
print(arg0);
174197
pi::printArgs(std::forward<Args>(args)...);
175198
}
176199

200+
template <typename T> struct printOut {
201+
printOut(T val) {}
202+
}; // Do nothing
203+
204+
template <> struct printOut<PiEvent *> {
205+
printOut(PiEvent *val) {
206+
std::cout << "\t[out]pi_event * : " << val;
207+
if (val) {
208+
std::cout << "[ " << *val << " ... ]";
209+
}
210+
std::cout << std::endl;
211+
}
212+
};
213+
214+
template <> struct printOut<PiMem *> {
215+
printOut(PiMem *val) {
216+
std::cout << "\t[out]pi_mem * : " << val;
217+
if (val) {
218+
std::cout << "[ " << *val << " ... ]";
219+
}
220+
std::cout << std::endl;
221+
}
222+
};
223+
224+
template <> struct printOut<void *> {
225+
printOut(void *val) { std::cout << "\t[out]void * : " << val << std::endl; }
226+
};
227+
228+
template <typename T> struct printOut<T **> {
229+
printOut(T **val) {
230+
std::cout << "\t[out]<unknown> ** : " << val;
231+
if (val) {
232+
std::cout << "[ " << *val << " ... ]";
233+
}
234+
std::cout << std::endl;
235+
}
236+
};
237+
238+
inline void printOuts(void) {}
239+
template <typename Arg0, typename... Args>
240+
void printOuts(Arg0 arg0, Args... args) {
241+
using T = decltype(arg0);
242+
printOut<T> a(arg0);
243+
printOuts(std::forward<Args>(args)...);
244+
}
177245
// C++ wrapper over the _pi_device_binary_property_struct structure.
178246
class DeviceBinaryProperty {
179247
public:

sycl/source/detail/plugin.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ class plugin {
6161
if (MPiEnableTrace) {
6262
std::cout << ") ---> ";
6363
RT::printArgs(R);
64+
RT::printOuts(Args...);
65+
std::cout << std::endl;
6466
}
6567
return R;
6668
}

0 commit comments

Comments
 (0)