12
12
#include < CL/sycl/detail/pi.hpp>
13
13
#include < CL/sycl/stl.hpp>
14
14
#include < detail/plugin_printers.hpp>
15
+ #include < memory>
16
+ #include < mutex>
15
17
16
18
#ifdef XPTI_ENABLE_INSTRUMENTATION
17
19
// Include the headers necessary for emitting traces using the trace framework
@@ -33,7 +35,8 @@ class plugin {
33
35
plugin () = delete ;
34
36
35
37
plugin (RT::PiPlugin Plugin, backend UseBackend)
36
- : MPlugin(Plugin), MBackend(UseBackend) {}
38
+ : MPlugin(Plugin), MBackend(UseBackend),
39
+ TracingMutex (std::make_shared<std::mutex>()) {}
37
40
38
41
plugin &operator =(const plugin &) = default ;
39
42
plugin (const plugin &) = default;
@@ -73,13 +76,12 @@ class plugin {
73
76
std::string PIFnName = PiCallInfo.getFuncName ();
74
77
uint64_t CorrelationID = pi::emitFunctionBeginTrace (PIFnName.c_str ());
75
78
#endif
79
+ RT::PiResult R = PiCallInfo.getFuncPtr (MPlugin)(Args...);
76
80
if (pi::trace (pi::TraceLevel::PI_TRACE_CALLS)) {
81
+ std::lock_guard<std::mutex> Guard (*TracingMutex);
77
82
std::string FnName = PiCallInfo.getFuncName ();
78
83
std::cout << " ---> " << FnName << " (" << std::endl;
79
84
RT::printArgs (Args...);
80
- }
81
- RT::PiResult R = PiCallInfo.getFuncPtr (MPlugin)(Args...);
82
- if (pi::trace (pi::TraceLevel::PI_TRACE_CALLS)) {
83
85
std::cout << " ) ---> " ;
84
86
RT::printArgs (R);
85
87
RT::printOuts (Args...);
@@ -106,6 +108,7 @@ class plugin {
106
108
private:
107
109
RT::PiPlugin MPlugin;
108
110
backend MBackend;
111
+ std::shared_ptr<std::mutex> TracingMutex;
109
112
}; // class plugin
110
113
} // namespace detail
111
114
} // namespace sycl
0 commit comments