20 #ifdef XPTI_ENABLE_INSTRUMENTATION
23 #include "xpti/xpti_trace_framework.hpp"
25 #define XPTI_CREATE_TRACEPOINT(CL) \
26 std::unique_ptr<xpti::framework::tracepoint_t> _TP(nullptr); \
27 if (xptiTraceEnabled()) { \
28 xpti::payload_t Payload{CL.functionName(), CL.fileName(), \
29 static_cast<int>(CL.lineNumber()), \
30 static_cast<int>(CL.columnNumber()), nullptr}; \
31 _TP = std::make_unique<xpti::framework::tracepoint_t>(&Payload); \
35 #define XPTI_CREATE_TRACEPOINT(CL)
49 void *RetVal =
nullptr;
61 }
catch (
const std::bad_alloc &) {
74 &RetVal, C,
nullptr, Size, Alignment);
79 case alloc::unknown: {
99 void *RetVal =
nullptr;
104 if (Kind == alloc::unknown) {
112 aligned_allocator<char> Alloc(Alignment);
114 RetVal = Alloc.allocate(Size);
115 }
catch (
const std::bad_alloc &) {
123 const detail::plugin &Plugin = CtxImpl->getPlugin();
132 bool IsBufferLocSupported =
134 if (IsBufferLocSupported &&
136 usm::buffer_location>()) {
137 auto location = PropList
138 .get_property<cl::sycl::ext::intel::experimental::
139 property::usm::buffer_location>()
140 .get_buffer_location();
144 &RetVal, C, Id, props, Size, Alignment);
147 &RetVal, C, Id,
nullptr, Size, Alignment);
151 case alloc::shared: {
153 if (PropList.has_property<
158 &RetVal, C, Id, Props, Size, Alignment);
161 &RetVal, C, Id,
nullptr, Size, Alignment);
166 case alloc::unknown: {
187 detail::OSUtil::alignedFree(Ptr);
222 void *
malloc_device(
size_t Size,
const device &Dev,
const context &Ctxt,
223 const property_list &PropList,
224 const detail::code_location CL) {
235 const detail::code_location CL) {
236 return malloc_device(Size, Q.get_device(), Q.get_context(), PropList, CL);
247 const context &Ctxt,
const property_list &,
248 const detail::code_location CL) {
259 const property_list &PropList,
260 const detail::code_location CL) {
281 void *
malloc_host(
size_t Size,
const context &Ctxt,
const property_list &,
282 const detail::code_location CL) {
290 void *
malloc_host(
size_t Size,
const queue &Q,
const property_list &PropList,
291 const detail::code_location CL) {
292 return malloc_host(Size, Q.get_context(), PropList, CL);
300 void *
malloc_shared(
size_t Size,
const device &Dev,
const context &Ctxt,
301 const property_list &PropList,
302 const detail::code_location CL) {
313 const detail::code_location CL) {
314 return malloc_shared(Size, Q.get_device(), Q.get_context(), PropList, CL);
323 const property_list &,
324 const detail::code_location CL) {
334 const property_list &PropList,
335 const detail::code_location CL) {
347 const context &Ctxt,
const property_list &PropList,
348 const detail::code_location CL) {
360 const property_list &PropList,
361 const detail::code_location CL) {
370 void *RetVal =
nullptr;
372 if (Kind == alloc::host) {
381 void *
malloc(
size_t Size,
const device &Dev,
const context &Ctxt,
alloc Kind,
382 const property_list &,
const detail::code_location CL) {
383 return malloc(Size, Dev, Ctxt, Kind, CL);
392 const property_list &PropList,
const detail::code_location CL) {
393 return malloc(Size, Q.get_device(), Q.get_context(), Kind, PropList, CL);
399 void *RetVal =
nullptr;
401 if (Kind == alloc::host) {
410 void *
aligned_alloc(
size_t Alignment,
size_t Size,
const device &Dev,
411 const context &Ctxt,
alloc Kind,
const property_list &,
412 const detail::code_location CL) {
423 const property_list &PropList,
424 const detail::code_location CL) {
425 return aligned_alloc(Alignment, Size, Q.get_device(), Q.get_context(), Kind,
437 return alloc::unknown;
456 return alloc::unknown;
465 ResultAlloc = alloc::host;
471 ResultAlloc = alloc::shared;
474 ResultAlloc = alloc::unknown;
498 auto Devs = CtxImpl->getDevices();
499 if (Devs.size() == 0)
514 for (
const device &Dev : CtxImpl->getDevices()) {
520 throw runtime_error(
"Cannot find device associated with USM allocation!",
683 void *RetVal =
nullptr;
685 if (Kind == alloc::host) {
715 void *RetVal =
nullptr;
717 if (Kind == alloc::host) {