diff --git a/scripts/templates/ldrddi.cpp.mako b/scripts/templates/ldrddi.cpp.mako index b93330049b..d7a6da9c15 100644 --- a/scripts/templates/ldrddi.cpp.mako +++ b/scripts/templates/ldrddi.cpp.mako @@ -56,7 +56,7 @@ namespace ur_loader size_t adapterIndex = 0; if( nullptr != ${obj['params'][1]['name']} && ${obj['params'][0]['name']} !=0) { - for( auto& platform : context->platforms ) + for( auto& platform : getContext()->platforms ) { if(platform.initStatus != ${X}_RESULT_SUCCESS) continue; @@ -81,7 +81,7 @@ namespace ur_loader if( ${obj['params'][2]['name']} != nullptr ) { - *${obj['params'][2]['name']} = static_cast(context->platforms.size()); + *${obj['params'][2]['name']} = static_cast(getContext()->platforms.size()); } %elif re.match(r"\w+PlatformGet$", th.make_func_name(n, tags, obj)): @@ -360,13 +360,13 @@ ${tbl['export']['name']}( if( nullptr == pDdiTable ) return ${X}_RESULT_ERROR_INVALID_NULL_POINTER; - if( ur_loader::context->version < version ) + if( ur_loader::getContext()->version < version ) return ${X}_RESULT_ERROR_UNSUPPORTED_VERSION; ${x}_result_t result = ${X}_RESULT_SUCCESS; // Load the device-platform DDI tables - for( auto& platform : ur_loader::context->platforms ) + for( auto& platform : ur_loader::getContext()->platforms ) { if(platform.initStatus != ${X}_RESULT_SUCCESS) continue; @@ -379,7 +379,7 @@ ${tbl['export']['name']}( if( ${X}_RESULT_SUCCESS == result ) { - if( ur_loader::context->platforms.size() != 1 || ur_loader::context->forceIntercept ) + if( ur_loader::getContext()->platforms.size() != 1 || ur_loader::getContext()->forceIntercept ) { // return pointers to loader's DDIs %for obj in tbl['functions']: @@ -397,7 +397,7 @@ ${tbl['export']['name']}( else { // return pointers directly to platform's DDIs - *pDdiTable = ur_loader::context->platforms.front().dditable.${n}.${tbl['name']}; + *pDdiTable = ur_loader::getContext()->platforms.front().dditable.${n}.${tbl['name']}; } } diff --git a/scripts/templates/libapi.cpp.mako b/scripts/templates/libapi.cpp.mako index 6fe1f3992b..33e11753ab 100644 --- a/scripts/templates/libapi.cpp.mako +++ b/scripts/templates/libapi.cpp.mako @@ -56,28 +56,10 @@ ${th.make_func_name(n, tags, obj)}( %endfor ) try { -%if re.match("Init", obj['name']): - <% - param_checks=th.make_param_checks(n, tags, obj, meta=meta).items() - %> - %for key, values in param_checks: - %for val in values: - if( ${val} ) - return ${key}; - - %endfor - %endfor - - static ${x}_result_t result = ${X}_RESULT_SUCCESS; - std::call_once(${x}_lib::context->initOnce, [device_flags, hLoaderConfig]() { - result = ${x}_lib::context->Init(device_flags, hLoaderConfig); - }); - - return result; -%elif th.obj_traits.is_loader_only(obj): +%if th.obj_traits.is_loader_only(obj): return ur_lib::${th.make_func_name(n, tags, obj)}(${", ".join(th.make_param_lines(n, tags, obj, format=["name"]))} ); %else: - auto ${th.make_pfn_name(n, tags, obj)} = ${x}_lib::context->${n}DdiTable.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)}; + auto ${th.make_pfn_name(n, tags, obj)} = ${x}_lib::getContext()->${n}DdiTable.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)}; if( nullptr == ${th.make_pfn_name(n, tags, obj)} ) return ${X}_RESULT_ERROR_UNINITIALIZED; diff --git a/scripts/templates/libddi.cpp.mako b/scripts/templates/libddi.cpp.mako index eae178324c..05d76ab138 100644 --- a/scripts/templates/libddi.cpp.mako +++ b/scripts/templates/libddi.cpp.mako @@ -28,7 +28,7 @@ namespace ${x}_lib /////////////////////////////////////////////////////////////////////////////// - __${x}dlllocal ${x}_result_t context_t::${n}LoaderInit() + __${x}dlllocal ${x}_result_t context_t::ddiInit() { ${x}_result_t result = ${X}_RESULT_SUCCESS; diff --git a/scripts/templates/trcddi.cpp.mako b/scripts/templates/trcddi.cpp.mako index 6f6579d5ac..16eb14eadd 100644 --- a/scripts/templates/trcddi.cpp.mako +++ b/scripts/templates/trcddi.cpp.mako @@ -37,23 +37,23 @@ namespace ur_tracing_layer %endfor ) { - auto ${th.make_pfn_name(n, tags, obj)} = context.${n}DdiTable.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)}; + auto ${th.make_pfn_name(n, tags, obj)} = getContext()->${n}DdiTable.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)}; if( nullptr == ${th.make_pfn_name(n, tags, obj)} ) return ${X}_RESULT_ERROR_UNSUPPORTED_FEATURE; ${th.make_pfncb_param_type(n, tags, obj)} params = { &${",&".join(th.make_param_lines(n, tags, obj, format=["name"]))} }; - uint64_t instance = context.notify_begin(${th.make_func_etor(n, tags, obj)}, "${th.make_func_name(n, tags, obj)}", ¶ms); + uint64_t instance = getContext()->notify_begin(${th.make_func_etor(n, tags, obj)}, "${th.make_func_name(n, tags, obj)}", ¶ms); - context.logger.info("---> ${th.make_func_name(n, tags, obj)}"); + getContext()->logger.info("---> ${th.make_func_name(n, tags, obj)}"); ${x}_result_t result = ${th.make_pfn_name(n, tags, obj)}( ${", ".join(th.make_param_lines(n, tags, obj, format=["name"]))} ); - context.notify_end(${th.make_func_etor(n, tags, obj)}, "${th.make_func_name(n, tags, obj)}", ¶ms, &result, instance); + getContext()->notify_end(${th.make_func_etor(n, tags, obj)}, "${th.make_func_name(n, tags, obj)}", ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, ${th.make_func_etor(n, tags, obj)}, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -79,13 +79,13 @@ namespace ur_tracing_layer %endfor ) { - auto& dditable = ur_tracing_layer::context.${n}DdiTable.${tbl['name']}; + auto& dditable = ur_tracing_layer::getContext()->${n}DdiTable.${tbl['name']}; if( nullptr == pDdiTable ) return ${X}_RESULT_ERROR_INVALID_NULL_POINTER; - if (UR_MAJOR_VERSION(ur_tracing_layer::context.version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_tracing_layer::context.version) > UR_MINOR_VERSION(version)) + if (UR_MAJOR_VERSION(ur_tracing_layer::getContext()->version) != UR_MAJOR_VERSION(version) || + UR_MINOR_VERSION(ur_tracing_layer::getContext()->version) > UR_MINOR_VERSION(version)) return ${X}_RESULT_ERROR_UNSUPPORTED_VERSION; ${x}_result_t result = ${X}_RESULT_SUCCESS; @@ -122,7 +122,7 @@ namespace ur_tracing_layer // program launch and the call to `urLoaderInit` logger = logger::create_logger("tracing", true, true); - ur_tracing_layer::context.codelocData = codelocData; + ur_tracing_layer::getContext()->codelocData = codelocData; %for tbl in th.get_pfntables(specs, meta, n, tags): if( ${X}_RESULT_SUCCESS == result ) diff --git a/scripts/templates/valddi.cpp.mako b/scripts/templates/valddi.cpp.mako index c8905a7e8b..cc6ebf9c2a 100644 --- a/scripts/templates/valddi.cpp.mako +++ b/scripts/templates/valddi.cpp.mako @@ -47,13 +47,13 @@ namespace ur_validation_layer %endfor ) { - auto ${th.make_pfn_name(n, tags, obj)} = context.${n}DdiTable.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)}; + auto ${th.make_pfn_name(n, tags, obj)} = getContext()->${n}DdiTable.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)}; if( nullptr == ${th.make_pfn_name(n, tags, obj)} ) { return ${X}_RESULT_ERROR_UNINITIALIZED; } - if( context.enableParameterValidation ) + if( getContext()->enableParameterValidation ) { %for key, values in sorted_param_checks: %for val in values: @@ -80,7 +80,7 @@ namespace ur_validation_layer is_related_create_get_retain_release_func = any(func_name in funcs for funcs in tp_input_handle_funcs.values()) %> %if tp_input_handle_funcs and not is_related_create_get_retain_release_func: - if (context.enableLifetimeValidation && !refCountContext.isReferenceValid(${tp['name']})) { + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(${tp['name']})) { refCountContext.logInvalidReference(${tp['name']}); } %endif @@ -94,24 +94,24 @@ namespace ur_validation_layer is_handle_to_adapter = ("_adapter_handle_t" in tp['type']) %> %if func_name in tp_handle_funcs['create']: - if( context.enableLeakChecking && result == UR_RESULT_SUCCESS ) + if( getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS ) { refCountContext.createRefCount(*${tp['name']}); } %elif func_name in tp_handle_funcs['get']: - if( context.enableLeakChecking && ${tp['name']} && result == UR_RESULT_SUCCESS ) + if( getContext()->enableLeakChecking && ${tp['name']} && result == UR_RESULT_SUCCESS ) { for (uint32_t i = ${th.param_traits.range_start(tp)}; i < ${th.param_traits.range_end(tp)}; i++) { refCountContext.createOrIncrementRefCount(${tp['name']}[i], ${str(is_handle_to_adapter).lower()}); } } %elif func_name in tp_handle_funcs['retain']: - if( context.enableLeakChecking && result == UR_RESULT_SUCCESS ) + if( getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS ) { refCountContext.incrementRefCount(${tp['name']}, ${str(is_handle_to_adapter).lower()}); } %elif func_name in tp_handle_funcs['release']: - if( context.enableLeakChecking && result == UR_RESULT_SUCCESS ) + if( getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS ) { refCountContext.decrementRefCount(${tp['name']}, ${str(is_handle_to_adapter).lower()}); } @@ -141,13 +141,13 @@ namespace ur_validation_layer %endfor ) { - auto& dditable = ur_validation_layer::context.${n}DdiTable.${tbl['name']}; + auto& dditable = ur_validation_layer::getContext()->${n}DdiTable.${tbl['name']}; if( nullptr == pDdiTable ) return ${X}_RESULT_ERROR_INVALID_NULL_POINTER; - if (UR_MAJOR_VERSION(ur_validation_layer::context.version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_validation_layer::context.version) > UR_MINOR_VERSION(version)) + if (UR_MAJOR_VERSION(ur_validation_layer::getContext()->version) != UR_MAJOR_VERSION(version) || + UR_MINOR_VERSION(ur_validation_layer::getContext()->version) > UR_MINOR_VERSION(version)) return ${X}_RESULT_ERROR_UNSUPPORTED_VERSION; ${x}_result_t result = ${X}_RESULT_SUCCESS; diff --git a/source/common/ur_util.hpp b/source/common/ur_util.hpp index c78aac1d37..a34234b6dd 100644 --- a/source/common/ur_util.hpp +++ b/source/common/ur_util.hpp @@ -9,11 +9,15 @@ */ #include +#include +#include +#include #ifndef UR_UTIL_H #define UR_UTIL_H 1 #include +#include #include #include #include @@ -343,4 +347,106 @@ splitMetadataName(const std::string &metadataName) { return std::make_pair(metadataName.substr(0, splitPos), metadataName.substr(splitPos, metadataName.length())); } + +// A simple spinlock, must be kept trivially destructible +// so that it's safe to use after its destructor has been called. +template class Spinlock { + public: + Spinlock() : lock(ATOMIC_FLAG_INIT) {} + + T *acquire() { + while (lock.test_and_set(std::memory_order_acquire)) { + std::this_thread::yield(); + } + return &value; + } + void release() { lock.clear(std::memory_order_release); } + + private: + std::atomic_flag lock; + T value; +}; + +// A reference counted pointer. +template class Rc { + public: + Rc() : ptr(nullptr), refcount(0) {} + Rc(const Rc &) = delete; + Rc &operator=(const Rc &) = delete; + Rc(Rc &&) = delete; + Rc &operator=(Rc &&) = delete; + + T *get() { + if (ptr == nullptr) { + ptr = new T(); + } + refcount++; + return ptr; + } + + int release(std::function deleter) { + if (refcount <= 0) { + return -1; + } + + if (--refcount == 0) { + deleter(ptr); + ptr = nullptr; + } + + return 0; + } + + void forceDelete() { + delete ptr; + refcount = 0; + ptr = nullptr; + } + + private: + T *ptr; + size_t refcount; +}; + +// AtomicSingleton is for those cases where we want to support creating state +// on first use, global MT-safe reference-counted access, explicit synchronized deletion, +// and, on top of all that, need to gracefully handle situations where destructor order +// causes a library/application to call into the loader after it has been destroyed. +template class AtomicSingleton { + private: + static Spinlock> instance; + // Simply using an std::mutex would have been much simpler, but mutexes might + // get deleted prior to last use of this type. + + public: + static T *get() { + auto val = instance.acquire(); + + auto ptr = val->get(); + + instance.release(); + + return ptr; + } + + static int release(std::function deleter) { + auto val = instance.acquire(); + int ret = val->release(deleter); + instance.release(); + + return ret; + } + + // When we don't care about the refcount or the refcount is external. + static void forceDelete() { + auto val = instance.acquire(); + + val->forceDelete(); + + instance.release(); + } +}; + +template Spinlock> AtomicSingleton::instance; + #endif /* UR_UTIL_H */ diff --git a/source/loader/CMakeLists.txt b/source/loader/CMakeLists.txt index 075d9909b0..0b4a62cc5f 100644 --- a/source/loader/CMakeLists.txt +++ b/source/loader/CMakeLists.txt @@ -187,14 +187,10 @@ if(WIN32) target_sources(ur_loader PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/windows/adapter_search.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/windows/lib_init.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/windows/loader_init.cpp ) else() target_sources(ur_loader PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/linux/adapter_search.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/linux/lib_init.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/linux/loader_init.cpp ) endif() diff --git a/source/loader/layers/sanitizer/asan_allocator.cpp b/source/loader/layers/sanitizer/asan_allocator.cpp index 1ffa477ca1..c95ed728b6 100644 --- a/source/loader/layers/sanitizer/asan_allocator.cpp +++ b/source/loader/layers/sanitizer/asan_allocator.cpp @@ -16,7 +16,7 @@ namespace ur_sanitizer_layer { void AllocInfo::print() { - context.logger.info( + getContext()->logger.info( "AllocInfo(Alloc=[{}-{}), User=[{}-{}), AllocSize={}, Type={})", (void *)AllocBegin, (void *)(AllocBegin + AllocSize), (void *)UserBegin, (void *)(UserEnd), AllocSize, ToString(Type)); diff --git a/source/loader/layers/sanitizer/asan_buffer.cpp b/source/loader/layers/sanitizer/asan_buffer.cpp index bb50b53c06..4cf90c7da4 100644 --- a/source/loader/layers/sanitizer/asan_buffer.cpp +++ b/source/loader/layers/sanitizer/asan_buffer.cpp @@ -53,7 +53,7 @@ ur_result_t EnqueueMemCopyRectHelper( // loop call 2D memory copy function to implement it. for (size_t i = 0; i < Region.depth; i++) { ur_event_handle_t NewEvent{}; - UR_CALL(context.urDdiTable.Enqueue.pfnUSMMemcpy2D( + UR_CALL(getContext()->urDdiTable.Enqueue.pfnUSMMemcpy2D( Queue, Blocking, DstOrigin + (i * DstSlicePitch), DstRowPitch, SrcOrigin + (i * SrcSlicePitch), SrcRowPitch, Region.width, Region.height, NumEventsInWaitList, EventWaitList, &NewEvent)); @@ -61,8 +61,8 @@ ur_result_t EnqueueMemCopyRectHelper( Events.push_back(NewEvent); } - UR_CALL(context.urDdiTable.Enqueue.pfnEventsWait(Queue, Events.size(), - Events.data(), Event)); + UR_CALL(getContext()->urDdiTable.Enqueue.pfnEventsWait( + Queue, Events.size(), Events.data(), Event)); return UR_RESULT_SUCCESS; } @@ -80,23 +80,24 @@ ur_result_t MemBuffer::getHandle(ur_device_handle_t Device, char *&Handle) { ur_usm_desc_t USMDesc{}; USMDesc.align = getAlignment(); ur_usm_pool_handle_t Pool{}; - ur_result_t URes = context.interceptor->allocateMemory( + ur_result_t URes = getContext()->interceptor->allocateMemory( Context, Device, &USMDesc, Pool, Size, AllocType::MEM_BUFFER, ur_cast(&Allocation)); if (URes != UR_RESULT_SUCCESS) { - context.logger.error( + getContext()->logger.error( "Failed to allocate {} bytes memory for buffer {}", Size, this); return URes; } if (HostPtr) { ManagedQueue Queue(Context, Device); - URes = context.urDdiTable.Enqueue.pfnUSMMemcpy( + URes = getContext()->urDdiTable.Enqueue.pfnUSMMemcpy( Queue, true, Allocation, HostPtr, Size, 0, nullptr, nullptr); if (URes != UR_RESULT_SUCCESS) { - context.logger.error("Failed to copy {} bytes data from host " - "pointer {} to buffer {}", - Size, HostPtr, this); + getContext()->logger.error( + "Failed to copy {} bytes data from host " + "pointer {} to buffer {}", + Size, HostPtr, this); return URes; } } @@ -109,9 +110,10 @@ ur_result_t MemBuffer::getHandle(ur_device_handle_t Device, char *&Handle) { ur_result_t MemBuffer::free() { for (const auto &[_, Ptr] : Allocations) { - ur_result_t URes = context.interceptor->releaseMemory(Context, Ptr); + ur_result_t URes = + getContext()->interceptor->releaseMemory(Context, Ptr); if (URes != UR_RESULT_SUCCESS) { - context.logger.error("Failed to free buffer handle {}", Ptr); + getContext()->logger.error("Failed to free buffer handle {}", Ptr); return URes; } } diff --git a/source/loader/layers/sanitizer/asan_interceptor.cpp b/source/loader/layers/sanitizer/asan_interceptor.cpp index f1991aaab8..add49e936b 100644 --- a/source/loader/layers/sanitizer/asan_interceptor.cpp +++ b/source/loader/layers/sanitizer/asan_interceptor.cpp @@ -44,7 +44,7 @@ ur_result_t urEnqueueUSMSet(ur_queue_handle_t Queue, void *Ptr, char Value, if (Size == 0) { return UR_RESULT_SUCCESS; } - return context.urDdiTable.Enqueue.pfnUSMFill( + return getContext()->urDdiTable.Enqueue.pfnUSMFill( Queue, Ptr, 1, &Value, Size, NumEvents, EventWaitList, OutEvent); } @@ -67,9 +67,10 @@ ur_result_t enqueueMemSetShadow(ur_context_handle_t Context, if (!MemSet) { return UR_RESULT_ERROR_UNKNOWN; } - context.logger.debug("enqueueMemSetShadow(addr={}, count={}, value={})", - (void *)ShadowBegin, ShadowEnd - ShadowBegin + 1, - (void *)(size_t)Value); + getContext()->logger.debug( + "enqueueMemSetShadow(addr={}, count={}, value={})", + (void *)ShadowBegin, ShadowEnd - ShadowBegin + 1, + (void *)(size_t)Value); MemSet((void *)ShadowBegin, Value, ShadowEnd - ShadowBegin + 1); } else if (DeviceInfo->Type == DeviceType::GPU_PVC) { uptr ShadowBegin = MemToShadow_PVC(DeviceInfo->ShadowOffset, Ptr); @@ -88,25 +89,26 @@ ur_result_t enqueueMemSetShadow(ur_context_handle_t Context, for (auto MappedPtr = RoundDownTo(ShadowBegin, PageSize); MappedPtr <= ShadowEnd; MappedPtr += PageSize) { if (!PhysicalMem) { - auto URes = context.urDdiTable.PhysicalMem.pfnCreate( + auto URes = getContext()->urDdiTable.PhysicalMem.pfnCreate( Context, DeviceInfo->Handle, PageSize, &Desc, &PhysicalMem); if (URes != UR_RESULT_SUCCESS) { - context.logger.error("urPhysicalMemCreate(): {}", URes); + getContext()->logger.error("urPhysicalMemCreate(): {}", + URes); return URes; } } - context.logger.debug("urVirtualMemMap: {} ~ {}", - (void *)MappedPtr, - (void *)(MappedPtr + PageSize - 1)); + getContext()->logger.debug("urVirtualMemMap: {} ~ {}", + (void *)MappedPtr, + (void *)(MappedPtr + PageSize - 1)); // FIXME: No flag to check the failed reason is VA is already mapped - auto URes = context.urDdiTable.VirtualMem.pfnMap( + auto URes = getContext()->urDdiTable.VirtualMem.pfnMap( Context, (void *)MappedPtr, PageSize, PhysicalMem, 0, UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE); if (URes != UR_RESULT_SUCCESS) { - context.logger.debug("urVirtualMemMap(): {}", URes); + getContext()->logger.debug("urVirtualMemMap(): {}", URes); } // Initialize to zero @@ -117,7 +119,8 @@ ur_result_t enqueueMemSetShadow(ur_context_handle_t Context, auto URes = urEnqueueUSMSet(Queue, (void *)MappedPtr, 0, PageSize); if (URes != UR_RESULT_SUCCESS) { - context.logger.error("urEnqueueUSMFill(): {}", URes); + getContext()->logger.error("urEnqueueUSMFill(): {}", + URes); return URes; } } @@ -126,16 +129,16 @@ ur_result_t enqueueMemSetShadow(ur_context_handle_t Context, auto URes = urEnqueueUSMSet(Queue, (void *)ShadowBegin, Value, ShadowEnd - ShadowBegin + 1); - context.logger.debug( + getContext()->logger.debug( "enqueueMemSetShadow (addr={}, count={}, value={}): {}", (void *)ShadowBegin, ShadowEnd - ShadowBegin + 1, (void *)(size_t)Value, URes); if (URes != UR_RESULT_SUCCESS) { - context.logger.error("urEnqueueUSMFill(): {}", URes); + getContext()->logger.error("urEnqueueUSMFill(): {}", URes); return URes; } } else { - context.logger.error("Unsupport device type"); + getContext()->logger.error("Unsupport device type"); return UR_RESULT_ERROR_INVALID_ARGUMENT; } return UR_RESULT_SUCCESS; @@ -197,19 +200,19 @@ ur_result_t SanitizerInterceptor::allocateMemory( void *Allocated = nullptr; if (Type == AllocType::DEVICE_USM) { - UR_CALL(context.urDdiTable.USM.pfnDeviceAlloc( + UR_CALL(getContext()->urDdiTable.USM.pfnDeviceAlloc( Context, Device, Properties, Pool, NeededSize, &Allocated)); } else if (Type == AllocType::HOST_USM) { - UR_CALL(context.urDdiTable.USM.pfnHostAlloc(Context, Properties, Pool, - NeededSize, &Allocated)); + UR_CALL(getContext()->urDdiTable.USM.pfnHostAlloc( + Context, Properties, Pool, NeededSize, &Allocated)); } else if (Type == AllocType::SHARED_USM) { - UR_CALL(context.urDdiTable.USM.pfnSharedAlloc( + UR_CALL(getContext()->urDdiTable.USM.pfnSharedAlloc( Context, Device, Properties, Pool, NeededSize, &Allocated)); } else if (Type == AllocType::MEM_BUFFER) { - UR_CALL(context.urDdiTable.USM.pfnDeviceAlloc( + UR_CALL(getContext()->urDdiTable.USM.pfnDeviceAlloc( Context, Device, Properties, Pool, NeededSize, &Allocated)); } else { - context.logger.error("Unsupport memory type"); + getContext()->logger.error("Unsupport memory type"); return UR_RESULT_ERROR_INVALID_ARGUMENT; } @@ -300,21 +303,21 @@ ur_result_t SanitizerInterceptor::releaseMemory(ur_context_handle_t Context, // If quarantine is disabled, USM is freed immediately if (!m_Quarantine) { - context.logger.debug("Free: {}", (void *)AllocInfo->AllocBegin); + getContext()->logger.debug("Free: {}", (void *)AllocInfo->AllocBegin); std::scoped_lock Guard(m_AllocationMapMutex); m_AllocationMap.erase(AllocInfoIt); - return context.urDdiTable.USM.pfnFree(Context, - (void *)(AllocInfo->AllocBegin)); + return getContext()->urDdiTable.USM.pfnFree( + Context, (void *)(AllocInfo->AllocBegin)); } auto ReleaseList = m_Quarantine->put(AllocInfo->Device, AllocInfoIt); if (ReleaseList.size()) { std::scoped_lock Guard(m_AllocationMapMutex); for (auto &It : ReleaseList) { - context.logger.info("Quarantine Free: {}", - (void *)It->second->AllocBegin); + getContext()->logger.info("Quarantine Free: {}", + (void *)It->second->AllocBegin); m_AllocationMap.erase(It); - UR_CALL(context.urDdiTable.USM.pfnFree( + UR_CALL(getContext()->urDdiTable.USM.pfnFree( Context, (void *)(It->second->AllocBegin))); } } @@ -335,7 +338,7 @@ ur_result_t SanitizerInterceptor::preLaunchKernel(ur_kernel_handle_t Kernel, ManagedQueue InternalQueue(Context, Device); if (!InternalQueue) { - context.logger.error("Failed to create internal queue"); + getContext()->logger.error("Failed to create internal queue"); return UR_RESULT_ERROR_INVALID_QUEUE; } @@ -351,7 +354,7 @@ ur_result_t SanitizerInterceptor::postLaunchKernel(ur_kernel_handle_t Kernel, ur_queue_handle_t Queue, USMLaunchInfo &LaunchInfo) { // FIXME: We must use block operation here, until we support urEventSetCallback - auto Result = context.urDdiTable.Queue.pfnFinish(Queue); + auto Result = getContext()->urDdiTable.Queue.pfnFinish(Queue); if (Result == UR_RESULT_SUCCESS) { for (const auto &AH : LaunchInfo.Data->SanitizerReport) { @@ -383,11 +386,11 @@ ur_result_t DeviceInfo::allocShadowMemory(ur_context_handle_t Context) { } else if (Type == DeviceType::GPU_PVC) { UR_CALL(SetupShadowMemoryOnPVC(Context, ShadowOffset, ShadowOffsetEnd)); } else { - context.logger.error("Unsupport device type"); + getContext()->logger.error("Unsupport device type"); return UR_RESULT_ERROR_INVALID_ARGUMENT; } - context.logger.info("ShadowMemory(Global): {} - {}", (void *)ShadowOffset, - (void *)ShadowOffsetEnd); + getContext()->logger.info("ShadowMemory(Global): {} - {}", + (void *)ShadowOffset, (void *)ShadowOffsetEnd); return UR_RESULT_SUCCESS; } @@ -498,23 +501,24 @@ SanitizerInterceptor::registerDeviceGlobals(ur_context_handle_t Context, ManagedQueue Queue(Context, Device); uint64_t NumOfDeviceGlobal; - auto Result = context.urDdiTable.Enqueue.pfnDeviceGlobalVariableRead( - Queue, Program, kSPIR_AsanDeviceGlobalCount, true, - sizeof(NumOfDeviceGlobal), 0, &NumOfDeviceGlobal, 0, nullptr, - nullptr); + auto Result = + getContext()->urDdiTable.Enqueue.pfnDeviceGlobalVariableRead( + Queue, Program, kSPIR_AsanDeviceGlobalCount, true, + sizeof(NumOfDeviceGlobal), 0, &NumOfDeviceGlobal, 0, nullptr, + nullptr); if (Result != UR_RESULT_SUCCESS) { - context.logger.info("No device globals"); + getContext()->logger.info("No device globals"); continue; } std::vector GVInfos(NumOfDeviceGlobal); - Result = context.urDdiTable.Enqueue.pfnDeviceGlobalVariableRead( + Result = getContext()->urDdiTable.Enqueue.pfnDeviceGlobalVariableRead( Queue, Program, kSPIR_AsanDeviceGlobalMetadata, true, sizeof(DeviceGlobalInfo) * NumOfDeviceGlobal, 0, &GVInfos[0], 0, nullptr, nullptr); if (Result != UR_RESULT_SUCCESS) { - context.logger.error("Device Global[{}] Read Failed: {}", - kSPIR_AsanDeviceGlobalMetadata, Result); + getContext()->logger.error("Device Global[{}] Read Failed: {}", + kSPIR_AsanDeviceGlobalMetadata, Result); return Result; } @@ -584,7 +588,7 @@ SanitizerInterceptor::insertDevice(ur_device_handle_t Device, } // Query alignment - UR_CALL(context.urDdiTable.Device.pfnGetInfo( + UR_CALL(getContext()->urDdiTable.Device.pfnGetInfo( Device, UR_DEVICE_INFO_MEM_BASE_ADDR_ALIGN, sizeof(DI->Alignment), &DI->Alignment, nullptr)); @@ -656,10 +660,10 @@ ur_result_t SanitizerInterceptor::prepareLaunch( for (const auto &[ArgIndex, MemBuffer] : KernelInfo->BufferArgs) { char *ArgPointer = nullptr; UR_CALL(MemBuffer->getHandle(DeviceInfo->Handle, ArgPointer)); - ur_result_t URes = context.urDdiTable.Kernel.pfnSetArgPointer( + ur_result_t URes = getContext()->urDdiTable.Kernel.pfnSetArgPointer( Kernel, ArgIndex, nullptr, ArgPointer); if (URes != UR_RESULT_SUCCESS) { - context.logger.error( + getContext()->logger.error( "Failed to set buffer {} as the {} arg to kernel {}: {}", ur_cast(MemBuffer.get()), ArgIndex, Kernel, URes); @@ -669,14 +673,15 @@ ur_result_t SanitizerInterceptor::prepareLaunch( // Set launch info argument auto ArgNums = GetKernelNumArgs(Kernel); if (ArgNums) { - context.logger.debug( + getContext()->logger.debug( "launch_info {} (numLocalArgs={}, localArgs={})", (void *)LaunchInfo.Data, LaunchInfo.Data->NumLocalArgs, (void *)LaunchInfo.Data->LocalArgs); - ur_result_t URes = context.urDdiTable.Kernel.pfnSetArgPointer( + ur_result_t URes = getContext()->urDdiTable.Kernel.pfnSetArgPointer( Kernel, ArgNums - 1, nullptr, LaunchInfo.Data); if (URes != UR_RESULT_SUCCESS) { - context.logger.error("Failed to set launch info: {}", URes); + getContext()->logger.error("Failed to set launch info: {}", + URes); return URes; } } @@ -686,11 +691,11 @@ ur_result_t SanitizerInterceptor::prepareLaunch( const void *Value, size_t Size) { auto Result = - context.urDdiTable.Enqueue.pfnDeviceGlobalVariableWrite( + getContext()->urDdiTable.Enqueue.pfnDeviceGlobalVariableWrite( Queue, Program, Name, false, Size, 0, Value, 0, nullptr, nullptr); if (Result != UR_RESULT_SUCCESS) { - context.logger.warning( + getContext()->logger.warning( "Failed to write device global \"{}\": {}", Name, Result); return false; } @@ -716,9 +721,11 @@ ur_result_t SanitizerInterceptor::prepareLaunch( if (LaunchInfo.LocalWorkSize.empty()) { LaunchInfo.LocalWorkSize.resize(LaunchInfo.WorkDim); - auto URes = context.urDdiTable.Kernel.pfnGetSuggestedLocalWorkSize( - Kernel, Queue, LaunchInfo.WorkDim, LaunchInfo.GlobalWorkOffset, - LaunchInfo.GlobalWorkSize, LaunchInfo.LocalWorkSize.data()); + auto URes = + getContext()->urDdiTable.Kernel.pfnGetSuggestedLocalWorkSize( + Kernel, Queue, LaunchInfo.WorkDim, + LaunchInfo.GlobalWorkOffset, LaunchInfo.GlobalWorkSize, + LaunchInfo.LocalWorkSize.data()); if (URes != UR_RESULT_SUCCESS) { if (URes != UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { return URes; @@ -741,7 +748,7 @@ ur_result_t SanitizerInterceptor::prepareLaunch( auto EnqueueAllocateShadowMemory = [Context, &DeviceInfo, Queue](size_t Size, uptr &Ptr) { void *Allocated = nullptr; - auto URes = context.urDdiTable.USM.pfnDeviceAlloc( + auto URes = getContext()->urDdiTable.USM.pfnDeviceAlloc( Context, DeviceInfo->Handle, nullptr, nullptr, Size, &Allocated); if (URes != UR_RESULT_SUCCESS) { @@ -751,7 +758,7 @@ ur_result_t SanitizerInterceptor::prepareLaunch( URes = urEnqueueUSMSet(Queue, Allocated, 0, Size); if (URes != UR_RESULT_SUCCESS) { [[maybe_unused]] auto URes = - context.urDdiTable.USM.pfnFree(Context, Allocated); + getContext()->urDdiTable.USM.pfnFree(Context, Allocated); assert(URes == UR_RESULT_SUCCESS && "urUSMFree failed at allocating shadow memory"); Allocated = nullptr; @@ -765,9 +772,9 @@ ur_result_t SanitizerInterceptor::prepareLaunch( auto PrivateMemoryUsage = GetKernelPrivateMemorySize(Kernel, DeviceInfo->Handle); - context.logger.info("KernelInfo {} (LocalMemory={}, PrivateMemory={})", - (void *)Kernel, LocalMemoryUsage, - PrivateMemoryUsage); + getContext()->logger.info( + "KernelInfo {} (LocalMemory={}, PrivateMemory={})", (void *)Kernel, + LocalMemoryUsage, PrivateMemoryUsage); // Write shadow memory offset for local memory if (Options().DetectLocals) { @@ -778,7 +785,7 @@ ur_result_t SanitizerInterceptor::prepareLaunch( const size_t LocalShadowMemorySize = (NumWG * LocalMemorySize) >> ASAN_SHADOW_SCALE; - context.logger.debug( + getContext()->logger.debug( "LocalMemory(WorkGroup={}, LocalMemorySize={}, " "LocalShadowMemorySize={})", NumWG, LocalMemorySize, LocalShadowMemorySize); @@ -787,12 +794,12 @@ ur_result_t SanitizerInterceptor::prepareLaunch( LocalShadowMemorySize, LaunchInfo.Data->LocalShadowOffset) != UR_RESULT_SUCCESS) { - context.logger.warning( + getContext()->logger.warning( "Failed to allocate shadow memory for local " "memory, maybe the number of workgroup ({}) is too " "large", NumWG); - context.logger.warning( + getContext()->logger.warning( "Skip checking local memory of kernel <{}>", GetKernelName(Kernel)); } else { @@ -800,7 +807,7 @@ ur_result_t SanitizerInterceptor::prepareLaunch( LaunchInfo.Data->LocalShadowOffset + LocalShadowMemorySize - 1; - context.logger.info( + getContext()->logger.info( "ShadowMemory(Local, {} - {})", (void *)LaunchInfo.Data->LocalShadowOffset, (void *)LaunchInfo.Data->LocalShadowOffsetEnd); @@ -816,27 +823,27 @@ ur_result_t SanitizerInterceptor::prepareLaunch( const size_t PrivateShadowMemorySize = (NumWG * ASAN_PRIVATE_SIZE) >> ASAN_SHADOW_SCALE; - context.logger.debug("PrivateMemory(WorkGroup={}, " - "PrivateShadowMemorySize={})", - NumWG, PrivateShadowMemorySize); + getContext()->logger.debug("PrivateMemory(WorkGroup={}, " + "PrivateShadowMemorySize={})", + NumWG, PrivateShadowMemorySize); if (EnqueueAllocateShadowMemory( PrivateShadowMemorySize, LaunchInfo.Data->PrivateShadowOffset) != UR_RESULT_SUCCESS) { - context.logger.warning( + getContext()->logger.warning( "Failed to allocate shadow memory for private " "memory, maybe the number of workgroup ({}) is too " "large", NumWG); - context.logger.warning( + getContext()->logger.warning( "Skip checking private memory of kernel <{}>", GetKernelName(Kernel)); } else { LaunchInfo.Data->PrivateShadowOffsetEnd = LaunchInfo.Data->PrivateShadowOffset + PrivateShadowMemorySize - 1; - context.logger.info( + getContext()->logger.info( "ShadowMemory(Private, {} - {})", (void *)LaunchInfo.Data->PrivateShadowOffset, (void *)LaunchInfo.Data->PrivateShadowOffsetEnd); @@ -864,9 +871,9 @@ SanitizerInterceptor::findAllocInfoByAddress(uptr Address) { } ur_result_t USMLaunchInfo::initialize() { - UR_CALL(context.urDdiTable.Context.pfnRetain(Context)); - UR_CALL(context.urDdiTable.Device.pfnRetain(Device)); - UR_CALL(context.urDdiTable.USM.pfnSharedAlloc( + UR_CALL(getContext()->urDdiTable.Context.pfnRetain(Context)); + UR_CALL(getContext()->urDdiTable.Device.pfnRetain(Device)); + UR_CALL(getContext()->urDdiTable.USM.pfnSharedAlloc( Context, Device, nullptr, nullptr, sizeof(LaunchInfo), (void **)&Data)); *Data = LaunchInfo{}; return UR_RESULT_SUCCESS; @@ -876,13 +883,13 @@ ur_result_t USMLaunchInfo::updateKernelInfo(const KernelInfo &KI) { auto NumArgs = KI.LocalArgs.size(); if (NumArgs) { Data->NumLocalArgs = NumArgs; - UR_CALL(context.urDdiTable.USM.pfnSharedAlloc( + UR_CALL(getContext()->urDdiTable.USM.pfnSharedAlloc( Context, Device, nullptr, nullptr, sizeof(LocalArgsInfo) * NumArgs, (void **)&Data->LocalArgs)); uint32_t i = 0; for (auto [ArgIndex, ArgInfo] : KI.LocalArgs) { Data->LocalArgs[i++] = ArgInfo; - context.logger.debug( + getContext()->logger.debug( "local_args (argIndex={}, size={}, sizeWithRZ={})", ArgIndex, ArgInfo.Size, ArgInfo.SizeWithRedZone); } @@ -896,27 +903,27 @@ USMLaunchInfo::~USMLaunchInfo() { auto Type = GetDeviceType(Device); if (Type == DeviceType::GPU_PVC) { if (Data->PrivateShadowOffset) { - Result = context.urDdiTable.USM.pfnFree( + Result = getContext()->urDdiTable.USM.pfnFree( Context, (void *)Data->PrivateShadowOffset); assert(Result == UR_RESULT_SUCCESS); } if (Data->LocalShadowOffset) { - Result = context.urDdiTable.USM.pfnFree( + Result = getContext()->urDdiTable.USM.pfnFree( Context, (void *)Data->LocalShadowOffset); assert(Result == UR_RESULT_SUCCESS); } } if (Data->LocalArgs) { - Result = context.urDdiTable.USM.pfnFree(Context, - (void *)Data->LocalArgs); + Result = getContext()->urDdiTable.USM.pfnFree( + Context, (void *)Data->LocalArgs); assert(Result == UR_RESULT_SUCCESS); } - Result = context.urDdiTable.USM.pfnFree(Context, (void *)Data); + Result = getContext()->urDdiTable.USM.pfnFree(Context, (void *)Data); assert(Result == UR_RESULT_SUCCESS); } - Result = context.urDdiTable.Context.pfnRelease(Context); + Result = getContext()->urDdiTable.Context.pfnRelease(Context); assert(Result == UR_RESULT_SUCCESS); - Result = context.urDdiTable.Device.pfnRelease(Device); + Result = getContext()->urDdiTable.Device.pfnRelease(Device); assert(Result == UR_RESULT_SUCCESS); } diff --git a/source/loader/layers/sanitizer/asan_interceptor.hpp b/source/loader/layers/sanitizer/asan_interceptor.hpp index 348dff9cc0..735baecf5c 100644 --- a/source/loader/layers/sanitizer/asan_interceptor.hpp +++ b/source/loader/layers/sanitizer/asan_interceptor.hpp @@ -47,13 +47,13 @@ struct DeviceInfo { explicit DeviceInfo(ur_device_handle_t Device) : Handle(Device) { [[maybe_unused]] auto Result = - context.urDdiTable.Device.pfnRetain(Device); + getContext()->urDdiTable.Device.pfnRetain(Device); assert(Result == UR_RESULT_SUCCESS); } ~DeviceInfo() { [[maybe_unused]] auto Result = - context.urDdiTable.Device.pfnRelease(Handle); + getContext()->urDdiTable.Device.pfnRelease(Handle); assert(Result == UR_RESULT_SUCCESS); } @@ -69,13 +69,13 @@ struct QueueInfo { explicit QueueInfo(ur_queue_handle_t Queue) : Handle(Queue), LastEvent(nullptr) { [[maybe_unused]] auto Result = - context.urDdiTable.Queue.pfnRetain(Queue); + getContext()->urDdiTable.Queue.pfnRetain(Queue); assert(Result == UR_RESULT_SUCCESS); } ~QueueInfo() { [[maybe_unused]] auto Result = - context.urDdiTable.Queue.pfnRelease(Handle); + getContext()->urDdiTable.Queue.pfnRelease(Handle); assert(Result == UR_RESULT_SUCCESS); } }; @@ -91,13 +91,13 @@ struct KernelInfo { explicit KernelInfo(ur_kernel_handle_t Kernel) : Handle(Kernel) { [[maybe_unused]] auto Result = - context.urDdiTable.Kernel.pfnRetain(Kernel); + getContext()->urDdiTable.Kernel.pfnRetain(Kernel); assert(Result == UR_RESULT_SUCCESS); } ~KernelInfo() { [[maybe_unused]] auto Result = - context.urDdiTable.Kernel.pfnRelease(Handle); + getContext()->urDdiTable.Kernel.pfnRelease(Handle); assert(Result == UR_RESULT_SUCCESS); } }; @@ -110,13 +110,13 @@ struct ContextInfo { explicit ContextInfo(ur_context_handle_t Context) : Handle(Context) { [[maybe_unused]] auto Result = - context.urDdiTable.Context.pfnRetain(Context); + getContext()->urDdiTable.Context.pfnRetain(Context); assert(Result == UR_RESULT_SUCCESS); } ~ContextInfo() { [[maybe_unused]] auto Result = - context.urDdiTable.Context.pfnRelease(Handle); + getContext()->urDdiTable.Context.pfnRelease(Handle); assert(Result == UR_RESULT_SUCCESS); } diff --git a/source/loader/layers/sanitizer/asan_options.hpp b/source/loader/layers/sanitizer/asan_options.hpp index faa633afd2..4f54c9562e 100644 --- a/source/loader/layers/sanitizer/asan_options.hpp +++ b/source/loader/layers/sanitizer/asan_options.hpp @@ -117,8 +117,9 @@ struct AsanOptions { MinRZSize = std::stoul(Value); if (MinRZSize < 16) { MinRZSize = 16; - context.logger.warning("Trying to set redzone size to a " - "value less than 16 is ignored"); + getContext()->logger.warning( + "Trying to set redzone size to a " + "value less than 16 is ignored"); } } catch (...) { die("[ERROR]: \"redzone\" should be an integer"); @@ -132,7 +133,7 @@ struct AsanOptions { MaxRZSize = std::stoul(Value); if (MaxRZSize > 2048) { MaxRZSize = 2048; - context.logger.warning( + getContext()->logger.warning( "Trying to set max redzone size to a " "value greater than 2048 is ignored"); } diff --git a/source/loader/layers/sanitizer/asan_report.cpp b/source/loader/layers/sanitizer/asan_report.cpp index 9590e232e4..7867ce9c41 100644 --- a/source/loader/layers/sanitizer/asan_report.cpp +++ b/source/loader/layers/sanitizer/asan_report.cpp @@ -23,62 +23,62 @@ namespace ur_sanitizer_layer { void ReportBadFree(uptr Addr, const StackTrace &stack, const std::shared_ptr &AI) { - context.logger.always( + getContext()->logger.always( "\n====ERROR: DeviceSanitizer: bad-free on address {}", (void *)Addr); stack.print(); if (!AI) { - context.logger.always("{} may be allocated on Host Memory", - (void *)Addr); + getContext()->logger.always("{} may be allocated on Host Memory", + (void *)Addr); } assert(!AI->IsReleased && "Chunk must be not released"); - context.logger.always("{} is located inside of {} region [{}, {})", - (void *)Addr, ToString(AI->Type), - (void *)AI->UserBegin, (void *)AI->UserEnd); - context.logger.always("allocated here:"); + getContext()->logger.always("{} is located inside of {} region [{}, {})", + (void *)Addr, ToString(AI->Type), + (void *)AI->UserBegin, (void *)AI->UserEnd); + getContext()->logger.always("allocated here:"); AI->AllocStack.print(); } void ReportBadContext(uptr Addr, const StackTrace &stack, const std::shared_ptr &AI) { - context.logger.always( + getContext()->logger.always( "\n====ERROR: DeviceSanitizer: bad-context on address {}", (void *)Addr); stack.print(); - context.logger.always("{} is located inside of {} region [{}, {})", - (void *)Addr, ToString(AI->Type), - (void *)AI->UserBegin, (void *)AI->UserEnd); - context.logger.always("allocated here:"); + getContext()->logger.always("{} is located inside of {} region [{}, {})", + (void *)Addr, ToString(AI->Type), + (void *)AI->UserBegin, (void *)AI->UserEnd); + getContext()->logger.always("allocated here:"); AI->AllocStack.print(); if (AI->IsReleased) { - context.logger.always("freed here:"); + getContext()->logger.always("freed here:"); AI->ReleaseStack.print(); } } void ReportDoubleFree(uptr Addr, const StackTrace &Stack, const std::shared_ptr &AI) { - context.logger.always( + getContext()->logger.always( "\n====ERROR: DeviceSanitizer: double-free on address {}", (void *)Addr); Stack.print(); - context.logger.always("{} is located inside of {} region [{}, {})", - (void *)Addr, ToString(AI->Type), - (void *)AI->UserBegin, (void *)AI->UserEnd); - context.logger.always("freed here:"); + getContext()->logger.always("{} is located inside of {} region [{}, {})", + (void *)Addr, ToString(AI->Type), + (void *)AI->UserBegin, (void *)AI->UserEnd); + getContext()->logger.always("freed here:"); AI->ReleaseStack.print(); - context.logger.always("previously allocated here:"); + getContext()->logger.always("previously allocated here:"); AI->AllocStack.print(); } void ReportGenericError(const DeviceSanitizerReport &Report) { - context.logger.always("\n====ERROR: DeviceSanitizer: {}", - ToString(Report.ErrorType)); + getContext()->logger.always("\n====ERROR: DeviceSanitizer: {}", + ToString(Report.ErrorType)); } void ReportOutOfBoundsError(const DeviceSanitizerReport &Report, @@ -90,16 +90,16 @@ void ReportOutOfBoundsError(const DeviceSanitizerReport &Report, // Try to demangle the kernel name KernelName = DemangleName(KernelName); - context.logger.always("\n====ERROR: DeviceSanitizer: {} on {}", - ToString(Report.ErrorType), - ToString(Report.MemoryType)); - context.logger.always( + getContext()->logger.always("\n====ERROR: DeviceSanitizer: {} on {}", + ToString(Report.ErrorType), + ToString(Report.MemoryType)); + getContext()->logger.always( "{} of size {} at kernel <{}> LID({}, {}, {}) GID({}, " "{}, {})", Report.IsWrite ? "WRITE" : "READ", Report.AccessSize, KernelName.c_str(), Report.LID0, Report.LID1, Report.LID2, Report.GID0, Report.GID1, Report.GID2); - context.logger.always(" #0 {} {}:{}", Func, File, Report.Line); + getContext()->logger.always(" #0 {} {}:{}", Func, File, Report.Line); } void ReportUseAfterFree(const DeviceSanitizerReport &Report, @@ -112,44 +112,46 @@ void ReportUseAfterFree(const DeviceSanitizerReport &Report, // Try to demangle the kernel name KernelName = DemangleName(KernelName); - context.logger.always("\n====ERROR: DeviceSanitizer: {} on address {}", - ToString(Report.ErrorType), (void *)Report.Address); - context.logger.always( + getContext()->logger.always( + "\n====ERROR: DeviceSanitizer: {} on address {}", + ToString(Report.ErrorType), (void *)Report.Address); + getContext()->logger.always( "{} of size {} at kernel <{}> LID({}, {}, {}) GID({}, " "{}, {})", Report.IsWrite ? "WRITE" : "READ", Report.AccessSize, KernelName.c_str(), Report.LID0, Report.LID1, Report.LID2, Report.GID0, Report.GID1, Report.GID2); - context.logger.always(" #0 {} {}:{}", Func, File, Report.Line); - context.logger.always(""); + getContext()->logger.always(" #0 {} {}:{}", Func, File, Report.Line); + getContext()->logger.always(""); if (Options().MaxQuarantineSizeMB > 0) { auto AllocInfoItOp = - context.interceptor->findAllocInfoByAddress(Report.Address); + getContext()->interceptor->findAllocInfoByAddress(Report.Address); if (!AllocInfoItOp) { - context.logger.always("Failed to find which chunck {} is allocated", - (void *)Report.Address); + getContext()->logger.always( + "Failed to find which chunck {} is allocated", + (void *)Report.Address); } else { auto &AllocInfo = (*AllocInfoItOp)->second; if (AllocInfo->Context != Context) { - context.logger.always( + getContext()->logger.always( "Failed to find which chunck {} is allocated", (void *)Report.Address); } assert(AllocInfo->IsReleased); - context.logger.always( + getContext()->logger.always( "{} is located inside of {} region [{}, {})", (void *)Report.Address, ToString(AllocInfo->Type), (void *)AllocInfo->UserBegin, (void *)AllocInfo->UserEnd); - context.logger.always("allocated here:"); + getContext()->logger.always("allocated here:"); AllocInfo->AllocStack.print(); - context.logger.always("released here:"); + getContext()->logger.always("released here:"); AllocInfo->ReleaseStack.print(); } } else { - context.logger.always( + getContext()->logger.always( "Please enable quarantine to get more information like memory " "chunck's kind and where the chunck was allocated and released."); } diff --git a/source/loader/layers/sanitizer/asan_shadow_setup.cpp b/source/loader/layers/sanitizer/asan_shadow_setup.cpp index 10c2377815..37ecbce281 100644 --- a/source/loader/layers/sanitizer/asan_shadow_setup.cpp +++ b/source/loader/layers/sanitizer/asan_shadow_setup.cpp @@ -68,13 +68,13 @@ ur_result_t SetupShadowMemory(ur_context_handle_t Context, uptr &ShadowBegin, // multiple contexts. Therefore, we just create one shadow memory here. static ur_result_t Result = [&Context]() { // TODO: Protect Bad Zone - auto Result = context.urDdiTable.VirtualMem.pfnReserve( + auto Result = getContext()->urDdiTable.VirtualMem.pfnReserve( Context, nullptr, SHADOW_SIZE, (void **)&LOW_SHADOW_BEGIN); if (Result == UR_RESULT_SUCCESS) { HIGH_SHADOW_END = LOW_SHADOW_BEGIN + SHADOW_SIZE; // Retain the context which reserves shadow memory ShadowContext = Context; - context.urDdiTable.Context.pfnRetain(Context); + getContext()->urDdiTable.Context.pfnRetain(Context); } return Result; }(); @@ -88,9 +88,9 @@ ur_result_t DestroyShadowMemory() { if (!ShadowContext) { return UR_RESULT_SUCCESS; } - auto Result = context.urDdiTable.VirtualMem.pfnFree( + auto Result = getContext()->urDdiTable.VirtualMem.pfnFree( ShadowContext, (const void *)LOW_SHADOW_BEGIN, SHADOW_SIZE); - context.urDdiTable.Context.pfnRelease(ShadowContext); + getContext()->urDdiTable.Context.pfnRelease(ShadowContext); return Result; }(); return Result; diff --git a/source/loader/layers/sanitizer/common.hpp b/source/loader/layers/sanitizer/common.hpp index 55c22f940a..9e8fa93902 100644 --- a/source/loader/layers/sanitizer/common.hpp +++ b/source/loader/layers/sanitizer/common.hpp @@ -119,10 +119,10 @@ inline uint64_t GetSizeAndRedzoneSizeForLocal(uint64_t Size, #define UR_CALL(Call) \ { \ if (PrintTrace) \ - context.logger.debug("UR ---> {}", #Call); \ + getContext()->logger.debug("UR ---> {}", #Call); \ ur_result_t Result = (Call); \ if (PrintTrace) \ - context.logger.debug("UR <--- {}({})", #Call, Result); \ + getContext()->logger.debug("UR <--- {}({})", #Call, Result); \ if (Result != UR_RESULT_SUCCESS) \ return Result; \ } diff --git a/source/loader/layers/sanitizer/linux/sanitizer_utils.cpp b/source/loader/layers/sanitizer/linux/sanitizer_utils.cpp index 469d71abeb..64704180ad 100644 --- a/source/loader/layers/sanitizer/linux/sanitizer_utils.cpp +++ b/source/loader/layers/sanitizer/linux/sanitizer_utils.cpp @@ -40,12 +40,13 @@ bool Munmap(uptr Addr, uptr Size) { return munmap((void *)Addr, Size) == 0; } void *GetMemFunctionPointer(const char *FuncName) { void *handle = dlopen(LIBC_SO, RTLD_LAZY | RTLD_NOLOAD); if (!handle) { - context.logger.error("Failed to dlopen {}", LIBC_SO); + getContext()->logger.error("Failed to dlopen {}", LIBC_SO); return nullptr; } auto ptr = dlsym(handle, FuncName); if (!ptr) { - context.logger.error("Failed to get '{}' from {}", FuncName, LIBC_SO); + getContext()->logger.error("Failed to get '{}' from {}", FuncName, + LIBC_SO); } return ptr; } diff --git a/source/loader/layers/sanitizer/stacktrace.cpp b/source/loader/layers/sanitizer/stacktrace.cpp index 6994ce58ad..6dcf447765 100644 --- a/source/loader/layers/sanitizer/stacktrace.cpp +++ b/source/loader/layers/sanitizer/stacktrace.cpp @@ -25,7 +25,7 @@ bool Contains(const std::string &s, const char *p) { void StackTrace::print() const { if (!stack.size()) { - context.logger.always(" failed to acquire backtrace"); + getContext()->logger.always(" failed to acquire backtrace"); } unsigned index = 0; @@ -37,10 +37,10 @@ void StackTrace::print() const { Contains(BI, "libur_loader.so")) { continue; } - context.logger.always(" #{} {}", index, BI); + getContext()->logger.always(" #{} {}", index, BI); ++index; } - context.logger.always(""); + getContext()->logger.always(""); } } // namespace ur_sanitizer_layer diff --git a/source/loader/layers/sanitizer/ur_sanddi.cpp b/source/loader/layers/sanitizer/ur_sanddi.cpp index 713fed4019..ef1e92f75b 100644 --- a/source/loader/layers/sanitizer/ur_sanddi.cpp +++ b/source/loader/layers/sanitizer/ur_sanddi.cpp @@ -21,11 +21,11 @@ namespace { ur_result_t setupContext(ur_context_handle_t Context, uint32_t numDevices, const ur_device_handle_t *phDevices) { std::shared_ptr CI; - UR_CALL(context.interceptor->insertContext(Context, CI)); + UR_CALL(getContext()->interceptor->insertContext(Context, CI)); for (uint32_t i = 0; i < numDevices; ++i) { auto hDevice = phDevices[i]; std::shared_ptr DI; - UR_CALL(context.interceptor->insertDevice(hDevice, DI)); + UR_CALL(getContext()->interceptor->insertDevice(hDevice, DI)); if (!DI->ShadowOffset) { UR_CALL(DI->allocShadowMemory(Context)); } @@ -49,15 +49,15 @@ __urdlllocal ur_result_t UR_APICALL urUSMHostAlloc( size, ///< [in] size in bytes of the USM memory object to be allocated void **ppMem ///< [out] pointer to USM host memory object ) { - auto pfnHostAlloc = context.urDdiTable.USM.pfnHostAlloc; + auto pfnHostAlloc = getContext()->urDdiTable.USM.pfnHostAlloc; if (nullptr == pfnHostAlloc) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - context.logger.debug("==== urUSMHostAlloc"); + getContext()->logger.debug("==== urUSMHostAlloc"); - return context.interceptor->allocateMemory( + return getContext()->interceptor->allocateMemory( hContext, nullptr, pUSMDesc, pool, size, AllocType::HOST_USM, ppMem); } @@ -74,15 +74,15 @@ __urdlllocal ur_result_t UR_APICALL urUSMDeviceAlloc( size, ///< [in] size in bytes of the USM memory object to be allocated void **ppMem ///< [out] pointer to USM device memory object ) { - auto pfnDeviceAlloc = context.urDdiTable.USM.pfnDeviceAlloc; + auto pfnDeviceAlloc = getContext()->urDdiTable.USM.pfnDeviceAlloc; if (nullptr == pfnDeviceAlloc) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - context.logger.debug("==== urUSMDeviceAlloc"); + getContext()->logger.debug("==== urUSMDeviceAlloc"); - return context.interceptor->allocateMemory( + return getContext()->interceptor->allocateMemory( hContext, hDevice, pUSMDesc, pool, size, AllocType::DEVICE_USM, ppMem); } @@ -99,15 +99,15 @@ __urdlllocal ur_result_t UR_APICALL urUSMSharedAlloc( size, ///< [in] size in bytes of the USM memory object to be allocated void **ppMem ///< [out] pointer to USM shared memory object ) { - auto pfnSharedAlloc = context.urDdiTable.USM.pfnSharedAlloc; + auto pfnSharedAlloc = getContext()->urDdiTable.USM.pfnSharedAlloc; if (nullptr == pfnSharedAlloc) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - context.logger.debug("==== urUSMSharedAlloc"); + getContext()->logger.debug("==== urUSMSharedAlloc"); - return context.interceptor->allocateMemory( + return getContext()->interceptor->allocateMemory( hContext, hDevice, pUSMDesc, pool, size, AllocType::SHARED_USM, ppMem); } @@ -117,15 +117,15 @@ __urdlllocal ur_result_t UR_APICALL urUSMFree( ur_context_handle_t hContext, ///< [in] handle of the context object void *pMem ///< [in] pointer to USM memory object ) { - auto pfnFree = context.urDdiTable.USM.pfnFree; + auto pfnFree = getContext()->urDdiTable.USM.pfnFree; if (nullptr == pfnFree) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - context.logger.debug("==== urUSMFree"); + getContext()->logger.debug("==== urUSMFree"); - return context.interceptor->releaseMemory(hContext, pMem); + return getContext()->interceptor->releaseMemory(hContext, pMem); } /////////////////////////////////////////////////////////////////////////////// @@ -135,17 +135,18 @@ __urdlllocal ur_result_t UR_APICALL urProgramBuild( ur_program_handle_t hProgram, ///< [in] handle of the program object const char *pOptions ///< [in] string of build options ) { - auto pfnProgramBuild = context.urDdiTable.Program.pfnBuild; + auto pfnProgramBuild = getContext()->urDdiTable.Program.pfnBuild; if (nullptr == pfnProgramBuild) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - context.logger.debug("==== urProgramBuild"); + getContext()->logger.debug("==== urProgramBuild"); UR_CALL(pfnProgramBuild(hContext, hProgram, pOptions)); - UR_CALL(context.interceptor->registerDeviceGlobals(hContext, hProgram)); + UR_CALL( + getContext()->interceptor->registerDeviceGlobals(hContext, hProgram)); return UR_RESULT_SUCCESS; } @@ -160,17 +161,17 @@ __urdlllocal ur_result_t UR_APICALL urProgramBuildExp( const char * pOptions ///< [in][optional] pointer to build options null-terminated string. ) { - auto pfnBuildExp = context.urDdiTable.ProgramExp.pfnBuildExp; + auto pfnBuildExp = getContext()->urDdiTable.ProgramExp.pfnBuildExp; if (nullptr == pfnBuildExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - context.logger.debug("==== urProgramBuildExp"); + getContext()->logger.debug("==== urProgramBuildExp"); UR_CALL(pfnBuildExp(hProgram, numDevices, phDevices, pOptions)); - UR_CALL(context.interceptor->registerDeviceGlobals(GetContext(hProgram), - hProgram)); + UR_CALL(getContext()->interceptor->registerDeviceGlobals( + GetContext(hProgram), hProgram)); return UR_RESULT_SUCCESS; } @@ -187,17 +188,18 @@ __urdlllocal ur_result_t UR_APICALL urProgramLink( ur_program_handle_t *phProgram ///< [out] pointer to handle of program object created. ) { - auto pfnProgramLink = context.urDdiTable.Program.pfnLink; + auto pfnProgramLink = getContext()->urDdiTable.Program.pfnLink; if (nullptr == pfnProgramLink) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - context.logger.debug("==== urProgramLink"); + getContext()->logger.debug("==== urProgramLink"); UR_CALL(pfnProgramLink(hContext, count, phPrograms, pOptions, phProgram)); - UR_CALL(context.interceptor->registerDeviceGlobals(hContext, *phProgram)); + UR_CALL( + getContext()->interceptor->registerDeviceGlobals(hContext, *phProgram)); return UR_RESULT_SUCCESS; } @@ -217,18 +219,19 @@ ur_result_t UR_APICALL urProgramLinkExp( ur_program_handle_t *phProgram ///< [out] pointer to handle of program object created. ) { - auto pfnProgramLinkExp = context.urDdiTable.ProgramExp.pfnLinkExp; + auto pfnProgramLinkExp = getContext()->urDdiTable.ProgramExp.pfnLinkExp; if (nullptr == pfnProgramLinkExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - context.logger.debug("==== urProgramLinkExp"); + getContext()->logger.debug("==== urProgramLinkExp"); UR_CALL(pfnProgramLinkExp(hContext, numDevices, phDevices, count, phPrograms, pOptions, phProgram)); - UR_CALL(context.interceptor->registerDeviceGlobals(hContext, *phProgram)); + UR_CALL( + getContext()->interceptor->registerDeviceGlobals(hContext, *phProgram)); return UR_RESULT_SUCCESS; } @@ -264,20 +267,21 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueKernelLaunch( phEvent ///< [out][optional] return an event object that identifies this particular ///< kernel execution instance. ) { - auto pfnKernelLaunch = context.urDdiTable.Enqueue.pfnKernelLaunch; + auto pfnKernelLaunch = getContext()->urDdiTable.Enqueue.pfnKernelLaunch; if (nullptr == pfnKernelLaunch) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - context.logger.debug("==== urEnqueueKernelLaunch"); + getContext()->logger.debug("==== urEnqueueKernelLaunch"); USMLaunchInfo LaunchInfo(GetContext(hQueue), GetDevice(hQueue), pGlobalWorkSize, pLocalWorkSize, pGlobalWorkOffset, workDim); UR_CALL(LaunchInfo.initialize()); - UR_CALL(context.interceptor->preLaunchKernel(hKernel, hQueue, LaunchInfo)); + UR_CALL(getContext()->interceptor->preLaunchKernel(hKernel, hQueue, + LaunchInfo)); ur_event_handle_t hEvent{}; ur_result_t result = @@ -286,8 +290,8 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueKernelLaunch( numEventsInWaitList, phEventWaitList, &hEvent); if (result == UR_RESULT_SUCCESS) { - UR_CALL( - context.interceptor->postLaunchKernel(hKernel, hQueue, LaunchInfo)); + UR_CALL(getContext()->interceptor->postLaunchKernel(hKernel, hQueue, + LaunchInfo)); } if (phEvent) { @@ -308,13 +312,13 @@ __urdlllocal ur_result_t UR_APICALL urContextCreate( ur_context_handle_t *phContext ///< [out] pointer to handle of context object created ) { - auto pfnCreate = context.urDdiTable.Context.pfnCreate; + auto pfnCreate = getContext()->urDdiTable.Context.pfnCreate; if (nullptr == pfnCreate) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - context.logger.debug("==== urContextCreate"); + getContext()->logger.debug("==== urContextCreate"); ur_result_t result = pfnCreate(numDevices, phDevices, pProperties, phContext); @@ -330,7 +334,7 @@ __urdlllocal ur_result_t UR_APICALL urContextCreate( /// @brief Intercept function for urContextCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( ur_native_handle_t - hNativeContext, ///< [in][nocheck] the native handle of the context. + hNativeContext, ///< [in][nocheck] the native handle of the getContext()-> uint32_t numDevices, ///< [in] number of devices associated with the context const ur_device_handle_t * phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context @@ -340,13 +344,13 @@ __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( phContext ///< [out] pointer to the handle of the context object created. ) { auto pfnCreateWithNativeHandle = - context.urDdiTable.Context.pfnCreateWithNativeHandle; + getContext()->urDdiTable.Context.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - context.logger.debug("==== urContextCreateWithNativeHandle"); + getContext()->logger.debug("==== urContextCreateWithNativeHandle"); ur_result_t result = pfnCreateWithNativeHandle( hNativeContext, numDevices, phDevices, pProperties, phContext); @@ -363,15 +367,15 @@ __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( __urdlllocal ur_result_t UR_APICALL urContextRelease( ur_context_handle_t hContext ///< [in] handle of the context to release. ) { - auto pfnRelease = context.urDdiTable.Context.pfnRelease; + auto pfnRelease = getContext()->urDdiTable.Context.pfnRelease; if (nullptr == pfnRelease) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - context.logger.debug("==== urContextRelease"); + getContext()->logger.debug("==== urContextRelease"); - UR_CALL(context.interceptor->eraseContext(hContext)); + UR_CALL(getContext()->interceptor->eraseContext(hContext)); ur_result_t result = pfnRelease(hContext); return result; @@ -388,7 +392,7 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreate( ur_mem_handle_t *phBuffer ///< [out] pointer to handle of the memory buffer created ) { - auto pfnBufferCreate = context.urDdiTable.Mem.pfnBufferCreate; + auto pfnBufferCreate = getContext()->urDdiTable.Mem.pfnBufferCreate; if (nullptr == pfnBufferCreate) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -398,7 +402,7 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreate( return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - context.logger.debug("==== urMemBufferCreate"); + getContext()->logger.debug("==== urMemBufferCreate"); void *Host = nullptr; if (pProperties) { @@ -411,7 +415,7 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreate( std::shared_ptr pMemBuffer = std::make_shared(hContext, size, hostPtrOrNull); - ur_result_t result = context.interceptor->insertMemBuffer(pMemBuffer); + ur_result_t result = getContext()->interceptor->insertMemBuffer(pMemBuffer); *phBuffer = ur_cast(pMemBuffer.get()); return result; @@ -434,15 +438,15 @@ __urdlllocal ur_result_t UR_APICALL urMemGetInfo( size_t * pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of the queried propName. ) { - auto pfnGetInfo = context.urDdiTable.Mem.pfnGetInfo; + auto pfnGetInfo = getContext()->urDdiTable.Mem.pfnGetInfo; if (nullptr == pfnGetInfo) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - context.logger.debug("==== urMemGetInfo"); + getContext()->logger.debug("==== urMemGetInfo"); - if (auto MemBuffer = context.interceptor->getMemBuffer(hMemory)) { + if (auto MemBuffer = getContext()->interceptor->getMemBuffer(hMemory)) { UrReturnHelper ReturnValue(propSize, pPropValue, pPropSizeRet); switch (propName) { case UR_MEM_INFO_CONTEXT: { @@ -468,15 +472,15 @@ __urdlllocal ur_result_t UR_APICALL urMemGetInfo( __urdlllocal ur_result_t UR_APICALL urMemRetain( ur_mem_handle_t hMem ///< [in] handle of the memory object to get access ) { - auto pfnRetain = context.urDdiTable.Mem.pfnRetain; + auto pfnRetain = getContext()->urDdiTable.Mem.pfnRetain; if (nullptr == pfnRetain) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - context.logger.debug("==== urMemRetain"); + getContext()->logger.debug("==== urMemRetain"); - if (auto MemBuffer = context.interceptor->getMemBuffer(hMem)) { + if (auto MemBuffer = getContext()->interceptor->getMemBuffer(hMem)) { MemBuffer->RefCount++; } else { UR_CALL(pfnRetain(hMem)); @@ -490,20 +494,20 @@ __urdlllocal ur_result_t UR_APICALL urMemRetain( __urdlllocal ur_result_t UR_APICALL urMemRelease( ur_mem_handle_t hMem ///< [in] handle of the memory object to release ) { - auto pfnRelease = context.urDdiTable.Mem.pfnRelease; + auto pfnRelease = getContext()->urDdiTable.Mem.pfnRelease; if (nullptr == pfnRelease) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - context.logger.debug("==== urMemRelease"); + getContext()->logger.debug("==== urMemRelease"); - if (auto MemBuffer = context.interceptor->getMemBuffer(hMem)) { + if (auto MemBuffer = getContext()->interceptor->getMemBuffer(hMem)) { if (--MemBuffer->RefCount != 0) { return UR_RESULT_SUCCESS; } UR_CALL(MemBuffer->free()); - UR_CALL(context.interceptor->eraseMemBuffer(hMem)); + UR_CALL(getContext()->interceptor->eraseMemBuffer(hMem)); } else { UR_CALL(pfnRelease(hMem)); } @@ -523,21 +527,21 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferPartition( ur_mem_handle_t *phMem ///< [out] pointer to the handle of sub buffer created ) { - auto pfnBufferPartition = context.urDdiTable.Mem.pfnBufferPartition; + auto pfnBufferPartition = getContext()->urDdiTable.Mem.pfnBufferPartition; if (nullptr == pfnBufferPartition) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - context.logger.debug("==== urMemBufferPartition"); + getContext()->logger.debug("==== urMemBufferPartition"); - if (auto ParentBuffer = context.interceptor->getMemBuffer(hBuffer)) { + if (auto ParentBuffer = getContext()->interceptor->getMemBuffer(hBuffer)) { if (ParentBuffer->Size < (pRegion->origin + pRegion->size)) { return UR_RESULT_ERROR_INVALID_BUFFER_SIZE; } std::shared_ptr SubBuffer = std::make_shared( ParentBuffer, pRegion->origin, pRegion->size); - UR_CALL(context.interceptor->insertMemBuffer(SubBuffer)); + UR_CALL(getContext()->interceptor->insertMemBuffer(SubBuffer)); *phMem = reinterpret_cast(SubBuffer.get()); } else { UR_CALL(pfnBufferPartition(hBuffer, flags, bufferCreateType, pRegion, @@ -555,15 +559,15 @@ __urdlllocal ur_result_t UR_APICALL urMemGetNativeHandle( ur_native_handle_t *phNativeMem ///< [out] a pointer to the native handle of the mem. ) { - auto pfnGetNativeHandle = context.urDdiTable.Mem.pfnGetNativeHandle; + auto pfnGetNativeHandle = getContext()->urDdiTable.Mem.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - context.logger.debug("==== urMemGetNativeHandle"); + getContext()->logger.debug("==== urMemGetNativeHandle"); - if (auto MemBuffer = context.interceptor->getMemBuffer(hMem)) { + if (auto MemBuffer = getContext()->interceptor->getMemBuffer(hMem)) { char *Handle = nullptr; UR_CALL(MemBuffer->getHandle(hDevice, Handle)); *phNativeMem = ur_cast(Handle); @@ -594,19 +598,19 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferRead( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnMemBufferRead = context.urDdiTable.Enqueue.pfnMemBufferRead; + auto pfnMemBufferRead = getContext()->urDdiTable.Enqueue.pfnMemBufferRead; if (nullptr == pfnMemBufferRead) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - context.logger.debug("==== urEnqueueMemBufferRead"); + getContext()->logger.debug("==== urEnqueueMemBufferRead"); - if (auto MemBuffer = context.interceptor->getMemBuffer(hBuffer)) { + if (auto MemBuffer = getContext()->interceptor->getMemBuffer(hBuffer)) { ur_device_handle_t Device = GetDevice(hQueue); char *pSrc = nullptr; UR_CALL(MemBuffer->getHandle(Device, pSrc)); - UR_CALL(context.urDdiTable.Enqueue.pfnUSMMemcpy( + UR_CALL(getContext()->urDdiTable.Enqueue.pfnUSMMemcpy( hQueue, blockingRead, pDst, pSrc + offset, size, numEventsInWaitList, phEventWaitList, phEvent)); } else { @@ -640,19 +644,19 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferWrite( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnMemBufferWrite = context.urDdiTable.Enqueue.pfnMemBufferWrite; + auto pfnMemBufferWrite = getContext()->urDdiTable.Enqueue.pfnMemBufferWrite; if (nullptr == pfnMemBufferWrite) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - context.logger.debug("==== urEnqueueMemBufferWrite"); + getContext()->logger.debug("==== urEnqueueMemBufferWrite"); - if (auto MemBuffer = context.interceptor->getMemBuffer(hBuffer)) { + if (auto MemBuffer = getContext()->interceptor->getMemBuffer(hBuffer)) { ur_device_handle_t Device = GetDevice(hQueue); char *pDst = nullptr; UR_CALL(MemBuffer->getHandle(Device, pDst)); - UR_CALL(context.urDdiTable.Enqueue.pfnUSMMemcpy( + UR_CALL(getContext()->urDdiTable.Enqueue.pfnUSMMemcpy( hQueue, blockingWrite, pDst + offset, pSrc, size, numEventsInWaitList, phEventWaitList, phEvent)); } else { @@ -696,15 +700,16 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferReadRect( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnMemBufferReadRect = context.urDdiTable.Enqueue.pfnMemBufferReadRect; + auto pfnMemBufferReadRect = + getContext()->urDdiTable.Enqueue.pfnMemBufferReadRect; if (nullptr == pfnMemBufferReadRect) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - context.logger.debug("==== urEnqueueMemBufferReadRect"); + getContext()->logger.debug("==== urEnqueueMemBufferReadRect"); - if (auto MemBuffer = context.interceptor->getMemBuffer(hBuffer)) { + if (auto MemBuffer = getContext()->interceptor->getMemBuffer(hBuffer)) { char *SrcHandle = nullptr; ur_device_handle_t Device = GetDevice(hQueue); UR_CALL(MemBuffer->getHandle(Device, SrcHandle)); @@ -760,15 +765,15 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferWriteRect( ///< command instance. ) { auto pfnMemBufferWriteRect = - context.urDdiTable.Enqueue.pfnMemBufferWriteRect; + getContext()->urDdiTable.Enqueue.pfnMemBufferWriteRect; if (nullptr == pfnMemBufferWriteRect) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - context.logger.debug("==== urEnqueueMemBufferWriteRect"); + getContext()->logger.debug("==== urEnqueueMemBufferWriteRect"); - if (auto MemBuffer = context.interceptor->getMemBuffer(hBuffer)) { + if (auto MemBuffer = getContext()->interceptor->getMemBuffer(hBuffer)) { char *DstHandle = nullptr; ur_device_handle_t Device = GetDevice(hQueue); UR_CALL(MemBuffer->getHandle(Device, DstHandle)); @@ -809,16 +814,16 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferCopy( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnMemBufferCopy = context.urDdiTable.Enqueue.pfnMemBufferCopy; + auto pfnMemBufferCopy = getContext()->urDdiTable.Enqueue.pfnMemBufferCopy; if (nullptr == pfnMemBufferCopy) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - context.logger.debug("==== urEnqueueMemBufferCopy"); + getContext()->logger.debug("==== urEnqueueMemBufferCopy"); - auto SrcBuffer = context.interceptor->getMemBuffer(hBufferSrc); - auto DstBuffer = context.interceptor->getMemBuffer(hBufferDst); + auto SrcBuffer = getContext()->interceptor->getMemBuffer(hBufferSrc); + auto DstBuffer = getContext()->interceptor->getMemBuffer(hBufferDst); UR_ASSERT((SrcBuffer && DstBuffer) || (!SrcBuffer && !DstBuffer), UR_RESULT_ERROR_INVALID_MEM_OBJECT); @@ -831,7 +836,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferCopy( char *DstHandle = nullptr; UR_CALL(DstBuffer->getHandle(Device, DstHandle)); - UR_CALL(context.urDdiTable.Enqueue.pfnUSMMemcpy( + UR_CALL(getContext()->urDdiTable.Enqueue.pfnUSMMemcpy( hQueue, false, DstHandle + dstOffset, SrcHandle + srcOffset, size, numEventsInWaitList, phEventWaitList, phEvent)); } else { @@ -873,16 +878,17 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferCopyRect( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnMemBufferCopyRect = context.urDdiTable.Enqueue.pfnMemBufferCopyRect; + auto pfnMemBufferCopyRect = + getContext()->urDdiTable.Enqueue.pfnMemBufferCopyRect; if (nullptr == pfnMemBufferCopyRect) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - context.logger.debug("==== urEnqueueMemBufferCopyRect"); + getContext()->logger.debug("==== urEnqueueMemBufferCopyRect"); - auto SrcBuffer = context.interceptor->getMemBuffer(hBufferSrc); - auto DstBuffer = context.interceptor->getMemBuffer(hBufferDst); + auto SrcBuffer = getContext()->interceptor->getMemBuffer(hBufferSrc); + auto DstBuffer = getContext()->interceptor->getMemBuffer(hBufferDst); UR_ASSERT((SrcBuffer && DstBuffer) || (!SrcBuffer && !DstBuffer), UR_RESULT_ERROR_INVALID_MEM_OBJECT); @@ -929,19 +935,19 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferFill( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnMemBufferFill = context.urDdiTable.Enqueue.pfnMemBufferFill; + auto pfnMemBufferFill = getContext()->urDdiTable.Enqueue.pfnMemBufferFill; if (nullptr == pfnMemBufferFill) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - context.logger.debug("==== urEnqueueMemBufferFill"); + getContext()->logger.debug("==== urEnqueueMemBufferFill"); - if (auto MemBuffer = context.interceptor->getMemBuffer(hBuffer)) { + if (auto MemBuffer = getContext()->interceptor->getMemBuffer(hBuffer)) { char *Handle = nullptr; ur_device_handle_t Device = GetDevice(hQueue); UR_CALL(MemBuffer->getHandle(Device, Handle)); - UR_CALL(context.urDdiTable.Enqueue.pfnUSMFill( + UR_CALL(getContext()->urDdiTable.Enqueue.pfnUSMFill( hQueue, Handle + offset, patternSize, pPattern, size, numEventsInWaitList, phEventWaitList, phEvent)); } else { @@ -975,15 +981,15 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferMap( void **ppRetMap ///< [out] return mapped pointer. TODO: move it before ///< numEventsInWaitList? ) { - auto pfnMemBufferMap = context.urDdiTable.Enqueue.pfnMemBufferMap; + auto pfnMemBufferMap = getContext()->urDdiTable.Enqueue.pfnMemBufferMap; if (nullptr == pfnMemBufferMap) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - context.logger.debug("==== urEnqueueMemBufferMap"); + getContext()->logger.debug("==== urEnqueueMemBufferMap"); - if (auto MemBuffer = context.interceptor->getMemBuffer(hBuffer)) { + if (auto MemBuffer = getContext()->interceptor->getMemBuffer(hBuffer)) { // Translate the host access mode info. MemBuffer::AccessMode AccessMode = MemBuffer::UNKNOWN; @@ -1013,7 +1019,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferMap( ur_usm_desc_t USMDesc{}; USMDesc.align = MemBuffer->getAlignment(); ur_usm_pool_handle_t Pool{}; - UR_CALL(context.interceptor->allocateMemory( + UR_CALL(getContext()->interceptor->allocateMemory( Context, nullptr, &USMDesc, Pool, size, AllocType::HOST_USM, ppRetMap)); } @@ -1023,7 +1029,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferMap( // we'll aways do copy here. char *SrcHandle = nullptr; UR_CALL(MemBuffer->getHandle(Device, SrcHandle)); - UR_CALL(context.urDdiTable.Enqueue.pfnUSMMemcpy( + UR_CALL(getContext()->urDdiTable.Enqueue.pfnUSMMemcpy( hQueue, blockingMap, *ppRetMap, SrcHandle + offset, size, numEventsInWaitList, phEventWaitList, phEvent)); @@ -1060,15 +1066,15 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemUnmap( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnMemUnmap = context.urDdiTable.Enqueue.pfnMemUnmap; + auto pfnMemUnmap = getContext()->urDdiTable.Enqueue.pfnMemUnmap; if (nullptr == pfnMemUnmap) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - context.logger.debug("==== urEnqueueMemUnmap"); + getContext()->logger.debug("==== urEnqueueMemUnmap"); - if (auto MemBuffer = context.interceptor->getMemBuffer(hMem)) { + if (auto MemBuffer = getContext()->interceptor->getMemBuffer(hMem)) { MemBuffer::Mapping Mapping{}; { std::scoped_lock Guard(MemBuffer->Mutex); @@ -1086,12 +1092,13 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemUnmap( ur_context_handle_t Context = GetContext(hQueue); ur_device_handle_t Device = GetDevice(hQueue); UR_CALL(MemBuffer->getHandle(Device, DstHandle)); - UR_CALL(context.urDdiTable.Enqueue.pfnUSMMemcpy( + UR_CALL(getContext()->urDdiTable.Enqueue.pfnUSMMemcpy( hQueue, true, DstHandle + Mapping.Offset, pMappedPtr, Mapping.Size, numEventsInWaitList, phEventWaitList, phEvent)); if (!MemBuffer->HostPtr) { - UR_CALL(context.interceptor->releaseMemory(Context, pMappedPtr)); + UR_CALL( + getContext()->interceptor->releaseMemory(Context, pMappedPtr)); } } else { UR_CALL(pfnMemUnmap(hQueue, hMem, pMappedPtr, numEventsInWaitList, @@ -1109,16 +1116,16 @@ __urdlllocal ur_result_t UR_APICALL urKernelCreate( ur_kernel_handle_t *phKernel ///< [out] pointer to handle of kernel object created. ) { - auto pfnCreate = context.urDdiTable.Kernel.pfnCreate; + auto pfnCreate = getContext()->urDdiTable.Kernel.pfnCreate; if (nullptr == pfnCreate) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - context.logger.debug("==== urKernelCreate"); + getContext()->logger.debug("==== urKernelCreate"); UR_CALL(pfnCreate(hProgram, pKernelName, phKernel)); - UR_CALL(context.interceptor->insertKernel(*phKernel)); + UR_CALL(getContext()->interceptor->insertKernel(*phKernel)); return UR_RESULT_SUCCESS; } @@ -1128,17 +1135,17 @@ __urdlllocal ur_result_t UR_APICALL urKernelCreate( __urdlllocal ur_result_t UR_APICALL urKernelRetain( ur_kernel_handle_t hKernel ///< [in] handle for the Kernel to retain ) { - auto pfnRetain = context.urDdiTable.Kernel.pfnRetain; + auto pfnRetain = getContext()->urDdiTable.Kernel.pfnRetain; if (nullptr == pfnRetain) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - context.logger.debug("==== urKernelRetain"); + getContext()->logger.debug("==== urKernelRetain"); UR_CALL(pfnRetain(hKernel)); - if (auto KernelInfo = context.interceptor->getKernelInfo(hKernel)) { + if (auto KernelInfo = getContext()->interceptor->getKernelInfo(hKernel)) { KernelInfo->RefCount++; } @@ -1150,20 +1157,20 @@ __urdlllocal ur_result_t UR_APICALL urKernelRetain( __urdlllocal ur_result_t urKernelRelease( ur_kernel_handle_t hKernel ///< [in] handle for the Kernel to release ) { - auto pfnRelease = context.urDdiTable.Kernel.pfnRelease; + auto pfnRelease = getContext()->urDdiTable.Kernel.pfnRelease; if (nullptr == pfnRelease) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - context.logger.debug("==== urKernelRelease"); + getContext()->logger.debug("==== urKernelRelease"); UR_CALL(pfnRelease(hKernel)); - if (auto KernelInfo = context.interceptor->getKernelInfo(hKernel)) { + if (auto KernelInfo = getContext()->interceptor->getKernelInfo(hKernel)) { if (--KernelInfo->RefCount != 0) { return UR_RESULT_SUCCESS; } - UR_CALL(context.interceptor->eraseKernel(hKernel)); + UR_CALL(getContext()->interceptor->eraseKernel(hKernel)); } return UR_RESULT_SUCCESS; @@ -1180,19 +1187,19 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgValue( const void *pArgValue ///< [in] argument value represented as matching arg type. ) { - auto pfnSetArgValue = context.urDdiTable.Kernel.pfnSetArgValue; + auto pfnSetArgValue = getContext()->urDdiTable.Kernel.pfnSetArgValue; if (nullptr == pfnSetArgValue) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - context.logger.debug("==== urKernelSetArgValue"); + getContext()->logger.debug("==== urKernelSetArgValue"); std::shared_ptr MemBuffer; if (argSize == sizeof(ur_mem_handle_t) && - (MemBuffer = context.interceptor->getMemBuffer( + (MemBuffer = getContext()->interceptor->getMemBuffer( *ur_cast(pArgValue)))) { - auto KernelInfo = context.interceptor->getKernelInfo(hKernel); + auto KernelInfo = getContext()->interceptor->getKernelInfo(hKernel); std::scoped_lock Guard(KernelInfo->Mutex); KernelInfo->BufferArgs[argIndex] = std::move(MemBuffer); } else { @@ -1212,16 +1219,16 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgMemObj( *pProperties, ///< [in][optional] pointer to Memory object properties. ur_mem_handle_t hArgValue ///< [in][optional] handle of Memory object. ) { - auto pfnSetArgMemObj = context.urDdiTable.Kernel.pfnSetArgMemObj; + auto pfnSetArgMemObj = getContext()->urDdiTable.Kernel.pfnSetArgMemObj; if (nullptr == pfnSetArgMemObj) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - context.logger.debug("==== urKernelSetArgMemObj"); + getContext()->logger.debug("==== urKernelSetArgMemObj"); - if (auto MemBuffer = context.interceptor->getMemBuffer(hArgValue)) { - auto KernelInfo = context.interceptor->getKernelInfo(hKernel); + if (auto MemBuffer = getContext()->interceptor->getMemBuffer(hArgValue)) { + auto KernelInfo = getContext()->interceptor->getKernelInfo(hKernel); std::scoped_lock Guard(KernelInfo->Mutex); KernelInfo->BufferArgs[argIndex] = std::move(MemBuffer); } else { @@ -1241,17 +1248,18 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgLocal( const ur_kernel_arg_local_properties_t *pProperties ///< [in][optional] pointer to local buffer properties. ) { - auto pfnSetArgLocal = context.urDdiTable.Kernel.pfnSetArgLocal; + auto pfnSetArgLocal = getContext()->urDdiTable.Kernel.pfnSetArgLocal; if (nullptr == pfnSetArgLocal) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - context.logger.debug("==== urKernelSetArgLocal (argIndex={}, argSize={})", - argIndex, argSize); + getContext()->logger.debug( + "==== urKernelSetArgLocal (argIndex={}, argSize={})", argIndex, + argSize); { - auto KI = context.interceptor->getKernelInfo(hKernel); + auto KI = getContext()->interceptor->getKernelInfo(hKernel); std::scoped_lock Guard(KI->Mutex); // TODO: get local variable alignment auto argSizeWithRZ = GetSizeAndRedzoneSizeForLocal( @@ -1283,9 +1291,9 @@ __urdlllocal ur_result_t UR_APICALL urGetContextProcAddrTable( return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_sanitizer_layer::context.version) != + if (UR_MAJOR_VERSION(ur_sanitizer_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_sanitizer_layer::context.version) > + UR_MINOR_VERSION(ur_sanitizer_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -1317,9 +1325,9 @@ __urdlllocal ur_result_t UR_APICALL urGetProgramProcAddrTable( return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_sanitizer_layer::context.version) != + if (UR_MAJOR_VERSION(ur_sanitizer_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_sanitizer_layer::context.version) > + UR_MINOR_VERSION(ur_sanitizer_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -1347,9 +1355,9 @@ __urdlllocal ur_result_t UR_APICALL urGetKernelProcAddrTable( return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_sanitizer_layer::context.version) != + if (UR_MAJOR_VERSION(ur_sanitizer_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_sanitizer_layer::context.version) > + UR_MINOR_VERSION(ur_sanitizer_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -1382,9 +1390,9 @@ __urdlllocal ur_result_t UR_APICALL urGetMemProcAddrTable( return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_sanitizer_layer::context.version) != + if (UR_MAJOR_VERSION(ur_sanitizer_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_sanitizer_layer::context.version) > + UR_MINOR_VERSION(ur_sanitizer_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -1416,9 +1424,9 @@ __urdlllocal ur_result_t UR_APICALL urGetProgramExpProcAddrTable( return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_sanitizer_layer::context.version) != + if (UR_MAJOR_VERSION(ur_sanitizer_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_sanitizer_layer::context.version) > + UR_MINOR_VERSION(ur_sanitizer_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -1447,9 +1455,9 @@ __urdlllocal ur_result_t UR_APICALL urGetEnqueueProcAddrTable( return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_sanitizer_layer::context.version) != + if (UR_MAJOR_VERSION(ur_sanitizer_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_sanitizer_layer::context.version) > + UR_MINOR_VERSION(ur_sanitizer_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -1489,9 +1497,9 @@ __urdlllocal ur_result_t UR_APICALL urGetUSMProcAddrTable( return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_sanitizer_layer::context.version) != + if (UR_MAJOR_VERSION(ur_sanitizer_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_sanitizer_layer::context.version) > + UR_MINOR_VERSION(ur_sanitizer_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -1512,19 +1520,19 @@ ur_result_t context_t::init(ur_dditable_t *dditable, ur_result_t result = UR_RESULT_SUCCESS; if (enabledLayerNames.count("UR_LAYER_ASAN")) { - context.enabledType = SanitizerType::AddressSanitizer; + getContext()->enabledType = SanitizerType::AddressSanitizer; } else if (enabledLayerNames.count("UR_LAYER_MSAN")) { - context.enabledType = SanitizerType::MemorySanitizer; + getContext()->enabledType = SanitizerType::MemorySanitizer; } else if (enabledLayerNames.count("UR_LAYER_TSAN")) { - context.enabledType = SanitizerType::ThreadSanitizer; + getContext()->enabledType = SanitizerType::ThreadSanitizer; } // Only support AddressSanitizer now - if (context.enabledType != SanitizerType::AddressSanitizer) { + if (getContext()->enabledType != SanitizerType::AddressSanitizer) { return result; } - if (context.enabledType == SanitizerType::AddressSanitizer) { + if (getContext()->enabledType == SanitizerType::AddressSanitizer) { if (!(dditable->VirtualMem.pfnReserve && dditable->VirtualMem.pfnMap && dditable->VirtualMem.pfnGranularityGetInfo)) { die("Some VirtualMem APIs are needed to enable UR_LAYER_ASAN"); diff --git a/source/loader/layers/sanitizer/ur_sanitizer_layer.cpp b/source/loader/layers/sanitizer/ur_sanitizer_layer.cpp index 5ced93fb24..f47970d828 100644 --- a/source/loader/layers/sanitizer/ur_sanitizer_layer.cpp +++ b/source/loader/layers/sanitizer/ur_sanitizer_layer.cpp @@ -14,7 +14,7 @@ #include "asan_interceptor.hpp" namespace ur_sanitizer_layer { -context_t context; +context_t *getContext() { return context_t::get(); } /////////////////////////////////////////////////////////////////////////////// context_t::context_t() diff --git a/source/loader/layers/sanitizer/ur_sanitizer_layer.hpp b/source/loader/layers/sanitizer/ur_sanitizer_layer.hpp index 32f01103d5..c1e6969cd0 100644 --- a/source/loader/layers/sanitizer/ur_sanitizer_layer.hpp +++ b/source/loader/layers/sanitizer/ur_sanitizer_layer.hpp @@ -13,6 +13,7 @@ #pragma once #include "logger/ur_logger.hpp" +#include "ur/ur.hpp" #include "ur_proxy_layer.hpp" #define SANITIZER_COMP_NAME "sanitizer layer" @@ -29,7 +30,8 @@ enum class SanitizerType { }; /////////////////////////////////////////////////////////////////////////////// -class __urdlllocal context_t : public proxy_layer_context_t { +class __urdlllocal context_t : public proxy_layer_context_t, + public AtomicSingleton { public: ur_dditable_t urDdiTable = {}; logger::Logger logger; @@ -51,5 +53,5 @@ class __urdlllocal context_t : public proxy_layer_context_t { ur_result_t tearDown() override; }; -extern context_t context; +context_t *getContext(); } // namespace ur_sanitizer_layer diff --git a/source/loader/layers/sanitizer/ur_sanitizer_utils.cpp b/source/loader/layers/sanitizer/ur_sanitizer_utils.cpp index 90dc435d84..daca24bc24 100644 --- a/source/loader/layers/sanitizer/ur_sanitizer_utils.cpp +++ b/source/loader/layers/sanitizer/ur_sanitizer_utils.cpp @@ -17,28 +17,28 @@ namespace ur_sanitizer_layer { ManagedQueue::ManagedQueue(ur_context_handle_t Context, ur_device_handle_t Device) { - [[maybe_unused]] auto Result = - context.urDdiTable.Queue.pfnCreate(Context, Device, nullptr, &Handle); + [[maybe_unused]] auto Result = getContext()->urDdiTable.Queue.pfnCreate( + Context, Device, nullptr, &Handle); assert(Result == UR_RESULT_SUCCESS && "Failed to create ManagedQueue"); - context.logger.debug(">>> ManagedQueue {}", (void *)Handle); + getContext()->logger.debug(">>> ManagedQueue {}", (void *)Handle); } ManagedQueue::~ManagedQueue() { - context.logger.debug("<<< ~ManagedQueue {}", (void *)Handle); + getContext()->logger.debug("<<< ~ManagedQueue {}", (void *)Handle); [[maybe_unused]] ur_result_t Result; - Result = context.urDdiTable.Queue.pfnFinish(Handle); + Result = getContext()->urDdiTable.Queue.pfnFinish(Handle); if (Result != UR_RESULT_SUCCESS) { - context.logger.error("Failed to finish ManagedQueue: {}", Result); + getContext()->logger.error("Failed to finish ManagedQueue: {}", Result); } assert(Result == UR_RESULT_SUCCESS && "Failed to finish ManagedQueue"); - Result = context.urDdiTable.Queue.pfnRelease(Handle); + Result = getContext()->urDdiTable.Queue.pfnRelease(Handle); assert(Result == UR_RESULT_SUCCESS && "Failed to release ManagedQueue"); } ur_context_handle_t GetContext(ur_queue_handle_t Queue) { ur_context_handle_t Context{}; - [[maybe_unused]] auto Result = context.urDdiTable.Queue.pfnGetInfo( + [[maybe_unused]] auto Result = getContext()->urDdiTable.Queue.pfnGetInfo( Queue, UR_QUEUE_INFO_CONTEXT, sizeof(ur_context_handle_t), &Context, nullptr); assert(Result == UR_RESULT_SUCCESS && "getContext() failed"); @@ -47,7 +47,7 @@ ur_context_handle_t GetContext(ur_queue_handle_t Queue) { ur_context_handle_t GetContext(ur_program_handle_t Program) { ur_context_handle_t Context{}; - [[maybe_unused]] auto Result = context.urDdiTable.Program.pfnGetInfo( + [[maybe_unused]] auto Result = getContext()->urDdiTable.Program.pfnGetInfo( Program, UR_PROGRAM_INFO_CONTEXT, sizeof(ur_context_handle_t), &Context, nullptr); assert(Result == UR_RESULT_SUCCESS && "getContext() failed"); @@ -56,7 +56,7 @@ ur_context_handle_t GetContext(ur_program_handle_t Program) { ur_context_handle_t GetContext(ur_kernel_handle_t Kernel) { ur_context_handle_t Context{}; - [[maybe_unused]] auto Result = context.urDdiTable.Kernel.pfnGetInfo( + [[maybe_unused]] auto Result = getContext()->urDdiTable.Kernel.pfnGetInfo( Kernel, UR_KERNEL_INFO_CONTEXT, sizeof(ur_context_handle_t), &Context, nullptr); assert(Result == UR_RESULT_SUCCESS && "getContext() failed"); @@ -65,7 +65,7 @@ ur_context_handle_t GetContext(ur_kernel_handle_t Kernel) { ur_device_handle_t GetDevice(ur_queue_handle_t Queue) { ur_device_handle_t Device{}; - [[maybe_unused]] auto Result = context.urDdiTable.Queue.pfnGetInfo( + [[maybe_unused]] auto Result = getContext()->urDdiTable.Queue.pfnGetInfo( Queue, UR_QUEUE_INFO_DEVICE, sizeof(ur_device_handle_t), &Device, nullptr); assert(Result == UR_RESULT_SUCCESS && "getDevice() failed"); @@ -74,7 +74,7 @@ ur_device_handle_t GetDevice(ur_queue_handle_t Queue) { ur_program_handle_t GetProgram(ur_kernel_handle_t Kernel) { ur_program_handle_t Program{}; - [[maybe_unused]] auto Result = context.urDdiTable.Kernel.pfnGetInfo( + [[maybe_unused]] auto Result = getContext()->urDdiTable.Kernel.pfnGetInfo( Kernel, UR_KERNEL_INFO_PROGRAM, sizeof(ur_program_handle_t), &Program, nullptr); assert(Result == UR_RESULT_SUCCESS && "getProgram() failed"); @@ -83,7 +83,7 @@ ur_program_handle_t GetProgram(ur_kernel_handle_t Kernel) { size_t GetDeviceLocalMemorySize(ur_device_handle_t Device) { size_t LocalMemorySize{}; - [[maybe_unused]] auto Result = context.urDdiTable.Device.pfnGetInfo( + [[maybe_unused]] auto Result = getContext()->urDdiTable.Device.pfnGetInfo( Device, UR_DEVICE_INFO_LOCAL_MEM_SIZE, sizeof(LocalMemorySize), &LocalMemorySize, nullptr); assert(Result == UR_RESULT_SUCCESS && "getLocalMemorySize() failed"); @@ -92,12 +92,12 @@ size_t GetDeviceLocalMemorySize(ur_device_handle_t Device) { std::string GetKernelName(ur_kernel_handle_t Kernel) { size_t KernelNameSize = 0; - [[maybe_unused]] auto Result = context.urDdiTable.Kernel.pfnGetInfo( + [[maybe_unused]] auto Result = getContext()->urDdiTable.Kernel.pfnGetInfo( Kernel, UR_KERNEL_INFO_FUNCTION_NAME, 0, nullptr, &KernelNameSize); assert(Result == UR_RESULT_SUCCESS && "getKernelName() failed"); std::vector KernelNameBuf(KernelNameSize); - Result = context.urDdiTable.Kernel.pfnGetInfo( + Result = getContext()->urDdiTable.Kernel.pfnGetInfo( Kernel, UR_KERNEL_INFO_FUNCTION_NAME, KernelNameSize, KernelNameBuf.data(), nullptr); assert(Result == UR_RESULT_SUCCESS && "getKernelName() failed"); @@ -109,15 +109,15 @@ ur_device_handle_t GetUSMAllocDevice(ur_context_handle_t Context, const void *MemPtr) { ur_device_handle_t Device{}; // if urGetMemAllocInfo failed, return nullptr - context.urDdiTable.USM.pfnGetMemAllocInfo(Context, MemPtr, - UR_USM_ALLOC_INFO_DEVICE, - sizeof(Device), &Device, nullptr); + getContext()->urDdiTable.USM.pfnGetMemAllocInfo( + Context, MemPtr, UR_USM_ALLOC_INFO_DEVICE, sizeof(Device), &Device, + nullptr); return Device; } DeviceType GetDeviceType(ur_device_handle_t Device) { ur_device_type_t DeviceType = UR_DEVICE_TYPE_DEFAULT; - [[maybe_unused]] auto Result = context.urDdiTable.Device.pfnGetInfo( + [[maybe_unused]] auto Result = getContext()->urDdiTable.Device.pfnGetInfo( Device, UR_DEVICE_INFO_TYPE, sizeof(DeviceType), &DeviceType, nullptr); assert(Result == UR_RESULT_SUCCESS && "getDeviceType() failed"); switch (DeviceType) { @@ -136,13 +136,14 @@ DeviceType GetDeviceType(ur_device_handle_t Device) { std::vector GetProgramDevices(ur_program_handle_t Program) { size_t PropSize; - [[maybe_unused]] ur_result_t Result = context.urDdiTable.Program.pfnGetInfo( - Program, UR_PROGRAM_INFO_DEVICES, 0, nullptr, &PropSize); + [[maybe_unused]] ur_result_t Result = + getContext()->urDdiTable.Program.pfnGetInfo( + Program, UR_PROGRAM_INFO_DEVICES, 0, nullptr, &PropSize); assert(Result == UR_RESULT_SUCCESS); std::vector Devices; Devices.resize(PropSize / sizeof(ur_device_handle_t)); - Result = context.urDdiTable.Program.pfnGetInfo( + Result = getContext()->urDdiTable.Program.pfnGetInfo( Program, UR_PROGRAM_INFO_DEVICES, PropSize, Devices.data(), nullptr); assert(Result == UR_RESULT_SUCCESS); @@ -151,7 +152,7 @@ std::vector GetProgramDevices(ur_program_handle_t Program) { uint32_t GetKernelNumArgs(ur_kernel_handle_t Kernel) { uint32_t NumArgs = 0; - [[maybe_unused]] auto Res = context.urDdiTable.Kernel.pfnGetInfo( + [[maybe_unused]] auto Res = getContext()->urDdiTable.Kernel.pfnGetInfo( Kernel, UR_KERNEL_INFO_NUM_ARGS, sizeof(NumArgs), &NumArgs, nullptr); assert(Res == UR_RESULT_SUCCESS); return NumArgs; @@ -160,7 +161,7 @@ uint32_t GetKernelNumArgs(ur_kernel_handle_t Kernel) { size_t GetKernelLocalMemorySize(ur_kernel_handle_t Kernel, ur_device_handle_t Device) { size_t Size = 0; - [[maybe_unused]] auto Res = context.urDdiTable.Kernel.pfnGetGroupInfo( + [[maybe_unused]] auto Res = getContext()->urDdiTable.Kernel.pfnGetGroupInfo( Kernel, Device, UR_KERNEL_GROUP_INFO_LOCAL_MEM_SIZE, sizeof(size_t), &Size, nullptr); assert(Res == UR_RESULT_SUCCESS); @@ -170,7 +171,7 @@ size_t GetKernelLocalMemorySize(ur_kernel_handle_t Kernel, size_t GetKernelPrivateMemorySize(ur_kernel_handle_t Kernel, ur_device_handle_t Device) { size_t Size = 0; - [[maybe_unused]] auto Res = context.urDdiTable.Kernel.pfnGetGroupInfo( + [[maybe_unused]] auto Res = getContext()->urDdiTable.Kernel.pfnGetGroupInfo( Kernel, Device, UR_KERNEL_GROUP_INFO_PRIVATE_MEM_SIZE, sizeof(size_t), &Size, nullptr); assert(Res == UR_RESULT_SUCCESS); @@ -181,7 +182,7 @@ size_t GetVirtualMemGranularity(ur_context_handle_t Context, ur_device_handle_t Device) { size_t Size; [[maybe_unused]] auto Result = - context.urDdiTable.VirtualMem.pfnGranularityGetInfo( + getContext()->urDdiTable.VirtualMem.pfnGranularityGetInfo( Context, Device, UR_VIRTUAL_MEM_GRANULARITY_INFO_RECOMMENDED, sizeof(Size), &Size, nullptr); assert(Result == UR_RESULT_SUCCESS); diff --git a/source/loader/layers/tracing/ur_tracing_layer.cpp b/source/loader/layers/tracing/ur_tracing_layer.cpp index 01243a670d..2170bdd993 100644 --- a/source/loader/layers/tracing/ur_tracing_layer.cpp +++ b/source/loader/layers/tracing/ur_tracing_layer.cpp @@ -14,21 +14,51 @@ #include "ur_util.hpp" #include "xpti/xpti_data_types.h" #include "xpti/xpti_trace_framework.h" +#include #include #include namespace ur_tracing_layer { -context_t context; +context_t *getContext() { return context_t::get(); } constexpr auto CALL_STREAM_NAME = "ur"; constexpr auto STREAM_VER_MAJOR = UR_MAJOR_VERSION(UR_API_VERSION_CURRENT); constexpr auto STREAM_VER_MINOR = UR_MINOR_VERSION(UR_API_VERSION_CURRENT); +// UR loader can be inited and teardown'ed multiple times in a single process. +// Unfortunately this doesn't match the semantics of XPTI, which can be initialized +// and finalized exactly once. To workaround this, XPTI is globally initialized on +// first use and finalized in the destructor. +class XptiContext { + XptiContext() { + xptiFrameworkInitialize(); + inited = true; + } + + ~XptiContext() { + xptiFrameworkFinalize(); + inited = false; + } + + // Accessing this after destruction is technically UB, but if we get there, + // it means something is calling UR after it has been destroyed at program + // exit. + std::atomic_bool inited; + + public: + static bool running() { + static XptiContext context; + return context.inited; + } +}; + static thread_local xpti_td *activeEvent; /////////////////////////////////////////////////////////////////////////////// context_t::context_t() : logger(logger::create_logger("tracing", true, true)) { - xptiFrameworkInitialize(); + if (!XptiContext::running()) { + return; + } call_stream_id = xptiRegisterStream(CALL_STREAM_NAME); std::ostringstream streamv; @@ -41,12 +71,20 @@ bool context_t::isAvailable() const { return true; } void context_t::notify(uint16_t trace_type, uint32_t id, const char *name, void *args, ur_result_t *resultp, uint64_t instance) { + if (!XptiContext::running()) { + return; + } + xpti::function_with_args_t payload{id, name, args, resultp, nullptr}; xptiNotifySubscribers(call_stream_id, trace_type, nullptr, activeEvent, instance, &payload); } uint64_t context_t::notify_begin(uint32_t id, const char *name, void *args) { + if (!XptiContext::running()) { + return 0; + } + if (auto loc = codelocData.get_codeloc()) { xpti::payload_t payload = xpti::payload_t(loc->functionName, loc->sourceFile, loc->lineNumber, @@ -65,14 +103,20 @@ uint64_t context_t::notify_begin(uint32_t id, const char *name, void *args) { void context_t::notify_end(uint32_t id, const char *name, void *args, ur_result_t *resultp, uint64_t instance) { + if (!XptiContext::running()) { + return; + } + notify((uint16_t)xpti::trace_point_type_t::function_with_args_end, id, name, args, resultp, instance); } /////////////////////////////////////////////////////////////////////////////// context_t::~context_t() { - xptiFinalize(CALL_STREAM_NAME); + if (!XptiContext::running()) { + return; + } - xptiFrameworkFinalize(); + xptiFinalize(CALL_STREAM_NAME); } } // namespace ur_tracing_layer diff --git a/source/loader/layers/tracing/ur_tracing_layer.hpp b/source/loader/layers/tracing/ur_tracing_layer.hpp index 84a109fb4f..198ad63a56 100644 --- a/source/loader/layers/tracing/ur_tracing_layer.hpp +++ b/source/loader/layers/tracing/ur_tracing_layer.hpp @@ -22,7 +22,8 @@ namespace ur_tracing_layer { /////////////////////////////////////////////////////////////////////////////// -class __urdlllocal context_t : public proxy_layer_context_t { +class __urdlllocal context_t : public proxy_layer_context_t, + public AtomicSingleton { public: ur_dditable_t urDdiTable = {}; codeloc_data codelocData; @@ -50,7 +51,7 @@ class __urdlllocal context_t : public proxy_layer_context_t { const std::string name = "UR_LAYER_TRACING"; }; -extern context_t context; +context_t *getContext(); } // namespace ur_tracing_layer #endif /* UR_TRACING_LAYER_H */ diff --git a/source/loader/layers/tracing/ur_trcddi.cpp b/source/loader/layers/tracing/ur_trcddi.cpp index a9b4bbf38d..67e63e8c03 100644 --- a/source/loader/layers/tracing/ur_trcddi.cpp +++ b/source/loader/layers/tracing/ur_trcddi.cpp @@ -30,26 +30,26 @@ __urdlllocal ur_result_t UR_APICALL urAdapterGet( uint32_t * pNumAdapters ///< [out][optional] returns the total number of adapters available. ) { - auto pfnAdapterGet = context.urDdiTable.Global.pfnAdapterGet; + auto pfnAdapterGet = getContext()->urDdiTable.Global.pfnAdapterGet; if (nullptr == pfnAdapterGet) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_adapter_get_params_t params = {&NumEntries, &phAdapters, &pNumAdapters}; - uint64_t instance = - context.notify_begin(UR_FUNCTION_ADAPTER_GET, "urAdapterGet", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_ADAPTER_GET, + "urAdapterGet", ¶ms); - context.logger.info("---> urAdapterGet"); + getContext()->logger.info("---> urAdapterGet"); ur_result_t result = pfnAdapterGet(NumEntries, phAdapters, pNumAdapters); - context.notify_end(UR_FUNCTION_ADAPTER_GET, "urAdapterGet", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_ADAPTER_GET, "urAdapterGet", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_ADAPTER_GET, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -59,27 +59,27 @@ __urdlllocal ur_result_t UR_APICALL urAdapterGet( __urdlllocal ur_result_t UR_APICALL urAdapterRelease( ur_adapter_handle_t hAdapter ///< [in][release] Adapter handle to release ) { - auto pfnAdapterRelease = context.urDdiTable.Global.pfnAdapterRelease; + auto pfnAdapterRelease = getContext()->urDdiTable.Global.pfnAdapterRelease; if (nullptr == pfnAdapterRelease) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_adapter_release_params_t params = {&hAdapter}; - uint64_t instance = context.notify_begin(UR_FUNCTION_ADAPTER_RELEASE, - "urAdapterRelease", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_ADAPTER_RELEASE, + "urAdapterRelease", ¶ms); - context.logger.info("---> urAdapterRelease"); + getContext()->logger.info("---> urAdapterRelease"); ur_result_t result = pfnAdapterRelease(hAdapter); - context.notify_end(UR_FUNCTION_ADAPTER_RELEASE, "urAdapterRelease", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_ADAPTER_RELEASE, "urAdapterRelease", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_ADAPTER_RELEASE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -89,27 +89,27 @@ __urdlllocal ur_result_t UR_APICALL urAdapterRelease( __urdlllocal ur_result_t UR_APICALL urAdapterRetain( ur_adapter_handle_t hAdapter ///< [in] Adapter handle to retain ) { - auto pfnAdapterRetain = context.urDdiTable.Global.pfnAdapterRetain; + auto pfnAdapterRetain = getContext()->urDdiTable.Global.pfnAdapterRetain; if (nullptr == pfnAdapterRetain) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_adapter_retain_params_t params = {&hAdapter}; - uint64_t instance = context.notify_begin(UR_FUNCTION_ADAPTER_RETAIN, - "urAdapterRetain", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_ADAPTER_RETAIN, + "urAdapterRetain", ¶ms); - context.logger.info("---> urAdapterRetain"); + getContext()->logger.info("---> urAdapterRetain"); ur_result_t result = pfnAdapterRetain(hAdapter); - context.notify_end(UR_FUNCTION_ADAPTER_RETAIN, "urAdapterRetain", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_ADAPTER_RETAIN, "urAdapterRetain", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_ADAPTER_RETAIN, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -126,7 +126,7 @@ __urdlllocal ur_result_t UR_APICALL urAdapterGetLastError( ///< be stored. ) { auto pfnAdapterGetLastError = - context.urDdiTable.Global.pfnAdapterGetLastError; + getContext()->urDdiTable.Global.pfnAdapterGetLastError; if (nullptr == pfnAdapterGetLastError) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -134,20 +134,21 @@ __urdlllocal ur_result_t UR_APICALL urAdapterGetLastError( ur_adapter_get_last_error_params_t params = {&hAdapter, &ppMessage, &pError}; - uint64_t instance = context.notify_begin(UR_FUNCTION_ADAPTER_GET_LAST_ERROR, - "urAdapterGetLastError", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_ADAPTER_GET_LAST_ERROR, "urAdapterGetLastError", ¶ms); - context.logger.info("---> urAdapterGetLastError"); + getContext()->logger.info("---> urAdapterGetLastError"); ur_result_t result = pfnAdapterGetLastError(hAdapter, ppMessage, pError); - context.notify_end(UR_FUNCTION_ADAPTER_GET_LAST_ERROR, - "urAdapterGetLastError", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_ADAPTER_GET_LAST_ERROR, + "urAdapterGetLastError", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ADAPTER_GET_LAST_ERROR, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -167,7 +168,7 @@ __urdlllocal ur_result_t UR_APICALL urAdapterGetInfo( size_t * pPropSizeRet ///< [out][optional] pointer to the actual number of bytes being queried by pPropValue. ) { - auto pfnAdapterGetInfo = context.urDdiTable.Global.pfnAdapterGetInfo; + auto pfnAdapterGetInfo = getContext()->urDdiTable.Global.pfnAdapterGetInfo; if (nullptr == pfnAdapterGetInfo) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -175,21 +176,21 @@ __urdlllocal ur_result_t UR_APICALL urAdapterGetInfo( ur_adapter_get_info_params_t params = {&hAdapter, &propName, &propSize, &pPropValue, &pPropSizeRet}; - uint64_t instance = context.notify_begin(UR_FUNCTION_ADAPTER_GET_INFO, - "urAdapterGetInfo", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_ADAPTER_GET_INFO, + "urAdapterGetInfo", ¶ms); - context.logger.info("---> urAdapterGetInfo"); + getContext()->logger.info("---> urAdapterGetInfo"); ur_result_t result = pfnAdapterGetInfo(hAdapter, propName, propSize, pPropValue, pPropSizeRet); - context.notify_end(UR_FUNCTION_ADAPTER_GET_INFO, "urAdapterGetInfo", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_ADAPTER_GET_INFO, "urAdapterGetInfo", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_ADAPTER_GET_INFO, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -212,7 +213,7 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGet( uint32_t * pNumPlatforms ///< [out][optional] returns the total number of platforms available. ) { - auto pfnGet = context.urDdiTable.Platform.pfnGet; + auto pfnGet = getContext()->urDdiTable.Platform.pfnGet; if (nullptr == pfnGet) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -220,21 +221,21 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGet( ur_platform_get_params_t params = {&phAdapters, &NumAdapters, &NumEntries, &phPlatforms, &pNumPlatforms}; - uint64_t instance = context.notify_begin(UR_FUNCTION_PLATFORM_GET, - "urPlatformGet", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_PLATFORM_GET, + "urPlatformGet", ¶ms); - context.logger.info("---> urPlatformGet"); + getContext()->logger.info("---> urPlatformGet"); ur_result_t result = pfnGet(phAdapters, NumAdapters, NumEntries, phPlatforms, pNumPlatforms); - context.notify_end(UR_FUNCTION_PLATFORM_GET, "urPlatformGet", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_PLATFORM_GET, "urPlatformGet", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_PLATFORM_GET, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -254,7 +255,7 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetInfo( size_t * pPropSizeRet ///< [out][optional] pointer to the actual number of bytes being queried by pPlatformInfo. ) { - auto pfnGetInfo = context.urDdiTable.Platform.pfnGetInfo; + auto pfnGetInfo = getContext()->urDdiTable.Platform.pfnGetInfo; if (nullptr == pfnGetInfo) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -262,21 +263,21 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetInfo( ur_platform_get_info_params_t params = {&hPlatform, &propName, &propSize, &pPropValue, &pPropSizeRet}; - uint64_t instance = context.notify_begin(UR_FUNCTION_PLATFORM_GET_INFO, - "urPlatformGetInfo", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_PLATFORM_GET_INFO, "urPlatformGetInfo", ¶ms); - context.logger.info("---> urPlatformGetInfo"); + getContext()->logger.info("---> urPlatformGetInfo"); ur_result_t result = pfnGetInfo(hPlatform, propName, propSize, pPropValue, pPropSizeRet); - context.notify_end(UR_FUNCTION_PLATFORM_GET_INFO, "urPlatformGetInfo", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_PLATFORM_GET_INFO, "urPlatformGetInfo", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_PLATFORM_GET_INFO, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -287,7 +288,7 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetApiVersion( ur_platform_handle_t hPlatform, ///< [in] handle of the platform ur_api_version_t *pVersion ///< [out] api version ) { - auto pfnGetApiVersion = context.urDdiTable.Platform.pfnGetApiVersion; + auto pfnGetApiVersion = getContext()->urDdiTable.Platform.pfnGetApiVersion; if (nullptr == pfnGetApiVersion) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -295,20 +296,21 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetApiVersion( ur_platform_get_api_version_params_t params = {&hPlatform, &pVersion}; uint64_t instance = - context.notify_begin(UR_FUNCTION_PLATFORM_GET_API_VERSION, - "urPlatformGetApiVersion", ¶ms); + getContext()->notify_begin(UR_FUNCTION_PLATFORM_GET_API_VERSION, + "urPlatformGetApiVersion", ¶ms); - context.logger.info("---> urPlatformGetApiVersion"); + getContext()->logger.info("---> urPlatformGetApiVersion"); ur_result_t result = pfnGetApiVersion(hPlatform, pVersion); - context.notify_end(UR_FUNCTION_PLATFORM_GET_API_VERSION, - "urPlatformGetApiVersion", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_PLATFORM_GET_API_VERSION, + "urPlatformGetApiVersion", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_PLATFORM_GET_API_VERSION, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -320,7 +322,8 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetNativeHandle( ur_native_handle_t * phNativePlatform ///< [out] a pointer to the native handle of the platform. ) { - auto pfnGetNativeHandle = context.urDdiTable.Platform.pfnGetNativeHandle; + auto pfnGetNativeHandle = + getContext()->urDdiTable.Platform.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -329,20 +332,21 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetNativeHandle( ur_platform_get_native_handle_params_t params = {&hPlatform, &phNativePlatform}; uint64_t instance = - context.notify_begin(UR_FUNCTION_PLATFORM_GET_NATIVE_HANDLE, - "urPlatformGetNativeHandle", ¶ms); + getContext()->notify_begin(UR_FUNCTION_PLATFORM_GET_NATIVE_HANDLE, + "urPlatformGetNativeHandle", ¶ms); - context.logger.info("---> urPlatformGetNativeHandle"); + getContext()->logger.info("---> urPlatformGetNativeHandle"); ur_result_t result = pfnGetNativeHandle(hPlatform, phNativePlatform); - context.notify_end(UR_FUNCTION_PLATFORM_GET_NATIVE_HANDLE, - "urPlatformGetNativeHandle", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_PLATFORM_GET_NATIVE_HANDLE, + "urPlatformGetNativeHandle", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_PLATFORM_GET_NATIVE_HANDLE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -360,7 +364,7 @@ __urdlllocal ur_result_t UR_APICALL urPlatformCreateWithNativeHandle( phPlatform ///< [out] pointer to the handle of the platform object created. ) { auto pfnCreateWithNativeHandle = - context.urDdiTable.Platform.pfnCreateWithNativeHandle; + getContext()->urDdiTable.Platform.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -368,23 +372,23 @@ __urdlllocal ur_result_t UR_APICALL urPlatformCreateWithNativeHandle( ur_platform_create_with_native_handle_params_t params = { &hNativePlatform, &hAdapter, &pProperties, &phPlatform}; - uint64_t instance = - context.notify_begin(UR_FUNCTION_PLATFORM_CREATE_WITH_NATIVE_HANDLE, - "urPlatformCreateWithNativeHandle", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_PLATFORM_CREATE_WITH_NATIVE_HANDLE, + "urPlatformCreateWithNativeHandle", ¶ms); - context.logger.info("---> urPlatformCreateWithNativeHandle"); + getContext()->logger.info("---> urPlatformCreateWithNativeHandle"); ur_result_t result = pfnCreateWithNativeHandle(hNativePlatform, hAdapter, pProperties, phPlatform); - context.notify_end(UR_FUNCTION_PLATFORM_CREATE_WITH_NATIVE_HANDLE, - "urPlatformCreateWithNativeHandle", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_PLATFORM_CREATE_WITH_NATIVE_HANDLE, + "urPlatformCreateWithNativeHandle", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_PLATFORM_CREATE_WITH_NATIVE_HANDLE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -399,7 +403,8 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetBackendOption( ppPlatformOption ///< [out] returns the correct platform specific compiler option based on ///< the frontend option. ) { - auto pfnGetBackendOption = context.urDdiTable.Platform.pfnGetBackendOption; + auto pfnGetBackendOption = + getContext()->urDdiTable.Platform.pfnGetBackendOption; if (nullptr == pfnGetBackendOption) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -408,22 +413,22 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetBackendOption( ur_platform_get_backend_option_params_t params = { &hPlatform, &pFrontendOption, &ppPlatformOption}; uint64_t instance = - context.notify_begin(UR_FUNCTION_PLATFORM_GET_BACKEND_OPTION, - "urPlatformGetBackendOption", ¶ms); + getContext()->notify_begin(UR_FUNCTION_PLATFORM_GET_BACKEND_OPTION, + "urPlatformGetBackendOption", ¶ms); - context.logger.info("---> urPlatformGetBackendOption"); + getContext()->logger.info("---> urPlatformGetBackendOption"); ur_result_t result = pfnGetBackendOption(hPlatform, pFrontendOption, ppPlatformOption); - context.notify_end(UR_FUNCTION_PLATFORM_GET_BACKEND_OPTION, - "urPlatformGetBackendOption", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_PLATFORM_GET_BACKEND_OPTION, + "urPlatformGetBackendOption", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_PLATFORM_GET_BACKEND_OPTION, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -445,7 +450,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGet( uint32_t *pNumDevices ///< [out][optional] pointer to the number of devices. ///< pNumDevices will be updated with the total number of devices available. ) { - auto pfnGet = context.urDdiTable.Device.pfnGet; + auto pfnGet = getContext()->urDdiTable.Device.pfnGet; if (nullptr == pfnGet) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -453,20 +458,20 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGet( ur_device_get_params_t params = {&hPlatform, &DeviceType, &NumEntries, &phDevices, &pNumDevices}; - uint64_t instance = - context.notify_begin(UR_FUNCTION_DEVICE_GET, "urDeviceGet", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_DEVICE_GET, + "urDeviceGet", ¶ms); - context.logger.info("---> urDeviceGet"); + getContext()->logger.info("---> urDeviceGet"); ur_result_t result = pfnGet(hPlatform, DeviceType, NumEntries, phDevices, pNumDevices); - context.notify_end(UR_FUNCTION_DEVICE_GET, "urDeviceGet", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_DEVICE_GET, "urDeviceGet", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_DEVICE_GET, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -487,7 +492,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetInfo( size_t * pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of the queried propName. ) { - auto pfnGetInfo = context.urDdiTable.Device.pfnGetInfo; + auto pfnGetInfo = getContext()->urDdiTable.Device.pfnGetInfo; if (nullptr == pfnGetInfo) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -495,21 +500,21 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetInfo( ur_device_get_info_params_t params = {&hDevice, &propName, &propSize, &pPropValue, &pPropSizeRet}; - uint64_t instance = context.notify_begin(UR_FUNCTION_DEVICE_GET_INFO, - "urDeviceGetInfo", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_DEVICE_GET_INFO, + "urDeviceGetInfo", ¶ms); - context.logger.info("---> urDeviceGetInfo"); + getContext()->logger.info("---> urDeviceGetInfo"); ur_result_t result = pfnGetInfo(hDevice, propName, propSize, pPropValue, pPropSizeRet); - context.notify_end(UR_FUNCTION_DEVICE_GET_INFO, "urDeviceGetInfo", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_DEVICE_GET_INFO, "urDeviceGetInfo", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_DEVICE_GET_INFO, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -520,27 +525,27 @@ __urdlllocal ur_result_t UR_APICALL urDeviceRetain( ur_device_handle_t hDevice ///< [in] handle of the device to get a reference of. ) { - auto pfnRetain = context.urDdiTable.Device.pfnRetain; + auto pfnRetain = getContext()->urDdiTable.Device.pfnRetain; if (nullptr == pfnRetain) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_device_retain_params_t params = {&hDevice}; - uint64_t instance = context.notify_begin(UR_FUNCTION_DEVICE_RETAIN, - "urDeviceRetain", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_DEVICE_RETAIN, + "urDeviceRetain", ¶ms); - context.logger.info("---> urDeviceRetain"); + getContext()->logger.info("---> urDeviceRetain"); ur_result_t result = pfnRetain(hDevice); - context.notify_end(UR_FUNCTION_DEVICE_RETAIN, "urDeviceRetain", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_DEVICE_RETAIN, "urDeviceRetain", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_DEVICE_RETAIN, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -551,27 +556,27 @@ __urdlllocal ur_result_t UR_APICALL urDeviceRelease( ur_device_handle_t hDevice ///< [in][release] handle of the device to release. ) { - auto pfnRelease = context.urDdiTable.Device.pfnRelease; + auto pfnRelease = getContext()->urDdiTable.Device.pfnRelease; if (nullptr == pfnRelease) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_device_release_params_t params = {&hDevice}; - uint64_t instance = context.notify_begin(UR_FUNCTION_DEVICE_RELEASE, - "urDeviceRelease", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_DEVICE_RELEASE, + "urDeviceRelease", ¶ms); - context.logger.info("---> urDeviceRelease"); + getContext()->logger.info("---> urDeviceRelease"); ur_result_t result = pfnRelease(hDevice); - context.notify_end(UR_FUNCTION_DEVICE_RELEASE, "urDeviceRelease", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_DEVICE_RELEASE, "urDeviceRelease", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_DEVICE_RELEASE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -591,7 +596,7 @@ __urdlllocal ur_result_t UR_APICALL urDevicePartition( pNumDevicesRet ///< [out][optional] pointer to the number of sub-devices the device can be ///< partitioned into according to the partitioning property. ) { - auto pfnPartition = context.urDdiTable.Device.pfnPartition; + auto pfnPartition = getContext()->urDdiTable.Device.pfnPartition; if (nullptr == pfnPartition) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -599,21 +604,21 @@ __urdlllocal ur_result_t UR_APICALL urDevicePartition( ur_device_partition_params_t params = {&hDevice, &pProperties, &NumDevices, &phSubDevices, &pNumDevicesRet}; - uint64_t instance = context.notify_begin(UR_FUNCTION_DEVICE_PARTITION, - "urDevicePartition", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_DEVICE_PARTITION, "urDevicePartition", ¶ms); - context.logger.info("---> urDevicePartition"); + getContext()->logger.info("---> urDevicePartition"); ur_result_t result = pfnPartition(hDevice, pProperties, NumDevices, phSubDevices, pNumDevicesRet); - context.notify_end(UR_FUNCTION_DEVICE_PARTITION, "urDevicePartition", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_DEVICE_PARTITION, "urDevicePartition", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_DEVICE_PARTITION, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -632,7 +637,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceSelectBinary( pSelectedBinary ///< [out] the index of the selected binary in the input array of binaries. ///< If a suitable binary was not found the function returns ::UR_RESULT_ERROR_INVALID_BINARY. ) { - auto pfnSelectBinary = context.urDdiTable.Device.pfnSelectBinary; + auto pfnSelectBinary = getContext()->urDdiTable.Device.pfnSelectBinary; if (nullptr == pfnSelectBinary) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -640,21 +645,22 @@ __urdlllocal ur_result_t UR_APICALL urDeviceSelectBinary( ur_device_select_binary_params_t params = {&hDevice, &pBinaries, &NumBinaries, &pSelectedBinary}; - uint64_t instance = context.notify_begin(UR_FUNCTION_DEVICE_SELECT_BINARY, - "urDeviceSelectBinary", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_DEVICE_SELECT_BINARY, "urDeviceSelectBinary", ¶ms); - context.logger.info("---> urDeviceSelectBinary"); + getContext()->logger.info("---> urDeviceSelectBinary"); ur_result_t result = pfnSelectBinary(hDevice, pBinaries, NumBinaries, pSelectedBinary); - context.notify_end(UR_FUNCTION_DEVICE_SELECT_BINARY, "urDeviceSelectBinary", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_DEVICE_SELECT_BINARY, + "urDeviceSelectBinary", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_DEVICE_SELECT_BINARY, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -666,7 +672,8 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetNativeHandle( ur_native_handle_t *phNativeDevice ///< [out] a pointer to the native handle of the device. ) { - auto pfnGetNativeHandle = context.urDdiTable.Device.pfnGetNativeHandle; + auto pfnGetNativeHandle = + getContext()->urDdiTable.Device.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -674,20 +681,21 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetNativeHandle( ur_device_get_native_handle_params_t params = {&hDevice, &phNativeDevice}; uint64_t instance = - context.notify_begin(UR_FUNCTION_DEVICE_GET_NATIVE_HANDLE, - "urDeviceGetNativeHandle", ¶ms); + getContext()->notify_begin(UR_FUNCTION_DEVICE_GET_NATIVE_HANDLE, + "urDeviceGetNativeHandle", ¶ms); - context.logger.info("---> urDeviceGetNativeHandle"); + getContext()->logger.info("---> urDeviceGetNativeHandle"); ur_result_t result = pfnGetNativeHandle(hDevice, phNativeDevice); - context.notify_end(UR_FUNCTION_DEVICE_GET_NATIVE_HANDLE, - "urDeviceGetNativeHandle", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_DEVICE_GET_NATIVE_HANDLE, + "urDeviceGetNativeHandle", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_DEVICE_GET_NATIVE_HANDLE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -704,7 +712,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceCreateWithNativeHandle( *phDevice ///< [out] pointer to the handle of the device object created. ) { auto pfnCreateWithNativeHandle = - context.urDdiTable.Device.pfnCreateWithNativeHandle; + getContext()->urDdiTable.Device.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -713,22 +721,22 @@ __urdlllocal ur_result_t UR_APICALL urDeviceCreateWithNativeHandle( ur_device_create_with_native_handle_params_t params = { &hNativeDevice, &hPlatform, &pProperties, &phDevice}; uint64_t instance = - context.notify_begin(UR_FUNCTION_DEVICE_CREATE_WITH_NATIVE_HANDLE, - "urDeviceCreateWithNativeHandle", ¶ms); + getContext()->notify_begin(UR_FUNCTION_DEVICE_CREATE_WITH_NATIVE_HANDLE, + "urDeviceCreateWithNativeHandle", ¶ms); - context.logger.info("---> urDeviceCreateWithNativeHandle"); + getContext()->logger.info("---> urDeviceCreateWithNativeHandle"); ur_result_t result = pfnCreateWithNativeHandle(hNativeDevice, hPlatform, pProperties, phDevice); - context.notify_end(UR_FUNCTION_DEVICE_CREATE_WITH_NATIVE_HANDLE, - "urDeviceCreateWithNativeHandle", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_DEVICE_CREATE_WITH_NATIVE_HANDLE, + "urDeviceCreateWithNativeHandle", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_DEVICE_CREATE_WITH_NATIVE_HANDLE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -745,7 +753,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetGlobalTimestamps( ///< correlates with the Device's global timestamp value ) { auto pfnGetGlobalTimestamps = - context.urDdiTable.Device.pfnGetGlobalTimestamps; + getContext()->urDdiTable.Device.pfnGetGlobalTimestamps; if (nullptr == pfnGetGlobalTimestamps) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -754,22 +762,22 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetGlobalTimestamps( ur_device_get_global_timestamps_params_t params = { &hDevice, &pDeviceTimestamp, &pHostTimestamp}; uint64_t instance = - context.notify_begin(UR_FUNCTION_DEVICE_GET_GLOBAL_TIMESTAMPS, - "urDeviceGetGlobalTimestamps", ¶ms); + getContext()->notify_begin(UR_FUNCTION_DEVICE_GET_GLOBAL_TIMESTAMPS, + "urDeviceGetGlobalTimestamps", ¶ms); - context.logger.info("---> urDeviceGetGlobalTimestamps"); + getContext()->logger.info("---> urDeviceGetGlobalTimestamps"); ur_result_t result = pfnGetGlobalTimestamps(hDevice, pDeviceTimestamp, pHostTimestamp); - context.notify_end(UR_FUNCTION_DEVICE_GET_GLOBAL_TIMESTAMPS, - "urDeviceGetGlobalTimestamps", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_DEVICE_GET_GLOBAL_TIMESTAMPS, + "urDeviceGetGlobalTimestamps", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_DEVICE_GET_GLOBAL_TIMESTAMPS, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -785,7 +793,7 @@ __urdlllocal ur_result_t UR_APICALL urContextCreate( ur_context_handle_t *phContext ///< [out] pointer to handle of context object created ) { - auto pfnCreate = context.urDdiTable.Context.pfnCreate; + auto pfnCreate = getContext()->urDdiTable.Context.pfnCreate; if (nullptr == pfnCreate) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -793,21 +801,21 @@ __urdlllocal ur_result_t UR_APICALL urContextCreate( ur_context_create_params_t params = {&DeviceCount, &phDevices, &pProperties, &phContext}; - uint64_t instance = context.notify_begin(UR_FUNCTION_CONTEXT_CREATE, - "urContextCreate", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_CONTEXT_CREATE, + "urContextCreate", ¶ms); - context.logger.info("---> urContextCreate"); + getContext()->logger.info("---> urContextCreate"); ur_result_t result = pfnCreate(DeviceCount, phDevices, pProperties, phContext); - context.notify_end(UR_FUNCTION_CONTEXT_CREATE, "urContextCreate", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_CONTEXT_CREATE, "urContextCreate", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_CONTEXT_CREATE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -818,27 +826,27 @@ __urdlllocal ur_result_t UR_APICALL urContextRetain( ur_context_handle_t hContext ///< [in] handle of the context to get a reference of. ) { - auto pfnRetain = context.urDdiTable.Context.pfnRetain; + auto pfnRetain = getContext()->urDdiTable.Context.pfnRetain; if (nullptr == pfnRetain) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_context_retain_params_t params = {&hContext}; - uint64_t instance = context.notify_begin(UR_FUNCTION_CONTEXT_RETAIN, - "urContextRetain", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_CONTEXT_RETAIN, + "urContextRetain", ¶ms); - context.logger.info("---> urContextRetain"); + getContext()->logger.info("---> urContextRetain"); ur_result_t result = pfnRetain(hContext); - context.notify_end(UR_FUNCTION_CONTEXT_RETAIN, "urContextRetain", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_CONTEXT_RETAIN, "urContextRetain", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_CONTEXT_RETAIN, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -849,27 +857,27 @@ __urdlllocal ur_result_t UR_APICALL urContextRelease( ur_context_handle_t hContext ///< [in][release] handle of the context to release. ) { - auto pfnRelease = context.urDdiTable.Context.pfnRelease; + auto pfnRelease = getContext()->urDdiTable.Context.pfnRelease; if (nullptr == pfnRelease) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_context_release_params_t params = {&hContext}; - uint64_t instance = context.notify_begin(UR_FUNCTION_CONTEXT_RELEASE, - "urContextRelease", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_CONTEXT_RELEASE, + "urContextRelease", ¶ms); - context.logger.info("---> urContextRelease"); + getContext()->logger.info("---> urContextRelease"); ur_result_t result = pfnRelease(hContext); - context.notify_end(UR_FUNCTION_CONTEXT_RELEASE, "urContextRelease", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_CONTEXT_RELEASE, "urContextRelease", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_CONTEXT_RELEASE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -891,7 +899,7 @@ __urdlllocal ur_result_t UR_APICALL urContextGetInfo( size_t * pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of the queried propName. ) { - auto pfnGetInfo = context.urDdiTable.Context.pfnGetInfo; + auto pfnGetInfo = getContext()->urDdiTable.Context.pfnGetInfo; if (nullptr == pfnGetInfo) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -899,21 +907,21 @@ __urdlllocal ur_result_t UR_APICALL urContextGetInfo( ur_context_get_info_params_t params = {&hContext, &propName, &propSize, &pPropValue, &pPropSizeRet}; - uint64_t instance = context.notify_begin(UR_FUNCTION_CONTEXT_GET_INFO, - "urContextGetInfo", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_CONTEXT_GET_INFO, + "urContextGetInfo", ¶ms); - context.logger.info("---> urContextGetInfo"); + getContext()->logger.info("---> urContextGetInfo"); ur_result_t result = pfnGetInfo(hContext, propName, propSize, pPropValue, pPropSizeRet); - context.notify_end(UR_FUNCTION_CONTEXT_GET_INFO, "urContextGetInfo", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_CONTEXT_GET_INFO, "urContextGetInfo", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_CONTEXT_GET_INFO, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -925,7 +933,8 @@ __urdlllocal ur_result_t UR_APICALL urContextGetNativeHandle( ur_native_handle_t * phNativeContext ///< [out] a pointer to the native handle of the context. ) { - auto pfnGetNativeHandle = context.urDdiTable.Context.pfnGetNativeHandle; + auto pfnGetNativeHandle = + getContext()->urDdiTable.Context.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -934,20 +943,21 @@ __urdlllocal ur_result_t UR_APICALL urContextGetNativeHandle( ur_context_get_native_handle_params_t params = {&hContext, &phNativeContext}; uint64_t instance = - context.notify_begin(UR_FUNCTION_CONTEXT_GET_NATIVE_HANDLE, - "urContextGetNativeHandle", ¶ms); + getContext()->notify_begin(UR_FUNCTION_CONTEXT_GET_NATIVE_HANDLE, + "urContextGetNativeHandle", ¶ms); - context.logger.info("---> urContextGetNativeHandle"); + getContext()->logger.info("---> urContextGetNativeHandle"); ur_result_t result = pfnGetNativeHandle(hContext, phNativeContext); - context.notify_end(UR_FUNCTION_CONTEXT_GET_NATIVE_HANDLE, - "urContextGetNativeHandle", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_CONTEXT_GET_NATIVE_HANDLE, + "urContextGetNativeHandle", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_CONTEXT_GET_NATIVE_HANDLE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -966,7 +976,7 @@ __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( phContext ///< [out] pointer to the handle of the context object created. ) { auto pfnCreateWithNativeHandle = - context.urDdiTable.Context.pfnCreateWithNativeHandle; + getContext()->urDdiTable.Context.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -974,23 +984,23 @@ __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( ur_context_create_with_native_handle_params_t params = { &hNativeContext, &numDevices, &phDevices, &pProperties, &phContext}; - uint64_t instance = - context.notify_begin(UR_FUNCTION_CONTEXT_CREATE_WITH_NATIVE_HANDLE, - "urContextCreateWithNativeHandle", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_CONTEXT_CREATE_WITH_NATIVE_HANDLE, + "urContextCreateWithNativeHandle", ¶ms); - context.logger.info("---> urContextCreateWithNativeHandle"); + getContext()->logger.info("---> urContextCreateWithNativeHandle"); ur_result_t result = pfnCreateWithNativeHandle( hNativeContext, numDevices, phDevices, pProperties, phContext); - context.notify_end(UR_FUNCTION_CONTEXT_CREATE_WITH_NATIVE_HANDLE, - "urContextCreateWithNativeHandle", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_CONTEXT_CREATE_WITH_NATIVE_HANDLE, + "urContextCreateWithNativeHandle", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_CONTEXT_CREATE_WITH_NATIVE_HANDLE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -1005,7 +1015,7 @@ __urdlllocal ur_result_t UR_APICALL urContextSetExtendedDeleter( pUserData ///< [in][out][optional] pointer to data to be passed to callback. ) { auto pfnSetExtendedDeleter = - context.urDdiTable.Context.pfnSetExtendedDeleter; + getContext()->urDdiTable.Context.pfnSetExtendedDeleter; if (nullptr == pfnSetExtendedDeleter) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -1014,21 +1024,21 @@ __urdlllocal ur_result_t UR_APICALL urContextSetExtendedDeleter( ur_context_set_extended_deleter_params_t params = {&hContext, &pfnDeleter, &pUserData}; uint64_t instance = - context.notify_begin(UR_FUNCTION_CONTEXT_SET_EXTENDED_DELETER, - "urContextSetExtendedDeleter", ¶ms); + getContext()->notify_begin(UR_FUNCTION_CONTEXT_SET_EXTENDED_DELETER, + "urContextSetExtendedDeleter", ¶ms); - context.logger.info("---> urContextSetExtendedDeleter"); + getContext()->logger.info("---> urContextSetExtendedDeleter"); ur_result_t result = pfnSetExtendedDeleter(hContext, pfnDeleter, pUserData); - context.notify_end(UR_FUNCTION_CONTEXT_SET_EXTENDED_DELETER, - "urContextSetExtendedDeleter", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_CONTEXT_SET_EXTENDED_DELETER, + "urContextSetExtendedDeleter", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_CONTEXT_SET_EXTENDED_DELETER, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -1044,7 +1054,7 @@ __urdlllocal ur_result_t UR_APICALL urMemImageCreate( void *pHost, ///< [in][optional] pointer to the buffer data ur_mem_handle_t *phMem ///< [out] pointer to handle of image object created ) { - auto pfnImageCreate = context.urDdiTable.Mem.pfnImageCreate; + auto pfnImageCreate = getContext()->urDdiTable.Mem.pfnImageCreate; if (nullptr == pfnImageCreate) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -1052,21 +1062,21 @@ __urdlllocal ur_result_t UR_APICALL urMemImageCreate( ur_mem_image_create_params_t params = {&hContext, &flags, &pImageFormat, &pImageDesc, &pHost, &phMem}; - uint64_t instance = context.notify_begin(UR_FUNCTION_MEM_IMAGE_CREATE, - "urMemImageCreate", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_MEM_IMAGE_CREATE, + "urMemImageCreate", ¶ms); - context.logger.info("---> urMemImageCreate"); + getContext()->logger.info("---> urMemImageCreate"); ur_result_t result = pfnImageCreate(hContext, flags, pImageFormat, pImageDesc, pHost, phMem); - context.notify_end(UR_FUNCTION_MEM_IMAGE_CREATE, "urMemImageCreate", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_MEM_IMAGE_CREATE, "urMemImageCreate", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_MEM_IMAGE_CREATE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -1082,7 +1092,7 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreate( ur_mem_handle_t *phBuffer ///< [out] pointer to handle of the memory buffer created ) { - auto pfnBufferCreate = context.urDdiTable.Mem.pfnBufferCreate; + auto pfnBufferCreate = getContext()->urDdiTable.Mem.pfnBufferCreate; if (nullptr == pfnBufferCreate) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -1090,21 +1100,21 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreate( ur_mem_buffer_create_params_t params = {&hContext, &flags, &size, &pProperties, &phBuffer}; - uint64_t instance = context.notify_begin(UR_FUNCTION_MEM_BUFFER_CREATE, - "urMemBufferCreate", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_MEM_BUFFER_CREATE, "urMemBufferCreate", ¶ms); - context.logger.info("---> urMemBufferCreate"); + getContext()->logger.info("---> urMemBufferCreate"); ur_result_t result = pfnBufferCreate(hContext, flags, size, pProperties, phBuffer); - context.notify_end(UR_FUNCTION_MEM_BUFFER_CREATE, "urMemBufferCreate", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_MEM_BUFFER_CREATE, "urMemBufferCreate", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_MEM_BUFFER_CREATE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -1114,26 +1124,26 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreate( __urdlllocal ur_result_t UR_APICALL urMemRetain( ur_mem_handle_t hMem ///< [in] handle of the memory object to get access ) { - auto pfnRetain = context.urDdiTable.Mem.pfnRetain; + auto pfnRetain = getContext()->urDdiTable.Mem.pfnRetain; if (nullptr == pfnRetain) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_mem_retain_params_t params = {&hMem}; - uint64_t instance = - context.notify_begin(UR_FUNCTION_MEM_RETAIN, "urMemRetain", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_MEM_RETAIN, + "urMemRetain", ¶ms); - context.logger.info("---> urMemRetain"); + getContext()->logger.info("---> urMemRetain"); ur_result_t result = pfnRetain(hMem); - context.notify_end(UR_FUNCTION_MEM_RETAIN, "urMemRetain", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_MEM_RETAIN, "urMemRetain", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_MEM_RETAIN, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -1144,26 +1154,26 @@ __urdlllocal ur_result_t UR_APICALL urMemRelease( ur_mem_handle_t hMem ///< [in][release] handle of the memory object to release ) { - auto pfnRelease = context.urDdiTable.Mem.pfnRelease; + auto pfnRelease = getContext()->urDdiTable.Mem.pfnRelease; if (nullptr == pfnRelease) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_mem_release_params_t params = {&hMem}; - uint64_t instance = - context.notify_begin(UR_FUNCTION_MEM_RELEASE, "urMemRelease", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_MEM_RELEASE, + "urMemRelease", ¶ms); - context.logger.info("---> urMemRelease"); + getContext()->logger.info("---> urMemRelease"); ur_result_t result = pfnRelease(hMem); - context.notify_end(UR_FUNCTION_MEM_RELEASE, "urMemRelease", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_MEM_RELEASE, "urMemRelease", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_MEM_RELEASE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -1180,7 +1190,7 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferPartition( ur_mem_handle_t *phMem ///< [out] pointer to the handle of sub buffer created ) { - auto pfnBufferPartition = context.urDdiTable.Mem.pfnBufferPartition; + auto pfnBufferPartition = getContext()->urDdiTable.Mem.pfnBufferPartition; if (nullptr == pfnBufferPartition) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -1188,21 +1198,22 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferPartition( ur_mem_buffer_partition_params_t params = { &hBuffer, &flags, &bufferCreateType, &pRegion, &phMem}; - uint64_t instance = context.notify_begin(UR_FUNCTION_MEM_BUFFER_PARTITION, - "urMemBufferPartition", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_MEM_BUFFER_PARTITION, "urMemBufferPartition", ¶ms); - context.logger.info("---> urMemBufferPartition"); + getContext()->logger.info("---> urMemBufferPartition"); ur_result_t result = pfnBufferPartition(hBuffer, flags, bufferCreateType, pRegion, phMem); - context.notify_end(UR_FUNCTION_MEM_BUFFER_PARTITION, "urMemBufferPartition", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_MEM_BUFFER_PARTITION, + "urMemBufferPartition", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_MEM_BUFFER_PARTITION, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -1217,27 +1228,28 @@ __urdlllocal ur_result_t UR_APICALL urMemGetNativeHandle( ur_native_handle_t *phNativeMem ///< [out] a pointer to the native handle of the mem. ) { - auto pfnGetNativeHandle = context.urDdiTable.Mem.pfnGetNativeHandle; + auto pfnGetNativeHandle = getContext()->urDdiTable.Mem.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_mem_get_native_handle_params_t params = {&hMem, &hDevice, &phNativeMem}; - uint64_t instance = context.notify_begin(UR_FUNCTION_MEM_GET_NATIVE_HANDLE, - "urMemGetNativeHandle", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_MEM_GET_NATIVE_HANDLE, "urMemGetNativeHandle", ¶ms); - context.logger.info("---> urMemGetNativeHandle"); + getContext()->logger.info("---> urMemGetNativeHandle"); ur_result_t result = pfnGetNativeHandle(hMem, hDevice, phNativeMem); - context.notify_end(UR_FUNCTION_MEM_GET_NATIVE_HANDLE, - "urMemGetNativeHandle", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_MEM_GET_NATIVE_HANDLE, + "urMemGetNativeHandle", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_MEM_GET_NATIVE_HANDLE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -1254,7 +1266,7 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( *phMem ///< [out] pointer to handle of buffer memory object created. ) { auto pfnBufferCreateWithNativeHandle = - context.urDdiTable.Mem.pfnBufferCreateWithNativeHandle; + getContext()->urDdiTable.Mem.pfnBufferCreateWithNativeHandle; if (nullptr == pfnBufferCreateWithNativeHandle) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -1262,23 +1274,23 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( ur_mem_buffer_create_with_native_handle_params_t params = { &hNativeMem, &hContext, &pProperties, &phMem}; - uint64_t instance = - context.notify_begin(UR_FUNCTION_MEM_BUFFER_CREATE_WITH_NATIVE_HANDLE, - "urMemBufferCreateWithNativeHandle", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_MEM_BUFFER_CREATE_WITH_NATIVE_HANDLE, + "urMemBufferCreateWithNativeHandle", ¶ms); - context.logger.info("---> urMemBufferCreateWithNativeHandle"); + getContext()->logger.info("---> urMemBufferCreateWithNativeHandle"); ur_result_t result = pfnBufferCreateWithNativeHandle(hNativeMem, hContext, pProperties, phMem); - context.notify_end(UR_FUNCTION_MEM_BUFFER_CREATE_WITH_NATIVE_HANDLE, - "urMemBufferCreateWithNativeHandle", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_MEM_BUFFER_CREATE_WITH_NATIVE_HANDLE, + "urMemBufferCreateWithNativeHandle", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_MEM_BUFFER_CREATE_WITH_NATIVE_HANDLE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -1298,7 +1310,7 @@ __urdlllocal ur_result_t UR_APICALL urMemImageCreateWithNativeHandle( *phMem ///< [out] pointer to handle of image memory object created. ) { auto pfnImageCreateWithNativeHandle = - context.urDdiTable.Mem.pfnImageCreateWithNativeHandle; + getContext()->urDdiTable.Mem.pfnImageCreateWithNativeHandle; if (nullptr == pfnImageCreateWithNativeHandle) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -1307,23 +1319,23 @@ __urdlllocal ur_result_t UR_APICALL urMemImageCreateWithNativeHandle( ur_mem_image_create_with_native_handle_params_t params = { &hNativeMem, &hContext, &pImageFormat, &pImageDesc, &pProperties, &phMem}; - uint64_t instance = - context.notify_begin(UR_FUNCTION_MEM_IMAGE_CREATE_WITH_NATIVE_HANDLE, - "urMemImageCreateWithNativeHandle", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_MEM_IMAGE_CREATE_WITH_NATIVE_HANDLE, + "urMemImageCreateWithNativeHandle", ¶ms); - context.logger.info("---> urMemImageCreateWithNativeHandle"); + getContext()->logger.info("---> urMemImageCreateWithNativeHandle"); ur_result_t result = pfnImageCreateWithNativeHandle( hNativeMem, hContext, pImageFormat, pImageDesc, pProperties, phMem); - context.notify_end(UR_FUNCTION_MEM_IMAGE_CREATE_WITH_NATIVE_HANDLE, - "urMemImageCreateWithNativeHandle", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_MEM_IMAGE_CREATE_WITH_NATIVE_HANDLE, + "urMemImageCreateWithNativeHandle", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_MEM_IMAGE_CREATE_WITH_NATIVE_HANDLE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -1345,7 +1357,7 @@ __urdlllocal ur_result_t UR_APICALL urMemGetInfo( size_t * pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of the queried propName. ) { - auto pfnGetInfo = context.urDdiTable.Mem.pfnGetInfo; + auto pfnGetInfo = getContext()->urDdiTable.Mem.pfnGetInfo; if (nullptr == pfnGetInfo) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -1353,21 +1365,21 @@ __urdlllocal ur_result_t UR_APICALL urMemGetInfo( ur_mem_get_info_params_t params = {&hMemory, &propName, &propSize, &pPropValue, &pPropSizeRet}; - uint64_t instance = - context.notify_begin(UR_FUNCTION_MEM_GET_INFO, "urMemGetInfo", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_MEM_GET_INFO, + "urMemGetInfo", ¶ms); - context.logger.info("---> urMemGetInfo"); + getContext()->logger.info("---> urMemGetInfo"); ur_result_t result = pfnGetInfo(hMemory, propName, propSize, pPropValue, pPropSizeRet); - context.notify_end(UR_FUNCTION_MEM_GET_INFO, "urMemGetInfo", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_MEM_GET_INFO, "urMemGetInfo", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_MEM_GET_INFO, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -1388,7 +1400,7 @@ __urdlllocal ur_result_t UR_APICALL urMemImageGetInfo( size_t * pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of the queried propName. ) { - auto pfnImageGetInfo = context.urDdiTable.Mem.pfnImageGetInfo; + auto pfnImageGetInfo = getContext()->urDdiTable.Mem.pfnImageGetInfo; if (nullptr == pfnImageGetInfo) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -1396,21 +1408,21 @@ __urdlllocal ur_result_t UR_APICALL urMemImageGetInfo( ur_mem_image_get_info_params_t params = {&hMemory, &propName, &propSize, &pPropValue, &pPropSizeRet}; - uint64_t instance = context.notify_begin(UR_FUNCTION_MEM_IMAGE_GET_INFO, - "urMemImageGetInfo", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_MEM_IMAGE_GET_INFO, "urMemImageGetInfo", ¶ms); - context.logger.info("---> urMemImageGetInfo"); + getContext()->logger.info("---> urMemImageGetInfo"); ur_result_t result = pfnImageGetInfo(hMemory, propName, propSize, pPropValue, pPropSizeRet); - context.notify_end(UR_FUNCTION_MEM_IMAGE_GET_INFO, "urMemImageGetInfo", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_MEM_IMAGE_GET_INFO, + "urMemImageGetInfo", ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_MEM_IMAGE_GET_INFO, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -1423,27 +1435,27 @@ __urdlllocal ur_result_t UR_APICALL urSamplerCreate( ur_sampler_handle_t *phSampler ///< [out] pointer to handle of sampler object created ) { - auto pfnCreate = context.urDdiTable.Sampler.pfnCreate; + auto pfnCreate = getContext()->urDdiTable.Sampler.pfnCreate; if (nullptr == pfnCreate) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_sampler_create_params_t params = {&hContext, &pDesc, &phSampler}; - uint64_t instance = context.notify_begin(UR_FUNCTION_SAMPLER_CREATE, - "urSamplerCreate", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_SAMPLER_CREATE, + "urSamplerCreate", ¶ms); - context.logger.info("---> urSamplerCreate"); + getContext()->logger.info("---> urSamplerCreate"); ur_result_t result = pfnCreate(hContext, pDesc, phSampler); - context.notify_end(UR_FUNCTION_SAMPLER_CREATE, "urSamplerCreate", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_SAMPLER_CREATE, "urSamplerCreate", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_SAMPLER_CREATE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -1454,27 +1466,27 @@ __urdlllocal ur_result_t UR_APICALL urSamplerRetain( ur_sampler_handle_t hSampler ///< [in] handle of the sampler object to get access ) { - auto pfnRetain = context.urDdiTable.Sampler.pfnRetain; + auto pfnRetain = getContext()->urDdiTable.Sampler.pfnRetain; if (nullptr == pfnRetain) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_sampler_retain_params_t params = {&hSampler}; - uint64_t instance = context.notify_begin(UR_FUNCTION_SAMPLER_RETAIN, - "urSamplerRetain", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_SAMPLER_RETAIN, + "urSamplerRetain", ¶ms); - context.logger.info("---> urSamplerRetain"); + getContext()->logger.info("---> urSamplerRetain"); ur_result_t result = pfnRetain(hSampler); - context.notify_end(UR_FUNCTION_SAMPLER_RETAIN, "urSamplerRetain", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_SAMPLER_RETAIN, "urSamplerRetain", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_SAMPLER_RETAIN, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -1485,27 +1497,27 @@ __urdlllocal ur_result_t UR_APICALL urSamplerRelease( ur_sampler_handle_t hSampler ///< [in][release] handle of the sampler object to release ) { - auto pfnRelease = context.urDdiTable.Sampler.pfnRelease; + auto pfnRelease = getContext()->urDdiTable.Sampler.pfnRelease; if (nullptr == pfnRelease) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_sampler_release_params_t params = {&hSampler}; - uint64_t instance = context.notify_begin(UR_FUNCTION_SAMPLER_RELEASE, - "urSamplerRelease", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_SAMPLER_RELEASE, + "urSamplerRelease", ¶ms); - context.logger.info("---> urSamplerRelease"); + getContext()->logger.info("---> urSamplerRelease"); ur_result_t result = pfnRelease(hSampler); - context.notify_end(UR_FUNCTION_SAMPLER_RELEASE, "urSamplerRelease", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_SAMPLER_RELEASE, "urSamplerRelease", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_SAMPLER_RELEASE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -1523,7 +1535,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerGetInfo( size_t * pPropSizeRet ///< [out][optional] size in bytes returned in sampler property value ) { - auto pfnGetInfo = context.urDdiTable.Sampler.pfnGetInfo; + auto pfnGetInfo = getContext()->urDdiTable.Sampler.pfnGetInfo; if (nullptr == pfnGetInfo) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -1531,21 +1543,21 @@ __urdlllocal ur_result_t UR_APICALL urSamplerGetInfo( ur_sampler_get_info_params_t params = {&hSampler, &propName, &propSize, &pPropValue, &pPropSizeRet}; - uint64_t instance = context.notify_begin(UR_FUNCTION_SAMPLER_GET_INFO, - "urSamplerGetInfo", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_SAMPLER_GET_INFO, + "urSamplerGetInfo", ¶ms); - context.logger.info("---> urSamplerGetInfo"); + getContext()->logger.info("---> urSamplerGetInfo"); ur_result_t result = pfnGetInfo(hSampler, propName, propSize, pPropValue, pPropSizeRet); - context.notify_end(UR_FUNCTION_SAMPLER_GET_INFO, "urSamplerGetInfo", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_SAMPLER_GET_INFO, "urSamplerGetInfo", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_SAMPLER_GET_INFO, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -1557,7 +1569,8 @@ __urdlllocal ur_result_t UR_APICALL urSamplerGetNativeHandle( ur_native_handle_t * phNativeSampler ///< [out] a pointer to the native handle of the sampler. ) { - auto pfnGetNativeHandle = context.urDdiTable.Sampler.pfnGetNativeHandle; + auto pfnGetNativeHandle = + getContext()->urDdiTable.Sampler.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -1566,20 +1579,21 @@ __urdlllocal ur_result_t UR_APICALL urSamplerGetNativeHandle( ur_sampler_get_native_handle_params_t params = {&hSampler, &phNativeSampler}; uint64_t instance = - context.notify_begin(UR_FUNCTION_SAMPLER_GET_NATIVE_HANDLE, - "urSamplerGetNativeHandle", ¶ms); + getContext()->notify_begin(UR_FUNCTION_SAMPLER_GET_NATIVE_HANDLE, + "urSamplerGetNativeHandle", ¶ms); - context.logger.info("---> urSamplerGetNativeHandle"); + getContext()->logger.info("---> urSamplerGetNativeHandle"); ur_result_t result = pfnGetNativeHandle(hSampler, phNativeSampler); - context.notify_end(UR_FUNCTION_SAMPLER_GET_NATIVE_HANDLE, - "urSamplerGetNativeHandle", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_SAMPLER_GET_NATIVE_HANDLE, + "urSamplerGetNativeHandle", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_SAMPLER_GET_NATIVE_HANDLE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -1596,7 +1610,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerCreateWithNativeHandle( phSampler ///< [out] pointer to the handle of the sampler object created. ) { auto pfnCreateWithNativeHandle = - context.urDdiTable.Sampler.pfnCreateWithNativeHandle; + getContext()->urDdiTable.Sampler.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -1604,23 +1618,23 @@ __urdlllocal ur_result_t UR_APICALL urSamplerCreateWithNativeHandle( ur_sampler_create_with_native_handle_params_t params = { &hNativeSampler, &hContext, &pProperties, &phSampler}; - uint64_t instance = - context.notify_begin(UR_FUNCTION_SAMPLER_CREATE_WITH_NATIVE_HANDLE, - "urSamplerCreateWithNativeHandle", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_SAMPLER_CREATE_WITH_NATIVE_HANDLE, + "urSamplerCreateWithNativeHandle", ¶ms); - context.logger.info("---> urSamplerCreateWithNativeHandle"); + getContext()->logger.info("---> urSamplerCreateWithNativeHandle"); ur_result_t result = pfnCreateWithNativeHandle(hNativeSampler, hContext, pProperties, phSampler); - context.notify_end(UR_FUNCTION_SAMPLER_CREATE_WITH_NATIVE_HANDLE, - "urSamplerCreateWithNativeHandle", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_SAMPLER_CREATE_WITH_NATIVE_HANDLE, + "urSamplerCreateWithNativeHandle", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_SAMPLER_CREATE_WITH_NATIVE_HANDLE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -1637,7 +1651,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMHostAlloc( size, ///< [in] minimum size in bytes of the USM memory object to be allocated void **ppMem ///< [out] pointer to USM host memory object ) { - auto pfnHostAlloc = context.urDdiTable.USM.pfnHostAlloc; + auto pfnHostAlloc = getContext()->urDdiTable.USM.pfnHostAlloc; if (nullptr == pfnHostAlloc) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -1645,20 +1659,20 @@ __urdlllocal ur_result_t UR_APICALL urUSMHostAlloc( ur_usm_host_alloc_params_t params = {&hContext, &pUSMDesc, &pool, &size, &ppMem}; - uint64_t instance = context.notify_begin(UR_FUNCTION_USM_HOST_ALLOC, - "urUSMHostAlloc", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_USM_HOST_ALLOC, + "urUSMHostAlloc", ¶ms); - context.logger.info("---> urUSMHostAlloc"); + getContext()->logger.info("---> urUSMHostAlloc"); ur_result_t result = pfnHostAlloc(hContext, pUSMDesc, pool, size, ppMem); - context.notify_end(UR_FUNCTION_USM_HOST_ALLOC, "urUSMHostAlloc", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_USM_HOST_ALLOC, "urUSMHostAlloc", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_USM_HOST_ALLOC, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -1676,7 +1690,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMDeviceAlloc( size, ///< [in] minimum size in bytes of the USM memory object to be allocated void **ppMem ///< [out] pointer to USM device memory object ) { - auto pfnDeviceAlloc = context.urDdiTable.USM.pfnDeviceAlloc; + auto pfnDeviceAlloc = getContext()->urDdiTable.USM.pfnDeviceAlloc; if (nullptr == pfnDeviceAlloc) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -1684,21 +1698,21 @@ __urdlllocal ur_result_t UR_APICALL urUSMDeviceAlloc( ur_usm_device_alloc_params_t params = {&hContext, &hDevice, &pUSMDesc, &pool, &size, &ppMem}; - uint64_t instance = context.notify_begin(UR_FUNCTION_USM_DEVICE_ALLOC, - "urUSMDeviceAlloc", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_USM_DEVICE_ALLOC, + "urUSMDeviceAlloc", ¶ms); - context.logger.info("---> urUSMDeviceAlloc"); + getContext()->logger.info("---> urUSMDeviceAlloc"); ur_result_t result = pfnDeviceAlloc(hContext, hDevice, pUSMDesc, pool, size, ppMem); - context.notify_end(UR_FUNCTION_USM_DEVICE_ALLOC, "urUSMDeviceAlloc", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_USM_DEVICE_ALLOC, "urUSMDeviceAlloc", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_USM_DEVICE_ALLOC, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -1716,7 +1730,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMSharedAlloc( size, ///< [in] minimum size in bytes of the USM memory object to be allocated void **ppMem ///< [out] pointer to USM shared memory object ) { - auto pfnSharedAlloc = context.urDdiTable.USM.pfnSharedAlloc; + auto pfnSharedAlloc = getContext()->urDdiTable.USM.pfnSharedAlloc; if (nullptr == pfnSharedAlloc) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -1724,21 +1738,21 @@ __urdlllocal ur_result_t UR_APICALL urUSMSharedAlloc( ur_usm_shared_alloc_params_t params = {&hContext, &hDevice, &pUSMDesc, &pool, &size, &ppMem}; - uint64_t instance = context.notify_begin(UR_FUNCTION_USM_SHARED_ALLOC, - "urUSMSharedAlloc", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_USM_SHARED_ALLOC, + "urUSMSharedAlloc", ¶ms); - context.logger.info("---> urUSMSharedAlloc"); + getContext()->logger.info("---> urUSMSharedAlloc"); ur_result_t result = pfnSharedAlloc(hContext, hDevice, pUSMDesc, pool, size, ppMem); - context.notify_end(UR_FUNCTION_USM_SHARED_ALLOC, "urUSMSharedAlloc", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_USM_SHARED_ALLOC, "urUSMSharedAlloc", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_USM_SHARED_ALLOC, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -1749,7 +1763,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMFree( ur_context_handle_t hContext, ///< [in] handle of the context object void *pMem ///< [in] pointer to USM memory object ) { - auto pfnFree = context.urDdiTable.USM.pfnFree; + auto pfnFree = getContext()->urDdiTable.USM.pfnFree; if (nullptr == pfnFree) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -1757,18 +1771,18 @@ __urdlllocal ur_result_t UR_APICALL urUSMFree( ur_usm_free_params_t params = {&hContext, &pMem}; uint64_t instance = - context.notify_begin(UR_FUNCTION_USM_FREE, "urUSMFree", ¶ms); + getContext()->notify_begin(UR_FUNCTION_USM_FREE, "urUSMFree", ¶ms); - context.logger.info("---> urUSMFree"); + getContext()->logger.info("---> urUSMFree"); ur_result_t result = pfnFree(hContext, pMem); - context.notify_end(UR_FUNCTION_USM_FREE, "urUSMFree", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_USM_FREE, "urUSMFree", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_USM_FREE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -1788,7 +1802,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMGetMemAllocInfo( size_t * pPropSizeRet ///< [out][optional] bytes returned in USM allocation property ) { - auto pfnGetMemAllocInfo = context.urDdiTable.USM.pfnGetMemAllocInfo; + auto pfnGetMemAllocInfo = getContext()->urDdiTable.USM.pfnGetMemAllocInfo; if (nullptr == pfnGetMemAllocInfo) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -1796,21 +1810,22 @@ __urdlllocal ur_result_t UR_APICALL urUSMGetMemAllocInfo( ur_usm_get_mem_alloc_info_params_t params = { &hContext, &pMem, &propName, &propSize, &pPropValue, &pPropSizeRet}; - uint64_t instance = context.notify_begin(UR_FUNCTION_USM_GET_MEM_ALLOC_INFO, - "urUSMGetMemAllocInfo", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_USM_GET_MEM_ALLOC_INFO, "urUSMGetMemAllocInfo", ¶ms); - context.logger.info("---> urUSMGetMemAllocInfo"); + getContext()->logger.info("---> urUSMGetMemAllocInfo"); ur_result_t result = pfnGetMemAllocInfo(hContext, pMem, propName, propSize, pPropValue, pPropSizeRet); - context.notify_end(UR_FUNCTION_USM_GET_MEM_ALLOC_INFO, - "urUSMGetMemAllocInfo", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_USM_GET_MEM_ALLOC_INFO, + "urUSMGetMemAllocInfo", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_USM_GET_MEM_ALLOC_INFO, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -1824,27 +1839,27 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolCreate( ///< ::ur_usm_pool_limits_desc_t ur_usm_pool_handle_t *ppPool ///< [out] pointer to USM memory pool ) { - auto pfnPoolCreate = context.urDdiTable.USM.pfnPoolCreate; + auto pfnPoolCreate = getContext()->urDdiTable.USM.pfnPoolCreate; if (nullptr == pfnPoolCreate) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_usm_pool_create_params_t params = {&hContext, &pPoolDesc, &ppPool}; - uint64_t instance = context.notify_begin(UR_FUNCTION_USM_POOL_CREATE, - "urUSMPoolCreate", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_USM_POOL_CREATE, + "urUSMPoolCreate", ¶ms); - context.logger.info("---> urUSMPoolCreate"); + getContext()->logger.info("---> urUSMPoolCreate"); ur_result_t result = pfnPoolCreate(hContext, pPoolDesc, ppPool); - context.notify_end(UR_FUNCTION_USM_POOL_CREATE, "urUSMPoolCreate", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_USM_POOL_CREATE, "urUSMPoolCreate", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_USM_POOL_CREATE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -1854,27 +1869,27 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolCreate( __urdlllocal ur_result_t UR_APICALL urUSMPoolRetain( ur_usm_pool_handle_t pPool ///< [in] pointer to USM memory pool ) { - auto pfnPoolRetain = context.urDdiTable.USM.pfnPoolRetain; + auto pfnPoolRetain = getContext()->urDdiTable.USM.pfnPoolRetain; if (nullptr == pfnPoolRetain) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_usm_pool_retain_params_t params = {&pPool}; - uint64_t instance = context.notify_begin(UR_FUNCTION_USM_POOL_RETAIN, - "urUSMPoolRetain", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_USM_POOL_RETAIN, + "urUSMPoolRetain", ¶ms); - context.logger.info("---> urUSMPoolRetain"); + getContext()->logger.info("---> urUSMPoolRetain"); ur_result_t result = pfnPoolRetain(pPool); - context.notify_end(UR_FUNCTION_USM_POOL_RETAIN, "urUSMPoolRetain", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_USM_POOL_RETAIN, "urUSMPoolRetain", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_USM_POOL_RETAIN, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -1884,27 +1899,27 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolRetain( __urdlllocal ur_result_t UR_APICALL urUSMPoolRelease( ur_usm_pool_handle_t pPool ///< [in][release] pointer to USM memory pool ) { - auto pfnPoolRelease = context.urDdiTable.USM.pfnPoolRelease; + auto pfnPoolRelease = getContext()->urDdiTable.USM.pfnPoolRelease; if (nullptr == pfnPoolRelease) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_usm_pool_release_params_t params = {&pPool}; - uint64_t instance = context.notify_begin(UR_FUNCTION_USM_POOL_RELEASE, - "urUSMPoolRelease", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_USM_POOL_RELEASE, + "urUSMPoolRelease", ¶ms); - context.logger.info("---> urUSMPoolRelease"); + getContext()->logger.info("---> urUSMPoolRelease"); ur_result_t result = pfnPoolRelease(pPool); - context.notify_end(UR_FUNCTION_USM_POOL_RELEASE, "urUSMPoolRelease", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_USM_POOL_RELEASE, "urUSMPoolRelease", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_USM_POOL_RELEASE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -1921,7 +1936,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolGetInfo( size_t * pPropSizeRet ///< [out][optional] size in bytes returned in pool property value ) { - auto pfnPoolGetInfo = context.urDdiTable.USM.pfnPoolGetInfo; + auto pfnPoolGetInfo = getContext()->urDdiTable.USM.pfnPoolGetInfo; if (nullptr == pfnPoolGetInfo) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -1929,21 +1944,21 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolGetInfo( ur_usm_pool_get_info_params_t params = {&hPool, &propName, &propSize, &pPropValue, &pPropSizeRet}; - uint64_t instance = context.notify_begin(UR_FUNCTION_USM_POOL_GET_INFO, - "urUSMPoolGetInfo", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_USM_POOL_GET_INFO, "urUSMPoolGetInfo", ¶ms); - context.logger.info("---> urUSMPoolGetInfo"); + getContext()->logger.info("---> urUSMPoolGetInfo"); ur_result_t result = pfnPoolGetInfo(hPool, propName, propSize, pPropValue, pPropSizeRet); - context.notify_end(UR_FUNCTION_USM_POOL_GET_INFO, "urUSMPoolGetInfo", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_USM_POOL_GET_INFO, "urUSMPoolGetInfo", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_USM_POOL_GET_INFO, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -1968,7 +1983,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemGranularityGetInfo( pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of the queried propName." ) { auto pfnGranularityGetInfo = - context.urDdiTable.VirtualMem.pfnGranularityGetInfo; + getContext()->urDdiTable.VirtualMem.pfnGranularityGetInfo; if (nullptr == pfnGranularityGetInfo) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -1977,22 +1992,22 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemGranularityGetInfo( ur_virtual_mem_granularity_get_info_params_t params = { &hContext, &hDevice, &propName, &propSize, &pPropValue, &pPropSizeRet}; uint64_t instance = - context.notify_begin(UR_FUNCTION_VIRTUAL_MEM_GRANULARITY_GET_INFO, - "urVirtualMemGranularityGetInfo", ¶ms); + getContext()->notify_begin(UR_FUNCTION_VIRTUAL_MEM_GRANULARITY_GET_INFO, + "urVirtualMemGranularityGetInfo", ¶ms); - context.logger.info("---> urVirtualMemGranularityGetInfo"); + getContext()->logger.info("---> urVirtualMemGranularityGetInfo"); ur_result_t result = pfnGranularityGetInfo( hContext, hDevice, propName, propSize, pPropValue, pPropSizeRet); - context.notify_end(UR_FUNCTION_VIRTUAL_MEM_GRANULARITY_GET_INFO, - "urVirtualMemGranularityGetInfo", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_VIRTUAL_MEM_GRANULARITY_GET_INFO, + "urVirtualMemGranularityGetInfo", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_VIRTUAL_MEM_GRANULARITY_GET_INFO, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -2011,7 +2026,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemReserve( ppStart ///< [out] pointer to the returned address at the start of reserved virtual ///< memory range. ) { - auto pfnReserve = context.urDdiTable.VirtualMem.pfnReserve; + auto pfnReserve = getContext()->urDdiTable.VirtualMem.pfnReserve; if (nullptr == pfnReserve) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -2019,20 +2034,20 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemReserve( ur_virtual_mem_reserve_params_t params = {&hContext, &pStart, &size, &ppStart}; - uint64_t instance = context.notify_begin(UR_FUNCTION_VIRTUAL_MEM_RESERVE, - "urVirtualMemReserve", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_VIRTUAL_MEM_RESERVE, "urVirtualMemReserve", ¶ms); - context.logger.info("---> urVirtualMemReserve"); + getContext()->logger.info("---> urVirtualMemReserve"); ur_result_t result = pfnReserve(hContext, pStart, size, ppStart); - context.notify_end(UR_FUNCTION_VIRTUAL_MEM_RESERVE, "urVirtualMemReserve", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_VIRTUAL_MEM_RESERVE, + "urVirtualMemReserve", ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_VIRTUAL_MEM_RESERVE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -2045,27 +2060,27 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemFree( pStart, ///< [in] pointer to the start of the virtual memory range to free. size_t size ///< [in] size in bytes of the virtual memory range to free. ) { - auto pfnFree = context.urDdiTable.VirtualMem.pfnFree; + auto pfnFree = getContext()->urDdiTable.VirtualMem.pfnFree; if (nullptr == pfnFree) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_virtual_mem_free_params_t params = {&hContext, &pStart, &size}; - uint64_t instance = context.notify_begin(UR_FUNCTION_VIRTUAL_MEM_FREE, - "urVirtualMemFree", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_VIRTUAL_MEM_FREE, + "urVirtualMemFree", ¶ms); - context.logger.info("---> urVirtualMemFree"); + getContext()->logger.info("---> urVirtualMemFree"); ur_result_t result = pfnFree(hContext, pStart, size); - context.notify_end(UR_FUNCTION_VIRTUAL_MEM_FREE, "urVirtualMemFree", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_VIRTUAL_MEM_FREE, "urVirtualMemFree", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_VIRTUAL_MEM_FREE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -2084,7 +2099,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemMap( ur_virtual_mem_access_flags_t flags ///< [in] access flags for the physical memory mapping. ) { - auto pfnMap = context.urDdiTable.VirtualMem.pfnMap; + auto pfnMap = getContext()->urDdiTable.VirtualMem.pfnMap; if (nullptr == pfnMap) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -2092,21 +2107,21 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemMap( ur_virtual_mem_map_params_t params = {&hContext, &pStart, &size, &hPhysicalMem, &offset, &flags}; - uint64_t instance = context.notify_begin(UR_FUNCTION_VIRTUAL_MEM_MAP, - "urVirtualMemMap", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_VIRTUAL_MEM_MAP, + "urVirtualMemMap", ¶ms); - context.logger.info("---> urVirtualMemMap"); + getContext()->logger.info("---> urVirtualMemMap"); ur_result_t result = pfnMap(hContext, pStart, size, hPhysicalMem, offset, flags); - context.notify_end(UR_FUNCTION_VIRTUAL_MEM_MAP, "urVirtualMemMap", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_VIRTUAL_MEM_MAP, "urVirtualMemMap", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_VIRTUAL_MEM_MAP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -2119,27 +2134,27 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemUnmap( pStart, ///< [in] pointer to the start of the mapped virtual memory range size_t size ///< [in] size in bytes of the virtual memory range. ) { - auto pfnUnmap = context.urDdiTable.VirtualMem.pfnUnmap; + auto pfnUnmap = getContext()->urDdiTable.VirtualMem.pfnUnmap; if (nullptr == pfnUnmap) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_virtual_mem_unmap_params_t params = {&hContext, &pStart, &size}; - uint64_t instance = context.notify_begin(UR_FUNCTION_VIRTUAL_MEM_UNMAP, - "urVirtualMemUnmap", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_VIRTUAL_MEM_UNMAP, "urVirtualMemUnmap", ¶ms); - context.logger.info("---> urVirtualMemUnmap"); + getContext()->logger.info("---> urVirtualMemUnmap"); ur_result_t result = pfnUnmap(hContext, pStart, size); - context.notify_end(UR_FUNCTION_VIRTUAL_MEM_UNMAP, "urVirtualMemUnmap", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_VIRTUAL_MEM_UNMAP, "urVirtualMemUnmap", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_VIRTUAL_MEM_UNMAP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -2154,7 +2169,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemSetAccess( ur_virtual_mem_access_flags_t flags ///< [in] access flags to set for the mapped virtual memory range. ) { - auto pfnSetAccess = context.urDdiTable.VirtualMem.pfnSetAccess; + auto pfnSetAccess = getContext()->urDdiTable.VirtualMem.pfnSetAccess; if (nullptr == pfnSetAccess) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -2162,20 +2177,21 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemSetAccess( ur_virtual_mem_set_access_params_t params = {&hContext, &pStart, &size, &flags}; - uint64_t instance = context.notify_begin(UR_FUNCTION_VIRTUAL_MEM_SET_ACCESS, - "urVirtualMemSetAccess", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_VIRTUAL_MEM_SET_ACCESS, "urVirtualMemSetAccess", ¶ms); - context.logger.info("---> urVirtualMemSetAccess"); + getContext()->logger.info("---> urVirtualMemSetAccess"); ur_result_t result = pfnSetAccess(hContext, pStart, size, flags); - context.notify_end(UR_FUNCTION_VIRTUAL_MEM_SET_ACCESS, - "urVirtualMemSetAccess", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_VIRTUAL_MEM_SET_ACCESS, + "urVirtualMemSetAccess", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_VIRTUAL_MEM_SET_ACCESS, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -2198,7 +2214,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemGetInfo( size_t * pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of the queried propName." ) { - auto pfnGetInfo = context.urDdiTable.VirtualMem.pfnGetInfo; + auto pfnGetInfo = getContext()->urDdiTable.VirtualMem.pfnGetInfo; if (nullptr == pfnGetInfo) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -2207,21 +2223,21 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemGetInfo( ur_virtual_mem_get_info_params_t params = { &hContext, &pStart, &size, &propName, &propSize, &pPropValue, &pPropSizeRet}; - uint64_t instance = context.notify_begin(UR_FUNCTION_VIRTUAL_MEM_GET_INFO, - "urVirtualMemGetInfo", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_VIRTUAL_MEM_GET_INFO, "urVirtualMemGetInfo", ¶ms); - context.logger.info("---> urVirtualMemGetInfo"); + getContext()->logger.info("---> urVirtualMemGetInfo"); ur_result_t result = pfnGetInfo(hContext, pStart, size, propName, propSize, pPropValue, pPropSizeRet); - context.notify_end(UR_FUNCTION_VIRTUAL_MEM_GET_INFO, "urVirtualMemGetInfo", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_VIRTUAL_MEM_GET_INFO, + "urVirtualMemGetInfo", ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_VIRTUAL_MEM_GET_INFO, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -2239,7 +2255,7 @@ __urdlllocal ur_result_t UR_APICALL urPhysicalMemCreate( ur_physical_mem_handle_t * phPhysicalMem ///< [out] pointer to handle of physical memory object created. ) { - auto pfnCreate = context.urDdiTable.PhysicalMem.pfnCreate; + auto pfnCreate = getContext()->urDdiTable.PhysicalMem.pfnCreate; if (nullptr == pfnCreate) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -2247,21 +2263,21 @@ __urdlllocal ur_result_t UR_APICALL urPhysicalMemCreate( ur_physical_mem_create_params_t params = {&hContext, &hDevice, &size, &pProperties, &phPhysicalMem}; - uint64_t instance = context.notify_begin(UR_FUNCTION_PHYSICAL_MEM_CREATE, - "urPhysicalMemCreate", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_PHYSICAL_MEM_CREATE, "urPhysicalMemCreate", ¶ms); - context.logger.info("---> urPhysicalMemCreate"); + getContext()->logger.info("---> urPhysicalMemCreate"); ur_result_t result = pfnCreate(hContext, hDevice, size, pProperties, phPhysicalMem); - context.notify_end(UR_FUNCTION_PHYSICAL_MEM_CREATE, "urPhysicalMemCreate", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_PHYSICAL_MEM_CREATE, + "urPhysicalMemCreate", ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_PHYSICAL_MEM_CREATE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -2272,27 +2288,27 @@ __urdlllocal ur_result_t UR_APICALL urPhysicalMemRetain( ur_physical_mem_handle_t hPhysicalMem ///< [in] handle of the physical memory object to retain. ) { - auto pfnRetain = context.urDdiTable.PhysicalMem.pfnRetain; + auto pfnRetain = getContext()->urDdiTable.PhysicalMem.pfnRetain; if (nullptr == pfnRetain) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_physical_mem_retain_params_t params = {&hPhysicalMem}; - uint64_t instance = context.notify_begin(UR_FUNCTION_PHYSICAL_MEM_RETAIN, - "urPhysicalMemRetain", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_PHYSICAL_MEM_RETAIN, "urPhysicalMemRetain", ¶ms); - context.logger.info("---> urPhysicalMemRetain"); + getContext()->logger.info("---> urPhysicalMemRetain"); ur_result_t result = pfnRetain(hPhysicalMem); - context.notify_end(UR_FUNCTION_PHYSICAL_MEM_RETAIN, "urPhysicalMemRetain", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_PHYSICAL_MEM_RETAIN, + "urPhysicalMemRetain", ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_PHYSICAL_MEM_RETAIN, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -2303,27 +2319,28 @@ __urdlllocal ur_result_t UR_APICALL urPhysicalMemRelease( ur_physical_mem_handle_t hPhysicalMem ///< [in][release] handle of the physical memory object to release. ) { - auto pfnRelease = context.urDdiTable.PhysicalMem.pfnRelease; + auto pfnRelease = getContext()->urDdiTable.PhysicalMem.pfnRelease; if (nullptr == pfnRelease) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_physical_mem_release_params_t params = {&hPhysicalMem}; - uint64_t instance = context.notify_begin(UR_FUNCTION_PHYSICAL_MEM_RELEASE, - "urPhysicalMemRelease", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_PHYSICAL_MEM_RELEASE, "urPhysicalMemRelease", ¶ms); - context.logger.info("---> urPhysicalMemRelease"); + getContext()->logger.info("---> urPhysicalMemRelease"); ur_result_t result = pfnRelease(hPhysicalMem); - context.notify_end(UR_FUNCTION_PHYSICAL_MEM_RELEASE, "urPhysicalMemRelease", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_PHYSICAL_MEM_RELEASE, + "urPhysicalMemRelease", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_PHYSICAL_MEM_RELEASE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -2339,7 +2356,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithIL( ur_program_handle_t *phProgram ///< [out] pointer to handle of program object created. ) { - auto pfnCreateWithIL = context.urDdiTable.Program.pfnCreateWithIL; + auto pfnCreateWithIL = getContext()->urDdiTable.Program.pfnCreateWithIL; if (nullptr == pfnCreateWithIL) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -2347,21 +2364,22 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithIL( ur_program_create_with_il_params_t params = {&hContext, &pIL, &length, &pProperties, &phProgram}; - uint64_t instance = context.notify_begin(UR_FUNCTION_PROGRAM_CREATE_WITH_IL, - "urProgramCreateWithIL", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_PROGRAM_CREATE_WITH_IL, "urProgramCreateWithIL", ¶ms); - context.logger.info("---> urProgramCreateWithIL"); + getContext()->logger.info("---> urProgramCreateWithIL"); ur_result_t result = pfnCreateWithIL(hContext, pIL, length, pProperties, phProgram); - context.notify_end(UR_FUNCTION_PROGRAM_CREATE_WITH_IL, - "urProgramCreateWithIL", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_PROGRAM_CREATE_WITH_IL, + "urProgramCreateWithIL", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_PROGRAM_CREATE_WITH_IL, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -2379,7 +2397,8 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithBinary( ur_program_handle_t *phProgram ///< [out] pointer to handle of Program object created. ) { - auto pfnCreateWithBinary = context.urDdiTable.Program.pfnCreateWithBinary; + auto pfnCreateWithBinary = + getContext()->urDdiTable.Program.pfnCreateWithBinary; if (nullptr == pfnCreateWithBinary) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -2388,21 +2407,22 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithBinary( ur_program_create_with_binary_params_t params = { &hContext, &hDevice, &size, &pBinary, &pProperties, &phProgram}; uint64_t instance = - context.notify_begin(UR_FUNCTION_PROGRAM_CREATE_WITH_BINARY, - "urProgramCreateWithBinary", ¶ms); + getContext()->notify_begin(UR_FUNCTION_PROGRAM_CREATE_WITH_BINARY, + "urProgramCreateWithBinary", ¶ms); - context.logger.info("---> urProgramCreateWithBinary"); + getContext()->logger.info("---> urProgramCreateWithBinary"); ur_result_t result = pfnCreateWithBinary(hContext, hDevice, size, pBinary, pProperties, phProgram); - context.notify_end(UR_FUNCTION_PROGRAM_CREATE_WITH_BINARY, - "urProgramCreateWithBinary", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_PROGRAM_CREATE_WITH_BINARY, + "urProgramCreateWithBinary", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_PROGRAM_CREATE_WITH_BINARY, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -2415,27 +2435,27 @@ __urdlllocal ur_result_t UR_APICALL urProgramBuild( const char * pOptions ///< [in][optional] pointer to build options null-terminated string. ) { - auto pfnBuild = context.urDdiTable.Program.pfnBuild; + auto pfnBuild = getContext()->urDdiTable.Program.pfnBuild; if (nullptr == pfnBuild) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_program_build_params_t params = {&hContext, &hProgram, &pOptions}; - uint64_t instance = context.notify_begin(UR_FUNCTION_PROGRAM_BUILD, - "urProgramBuild", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_PROGRAM_BUILD, + "urProgramBuild", ¶ms); - context.logger.info("---> urProgramBuild"); + getContext()->logger.info("---> urProgramBuild"); ur_result_t result = pfnBuild(hContext, hProgram, pOptions); - context.notify_end(UR_FUNCTION_PROGRAM_BUILD, "urProgramBuild", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_PROGRAM_BUILD, "urProgramBuild", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_PROGRAM_BUILD, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -2449,27 +2469,27 @@ __urdlllocal ur_result_t UR_APICALL urProgramCompile( const char * pOptions ///< [in][optional] pointer to build options null-terminated string. ) { - auto pfnCompile = context.urDdiTable.Program.pfnCompile; + auto pfnCompile = getContext()->urDdiTable.Program.pfnCompile; if (nullptr == pfnCompile) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_program_compile_params_t params = {&hContext, &hProgram, &pOptions}; - uint64_t instance = context.notify_begin(UR_FUNCTION_PROGRAM_COMPILE, - "urProgramCompile", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_PROGRAM_COMPILE, + "urProgramCompile", ¶ms); - context.logger.info("---> urProgramCompile"); + getContext()->logger.info("---> urProgramCompile"); ur_result_t result = pfnCompile(hContext, hProgram, pOptions); - context.notify_end(UR_FUNCTION_PROGRAM_COMPILE, "urProgramCompile", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_PROGRAM_COMPILE, "urProgramCompile", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_PROGRAM_COMPILE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -2486,7 +2506,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramLink( ur_program_handle_t *phProgram ///< [out] pointer to handle of program object created. ) { - auto pfnLink = context.urDdiTable.Program.pfnLink; + auto pfnLink = getContext()->urDdiTable.Program.pfnLink; if (nullptr == pfnLink) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -2494,21 +2514,21 @@ __urdlllocal ur_result_t UR_APICALL urProgramLink( ur_program_link_params_t params = {&hContext, &count, &phPrograms, &pOptions, &phProgram}; - uint64_t instance = context.notify_begin(UR_FUNCTION_PROGRAM_LINK, - "urProgramLink", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_PROGRAM_LINK, + "urProgramLink", ¶ms); - context.logger.info("---> urProgramLink"); + getContext()->logger.info("---> urProgramLink"); ur_result_t result = pfnLink(hContext, count, phPrograms, pOptions, phProgram); - context.notify_end(UR_FUNCTION_PROGRAM_LINK, "urProgramLink", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_PROGRAM_LINK, "urProgramLink", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_PROGRAM_LINK, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -2518,27 +2538,27 @@ __urdlllocal ur_result_t UR_APICALL urProgramLink( __urdlllocal ur_result_t UR_APICALL urProgramRetain( ur_program_handle_t hProgram ///< [in] handle for the Program to retain ) { - auto pfnRetain = context.urDdiTable.Program.pfnRetain; + auto pfnRetain = getContext()->urDdiTable.Program.pfnRetain; if (nullptr == pfnRetain) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_program_retain_params_t params = {&hProgram}; - uint64_t instance = context.notify_begin(UR_FUNCTION_PROGRAM_RETAIN, - "urProgramRetain", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_PROGRAM_RETAIN, + "urProgramRetain", ¶ms); - context.logger.info("---> urProgramRetain"); + getContext()->logger.info("---> urProgramRetain"); ur_result_t result = pfnRetain(hProgram); - context.notify_end(UR_FUNCTION_PROGRAM_RETAIN, "urProgramRetain", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_PROGRAM_RETAIN, "urProgramRetain", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_PROGRAM_RETAIN, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -2549,27 +2569,27 @@ __urdlllocal ur_result_t UR_APICALL urProgramRelease( ur_program_handle_t hProgram ///< [in][release] handle for the Program to release ) { - auto pfnRelease = context.urDdiTable.Program.pfnRelease; + auto pfnRelease = getContext()->urDdiTable.Program.pfnRelease; if (nullptr == pfnRelease) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_program_release_params_t params = {&hProgram}; - uint64_t instance = context.notify_begin(UR_FUNCTION_PROGRAM_RELEASE, - "urProgramRelease", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_PROGRAM_RELEASE, + "urProgramRelease", ¶ms); - context.logger.info("---> urProgramRelease"); + getContext()->logger.info("---> urProgramRelease"); ur_result_t result = pfnRelease(hProgram); - context.notify_end(UR_FUNCTION_PROGRAM_RELEASE, "urProgramRelease", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_PROGRAM_RELEASE, "urProgramRelease", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_PROGRAM_RELEASE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -2589,7 +2609,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetFunctionPointer( ppFunctionPointer ///< [out] Returns the pointer to the function if it is found in the program. ) { auto pfnGetFunctionPointer = - context.urDdiTable.Program.pfnGetFunctionPointer; + getContext()->urDdiTable.Program.pfnGetFunctionPointer; if (nullptr == pfnGetFunctionPointer) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -2598,22 +2618,22 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetFunctionPointer( ur_program_get_function_pointer_params_t params = { &hDevice, &hProgram, &pFunctionName, &ppFunctionPointer}; uint64_t instance = - context.notify_begin(UR_FUNCTION_PROGRAM_GET_FUNCTION_POINTER, - "urProgramGetFunctionPointer", ¶ms); + getContext()->notify_begin(UR_FUNCTION_PROGRAM_GET_FUNCTION_POINTER, + "urProgramGetFunctionPointer", ¶ms); - context.logger.info("---> urProgramGetFunctionPointer"); + getContext()->logger.info("---> urProgramGetFunctionPointer"); ur_result_t result = pfnGetFunctionPointer(hDevice, hProgram, pFunctionName, ppFunctionPointer); - context.notify_end(UR_FUNCTION_PROGRAM_GET_FUNCTION_POINTER, - "urProgramGetFunctionPointer", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_PROGRAM_GET_FUNCTION_POINTER, + "urProgramGetFunctionPointer", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_PROGRAM_GET_FUNCTION_POINTER, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -2634,7 +2654,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetGlobalVariablePointer( ppGlobalVariablePointerRet ///< [out] Returns the pointer to the global variable if it is found in the program. ) { auto pfnGetGlobalVariablePointer = - context.urDdiTable.Program.pfnGetGlobalVariablePointer; + getContext()->urDdiTable.Program.pfnGetGlobalVariablePointer; if (nullptr == pfnGetGlobalVariablePointer) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -2643,24 +2663,24 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetGlobalVariablePointer( ur_program_get_global_variable_pointer_params_t params = { &hDevice, &hProgram, &pGlobalVariableName, &pGlobalVariableSizeRet, &ppGlobalVariablePointerRet}; - uint64_t instance = - context.notify_begin(UR_FUNCTION_PROGRAM_GET_GLOBAL_VARIABLE_POINTER, - "urProgramGetGlobalVariablePointer", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_PROGRAM_GET_GLOBAL_VARIABLE_POINTER, + "urProgramGetGlobalVariablePointer", ¶ms); - context.logger.info("---> urProgramGetGlobalVariablePointer"); + getContext()->logger.info("---> urProgramGetGlobalVariablePointer"); ur_result_t result = pfnGetGlobalVariablePointer( hDevice, hProgram, pGlobalVariableName, pGlobalVariableSizeRet, ppGlobalVariablePointerRet); - context.notify_end(UR_FUNCTION_PROGRAM_GET_GLOBAL_VARIABLE_POINTER, - "urProgramGetGlobalVariablePointer", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_PROGRAM_GET_GLOBAL_VARIABLE_POINTER, + "urProgramGetGlobalVariablePointer", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_PROGRAM_GET_GLOBAL_VARIABLE_POINTER, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -2681,7 +2701,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetInfo( size_t * pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of the queried propName. ) { - auto pfnGetInfo = context.urDdiTable.Program.pfnGetInfo; + auto pfnGetInfo = getContext()->urDdiTable.Program.pfnGetInfo; if (nullptr == pfnGetInfo) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -2689,21 +2709,21 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetInfo( ur_program_get_info_params_t params = {&hProgram, &propName, &propSize, &pPropValue, &pPropSizeRet}; - uint64_t instance = context.notify_begin(UR_FUNCTION_PROGRAM_GET_INFO, - "urProgramGetInfo", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_PROGRAM_GET_INFO, + "urProgramGetInfo", ¶ms); - context.logger.info("---> urProgramGetInfo"); + getContext()->logger.info("---> urProgramGetInfo"); ur_result_t result = pfnGetInfo(hProgram, propName, propSize, pPropValue, pPropSizeRet); - context.notify_end(UR_FUNCTION_PROGRAM_GET_INFO, "urProgramGetInfo", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_PROGRAM_GET_INFO, "urProgramGetInfo", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_PROGRAM_GET_INFO, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -2726,7 +2746,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetBuildInfo( pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of data being ///< queried by propName. ) { - auto pfnGetBuildInfo = context.urDdiTable.Program.pfnGetBuildInfo; + auto pfnGetBuildInfo = getContext()->urDdiTable.Program.pfnGetBuildInfo; if (nullptr == pfnGetBuildInfo) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -2734,21 +2754,22 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetBuildInfo( ur_program_get_build_info_params_t params = { &hProgram, &hDevice, &propName, &propSize, &pPropValue, &pPropSizeRet}; - uint64_t instance = context.notify_begin(UR_FUNCTION_PROGRAM_GET_BUILD_INFO, - "urProgramGetBuildInfo", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_PROGRAM_GET_BUILD_INFO, "urProgramGetBuildInfo", ¶ms); - context.logger.info("---> urProgramGetBuildInfo"); + getContext()->logger.info("---> urProgramGetBuildInfo"); ur_result_t result = pfnGetBuildInfo(hProgram, hDevice, propName, propSize, pPropValue, pPropSizeRet); - context.notify_end(UR_FUNCTION_PROGRAM_GET_BUILD_INFO, - "urProgramGetBuildInfo", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_PROGRAM_GET_BUILD_INFO, + "urProgramGetBuildInfo", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_PROGRAM_GET_BUILD_INFO, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -2763,7 +2784,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramSetSpecializationConstants( ///< descriptions ) { auto pfnSetSpecializationConstants = - context.urDdiTable.Program.pfnSetSpecializationConstants; + getContext()->urDdiTable.Program.pfnSetSpecializationConstants; if (nullptr == pfnSetSpecializationConstants) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -2771,23 +2792,23 @@ __urdlllocal ur_result_t UR_APICALL urProgramSetSpecializationConstants( ur_program_set_specialization_constants_params_t params = { &hProgram, &count, &pSpecConstants}; - uint64_t instance = - context.notify_begin(UR_FUNCTION_PROGRAM_SET_SPECIALIZATION_CONSTANTS, - "urProgramSetSpecializationConstants", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_PROGRAM_SET_SPECIALIZATION_CONSTANTS, + "urProgramSetSpecializationConstants", ¶ms); - context.logger.info("---> urProgramSetSpecializationConstants"); + getContext()->logger.info("---> urProgramSetSpecializationConstants"); ur_result_t result = pfnSetSpecializationConstants(hProgram, count, pSpecConstants); - context.notify_end(UR_FUNCTION_PROGRAM_SET_SPECIALIZATION_CONSTANTS, - "urProgramSetSpecializationConstants", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_PROGRAM_SET_SPECIALIZATION_CONSTANTS, + "urProgramSetSpecializationConstants", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_PROGRAM_SET_SPECIALIZATION_CONSTANTS, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -2799,7 +2820,8 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetNativeHandle( ur_native_handle_t * phNativeProgram ///< [out] a pointer to the native handle of the program. ) { - auto pfnGetNativeHandle = context.urDdiTable.Program.pfnGetNativeHandle; + auto pfnGetNativeHandle = + getContext()->urDdiTable.Program.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -2808,20 +2830,21 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetNativeHandle( ur_program_get_native_handle_params_t params = {&hProgram, &phNativeProgram}; uint64_t instance = - context.notify_begin(UR_FUNCTION_PROGRAM_GET_NATIVE_HANDLE, - "urProgramGetNativeHandle", ¶ms); + getContext()->notify_begin(UR_FUNCTION_PROGRAM_GET_NATIVE_HANDLE, + "urProgramGetNativeHandle", ¶ms); - context.logger.info("---> urProgramGetNativeHandle"); + getContext()->logger.info("---> urProgramGetNativeHandle"); ur_result_t result = pfnGetNativeHandle(hProgram, phNativeProgram); - context.notify_end(UR_FUNCTION_PROGRAM_GET_NATIVE_HANDLE, - "urProgramGetNativeHandle", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_PROGRAM_GET_NATIVE_HANDLE, + "urProgramGetNativeHandle", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_PROGRAM_GET_NATIVE_HANDLE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -2838,7 +2861,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithNativeHandle( phProgram ///< [out] pointer to the handle of the program object created. ) { auto pfnCreateWithNativeHandle = - context.urDdiTable.Program.pfnCreateWithNativeHandle; + getContext()->urDdiTable.Program.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -2846,23 +2869,23 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithNativeHandle( ur_program_create_with_native_handle_params_t params = { &hNativeProgram, &hContext, &pProperties, &phProgram}; - uint64_t instance = - context.notify_begin(UR_FUNCTION_PROGRAM_CREATE_WITH_NATIVE_HANDLE, - "urProgramCreateWithNativeHandle", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_PROGRAM_CREATE_WITH_NATIVE_HANDLE, + "urProgramCreateWithNativeHandle", ¶ms); - context.logger.info("---> urProgramCreateWithNativeHandle"); + getContext()->logger.info("---> urProgramCreateWithNativeHandle"); ur_result_t result = pfnCreateWithNativeHandle(hNativeProgram, hContext, pProperties, phProgram); - context.notify_end(UR_FUNCTION_PROGRAM_CREATE_WITH_NATIVE_HANDLE, - "urProgramCreateWithNativeHandle", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_PROGRAM_CREATE_WITH_NATIVE_HANDLE, + "urProgramCreateWithNativeHandle", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_PROGRAM_CREATE_WITH_NATIVE_HANDLE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -2875,27 +2898,27 @@ __urdlllocal ur_result_t UR_APICALL urKernelCreate( ur_kernel_handle_t *phKernel ///< [out] pointer to handle of kernel object created. ) { - auto pfnCreate = context.urDdiTable.Kernel.pfnCreate; + auto pfnCreate = getContext()->urDdiTable.Kernel.pfnCreate; if (nullptr == pfnCreate) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_kernel_create_params_t params = {&hProgram, &pKernelName, &phKernel}; - uint64_t instance = context.notify_begin(UR_FUNCTION_KERNEL_CREATE, - "urKernelCreate", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_KERNEL_CREATE, + "urKernelCreate", ¶ms); - context.logger.info("---> urKernelCreate"); + getContext()->logger.info("---> urKernelCreate"); ur_result_t result = pfnCreate(hProgram, pKernelName, phKernel); - context.notify_end(UR_FUNCTION_KERNEL_CREATE, "urKernelCreate", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_KERNEL_CREATE, "urKernelCreate", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_KERNEL_CREATE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -2911,7 +2934,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgValue( const void *pArgValue ///< [in] argument value represented as matching arg type. ) { - auto pfnSetArgValue = context.urDdiTable.Kernel.pfnSetArgValue; + auto pfnSetArgValue = getContext()->urDdiTable.Kernel.pfnSetArgValue; if (nullptr == pfnSetArgValue) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -2919,21 +2942,21 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgValue( ur_kernel_set_arg_value_params_t params = {&hKernel, &argIndex, &argSize, &pProperties, &pArgValue}; - uint64_t instance = context.notify_begin(UR_FUNCTION_KERNEL_SET_ARG_VALUE, - "urKernelSetArgValue", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_KERNEL_SET_ARG_VALUE, "urKernelSetArgValue", ¶ms); - context.logger.info("---> urKernelSetArgValue"); + getContext()->logger.info("---> urKernelSetArgValue"); ur_result_t result = pfnSetArgValue(hKernel, argIndex, argSize, pProperties, pArgValue); - context.notify_end(UR_FUNCTION_KERNEL_SET_ARG_VALUE, "urKernelSetArgValue", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_KERNEL_SET_ARG_VALUE, + "urKernelSetArgValue", ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_KERNEL_SET_ARG_VALUE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -2948,7 +2971,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgLocal( const ur_kernel_arg_local_properties_t *pProperties ///< [in][optional] pointer to local buffer properties. ) { - auto pfnSetArgLocal = context.urDdiTable.Kernel.pfnSetArgLocal; + auto pfnSetArgLocal = getContext()->urDdiTable.Kernel.pfnSetArgLocal; if (nullptr == pfnSetArgLocal) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -2956,21 +2979,21 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgLocal( ur_kernel_set_arg_local_params_t params = {&hKernel, &argIndex, &argSize, &pProperties}; - uint64_t instance = context.notify_begin(UR_FUNCTION_KERNEL_SET_ARG_LOCAL, - "urKernelSetArgLocal", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_KERNEL_SET_ARG_LOCAL, "urKernelSetArgLocal", ¶ms); - context.logger.info("---> urKernelSetArgLocal"); + getContext()->logger.info("---> urKernelSetArgLocal"); ur_result_t result = pfnSetArgLocal(hKernel, argIndex, argSize, pProperties); - context.notify_end(UR_FUNCTION_KERNEL_SET_ARG_LOCAL, "urKernelSetArgLocal", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_KERNEL_SET_ARG_LOCAL, + "urKernelSetArgLocal", ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_KERNEL_SET_ARG_LOCAL, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -2992,7 +3015,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetInfo( pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of data being ///< queried by propName. ) { - auto pfnGetInfo = context.urDdiTable.Kernel.pfnGetInfo; + auto pfnGetInfo = getContext()->urDdiTable.Kernel.pfnGetInfo; if (nullptr == pfnGetInfo) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -3000,21 +3023,21 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetInfo( ur_kernel_get_info_params_t params = {&hKernel, &propName, &propSize, &pPropValue, &pPropSizeRet}; - uint64_t instance = context.notify_begin(UR_FUNCTION_KERNEL_GET_INFO, - "urKernelGetInfo", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_KERNEL_GET_INFO, + "urKernelGetInfo", ¶ms); - context.logger.info("---> urKernelGetInfo"); + getContext()->logger.info("---> urKernelGetInfo"); ur_result_t result = pfnGetInfo(hKernel, propName, propSize, pPropValue, pPropSizeRet); - context.notify_end(UR_FUNCTION_KERNEL_GET_INFO, "urKernelGetInfo", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_KERNEL_GET_INFO, "urKernelGetInfo", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_KERNEL_GET_INFO, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -3034,7 +3057,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetGroupInfo( pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of data being ///< queried by propName. ) { - auto pfnGetGroupInfo = context.urDdiTable.Kernel.pfnGetGroupInfo; + auto pfnGetGroupInfo = getContext()->urDdiTable.Kernel.pfnGetGroupInfo; if (nullptr == pfnGetGroupInfo) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -3042,21 +3065,22 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetGroupInfo( ur_kernel_get_group_info_params_t params = { &hKernel, &hDevice, &propName, &propSize, &pPropValue, &pPropSizeRet}; - uint64_t instance = context.notify_begin(UR_FUNCTION_KERNEL_GET_GROUP_INFO, - "urKernelGetGroupInfo", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_KERNEL_GET_GROUP_INFO, "urKernelGetGroupInfo", ¶ms); - context.logger.info("---> urKernelGetGroupInfo"); + getContext()->logger.info("---> urKernelGetGroupInfo"); ur_result_t result = pfnGetGroupInfo(hKernel, hDevice, propName, propSize, pPropValue, pPropSizeRet); - context.notify_end(UR_FUNCTION_KERNEL_GET_GROUP_INFO, - "urKernelGetGroupInfo", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_KERNEL_GET_GROUP_INFO, + "urKernelGetGroupInfo", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_KERNEL_GET_GROUP_INFO, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -3076,7 +3100,8 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetSubGroupInfo( pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of data being ///< queried by propName. ) { - auto pfnGetSubGroupInfo = context.urDdiTable.Kernel.pfnGetSubGroupInfo; + auto pfnGetSubGroupInfo = + getContext()->urDdiTable.Kernel.pfnGetSubGroupInfo; if (nullptr == pfnGetSubGroupInfo) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -3085,21 +3110,22 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetSubGroupInfo( ur_kernel_get_sub_group_info_params_t params = { &hKernel, &hDevice, &propName, &propSize, &pPropValue, &pPropSizeRet}; uint64_t instance = - context.notify_begin(UR_FUNCTION_KERNEL_GET_SUB_GROUP_INFO, - "urKernelGetSubGroupInfo", ¶ms); + getContext()->notify_begin(UR_FUNCTION_KERNEL_GET_SUB_GROUP_INFO, + "urKernelGetSubGroupInfo", ¶ms); - context.logger.info("---> urKernelGetSubGroupInfo"); + getContext()->logger.info("---> urKernelGetSubGroupInfo"); ur_result_t result = pfnGetSubGroupInfo(hKernel, hDevice, propName, propSize, pPropValue, pPropSizeRet); - context.notify_end(UR_FUNCTION_KERNEL_GET_SUB_GROUP_INFO, - "urKernelGetSubGroupInfo", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_KERNEL_GET_SUB_GROUP_INFO, + "urKernelGetSubGroupInfo", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_KERNEL_GET_SUB_GROUP_INFO, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -3109,27 +3135,27 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetSubGroupInfo( __urdlllocal ur_result_t UR_APICALL urKernelRetain( ur_kernel_handle_t hKernel ///< [in] handle for the Kernel to retain ) { - auto pfnRetain = context.urDdiTable.Kernel.pfnRetain; + auto pfnRetain = getContext()->urDdiTable.Kernel.pfnRetain; if (nullptr == pfnRetain) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_kernel_retain_params_t params = {&hKernel}; - uint64_t instance = context.notify_begin(UR_FUNCTION_KERNEL_RETAIN, - "urKernelRetain", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_KERNEL_RETAIN, + "urKernelRetain", ¶ms); - context.logger.info("---> urKernelRetain"); + getContext()->logger.info("---> urKernelRetain"); ur_result_t result = pfnRetain(hKernel); - context.notify_end(UR_FUNCTION_KERNEL_RETAIN, "urKernelRetain", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_KERNEL_RETAIN, "urKernelRetain", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_KERNEL_RETAIN, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -3140,27 +3166,27 @@ __urdlllocal ur_result_t UR_APICALL urKernelRelease( ur_kernel_handle_t hKernel ///< [in][release] handle for the Kernel to release ) { - auto pfnRelease = context.urDdiTable.Kernel.pfnRelease; + auto pfnRelease = getContext()->urDdiTable.Kernel.pfnRelease; if (nullptr == pfnRelease) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_kernel_release_params_t params = {&hKernel}; - uint64_t instance = context.notify_begin(UR_FUNCTION_KERNEL_RELEASE, - "urKernelRelease", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_KERNEL_RELEASE, + "urKernelRelease", ¶ms); - context.logger.info("---> urKernelRelease"); + getContext()->logger.info("---> urKernelRelease"); ur_result_t result = pfnRelease(hKernel); - context.notify_end(UR_FUNCTION_KERNEL_RELEASE, "urKernelRelease", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_KERNEL_RELEASE, "urKernelRelease", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_KERNEL_RELEASE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -3176,7 +3202,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgPointer( pArgValue ///< [in][optional] Pointer obtained by USM allocation or virtual memory ///< mapping operation. If null then argument value is considered null. ) { - auto pfnSetArgPointer = context.urDdiTable.Kernel.pfnSetArgPointer; + auto pfnSetArgPointer = getContext()->urDdiTable.Kernel.pfnSetArgPointer; if (nullptr == pfnSetArgPointer) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -3184,21 +3210,22 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgPointer( ur_kernel_set_arg_pointer_params_t params = {&hKernel, &argIndex, &pProperties, &pArgValue}; - uint64_t instance = context.notify_begin(UR_FUNCTION_KERNEL_SET_ARG_POINTER, - "urKernelSetArgPointer", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_KERNEL_SET_ARG_POINTER, "urKernelSetArgPointer", ¶ms); - context.logger.info("---> urKernelSetArgPointer"); + getContext()->logger.info("---> urKernelSetArgPointer"); ur_result_t result = pfnSetArgPointer(hKernel, argIndex, pProperties, pArgValue); - context.notify_end(UR_FUNCTION_KERNEL_SET_ARG_POINTER, - "urKernelSetArgPointer", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_KERNEL_SET_ARG_POINTER, + "urKernelSetArgPointer", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_KERNEL_SET_ARG_POINTER, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -3215,7 +3242,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetExecInfo( pPropValue ///< [in][typename(propName, propSize)] pointer to memory location holding ///< the property value. ) { - auto pfnSetExecInfo = context.urDdiTable.Kernel.pfnSetExecInfo; + auto pfnSetExecInfo = getContext()->urDdiTable.Kernel.pfnSetExecInfo; if (nullptr == pfnSetExecInfo) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -3223,21 +3250,21 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetExecInfo( ur_kernel_set_exec_info_params_t params = {&hKernel, &propName, &propSize, &pProperties, &pPropValue}; - uint64_t instance = context.notify_begin(UR_FUNCTION_KERNEL_SET_EXEC_INFO, - "urKernelSetExecInfo", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_KERNEL_SET_EXEC_INFO, "urKernelSetExecInfo", ¶ms); - context.logger.info("---> urKernelSetExecInfo"); + getContext()->logger.info("---> urKernelSetExecInfo"); ur_result_t result = pfnSetExecInfo(hKernel, propName, propSize, pProperties, pPropValue); - context.notify_end(UR_FUNCTION_KERNEL_SET_EXEC_INFO, "urKernelSetExecInfo", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_KERNEL_SET_EXEC_INFO, + "urKernelSetExecInfo", ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_KERNEL_SET_EXEC_INFO, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -3251,7 +3278,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgSampler( *pProperties, ///< [in][optional] pointer to sampler properties. ur_sampler_handle_t hArgValue ///< [in] handle of Sampler object. ) { - auto pfnSetArgSampler = context.urDdiTable.Kernel.pfnSetArgSampler; + auto pfnSetArgSampler = getContext()->urDdiTable.Kernel.pfnSetArgSampler; if (nullptr == pfnSetArgSampler) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -3259,21 +3286,22 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgSampler( ur_kernel_set_arg_sampler_params_t params = {&hKernel, &argIndex, &pProperties, &hArgValue}; - uint64_t instance = context.notify_begin(UR_FUNCTION_KERNEL_SET_ARG_SAMPLER, - "urKernelSetArgSampler", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_KERNEL_SET_ARG_SAMPLER, "urKernelSetArgSampler", ¶ms); - context.logger.info("---> urKernelSetArgSampler"); + getContext()->logger.info("---> urKernelSetArgSampler"); ur_result_t result = pfnSetArgSampler(hKernel, argIndex, pProperties, hArgValue); - context.notify_end(UR_FUNCTION_KERNEL_SET_ARG_SAMPLER, - "urKernelSetArgSampler", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_KERNEL_SET_ARG_SAMPLER, + "urKernelSetArgSampler", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_KERNEL_SET_ARG_SAMPLER, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -3287,7 +3315,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgMemObj( *pProperties, ///< [in][optional] pointer to Memory object properties. ur_mem_handle_t hArgValue ///< [in][optional] handle of Memory object. ) { - auto pfnSetArgMemObj = context.urDdiTable.Kernel.pfnSetArgMemObj; + auto pfnSetArgMemObj = getContext()->urDdiTable.Kernel.pfnSetArgMemObj; if (nullptr == pfnSetArgMemObj) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -3295,21 +3323,22 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgMemObj( ur_kernel_set_arg_mem_obj_params_t params = {&hKernel, &argIndex, &pProperties, &hArgValue}; - uint64_t instance = context.notify_begin(UR_FUNCTION_KERNEL_SET_ARG_MEM_OBJ, - "urKernelSetArgMemObj", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_KERNEL_SET_ARG_MEM_OBJ, "urKernelSetArgMemObj", ¶ms); - context.logger.info("---> urKernelSetArgMemObj"); + getContext()->logger.info("---> urKernelSetArgMemObj"); ur_result_t result = pfnSetArgMemObj(hKernel, argIndex, pProperties, hArgValue); - context.notify_end(UR_FUNCTION_KERNEL_SET_ARG_MEM_OBJ, - "urKernelSetArgMemObj", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_KERNEL_SET_ARG_MEM_OBJ, + "urKernelSetArgMemObj", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_KERNEL_SET_ARG_MEM_OBJ, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -3323,7 +3352,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetSpecializationConstants( pSpecConstants ///< [in] array of specialization constant value descriptions ) { auto pfnSetSpecializationConstants = - context.urDdiTable.Kernel.pfnSetSpecializationConstants; + getContext()->urDdiTable.Kernel.pfnSetSpecializationConstants; if (nullptr == pfnSetSpecializationConstants) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -3331,23 +3360,23 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetSpecializationConstants( ur_kernel_set_specialization_constants_params_t params = {&hKernel, &count, &pSpecConstants}; - uint64_t instance = - context.notify_begin(UR_FUNCTION_KERNEL_SET_SPECIALIZATION_CONSTANTS, - "urKernelSetSpecializationConstants", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_KERNEL_SET_SPECIALIZATION_CONSTANTS, + "urKernelSetSpecializationConstants", ¶ms); - context.logger.info("---> urKernelSetSpecializationConstants"); + getContext()->logger.info("---> urKernelSetSpecializationConstants"); ur_result_t result = pfnSetSpecializationConstants(hKernel, count, pSpecConstants); - context.notify_end(UR_FUNCTION_KERNEL_SET_SPECIALIZATION_CONSTANTS, - "urKernelSetSpecializationConstants", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_KERNEL_SET_SPECIALIZATION_CONSTANTS, + "urKernelSetSpecializationConstants", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_KERNEL_SET_SPECIALIZATION_CONSTANTS, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -3359,7 +3388,8 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetNativeHandle( ur_native_handle_t *phNativeKernel ///< [out] a pointer to the native handle of the kernel. ) { - auto pfnGetNativeHandle = context.urDdiTable.Kernel.pfnGetNativeHandle; + auto pfnGetNativeHandle = + getContext()->urDdiTable.Kernel.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -3367,20 +3397,21 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetNativeHandle( ur_kernel_get_native_handle_params_t params = {&hKernel, &phNativeKernel}; uint64_t instance = - context.notify_begin(UR_FUNCTION_KERNEL_GET_NATIVE_HANDLE, - "urKernelGetNativeHandle", ¶ms); + getContext()->notify_begin(UR_FUNCTION_KERNEL_GET_NATIVE_HANDLE, + "urKernelGetNativeHandle", ¶ms); - context.logger.info("---> urKernelGetNativeHandle"); + getContext()->logger.info("---> urKernelGetNativeHandle"); ur_result_t result = pfnGetNativeHandle(hKernel, phNativeKernel); - context.notify_end(UR_FUNCTION_KERNEL_GET_NATIVE_HANDLE, - "urKernelGetNativeHandle", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_KERNEL_GET_NATIVE_HANDLE, + "urKernelGetNativeHandle", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_KERNEL_GET_NATIVE_HANDLE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -3399,7 +3430,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelCreateWithNativeHandle( *phKernel ///< [out] pointer to the handle of the kernel object created. ) { auto pfnCreateWithNativeHandle = - context.urDdiTable.Kernel.pfnCreateWithNativeHandle; + getContext()->urDdiTable.Kernel.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -3408,22 +3439,22 @@ __urdlllocal ur_result_t UR_APICALL urKernelCreateWithNativeHandle( ur_kernel_create_with_native_handle_params_t params = { &hNativeKernel, &hContext, &hProgram, &pProperties, &phKernel}; uint64_t instance = - context.notify_begin(UR_FUNCTION_KERNEL_CREATE_WITH_NATIVE_HANDLE, - "urKernelCreateWithNativeHandle", ¶ms); + getContext()->notify_begin(UR_FUNCTION_KERNEL_CREATE_WITH_NATIVE_HANDLE, + "urKernelCreateWithNativeHandle", ¶ms); - context.logger.info("---> urKernelCreateWithNativeHandle"); + getContext()->logger.info("---> urKernelCreateWithNativeHandle"); ur_result_t result = pfnCreateWithNativeHandle( hNativeKernel, hContext, hProgram, pProperties, phKernel); - context.notify_end(UR_FUNCTION_KERNEL_CREATE_WITH_NATIVE_HANDLE, - "urKernelCreateWithNativeHandle", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_KERNEL_CREATE_WITH_NATIVE_HANDLE, + "urKernelCreateWithNativeHandle", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_KERNEL_CREATE_WITH_NATIVE_HANDLE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -3448,7 +3479,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetSuggestedLocalWorkSize( ///< suggested local work size that will contain the result of the query ) { auto pfnGetSuggestedLocalWorkSize = - context.urDdiTable.Kernel.pfnGetSuggestedLocalWorkSize; + getContext()->urDdiTable.Kernel.pfnGetSuggestedLocalWorkSize; if (nullptr == pfnGetSuggestedLocalWorkSize) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -3457,24 +3488,24 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetSuggestedLocalWorkSize( ur_kernel_get_suggested_local_work_size_params_t params = { &hKernel, &hQueue, &numWorkDim, &pGlobalWorkOffset, &pGlobalWorkSize, &pSuggestedLocalWorkSize}; - uint64_t instance = - context.notify_begin(UR_FUNCTION_KERNEL_GET_SUGGESTED_LOCAL_WORK_SIZE, - "urKernelGetSuggestedLocalWorkSize", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_KERNEL_GET_SUGGESTED_LOCAL_WORK_SIZE, + "urKernelGetSuggestedLocalWorkSize", ¶ms); - context.logger.info("---> urKernelGetSuggestedLocalWorkSize"); + getContext()->logger.info("---> urKernelGetSuggestedLocalWorkSize"); ur_result_t result = pfnGetSuggestedLocalWorkSize( hKernel, hQueue, numWorkDim, pGlobalWorkOffset, pGlobalWorkSize, pSuggestedLocalWorkSize); - context.notify_end(UR_FUNCTION_KERNEL_GET_SUGGESTED_LOCAL_WORK_SIZE, - "urKernelGetSuggestedLocalWorkSize", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_KERNEL_GET_SUGGESTED_LOCAL_WORK_SIZE, + "urKernelGetSuggestedLocalWorkSize", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_KERNEL_GET_SUGGESTED_LOCAL_WORK_SIZE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -3492,7 +3523,7 @@ __urdlllocal ur_result_t UR_APICALL urQueueGetInfo( size_t * pPropSizeRet ///< [out][optional] size in bytes returned in queue property value ) { - auto pfnGetInfo = context.urDdiTable.Queue.pfnGetInfo; + auto pfnGetInfo = getContext()->urDdiTable.Queue.pfnGetInfo; if (nullptr == pfnGetInfo) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -3500,21 +3531,21 @@ __urdlllocal ur_result_t UR_APICALL urQueueGetInfo( ur_queue_get_info_params_t params = {&hQueue, &propName, &propSize, &pPropValue, &pPropSizeRet}; - uint64_t instance = context.notify_begin(UR_FUNCTION_QUEUE_GET_INFO, - "urQueueGetInfo", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_QUEUE_GET_INFO, + "urQueueGetInfo", ¶ms); - context.logger.info("---> urQueueGetInfo"); + getContext()->logger.info("---> urQueueGetInfo"); ur_result_t result = pfnGetInfo(hQueue, propName, propSize, pPropValue, pPropSizeRet); - context.notify_end(UR_FUNCTION_QUEUE_GET_INFO, "urQueueGetInfo", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_QUEUE_GET_INFO, "urQueueGetInfo", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_QUEUE_GET_INFO, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -3529,7 +3560,7 @@ __urdlllocal ur_result_t UR_APICALL urQueueCreate( ur_queue_handle_t *phQueue ///< [out] pointer to handle of queue object created ) { - auto pfnCreate = context.urDdiTable.Queue.pfnCreate; + auto pfnCreate = getContext()->urDdiTable.Queue.pfnCreate; if (nullptr == pfnCreate) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -3537,20 +3568,20 @@ __urdlllocal ur_result_t UR_APICALL urQueueCreate( ur_queue_create_params_t params = {&hContext, &hDevice, &pProperties, &phQueue}; - uint64_t instance = context.notify_begin(UR_FUNCTION_QUEUE_CREATE, - "urQueueCreate", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_QUEUE_CREATE, + "urQueueCreate", ¶ms); - context.logger.info("---> urQueueCreate"); + getContext()->logger.info("---> urQueueCreate"); ur_result_t result = pfnCreate(hContext, hDevice, pProperties, phQueue); - context.notify_end(UR_FUNCTION_QUEUE_CREATE, "urQueueCreate", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_QUEUE_CREATE, "urQueueCreate", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_QUEUE_CREATE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -3560,27 +3591,27 @@ __urdlllocal ur_result_t UR_APICALL urQueueCreate( __urdlllocal ur_result_t UR_APICALL urQueueRetain( ur_queue_handle_t hQueue ///< [in] handle of the queue object to get access ) { - auto pfnRetain = context.urDdiTable.Queue.pfnRetain; + auto pfnRetain = getContext()->urDdiTable.Queue.pfnRetain; if (nullptr == pfnRetain) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_queue_retain_params_t params = {&hQueue}; - uint64_t instance = context.notify_begin(UR_FUNCTION_QUEUE_RETAIN, - "urQueueRetain", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_QUEUE_RETAIN, + "urQueueRetain", ¶ms); - context.logger.info("---> urQueueRetain"); + getContext()->logger.info("---> urQueueRetain"); ur_result_t result = pfnRetain(hQueue); - context.notify_end(UR_FUNCTION_QUEUE_RETAIN, "urQueueRetain", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_QUEUE_RETAIN, "urQueueRetain", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_QUEUE_RETAIN, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -3591,27 +3622,27 @@ __urdlllocal ur_result_t UR_APICALL urQueueRelease( ur_queue_handle_t hQueue ///< [in][release] handle of the queue object to release ) { - auto pfnRelease = context.urDdiTable.Queue.pfnRelease; + auto pfnRelease = getContext()->urDdiTable.Queue.pfnRelease; if (nullptr == pfnRelease) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_queue_release_params_t params = {&hQueue}; - uint64_t instance = context.notify_begin(UR_FUNCTION_QUEUE_RELEASE, - "urQueueRelease", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_QUEUE_RELEASE, + "urQueueRelease", ¶ms); - context.logger.info("---> urQueueRelease"); + getContext()->logger.info("---> urQueueRelease"); ur_result_t result = pfnRelease(hQueue); - context.notify_end(UR_FUNCTION_QUEUE_RELEASE, "urQueueRelease", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_QUEUE_RELEASE, "urQueueRelease", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_QUEUE_RELEASE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -3625,7 +3656,7 @@ __urdlllocal ur_result_t UR_APICALL urQueueGetNativeHandle( ur_native_handle_t *phNativeQueue ///< [out] a pointer to the native handle of the queue. ) { - auto pfnGetNativeHandle = context.urDdiTable.Queue.pfnGetNativeHandle; + auto pfnGetNativeHandle = getContext()->urDdiTable.Queue.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -3633,20 +3664,21 @@ __urdlllocal ur_result_t UR_APICALL urQueueGetNativeHandle( ur_queue_get_native_handle_params_t params = {&hQueue, &pDesc, &phNativeQueue}; - uint64_t instance = context.notify_begin( + uint64_t instance = getContext()->notify_begin( UR_FUNCTION_QUEUE_GET_NATIVE_HANDLE, "urQueueGetNativeHandle", ¶ms); - context.logger.info("---> urQueueGetNativeHandle"); + getContext()->logger.info("---> urQueueGetNativeHandle"); ur_result_t result = pfnGetNativeHandle(hQueue, pDesc, phNativeQueue); - context.notify_end(UR_FUNCTION_QUEUE_GET_NATIVE_HANDLE, - "urQueueGetNativeHandle", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_QUEUE_GET_NATIVE_HANDLE, + "urQueueGetNativeHandle", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_QUEUE_GET_NATIVE_HANDLE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -3664,7 +3696,7 @@ __urdlllocal ur_result_t UR_APICALL urQueueCreateWithNativeHandle( *phQueue ///< [out] pointer to the handle of the queue object created. ) { auto pfnCreateWithNativeHandle = - context.urDdiTable.Queue.pfnCreateWithNativeHandle; + getContext()->urDdiTable.Queue.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -3673,22 +3705,22 @@ __urdlllocal ur_result_t UR_APICALL urQueueCreateWithNativeHandle( ur_queue_create_with_native_handle_params_t params = { &hNativeQueue, &hContext, &hDevice, &pProperties, &phQueue}; uint64_t instance = - context.notify_begin(UR_FUNCTION_QUEUE_CREATE_WITH_NATIVE_HANDLE, - "urQueueCreateWithNativeHandle", ¶ms); + getContext()->notify_begin(UR_FUNCTION_QUEUE_CREATE_WITH_NATIVE_HANDLE, + "urQueueCreateWithNativeHandle", ¶ms); - context.logger.info("---> urQueueCreateWithNativeHandle"); + getContext()->logger.info("---> urQueueCreateWithNativeHandle"); ur_result_t result = pfnCreateWithNativeHandle( hNativeQueue, hContext, hDevice, pProperties, phQueue); - context.notify_end(UR_FUNCTION_QUEUE_CREATE_WITH_NATIVE_HANDLE, - "urQueueCreateWithNativeHandle", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_QUEUE_CREATE_WITH_NATIVE_HANDLE, + "urQueueCreateWithNativeHandle", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_QUEUE_CREATE_WITH_NATIVE_HANDLE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -3698,27 +3730,27 @@ __urdlllocal ur_result_t UR_APICALL urQueueCreateWithNativeHandle( __urdlllocal ur_result_t UR_APICALL urQueueFinish( ur_queue_handle_t hQueue ///< [in] handle of the queue to be finished. ) { - auto pfnFinish = context.urDdiTable.Queue.pfnFinish; + auto pfnFinish = getContext()->urDdiTable.Queue.pfnFinish; if (nullptr == pfnFinish) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_queue_finish_params_t params = {&hQueue}; - uint64_t instance = context.notify_begin(UR_FUNCTION_QUEUE_FINISH, - "urQueueFinish", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_QUEUE_FINISH, + "urQueueFinish", ¶ms); - context.logger.info("---> urQueueFinish"); + getContext()->logger.info("---> urQueueFinish"); ur_result_t result = pfnFinish(hQueue); - context.notify_end(UR_FUNCTION_QUEUE_FINISH, "urQueueFinish", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_QUEUE_FINISH, "urQueueFinish", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_QUEUE_FINISH, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -3728,26 +3760,26 @@ __urdlllocal ur_result_t UR_APICALL urQueueFinish( __urdlllocal ur_result_t UR_APICALL urQueueFlush( ur_queue_handle_t hQueue ///< [in] handle of the queue to be flushed. ) { - auto pfnFlush = context.urDdiTable.Queue.pfnFlush; + auto pfnFlush = getContext()->urDdiTable.Queue.pfnFlush; if (nullptr == pfnFlush) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_queue_flush_params_t params = {&hQueue}; - uint64_t instance = - context.notify_begin(UR_FUNCTION_QUEUE_FLUSH, "urQueueFlush", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_QUEUE_FLUSH, + "urQueueFlush", ¶ms); - context.logger.info("---> urQueueFlush"); + getContext()->logger.info("---> urQueueFlush"); ur_result_t result = pfnFlush(hQueue); - context.notify_end(UR_FUNCTION_QUEUE_FLUSH, "urQueueFlush", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_QUEUE_FLUSH, "urQueueFlush", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_QUEUE_FLUSH, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -3763,7 +3795,7 @@ __urdlllocal ur_result_t UR_APICALL urEventGetInfo( ///< property size_t *pPropSizeRet ///< [out][optional] bytes returned in event property ) { - auto pfnGetInfo = context.urDdiTable.Event.pfnGetInfo; + auto pfnGetInfo = getContext()->urDdiTable.Event.pfnGetInfo; if (nullptr == pfnGetInfo) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -3771,21 +3803,21 @@ __urdlllocal ur_result_t UR_APICALL urEventGetInfo( ur_event_get_info_params_t params = {&hEvent, &propName, &propSize, &pPropValue, &pPropSizeRet}; - uint64_t instance = context.notify_begin(UR_FUNCTION_EVENT_GET_INFO, - "urEventGetInfo", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_EVENT_GET_INFO, + "urEventGetInfo", ¶ms); - context.logger.info("---> urEventGetInfo"); + getContext()->logger.info("---> urEventGetInfo"); ur_result_t result = pfnGetInfo(hEvent, propName, propSize, pPropValue, pPropSizeRet); - context.notify_end(UR_FUNCTION_EVENT_GET_INFO, "urEventGetInfo", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_EVENT_GET_INFO, "urEventGetInfo", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_EVENT_GET_INFO, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -3804,7 +3836,8 @@ __urdlllocal ur_result_t UR_APICALL urEventGetProfilingInfo( pPropSizeRet ///< [out][optional] pointer to the actual size in bytes returned in ///< propValue ) { - auto pfnGetProfilingInfo = context.urDdiTable.Event.pfnGetProfilingInfo; + auto pfnGetProfilingInfo = + getContext()->urDdiTable.Event.pfnGetProfilingInfo; if (nullptr == pfnGetProfilingInfo) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -3813,21 +3846,22 @@ __urdlllocal ur_result_t UR_APICALL urEventGetProfilingInfo( ur_event_get_profiling_info_params_t params = { &hEvent, &propName, &propSize, &pPropValue, &pPropSizeRet}; uint64_t instance = - context.notify_begin(UR_FUNCTION_EVENT_GET_PROFILING_INFO, - "urEventGetProfilingInfo", ¶ms); + getContext()->notify_begin(UR_FUNCTION_EVENT_GET_PROFILING_INFO, + "urEventGetProfilingInfo", ¶ms); - context.logger.info("---> urEventGetProfilingInfo"); + getContext()->logger.info("---> urEventGetProfilingInfo"); ur_result_t result = pfnGetProfilingInfo(hEvent, propName, propSize, pPropValue, pPropSizeRet); - context.notify_end(UR_FUNCTION_EVENT_GET_PROFILING_INFO, - "urEventGetProfilingInfo", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_EVENT_GET_PROFILING_INFO, + "urEventGetProfilingInfo", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_EVENT_GET_PROFILING_INFO, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -3840,26 +3874,26 @@ __urdlllocal ur_result_t UR_APICALL urEventWait( phEventWaitList ///< [in][range(0, numEvents)] pointer to a list of events to wait for ///< completion ) { - auto pfnWait = context.urDdiTable.Event.pfnWait; + auto pfnWait = getContext()->urDdiTable.Event.pfnWait; if (nullptr == pfnWait) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_event_wait_params_t params = {&numEvents, &phEventWaitList}; - uint64_t instance = - context.notify_begin(UR_FUNCTION_EVENT_WAIT, "urEventWait", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_EVENT_WAIT, + "urEventWait", ¶ms); - context.logger.info("---> urEventWait"); + getContext()->logger.info("---> urEventWait"); ur_result_t result = pfnWait(numEvents, phEventWaitList); - context.notify_end(UR_FUNCTION_EVENT_WAIT, "urEventWait", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_EVENT_WAIT, "urEventWait", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_EVENT_WAIT, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -3869,27 +3903,27 @@ __urdlllocal ur_result_t UR_APICALL urEventWait( __urdlllocal ur_result_t UR_APICALL urEventRetain( ur_event_handle_t hEvent ///< [in] handle of the event object ) { - auto pfnRetain = context.urDdiTable.Event.pfnRetain; + auto pfnRetain = getContext()->urDdiTable.Event.pfnRetain; if (nullptr == pfnRetain) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_event_retain_params_t params = {&hEvent}; - uint64_t instance = context.notify_begin(UR_FUNCTION_EVENT_RETAIN, - "urEventRetain", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_EVENT_RETAIN, + "urEventRetain", ¶ms); - context.logger.info("---> urEventRetain"); + getContext()->logger.info("---> urEventRetain"); ur_result_t result = pfnRetain(hEvent); - context.notify_end(UR_FUNCTION_EVENT_RETAIN, "urEventRetain", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_EVENT_RETAIN, "urEventRetain", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_EVENT_RETAIN, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -3899,27 +3933,27 @@ __urdlllocal ur_result_t UR_APICALL urEventRetain( __urdlllocal ur_result_t UR_APICALL urEventRelease( ur_event_handle_t hEvent ///< [in][release] handle of the event object ) { - auto pfnRelease = context.urDdiTable.Event.pfnRelease; + auto pfnRelease = getContext()->urDdiTable.Event.pfnRelease; if (nullptr == pfnRelease) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_event_release_params_t params = {&hEvent}; - uint64_t instance = context.notify_begin(UR_FUNCTION_EVENT_RELEASE, - "urEventRelease", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_EVENT_RELEASE, + "urEventRelease", ¶ms); - context.logger.info("---> urEventRelease"); + getContext()->logger.info("---> urEventRelease"); ur_result_t result = pfnRelease(hEvent); - context.notify_end(UR_FUNCTION_EVENT_RELEASE, "urEventRelease", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_EVENT_RELEASE, "urEventRelease", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_EVENT_RELEASE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -3931,27 +3965,28 @@ __urdlllocal ur_result_t UR_APICALL urEventGetNativeHandle( ur_native_handle_t *phNativeEvent ///< [out] a pointer to the native handle of the event. ) { - auto pfnGetNativeHandle = context.urDdiTable.Event.pfnGetNativeHandle; + auto pfnGetNativeHandle = getContext()->urDdiTable.Event.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_event_get_native_handle_params_t params = {&hEvent, &phNativeEvent}; - uint64_t instance = context.notify_begin( + uint64_t instance = getContext()->notify_begin( UR_FUNCTION_EVENT_GET_NATIVE_HANDLE, "urEventGetNativeHandle", ¶ms); - context.logger.info("---> urEventGetNativeHandle"); + getContext()->logger.info("---> urEventGetNativeHandle"); ur_result_t result = pfnGetNativeHandle(hEvent, phNativeEvent); - context.notify_end(UR_FUNCTION_EVENT_GET_NATIVE_HANDLE, - "urEventGetNativeHandle", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_EVENT_GET_NATIVE_HANDLE, + "urEventGetNativeHandle", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_EVENT_GET_NATIVE_HANDLE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -3968,7 +4003,7 @@ __urdlllocal ur_result_t UR_APICALL urEventCreateWithNativeHandle( *phEvent ///< [out] pointer to the handle of the event object created. ) { auto pfnCreateWithNativeHandle = - context.urDdiTable.Event.pfnCreateWithNativeHandle; + getContext()->urDdiTable.Event.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -3977,22 +4012,22 @@ __urdlllocal ur_result_t UR_APICALL urEventCreateWithNativeHandle( ur_event_create_with_native_handle_params_t params = { &hNativeEvent, &hContext, &pProperties, &phEvent}; uint64_t instance = - context.notify_begin(UR_FUNCTION_EVENT_CREATE_WITH_NATIVE_HANDLE, - "urEventCreateWithNativeHandle", ¶ms); + getContext()->notify_begin(UR_FUNCTION_EVENT_CREATE_WITH_NATIVE_HANDLE, + "urEventCreateWithNativeHandle", ¶ms); - context.logger.info("---> urEventCreateWithNativeHandle"); + getContext()->logger.info("---> urEventCreateWithNativeHandle"); ur_result_t result = pfnCreateWithNativeHandle(hNativeEvent, hContext, pProperties, phEvent); - context.notify_end(UR_FUNCTION_EVENT_CREATE_WITH_NATIVE_HANDLE, - "urEventCreateWithNativeHandle", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_EVENT_CREATE_WITH_NATIVE_HANDLE, + "urEventCreateWithNativeHandle", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_EVENT_CREATE_WITH_NATIVE_HANDLE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -4006,7 +4041,7 @@ __urdlllocal ur_result_t UR_APICALL urEventSetCallback( void * pUserData ///< [in][out][optional] pointer to data to be passed to callback. ) { - auto pfnSetCallback = context.urDdiTable.Event.pfnSetCallback; + auto pfnSetCallback = getContext()->urDdiTable.Event.pfnSetCallback; if (nullptr == pfnSetCallback) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -4014,21 +4049,21 @@ __urdlllocal ur_result_t UR_APICALL urEventSetCallback( ur_event_set_callback_params_t params = {&hEvent, &execStatus, &pfnNotify, &pUserData}; - uint64_t instance = context.notify_begin(UR_FUNCTION_EVENT_SET_CALLBACK, - "urEventSetCallback", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_EVENT_SET_CALLBACK, "urEventSetCallback", ¶ms); - context.logger.info("---> urEventSetCallback"); + getContext()->logger.info("---> urEventSetCallback"); ur_result_t result = pfnSetCallback(hEvent, execStatus, pfnNotify, pUserData); - context.notify_end(UR_FUNCTION_EVENT_SET_CALLBACK, "urEventSetCallback", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_EVENT_SET_CALLBACK, + "urEventSetCallback", ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_EVENT_SET_CALLBACK, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -4064,7 +4099,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueKernelLaunch( phEvent ///< [out][optional] return an event object that identifies this particular ///< kernel execution instance. ) { - auto pfnKernelLaunch = context.urDdiTable.Enqueue.pfnKernelLaunch; + auto pfnKernelLaunch = getContext()->urDdiTable.Enqueue.pfnKernelLaunch; if (nullptr == pfnKernelLaunch) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -4079,22 +4114,23 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueKernelLaunch( &numEventsInWaitList, &phEventWaitList, &phEvent}; - uint64_t instance = context.notify_begin(UR_FUNCTION_ENQUEUE_KERNEL_LAUNCH, - "urEnqueueKernelLaunch", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_ENQUEUE_KERNEL_LAUNCH, "urEnqueueKernelLaunch", ¶ms); - context.logger.info("---> urEnqueueKernelLaunch"); + getContext()->logger.info("---> urEnqueueKernelLaunch"); ur_result_t result = pfnKernelLaunch( hQueue, hKernel, workDim, pGlobalWorkOffset, pGlobalWorkSize, pLocalWorkSize, numEventsInWaitList, phEventWaitList, phEvent); - context.notify_end(UR_FUNCTION_ENQUEUE_KERNEL_LAUNCH, - "urEnqueueKernelLaunch", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_ENQUEUE_KERNEL_LAUNCH, + "urEnqueueKernelLaunch", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_ENQUEUE_KERNEL_LAUNCH, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -4114,7 +4150,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueEventsWait( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnEventsWait = context.urDdiTable.Enqueue.pfnEventsWait; + auto pfnEventsWait = getContext()->urDdiTable.Enqueue.pfnEventsWait; if (nullptr == pfnEventsWait) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -4122,21 +4158,21 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueEventsWait( ur_enqueue_events_wait_params_t params = {&hQueue, &numEventsInWaitList, &phEventWaitList, &phEvent}; - uint64_t instance = context.notify_begin(UR_FUNCTION_ENQUEUE_EVENTS_WAIT, - "urEnqueueEventsWait", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_ENQUEUE_EVENTS_WAIT, "urEnqueueEventsWait", ¶ms); - context.logger.info("---> urEnqueueEventsWait"); + getContext()->logger.info("---> urEnqueueEventsWait"); ur_result_t result = pfnEventsWait(hQueue, numEventsInWaitList, phEventWaitList, phEvent); - context.notify_end(UR_FUNCTION_ENQUEUE_EVENTS_WAIT, "urEnqueueEventsWait", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_ENQUEUE_EVENTS_WAIT, + "urEnqueueEventsWait", ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_ENQUEUE_EVENTS_WAIT, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -4157,7 +4193,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueEventsWaitWithBarrier( ///< command instance. ) { auto pfnEventsWaitWithBarrier = - context.urDdiTable.Enqueue.pfnEventsWaitWithBarrier; + getContext()->urDdiTable.Enqueue.pfnEventsWaitWithBarrier; if (nullptr == pfnEventsWaitWithBarrier) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -4166,22 +4202,22 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueEventsWaitWithBarrier( ur_enqueue_events_wait_with_barrier_params_t params = { &hQueue, &numEventsInWaitList, &phEventWaitList, &phEvent}; uint64_t instance = - context.notify_begin(UR_FUNCTION_ENQUEUE_EVENTS_WAIT_WITH_BARRIER, - "urEnqueueEventsWaitWithBarrier", ¶ms); + getContext()->notify_begin(UR_FUNCTION_ENQUEUE_EVENTS_WAIT_WITH_BARRIER, + "urEnqueueEventsWaitWithBarrier", ¶ms); - context.logger.info("---> urEnqueueEventsWaitWithBarrier"); + getContext()->logger.info("---> urEnqueueEventsWaitWithBarrier"); ur_result_t result = pfnEventsWaitWithBarrier(hQueue, numEventsInWaitList, phEventWaitList, phEvent); - context.notify_end(UR_FUNCTION_ENQUEUE_EVENTS_WAIT_WITH_BARRIER, - "urEnqueueEventsWaitWithBarrier", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_ENQUEUE_EVENTS_WAIT_WITH_BARRIER, + "urEnqueueEventsWaitWithBarrier", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_EVENTS_WAIT_WITH_BARRIER, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -4206,7 +4242,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferRead( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnMemBufferRead = context.urDdiTable.Enqueue.pfnMemBufferRead; + auto pfnMemBufferRead = getContext()->urDdiTable.Enqueue.pfnMemBufferRead; if (nullptr == pfnMemBufferRead) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -4216,22 +4252,23 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferRead( &hQueue, &hBuffer, &blockingRead, &offset, &size, &pDst, &numEventsInWaitList, &phEventWaitList, &phEvent}; - uint64_t instance = context.notify_begin( + uint64_t instance = getContext()->notify_begin( UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ, "urEnqueueMemBufferRead", ¶ms); - context.logger.info("---> urEnqueueMemBufferRead"); + getContext()->logger.info("---> urEnqueueMemBufferRead"); ur_result_t result = pfnMemBufferRead(hQueue, hBuffer, blockingRead, offset, size, pDst, numEventsInWaitList, phEventWaitList, phEvent); - context.notify_end(UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ, - "urEnqueueMemBufferRead", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ, + "urEnqueueMemBufferRead", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -4258,7 +4295,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferWrite( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnMemBufferWrite = context.urDdiTable.Enqueue.pfnMemBufferWrite; + auto pfnMemBufferWrite = getContext()->urDdiTable.Enqueue.pfnMemBufferWrite; if (nullptr == pfnMemBufferWrite) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -4269,22 +4306,23 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferWrite( &size, &pSrc, &numEventsInWaitList, &phEventWaitList, &phEvent}; uint64_t instance = - context.notify_begin(UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE, - "urEnqueueMemBufferWrite", ¶ms); + getContext()->notify_begin(UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE, + "urEnqueueMemBufferWrite", ¶ms); - context.logger.info("---> urEnqueueMemBufferWrite"); + getContext()->logger.info("---> urEnqueueMemBufferWrite"); ur_result_t result = pfnMemBufferWrite(hQueue, hBuffer, blockingWrite, offset, size, pSrc, numEventsInWaitList, phEventWaitList, phEvent); - context.notify_end(UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE, - "urEnqueueMemBufferWrite", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE, + "urEnqueueMemBufferWrite", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -4321,7 +4359,8 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferReadRect( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnMemBufferReadRect = context.urDdiTable.Enqueue.pfnMemBufferReadRect; + auto pfnMemBufferReadRect = + getContext()->urDdiTable.Enqueue.pfnMemBufferReadRect; if (nullptr == pfnMemBufferReadRect) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -4342,24 +4381,24 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferReadRect( &phEventWaitList, &phEvent}; uint64_t instance = - context.notify_begin(UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ_RECT, - "urEnqueueMemBufferReadRect", ¶ms); + getContext()->notify_begin(UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ_RECT, + "urEnqueueMemBufferReadRect", ¶ms); - context.logger.info("---> urEnqueueMemBufferReadRect"); + getContext()->logger.info("---> urEnqueueMemBufferReadRect"); ur_result_t result = pfnMemBufferReadRect( hQueue, hBuffer, blockingRead, bufferOrigin, hostOrigin, region, bufferRowPitch, bufferSlicePitch, hostRowPitch, hostSlicePitch, pDst, numEventsInWaitList, phEventWaitList, phEvent); - context.notify_end(UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ_RECT, - "urEnqueueMemBufferReadRect", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ_RECT, + "urEnqueueMemBufferReadRect", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ_RECT, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -4400,7 +4439,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferWriteRect( ///< command instance. ) { auto pfnMemBufferWriteRect = - context.urDdiTable.Enqueue.pfnMemBufferWriteRect; + getContext()->urDdiTable.Enqueue.pfnMemBufferWriteRect; if (nullptr == pfnMemBufferWriteRect) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -4421,24 +4460,24 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferWriteRect( &phEventWaitList, &phEvent}; uint64_t instance = - context.notify_begin(UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE_RECT, - "urEnqueueMemBufferWriteRect", ¶ms); + getContext()->notify_begin(UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE_RECT, + "urEnqueueMemBufferWriteRect", ¶ms); - context.logger.info("---> urEnqueueMemBufferWriteRect"); + getContext()->logger.info("---> urEnqueueMemBufferWriteRect"); ur_result_t result = pfnMemBufferWriteRect( hQueue, hBuffer, blockingWrite, bufferOrigin, hostOrigin, region, bufferRowPitch, bufferSlicePitch, hostRowPitch, hostSlicePitch, pSrc, numEventsInWaitList, phEventWaitList, phEvent); - context.notify_end(UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE_RECT, - "urEnqueueMemBufferWriteRect", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE_RECT, + "urEnqueueMemBufferWriteRect", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE_RECT, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -4464,7 +4503,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferCopy( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnMemBufferCopy = context.urDdiTable.Enqueue.pfnMemBufferCopy; + auto pfnMemBufferCopy = getContext()->urDdiTable.Enqueue.pfnMemBufferCopy; if (nullptr == pfnMemBufferCopy) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -4473,22 +4512,23 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferCopy( ur_enqueue_mem_buffer_copy_params_t params = { &hQueue, &hBufferSrc, &hBufferDst, &srcOffset, &dstOffset, &size, &numEventsInWaitList, &phEventWaitList, &phEvent}; - uint64_t instance = context.notify_begin( + uint64_t instance = getContext()->notify_begin( UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY, "urEnqueueMemBufferCopy", ¶ms); - context.logger.info("---> urEnqueueMemBufferCopy"); + getContext()->logger.info("---> urEnqueueMemBufferCopy"); ur_result_t result = pfnMemBufferCopy(hQueue, hBufferSrc, hBufferDst, srcOffset, dstOffset, size, numEventsInWaitList, phEventWaitList, phEvent); - context.notify_end(UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY, - "urEnqueueMemBufferCopy", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY, + "urEnqueueMemBufferCopy", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -4523,7 +4563,8 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferCopyRect( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnMemBufferCopyRect = context.urDdiTable.Enqueue.pfnMemBufferCopyRect; + auto pfnMemBufferCopyRect = + getContext()->urDdiTable.Enqueue.pfnMemBufferCopyRect; if (nullptr == pfnMemBufferCopyRect) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -4535,24 +4576,24 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferCopyRect( &dstRowPitch, &dstSlicePitch, &numEventsInWaitList, &phEventWaitList, &phEvent}; uint64_t instance = - context.notify_begin(UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY_RECT, - "urEnqueueMemBufferCopyRect", ¶ms); + getContext()->notify_begin(UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY_RECT, + "urEnqueueMemBufferCopyRect", ¶ms); - context.logger.info("---> urEnqueueMemBufferCopyRect"); + getContext()->logger.info("---> urEnqueueMemBufferCopyRect"); ur_result_t result = pfnMemBufferCopyRect( hQueue, hBufferSrc, hBufferDst, srcOrigin, dstOrigin, region, srcRowPitch, srcSlicePitch, dstRowPitch, dstSlicePitch, numEventsInWaitList, phEventWaitList, phEvent); - context.notify_end(UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY_RECT, - "urEnqueueMemBufferCopyRect", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY_RECT, + "urEnqueueMemBufferCopyRect", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY_RECT, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -4577,7 +4618,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferFill( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnMemBufferFill = context.urDdiTable.Enqueue.pfnMemBufferFill; + auto pfnMemBufferFill = getContext()->urDdiTable.Enqueue.pfnMemBufferFill; if (nullptr == pfnMemBufferFill) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -4592,22 +4633,23 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferFill( &numEventsInWaitList, &phEventWaitList, &phEvent}; - uint64_t instance = context.notify_begin( + uint64_t instance = getContext()->notify_begin( UR_FUNCTION_ENQUEUE_MEM_BUFFER_FILL, "urEnqueueMemBufferFill", ¶ms); - context.logger.info("---> urEnqueueMemBufferFill"); + getContext()->logger.info("---> urEnqueueMemBufferFill"); ur_result_t result = pfnMemBufferFill(hQueue, hBuffer, pPattern, patternSize, offset, size, numEventsInWaitList, phEventWaitList, phEvent); - context.notify_end(UR_FUNCTION_ENQUEUE_MEM_BUFFER_FILL, - "urEnqueueMemBufferFill", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_ENQUEUE_MEM_BUFFER_FILL, + "urEnqueueMemBufferFill", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_MEM_BUFFER_FILL, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -4637,7 +4679,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemImageRead( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnMemImageRead = context.urDdiTable.Enqueue.pfnMemImageRead; + auto pfnMemImageRead = getContext()->urDdiTable.Enqueue.pfnMemImageRead; if (nullptr == pfnMemImageRead) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -4648,22 +4690,23 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemImageRead( &origin, ®ion, &rowPitch, &slicePitch, &pDst, &numEventsInWaitList, &phEventWaitList, &phEvent}; - uint64_t instance = context.notify_begin(UR_FUNCTION_ENQUEUE_MEM_IMAGE_READ, - "urEnqueueMemImageRead", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_ENQUEUE_MEM_IMAGE_READ, "urEnqueueMemImageRead", ¶ms); - context.logger.info("---> urEnqueueMemImageRead"); + getContext()->logger.info("---> urEnqueueMemImageRead"); ur_result_t result = pfnMemImageRead( hQueue, hImage, blockingRead, origin, region, rowPitch, slicePitch, pDst, numEventsInWaitList, phEventWaitList, phEvent); - context.notify_end(UR_FUNCTION_ENQUEUE_MEM_IMAGE_READ, - "urEnqueueMemImageRead", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_ENQUEUE_MEM_IMAGE_READ, + "urEnqueueMemImageRead", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_MEM_IMAGE_READ, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -4694,7 +4737,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemImageWrite( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnMemImageWrite = context.urDdiTable.Enqueue.pfnMemImageWrite; + auto pfnMemImageWrite = getContext()->urDdiTable.Enqueue.pfnMemImageWrite; if (nullptr == pfnMemImageWrite) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -4705,22 +4748,23 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemImageWrite( &origin, ®ion, &rowPitch, &slicePitch, &pSrc, &numEventsInWaitList, &phEventWaitList, &phEvent}; - uint64_t instance = context.notify_begin( + uint64_t instance = getContext()->notify_begin( UR_FUNCTION_ENQUEUE_MEM_IMAGE_WRITE, "urEnqueueMemImageWrite", ¶ms); - context.logger.info("---> urEnqueueMemImageWrite"); + getContext()->logger.info("---> urEnqueueMemImageWrite"); ur_result_t result = pfnMemImageWrite( hQueue, hImage, blockingWrite, origin, region, rowPitch, slicePitch, pSrc, numEventsInWaitList, phEventWaitList, phEvent); - context.notify_end(UR_FUNCTION_ENQUEUE_MEM_IMAGE_WRITE, - "urEnqueueMemImageWrite", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_ENQUEUE_MEM_IMAGE_WRITE, + "urEnqueueMemImageWrite", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_MEM_IMAGE_WRITE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -4752,7 +4796,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemImageCopy( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnMemImageCopy = context.urDdiTable.Enqueue.pfnMemImageCopy; + auto pfnMemImageCopy = getContext()->urDdiTable.Enqueue.pfnMemImageCopy; if (nullptr == pfnMemImageCopy) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -4761,22 +4805,23 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemImageCopy( ur_enqueue_mem_image_copy_params_t params = { &hQueue, &hImageSrc, &hImageDst, &srcOrigin, &dstOrigin, ®ion, &numEventsInWaitList, &phEventWaitList, &phEvent}; - uint64_t instance = context.notify_begin(UR_FUNCTION_ENQUEUE_MEM_IMAGE_COPY, - "urEnqueueMemImageCopy", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_ENQUEUE_MEM_IMAGE_COPY, "urEnqueueMemImageCopy", ¶ms); - context.logger.info("---> urEnqueueMemImageCopy"); + getContext()->logger.info("---> urEnqueueMemImageCopy"); ur_result_t result = pfnMemImageCopy(hQueue, hImageSrc, hImageDst, srcOrigin, dstOrigin, region, numEventsInWaitList, phEventWaitList, phEvent); - context.notify_end(UR_FUNCTION_ENQUEUE_MEM_IMAGE_COPY, - "urEnqueueMemImageCopy", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_ENQUEUE_MEM_IMAGE_COPY, + "urEnqueueMemImageCopy", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_MEM_IMAGE_COPY, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -4803,7 +4848,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferMap( void **ppRetMap ///< [out] return mapped pointer. TODO: move it before ///< numEventsInWaitList? ) { - auto pfnMemBufferMap = context.urDdiTable.Enqueue.pfnMemBufferMap; + auto pfnMemBufferMap = getContext()->urDdiTable.Enqueue.pfnMemBufferMap; if (nullptr == pfnMemBufferMap) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -4813,22 +4858,23 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferMap( &hQueue, &hBuffer, &blockingMap, &mapFlags, &offset, &size, &numEventsInWaitList, &phEventWaitList, &phEvent, &ppRetMap}; - uint64_t instance = context.notify_begin(UR_FUNCTION_ENQUEUE_MEM_BUFFER_MAP, - "urEnqueueMemBufferMap", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_ENQUEUE_MEM_BUFFER_MAP, "urEnqueueMemBufferMap", ¶ms); - context.logger.info("---> urEnqueueMemBufferMap"); + getContext()->logger.info("---> urEnqueueMemBufferMap"); ur_result_t result = pfnMemBufferMap(hQueue, hBuffer, blockingMap, mapFlags, offset, size, numEventsInWaitList, phEventWaitList, phEvent, ppRetMap); - context.notify_end(UR_FUNCTION_ENQUEUE_MEM_BUFFER_MAP, - "urEnqueueMemBufferMap", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_ENQUEUE_MEM_BUFFER_MAP, + "urEnqueueMemBufferMap", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_MEM_BUFFER_MAP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -4850,7 +4896,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemUnmap( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnMemUnmap = context.urDdiTable.Enqueue.pfnMemUnmap; + auto pfnMemUnmap = getContext()->urDdiTable.Enqueue.pfnMemUnmap; if (nullptr == pfnMemUnmap) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -4859,22 +4905,22 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemUnmap( ur_enqueue_mem_unmap_params_t params = { &hQueue, &hMem, &pMappedPtr, &numEventsInWaitList, &phEventWaitList, &phEvent}; - uint64_t instance = context.notify_begin(UR_FUNCTION_ENQUEUE_MEM_UNMAP, - "urEnqueueMemUnmap", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_ENQUEUE_MEM_UNMAP, "urEnqueueMemUnmap", ¶ms); - context.logger.info("---> urEnqueueMemUnmap"); + getContext()->logger.info("---> urEnqueueMemUnmap"); ur_result_t result = pfnMemUnmap(hQueue, hMem, pMappedPtr, numEventsInWaitList, phEventWaitList, phEvent); - context.notify_end(UR_FUNCTION_ENQUEUE_MEM_UNMAP, "urEnqueueMemUnmap", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_ENQUEUE_MEM_UNMAP, "urEnqueueMemUnmap", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_ENQUEUE_MEM_UNMAP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -4901,7 +4947,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMFill( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnUSMFill = context.urDdiTable.Enqueue.pfnUSMFill; + auto pfnUSMFill = getContext()->urDdiTable.Enqueue.pfnUSMFill; if (nullptr == pfnUSMFill) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -4911,22 +4957,22 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMFill( &hQueue, &pMem, &patternSize, &pPattern, &size, &numEventsInWaitList, &phEventWaitList, &phEvent}; - uint64_t instance = context.notify_begin(UR_FUNCTION_ENQUEUE_USM_FILL, - "urEnqueueUSMFill", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_ENQUEUE_USM_FILL, + "urEnqueueUSMFill", ¶ms); - context.logger.info("---> urEnqueueUSMFill"); + getContext()->logger.info("---> urEnqueueUSMFill"); ur_result_t result = pfnUSMFill(hQueue, pMem, patternSize, pPattern, size, numEventsInWaitList, phEventWaitList, phEvent); - context.notify_end(UR_FUNCTION_ENQUEUE_USM_FILL, "urEnqueueUSMFill", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_ENQUEUE_USM_FILL, "urEnqueueUSMFill", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_ENQUEUE_USM_FILL, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -4951,7 +4997,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMMemcpy( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnUSMMemcpy = context.urDdiTable.Enqueue.pfnUSMMemcpy; + auto pfnUSMMemcpy = getContext()->urDdiTable.Enqueue.pfnUSMMemcpy; if (nullptr == pfnUSMMemcpy) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -4960,22 +5006,22 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMMemcpy( ur_enqueue_usm_memcpy_params_t params = { &hQueue, &blocking, &pDst, &pSrc, &size, &numEventsInWaitList, &phEventWaitList, &phEvent}; - uint64_t instance = context.notify_begin(UR_FUNCTION_ENQUEUE_USM_MEMCPY, - "urEnqueueUSMMemcpy", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_ENQUEUE_USM_MEMCPY, "urEnqueueUSMMemcpy", ¶ms); - context.logger.info("---> urEnqueueUSMMemcpy"); + getContext()->logger.info("---> urEnqueueUSMMemcpy"); ur_result_t result = pfnUSMMemcpy(hQueue, blocking, pDst, pSrc, size, numEventsInWaitList, phEventWaitList, phEvent); - context.notify_end(UR_FUNCTION_ENQUEUE_USM_MEMCPY, "urEnqueueUSMMemcpy", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_ENQUEUE_USM_MEMCPY, + "urEnqueueUSMMemcpy", ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_ENQUEUE_USM_MEMCPY, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -4998,7 +5044,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMPrefetch( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnUSMPrefetch = context.urDdiTable.Enqueue.pfnUSMPrefetch; + auto pfnUSMPrefetch = getContext()->urDdiTable.Enqueue.pfnUSMPrefetch; if (nullptr == pfnUSMPrefetch) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -5007,22 +5053,23 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMPrefetch( ur_enqueue_usm_prefetch_params_t params = { &hQueue, &pMem, &size, &flags, &numEventsInWaitList, &phEventWaitList, &phEvent}; - uint64_t instance = context.notify_begin(UR_FUNCTION_ENQUEUE_USM_PREFETCH, - "urEnqueueUSMPrefetch", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_ENQUEUE_USM_PREFETCH, "urEnqueueUSMPrefetch", ¶ms); - context.logger.info("---> urEnqueueUSMPrefetch"); + getContext()->logger.info("---> urEnqueueUSMPrefetch"); ur_result_t result = pfnUSMPrefetch(hQueue, pMem, size, flags, numEventsInWaitList, phEventWaitList, phEvent); - context.notify_end(UR_FUNCTION_ENQUEUE_USM_PREFETCH, "urEnqueueUSMPrefetch", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_ENQUEUE_USM_PREFETCH, + "urEnqueueUSMPrefetch", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_ENQUEUE_USM_PREFETCH, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -5039,7 +5086,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMAdvise( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnUSMAdvise = context.urDdiTable.Enqueue.pfnUSMAdvise; + auto pfnUSMAdvise = getContext()->urDdiTable.Enqueue.pfnUSMAdvise; if (nullptr == pfnUSMAdvise) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -5047,20 +5094,20 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMAdvise( ur_enqueue_usm_advise_params_t params = {&hQueue, &pMem, &size, &advice, &phEvent}; - uint64_t instance = context.notify_begin(UR_FUNCTION_ENQUEUE_USM_ADVISE, - "urEnqueueUSMAdvise", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_ENQUEUE_USM_ADVISE, "urEnqueueUSMAdvise", ¶ms); - context.logger.info("---> urEnqueueUSMAdvise"); + getContext()->logger.info("---> urEnqueueUSMAdvise"); ur_result_t result = pfnUSMAdvise(hQueue, pMem, size, advice, phEvent); - context.notify_end(UR_FUNCTION_ENQUEUE_USM_ADVISE, "urEnqueueUSMAdvise", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_ENQUEUE_USM_ADVISE, + "urEnqueueUSMAdvise", ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_ENQUEUE_USM_ADVISE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -5092,7 +5139,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMFill2D( phEvent ///< [out][optional] return an event object that identifies this particular ///< kernel execution instance. ) { - auto pfnUSMFill2D = context.urDdiTable.Enqueue.pfnUSMFill2D; + auto pfnUSMFill2D = getContext()->urDdiTable.Enqueue.pfnUSMFill2D; if (nullptr == pfnUSMFill2D) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -5102,22 +5149,22 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMFill2D( &hQueue, &pMem, &pitch, &patternSize, &pPattern, &width, &height, &numEventsInWaitList, &phEventWaitList, &phEvent}; - uint64_t instance = context.notify_begin(UR_FUNCTION_ENQUEUE_USM_FILL_2D, - "urEnqueueUSMFill2D", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_ENQUEUE_USM_FILL_2D, "urEnqueueUSMFill2D", ¶ms); - context.logger.info("---> urEnqueueUSMFill2D"); + getContext()->logger.info("---> urEnqueueUSMFill2D"); ur_result_t result = pfnUSMFill2D(hQueue, pMem, pitch, patternSize, pPattern, width, height, numEventsInWaitList, phEventWaitList, phEvent); - context.notify_end(UR_FUNCTION_ENQUEUE_USM_FILL_2D, "urEnqueueUSMFill2D", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_ENQUEUE_USM_FILL_2D, + "urEnqueueUSMFill2D", ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_ENQUEUE_USM_FILL_2D, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -5148,7 +5195,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMMemcpy2D( phEvent ///< [out][optional] return an event object that identifies this particular ///< kernel execution instance. ) { - auto pfnUSMMemcpy2D = context.urDdiTable.Enqueue.pfnUSMMemcpy2D; + auto pfnUSMMemcpy2D = getContext()->urDdiTable.Enqueue.pfnUSMMemcpy2D; if (nullptr == pfnUSMMemcpy2D) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -5159,22 +5206,23 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMMemcpy2D( &dstPitch, &pSrc, &srcPitch, &width, &height, &numEventsInWaitList, &phEventWaitList, &phEvent}; - uint64_t instance = context.notify_begin(UR_FUNCTION_ENQUEUE_USM_MEMCPY_2D, - "urEnqueueUSMMemcpy2D", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_ENQUEUE_USM_MEMCPY_2D, "urEnqueueUSMMemcpy2D", ¶ms); - context.logger.info("---> urEnqueueUSMMemcpy2D"); + getContext()->logger.info("---> urEnqueueUSMMemcpy2D"); ur_result_t result = pfnUSMMemcpy2D(hQueue, blocking, pDst, dstPitch, pSrc, srcPitch, width, height, numEventsInWaitList, phEventWaitList, phEvent); - context.notify_end(UR_FUNCTION_ENQUEUE_USM_MEMCPY_2D, - "urEnqueueUSMMemcpy2D", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_ENQUEUE_USM_MEMCPY_2D, + "urEnqueueUSMMemcpy2D", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_ENQUEUE_USM_MEMCPY_2D, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -5203,7 +5251,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueDeviceGlobalVariableWrite( ///< kernel execution instance. ) { auto pfnDeviceGlobalVariableWrite = - context.urDdiTable.Enqueue.pfnDeviceGlobalVariableWrite; + getContext()->urDdiTable.Enqueue.pfnDeviceGlobalVariableWrite; if (nullptr == pfnDeviceGlobalVariableWrite) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -5213,24 +5261,24 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueDeviceGlobalVariableWrite( &hQueue, &hProgram, &name, &blockingWrite, &count, &offset, &pSrc, &numEventsInWaitList, &phEventWaitList, &phEvent}; - uint64_t instance = - context.notify_begin(UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_WRITE, - "urEnqueueDeviceGlobalVariableWrite", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_WRITE, + "urEnqueueDeviceGlobalVariableWrite", ¶ms); - context.logger.info("---> urEnqueueDeviceGlobalVariableWrite"); + getContext()->logger.info("---> urEnqueueDeviceGlobalVariableWrite"); ur_result_t result = pfnDeviceGlobalVariableWrite( hQueue, hProgram, name, blockingWrite, count, offset, pSrc, numEventsInWaitList, phEventWaitList, phEvent); - context.notify_end(UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_WRITE, - "urEnqueueDeviceGlobalVariableWrite", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_WRITE, + "urEnqueueDeviceGlobalVariableWrite", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_WRITE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -5259,7 +5307,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueDeviceGlobalVariableRead( ///< kernel execution instance. ) { auto pfnDeviceGlobalVariableRead = - context.urDdiTable.Enqueue.pfnDeviceGlobalVariableRead; + getContext()->urDdiTable.Enqueue.pfnDeviceGlobalVariableRead; if (nullptr == pfnDeviceGlobalVariableRead) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -5269,24 +5317,24 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueDeviceGlobalVariableRead( &hQueue, &hProgram, &name, &blockingRead, &count, &offset, &pDst, &numEventsInWaitList, &phEventWaitList, &phEvent}; - uint64_t instance = - context.notify_begin(UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_READ, - "urEnqueueDeviceGlobalVariableRead", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_READ, + "urEnqueueDeviceGlobalVariableRead", ¶ms); - context.logger.info("---> urEnqueueDeviceGlobalVariableRead"); + getContext()->logger.info("---> urEnqueueDeviceGlobalVariableRead"); ur_result_t result = pfnDeviceGlobalVariableRead( hQueue, hProgram, name, blockingRead, count, offset, pDst, numEventsInWaitList, phEventWaitList, phEvent); - context.notify_end(UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_READ, - "urEnqueueDeviceGlobalVariableRead", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_READ, + "urEnqueueDeviceGlobalVariableRead", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_READ, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -5318,7 +5366,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueReadHostPipe( ///< command ///< and can be used to query or queue a wait for this command to complete. ) { - auto pfnReadHostPipe = context.urDdiTable.Enqueue.pfnReadHostPipe; + auto pfnReadHostPipe = getContext()->urDdiTable.Enqueue.pfnReadHostPipe; if (nullptr == pfnReadHostPipe) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -5328,22 +5376,23 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueReadHostPipe( &hQueue, &hProgram, &pipe_symbol, &blocking, &pDst, &size, &numEventsInWaitList, &phEventWaitList, &phEvent}; - uint64_t instance = context.notify_begin(UR_FUNCTION_ENQUEUE_READ_HOST_PIPE, - "urEnqueueReadHostPipe", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_ENQUEUE_READ_HOST_PIPE, "urEnqueueReadHostPipe", ¶ms); - context.logger.info("---> urEnqueueReadHostPipe"); + getContext()->logger.info("---> urEnqueueReadHostPipe"); ur_result_t result = pfnReadHostPipe(hQueue, hProgram, pipe_symbol, blocking, pDst, size, numEventsInWaitList, phEventWaitList, phEvent); - context.notify_end(UR_FUNCTION_ENQUEUE_READ_HOST_PIPE, - "urEnqueueReadHostPipe", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_ENQUEUE_READ_HOST_PIPE, + "urEnqueueReadHostPipe", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_READ_HOST_PIPE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -5375,7 +5424,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueWriteHostPipe( phEvent ///< [out][optional] returns an event object that identifies this write command ///< and can be used to query or queue a wait for this command to complete. ) { - auto pfnWriteHostPipe = context.urDdiTable.Enqueue.pfnWriteHostPipe; + auto pfnWriteHostPipe = getContext()->urDdiTable.Enqueue.pfnWriteHostPipe; if (nullptr == pfnWriteHostPipe) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -5385,22 +5434,23 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueWriteHostPipe( &hQueue, &hProgram, &pipe_symbol, &blocking, &pSrc, &size, &numEventsInWaitList, &phEventWaitList, &phEvent}; - uint64_t instance = context.notify_begin( + uint64_t instance = getContext()->notify_begin( UR_FUNCTION_ENQUEUE_WRITE_HOST_PIPE, "urEnqueueWriteHostPipe", ¶ms); - context.logger.info("---> urEnqueueWriteHostPipe"); + getContext()->logger.info("---> urEnqueueWriteHostPipe"); ur_result_t result = pfnWriteHostPipe(hQueue, hProgram, pipe_symbol, blocking, pSrc, size, numEventsInWaitList, phEventWaitList, phEvent); - context.notify_end(UR_FUNCTION_ENQUEUE_WRITE_HOST_PIPE, - "urEnqueueWriteHostPipe", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_ENQUEUE_WRITE_HOST_PIPE, + "urEnqueueWriteHostPipe", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_WRITE_HOST_PIPE, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -5422,7 +5472,8 @@ __urdlllocal ur_result_t UR_APICALL urUSMPitchedAllocExp( void **ppMem, ///< [out] pointer to USM shared memory object size_t *pResultPitch ///< [out] pitch of the allocation ) { - auto pfnPitchedAllocExp = context.urDdiTable.USMExp.pfnPitchedAllocExp; + auto pfnPitchedAllocExp = + getContext()->urDdiTable.USMExp.pfnPitchedAllocExp; if (nullptr == pfnPitchedAllocExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -5431,22 +5482,23 @@ __urdlllocal ur_result_t UR_APICALL urUSMPitchedAllocExp( ur_usm_pitched_alloc_exp_params_t params = { &hContext, &hDevice, &pUSMDesc, &pool, &widthInBytes, &height, &elementSizeBytes, &ppMem, &pResultPitch}; - uint64_t instance = context.notify_begin(UR_FUNCTION_USM_PITCHED_ALLOC_EXP, - "urUSMPitchedAllocExp", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_USM_PITCHED_ALLOC_EXP, "urUSMPitchedAllocExp", ¶ms); - context.logger.info("---> urUSMPitchedAllocExp"); + getContext()->logger.info("---> urUSMPitchedAllocExp"); ur_result_t result = pfnPitchedAllocExp(hContext, hDevice, pUSMDesc, pool, widthInBytes, height, elementSizeBytes, ppMem, pResultPitch); - context.notify_end(UR_FUNCTION_USM_PITCHED_ALLOC_EXP, - "urUSMPitchedAllocExp", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_USM_PITCHED_ALLOC_EXP, + "urUSMPitchedAllocExp", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_USM_PITCHED_ALLOC_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -5461,7 +5513,8 @@ urBindlessImagesUnsampledImageHandleDestroyExp( hImage ///< [in][release] pointer to handle of image object to destroy ) { auto pfnUnsampledImageHandleDestroyExp = - context.urDdiTable.BindlessImagesExp.pfnUnsampledImageHandleDestroyExp; + getContext() + ->urDdiTable.BindlessImagesExp.pfnUnsampledImageHandleDestroyExp; if (nullptr == pfnUnsampledImageHandleDestroyExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -5469,16 +5522,17 @@ urBindlessImagesUnsampledImageHandleDestroyExp( ur_bindless_images_unsampled_image_handle_destroy_exp_params_t params = { &hContext, &hDevice, &hImage}; - uint64_t instance = context.notify_begin( + uint64_t instance = getContext()->notify_begin( UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_HANDLE_DESTROY_EXP, "urBindlessImagesUnsampledImageHandleDestroyExp", ¶ms); - context.logger.info("---> urBindlessImagesUnsampledImageHandleDestroyExp"); + getContext()->logger.info( + "---> urBindlessImagesUnsampledImageHandleDestroyExp"); ur_result_t result = pfnUnsampledImageHandleDestroyExp(hContext, hDevice, hImage); - context.notify_end( + getContext()->notify_end( UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_HANDLE_DESTROY_EXP, "urBindlessImagesUnsampledImageHandleDestroyExp", ¶ms, &result, instance); @@ -5488,7 +5542,7 @@ urBindlessImagesUnsampledImageHandleDestroyExp( args_str, UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_HANDLE_DESTROY_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -5503,7 +5557,8 @@ urBindlessImagesSampledImageHandleDestroyExp( hImage ///< [in][release] pointer to handle of image object to destroy ) { auto pfnSampledImageHandleDestroyExp = - context.urDdiTable.BindlessImagesExp.pfnSampledImageHandleDestroyExp; + getContext() + ->urDdiTable.BindlessImagesExp.pfnSampledImageHandleDestroyExp; if (nullptr == pfnSampledImageHandleDestroyExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -5511,16 +5566,17 @@ urBindlessImagesSampledImageHandleDestroyExp( ur_bindless_images_sampled_image_handle_destroy_exp_params_t params = { &hContext, &hDevice, &hImage}; - uint64_t instance = context.notify_begin( + uint64_t instance = getContext()->notify_begin( UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_HANDLE_DESTROY_EXP, "urBindlessImagesSampledImageHandleDestroyExp", ¶ms); - context.logger.info("---> urBindlessImagesSampledImageHandleDestroyExp"); + getContext()->logger.info( + "---> urBindlessImagesSampledImageHandleDestroyExp"); ur_result_t result = pfnSampledImageHandleDestroyExp(hContext, hDevice, hImage); - context.notify_end( + getContext()->notify_end( UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_HANDLE_DESTROY_EXP, "urBindlessImagesSampledImageHandleDestroyExp", ¶ms, &result, instance); @@ -5529,7 +5585,7 @@ urBindlessImagesSampledImageHandleDestroyExp( ur::extras::printFunctionParams( args_str, UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_HANDLE_DESTROY_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -5546,7 +5602,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( *phImageMem ///< [out] pointer to handle of image memory allocated ) { auto pfnImageAllocateExp = - context.urDdiTable.BindlessImagesExp.pfnImageAllocateExp; + getContext()->urDdiTable.BindlessImagesExp.pfnImageAllocateExp; if (nullptr == pfnImageAllocateExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -5554,23 +5610,23 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( ur_bindless_images_image_allocate_exp_params_t params = { &hContext, &hDevice, &pImageFormat, &pImageDesc, &phImageMem}; - uint64_t instance = - context.notify_begin(UR_FUNCTION_BINDLESS_IMAGES_IMAGE_ALLOCATE_EXP, - "urBindlessImagesImageAllocateExp", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_BINDLESS_IMAGES_IMAGE_ALLOCATE_EXP, + "urBindlessImagesImageAllocateExp", ¶ms); - context.logger.info("---> urBindlessImagesImageAllocateExp"); + getContext()->logger.info("---> urBindlessImagesImageAllocateExp"); ur_result_t result = pfnImageAllocateExp(hContext, hDevice, pImageFormat, pImageDesc, phImageMem); - context.notify_end(UR_FUNCTION_BINDLESS_IMAGES_IMAGE_ALLOCATE_EXP, - "urBindlessImagesImageAllocateExp", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_BINDLESS_IMAGES_IMAGE_ALLOCATE_EXP, + "urBindlessImagesImageAllocateExp", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_BINDLESS_IMAGES_IMAGE_ALLOCATE_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -5583,7 +5639,8 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageFreeExp( ur_exp_image_mem_handle_t hImageMem ///< [in][release] handle of image memory to be freed ) { - auto pfnImageFreeExp = context.urDdiTable.BindlessImagesExp.pfnImageFreeExp; + auto pfnImageFreeExp = + getContext()->urDdiTable.BindlessImagesExp.pfnImageFreeExp; if (nullptr == pfnImageFreeExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -5592,21 +5649,21 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageFreeExp( ur_bindless_images_image_free_exp_params_t params = {&hContext, &hDevice, &hImageMem}; uint64_t instance = - context.notify_begin(UR_FUNCTION_BINDLESS_IMAGES_IMAGE_FREE_EXP, - "urBindlessImagesImageFreeExp", ¶ms); + getContext()->notify_begin(UR_FUNCTION_BINDLESS_IMAGES_IMAGE_FREE_EXP, + "urBindlessImagesImageFreeExp", ¶ms); - context.logger.info("---> urBindlessImagesImageFreeExp"); + getContext()->logger.info("---> urBindlessImagesImageFreeExp"); ur_result_t result = pfnImageFreeExp(hContext, hDevice, hImageMem); - context.notify_end(UR_FUNCTION_BINDLESS_IMAGES_IMAGE_FREE_EXP, - "urBindlessImagesImageFreeExp", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_BINDLESS_IMAGES_IMAGE_FREE_EXP, + "urBindlessImagesImageFreeExp", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_BINDLESS_IMAGES_IMAGE_FREE_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -5625,7 +5682,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( *phImage ///< [out] pointer to handle of image object created ) { auto pfnUnsampledImageCreateExp = - context.urDdiTable.BindlessImagesExp.pfnUnsampledImageCreateExp; + getContext()->urDdiTable.BindlessImagesExp.pfnUnsampledImageCreateExp; if (nullptr == pfnUnsampledImageCreateExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -5633,24 +5690,24 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( ur_bindless_images_unsampled_image_create_exp_params_t params = { &hContext, &hDevice, &hImageMem, &pImageFormat, &pImageDesc, &phImage}; - uint64_t instance = context.notify_begin( + uint64_t instance = getContext()->notify_begin( UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_CREATE_EXP, "urBindlessImagesUnsampledImageCreateExp", ¶ms); - context.logger.info("---> urBindlessImagesUnsampledImageCreateExp"); + getContext()->logger.info("---> urBindlessImagesUnsampledImageCreateExp"); ur_result_t result = pfnUnsampledImageCreateExp( hContext, hDevice, hImageMem, pImageFormat, pImageDesc, phImage); - context.notify_end(UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_CREATE_EXP, - "urBindlessImagesUnsampledImageCreateExp", ¶ms, - &result, instance); + getContext()->notify_end( + UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_CREATE_EXP, + "urBindlessImagesUnsampledImageCreateExp", ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_CREATE_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -5670,7 +5727,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( *phImage ///< [out] pointer to handle of image object created ) { auto pfnSampledImageCreateExp = - context.urDdiTable.BindlessImagesExp.pfnSampledImageCreateExp; + getContext()->urDdiTable.BindlessImagesExp.pfnSampledImageCreateExp; if (nullptr == pfnSampledImageCreateExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -5679,25 +5736,25 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( ur_bindless_images_sampled_image_create_exp_params_t params = { &hContext, &hDevice, &hImageMem, &pImageFormat, &pImageDesc, &hSampler, &phImage}; - uint64_t instance = context.notify_begin( + uint64_t instance = getContext()->notify_begin( UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_CREATE_EXP, "urBindlessImagesSampledImageCreateExp", ¶ms); - context.logger.info("---> urBindlessImagesSampledImageCreateExp"); + getContext()->logger.info("---> urBindlessImagesSampledImageCreateExp"); ur_result_t result = pfnSampledImageCreateExp(hContext, hDevice, hImageMem, pImageFormat, pImageDesc, hSampler, phImage); - context.notify_end(UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_CREATE_EXP, - "urBindlessImagesSampledImageCreateExp", ¶ms, - &result, instance); + getContext()->notify_end( + UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_CREATE_EXP, + "urBindlessImagesSampledImageCreateExp", ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_CREATE_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -5736,7 +5793,8 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnImageCopyExp = context.urDdiTable.BindlessImagesExp.pfnImageCopyExp; + auto pfnImageCopyExp = + getContext()->urDdiTable.BindlessImagesExp.pfnImageCopyExp; if (nullptr == pfnImageCopyExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -5756,24 +5814,24 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp( &phEventWaitList, &phEvent}; uint64_t instance = - context.notify_begin(UR_FUNCTION_BINDLESS_IMAGES_IMAGE_COPY_EXP, - "urBindlessImagesImageCopyExp", ¶ms); + getContext()->notify_begin(UR_FUNCTION_BINDLESS_IMAGES_IMAGE_COPY_EXP, + "urBindlessImagesImageCopyExp", ¶ms); - context.logger.info("---> urBindlessImagesImageCopyExp"); + getContext()->logger.info("---> urBindlessImagesImageCopyExp"); ur_result_t result = pfnImageCopyExp( hQueue, pDst, pSrc, pImageFormat, pImageDesc, imageCopyFlags, srcOffset, dstOffset, copyExtent, hostExtent, numEventsInWaitList, phEventWaitList, phEvent); - context.notify_end(UR_FUNCTION_BINDLESS_IMAGES_IMAGE_COPY_EXP, - "urBindlessImagesImageCopyExp", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_BINDLESS_IMAGES_IMAGE_COPY_EXP, + "urBindlessImagesImageCopyExp", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_BINDLESS_IMAGES_IMAGE_COPY_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -5787,7 +5845,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( size_t *pPropSizeRet ///< [out][optional] returned query value size ) { auto pfnImageGetInfoExp = - context.urDdiTable.BindlessImagesExp.pfnImageGetInfoExp; + getContext()->urDdiTable.BindlessImagesExp.pfnImageGetInfoExp; if (nullptr == pfnImageGetInfoExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -5795,23 +5853,23 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( ur_bindless_images_image_get_info_exp_params_t params = { &hImageMem, &propName, &pPropValue, &pPropSizeRet}; - uint64_t instance = - context.notify_begin(UR_FUNCTION_BINDLESS_IMAGES_IMAGE_GET_INFO_EXP, - "urBindlessImagesImageGetInfoExp", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_BINDLESS_IMAGES_IMAGE_GET_INFO_EXP, + "urBindlessImagesImageGetInfoExp", ¶ms); - context.logger.info("---> urBindlessImagesImageGetInfoExp"); + getContext()->logger.info("---> urBindlessImagesImageGetInfoExp"); ur_result_t result = pfnImageGetInfoExp(hImageMem, propName, pPropValue, pPropSizeRet); - context.notify_end(UR_FUNCTION_BINDLESS_IMAGES_IMAGE_GET_INFO_EXP, - "urBindlessImagesImageGetInfoExp", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_BINDLESS_IMAGES_IMAGE_GET_INFO_EXP, + "urBindlessImagesImageGetInfoExp", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_BINDLESS_IMAGES_IMAGE_GET_INFO_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -5828,7 +5886,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( *phImageMem ///< [out] returning memory handle to the individual image ) { auto pfnMipmapGetLevelExp = - context.urDdiTable.BindlessImagesExp.pfnMipmapGetLevelExp; + getContext()->urDdiTable.BindlessImagesExp.pfnMipmapGetLevelExp; if (nullptr == pfnMipmapGetLevelExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -5836,23 +5894,23 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( ur_bindless_images_mipmap_get_level_exp_params_t params = { &hContext, &hDevice, &hImageMem, &mipmapLevel, &phImageMem}; - uint64_t instance = - context.notify_begin(UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_GET_LEVEL_EXP, - "urBindlessImagesMipmapGetLevelExp", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_GET_LEVEL_EXP, + "urBindlessImagesMipmapGetLevelExp", ¶ms); - context.logger.info("---> urBindlessImagesMipmapGetLevelExp"); + getContext()->logger.info("---> urBindlessImagesMipmapGetLevelExp"); ur_result_t result = pfnMipmapGetLevelExp(hContext, hDevice, hImageMem, mipmapLevel, phImageMem); - context.notify_end(UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_GET_LEVEL_EXP, - "urBindlessImagesMipmapGetLevelExp", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_GET_LEVEL_EXP, + "urBindlessImagesMipmapGetLevelExp", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_GET_LEVEL_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -5866,7 +5924,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( hMem ///< [in][release] handle of image memory to be freed ) { auto pfnMipmapFreeExp = - context.urDdiTable.BindlessImagesExp.pfnMipmapFreeExp; + getContext()->urDdiTable.BindlessImagesExp.pfnMipmapFreeExp; if (nullptr == pfnMipmapFreeExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -5875,21 +5933,21 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( ur_bindless_images_mipmap_free_exp_params_t params = {&hContext, &hDevice, &hMem}; uint64_t instance = - context.notify_begin(UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_FREE_EXP, - "urBindlessImagesMipmapFreeExp", ¶ms); + getContext()->notify_begin(UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_FREE_EXP, + "urBindlessImagesMipmapFreeExp", ¶ms); - context.logger.info("---> urBindlessImagesMipmapFreeExp"); + getContext()->logger.info("---> urBindlessImagesMipmapFreeExp"); ur_result_t result = pfnMipmapFreeExp(hContext, hDevice, hMem); - context.notify_end(UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_FREE_EXP, - "urBindlessImagesMipmapFreeExp", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_FREE_EXP, + "urBindlessImagesMipmapFreeExp", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_FREE_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -5908,7 +5966,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportExternalMemoryExp( *phInteropMem ///< [out] interop memory handle to the external memory ) { auto pfnImportExternalMemoryExp = - context.urDdiTable.BindlessImagesExp.pfnImportExternalMemoryExp; + getContext()->urDdiTable.BindlessImagesExp.pfnImportExternalMemoryExp; if (nullptr == pfnImportExternalMemoryExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -5917,24 +5975,24 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportExternalMemoryExp( ur_bindless_images_import_external_memory_exp_params_t params = { &hContext, &hDevice, &size, &memHandleType, &pInteropMemDesc, &phInteropMem}; - uint64_t instance = context.notify_begin( + uint64_t instance = getContext()->notify_begin( UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_MEMORY_EXP, "urBindlessImagesImportExternalMemoryExp", ¶ms); - context.logger.info("---> urBindlessImagesImportExternalMemoryExp"); + getContext()->logger.info("---> urBindlessImagesImportExternalMemoryExp"); ur_result_t result = pfnImportExternalMemoryExp( hContext, hDevice, size, memHandleType, pInteropMemDesc, phInteropMem); - context.notify_end(UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_MEMORY_EXP, - "urBindlessImagesImportExternalMemoryExp", ¶ms, - &result, instance); + getContext()->notify_end( + UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_MEMORY_EXP, + "urBindlessImagesImportExternalMemoryExp", ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_MEMORY_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -5953,7 +6011,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( phImageMem ///< [out] image memory handle to the externally allocated memory ) { auto pfnMapExternalArrayExp = - context.urDdiTable.BindlessImagesExp.pfnMapExternalArrayExp; + getContext()->urDdiTable.BindlessImagesExp.pfnMapExternalArrayExp; if (nullptr == pfnMapExternalArrayExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -5962,23 +6020,23 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( ur_bindless_images_map_external_array_exp_params_t params = { &hContext, &hDevice, &pImageFormat, &pImageDesc, &hInteropMem, &phImageMem}; - uint64_t instance = - context.notify_begin(UR_FUNCTION_BINDLESS_IMAGES_MAP_EXTERNAL_ARRAY_EXP, - "urBindlessImagesMapExternalArrayExp", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_BINDLESS_IMAGES_MAP_EXTERNAL_ARRAY_EXP, + "urBindlessImagesMapExternalArrayExp", ¶ms); - context.logger.info("---> urBindlessImagesMapExternalArrayExp"); + getContext()->logger.info("---> urBindlessImagesMapExternalArrayExp"); ur_result_t result = pfnMapExternalArrayExp( hContext, hDevice, pImageFormat, pImageDesc, hInteropMem, phImageMem); - context.notify_end(UR_FUNCTION_BINDLESS_IMAGES_MAP_EXTERNAL_ARRAY_EXP, - "urBindlessImagesMapExternalArrayExp", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_BINDLESS_IMAGES_MAP_EXTERNAL_ARRAY_EXP, + "urBindlessImagesMapExternalArrayExp", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_BINDLESS_IMAGES_MAP_EXTERNAL_ARRAY_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -5992,7 +6050,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( hInteropMem ///< [in][release] handle of interop memory to be freed ) { auto pfnReleaseInteropExp = - context.urDdiTable.BindlessImagesExp.pfnReleaseInteropExp; + getContext()->urDdiTable.BindlessImagesExp.pfnReleaseInteropExp; if (nullptr == pfnReleaseInteropExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -6000,22 +6058,22 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( ur_bindless_images_release_interop_exp_params_t params = { &hContext, &hDevice, &hInteropMem}; - uint64_t instance = - context.notify_begin(UR_FUNCTION_BINDLESS_IMAGES_RELEASE_INTEROP_EXP, - "urBindlessImagesReleaseInteropExp", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_BINDLESS_IMAGES_RELEASE_INTEROP_EXP, + "urBindlessImagesReleaseInteropExp", ¶ms); - context.logger.info("---> urBindlessImagesReleaseInteropExp"); + getContext()->logger.info("---> urBindlessImagesReleaseInteropExp"); ur_result_t result = pfnReleaseInteropExp(hContext, hDevice, hInteropMem); - context.notify_end(UR_FUNCTION_BINDLESS_IMAGES_RELEASE_INTEROP_EXP, - "urBindlessImagesReleaseInteropExp", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_BINDLESS_IMAGES_RELEASE_INTEROP_EXP, + "urBindlessImagesReleaseInteropExp", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_BINDLESS_IMAGES_RELEASE_INTEROP_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -6033,7 +6091,8 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreExp( phInteropSemaphore ///< [out] interop semaphore handle to the external semaphore ) { auto pfnImportExternalSemaphoreExp = - context.urDdiTable.BindlessImagesExp.pfnImportExternalSemaphoreExp; + getContext() + ->urDdiTable.BindlessImagesExp.pfnImportExternalSemaphoreExp; if (nullptr == pfnImportExternalSemaphoreExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -6042,17 +6101,18 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreExp( ur_bindless_images_import_external_semaphore_exp_params_t params = { &hContext, &hDevice, &semHandleType, &pInteropSemaphoreDesc, &phInteropSemaphore}; - uint64_t instance = context.notify_begin( + uint64_t instance = getContext()->notify_begin( UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_SEMAPHORE_EXP, "urBindlessImagesImportExternalSemaphoreExp", ¶ms); - context.logger.info("---> urBindlessImagesImportExternalSemaphoreExp"); + getContext()->logger.info( + "---> urBindlessImagesImportExternalSemaphoreExp"); ur_result_t result = pfnImportExternalSemaphoreExp( hContext, hDevice, semHandleType, pInteropSemaphoreDesc, phInteropSemaphore); - context.notify_end( + getContext()->notify_end( UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_SEMAPHORE_EXP, "urBindlessImagesImportExternalSemaphoreExp", ¶ms, &result, instance); @@ -6061,7 +6121,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreExp( ur::extras::printFunctionParams( args_str, UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_SEMAPHORE_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -6075,7 +6135,8 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( hInteropSemaphore ///< [in][release] handle of interop semaphore to be destroyed ) { auto pfnDestroyExternalSemaphoreExp = - context.urDdiTable.BindlessImagesExp.pfnDestroyExternalSemaphoreExp; + getContext() + ->urDdiTable.BindlessImagesExp.pfnDestroyExternalSemaphoreExp; if (nullptr == pfnDestroyExternalSemaphoreExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -6083,16 +6144,17 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( ur_bindless_images_destroy_external_semaphore_exp_params_t params = { &hContext, &hDevice, &hInteropSemaphore}; - uint64_t instance = context.notify_begin( + uint64_t instance = getContext()->notify_begin( UR_FUNCTION_BINDLESS_IMAGES_DESTROY_EXTERNAL_SEMAPHORE_EXP, "urBindlessImagesDestroyExternalSemaphoreExp", ¶ms); - context.logger.info("---> urBindlessImagesDestroyExternalSemaphoreExp"); + getContext()->logger.info( + "---> urBindlessImagesDestroyExternalSemaphoreExp"); ur_result_t result = pfnDestroyExternalSemaphoreExp(hContext, hDevice, hInteropSemaphore); - context.notify_end( + getContext()->notify_end( UR_FUNCTION_BINDLESS_IMAGES_DESTROY_EXTERNAL_SEMAPHORE_EXP, "urBindlessImagesDestroyExternalSemaphoreExp", ¶ms, &result, instance); @@ -6101,7 +6163,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( ur::extras::printFunctionParams( args_str, UR_FUNCTION_BINDLESS_IMAGES_DESTROY_EXTERNAL_SEMAPHORE_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -6130,7 +6192,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesWaitExternalSemaphoreExp( ///< command instance. ) { auto pfnWaitExternalSemaphoreExp = - context.urDdiTable.BindlessImagesExp.pfnWaitExternalSemaphoreExp; + getContext()->urDdiTable.BindlessImagesExp.pfnWaitExternalSemaphoreExp; if (nullptr == pfnWaitExternalSemaphoreExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -6140,25 +6202,25 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesWaitExternalSemaphoreExp( &hQueue, &hSemaphore, &hasWaitValue, &waitValue, &numEventsInWaitList, &phEventWaitList, &phEvent}; - uint64_t instance = context.notify_begin( + uint64_t instance = getContext()->notify_begin( UR_FUNCTION_BINDLESS_IMAGES_WAIT_EXTERNAL_SEMAPHORE_EXP, "urBindlessImagesWaitExternalSemaphoreExp", ¶ms); - context.logger.info("---> urBindlessImagesWaitExternalSemaphoreExp"); + getContext()->logger.info("---> urBindlessImagesWaitExternalSemaphoreExp"); ur_result_t result = pfnWaitExternalSemaphoreExp( hQueue, hSemaphore, hasWaitValue, waitValue, numEventsInWaitList, phEventWaitList, phEvent); - context.notify_end(UR_FUNCTION_BINDLESS_IMAGES_WAIT_EXTERNAL_SEMAPHORE_EXP, - "urBindlessImagesWaitExternalSemaphoreExp", ¶ms, - &result, instance); + getContext()->notify_end( + UR_FUNCTION_BINDLESS_IMAGES_WAIT_EXTERNAL_SEMAPHORE_EXP, + "urBindlessImagesWaitExternalSemaphoreExp", ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_BINDLESS_IMAGES_WAIT_EXTERNAL_SEMAPHORE_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -6187,7 +6249,8 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSignalExternalSemaphoreExp( ///< command instance. ) { auto pfnSignalExternalSemaphoreExp = - context.urDdiTable.BindlessImagesExp.pfnSignalExternalSemaphoreExp; + getContext() + ->urDdiTable.BindlessImagesExp.pfnSignalExternalSemaphoreExp; if (nullptr == pfnSignalExternalSemaphoreExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -6197,17 +6260,18 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSignalExternalSemaphoreExp( &hQueue, &hSemaphore, &hasSignalValue, &signalValue, &numEventsInWaitList, &phEventWaitList, &phEvent}; - uint64_t instance = context.notify_begin( + uint64_t instance = getContext()->notify_begin( UR_FUNCTION_BINDLESS_IMAGES_SIGNAL_EXTERNAL_SEMAPHORE_EXP, "urBindlessImagesSignalExternalSemaphoreExp", ¶ms); - context.logger.info("---> urBindlessImagesSignalExternalSemaphoreExp"); + getContext()->logger.info( + "---> urBindlessImagesSignalExternalSemaphoreExp"); ur_result_t result = pfnSignalExternalSemaphoreExp( hQueue, hSemaphore, hasSignalValue, signalValue, numEventsInWaitList, phEventWaitList, phEvent); - context.notify_end( + getContext()->notify_end( UR_FUNCTION_BINDLESS_IMAGES_SIGNAL_EXTERNAL_SEMAPHORE_EXP, "urBindlessImagesSignalExternalSemaphoreExp", ¶ms, &result, instance); @@ -6216,7 +6280,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSignalExternalSemaphoreExp( ur::extras::printFunctionParams( args_str, UR_FUNCTION_BINDLESS_IMAGES_SIGNAL_EXTERNAL_SEMAPHORE_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -6231,7 +6295,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferCreateExp( ur_exp_command_buffer_handle_t *phCommandBuffer ///< [out] Pointer to command-Buffer handle. ) { - auto pfnCreateExp = context.urDdiTable.CommandBufferExp.pfnCreateExp; + auto pfnCreateExp = getContext()->urDdiTable.CommandBufferExp.pfnCreateExp; if (nullptr == pfnCreateExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -6240,21 +6304,22 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferCreateExp( ur_command_buffer_create_exp_params_t params = { &hContext, &hDevice, &pCommandBufferDesc, &phCommandBuffer}; uint64_t instance = - context.notify_begin(UR_FUNCTION_COMMAND_BUFFER_CREATE_EXP, - "urCommandBufferCreateExp", ¶ms); + getContext()->notify_begin(UR_FUNCTION_COMMAND_BUFFER_CREATE_EXP, + "urCommandBufferCreateExp", ¶ms); - context.logger.info("---> urCommandBufferCreateExp"); + getContext()->logger.info("---> urCommandBufferCreateExp"); ur_result_t result = pfnCreateExp(hContext, hDevice, pCommandBufferDesc, phCommandBuffer); - context.notify_end(UR_FUNCTION_COMMAND_BUFFER_CREATE_EXP, - "urCommandBufferCreateExp", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_COMMAND_BUFFER_CREATE_EXP, + "urCommandBufferCreateExp", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_CREATE_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -6265,7 +6330,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferRetainExp( ur_exp_command_buffer_handle_t hCommandBuffer ///< [in] Handle of the command-buffer object. ) { - auto pfnRetainExp = context.urDdiTable.CommandBufferExp.pfnRetainExp; + auto pfnRetainExp = getContext()->urDdiTable.CommandBufferExp.pfnRetainExp; if (nullptr == pfnRetainExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -6273,20 +6338,21 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferRetainExp( ur_command_buffer_retain_exp_params_t params = {&hCommandBuffer}; uint64_t instance = - context.notify_begin(UR_FUNCTION_COMMAND_BUFFER_RETAIN_EXP, - "urCommandBufferRetainExp", ¶ms); + getContext()->notify_begin(UR_FUNCTION_COMMAND_BUFFER_RETAIN_EXP, + "urCommandBufferRetainExp", ¶ms); - context.logger.info("---> urCommandBufferRetainExp"); + getContext()->logger.info("---> urCommandBufferRetainExp"); ur_result_t result = pfnRetainExp(hCommandBuffer); - context.notify_end(UR_FUNCTION_COMMAND_BUFFER_RETAIN_EXP, - "urCommandBufferRetainExp", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_COMMAND_BUFFER_RETAIN_EXP, + "urCommandBufferRetainExp", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_RETAIN_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -6297,7 +6363,8 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferReleaseExp( ur_exp_command_buffer_handle_t hCommandBuffer ///< [in][release] Handle of the command-buffer object. ) { - auto pfnReleaseExp = context.urDdiTable.CommandBufferExp.pfnReleaseExp; + auto pfnReleaseExp = + getContext()->urDdiTable.CommandBufferExp.pfnReleaseExp; if (nullptr == pfnReleaseExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -6305,20 +6372,21 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferReleaseExp( ur_command_buffer_release_exp_params_t params = {&hCommandBuffer}; uint64_t instance = - context.notify_begin(UR_FUNCTION_COMMAND_BUFFER_RELEASE_EXP, - "urCommandBufferReleaseExp", ¶ms); + getContext()->notify_begin(UR_FUNCTION_COMMAND_BUFFER_RELEASE_EXP, + "urCommandBufferReleaseExp", ¶ms); - context.logger.info("---> urCommandBufferReleaseExp"); + getContext()->logger.info("---> urCommandBufferReleaseExp"); ur_result_t result = pfnReleaseExp(hCommandBuffer); - context.notify_end(UR_FUNCTION_COMMAND_BUFFER_RELEASE_EXP, - "urCommandBufferReleaseExp", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_COMMAND_BUFFER_RELEASE_EXP, + "urCommandBufferReleaseExp", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_RELEASE_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -6329,7 +6397,8 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferFinalizeExp( ur_exp_command_buffer_handle_t hCommandBuffer ///< [in] Handle of the command-buffer object. ) { - auto pfnFinalizeExp = context.urDdiTable.CommandBufferExp.pfnFinalizeExp; + auto pfnFinalizeExp = + getContext()->urDdiTable.CommandBufferExp.pfnFinalizeExp; if (nullptr == pfnFinalizeExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -6337,21 +6406,21 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferFinalizeExp( ur_command_buffer_finalize_exp_params_t params = {&hCommandBuffer}; uint64_t instance = - context.notify_begin(UR_FUNCTION_COMMAND_BUFFER_FINALIZE_EXP, - "urCommandBufferFinalizeExp", ¶ms); + getContext()->notify_begin(UR_FUNCTION_COMMAND_BUFFER_FINALIZE_EXP, + "urCommandBufferFinalizeExp", ¶ms); - context.logger.info("---> urCommandBufferFinalizeExp"); + getContext()->logger.info("---> urCommandBufferFinalizeExp"); ur_result_t result = pfnFinalizeExp(hCommandBuffer); - context.notify_end(UR_FUNCTION_COMMAND_BUFFER_FINALIZE_EXP, - "urCommandBufferFinalizeExp", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_COMMAND_BUFFER_FINALIZE_EXP, + "urCommandBufferFinalizeExp", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_FINALIZE_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -6380,7 +6449,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendKernelLaunchExp( *phCommand ///< [out][optional] Handle to this command. ) { auto pfnAppendKernelLaunchExp = - context.urDdiTable.CommandBufferExp.pfnAppendKernelLaunchExp; + getContext()->urDdiTable.CommandBufferExp.pfnAppendKernelLaunchExp; if (nullptr == pfnAppendKernelLaunchExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -6397,25 +6466,25 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendKernelLaunchExp( &pSyncPointWaitList, &pSyncPoint, &phCommand}; - uint64_t instance = context.notify_begin( + uint64_t instance = getContext()->notify_begin( UR_FUNCTION_COMMAND_BUFFER_APPEND_KERNEL_LAUNCH_EXP, "urCommandBufferAppendKernelLaunchExp", ¶ms); - context.logger.info("---> urCommandBufferAppendKernelLaunchExp"); + getContext()->logger.info("---> urCommandBufferAppendKernelLaunchExp"); ur_result_t result = pfnAppendKernelLaunchExp( hCommandBuffer, hKernel, workDim, pGlobalWorkOffset, pGlobalWorkSize, pLocalWorkSize, numSyncPointsInWaitList, pSyncPointWaitList, pSyncPoint, phCommand); - context.notify_end(UR_FUNCTION_COMMAND_BUFFER_APPEND_KERNEL_LAUNCH_EXP, - "urCommandBufferAppendKernelLaunchExp", ¶ms, &result, - instance); + getContext()->notify_end( + UR_FUNCTION_COMMAND_BUFFER_APPEND_KERNEL_LAUNCH_EXP, + "urCommandBufferAppendKernelLaunchExp", ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_APPEND_KERNEL_LAUNCH_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -6437,7 +6506,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendUSMMemcpyExp( pSyncPoint ///< [out][optional] Sync point associated with this command. ) { auto pfnAppendUSMMemcpyExp = - context.urDdiTable.CommandBufferExp.pfnAppendUSMMemcpyExp; + getContext()->urDdiTable.CommandBufferExp.pfnAppendUSMMemcpyExp; if (nullptr == pfnAppendUSMMemcpyExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -6446,24 +6515,24 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendUSMMemcpyExp( ur_command_buffer_append_usm_memcpy_exp_params_t params = { &hCommandBuffer, &pDst, &pSrc, &size, &numSyncPointsInWaitList, &pSyncPointWaitList, &pSyncPoint}; - uint64_t instance = - context.notify_begin(UR_FUNCTION_COMMAND_BUFFER_APPEND_USM_MEMCPY_EXP, - "urCommandBufferAppendUSMMemcpyExp", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_COMMAND_BUFFER_APPEND_USM_MEMCPY_EXP, + "urCommandBufferAppendUSMMemcpyExp", ¶ms); - context.logger.info("---> urCommandBufferAppendUSMMemcpyExp"); + getContext()->logger.info("---> urCommandBufferAppendUSMMemcpyExp"); ur_result_t result = pfnAppendUSMMemcpyExp(hCommandBuffer, pDst, pSrc, size, numSyncPointsInWaitList, pSyncPointWaitList, pSyncPoint); - context.notify_end(UR_FUNCTION_COMMAND_BUFFER_APPEND_USM_MEMCPY_EXP, - "urCommandBufferAppendUSMMemcpyExp", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_COMMAND_BUFFER_APPEND_USM_MEMCPY_EXP, + "urCommandBufferAppendUSMMemcpyExp", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_APPEND_USM_MEMCPY_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -6487,7 +6556,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendUSMFillExp( pSyncPoint ///< [out][optional] sync point associated with this command. ) { auto pfnAppendUSMFillExp = - context.urDdiTable.CommandBufferExp.pfnAppendUSMFillExp; + getContext()->urDdiTable.CommandBufferExp.pfnAppendUSMFillExp; if (nullptr == pfnAppendUSMFillExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -6497,24 +6566,24 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendUSMFillExp( &hCommandBuffer, &pMemory, &pPattern, &patternSize, &size, &numSyncPointsInWaitList, &pSyncPointWaitList, &pSyncPoint}; - uint64_t instance = - context.notify_begin(UR_FUNCTION_COMMAND_BUFFER_APPEND_USM_FILL_EXP, - "urCommandBufferAppendUSMFillExp", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_COMMAND_BUFFER_APPEND_USM_FILL_EXP, + "urCommandBufferAppendUSMFillExp", ¶ms); - context.logger.info("---> urCommandBufferAppendUSMFillExp"); + getContext()->logger.info("---> urCommandBufferAppendUSMFillExp"); ur_result_t result = pfnAppendUSMFillExp( hCommandBuffer, pMemory, pPattern, patternSize, size, numSyncPointsInWaitList, pSyncPointWaitList, pSyncPoint); - context.notify_end(UR_FUNCTION_COMMAND_BUFFER_APPEND_USM_FILL_EXP, - "urCommandBufferAppendUSMFillExp", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_COMMAND_BUFFER_APPEND_USM_FILL_EXP, + "urCommandBufferAppendUSMFillExp", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_APPEND_USM_FILL_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -6538,7 +6607,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferCopyExp( pSyncPoint ///< [out][optional] Sync point associated with this command. ) { auto pfnAppendMemBufferCopyExp = - context.urDdiTable.CommandBufferExp.pfnAppendMemBufferCopyExp; + getContext()->urDdiTable.CommandBufferExp.pfnAppendMemBufferCopyExp; if (nullptr == pfnAppendMemBufferCopyExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -6554,25 +6623,25 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferCopyExp( &numSyncPointsInWaitList, &pSyncPointWaitList, &pSyncPoint}; - uint64_t instance = context.notify_begin( + uint64_t instance = getContext()->notify_begin( UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_COPY_EXP, "urCommandBufferAppendMemBufferCopyExp", ¶ms); - context.logger.info("---> urCommandBufferAppendMemBufferCopyExp"); + getContext()->logger.info("---> urCommandBufferAppendMemBufferCopyExp"); ur_result_t result = pfnAppendMemBufferCopyExp( hCommandBuffer, hSrcMem, hDstMem, srcOffset, dstOffset, size, numSyncPointsInWaitList, pSyncPointWaitList, pSyncPoint); - context.notify_end(UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_COPY_EXP, - "urCommandBufferAppendMemBufferCopyExp", ¶ms, - &result, instance); + getContext()->notify_end( + UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_COPY_EXP, + "urCommandBufferAppendMemBufferCopyExp", ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_COPY_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -6596,7 +6665,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferWriteExp( pSyncPoint ///< [out][optional] Sync point associated with this command. ) { auto pfnAppendMemBufferWriteExp = - context.urDdiTable.CommandBufferExp.pfnAppendMemBufferWriteExp; + getContext()->urDdiTable.CommandBufferExp.pfnAppendMemBufferWriteExp; if (nullptr == pfnAppendMemBufferWriteExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -6611,25 +6680,25 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferWriteExp( &numSyncPointsInWaitList, &pSyncPointWaitList, &pSyncPoint}; - uint64_t instance = context.notify_begin( + uint64_t instance = getContext()->notify_begin( UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_WRITE_EXP, "urCommandBufferAppendMemBufferWriteExp", ¶ms); - context.logger.info("---> urCommandBufferAppendMemBufferWriteExp"); + getContext()->logger.info("---> urCommandBufferAppendMemBufferWriteExp"); ur_result_t result = pfnAppendMemBufferWriteExp( hCommandBuffer, hBuffer, offset, size, pSrc, numSyncPointsInWaitList, pSyncPointWaitList, pSyncPoint); - context.notify_end(UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_WRITE_EXP, - "urCommandBufferAppendMemBufferWriteExp", ¶ms, - &result, instance); + getContext()->notify_end( + UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_WRITE_EXP, + "urCommandBufferAppendMemBufferWriteExp", ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_WRITE_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -6652,7 +6721,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferReadExp( pSyncPoint ///< [out][optional] Sync point associated with this command. ) { auto pfnAppendMemBufferReadExp = - context.urDdiTable.CommandBufferExp.pfnAppendMemBufferReadExp; + getContext()->urDdiTable.CommandBufferExp.pfnAppendMemBufferReadExp; if (nullptr == pfnAppendMemBufferReadExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -6667,25 +6736,25 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferReadExp( &numSyncPointsInWaitList, &pSyncPointWaitList, &pSyncPoint}; - uint64_t instance = context.notify_begin( + uint64_t instance = getContext()->notify_begin( UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_READ_EXP, "urCommandBufferAppendMemBufferReadExp", ¶ms); - context.logger.info("---> urCommandBufferAppendMemBufferReadExp"); + getContext()->logger.info("---> urCommandBufferAppendMemBufferReadExp"); ur_result_t result = pfnAppendMemBufferReadExp( hCommandBuffer, hBuffer, offset, size, pDst, numSyncPointsInWaitList, pSyncPointWaitList, pSyncPoint); - context.notify_end(UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_READ_EXP, - "urCommandBufferAppendMemBufferReadExp", ¶ms, - &result, instance); + getContext()->notify_end( + UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_READ_EXP, + "urCommandBufferAppendMemBufferReadExp", ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_READ_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -6716,7 +6785,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferCopyRectExp( pSyncPoint ///< [out][optional] Sync point associated with this command. ) { auto pfnAppendMemBufferCopyRectExp = - context.urDdiTable.CommandBufferExp.pfnAppendMemBufferCopyRectExp; + getContext()->urDdiTable.CommandBufferExp.pfnAppendMemBufferCopyRectExp; if (nullptr == pfnAppendMemBufferCopyRectExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -6736,18 +6805,18 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferCopyRectExp( &numSyncPointsInWaitList, &pSyncPointWaitList, &pSyncPoint}; - uint64_t instance = context.notify_begin( + uint64_t instance = getContext()->notify_begin( UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_COPY_RECT_EXP, "urCommandBufferAppendMemBufferCopyRectExp", ¶ms); - context.logger.info("---> urCommandBufferAppendMemBufferCopyRectExp"); + getContext()->logger.info("---> urCommandBufferAppendMemBufferCopyRectExp"); ur_result_t result = pfnAppendMemBufferCopyRectExp( hCommandBuffer, hSrcMem, hDstMem, srcOrigin, dstOrigin, region, srcRowPitch, srcSlicePitch, dstRowPitch, dstSlicePitch, numSyncPointsInWaitList, pSyncPointWaitList, pSyncPoint); - context.notify_end( + getContext()->notify_end( UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_COPY_RECT_EXP, "urCommandBufferAppendMemBufferCopyRectExp", ¶ms, &result, instance); @@ -6756,7 +6825,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferCopyRectExp( ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_COPY_RECT_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -6793,7 +6862,8 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferWriteRectExp( pSyncPoint ///< [out][optional] Sync point associated with this command. ) { auto pfnAppendMemBufferWriteRectExp = - context.urDdiTable.CommandBufferExp.pfnAppendMemBufferWriteRectExp; + getContext() + ->urDdiTable.CommandBufferExp.pfnAppendMemBufferWriteRectExp; if (nullptr == pfnAppendMemBufferWriteRectExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -6813,18 +6883,19 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferWriteRectExp( &numSyncPointsInWaitList, &pSyncPointWaitList, &pSyncPoint}; - uint64_t instance = context.notify_begin( + uint64_t instance = getContext()->notify_begin( UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_WRITE_RECT_EXP, "urCommandBufferAppendMemBufferWriteRectExp", ¶ms); - context.logger.info("---> urCommandBufferAppendMemBufferWriteRectExp"); + getContext()->logger.info( + "---> urCommandBufferAppendMemBufferWriteRectExp"); ur_result_t result = pfnAppendMemBufferWriteRectExp( hCommandBuffer, hBuffer, bufferOffset, hostOffset, region, bufferRowPitch, bufferSlicePitch, hostRowPitch, hostSlicePitch, pSrc, numSyncPointsInWaitList, pSyncPointWaitList, pSyncPoint); - context.notify_end( + getContext()->notify_end( UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_WRITE_RECT_EXP, "urCommandBufferAppendMemBufferWriteRectExp", ¶ms, &result, instance); @@ -6833,7 +6904,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferWriteRectExp( ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_WRITE_RECT_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -6868,7 +6939,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferReadRectExp( pSyncPoint ///< [out][optional] Sync point associated with this command. ) { auto pfnAppendMemBufferReadRectExp = - context.urDdiTable.CommandBufferExp.pfnAppendMemBufferReadRectExp; + getContext()->urDdiTable.CommandBufferExp.pfnAppendMemBufferReadRectExp; if (nullptr == pfnAppendMemBufferReadRectExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -6888,18 +6959,18 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferReadRectExp( &numSyncPointsInWaitList, &pSyncPointWaitList, &pSyncPoint}; - uint64_t instance = context.notify_begin( + uint64_t instance = getContext()->notify_begin( UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_READ_RECT_EXP, "urCommandBufferAppendMemBufferReadRectExp", ¶ms); - context.logger.info("---> urCommandBufferAppendMemBufferReadRectExp"); + getContext()->logger.info("---> urCommandBufferAppendMemBufferReadRectExp"); ur_result_t result = pfnAppendMemBufferReadRectExp( hCommandBuffer, hBuffer, bufferOffset, hostOffset, region, bufferRowPitch, bufferSlicePitch, hostRowPitch, hostSlicePitch, pDst, numSyncPointsInWaitList, pSyncPointWaitList, pSyncPoint); - context.notify_end( + getContext()->notify_end( UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_READ_RECT_EXP, "urCommandBufferAppendMemBufferReadRectExp", ¶ms, &result, instance); @@ -6908,7 +6979,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferReadRectExp( ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_READ_RECT_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -6933,7 +7004,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferFillExp( pSyncPoint ///< [out][optional] sync point associated with this command. ) { auto pfnAppendMemBufferFillExp = - context.urDdiTable.CommandBufferExp.pfnAppendMemBufferFillExp; + getContext()->urDdiTable.CommandBufferExp.pfnAppendMemBufferFillExp; if (nullptr == pfnAppendMemBufferFillExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -6949,25 +7020,25 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferFillExp( &numSyncPointsInWaitList, &pSyncPointWaitList, &pSyncPoint}; - uint64_t instance = context.notify_begin( + uint64_t instance = getContext()->notify_begin( UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_FILL_EXP, "urCommandBufferAppendMemBufferFillExp", ¶ms); - context.logger.info("---> urCommandBufferAppendMemBufferFillExp"); + getContext()->logger.info("---> urCommandBufferAppendMemBufferFillExp"); ur_result_t result = pfnAppendMemBufferFillExp( hCommandBuffer, hBuffer, pPattern, patternSize, offset, size, numSyncPointsInWaitList, pSyncPointWaitList, pSyncPoint); - context.notify_end(UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_FILL_EXP, - "urCommandBufferAppendMemBufferFillExp", ¶ms, - &result, instance); + getContext()->notify_end( + UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_FILL_EXP, + "urCommandBufferAppendMemBufferFillExp", ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_FILL_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -6989,7 +7060,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendUSMPrefetchExp( pSyncPoint ///< [out][optional] sync point associated with this command. ) { auto pfnAppendUSMPrefetchExp = - context.urDdiTable.CommandBufferExp.pfnAppendUSMPrefetchExp; + getContext()->urDdiTable.CommandBufferExp.pfnAppendUSMPrefetchExp; if (nullptr == pfnAppendUSMPrefetchExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -7003,24 +7074,24 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendUSMPrefetchExp( &numSyncPointsInWaitList, &pSyncPointWaitList, &pSyncPoint}; - uint64_t instance = - context.notify_begin(UR_FUNCTION_COMMAND_BUFFER_APPEND_USM_PREFETCH_EXP, - "urCommandBufferAppendUSMPrefetchExp", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_COMMAND_BUFFER_APPEND_USM_PREFETCH_EXP, + "urCommandBufferAppendUSMPrefetchExp", ¶ms); - context.logger.info("---> urCommandBufferAppendUSMPrefetchExp"); + getContext()->logger.info("---> urCommandBufferAppendUSMPrefetchExp"); ur_result_t result = pfnAppendUSMPrefetchExp( hCommandBuffer, pMemory, size, flags, numSyncPointsInWaitList, pSyncPointWaitList, pSyncPoint); - context.notify_end(UR_FUNCTION_COMMAND_BUFFER_APPEND_USM_PREFETCH_EXP, - "urCommandBufferAppendUSMPrefetchExp", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_COMMAND_BUFFER_APPEND_USM_PREFETCH_EXP, + "urCommandBufferAppendUSMPrefetchExp", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_APPEND_USM_PREFETCH_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -7042,7 +7113,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendUSMAdviseExp( pSyncPoint ///< [out][optional] sync point associated with this command. ) { auto pfnAppendUSMAdviseExp = - context.urDdiTable.CommandBufferExp.pfnAppendUSMAdviseExp; + getContext()->urDdiTable.CommandBufferExp.pfnAppendUSMAdviseExp; if (nullptr == pfnAppendUSMAdviseExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -7056,24 +7127,24 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendUSMAdviseExp( &numSyncPointsInWaitList, &pSyncPointWaitList, &pSyncPoint}; - uint64_t instance = - context.notify_begin(UR_FUNCTION_COMMAND_BUFFER_APPEND_USM_ADVISE_EXP, - "urCommandBufferAppendUSMAdviseExp", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_COMMAND_BUFFER_APPEND_USM_ADVISE_EXP, + "urCommandBufferAppendUSMAdviseExp", ¶ms); - context.logger.info("---> urCommandBufferAppendUSMAdviseExp"); + getContext()->logger.info("---> urCommandBufferAppendUSMAdviseExp"); ur_result_t result = pfnAppendUSMAdviseExp(hCommandBuffer, pMemory, size, advice, numSyncPointsInWaitList, pSyncPointWaitList, pSyncPoint); - context.notify_end(UR_FUNCTION_COMMAND_BUFFER_APPEND_USM_ADVISE_EXP, - "urCommandBufferAppendUSMAdviseExp", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_COMMAND_BUFFER_APPEND_USM_ADVISE_EXP, + "urCommandBufferAppendUSMAdviseExp", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_APPEND_USM_ADVISE_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -7094,7 +7165,8 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferEnqueueExp( phEvent ///< [out][optional] return an event object that identifies this particular ///< command-buffer execution instance. ) { - auto pfnEnqueueExp = context.urDdiTable.CommandBufferExp.pfnEnqueueExp; + auto pfnEnqueueExp = + getContext()->urDdiTable.CommandBufferExp.pfnEnqueueExp; if (nullptr == pfnEnqueueExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -7104,21 +7176,22 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferEnqueueExp( &hCommandBuffer, &hQueue, &numEventsInWaitList, &phEventWaitList, &phEvent}; uint64_t instance = - context.notify_begin(UR_FUNCTION_COMMAND_BUFFER_ENQUEUE_EXP, - "urCommandBufferEnqueueExp", ¶ms); + getContext()->notify_begin(UR_FUNCTION_COMMAND_BUFFER_ENQUEUE_EXP, + "urCommandBufferEnqueueExp", ¶ms); - context.logger.info("---> urCommandBufferEnqueueExp"); + getContext()->logger.info("---> urCommandBufferEnqueueExp"); ur_result_t result = pfnEnqueueExp( hCommandBuffer, hQueue, numEventsInWaitList, phEventWaitList, phEvent); - context.notify_end(UR_FUNCTION_COMMAND_BUFFER_ENQUEUE_EXP, - "urCommandBufferEnqueueExp", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_COMMAND_BUFFER_ENQUEUE_EXP, + "urCommandBufferEnqueueExp", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_ENQUEUE_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -7130,29 +7203,29 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferRetainCommandExp( hCommand ///< [in] Handle of the command-buffer command. ) { auto pfnRetainCommandExp = - context.urDdiTable.CommandBufferExp.pfnRetainCommandExp; + getContext()->urDdiTable.CommandBufferExp.pfnRetainCommandExp; if (nullptr == pfnRetainCommandExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_command_buffer_retain_command_exp_params_t params = {&hCommand}; - uint64_t instance = - context.notify_begin(UR_FUNCTION_COMMAND_BUFFER_RETAIN_COMMAND_EXP, - "urCommandBufferRetainCommandExp", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_COMMAND_BUFFER_RETAIN_COMMAND_EXP, + "urCommandBufferRetainCommandExp", ¶ms); - context.logger.info("---> urCommandBufferRetainCommandExp"); + getContext()->logger.info("---> urCommandBufferRetainCommandExp"); ur_result_t result = pfnRetainCommandExp(hCommand); - context.notify_end(UR_FUNCTION_COMMAND_BUFFER_RETAIN_COMMAND_EXP, - "urCommandBufferRetainCommandExp", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_COMMAND_BUFFER_RETAIN_COMMAND_EXP, + "urCommandBufferRetainCommandExp", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_RETAIN_COMMAND_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -7164,29 +7237,29 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferReleaseCommandExp( hCommand ///< [in][release] Handle of the command-buffer command. ) { auto pfnReleaseCommandExp = - context.urDdiTable.CommandBufferExp.pfnReleaseCommandExp; + getContext()->urDdiTable.CommandBufferExp.pfnReleaseCommandExp; if (nullptr == pfnReleaseCommandExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_command_buffer_release_command_exp_params_t params = {&hCommand}; - uint64_t instance = - context.notify_begin(UR_FUNCTION_COMMAND_BUFFER_RELEASE_COMMAND_EXP, - "urCommandBufferReleaseCommandExp", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_COMMAND_BUFFER_RELEASE_COMMAND_EXP, + "urCommandBufferReleaseCommandExp", ¶ms); - context.logger.info("---> urCommandBufferReleaseCommandExp"); + getContext()->logger.info("---> urCommandBufferReleaseCommandExp"); ur_result_t result = pfnReleaseCommandExp(hCommand); - context.notify_end(UR_FUNCTION_COMMAND_BUFFER_RELEASE_COMMAND_EXP, - "urCommandBufferReleaseCommandExp", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_COMMAND_BUFFER_RELEASE_COMMAND_EXP, + "urCommandBufferReleaseCommandExp", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_RELEASE_COMMAND_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -7200,7 +7273,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferUpdateKernelLaunchExp( pUpdateKernelLaunch ///< [in] Struct defining how the kernel command is to be updated. ) { auto pfnUpdateKernelLaunchExp = - context.urDdiTable.CommandBufferExp.pfnUpdateKernelLaunchExp; + getContext()->urDdiTable.CommandBufferExp.pfnUpdateKernelLaunchExp; if (nullptr == pfnUpdateKernelLaunchExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -7208,23 +7281,23 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferUpdateKernelLaunchExp( ur_command_buffer_update_kernel_launch_exp_params_t params = { &hCommand, &pUpdateKernelLaunch}; - uint64_t instance = context.notify_begin( + uint64_t instance = getContext()->notify_begin( UR_FUNCTION_COMMAND_BUFFER_UPDATE_KERNEL_LAUNCH_EXP, "urCommandBufferUpdateKernelLaunchExp", ¶ms); - context.logger.info("---> urCommandBufferUpdateKernelLaunchExp"); + getContext()->logger.info("---> urCommandBufferUpdateKernelLaunchExp"); ur_result_t result = pfnUpdateKernelLaunchExp(hCommand, pUpdateKernelLaunch); - context.notify_end(UR_FUNCTION_COMMAND_BUFFER_UPDATE_KERNEL_LAUNCH_EXP, - "urCommandBufferUpdateKernelLaunchExp", ¶ms, &result, - instance); + getContext()->notify_end( + UR_FUNCTION_COMMAND_BUFFER_UPDATE_KERNEL_LAUNCH_EXP, + "urCommandBufferUpdateKernelLaunchExp", ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_UPDATE_KERNEL_LAUNCH_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -7244,7 +7317,8 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferGetInfoExp( size_t * pPropSizeRet ///< [out][optional] bytes returned in command-buffer property ) { - auto pfnGetInfoExp = context.urDdiTable.CommandBufferExp.pfnGetInfoExp; + auto pfnGetInfoExp = + getContext()->urDdiTable.CommandBufferExp.pfnGetInfoExp; if (nullptr == pfnGetInfoExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -7253,21 +7327,22 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferGetInfoExp( ur_command_buffer_get_info_exp_params_t params = { &hCommandBuffer, &propName, &propSize, &pPropValue, &pPropSizeRet}; uint64_t instance = - context.notify_begin(UR_FUNCTION_COMMAND_BUFFER_GET_INFO_EXP, - "urCommandBufferGetInfoExp", ¶ms); + getContext()->notify_begin(UR_FUNCTION_COMMAND_BUFFER_GET_INFO_EXP, + "urCommandBufferGetInfoExp", ¶ms); - context.logger.info("---> urCommandBufferGetInfoExp"); + getContext()->logger.info("---> urCommandBufferGetInfoExp"); ur_result_t result = pfnGetInfoExp(hCommandBuffer, propName, propSize, pPropValue, pPropSizeRet); - context.notify_end(UR_FUNCTION_COMMAND_BUFFER_GET_INFO_EXP, - "urCommandBufferGetInfoExp", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_COMMAND_BUFFER_GET_INFO_EXP, + "urCommandBufferGetInfoExp", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_GET_INFO_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -7288,7 +7363,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferCommandGetInfoExp( pPropSizeRet ///< [out][optional] bytes returned in command-buffer command property ) { auto pfnCommandGetInfoExp = - context.urDdiTable.CommandBufferExp.pfnCommandGetInfoExp; + getContext()->urDdiTable.CommandBufferExp.pfnCommandGetInfoExp; if (nullptr == pfnCommandGetInfoExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -7296,23 +7371,23 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferCommandGetInfoExp( ur_command_buffer_command_get_info_exp_params_t params = { &hCommand, &propName, &propSize, &pPropValue, &pPropSizeRet}; - uint64_t instance = - context.notify_begin(UR_FUNCTION_COMMAND_BUFFER_COMMAND_GET_INFO_EXP, - "urCommandBufferCommandGetInfoExp", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_COMMAND_BUFFER_COMMAND_GET_INFO_EXP, + "urCommandBufferCommandGetInfoExp", ¶ms); - context.logger.info("---> urCommandBufferCommandGetInfoExp"); + getContext()->logger.info("---> urCommandBufferCommandGetInfoExp"); ur_result_t result = pfnCommandGetInfoExp(hCommand, propName, propSize, pPropValue, pPropSizeRet); - context.notify_end(UR_FUNCTION_COMMAND_BUFFER_COMMAND_GET_INFO_EXP, - "urCommandBufferCommandGetInfoExp", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_COMMAND_BUFFER_COMMAND_GET_INFO_EXP, + "urCommandBufferCommandGetInfoExp", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_COMMAND_GET_INFO_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -7349,7 +7424,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueCooperativeKernelLaunchExp( ///< kernel execution instance. ) { auto pfnCooperativeKernelLaunchExp = - context.urDdiTable.EnqueueExp.pfnCooperativeKernelLaunchExp; + getContext()->urDdiTable.EnqueueExp.pfnCooperativeKernelLaunchExp; if (nullptr == pfnCooperativeKernelLaunchExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -7365,24 +7440,24 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueCooperativeKernelLaunchExp( &numEventsInWaitList, &phEventWaitList, &phEvent}; - uint64_t instance = - context.notify_begin(UR_FUNCTION_ENQUEUE_COOPERATIVE_KERNEL_LAUNCH_EXP, - "urEnqueueCooperativeKernelLaunchExp", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_ENQUEUE_COOPERATIVE_KERNEL_LAUNCH_EXP, + "urEnqueueCooperativeKernelLaunchExp", ¶ms); - context.logger.info("---> urEnqueueCooperativeKernelLaunchExp"); + getContext()->logger.info("---> urEnqueueCooperativeKernelLaunchExp"); ur_result_t result = pfnCooperativeKernelLaunchExp( hQueue, hKernel, workDim, pGlobalWorkOffset, pGlobalWorkSize, pLocalWorkSize, numEventsInWaitList, phEventWaitList, phEvent); - context.notify_end(UR_FUNCTION_ENQUEUE_COOPERATIVE_KERNEL_LAUNCH_EXP, - "urEnqueueCooperativeKernelLaunchExp", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_ENQUEUE_COOPERATIVE_KERNEL_LAUNCH_EXP, + "urEnqueueCooperativeKernelLaunchExp", ¶ms, + &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_COOPERATIVE_KERNEL_LAUNCH_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -7400,7 +7475,8 @@ __urdlllocal ur_result_t UR_APICALL urKernelSuggestMaxCooperativeGroupCountExp( uint32_t *pGroupCountRet ///< [out] pointer to maximum number of groups ) { auto pfnSuggestMaxCooperativeGroupCountExp = - context.urDdiTable.KernelExp.pfnSuggestMaxCooperativeGroupCountExp; + getContext() + ->urDdiTable.KernelExp.pfnSuggestMaxCooperativeGroupCountExp; if (nullptr == pfnSuggestMaxCooperativeGroupCountExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -7408,16 +7484,17 @@ __urdlllocal ur_result_t UR_APICALL urKernelSuggestMaxCooperativeGroupCountExp( ur_kernel_suggest_max_cooperative_group_count_exp_params_t params = { &hKernel, &localWorkSize, &dynamicSharedMemorySize, &pGroupCountRet}; - uint64_t instance = context.notify_begin( + uint64_t instance = getContext()->notify_begin( UR_FUNCTION_KERNEL_SUGGEST_MAX_COOPERATIVE_GROUP_COUNT_EXP, "urKernelSuggestMaxCooperativeGroupCountExp", ¶ms); - context.logger.info("---> urKernelSuggestMaxCooperativeGroupCountExp"); + getContext()->logger.info( + "---> urKernelSuggestMaxCooperativeGroupCountExp"); ur_result_t result = pfnSuggestMaxCooperativeGroupCountExp( hKernel, localWorkSize, dynamicSharedMemorySize, pGroupCountRet); - context.notify_end( + getContext()->notify_end( UR_FUNCTION_KERNEL_SUGGEST_MAX_COOPERATIVE_GROUP_COUNT_EXP, "urKernelSuggestMaxCooperativeGroupCountExp", ¶ms, &result, instance); @@ -7426,7 +7503,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSuggestMaxCooperativeGroupCountExp( ur::extras::printFunctionParams( args_str, UR_FUNCTION_KERNEL_SUGGEST_MAX_COOPERATIVE_GROUP_COUNT_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -7455,7 +7532,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueTimestampRecordingExp( ///< reports the timestamp recorded when the command is executed on the device. ) { auto pfnTimestampRecordingExp = - context.urDdiTable.EnqueueExp.pfnTimestampRecordingExp; + getContext()->urDdiTable.EnqueueExp.pfnTimestampRecordingExp; if (nullptr == pfnTimestampRecordingExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -7464,22 +7541,22 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueTimestampRecordingExp( ur_enqueue_timestamp_recording_exp_params_t params = { &hQueue, &blocking, &numEventsInWaitList, &phEventWaitList, &phEvent}; uint64_t instance = - context.notify_begin(UR_FUNCTION_ENQUEUE_TIMESTAMP_RECORDING_EXP, - "urEnqueueTimestampRecordingExp", ¶ms); + getContext()->notify_begin(UR_FUNCTION_ENQUEUE_TIMESTAMP_RECORDING_EXP, + "urEnqueueTimestampRecordingExp", ¶ms); - context.logger.info("---> urEnqueueTimestampRecordingExp"); + getContext()->logger.info("---> urEnqueueTimestampRecordingExp"); ur_result_t result = pfnTimestampRecordingExp( hQueue, blocking, numEventsInWaitList, phEventWaitList, phEvent); - context.notify_end(UR_FUNCTION_ENQUEUE_TIMESTAMP_RECORDING_EXP, - "urEnqueueTimestampRecordingExp", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_ENQUEUE_TIMESTAMP_RECORDING_EXP, + "urEnqueueTimestampRecordingExp", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_TIMESTAMP_RECORDING_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -7515,7 +7592,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueKernelLaunchCustomExp( ///< kernel execution instance. ) { auto pfnKernelLaunchCustomExp = - context.urDdiTable.EnqueueExp.pfnKernelLaunchCustomExp; + getContext()->urDdiTable.EnqueueExp.pfnKernelLaunchCustomExp; if (nullptr == pfnKernelLaunchCustomExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -7528,24 +7605,24 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueKernelLaunchCustomExp( &launchPropList, &numEventsInWaitList, &phEventWaitList, &phEvent}; uint64_t instance = - context.notify_begin(UR_FUNCTION_ENQUEUE_KERNEL_LAUNCH_CUSTOM_EXP, - "urEnqueueKernelLaunchCustomExp", ¶ms); + getContext()->notify_begin(UR_FUNCTION_ENQUEUE_KERNEL_LAUNCH_CUSTOM_EXP, + "urEnqueueKernelLaunchCustomExp", ¶ms); - context.logger.info("---> urEnqueueKernelLaunchCustomExp"); + getContext()->logger.info("---> urEnqueueKernelLaunchCustomExp"); ur_result_t result = pfnKernelLaunchCustomExp( hQueue, hKernel, workDim, pGlobalWorkSize, pLocalWorkSize, numPropsInLaunchPropList, launchPropList, numEventsInWaitList, phEventWaitList, phEvent); - context.notify_end(UR_FUNCTION_ENQUEUE_KERNEL_LAUNCH_CUSTOM_EXP, - "urEnqueueKernelLaunchCustomExp", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_ENQUEUE_KERNEL_LAUNCH_CUSTOM_EXP, + "urEnqueueKernelLaunchCustomExp", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_KERNEL_LAUNCH_CUSTOM_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -7560,7 +7637,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramBuildExp( const char * pOptions ///< [in][optional] pointer to build options null-terminated string. ) { - auto pfnBuildExp = context.urDdiTable.ProgramExp.pfnBuildExp; + auto pfnBuildExp = getContext()->urDdiTable.ProgramExp.pfnBuildExp; if (nullptr == pfnBuildExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -7568,20 +7645,20 @@ __urdlllocal ur_result_t UR_APICALL urProgramBuildExp( ur_program_build_exp_params_t params = {&hProgram, &numDevices, &phDevices, &pOptions}; - uint64_t instance = context.notify_begin(UR_FUNCTION_PROGRAM_BUILD_EXP, - "urProgramBuildExp", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_PROGRAM_BUILD_EXP, "urProgramBuildExp", ¶ms); - context.logger.info("---> urProgramBuildExp"); + getContext()->logger.info("---> urProgramBuildExp"); ur_result_t result = pfnBuildExp(hProgram, numDevices, phDevices, pOptions); - context.notify_end(UR_FUNCTION_PROGRAM_BUILD_EXP, "urProgramBuildExp", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_PROGRAM_BUILD_EXP, "urProgramBuildExp", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_PROGRAM_BUILD_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -7597,7 +7674,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramCompileExp( const char * pOptions ///< [in][optional] pointer to build options null-terminated string. ) { - auto pfnCompileExp = context.urDdiTable.ProgramExp.pfnCompileExp; + auto pfnCompileExp = getContext()->urDdiTable.ProgramExp.pfnCompileExp; if (nullptr == pfnCompileExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -7605,21 +7682,21 @@ __urdlllocal ur_result_t UR_APICALL urProgramCompileExp( ur_program_compile_exp_params_t params = {&hProgram, &numDevices, &phDevices, &pOptions}; - uint64_t instance = context.notify_begin(UR_FUNCTION_PROGRAM_COMPILE_EXP, - "urProgramCompileExp", ¶ms); + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_PROGRAM_COMPILE_EXP, "urProgramCompileExp", ¶ms); - context.logger.info("---> urProgramCompileExp"); + getContext()->logger.info("---> urProgramCompileExp"); ur_result_t result = pfnCompileExp(hProgram, numDevices, phDevices, pOptions); - context.notify_end(UR_FUNCTION_PROGRAM_COMPILE_EXP, "urProgramCompileExp", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_PROGRAM_COMPILE_EXP, + "urProgramCompileExp", ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_PROGRAM_COMPILE_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -7639,7 +7716,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramLinkExp( ur_program_handle_t *phProgram ///< [out] pointer to handle of program object created. ) { - auto pfnLinkExp = context.urDdiTable.ProgramExp.pfnLinkExp; + auto pfnLinkExp = getContext()->urDdiTable.ProgramExp.pfnLinkExp; if (nullptr == pfnLinkExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -7648,21 +7725,21 @@ __urdlllocal ur_result_t UR_APICALL urProgramLinkExp( ur_program_link_exp_params_t params = {&hContext, &numDevices, &phDevices, &count, &phPrograms, &pOptions, &phProgram}; - uint64_t instance = context.notify_begin(UR_FUNCTION_PROGRAM_LINK_EXP, - "urProgramLinkExp", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_PROGRAM_LINK_EXP, + "urProgramLinkExp", ¶ms); - context.logger.info("---> urProgramLinkExp"); + getContext()->logger.info("---> urProgramLinkExp"); ur_result_t result = pfnLinkExp(hContext, numDevices, phDevices, count, phPrograms, pOptions, phProgram); - context.notify_end(UR_FUNCTION_PROGRAM_LINK_EXP, "urProgramLinkExp", - ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_PROGRAM_LINK_EXP, "urProgramLinkExp", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_PROGRAM_LINK_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -7674,27 +7751,27 @@ __urdlllocal ur_result_t UR_APICALL urUSMImportExp( void *pMem, ///< [in] pointer to host memory object size_t size ///< [in] size in bytes of the host memory object to be imported ) { - auto pfnImportExp = context.urDdiTable.USMExp.pfnImportExp; + auto pfnImportExp = getContext()->urDdiTable.USMExp.pfnImportExp; if (nullptr == pfnImportExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_usm_import_exp_params_t params = {&hContext, &pMem, &size}; - uint64_t instance = context.notify_begin(UR_FUNCTION_USM_IMPORT_EXP, - "urUSMImportExp", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_USM_IMPORT_EXP, + "urUSMImportExp", ¶ms); - context.logger.info("---> urUSMImportExp"); + getContext()->logger.info("---> urUSMImportExp"); ur_result_t result = pfnImportExp(hContext, pMem, size); - context.notify_end(UR_FUNCTION_USM_IMPORT_EXP, "urUSMImportExp", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_USM_IMPORT_EXP, "urUSMImportExp", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_USM_IMPORT_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -7705,27 +7782,27 @@ __urdlllocal ur_result_t UR_APICALL urUSMReleaseExp( ur_context_handle_t hContext, ///< [in] handle of the context object void *pMem ///< [in] pointer to host memory object ) { - auto pfnReleaseExp = context.urDdiTable.USMExp.pfnReleaseExp; + auto pfnReleaseExp = getContext()->urDdiTable.USMExp.pfnReleaseExp; if (nullptr == pfnReleaseExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } ur_usm_release_exp_params_t params = {&hContext, &pMem}; - uint64_t instance = context.notify_begin(UR_FUNCTION_USM_RELEASE_EXP, - "urUSMReleaseExp", ¶ms); + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_USM_RELEASE_EXP, + "urUSMReleaseExp", ¶ms); - context.logger.info("---> urUSMReleaseExp"); + getContext()->logger.info("---> urUSMReleaseExp"); ur_result_t result = pfnReleaseExp(hContext, pMem); - context.notify_end(UR_FUNCTION_USM_RELEASE_EXP, "urUSMReleaseExp", ¶ms, - &result, instance); + getContext()->notify_end(UR_FUNCTION_USM_RELEASE_EXP, "urUSMReleaseExp", + ¶ms, &result, instance); std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_USM_RELEASE_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -7738,7 +7815,7 @@ __urdlllocal ur_result_t UR_APICALL urUsmP2PEnablePeerAccessExp( ur_device_handle_t peerDevice ///< [in] handle of the peer device object ) { auto pfnEnablePeerAccessExp = - context.urDdiTable.UsmP2PExp.pfnEnablePeerAccessExp; + getContext()->urDdiTable.UsmP2PExp.pfnEnablePeerAccessExp; if (nullptr == pfnEnablePeerAccessExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -7747,21 +7824,21 @@ __urdlllocal ur_result_t UR_APICALL urUsmP2PEnablePeerAccessExp( ur_usm_p2p_enable_peer_access_exp_params_t params = {&commandDevice, &peerDevice}; uint64_t instance = - context.notify_begin(UR_FUNCTION_USM_P2P_ENABLE_PEER_ACCESS_EXP, - "urUsmP2PEnablePeerAccessExp", ¶ms); + getContext()->notify_begin(UR_FUNCTION_USM_P2P_ENABLE_PEER_ACCESS_EXP, + "urUsmP2PEnablePeerAccessExp", ¶ms); - context.logger.info("---> urUsmP2PEnablePeerAccessExp"); + getContext()->logger.info("---> urUsmP2PEnablePeerAccessExp"); ur_result_t result = pfnEnablePeerAccessExp(commandDevice, peerDevice); - context.notify_end(UR_FUNCTION_USM_P2P_ENABLE_PEER_ACCESS_EXP, - "urUsmP2PEnablePeerAccessExp", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_USM_P2P_ENABLE_PEER_ACCESS_EXP, + "urUsmP2PEnablePeerAccessExp", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_USM_P2P_ENABLE_PEER_ACCESS_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -7774,7 +7851,7 @@ __urdlllocal ur_result_t UR_APICALL urUsmP2PDisablePeerAccessExp( ur_device_handle_t peerDevice ///< [in] handle of the peer device object ) { auto pfnDisablePeerAccessExp = - context.urDdiTable.UsmP2PExp.pfnDisablePeerAccessExp; + getContext()->urDdiTable.UsmP2PExp.pfnDisablePeerAccessExp; if (nullptr == pfnDisablePeerAccessExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -7783,21 +7860,21 @@ __urdlllocal ur_result_t UR_APICALL urUsmP2PDisablePeerAccessExp( ur_usm_p2p_disable_peer_access_exp_params_t params = {&commandDevice, &peerDevice}; uint64_t instance = - context.notify_begin(UR_FUNCTION_USM_P2P_DISABLE_PEER_ACCESS_EXP, - "urUsmP2PDisablePeerAccessExp", ¶ms); + getContext()->notify_begin(UR_FUNCTION_USM_P2P_DISABLE_PEER_ACCESS_EXP, + "urUsmP2PDisablePeerAccessExp", ¶ms); - context.logger.info("---> urUsmP2PDisablePeerAccessExp"); + getContext()->logger.info("---> urUsmP2PDisablePeerAccessExp"); ur_result_t result = pfnDisablePeerAccessExp(commandDevice, peerDevice); - context.notify_end(UR_FUNCTION_USM_P2P_DISABLE_PEER_ACCESS_EXP, - "urUsmP2PDisablePeerAccessExp", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_USM_P2P_DISABLE_PEER_ACCESS_EXP, + "urUsmP2PDisablePeerAccessExp", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_USM_P2P_DISABLE_PEER_ACCESS_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -7821,7 +7898,7 @@ __urdlllocal ur_result_t UR_APICALL urUsmP2PPeerAccessGetInfoExp( pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of the queried propName. ) { auto pfnPeerAccessGetInfoExp = - context.urDdiTable.UsmP2PExp.pfnPeerAccessGetInfoExp; + getContext()->urDdiTable.UsmP2PExp.pfnPeerAccessGetInfoExp; if (nullptr == pfnPeerAccessGetInfoExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -7831,23 +7908,23 @@ __urdlllocal ur_result_t UR_APICALL urUsmP2PPeerAccessGetInfoExp( &commandDevice, &peerDevice, &propName, &propSize, &pPropValue, &pPropSizeRet}; uint64_t instance = - context.notify_begin(UR_FUNCTION_USM_P2P_PEER_ACCESS_GET_INFO_EXP, - "urUsmP2PPeerAccessGetInfoExp", ¶ms); + getContext()->notify_begin(UR_FUNCTION_USM_P2P_PEER_ACCESS_GET_INFO_EXP, + "urUsmP2PPeerAccessGetInfoExp", ¶ms); - context.logger.info("---> urUsmP2PPeerAccessGetInfoExp"); + getContext()->logger.info("---> urUsmP2PPeerAccessGetInfoExp"); ur_result_t result = pfnPeerAccessGetInfoExp(commandDevice, peerDevice, propName, propSize, pPropValue, pPropSizeRet); - context.notify_end(UR_FUNCTION_USM_P2P_PEER_ACCESS_GET_INFO_EXP, - "urUsmP2PPeerAccessGetInfoExp", ¶ms, &result, - instance); + getContext()->notify_end(UR_FUNCTION_USM_P2P_PEER_ACCESS_GET_INFO_EXP, + "urUsmP2PPeerAccessGetInfoExp", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_USM_P2P_PEER_ACCESS_GET_INFO_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -7878,7 +7955,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueNativeCommandExp( ///< been enqueued in nativeEnqueueFunc. ) { auto pfnNativeCommandExp = - context.urDdiTable.EnqueueExp.pfnNativeCommandExp; + getContext()->urDdiTable.EnqueueExp.pfnNativeCommandExp; if (nullptr == pfnNativeCommandExp) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; @@ -7894,22 +7971,23 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueNativeCommandExp( &phEventWaitList, &phEvent}; uint64_t instance = - context.notify_begin(UR_FUNCTION_ENQUEUE_NATIVE_COMMAND_EXP, - "urEnqueueNativeCommandExp", ¶ms); + getContext()->notify_begin(UR_FUNCTION_ENQUEUE_NATIVE_COMMAND_EXP, + "urEnqueueNativeCommandExp", ¶ms); - context.logger.info("---> urEnqueueNativeCommandExp"); + getContext()->logger.info("---> urEnqueueNativeCommandExp"); ur_result_t result = pfnNativeCommandExp( hQueue, pfnNativeEnqueue, data, numMemsInMemList, phMemList, pProperties, numEventsInWaitList, phEventWaitList, phEvent); - context.notify_end(UR_FUNCTION_ENQUEUE_NATIVE_COMMAND_EXP, - "urEnqueueNativeCommandExp", ¶ms, &result, instance); + getContext()->notify_end(UR_FUNCTION_ENQUEUE_NATIVE_COMMAND_EXP, + "urEnqueueNativeCommandExp", ¶ms, &result, + instance); std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_NATIVE_COMMAND_EXP, ¶ms); - context.logger.info("({}) -> {};\n", args_str.str(), result); + getContext()->logger.info("({}) -> {};\n", args_str.str(), result); return result; } @@ -7927,15 +8005,15 @@ __urdlllocal ur_result_t UR_APICALL urGetGlobalProcAddrTable( ur_global_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_tracing_layer::context.urDdiTable.Global; + auto &dditable = ur_tracing_layer::getContext()->urDdiTable.Global; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_tracing_layer::context.version) != + if (UR_MAJOR_VERSION(ur_tracing_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_tracing_layer::context.version) > + UR_MINOR_VERSION(ur_tracing_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -7972,15 +8050,16 @@ __urdlllocal ur_result_t UR_APICALL urGetBindlessImagesExpProcAddrTable( ur_bindless_images_exp_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_tracing_layer::context.urDdiTable.BindlessImagesExp; + auto &dditable = + ur_tracing_layer::getContext()->urDdiTable.BindlessImagesExp; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_tracing_layer::context.version) != + if (UR_MAJOR_VERSION(ur_tracing_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_tracing_layer::context.version) > + UR_MINOR_VERSION(ur_tracing_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -8074,15 +8153,16 @@ __urdlllocal ur_result_t UR_APICALL urGetCommandBufferExpProcAddrTable( ur_command_buffer_exp_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_tracing_layer::context.urDdiTable.CommandBufferExp; + auto &dditable = + ur_tracing_layer::getContext()->urDdiTable.CommandBufferExp; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_tracing_layer::context.version) != + if (UR_MAJOR_VERSION(ur_tracing_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_tracing_layer::context.version) > + UR_MINOR_VERSION(ur_tracing_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -8189,15 +8269,15 @@ __urdlllocal ur_result_t UR_APICALL urGetContextProcAddrTable( ur_context_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_tracing_layer::context.urDdiTable.Context; + auto &dditable = ur_tracing_layer::getContext()->urDdiTable.Context; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_tracing_layer::context.version) != + if (UR_MAJOR_VERSION(ur_tracing_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_tracing_layer::context.version) > + UR_MINOR_VERSION(ur_tracing_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -8242,15 +8322,15 @@ __urdlllocal ur_result_t UR_APICALL urGetEnqueueProcAddrTable( ur_enqueue_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_tracing_layer::context.urDdiTable.Enqueue; + auto &dditable = ur_tracing_layer::getContext()->urDdiTable.Enqueue; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_tracing_layer::context.version) != + if (UR_MAJOR_VERSION(ur_tracing_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_tracing_layer::context.version) > + UR_MINOR_VERSION(ur_tracing_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -8355,15 +8435,15 @@ __urdlllocal ur_result_t UR_APICALL urGetEnqueueExpProcAddrTable( ur_enqueue_exp_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_tracing_layer::context.urDdiTable.EnqueueExp; + auto &dditable = ur_tracing_layer::getContext()->urDdiTable.EnqueueExp; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_tracing_layer::context.version) != + if (UR_MAJOR_VERSION(ur_tracing_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_tracing_layer::context.version) > + UR_MINOR_VERSION(ur_tracing_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -8402,15 +8482,15 @@ __urdlllocal ur_result_t UR_APICALL urGetEventProcAddrTable( ur_event_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_tracing_layer::context.urDdiTable.Event; + auto &dditable = ur_tracing_layer::getContext()->urDdiTable.Event; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_tracing_layer::context.version) != + if (UR_MAJOR_VERSION(ur_tracing_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_tracing_layer::context.version) > + UR_MINOR_VERSION(ur_tracing_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -8457,15 +8537,15 @@ __urdlllocal ur_result_t UR_APICALL urGetKernelProcAddrTable( ur_kernel_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_tracing_layer::context.urDdiTable.Kernel; + auto &dditable = ur_tracing_layer::getContext()->urDdiTable.Kernel; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_tracing_layer::context.version) != + if (UR_MAJOR_VERSION(ur_tracing_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_tracing_layer::context.version) > + UR_MINOR_VERSION(ur_tracing_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -8540,15 +8620,15 @@ __urdlllocal ur_result_t UR_APICALL urGetKernelExpProcAddrTable( ur_kernel_exp_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_tracing_layer::context.urDdiTable.KernelExp; + auto &dditable = ur_tracing_layer::getContext()->urDdiTable.KernelExp; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_tracing_layer::context.version) != + if (UR_MAJOR_VERSION(ur_tracing_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_tracing_layer::context.version) > + UR_MINOR_VERSION(ur_tracing_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -8575,15 +8655,15 @@ __urdlllocal ur_result_t UR_APICALL urGetMemProcAddrTable( ur_mem_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_tracing_layer::context.urDdiTable.Mem; + auto &dditable = ur_tracing_layer::getContext()->urDdiTable.Mem; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_tracing_layer::context.version) != + if (UR_MAJOR_VERSION(ur_tracing_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_tracing_layer::context.version) > + UR_MINOR_VERSION(ur_tracing_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -8639,15 +8719,15 @@ __urdlllocal ur_result_t UR_APICALL urGetPhysicalMemProcAddrTable( ur_physical_mem_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_tracing_layer::context.urDdiTable.PhysicalMem; + auto &dditable = ur_tracing_layer::getContext()->urDdiTable.PhysicalMem; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_tracing_layer::context.version) != + if (UR_MAJOR_VERSION(ur_tracing_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_tracing_layer::context.version) > + UR_MINOR_VERSION(ur_tracing_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -8678,15 +8758,15 @@ __urdlllocal ur_result_t UR_APICALL urGetPlatformProcAddrTable( ur_platform_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_tracing_layer::context.urDdiTable.Platform; + auto &dditable = ur_tracing_layer::getContext()->urDdiTable.Platform; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_tracing_layer::context.version) != + if (UR_MAJOR_VERSION(ur_tracing_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_tracing_layer::context.version) > + UR_MINOR_VERSION(ur_tracing_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -8728,15 +8808,15 @@ __urdlllocal ur_result_t UR_APICALL urGetProgramProcAddrTable( ur_program_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_tracing_layer::context.urDdiTable.Program; + auto &dditable = ur_tracing_layer::getContext()->urDdiTable.Program; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_tracing_layer::context.version) != + if (UR_MAJOR_VERSION(ur_tracing_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_tracing_layer::context.version) > + UR_MINOR_VERSION(ur_tracing_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -8807,15 +8887,15 @@ __urdlllocal ur_result_t UR_APICALL urGetProgramExpProcAddrTable( ur_program_exp_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_tracing_layer::context.urDdiTable.ProgramExp; + auto &dditable = ur_tracing_layer::getContext()->urDdiTable.ProgramExp; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_tracing_layer::context.version) != + if (UR_MAJOR_VERSION(ur_tracing_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_tracing_layer::context.version) > + UR_MINOR_VERSION(ur_tracing_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -8846,15 +8926,15 @@ __urdlllocal ur_result_t UR_APICALL urGetQueueProcAddrTable( ur_queue_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_tracing_layer::context.urDdiTable.Queue; + auto &dditable = ur_tracing_layer::getContext()->urDdiTable.Queue; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_tracing_layer::context.version) != + if (UR_MAJOR_VERSION(ur_tracing_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_tracing_layer::context.version) > + UR_MINOR_VERSION(ur_tracing_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -8901,15 +8981,15 @@ __urdlllocal ur_result_t UR_APICALL urGetSamplerProcAddrTable( ur_sampler_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_tracing_layer::context.urDdiTable.Sampler; + auto &dditable = ur_tracing_layer::getContext()->urDdiTable.Sampler; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_tracing_layer::context.version) != + if (UR_MAJOR_VERSION(ur_tracing_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_tracing_layer::context.version) > + UR_MINOR_VERSION(ur_tracing_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -8950,15 +9030,15 @@ __urdlllocal ur_result_t UR_APICALL urGetUSMProcAddrTable( ur_usm_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_tracing_layer::context.urDdiTable.USM; + auto &dditable = ur_tracing_layer::getContext()->urDdiTable.USM; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_tracing_layer::context.version) != + if (UR_MAJOR_VERSION(ur_tracing_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_tracing_layer::context.version) > + UR_MINOR_VERSION(ur_tracing_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -9007,15 +9087,15 @@ __urdlllocal ur_result_t UR_APICALL urGetUSMExpProcAddrTable( ur_usm_exp_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_tracing_layer::context.urDdiTable.USMExp; + auto &dditable = ur_tracing_layer::getContext()->urDdiTable.USMExp; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_tracing_layer::context.version) != + if (UR_MAJOR_VERSION(ur_tracing_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_tracing_layer::context.version) > + UR_MINOR_VERSION(ur_tracing_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -9046,15 +9126,15 @@ __urdlllocal ur_result_t UR_APICALL urGetUsmP2PExpProcAddrTable( ur_usm_p2p_exp_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_tracing_layer::context.urDdiTable.UsmP2PExp; + auto &dditable = ur_tracing_layer::getContext()->urDdiTable.UsmP2PExp; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_tracing_layer::context.version) != + if (UR_MAJOR_VERSION(ur_tracing_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_tracing_layer::context.version) > + UR_MINOR_VERSION(ur_tracing_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -9088,15 +9168,15 @@ __urdlllocal ur_result_t UR_APICALL urGetVirtualMemProcAddrTable( ur_virtual_mem_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_tracing_layer::context.urDdiTable.VirtualMem; + auto &dditable = ur_tracing_layer::getContext()->urDdiTable.VirtualMem; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_tracing_layer::context.version) != + if (UR_MAJOR_VERSION(ur_tracing_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_tracing_layer::context.version) > + UR_MINOR_VERSION(ur_tracing_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -9140,15 +9220,15 @@ __urdlllocal ur_result_t UR_APICALL urGetDeviceProcAddrTable( ur_device_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_tracing_layer::context.urDdiTable.Device; + auto &dditable = ur_tracing_layer::getContext()->urDdiTable.Device; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_tracing_layer::context.version) != + if (UR_MAJOR_VERSION(ur_tracing_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_tracing_layer::context.version) > + UR_MINOR_VERSION(ur_tracing_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -9200,7 +9280,7 @@ ur_result_t context_t::init(ur_dditable_t *dditable, // program launch and the call to `urLoaderInit` logger = logger::create_logger("tracing", true, true); - ur_tracing_layer::context.codelocData = codelocData; + ur_tracing_layer::getContext()->codelocData = codelocData; if (UR_RESULT_SUCCESS == result) { result = ur_tracing_layer::urGetGlobalProcAddrTable( diff --git a/source/loader/layers/ur_proxy_layer.hpp b/source/loader/layers/ur_proxy_layer.hpp index 2b710f3287..ab81632890 100644 --- a/source/loader/layers/ur_proxy_layer.hpp +++ b/source/loader/layers/ur_proxy_layer.hpp @@ -21,6 +21,7 @@ /////////////////////////////////////////////////////////////////////////////// class __urdlllocal proxy_layer_context_t { public: + virtual ~proxy_layer_context_t(){}; ur_api_version_t version = UR_API_VERSION_CURRENT; virtual std::vector getNames() const = 0; diff --git a/source/loader/layers/validation/ur_leak_check.hpp b/source/loader/layers/validation/ur_leak_check.hpp index 008795078a..694f3c8aa7 100644 --- a/source/loader/layers/validation/ur_leak_check.hpp +++ b/source/loader/layers/validation/ur_leak_check.hpp @@ -67,13 +67,13 @@ struct RefCountContext { ptr, RefRuntimeInfo{1, std::type_index(typeid(handle)), getCurrentBacktrace()}); } else { - context.logger.error("Handle {} already exists", ptr); + getContext()->logger.error("Handle {} already exists", ptr); return; } break; case REFCOUNT_INCREASE: if (it == counts.end()) { - context.logger.error( + getContext()->logger.error( "Attempting to retain nonexistent handle {}", ptr); return; } else { @@ -90,7 +90,7 @@ struct RefCountContext { } if (it->second.refCount < 0) { - context.logger.error( + getContext()->logger.error( "Attempting to release nonexistent handle {}", ptr); } else if (it->second.refCount == 0 && isAdapterHandle) { adapterCount--; @@ -98,8 +98,9 @@ struct RefCountContext { break; } - context.logger.debug("Reference count for handle {} changed to {}", ptr, - it->second.refCount); + getContext()->logger.debug( + "Reference count for handle {} changed to {}", ptr, + it->second.refCount); if (it->second.refCount == 0) { counts.erase(ptr); @@ -145,19 +146,20 @@ struct RefCountContext { void logInvalidReferences() { for (auto &[ptr, refRuntimeInfo] : counts) { - context.logger.error("Retained {} reference(s) to handle {}", - refRuntimeInfo.refCount, ptr); - context.logger.error("Handle {} was recorded for first time here:", - ptr); + getContext()->logger.error("Retained {} reference(s) to handle {}", + refRuntimeInfo.refCount, ptr); + getContext()->logger.error( + "Handle {} was recorded for first time here:", ptr); for (size_t i = 0; i < refRuntimeInfo.backtrace.size(); i++) { - context.logger.error("#{} {}", i, - refRuntimeInfo.backtrace[i].c_str()); + getContext()->logger.error("#{} {}", i, + refRuntimeInfo.backtrace[i].c_str()); } } } void logInvalidReference(void *ptr) { - context.logger.error("There are no valid references to handle {}", ptr); + getContext()->logger.error("There are no valid references to handle {}", + ptr); } } refCountContext; diff --git a/source/loader/layers/validation/ur_valddi.cpp b/source/loader/layers/validation/ur_valddi.cpp index 72f3790816..b6bf3df0a9 100644 --- a/source/loader/layers/validation/ur_valddi.cpp +++ b/source/loader/layers/validation/ur_valddi.cpp @@ -29,18 +29,18 @@ __urdlllocal ur_result_t UR_APICALL urAdapterGet( uint32_t * pNumAdapters ///< [out][optional] returns the total number of adapters available. ) { - auto pfnAdapterGet = context.urDdiTable.Global.pfnAdapterGet; + auto pfnAdapterGet = getContext()->urDdiTable.Global.pfnAdapterGet; if (nullptr == pfnAdapterGet) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { } ur_result_t result = pfnAdapterGet(NumEntries, phAdapters, pNumAdapters); - if (context.enableLeakChecking && phAdapters && + if (getContext()->enableLeakChecking && phAdapters && result == UR_RESULT_SUCCESS) { for (uint32_t i = 0; i < NumEntries; i++) { refCountContext.createOrIncrementRefCount(phAdapters[i], true); @@ -55,13 +55,13 @@ __urdlllocal ur_result_t UR_APICALL urAdapterGet( __urdlllocal ur_result_t UR_APICALL urAdapterRelease( ur_adapter_handle_t hAdapter ///< [in][release] Adapter handle to release ) { - auto pfnAdapterRelease = context.urDdiTable.Global.pfnAdapterRelease; + auto pfnAdapterRelease = getContext()->urDdiTable.Global.pfnAdapterRelease; if (nullptr == pfnAdapterRelease) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hAdapter) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -69,7 +69,7 @@ __urdlllocal ur_result_t UR_APICALL urAdapterRelease( ur_result_t result = pfnAdapterRelease(hAdapter); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.decrementRefCount(hAdapter, true); } @@ -81,13 +81,13 @@ __urdlllocal ur_result_t UR_APICALL urAdapterRelease( __urdlllocal ur_result_t UR_APICALL urAdapterRetain( ur_adapter_handle_t hAdapter ///< [in] Adapter handle to retain ) { - auto pfnAdapterRetain = context.urDdiTable.Global.pfnAdapterRetain; + auto pfnAdapterRetain = getContext()->urDdiTable.Global.pfnAdapterRetain; if (nullptr == pfnAdapterRetain) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hAdapter) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -95,7 +95,7 @@ __urdlllocal ur_result_t UR_APICALL urAdapterRetain( ur_result_t result = pfnAdapterRetain(hAdapter); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.incrementRefCount(hAdapter, true); } @@ -114,13 +114,13 @@ __urdlllocal ur_result_t UR_APICALL urAdapterGetLastError( ///< be stored. ) { auto pfnAdapterGetLastError = - context.urDdiTable.Global.pfnAdapterGetLastError; + getContext()->urDdiTable.Global.pfnAdapterGetLastError; if (nullptr == pfnAdapterGetLastError) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hAdapter) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -134,7 +134,7 @@ __urdlllocal ur_result_t UR_APICALL urAdapterGetLastError( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hAdapter)) { refCountContext.logInvalidReference(hAdapter); } @@ -159,13 +159,13 @@ __urdlllocal ur_result_t UR_APICALL urAdapterGetInfo( size_t * pPropSizeRet ///< [out][optional] pointer to the actual number of bytes being queried by pPropValue. ) { - auto pfnAdapterGetInfo = context.urDdiTable.Global.pfnAdapterGetInfo; + auto pfnAdapterGetInfo = getContext()->urDdiTable.Global.pfnAdapterGetInfo; if (nullptr == pfnAdapterGetInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hAdapter) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -187,7 +187,7 @@ __urdlllocal ur_result_t UR_APICALL urAdapterGetInfo( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hAdapter)) { refCountContext.logInvalidReference(hAdapter); } @@ -216,13 +216,13 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGet( uint32_t * pNumPlatforms ///< [out][optional] returns the total number of platforms available. ) { - auto pfnGet = context.urDdiTable.Platform.pfnGet; + auto pfnGet = getContext()->urDdiTable.Platform.pfnGet; if (nullptr == pfnGet) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == phAdapters) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } @@ -253,13 +253,13 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetInfo( size_t * pPropSizeRet ///< [out][optional] pointer to the actual number of bytes being queried by pPlatformInfo. ) { - auto pfnGetInfo = context.urDdiTable.Platform.pfnGetInfo; + auto pfnGetInfo = getContext()->urDdiTable.Platform.pfnGetInfo; if (nullptr == pfnGetInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hPlatform) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -293,13 +293,13 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetApiVersion( ur_platform_handle_t hPlatform, ///< [in] handle of the platform ur_api_version_t *pVersion ///< [out] api version ) { - auto pfnGetApiVersion = context.urDdiTable.Platform.pfnGetApiVersion; + auto pfnGetApiVersion = getContext()->urDdiTable.Platform.pfnGetApiVersion; if (nullptr == pfnGetApiVersion) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hPlatform) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -321,13 +321,14 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetNativeHandle( ur_native_handle_t * phNativePlatform ///< [out] a pointer to the native handle of the platform. ) { - auto pfnGetNativeHandle = context.urDdiTable.Platform.pfnGetNativeHandle; + auto pfnGetNativeHandle = + getContext()->urDdiTable.Platform.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hPlatform) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -355,13 +356,13 @@ __urdlllocal ur_result_t UR_APICALL urPlatformCreateWithNativeHandle( phPlatform ///< [out] pointer to the handle of the platform object created. ) { auto pfnCreateWithNativeHandle = - context.urDdiTable.Platform.pfnCreateWithNativeHandle; + getContext()->urDdiTable.Platform.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hAdapter) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -371,7 +372,7 @@ __urdlllocal ur_result_t UR_APICALL urPlatformCreateWithNativeHandle( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hAdapter)) { refCountContext.logInvalidReference(hAdapter); } @@ -392,13 +393,14 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetBackendOption( ppPlatformOption ///< [out] returns the correct platform specific compiler option based on ///< the frontend option. ) { - auto pfnGetBackendOption = context.urDdiTable.Platform.pfnGetBackendOption; + auto pfnGetBackendOption = + getContext()->urDdiTable.Platform.pfnGetBackendOption; if (nullptr == pfnGetBackendOption) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hPlatform) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -435,13 +437,13 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGet( uint32_t *pNumDevices ///< [out][optional] pointer to the number of devices. ///< pNumDevices will be updated with the total number of devices available. ) { - auto pfnGet = context.urDdiTable.Device.pfnGet; + auto pfnGet = getContext()->urDdiTable.Device.pfnGet; if (nullptr == pfnGet) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hPlatform) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -462,7 +464,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGet( ur_result_t result = pfnGet(hPlatform, DeviceType, NumEntries, phDevices, pNumDevices); - if (context.enableLeakChecking && phDevices && + if (getContext()->enableLeakChecking && phDevices && result == UR_RESULT_SUCCESS) { for (uint32_t i = 0; i < NumEntries; i++) { refCountContext.createOrIncrementRefCount(phDevices[i], false); @@ -488,13 +490,13 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetInfo( size_t * pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of the queried propName. ) { - auto pfnGetInfo = context.urDdiTable.Device.pfnGetInfo; + auto pfnGetInfo = getContext()->urDdiTable.Device.pfnGetInfo; if (nullptr == pfnGetInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hDevice) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -516,7 +518,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetInfo( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDevice)) { refCountContext.logInvalidReference(hDevice); } @@ -533,13 +535,13 @@ __urdlllocal ur_result_t UR_APICALL urDeviceRetain( ur_device_handle_t hDevice ///< [in] handle of the device to get a reference of. ) { - auto pfnRetain = context.urDdiTable.Device.pfnRetain; + auto pfnRetain = getContext()->urDdiTable.Device.pfnRetain; if (nullptr == pfnRetain) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hDevice) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -547,7 +549,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceRetain( ur_result_t result = pfnRetain(hDevice); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.incrementRefCount(hDevice, false); } @@ -560,13 +562,13 @@ __urdlllocal ur_result_t UR_APICALL urDeviceRelease( ur_device_handle_t hDevice ///< [in][release] handle of the device to release. ) { - auto pfnRelease = context.urDdiTable.Device.pfnRelease; + auto pfnRelease = getContext()->urDdiTable.Device.pfnRelease; if (nullptr == pfnRelease) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hDevice) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -574,7 +576,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceRelease( ur_result_t result = pfnRelease(hDevice); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.decrementRefCount(hDevice, false); } @@ -596,13 +598,13 @@ __urdlllocal ur_result_t UR_APICALL urDevicePartition( pNumDevicesRet ///< [out][optional] pointer to the number of sub-devices the device can be ///< partitioned into according to the partitioning property. ) { - auto pfnPartition = context.urDdiTable.Device.pfnPartition; + auto pfnPartition = getContext()->urDdiTable.Device.pfnPartition; if (nullptr == pfnPartition) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hDevice) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -616,7 +618,7 @@ __urdlllocal ur_result_t UR_APICALL urDevicePartition( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDevice)) { refCountContext.logInvalidReference(hDevice); } @@ -641,13 +643,13 @@ __urdlllocal ur_result_t UR_APICALL urDeviceSelectBinary( pSelectedBinary ///< [out] the index of the selected binary in the input array of binaries. ///< If a suitable binary was not found the function returns ::UR_RESULT_ERROR_INVALID_BINARY. ) { - auto pfnSelectBinary = context.urDdiTable.Device.pfnSelectBinary; + auto pfnSelectBinary = getContext()->urDdiTable.Device.pfnSelectBinary; if (nullptr == pfnSelectBinary) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hDevice) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -665,7 +667,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceSelectBinary( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDevice)) { refCountContext.logInvalidReference(hDevice); } @@ -683,13 +685,14 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetNativeHandle( ur_native_handle_t *phNativeDevice ///< [out] a pointer to the native handle of the device. ) { - auto pfnGetNativeHandle = context.urDdiTable.Device.pfnGetNativeHandle; + auto pfnGetNativeHandle = + getContext()->urDdiTable.Device.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hDevice) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -699,7 +702,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetNativeHandle( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDevice)) { refCountContext.logInvalidReference(hDevice); } @@ -721,13 +724,13 @@ __urdlllocal ur_result_t UR_APICALL urDeviceCreateWithNativeHandle( *phDevice ///< [out] pointer to the handle of the device object created. ) { auto pfnCreateWithNativeHandle = - context.urDdiTable.Device.pfnCreateWithNativeHandle; + getContext()->urDdiTable.Device.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hPlatform) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -740,7 +743,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceCreateWithNativeHandle( ur_result_t result = pfnCreateWithNativeHandle(hNativeDevice, hPlatform, pProperties, phDevice); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.createRefCount(*phDevice); } @@ -759,19 +762,19 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetGlobalTimestamps( ///< correlates with the Device's global timestamp value ) { auto pfnGetGlobalTimestamps = - context.urDdiTable.Device.pfnGetGlobalTimestamps; + getContext()->urDdiTable.Device.pfnGetGlobalTimestamps; if (nullptr == pfnGetGlobalTimestamps) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hDevice) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDevice)) { refCountContext.logInvalidReference(hDevice); } @@ -793,13 +796,13 @@ __urdlllocal ur_result_t UR_APICALL urContextCreate( ur_context_handle_t *phContext ///< [out] pointer to handle of context object created ) { - auto pfnCreate = context.urDdiTable.Context.pfnCreate; + auto pfnCreate = getContext()->urDdiTable.Context.pfnCreate; if (nullptr == pfnCreate) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == phDevices) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } @@ -816,7 +819,7 @@ __urdlllocal ur_result_t UR_APICALL urContextCreate( ur_result_t result = pfnCreate(DeviceCount, phDevices, pProperties, phContext); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.createRefCount(*phContext); } @@ -829,13 +832,13 @@ __urdlllocal ur_result_t UR_APICALL urContextRetain( ur_context_handle_t hContext ///< [in] handle of the context to get a reference of. ) { - auto pfnRetain = context.urDdiTable.Context.pfnRetain; + auto pfnRetain = getContext()->urDdiTable.Context.pfnRetain; if (nullptr == pfnRetain) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -843,7 +846,7 @@ __urdlllocal ur_result_t UR_APICALL urContextRetain( ur_result_t result = pfnRetain(hContext); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.incrementRefCount(hContext, false); } @@ -856,13 +859,13 @@ __urdlllocal ur_result_t UR_APICALL urContextRelease( ur_context_handle_t hContext ///< [in][release] handle of the context to release. ) { - auto pfnRelease = context.urDdiTable.Context.pfnRelease; + auto pfnRelease = getContext()->urDdiTable.Context.pfnRelease; if (nullptr == pfnRelease) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -870,7 +873,7 @@ __urdlllocal ur_result_t UR_APICALL urContextRelease( ur_result_t result = pfnRelease(hContext); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.decrementRefCount(hContext, false); } @@ -894,13 +897,13 @@ __urdlllocal ur_result_t UR_APICALL urContextGetInfo( size_t * pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of the queried propName. ) { - auto pfnGetInfo = context.urDdiTable.Context.pfnGetInfo; + auto pfnGetInfo = getContext()->urDdiTable.Context.pfnGetInfo; if (nullptr == pfnGetInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -922,7 +925,7 @@ __urdlllocal ur_result_t UR_APICALL urContextGetInfo( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } @@ -940,13 +943,14 @@ __urdlllocal ur_result_t UR_APICALL urContextGetNativeHandle( ur_native_handle_t * phNativeContext ///< [out] a pointer to the native handle of the context. ) { - auto pfnGetNativeHandle = context.urDdiTable.Context.pfnGetNativeHandle; + auto pfnGetNativeHandle = + getContext()->urDdiTable.Context.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -956,7 +960,7 @@ __urdlllocal ur_result_t UR_APICALL urContextGetNativeHandle( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } @@ -980,13 +984,13 @@ __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( phContext ///< [out] pointer to the handle of the context object created. ) { auto pfnCreateWithNativeHandle = - context.urDdiTable.Context.pfnCreateWithNativeHandle; + getContext()->urDdiTable.Context.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == phDevices) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } @@ -999,7 +1003,7 @@ __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( ur_result_t result = pfnCreateWithNativeHandle( hNativeContext, numDevices, phDevices, pProperties, phContext); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.createRefCount(*phContext); } @@ -1016,13 +1020,13 @@ __urdlllocal ur_result_t UR_APICALL urContextSetExtendedDeleter( pUserData ///< [in][out][optional] pointer to data to be passed to callback. ) { auto pfnSetExtendedDeleter = - context.urDdiTable.Context.pfnSetExtendedDeleter; + getContext()->urDdiTable.Context.pfnSetExtendedDeleter; if (nullptr == pfnSetExtendedDeleter) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -1032,7 +1036,7 @@ __urdlllocal ur_result_t UR_APICALL urContextSetExtendedDeleter( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } @@ -1053,13 +1057,13 @@ __urdlllocal ur_result_t UR_APICALL urMemImageCreate( void *pHost, ///< [in][optional] pointer to the buffer data ur_mem_handle_t *phMem ///< [out] pointer to handle of image object created ) { - auto pfnImageCreate = context.urDdiTable.Mem.pfnImageCreate; + auto pfnImageCreate = getContext()->urDdiTable.Mem.pfnImageCreate; if (nullptr == pfnImageCreate) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -1113,7 +1117,7 @@ __urdlllocal ur_result_t UR_APICALL urMemImageCreate( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } @@ -1121,7 +1125,7 @@ __urdlllocal ur_result_t UR_APICALL urMemImageCreate( ur_result_t result = pfnImageCreate(hContext, flags, pImageFormat, pImageDesc, pHost, phMem); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.createRefCount(*phMem); } @@ -1139,13 +1143,13 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreate( ur_mem_handle_t *phBuffer ///< [out] pointer to handle of the memory buffer created ) { - auto pfnBufferCreate = context.urDdiTable.Mem.pfnBufferCreate; + auto pfnBufferCreate = getContext()->urDdiTable.Mem.pfnBufferCreate; if (nullptr == pfnBufferCreate) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -1181,7 +1185,7 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreate( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } @@ -1189,7 +1193,7 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreate( ur_result_t result = pfnBufferCreate(hContext, flags, size, pProperties, phBuffer); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.createRefCount(*phBuffer); } @@ -1201,13 +1205,13 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreate( __urdlllocal ur_result_t UR_APICALL urMemRetain( ur_mem_handle_t hMem ///< [in] handle of the memory object to get access ) { - auto pfnRetain = context.urDdiTable.Mem.pfnRetain; + auto pfnRetain = getContext()->urDdiTable.Mem.pfnRetain; if (nullptr == pfnRetain) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hMem) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -1215,7 +1219,7 @@ __urdlllocal ur_result_t UR_APICALL urMemRetain( ur_result_t result = pfnRetain(hMem); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.incrementRefCount(hMem, false); } @@ -1228,13 +1232,13 @@ __urdlllocal ur_result_t UR_APICALL urMemRelease( ur_mem_handle_t hMem ///< [in][release] handle of the memory object to release ) { - auto pfnRelease = context.urDdiTable.Mem.pfnRelease; + auto pfnRelease = getContext()->urDdiTable.Mem.pfnRelease; if (nullptr == pfnRelease) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hMem) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -1242,7 +1246,7 @@ __urdlllocal ur_result_t UR_APICALL urMemRelease( ur_result_t result = pfnRelease(hMem); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.decrementRefCount(hMem, false); } @@ -1261,13 +1265,13 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferPartition( ur_mem_handle_t *phMem ///< [out] pointer to the handle of sub buffer created ) { - auto pfnBufferPartition = context.urDdiTable.Mem.pfnBufferPartition; + auto pfnBufferPartition = getContext()->urDdiTable.Mem.pfnBufferPartition; if (nullptr == pfnBufferPartition) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hBuffer) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -1293,7 +1297,7 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferPartition( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hBuffer)) { refCountContext.logInvalidReference(hBuffer); } @@ -1314,13 +1318,13 @@ __urdlllocal ur_result_t UR_APICALL urMemGetNativeHandle( ur_native_handle_t *phNativeMem ///< [out] a pointer to the native handle of the mem. ) { - auto pfnGetNativeHandle = context.urDdiTable.Mem.pfnGetNativeHandle; + auto pfnGetNativeHandle = getContext()->urDdiTable.Mem.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hMem) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -1330,12 +1334,12 @@ __urdlllocal ur_result_t UR_APICALL urMemGetNativeHandle( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hMem)) { refCountContext.logInvalidReference(hMem); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDevice)) { refCountContext.logInvalidReference(hDevice); } @@ -1357,13 +1361,13 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( *phMem ///< [out] pointer to handle of buffer memory object created. ) { auto pfnBufferCreateWithNativeHandle = - context.urDdiTable.Mem.pfnBufferCreateWithNativeHandle; + getContext()->urDdiTable.Mem.pfnBufferCreateWithNativeHandle; if (nullptr == pfnBufferCreateWithNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -1373,7 +1377,7 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } @@ -1381,7 +1385,7 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( ur_result_t result = pfnBufferCreateWithNativeHandle(hNativeMem, hContext, pProperties, phMem); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.createRefCount(*phMem); } @@ -1403,13 +1407,13 @@ __urdlllocal ur_result_t UR_APICALL urMemImageCreateWithNativeHandle( *phMem ///< [out] pointer to handle of image memory object created. ) { auto pfnImageCreateWithNativeHandle = - context.urDdiTable.Mem.pfnImageCreateWithNativeHandle; + getContext()->urDdiTable.Mem.pfnImageCreateWithNativeHandle; if (nullptr == pfnImageCreateWithNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -1427,7 +1431,7 @@ __urdlllocal ur_result_t UR_APICALL urMemImageCreateWithNativeHandle( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } @@ -1435,7 +1439,7 @@ __urdlllocal ur_result_t UR_APICALL urMemImageCreateWithNativeHandle( ur_result_t result = pfnImageCreateWithNativeHandle( hNativeMem, hContext, pImageFormat, pImageDesc, pProperties, phMem); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.createRefCount(*phMem); } @@ -1459,13 +1463,13 @@ __urdlllocal ur_result_t UR_APICALL urMemGetInfo( size_t * pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of the queried propName. ) { - auto pfnGetInfo = context.urDdiTable.Mem.pfnGetInfo; + auto pfnGetInfo = getContext()->urDdiTable.Mem.pfnGetInfo; if (nullptr == pfnGetInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hMemory) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -1487,7 +1491,7 @@ __urdlllocal ur_result_t UR_APICALL urMemGetInfo( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hMemory)) { refCountContext.logInvalidReference(hMemory); } @@ -1514,13 +1518,13 @@ __urdlllocal ur_result_t UR_APICALL urMemImageGetInfo( size_t * pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of the queried propName. ) { - auto pfnImageGetInfo = context.urDdiTable.Mem.pfnImageGetInfo; + auto pfnImageGetInfo = getContext()->urDdiTable.Mem.pfnImageGetInfo; if (nullptr == pfnImageGetInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hMemory) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -1542,7 +1546,7 @@ __urdlllocal ur_result_t UR_APICALL urMemImageGetInfo( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hMemory)) { refCountContext.logInvalidReference(hMemory); } @@ -1561,13 +1565,13 @@ __urdlllocal ur_result_t UR_APICALL urSamplerCreate( ur_sampler_handle_t *phSampler ///< [out] pointer to handle of sampler object created ) { - auto pfnCreate = context.urDdiTable.Sampler.pfnCreate; + auto pfnCreate = getContext()->urDdiTable.Sampler.pfnCreate; if (nullptr == pfnCreate) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -1590,14 +1594,14 @@ __urdlllocal ur_result_t UR_APICALL urSamplerCreate( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } ur_result_t result = pfnCreate(hContext, pDesc, phSampler); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.createRefCount(*phSampler); } @@ -1610,13 +1614,13 @@ __urdlllocal ur_result_t UR_APICALL urSamplerRetain( ur_sampler_handle_t hSampler ///< [in] handle of the sampler object to get access ) { - auto pfnRetain = context.urDdiTable.Sampler.pfnRetain; + auto pfnRetain = getContext()->urDdiTable.Sampler.pfnRetain; if (nullptr == pfnRetain) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hSampler) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -1624,7 +1628,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerRetain( ur_result_t result = pfnRetain(hSampler); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.incrementRefCount(hSampler, false); } @@ -1637,13 +1641,13 @@ __urdlllocal ur_result_t UR_APICALL urSamplerRelease( ur_sampler_handle_t hSampler ///< [in][release] handle of the sampler object to release ) { - auto pfnRelease = context.urDdiTable.Sampler.pfnRelease; + auto pfnRelease = getContext()->urDdiTable.Sampler.pfnRelease; if (nullptr == pfnRelease) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hSampler) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -1651,7 +1655,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerRelease( ur_result_t result = pfnRelease(hSampler); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.decrementRefCount(hSampler, false); } @@ -1671,13 +1675,13 @@ __urdlllocal ur_result_t UR_APICALL urSamplerGetInfo( size_t * pPropSizeRet ///< [out][optional] size in bytes returned in sampler property value ) { - auto pfnGetInfo = context.urDdiTable.Sampler.pfnGetInfo; + auto pfnGetInfo = getContext()->urDdiTable.Sampler.pfnGetInfo; if (nullptr == pfnGetInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hSampler) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -1699,7 +1703,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerGetInfo( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hSampler)) { refCountContext.logInvalidReference(hSampler); } @@ -1717,13 +1721,14 @@ __urdlllocal ur_result_t UR_APICALL urSamplerGetNativeHandle( ur_native_handle_t * phNativeSampler ///< [out] a pointer to the native handle of the sampler. ) { - auto pfnGetNativeHandle = context.urDdiTable.Sampler.pfnGetNativeHandle; + auto pfnGetNativeHandle = + getContext()->urDdiTable.Sampler.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hSampler) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -1733,7 +1738,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerGetNativeHandle( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hSampler)) { refCountContext.logInvalidReference(hSampler); } @@ -1755,13 +1760,13 @@ __urdlllocal ur_result_t UR_APICALL urSamplerCreateWithNativeHandle( phSampler ///< [out] pointer to the handle of the sampler object created. ) { auto pfnCreateWithNativeHandle = - context.urDdiTable.Sampler.pfnCreateWithNativeHandle; + getContext()->urDdiTable.Sampler.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -1771,7 +1776,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerCreateWithNativeHandle( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } @@ -1779,7 +1784,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerCreateWithNativeHandle( ur_result_t result = pfnCreateWithNativeHandle(hNativeSampler, hContext, pProperties, phSampler); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.createRefCount(*phSampler); } @@ -1798,13 +1803,13 @@ __urdlllocal ur_result_t UR_APICALL urUSMHostAlloc( size, ///< [in] minimum size in bytes of the USM memory object to be allocated void **ppMem ///< [out] pointer to USM host memory object ) { - auto pfnHostAlloc = context.urDdiTable.USM.pfnHostAlloc; + auto pfnHostAlloc = getContext()->urDdiTable.USM.pfnHostAlloc; if (nullptr == pfnHostAlloc) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -1827,12 +1832,12 @@ __urdlllocal ur_result_t UR_APICALL urUSMHostAlloc( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(pool)) { refCountContext.logInvalidReference(pool); } @@ -1855,13 +1860,13 @@ __urdlllocal ur_result_t UR_APICALL urUSMDeviceAlloc( size, ///< [in] minimum size in bytes of the USM memory object to be allocated void **ppMem ///< [out] pointer to USM device memory object ) { - auto pfnDeviceAlloc = context.urDdiTable.USM.pfnDeviceAlloc; + auto pfnDeviceAlloc = getContext()->urDdiTable.USM.pfnDeviceAlloc; if (nullptr == pfnDeviceAlloc) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -1888,17 +1893,17 @@ __urdlllocal ur_result_t UR_APICALL urUSMDeviceAlloc( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDevice)) { refCountContext.logInvalidReference(hDevice); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(pool)) { refCountContext.logInvalidReference(pool); } @@ -1922,13 +1927,13 @@ __urdlllocal ur_result_t UR_APICALL urUSMSharedAlloc( size, ///< [in] minimum size in bytes of the USM memory object to be allocated void **ppMem ///< [out] pointer to USM shared memory object ) { - auto pfnSharedAlloc = context.urDdiTable.USM.pfnSharedAlloc; + auto pfnSharedAlloc = getContext()->urDdiTable.USM.pfnSharedAlloc; if (nullptr == pfnSharedAlloc) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -1955,17 +1960,17 @@ __urdlllocal ur_result_t UR_APICALL urUSMSharedAlloc( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDevice)) { refCountContext.logInvalidReference(hDevice); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(pool)) { refCountContext.logInvalidReference(pool); } @@ -1982,13 +1987,13 @@ __urdlllocal ur_result_t UR_APICALL urUSMFree( ur_context_handle_t hContext, ///< [in] handle of the context object void *pMem ///< [in] pointer to USM memory object ) { - auto pfnFree = context.urDdiTable.USM.pfnFree; + auto pfnFree = getContext()->urDdiTable.USM.pfnFree; if (nullptr == pfnFree) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -1998,7 +2003,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMFree( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } @@ -2023,13 +2028,13 @@ __urdlllocal ur_result_t UR_APICALL urUSMGetMemAllocInfo( size_t * pPropSizeRet ///< [out][optional] bytes returned in USM allocation property ) { - auto pfnGetMemAllocInfo = context.urDdiTable.USM.pfnGetMemAllocInfo; + auto pfnGetMemAllocInfo = getContext()->urDdiTable.USM.pfnGetMemAllocInfo; if (nullptr == pfnGetMemAllocInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -2043,7 +2048,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMGetMemAllocInfo( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } @@ -2063,13 +2068,13 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolCreate( ///< ::ur_usm_pool_limits_desc_t ur_usm_pool_handle_t *ppPool ///< [out] pointer to USM memory pool ) { - auto pfnPoolCreate = context.urDdiTable.USM.pfnPoolCreate; + auto pfnPoolCreate = getContext()->urDdiTable.USM.pfnPoolCreate; if (nullptr == pfnPoolCreate) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -2087,14 +2092,14 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolCreate( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } ur_result_t result = pfnPoolCreate(hContext, pPoolDesc, ppPool); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.createRefCount(*ppPool); } @@ -2106,13 +2111,13 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolCreate( __urdlllocal ur_result_t UR_APICALL urUSMPoolRetain( ur_usm_pool_handle_t pPool ///< [in] pointer to USM memory pool ) { - auto pfnPoolRetain = context.urDdiTable.USM.pfnPoolRetain; + auto pfnPoolRetain = getContext()->urDdiTable.USM.pfnPoolRetain; if (nullptr == pfnPoolRetain) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == pPool) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -2120,7 +2125,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolRetain( ur_result_t result = pfnPoolRetain(pPool); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.incrementRefCount(pPool, false); } @@ -2132,13 +2137,13 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolRetain( __urdlllocal ur_result_t UR_APICALL urUSMPoolRelease( ur_usm_pool_handle_t pPool ///< [in][release] pointer to USM memory pool ) { - auto pfnPoolRelease = context.urDdiTable.USM.pfnPoolRelease; + auto pfnPoolRelease = getContext()->urDdiTable.USM.pfnPoolRelease; if (nullptr == pfnPoolRelease) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == pPool) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -2146,7 +2151,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolRelease( ur_result_t result = pfnPoolRelease(pPool); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.decrementRefCount(pPool, false); } @@ -2165,13 +2170,13 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolGetInfo( size_t * pPropSizeRet ///< [out][optional] size in bytes returned in pool property value ) { - auto pfnPoolGetInfo = context.urDdiTable.USM.pfnPoolGetInfo; + auto pfnPoolGetInfo = getContext()->urDdiTable.USM.pfnPoolGetInfo; if (nullptr == pfnPoolGetInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hPool) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -2193,7 +2198,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolGetInfo( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hPool)) { refCountContext.logInvalidReference(hPool); } @@ -2224,13 +2229,13 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemGranularityGetInfo( pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of the queried propName." ) { auto pfnGranularityGetInfo = - context.urDdiTable.VirtualMem.pfnGranularityGetInfo; + getContext()->urDdiTable.VirtualMem.pfnGranularityGetInfo; if (nullptr == pfnGranularityGetInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -2252,12 +2257,12 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemGranularityGetInfo( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDevice)) { refCountContext.logInvalidReference(hDevice); } @@ -2282,13 +2287,13 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemReserve( ppStart ///< [out] pointer to the returned address at the start of reserved virtual ///< memory range. ) { - auto pfnReserve = context.urDdiTable.VirtualMem.pfnReserve; + auto pfnReserve = getContext()->urDdiTable.VirtualMem.pfnReserve; if (nullptr == pfnReserve) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -2298,7 +2303,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemReserve( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } @@ -2316,13 +2321,13 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemFree( pStart, ///< [in] pointer to the start of the virtual memory range to free. size_t size ///< [in] size in bytes of the virtual memory range to free. ) { - auto pfnFree = context.urDdiTable.VirtualMem.pfnFree; + auto pfnFree = getContext()->urDdiTable.VirtualMem.pfnFree; if (nullptr == pfnFree) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -2332,7 +2337,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemFree( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } @@ -2356,13 +2361,13 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemMap( ur_virtual_mem_access_flags_t flags ///< [in] access flags for the physical memory mapping. ) { - auto pfnMap = context.urDdiTable.VirtualMem.pfnMap; + auto pfnMap = getContext()->urDdiTable.VirtualMem.pfnMap; if (nullptr == pfnMap) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -2380,12 +2385,12 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemMap( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hPhysicalMem)) { refCountContext.logInvalidReference(hPhysicalMem); } @@ -2404,13 +2409,13 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemUnmap( pStart, ///< [in] pointer to the start of the mapped virtual memory range size_t size ///< [in] size in bytes of the virtual memory range. ) { - auto pfnUnmap = context.urDdiTable.VirtualMem.pfnUnmap; + auto pfnUnmap = getContext()->urDdiTable.VirtualMem.pfnUnmap; if (nullptr == pfnUnmap) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -2420,7 +2425,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemUnmap( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } @@ -2440,13 +2445,13 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemSetAccess( ur_virtual_mem_access_flags_t flags ///< [in] access flags to set for the mapped virtual memory range. ) { - auto pfnSetAccess = context.urDdiTable.VirtualMem.pfnSetAccess; + auto pfnSetAccess = getContext()->urDdiTable.VirtualMem.pfnSetAccess; if (nullptr == pfnSetAccess) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -2460,7 +2465,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemSetAccess( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } @@ -2488,13 +2493,13 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemGetInfo( size_t * pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of the queried propName." ) { - auto pfnGetInfo = context.urDdiTable.VirtualMem.pfnGetInfo; + auto pfnGetInfo = getContext()->urDdiTable.VirtualMem.pfnGetInfo; if (nullptr == pfnGetInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -2508,7 +2513,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemGetInfo( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } @@ -2532,13 +2537,13 @@ __urdlllocal ur_result_t UR_APICALL urPhysicalMemCreate( ur_physical_mem_handle_t * phPhysicalMem ///< [out] pointer to handle of physical memory object created. ) { - auto pfnCreate = context.urDdiTable.PhysicalMem.pfnCreate; + auto pfnCreate = getContext()->urDdiTable.PhysicalMem.pfnCreate; if (nullptr == pfnCreate) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -2557,12 +2562,12 @@ __urdlllocal ur_result_t UR_APICALL urPhysicalMemCreate( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDevice)) { refCountContext.logInvalidReference(hDevice); } @@ -2570,7 +2575,7 @@ __urdlllocal ur_result_t UR_APICALL urPhysicalMemCreate( ur_result_t result = pfnCreate(hContext, hDevice, size, pProperties, phPhysicalMem); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.createRefCount(*phPhysicalMem); } @@ -2583,13 +2588,13 @@ __urdlllocal ur_result_t UR_APICALL urPhysicalMemRetain( ur_physical_mem_handle_t hPhysicalMem ///< [in] handle of the physical memory object to retain. ) { - auto pfnRetain = context.urDdiTable.PhysicalMem.pfnRetain; + auto pfnRetain = getContext()->urDdiTable.PhysicalMem.pfnRetain; if (nullptr == pfnRetain) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hPhysicalMem) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -2597,7 +2602,7 @@ __urdlllocal ur_result_t UR_APICALL urPhysicalMemRetain( ur_result_t result = pfnRetain(hPhysicalMem); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.incrementRefCount(hPhysicalMem, false); } @@ -2610,13 +2615,13 @@ __urdlllocal ur_result_t UR_APICALL urPhysicalMemRelease( ur_physical_mem_handle_t hPhysicalMem ///< [in][release] handle of the physical memory object to release. ) { - auto pfnRelease = context.urDdiTable.PhysicalMem.pfnRelease; + auto pfnRelease = getContext()->urDdiTable.PhysicalMem.pfnRelease; if (nullptr == pfnRelease) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hPhysicalMem) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -2624,7 +2629,7 @@ __urdlllocal ur_result_t UR_APICALL urPhysicalMemRelease( ur_result_t result = pfnRelease(hPhysicalMem); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.decrementRefCount(hPhysicalMem, false); } @@ -2642,13 +2647,13 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithIL( ur_program_handle_t *phProgram ///< [out] pointer to handle of program object created. ) { - auto pfnCreateWithIL = context.urDdiTable.Program.pfnCreateWithIL; + auto pfnCreateWithIL = getContext()->urDdiTable.Program.pfnCreateWithIL; if (nullptr == pfnCreateWithIL) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -2676,7 +2681,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithIL( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } @@ -2684,7 +2689,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithIL( ur_result_t result = pfnCreateWithIL(hContext, pIL, length, pProperties, phProgram); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.createRefCount(*phProgram); } @@ -2704,13 +2709,14 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithBinary( ur_program_handle_t *phProgram ///< [out] pointer to handle of Program object created. ) { - auto pfnCreateWithBinary = context.urDdiTable.Program.pfnCreateWithBinary; + auto pfnCreateWithBinary = + getContext()->urDdiTable.Program.pfnCreateWithBinary; if (nullptr == pfnCreateWithBinary) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -2738,12 +2744,12 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithBinary( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDevice)) { refCountContext.logInvalidReference(hDevice); } @@ -2751,7 +2757,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithBinary( ur_result_t result = pfnCreateWithBinary(hContext, hDevice, size, pBinary, pProperties, phProgram); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.createRefCount(*phProgram); } @@ -2766,13 +2772,13 @@ __urdlllocal ur_result_t UR_APICALL urProgramBuild( const char * pOptions ///< [in][optional] pointer to build options null-terminated string. ) { - auto pfnBuild = context.urDdiTable.Program.pfnBuild; + auto pfnBuild = getContext()->urDdiTable.Program.pfnBuild; if (nullptr == pfnBuild) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -2782,12 +2788,12 @@ __urdlllocal ur_result_t UR_APICALL urProgramBuild( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hProgram)) { refCountContext.logInvalidReference(hProgram); } @@ -2806,13 +2812,13 @@ __urdlllocal ur_result_t UR_APICALL urProgramCompile( const char * pOptions ///< [in][optional] pointer to build options null-terminated string. ) { - auto pfnCompile = context.urDdiTable.Program.pfnCompile; + auto pfnCompile = getContext()->urDdiTable.Program.pfnCompile; if (nullptr == pfnCompile) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -2822,12 +2828,12 @@ __urdlllocal ur_result_t UR_APICALL urProgramCompile( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hProgram)) { refCountContext.logInvalidReference(hProgram); } @@ -2849,13 +2855,13 @@ __urdlllocal ur_result_t UR_APICALL urProgramLink( ur_program_handle_t *phProgram ///< [out] pointer to handle of program object created. ) { - auto pfnLink = context.urDdiTable.Program.pfnLink; + auto pfnLink = getContext()->urDdiTable.Program.pfnLink; if (nullptr == pfnLink) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -2873,7 +2879,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramLink( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } @@ -2889,13 +2895,13 @@ __urdlllocal ur_result_t UR_APICALL urProgramLink( __urdlllocal ur_result_t UR_APICALL urProgramRetain( ur_program_handle_t hProgram ///< [in] handle for the Program to retain ) { - auto pfnRetain = context.urDdiTable.Program.pfnRetain; + auto pfnRetain = getContext()->urDdiTable.Program.pfnRetain; if (nullptr == pfnRetain) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hProgram) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -2903,7 +2909,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramRetain( ur_result_t result = pfnRetain(hProgram); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.incrementRefCount(hProgram, false); } @@ -2916,13 +2922,13 @@ __urdlllocal ur_result_t UR_APICALL urProgramRelease( ur_program_handle_t hProgram ///< [in][release] handle for the Program to release ) { - auto pfnRelease = context.urDdiTable.Program.pfnRelease; + auto pfnRelease = getContext()->urDdiTable.Program.pfnRelease; if (nullptr == pfnRelease) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hProgram) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -2930,7 +2936,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramRelease( ur_result_t result = pfnRelease(hProgram); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.decrementRefCount(hProgram, false); } @@ -2952,13 +2958,13 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetFunctionPointer( ppFunctionPointer ///< [out] Returns the pointer to the function if it is found in the program. ) { auto pfnGetFunctionPointer = - context.urDdiTable.Program.pfnGetFunctionPointer; + getContext()->urDdiTable.Program.pfnGetFunctionPointer; if (nullptr == pfnGetFunctionPointer) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hDevice) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -2976,12 +2982,12 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetFunctionPointer( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDevice)) { refCountContext.logInvalidReference(hDevice); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hProgram)) { refCountContext.logInvalidReference(hProgram); } @@ -3008,13 +3014,13 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetGlobalVariablePointer( ppGlobalVariablePointerRet ///< [out] Returns the pointer to the global variable if it is found in the program. ) { auto pfnGetGlobalVariablePointer = - context.urDdiTable.Program.pfnGetGlobalVariablePointer; + getContext()->urDdiTable.Program.pfnGetGlobalVariablePointer; if (nullptr == pfnGetGlobalVariablePointer) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hDevice) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -3032,12 +3038,12 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetGlobalVariablePointer( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDevice)) { refCountContext.logInvalidReference(hDevice); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hProgram)) { refCountContext.logInvalidReference(hProgram); } @@ -3065,13 +3071,13 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetInfo( size_t * pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of the queried propName. ) { - auto pfnGetInfo = context.urDdiTable.Program.pfnGetInfo; + auto pfnGetInfo = getContext()->urDdiTable.Program.pfnGetInfo; if (nullptr == pfnGetInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hProgram) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -3093,7 +3099,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetInfo( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hProgram)) { refCountContext.logInvalidReference(hProgram); } @@ -3122,13 +3128,13 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetBuildInfo( pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of data being ///< queried by propName. ) { - auto pfnGetBuildInfo = context.urDdiTable.Program.pfnGetBuildInfo; + auto pfnGetBuildInfo = getContext()->urDdiTable.Program.pfnGetBuildInfo; if (nullptr == pfnGetBuildInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hProgram) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -3142,12 +3148,12 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetBuildInfo( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hProgram)) { refCountContext.logInvalidReference(hProgram); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDevice)) { refCountContext.logInvalidReference(hDevice); } @@ -3168,13 +3174,13 @@ __urdlllocal ur_result_t UR_APICALL urProgramSetSpecializationConstants( ///< descriptions ) { auto pfnSetSpecializationConstants = - context.urDdiTable.Program.pfnSetSpecializationConstants; + getContext()->urDdiTable.Program.pfnSetSpecializationConstants; if (nullptr == pfnSetSpecializationConstants) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hProgram) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -3188,7 +3194,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramSetSpecializationConstants( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hProgram)) { refCountContext.logInvalidReference(hProgram); } @@ -3206,13 +3212,14 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetNativeHandle( ur_native_handle_t * phNativeProgram ///< [out] a pointer to the native handle of the program. ) { - auto pfnGetNativeHandle = context.urDdiTable.Program.pfnGetNativeHandle; + auto pfnGetNativeHandle = + getContext()->urDdiTable.Program.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hProgram) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -3222,7 +3229,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetNativeHandle( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hProgram)) { refCountContext.logInvalidReference(hProgram); } @@ -3244,13 +3251,13 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithNativeHandle( phProgram ///< [out] pointer to the handle of the program object created. ) { auto pfnCreateWithNativeHandle = - context.urDdiTable.Program.pfnCreateWithNativeHandle; + getContext()->urDdiTable.Program.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -3260,7 +3267,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithNativeHandle( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } @@ -3268,7 +3275,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithNativeHandle( ur_result_t result = pfnCreateWithNativeHandle(hNativeProgram, hContext, pProperties, phProgram); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.createRefCount(*phProgram); } @@ -3283,13 +3290,13 @@ __urdlllocal ur_result_t UR_APICALL urKernelCreate( ur_kernel_handle_t *phKernel ///< [out] pointer to handle of kernel object created. ) { - auto pfnCreate = context.urDdiTable.Kernel.pfnCreate; + auto pfnCreate = getContext()->urDdiTable.Kernel.pfnCreate; if (nullptr == pfnCreate) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hProgram) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -3303,14 +3310,14 @@ __urdlllocal ur_result_t UR_APICALL urKernelCreate( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hProgram)) { refCountContext.logInvalidReference(hProgram); } ur_result_t result = pfnCreate(hProgram, pKernelName, phKernel); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.createRefCount(*phKernel); } @@ -3328,13 +3335,13 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgValue( const void *pArgValue ///< [in] argument value represented as matching arg type. ) { - auto pfnSetArgValue = context.urDdiTable.Kernel.pfnSetArgValue; + auto pfnSetArgValue = getContext()->urDdiTable.Kernel.pfnSetArgValue; if (nullptr == pfnSetArgValue) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hKernel) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -3344,7 +3351,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgValue( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hKernel)) { refCountContext.logInvalidReference(hKernel); } @@ -3365,19 +3372,19 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgLocal( const ur_kernel_arg_local_properties_t *pProperties ///< [in][optional] pointer to local buffer properties. ) { - auto pfnSetArgLocal = context.urDdiTable.Kernel.pfnSetArgLocal; + auto pfnSetArgLocal = getContext()->urDdiTable.Kernel.pfnSetArgLocal; if (nullptr == pfnSetArgLocal) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hKernel) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hKernel)) { refCountContext.logInvalidReference(hKernel); } @@ -3405,13 +3412,13 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetInfo( pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of data being ///< queried by propName. ) { - auto pfnGetInfo = context.urDdiTable.Kernel.pfnGetInfo; + auto pfnGetInfo = getContext()->urDdiTable.Kernel.pfnGetInfo; if (nullptr == pfnGetInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hKernel) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -3433,7 +3440,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetInfo( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hKernel)) { refCountContext.logInvalidReference(hKernel); } @@ -3459,13 +3466,13 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetGroupInfo( pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of data being ///< queried by propName. ) { - auto pfnGetGroupInfo = context.urDdiTable.Kernel.pfnGetGroupInfo; + auto pfnGetGroupInfo = getContext()->urDdiTable.Kernel.pfnGetGroupInfo; if (nullptr == pfnGetGroupInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hKernel) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -3479,12 +3486,12 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetGroupInfo( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hKernel)) { refCountContext.logInvalidReference(hKernel); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDevice)) { refCountContext.logInvalidReference(hDevice); } @@ -3510,13 +3517,14 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetSubGroupInfo( pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of data being ///< queried by propName. ) { - auto pfnGetSubGroupInfo = context.urDdiTable.Kernel.pfnGetSubGroupInfo; + auto pfnGetSubGroupInfo = + getContext()->urDdiTable.Kernel.pfnGetSubGroupInfo; if (nullptr == pfnGetSubGroupInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hKernel) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -3530,12 +3538,12 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetSubGroupInfo( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hKernel)) { refCountContext.logInvalidReference(hKernel); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDevice)) { refCountContext.logInvalidReference(hDevice); } @@ -3551,13 +3559,13 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetSubGroupInfo( __urdlllocal ur_result_t UR_APICALL urKernelRetain( ur_kernel_handle_t hKernel ///< [in] handle for the Kernel to retain ) { - auto pfnRetain = context.urDdiTable.Kernel.pfnRetain; + auto pfnRetain = getContext()->urDdiTable.Kernel.pfnRetain; if (nullptr == pfnRetain) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hKernel) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -3565,7 +3573,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelRetain( ur_result_t result = pfnRetain(hKernel); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.incrementRefCount(hKernel, false); } @@ -3578,13 +3586,13 @@ __urdlllocal ur_result_t UR_APICALL urKernelRelease( ur_kernel_handle_t hKernel ///< [in][release] handle for the Kernel to release ) { - auto pfnRelease = context.urDdiTable.Kernel.pfnRelease; + auto pfnRelease = getContext()->urDdiTable.Kernel.pfnRelease; if (nullptr == pfnRelease) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hKernel) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -3592,7 +3600,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelRelease( ur_result_t result = pfnRelease(hKernel); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.decrementRefCount(hKernel, false); } @@ -3610,19 +3618,19 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgPointer( pArgValue ///< [in][optional] Pointer obtained by USM allocation or virtual memory ///< mapping operation. If null then argument value is considered null. ) { - auto pfnSetArgPointer = context.urDdiTable.Kernel.pfnSetArgPointer; + auto pfnSetArgPointer = getContext()->urDdiTable.Kernel.pfnSetArgPointer; if (nullptr == pfnSetArgPointer) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hKernel) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hKernel)) { refCountContext.logInvalidReference(hKernel); } @@ -3645,13 +3653,13 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetExecInfo( pPropValue ///< [in][typename(propName, propSize)] pointer to memory location holding ///< the property value. ) { - auto pfnSetExecInfo = context.urDdiTable.Kernel.pfnSetExecInfo; + auto pfnSetExecInfo = getContext()->urDdiTable.Kernel.pfnSetExecInfo; if (nullptr == pfnSetExecInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hKernel) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -3665,7 +3673,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetExecInfo( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hKernel)) { refCountContext.logInvalidReference(hKernel); } @@ -3685,13 +3693,13 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgSampler( *pProperties, ///< [in][optional] pointer to sampler properties. ur_sampler_handle_t hArgValue ///< [in] handle of Sampler object. ) { - auto pfnSetArgSampler = context.urDdiTable.Kernel.pfnSetArgSampler; + auto pfnSetArgSampler = getContext()->urDdiTable.Kernel.pfnSetArgSampler; if (nullptr == pfnSetArgSampler) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hKernel) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -3701,12 +3709,12 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgSampler( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hKernel)) { refCountContext.logInvalidReference(hKernel); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hArgValue)) { refCountContext.logInvalidReference(hArgValue); } @@ -3726,13 +3734,13 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgMemObj( *pProperties, ///< [in][optional] pointer to Memory object properties. ur_mem_handle_t hArgValue ///< [in][optional] handle of Memory object. ) { - auto pfnSetArgMemObj = context.urDdiTable.Kernel.pfnSetArgMemObj; + auto pfnSetArgMemObj = getContext()->urDdiTable.Kernel.pfnSetArgMemObj; if (nullptr == pfnSetArgMemObj) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hKernel) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -3743,12 +3751,12 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgMemObj( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hKernel)) { refCountContext.logInvalidReference(hKernel); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hArgValue)) { refCountContext.logInvalidReference(hArgValue); } @@ -3768,13 +3776,13 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetSpecializationConstants( pSpecConstants ///< [in] array of specialization constant value descriptions ) { auto pfnSetSpecializationConstants = - context.urDdiTable.Kernel.pfnSetSpecializationConstants; + getContext()->urDdiTable.Kernel.pfnSetSpecializationConstants; if (nullptr == pfnSetSpecializationConstants) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hKernel) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -3788,7 +3796,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetSpecializationConstants( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hKernel)) { refCountContext.logInvalidReference(hKernel); } @@ -3806,13 +3814,14 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetNativeHandle( ur_native_handle_t *phNativeKernel ///< [out] a pointer to the native handle of the kernel. ) { - auto pfnGetNativeHandle = context.urDdiTable.Kernel.pfnGetNativeHandle; + auto pfnGetNativeHandle = + getContext()->urDdiTable.Kernel.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hKernel) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -3822,7 +3831,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetNativeHandle( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hKernel)) { refCountContext.logInvalidReference(hKernel); } @@ -3846,13 +3855,13 @@ __urdlllocal ur_result_t UR_APICALL urKernelCreateWithNativeHandle( *phKernel ///< [out] pointer to the handle of the kernel object created. ) { auto pfnCreateWithNativeHandle = - context.urDdiTable.Kernel.pfnCreateWithNativeHandle; + getContext()->urDdiTable.Kernel.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -3866,12 +3875,12 @@ __urdlllocal ur_result_t UR_APICALL urKernelCreateWithNativeHandle( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hProgram)) { refCountContext.logInvalidReference(hProgram); } @@ -3879,7 +3888,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelCreateWithNativeHandle( ur_result_t result = pfnCreateWithNativeHandle( hNativeKernel, hContext, hProgram, pProperties, phKernel); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.createRefCount(*phKernel); } @@ -3906,13 +3915,13 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetSuggestedLocalWorkSize( ///< suggested local work size that will contain the result of the query ) { auto pfnGetSuggestedLocalWorkSize = - context.urDdiTable.Kernel.pfnGetSuggestedLocalWorkSize; + getContext()->urDdiTable.Kernel.pfnGetSuggestedLocalWorkSize; if (nullptr == pfnGetSuggestedLocalWorkSize) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hKernel) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -3934,12 +3943,12 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetSuggestedLocalWorkSize( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hKernel)) { refCountContext.logInvalidReference(hKernel); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } @@ -3964,13 +3973,13 @@ __urdlllocal ur_result_t UR_APICALL urQueueGetInfo( size_t * pPropSizeRet ///< [out][optional] size in bytes returned in queue property value ) { - auto pfnGetInfo = context.urDdiTable.Queue.pfnGetInfo; + auto pfnGetInfo = getContext()->urDdiTable.Queue.pfnGetInfo; if (nullptr == pfnGetInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -3992,7 +4001,7 @@ __urdlllocal ur_result_t UR_APICALL urQueueGetInfo( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } @@ -4013,13 +4022,13 @@ __urdlllocal ur_result_t UR_APICALL urQueueCreate( ur_queue_handle_t *phQueue ///< [out] pointer to handle of queue object created ) { - auto pfnCreate = context.urDdiTable.Queue.pfnCreate; + auto pfnCreate = getContext()->urDdiTable.Queue.pfnCreate; if (nullptr == pfnCreate) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -4049,19 +4058,19 @@ __urdlllocal ur_result_t UR_APICALL urQueueCreate( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDevice)) { refCountContext.logInvalidReference(hDevice); } ur_result_t result = pfnCreate(hContext, hDevice, pProperties, phQueue); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.createRefCount(*phQueue); } @@ -4073,13 +4082,13 @@ __urdlllocal ur_result_t UR_APICALL urQueueCreate( __urdlllocal ur_result_t UR_APICALL urQueueRetain( ur_queue_handle_t hQueue ///< [in] handle of the queue object to get access ) { - auto pfnRetain = context.urDdiTable.Queue.pfnRetain; + auto pfnRetain = getContext()->urDdiTable.Queue.pfnRetain; if (nullptr == pfnRetain) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -4087,7 +4096,7 @@ __urdlllocal ur_result_t UR_APICALL urQueueRetain( ur_result_t result = pfnRetain(hQueue); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.incrementRefCount(hQueue, false); } @@ -4100,13 +4109,13 @@ __urdlllocal ur_result_t UR_APICALL urQueueRelease( ur_queue_handle_t hQueue ///< [in][release] handle of the queue object to release ) { - auto pfnRelease = context.urDdiTable.Queue.pfnRelease; + auto pfnRelease = getContext()->urDdiTable.Queue.pfnRelease; if (nullptr == pfnRelease) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -4114,7 +4123,7 @@ __urdlllocal ur_result_t UR_APICALL urQueueRelease( ur_result_t result = pfnRelease(hQueue); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.decrementRefCount(hQueue, false); } @@ -4130,13 +4139,13 @@ __urdlllocal ur_result_t UR_APICALL urQueueGetNativeHandle( ur_native_handle_t *phNativeQueue ///< [out] a pointer to the native handle of the queue. ) { - auto pfnGetNativeHandle = context.urDdiTable.Queue.pfnGetNativeHandle; + auto pfnGetNativeHandle = getContext()->urDdiTable.Queue.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -4146,7 +4155,7 @@ __urdlllocal ur_result_t UR_APICALL urQueueGetNativeHandle( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } @@ -4169,13 +4178,13 @@ __urdlllocal ur_result_t UR_APICALL urQueueCreateWithNativeHandle( *phQueue ///< [out] pointer to the handle of the queue object created. ) { auto pfnCreateWithNativeHandle = - context.urDdiTable.Queue.pfnCreateWithNativeHandle; + getContext()->urDdiTable.Queue.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -4189,12 +4198,12 @@ __urdlllocal ur_result_t UR_APICALL urQueueCreateWithNativeHandle( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDevice)) { refCountContext.logInvalidReference(hDevice); } @@ -4202,7 +4211,7 @@ __urdlllocal ur_result_t UR_APICALL urQueueCreateWithNativeHandle( ur_result_t result = pfnCreateWithNativeHandle( hNativeQueue, hContext, hDevice, pProperties, phQueue); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.createRefCount(*phQueue); } @@ -4214,19 +4223,19 @@ __urdlllocal ur_result_t UR_APICALL urQueueCreateWithNativeHandle( __urdlllocal ur_result_t UR_APICALL urQueueFinish( ur_queue_handle_t hQueue ///< [in] handle of the queue to be finished. ) { - auto pfnFinish = context.urDdiTable.Queue.pfnFinish; + auto pfnFinish = getContext()->urDdiTable.Queue.pfnFinish; if (nullptr == pfnFinish) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } @@ -4241,19 +4250,19 @@ __urdlllocal ur_result_t UR_APICALL urQueueFinish( __urdlllocal ur_result_t UR_APICALL urQueueFlush( ur_queue_handle_t hQueue ///< [in] handle of the queue to be flushed. ) { - auto pfnFlush = context.urDdiTable.Queue.pfnFlush; + auto pfnFlush = getContext()->urDdiTable.Queue.pfnFlush; if (nullptr == pfnFlush) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } @@ -4274,13 +4283,13 @@ __urdlllocal ur_result_t UR_APICALL urEventGetInfo( ///< property size_t *pPropSizeRet ///< [out][optional] bytes returned in event property ) { - auto pfnGetInfo = context.urDdiTable.Event.pfnGetInfo; + auto pfnGetInfo = getContext()->urDdiTable.Event.pfnGetInfo; if (nullptr == pfnGetInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hEvent) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -4302,7 +4311,7 @@ __urdlllocal ur_result_t UR_APICALL urEventGetInfo( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hEvent)) { refCountContext.logInvalidReference(hEvent); } @@ -4327,13 +4336,14 @@ __urdlllocal ur_result_t UR_APICALL urEventGetProfilingInfo( pPropSizeRet ///< [out][optional] pointer to the actual size in bytes returned in ///< propValue ) { - auto pfnGetProfilingInfo = context.urDdiTable.Event.pfnGetProfilingInfo; + auto pfnGetProfilingInfo = + getContext()->urDdiTable.Event.pfnGetProfilingInfo; if (nullptr == pfnGetProfilingInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hEvent) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -4347,7 +4357,7 @@ __urdlllocal ur_result_t UR_APICALL urEventGetProfilingInfo( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hEvent)) { refCountContext.logInvalidReference(hEvent); } @@ -4366,13 +4376,13 @@ __urdlllocal ur_result_t UR_APICALL urEventWait( phEventWaitList ///< [in][range(0, numEvents)] pointer to a list of events to wait for ///< completion ) { - auto pfnWait = context.urDdiTable.Event.pfnWait; + auto pfnWait = getContext()->urDdiTable.Event.pfnWait; if (nullptr == pfnWait) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == phEventWaitList) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } @@ -4392,13 +4402,13 @@ __urdlllocal ur_result_t UR_APICALL urEventWait( __urdlllocal ur_result_t UR_APICALL urEventRetain( ur_event_handle_t hEvent ///< [in] handle of the event object ) { - auto pfnRetain = context.urDdiTable.Event.pfnRetain; + auto pfnRetain = getContext()->urDdiTable.Event.pfnRetain; if (nullptr == pfnRetain) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hEvent) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -4406,7 +4416,7 @@ __urdlllocal ur_result_t UR_APICALL urEventRetain( ur_result_t result = pfnRetain(hEvent); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.incrementRefCount(hEvent, false); } @@ -4418,13 +4428,13 @@ __urdlllocal ur_result_t UR_APICALL urEventRetain( __urdlllocal ur_result_t UR_APICALL urEventRelease( ur_event_handle_t hEvent ///< [in][release] handle of the event object ) { - auto pfnRelease = context.urDdiTable.Event.pfnRelease; + auto pfnRelease = getContext()->urDdiTable.Event.pfnRelease; if (nullptr == pfnRelease) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hEvent) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -4432,7 +4442,7 @@ __urdlllocal ur_result_t UR_APICALL urEventRelease( ur_result_t result = pfnRelease(hEvent); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.decrementRefCount(hEvent, false); } @@ -4446,13 +4456,13 @@ __urdlllocal ur_result_t UR_APICALL urEventGetNativeHandle( ur_native_handle_t *phNativeEvent ///< [out] a pointer to the native handle of the event. ) { - auto pfnGetNativeHandle = context.urDdiTable.Event.pfnGetNativeHandle; + auto pfnGetNativeHandle = getContext()->urDdiTable.Event.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hEvent) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -4462,7 +4472,7 @@ __urdlllocal ur_result_t UR_APICALL urEventGetNativeHandle( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hEvent)) { refCountContext.logInvalidReference(hEvent); } @@ -4484,13 +4494,13 @@ __urdlllocal ur_result_t UR_APICALL urEventCreateWithNativeHandle( *phEvent ///< [out] pointer to the handle of the event object created. ) { auto pfnCreateWithNativeHandle = - context.urDdiTable.Event.pfnCreateWithNativeHandle; + getContext()->urDdiTable.Event.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -4500,7 +4510,7 @@ __urdlllocal ur_result_t UR_APICALL urEventCreateWithNativeHandle( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } @@ -4508,7 +4518,7 @@ __urdlllocal ur_result_t UR_APICALL urEventCreateWithNativeHandle( ur_result_t result = pfnCreateWithNativeHandle(hNativeEvent, hContext, pProperties, phEvent); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.createRefCount(*phEvent); } @@ -4524,13 +4534,13 @@ __urdlllocal ur_result_t UR_APICALL urEventSetCallback( void * pUserData ///< [in][out][optional] pointer to data to be passed to callback. ) { - auto pfnSetCallback = context.urDdiTable.Event.pfnSetCallback; + auto pfnSetCallback = getContext()->urDdiTable.Event.pfnSetCallback; if (nullptr == pfnSetCallback) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hEvent) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -4548,7 +4558,7 @@ __urdlllocal ur_result_t UR_APICALL urEventSetCallback( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hEvent)) { refCountContext.logInvalidReference(hEvent); } @@ -4590,13 +4600,13 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueKernelLaunch( phEvent ///< [out][optional] return an event object that identifies this particular ///< kernel execution instance. ) { - auto pfnKernelLaunch = context.urDdiTable.Enqueue.pfnKernelLaunch; + auto pfnKernelLaunch = getContext()->urDdiTable.Enqueue.pfnKernelLaunch; if (nullptr == pfnKernelLaunch) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -4630,12 +4640,12 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueKernelLaunch( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hKernel)) { refCountContext.logInvalidReference(hKernel); } @@ -4662,13 +4672,13 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueEventsWait( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnEventsWait = context.urDdiTable.Enqueue.pfnEventsWait; + auto pfnEventsWait = getContext()->urDdiTable.Enqueue.pfnEventsWait; if (nullptr == pfnEventsWait) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -4690,7 +4700,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueEventsWait( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } @@ -4717,13 +4727,13 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueEventsWaitWithBarrier( ///< command instance. ) { auto pfnEventsWaitWithBarrier = - context.urDdiTable.Enqueue.pfnEventsWaitWithBarrier; + getContext()->urDdiTable.Enqueue.pfnEventsWaitWithBarrier; if (nullptr == pfnEventsWaitWithBarrier) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -4745,7 +4755,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueEventsWaitWithBarrier( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } @@ -4776,13 +4786,13 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferRead( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnMemBufferRead = context.urDdiTable.Enqueue.pfnMemBufferRead; + auto pfnMemBufferRead = getContext()->urDdiTable.Enqueue.pfnMemBufferRead; if (nullptr == pfnMemBufferRead) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -4817,12 +4827,12 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferRead( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hBuffer)) { refCountContext.logInvalidReference(hBuffer); } @@ -4856,13 +4866,13 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferWrite( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnMemBufferWrite = context.urDdiTable.Enqueue.pfnMemBufferWrite; + auto pfnMemBufferWrite = getContext()->urDdiTable.Enqueue.pfnMemBufferWrite; if (nullptr == pfnMemBufferWrite) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -4897,12 +4907,12 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferWrite( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hBuffer)) { refCountContext.logInvalidReference(hBuffer); } @@ -4946,13 +4956,14 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferReadRect( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnMemBufferReadRect = context.urDdiTable.Enqueue.pfnMemBufferReadRect; + auto pfnMemBufferReadRect = + getContext()->urDdiTable.Enqueue.pfnMemBufferReadRect; if (nullptr == pfnMemBufferReadRect) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -5027,12 +5038,12 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferReadRect( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hBuffer)) { refCountContext.logInvalidReference(hBuffer); } @@ -5081,13 +5092,13 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferWriteRect( ///< command instance. ) { auto pfnMemBufferWriteRect = - context.urDdiTable.Enqueue.pfnMemBufferWriteRect; + getContext()->urDdiTable.Enqueue.pfnMemBufferWriteRect; if (nullptr == pfnMemBufferWriteRect) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -5162,12 +5173,12 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferWriteRect( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hBuffer)) { refCountContext.logInvalidReference(hBuffer); } @@ -5201,13 +5212,13 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferCopy( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnMemBufferCopy = context.urDdiTable.Enqueue.pfnMemBufferCopy; + auto pfnMemBufferCopy = getContext()->urDdiTable.Enqueue.pfnMemBufferCopy; if (nullptr == pfnMemBufferCopy) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -5247,17 +5258,17 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferCopy( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hBufferSrc)) { refCountContext.logInvalidReference(hBufferSrc); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hBufferDst)) { refCountContext.logInvalidReference(hBufferDst); } @@ -5299,13 +5310,14 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferCopyRect( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnMemBufferCopyRect = context.urDdiTable.Enqueue.pfnMemBufferCopyRect; + auto pfnMemBufferCopyRect = + getContext()->urDdiTable.Enqueue.pfnMemBufferCopyRect; if (nullptr == pfnMemBufferCopyRect) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -5381,17 +5393,17 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferCopyRect( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hBufferSrc)) { refCountContext.logInvalidReference(hBufferSrc); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hBufferDst)) { refCountContext.logInvalidReference(hBufferDst); } @@ -5424,13 +5436,13 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferFill( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnMemBufferFill = context.urDdiTable.Enqueue.pfnMemBufferFill; + auto pfnMemBufferFill = getContext()->urDdiTable.Enqueue.pfnMemBufferFill; if (nullptr == pfnMemBufferFill) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -5485,12 +5497,12 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferFill( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hBuffer)) { refCountContext.logInvalidReference(hBuffer); } @@ -5527,13 +5539,13 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemImageRead( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnMemImageRead = context.urDdiTable.Enqueue.pfnMemImageRead; + auto pfnMemImageRead = getContext()->urDdiTable.Enqueue.pfnMemImageRead; if (nullptr == pfnMemImageRead) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -5572,12 +5584,12 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemImageRead( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hImage)) { refCountContext.logInvalidReference(hImage); } @@ -5615,13 +5627,13 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemImageWrite( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnMemImageWrite = context.urDdiTable.Enqueue.pfnMemImageWrite; + auto pfnMemImageWrite = getContext()->urDdiTable.Enqueue.pfnMemImageWrite; if (nullptr == pfnMemImageWrite) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -5660,12 +5672,12 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemImageWrite( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hImage)) { refCountContext.logInvalidReference(hImage); } @@ -5704,13 +5716,13 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemImageCopy( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnMemImageCopy = context.urDdiTable.Enqueue.pfnMemImageCopy; + auto pfnMemImageCopy = getContext()->urDdiTable.Enqueue.pfnMemImageCopy; if (nullptr == pfnMemImageCopy) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -5754,17 +5766,17 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemImageCopy( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hImageSrc)) { refCountContext.logInvalidReference(hImageSrc); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hImageDst)) { refCountContext.logInvalidReference(hImageDst); } @@ -5798,13 +5810,13 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferMap( void **ppRetMap ///< [out] return mapped pointer. TODO: move it before ///< numEventsInWaitList? ) { - auto pfnMemBufferMap = context.urDdiTable.Enqueue.pfnMemBufferMap; + auto pfnMemBufferMap = getContext()->urDdiTable.Enqueue.pfnMemBufferMap; if (nullptr == pfnMemBufferMap) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -5843,12 +5855,12 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferMap( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hBuffer)) { refCountContext.logInvalidReference(hBuffer); } @@ -5877,13 +5889,13 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemUnmap( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnMemUnmap = context.urDdiTable.Enqueue.pfnMemUnmap; + auto pfnMemUnmap = getContext()->urDdiTable.Enqueue.pfnMemUnmap; if (nullptr == pfnMemUnmap) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -5913,12 +5925,12 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemUnmap( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hMem)) { refCountContext.logInvalidReference(hMem); } @@ -5952,13 +5964,13 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMFill( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnUSMFill = context.urDdiTable.Enqueue.pfnUSMFill; + auto pfnUSMFill = getContext()->urDdiTable.Enqueue.pfnUSMFill; if (nullptr == pfnUSMFill) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -6009,7 +6021,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMFill( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } @@ -6041,13 +6053,13 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMMemcpy( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnUSMMemcpy = context.urDdiTable.Enqueue.pfnUSMMemcpy; + auto pfnUSMMemcpy = getContext()->urDdiTable.Enqueue.pfnUSMMemcpy; if (nullptr == pfnUSMMemcpy) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -6091,7 +6103,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMMemcpy( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } @@ -6121,13 +6133,13 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMPrefetch( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnUSMPrefetch = context.urDdiTable.Enqueue.pfnUSMPrefetch; + auto pfnUSMPrefetch = getContext()->urDdiTable.Enqueue.pfnUSMPrefetch; if (nullptr == pfnUSMPrefetch) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -6166,7 +6178,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMPrefetch( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } @@ -6190,13 +6202,13 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMAdvise( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnUSMAdvise = context.urDdiTable.Enqueue.pfnUSMAdvise; + auto pfnUSMAdvise = getContext()->urDdiTable.Enqueue.pfnUSMAdvise; if (nullptr == pfnUSMAdvise) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -6219,7 +6231,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMAdvise( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } @@ -6256,13 +6268,13 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMFill2D( phEvent ///< [out][optional] return an event object that identifies this particular ///< kernel execution instance. ) { - auto pfnUSMFill2D = context.urDdiTable.Enqueue.pfnUSMFill2D; + auto pfnUSMFill2D = getContext()->urDdiTable.Enqueue.pfnUSMFill2D; if (nullptr == pfnUSMFill2D) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -6329,7 +6341,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMFill2D( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } @@ -6367,13 +6379,13 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMMemcpy2D( phEvent ///< [out][optional] return an event object that identifies this particular ///< kernel execution instance. ) { - auto pfnUSMMemcpy2D = context.urDdiTable.Enqueue.pfnUSMMemcpy2D; + auto pfnUSMMemcpy2D = getContext()->urDdiTable.Enqueue.pfnUSMMemcpy2D; if (nullptr == pfnUSMMemcpy2D) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -6433,7 +6445,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMMemcpy2D( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } @@ -6469,13 +6481,13 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueDeviceGlobalVariableWrite( ///< kernel execution instance. ) { auto pfnDeviceGlobalVariableWrite = - context.urDdiTable.Enqueue.pfnDeviceGlobalVariableWrite; + getContext()->urDdiTable.Enqueue.pfnDeviceGlobalVariableWrite; if (nullptr == pfnDeviceGlobalVariableWrite) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -6509,12 +6521,12 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueDeviceGlobalVariableWrite( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hProgram)) { refCountContext.logInvalidReference(hProgram); } @@ -6550,13 +6562,13 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueDeviceGlobalVariableRead( ///< kernel execution instance. ) { auto pfnDeviceGlobalVariableRead = - context.urDdiTable.Enqueue.pfnDeviceGlobalVariableRead; + getContext()->urDdiTable.Enqueue.pfnDeviceGlobalVariableRead; if (nullptr == pfnDeviceGlobalVariableRead) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -6590,12 +6602,12 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueDeviceGlobalVariableRead( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hProgram)) { refCountContext.logInvalidReference(hProgram); } @@ -6634,13 +6646,13 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueReadHostPipe( ///< command ///< and can be used to query or queue a wait for this command to complete. ) { - auto pfnReadHostPipe = context.urDdiTable.Enqueue.pfnReadHostPipe; + auto pfnReadHostPipe = getContext()->urDdiTable.Enqueue.pfnReadHostPipe; if (nullptr == pfnReadHostPipe) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -6674,12 +6686,12 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueReadHostPipe( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hProgram)) { refCountContext.logInvalidReference(hProgram); } @@ -6718,13 +6730,13 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueWriteHostPipe( phEvent ///< [out][optional] returns an event object that identifies this write command ///< and can be used to query or queue a wait for this command to complete. ) { - auto pfnWriteHostPipe = context.urDdiTable.Enqueue.pfnWriteHostPipe; + auto pfnWriteHostPipe = getContext()->urDdiTable.Enqueue.pfnWriteHostPipe; if (nullptr == pfnWriteHostPipe) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -6758,12 +6770,12 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueWriteHostPipe( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hProgram)) { refCountContext.logInvalidReference(hProgram); } @@ -6792,13 +6804,14 @@ __urdlllocal ur_result_t UR_APICALL urUSMPitchedAllocExp( void **ppMem, ///< [out] pointer to USM shared memory object size_t *pResultPitch ///< [out] pitch of the allocation ) { - auto pfnPitchedAllocExp = context.urDdiTable.USMExp.pfnPitchedAllocExp; + auto pfnPitchedAllocExp = + getContext()->urDdiTable.USMExp.pfnPitchedAllocExp; if (nullptr == pfnPitchedAllocExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -6829,17 +6842,17 @@ __urdlllocal ur_result_t UR_APICALL urUSMPitchedAllocExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDevice)) { refCountContext.logInvalidReference(hDevice); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(pool)) { refCountContext.logInvalidReference(pool); } @@ -6861,13 +6874,14 @@ urBindlessImagesUnsampledImageHandleDestroyExp( hImage ///< [in][release] pointer to handle of image object to destroy ) { auto pfnUnsampledImageHandleDestroyExp = - context.urDdiTable.BindlessImagesExp.pfnUnsampledImageHandleDestroyExp; + getContext() + ->urDdiTable.BindlessImagesExp.pfnUnsampledImageHandleDestroyExp; if (nullptr == pfnUnsampledImageHandleDestroyExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -6881,12 +6895,12 @@ urBindlessImagesUnsampledImageHandleDestroyExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDevice)) { refCountContext.logInvalidReference(hDevice); } @@ -6907,13 +6921,14 @@ urBindlessImagesSampledImageHandleDestroyExp( hImage ///< [in][release] pointer to handle of image object to destroy ) { auto pfnSampledImageHandleDestroyExp = - context.urDdiTable.BindlessImagesExp.pfnSampledImageHandleDestroyExp; + getContext() + ->urDdiTable.BindlessImagesExp.pfnSampledImageHandleDestroyExp; if (nullptr == pfnSampledImageHandleDestroyExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -6927,12 +6942,12 @@ urBindlessImagesSampledImageHandleDestroyExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDevice)) { refCountContext.logInvalidReference(hDevice); } @@ -6955,13 +6970,13 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( *phImageMem ///< [out] pointer to handle of image memory allocated ) { auto pfnImageAllocateExp = - context.urDdiTable.BindlessImagesExp.pfnImageAllocateExp; + getContext()->urDdiTable.BindlessImagesExp.pfnImageAllocateExp; if (nullptr == pfnImageAllocateExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -6987,12 +7002,12 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDevice)) { refCountContext.logInvalidReference(hDevice); } @@ -7011,13 +7026,14 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageFreeExp( ur_exp_image_mem_handle_t hImageMem ///< [in][release] handle of image memory to be freed ) { - auto pfnImageFreeExp = context.urDdiTable.BindlessImagesExp.pfnImageFreeExp; + auto pfnImageFreeExp = + getContext()->urDdiTable.BindlessImagesExp.pfnImageFreeExp; if (nullptr == pfnImageFreeExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -7031,12 +7047,12 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageFreeExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDevice)) { refCountContext.logInvalidReference(hDevice); } @@ -7060,13 +7076,13 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( *phImage ///< [out] pointer to handle of image object created ) { auto pfnUnsampledImageCreateExp = - context.urDdiTable.BindlessImagesExp.pfnUnsampledImageCreateExp; + getContext()->urDdiTable.BindlessImagesExp.pfnUnsampledImageCreateExp; if (nullptr == pfnUnsampledImageCreateExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -7096,12 +7112,12 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDevice)) { refCountContext.logInvalidReference(hDevice); } @@ -7127,13 +7143,13 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( *phImage ///< [out] pointer to handle of image object created ) { auto pfnSampledImageCreateExp = - context.urDdiTable.BindlessImagesExp.pfnSampledImageCreateExp; + getContext()->urDdiTable.BindlessImagesExp.pfnSampledImageCreateExp; if (nullptr == pfnSampledImageCreateExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -7167,17 +7183,17 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDevice)) { refCountContext.logInvalidReference(hDevice); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hSampler)) { refCountContext.logInvalidReference(hSampler); } @@ -7223,13 +7239,14 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) { - auto pfnImageCopyExp = context.urDdiTable.BindlessImagesExp.pfnImageCopyExp; + auto pfnImageCopyExp = + getContext()->urDdiTable.BindlessImagesExp.pfnImageCopyExp; if (nullptr == pfnImageCopyExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -7267,7 +7284,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } @@ -7289,13 +7306,13 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( size_t *pPropSizeRet ///< [out][optional] returned query value size ) { auto pfnImageGetInfoExp = - context.urDdiTable.BindlessImagesExp.pfnImageGetInfoExp; + getContext()->urDdiTable.BindlessImagesExp.pfnImageGetInfoExp; if (nullptr == pfnImageGetInfoExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hImageMem) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -7327,13 +7344,13 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( *phImageMem ///< [out] returning memory handle to the individual image ) { auto pfnMipmapGetLevelExp = - context.urDdiTable.BindlessImagesExp.pfnMipmapGetLevelExp; + getContext()->urDdiTable.BindlessImagesExp.pfnMipmapGetLevelExp; if (nullptr == pfnMipmapGetLevelExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -7351,12 +7368,12 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDevice)) { refCountContext.logInvalidReference(hDevice); } @@ -7376,13 +7393,13 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( hMem ///< [in][release] handle of image memory to be freed ) { auto pfnMipmapFreeExp = - context.urDdiTable.BindlessImagesExp.pfnMipmapFreeExp; + getContext()->urDdiTable.BindlessImagesExp.pfnMipmapFreeExp; if (nullptr == pfnMipmapFreeExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -7396,12 +7413,12 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDevice)) { refCountContext.logInvalidReference(hDevice); } @@ -7425,13 +7442,13 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportExternalMemoryExp( *phInteropMem ///< [out] interop memory handle to the external memory ) { auto pfnImportExternalMemoryExp = - context.urDdiTable.BindlessImagesExp.pfnImportExternalMemoryExp; + getContext()->urDdiTable.BindlessImagesExp.pfnImportExternalMemoryExp; if (nullptr == pfnImportExternalMemoryExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -7453,12 +7470,12 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportExternalMemoryExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDevice)) { refCountContext.logInvalidReference(hDevice); } @@ -7483,13 +7500,13 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( phImageMem ///< [out] image memory handle to the externally allocated memory ) { auto pfnMapExternalArrayExp = - context.urDdiTable.BindlessImagesExp.pfnMapExternalArrayExp; + getContext()->urDdiTable.BindlessImagesExp.pfnMapExternalArrayExp; if (nullptr == pfnMapExternalArrayExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -7519,12 +7536,12 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDevice)) { refCountContext.logInvalidReference(hDevice); } @@ -7544,13 +7561,13 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( hInteropMem ///< [in][release] handle of interop memory to be freed ) { auto pfnReleaseInteropExp = - context.urDdiTable.BindlessImagesExp.pfnReleaseInteropExp; + getContext()->urDdiTable.BindlessImagesExp.pfnReleaseInteropExp; if (nullptr == pfnReleaseInteropExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -7564,12 +7581,12 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDevice)) { refCountContext.logInvalidReference(hDevice); } @@ -7592,13 +7609,14 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreExp( phInteropSemaphore ///< [out] interop semaphore handle to the external semaphore ) { auto pfnImportExternalSemaphoreExp = - context.urDdiTable.BindlessImagesExp.pfnImportExternalSemaphoreExp; + getContext() + ->urDdiTable.BindlessImagesExp.pfnImportExternalSemaphoreExp; if (nullptr == pfnImportExternalSemaphoreExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -7621,12 +7639,12 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDevice)) { refCountContext.logInvalidReference(hDevice); } @@ -7647,13 +7665,14 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( hInteropSemaphore ///< [in][release] handle of interop semaphore to be destroyed ) { auto pfnDestroyExternalSemaphoreExp = - context.urDdiTable.BindlessImagesExp.pfnDestroyExternalSemaphoreExp; + getContext() + ->urDdiTable.BindlessImagesExp.pfnDestroyExternalSemaphoreExp; if (nullptr == pfnDestroyExternalSemaphoreExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -7667,12 +7686,12 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDevice)) { refCountContext.logInvalidReference(hDevice); } @@ -7707,13 +7726,13 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesWaitExternalSemaphoreExp( ///< command instance. ) { auto pfnWaitExternalSemaphoreExp = - context.urDdiTable.BindlessImagesExp.pfnWaitExternalSemaphoreExp; + getContext()->urDdiTable.BindlessImagesExp.pfnWaitExternalSemaphoreExp; if (nullptr == pfnWaitExternalSemaphoreExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -7731,7 +7750,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesWaitExternalSemaphoreExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } @@ -7767,13 +7786,14 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSignalExternalSemaphoreExp( ///< command instance. ) { auto pfnSignalExternalSemaphoreExp = - context.urDdiTable.BindlessImagesExp.pfnSignalExternalSemaphoreExp; + getContext() + ->urDdiTable.BindlessImagesExp.pfnSignalExternalSemaphoreExp; if (nullptr == pfnSignalExternalSemaphoreExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -7791,7 +7811,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSignalExternalSemaphoreExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } @@ -7813,13 +7833,13 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferCreateExp( ur_exp_command_buffer_handle_t *phCommandBuffer ///< [out] Pointer to command-Buffer handle. ) { - auto pfnCreateExp = context.urDdiTable.CommandBufferExp.pfnCreateExp; + auto pfnCreateExp = getContext()->urDdiTable.CommandBufferExp.pfnCreateExp; if (nullptr == pfnCreateExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -7833,12 +7853,12 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferCreateExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDevice)) { refCountContext.logInvalidReference(hDevice); } @@ -7855,13 +7875,13 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferRetainExp( ur_exp_command_buffer_handle_t hCommandBuffer ///< [in] Handle of the command-buffer object. ) { - auto pfnRetainExp = context.urDdiTable.CommandBufferExp.pfnRetainExp; + auto pfnRetainExp = getContext()->urDdiTable.CommandBufferExp.pfnRetainExp; if (nullptr == pfnRetainExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hCommandBuffer) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -7878,13 +7898,14 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferReleaseExp( ur_exp_command_buffer_handle_t hCommandBuffer ///< [in][release] Handle of the command-buffer object. ) { - auto pfnReleaseExp = context.urDdiTable.CommandBufferExp.pfnReleaseExp; + auto pfnReleaseExp = + getContext()->urDdiTable.CommandBufferExp.pfnReleaseExp; if (nullptr == pfnReleaseExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hCommandBuffer) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -7901,13 +7922,14 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferFinalizeExp( ur_exp_command_buffer_handle_t hCommandBuffer ///< [in] Handle of the command-buffer object. ) { - auto pfnFinalizeExp = context.urDdiTable.CommandBufferExp.pfnFinalizeExp; + auto pfnFinalizeExp = + getContext()->urDdiTable.CommandBufferExp.pfnFinalizeExp; if (nullptr == pfnFinalizeExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hCommandBuffer) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -7942,13 +7964,13 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendKernelLaunchExp( *phCommand ///< [out][optional] Handle to this command. ) { auto pfnAppendKernelLaunchExp = - context.urDdiTable.CommandBufferExp.pfnAppendKernelLaunchExp; + getContext()->urDdiTable.CommandBufferExp.pfnAppendKernelLaunchExp; if (nullptr == pfnAppendKernelLaunchExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hCommandBuffer) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -7974,7 +7996,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendKernelLaunchExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hKernel)) { refCountContext.logInvalidReference(hKernel); } @@ -8004,13 +8026,13 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendUSMMemcpyExp( pSyncPoint ///< [out][optional] Sync point associated with this command. ) { auto pfnAppendUSMMemcpyExp = - context.urDdiTable.CommandBufferExp.pfnAppendUSMMemcpyExp; + getContext()->urDdiTable.CommandBufferExp.pfnAppendUSMMemcpyExp; if (nullptr == pfnAppendUSMMemcpyExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hCommandBuffer) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -8062,13 +8084,13 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendUSMFillExp( pSyncPoint ///< [out][optional] sync point associated with this command. ) { auto pfnAppendUSMFillExp = - context.urDdiTable.CommandBufferExp.pfnAppendUSMFillExp; + getContext()->urDdiTable.CommandBufferExp.pfnAppendUSMFillExp; if (nullptr == pfnAppendUSMFillExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hCommandBuffer) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -8132,13 +8154,13 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferCopyExp( pSyncPoint ///< [out][optional] Sync point associated with this command. ) { auto pfnAppendMemBufferCopyExp = - context.urDdiTable.CommandBufferExp.pfnAppendMemBufferCopyExp; + getContext()->urDdiTable.CommandBufferExp.pfnAppendMemBufferCopyExp; if (nullptr == pfnAppendMemBufferCopyExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hCommandBuffer) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -8160,12 +8182,12 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferCopyExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hSrcMem)) { refCountContext.logInvalidReference(hSrcMem); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDstMem)) { refCountContext.logInvalidReference(hDstMem); } @@ -8196,13 +8218,13 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferWriteExp( pSyncPoint ///< [out][optional] Sync point associated with this command. ) { auto pfnAppendMemBufferWriteExp = - context.urDdiTable.CommandBufferExp.pfnAppendMemBufferWriteExp; + getContext()->urDdiTable.CommandBufferExp.pfnAppendMemBufferWriteExp; if (nullptr == pfnAppendMemBufferWriteExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hCommandBuffer) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -8224,7 +8246,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferWriteExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hBuffer)) { refCountContext.logInvalidReference(hBuffer); } @@ -8254,13 +8276,13 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferReadExp( pSyncPoint ///< [out][optional] Sync point associated with this command. ) { auto pfnAppendMemBufferReadExp = - context.urDdiTable.CommandBufferExp.pfnAppendMemBufferReadExp; + getContext()->urDdiTable.CommandBufferExp.pfnAppendMemBufferReadExp; if (nullptr == pfnAppendMemBufferReadExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hCommandBuffer) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -8282,7 +8304,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferReadExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hBuffer)) { refCountContext.logInvalidReference(hBuffer); } @@ -8320,13 +8342,13 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferCopyRectExp( pSyncPoint ///< [out][optional] Sync point associated with this command. ) { auto pfnAppendMemBufferCopyRectExp = - context.urDdiTable.CommandBufferExp.pfnAppendMemBufferCopyRectExp; + getContext()->urDdiTable.CommandBufferExp.pfnAppendMemBufferCopyRectExp; if (nullptr == pfnAppendMemBufferCopyRectExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hCommandBuffer) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -8348,12 +8370,12 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferCopyRectExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hSrcMem)) { refCountContext.logInvalidReference(hSrcMem); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hDstMem)) { refCountContext.logInvalidReference(hDstMem); } @@ -8398,13 +8420,14 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferWriteRectExp( pSyncPoint ///< [out][optional] Sync point associated with this command. ) { auto pfnAppendMemBufferWriteRectExp = - context.urDdiTable.CommandBufferExp.pfnAppendMemBufferWriteRectExp; + getContext() + ->urDdiTable.CommandBufferExp.pfnAppendMemBufferWriteRectExp; if (nullptr == pfnAppendMemBufferWriteRectExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hCommandBuffer) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -8426,7 +8449,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferWriteRectExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hBuffer)) { refCountContext.logInvalidReference(hBuffer); } @@ -8469,13 +8492,13 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferReadRectExp( pSyncPoint ///< [out][optional] Sync point associated with this command. ) { auto pfnAppendMemBufferReadRectExp = - context.urDdiTable.CommandBufferExp.pfnAppendMemBufferReadRectExp; + getContext()->urDdiTable.CommandBufferExp.pfnAppendMemBufferReadRectExp; if (nullptr == pfnAppendMemBufferReadRectExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hCommandBuffer) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -8497,7 +8520,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferReadRectExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hBuffer)) { refCountContext.logInvalidReference(hBuffer); } @@ -8530,13 +8553,13 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferFillExp( pSyncPoint ///< [out][optional] sync point associated with this command. ) { auto pfnAppendMemBufferFillExp = - context.urDdiTable.CommandBufferExp.pfnAppendMemBufferFillExp; + getContext()->urDdiTable.CommandBufferExp.pfnAppendMemBufferFillExp; if (nullptr == pfnAppendMemBufferFillExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hCommandBuffer) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -8558,7 +8581,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferFillExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hBuffer)) { refCountContext.logInvalidReference(hBuffer); } @@ -8587,13 +8610,13 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendUSMPrefetchExp( pSyncPoint ///< [out][optional] sync point associated with this command. ) { auto pfnAppendUSMPrefetchExp = - context.urDdiTable.CommandBufferExp.pfnAppendUSMPrefetchExp; + getContext()->urDdiTable.CommandBufferExp.pfnAppendUSMPrefetchExp; if (nullptr == pfnAppendUSMPrefetchExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hCommandBuffer) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -8643,13 +8666,13 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendUSMAdviseExp( pSyncPoint ///< [out][optional] sync point associated with this command. ) { auto pfnAppendUSMAdviseExp = - context.urDdiTable.CommandBufferExp.pfnAppendUSMAdviseExp; + getContext()->urDdiTable.CommandBufferExp.pfnAppendUSMAdviseExp; if (nullptr == pfnAppendUSMAdviseExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hCommandBuffer) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -8698,13 +8721,14 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferEnqueueExp( phEvent ///< [out][optional] return an event object that identifies this particular ///< command-buffer execution instance. ) { - auto pfnEnqueueExp = context.urDdiTable.CommandBufferExp.pfnEnqueueExp; + auto pfnEnqueueExp = + getContext()->urDdiTable.CommandBufferExp.pfnEnqueueExp; if (nullptr == pfnEnqueueExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hCommandBuffer) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -8730,7 +8754,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferEnqueueExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } @@ -8748,13 +8772,13 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferRetainCommandExp( hCommand ///< [in] Handle of the command-buffer command. ) { auto pfnRetainCommandExp = - context.urDdiTable.CommandBufferExp.pfnRetainCommandExp; + getContext()->urDdiTable.CommandBufferExp.pfnRetainCommandExp; if (nullptr == pfnRetainCommandExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hCommand) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -8772,13 +8796,13 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferReleaseCommandExp( hCommand ///< [in][release] Handle of the command-buffer command. ) { auto pfnReleaseCommandExp = - context.urDdiTable.CommandBufferExp.pfnReleaseCommandExp; + getContext()->urDdiTable.CommandBufferExp.pfnReleaseCommandExp; if (nullptr == pfnReleaseCommandExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hCommand) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -8798,13 +8822,13 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferUpdateKernelLaunchExp( pUpdateKernelLaunch ///< [in] Struct defining how the kernel command is to be updated. ) { auto pfnUpdateKernelLaunchExp = - context.urDdiTable.CommandBufferExp.pfnUpdateKernelLaunchExp; + getContext()->urDdiTable.CommandBufferExp.pfnUpdateKernelLaunchExp; if (nullptr == pfnUpdateKernelLaunchExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hCommand) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -8835,13 +8859,14 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferGetInfoExp( size_t * pPropSizeRet ///< [out][optional] bytes returned in command-buffer property ) { - auto pfnGetInfoExp = context.urDdiTable.CommandBufferExp.pfnGetInfoExp; + auto pfnGetInfoExp = + getContext()->urDdiTable.CommandBufferExp.pfnGetInfoExp; if (nullptr == pfnGetInfoExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hCommandBuffer) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -8885,13 +8910,13 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferCommandGetInfoExp( pPropSizeRet ///< [out][optional] bytes returned in command-buffer command property ) { auto pfnCommandGetInfoExp = - context.urDdiTable.CommandBufferExp.pfnCommandGetInfoExp; + getContext()->urDdiTable.CommandBufferExp.pfnCommandGetInfoExp; if (nullptr == pfnCommandGetInfoExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hCommand) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -8951,13 +8976,13 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueCooperativeKernelLaunchExp( ///< kernel execution instance. ) { auto pfnCooperativeKernelLaunchExp = - context.urDdiTable.EnqueueExp.pfnCooperativeKernelLaunchExp; + getContext()->urDdiTable.EnqueueExp.pfnCooperativeKernelLaunchExp; if (nullptr == pfnCooperativeKernelLaunchExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -8991,12 +9016,12 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueCooperativeKernelLaunchExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hKernel)) { refCountContext.logInvalidReference(hKernel); } @@ -9021,13 +9046,14 @@ __urdlllocal ur_result_t UR_APICALL urKernelSuggestMaxCooperativeGroupCountExp( uint32_t *pGroupCountRet ///< [out] pointer to maximum number of groups ) { auto pfnSuggestMaxCooperativeGroupCountExp = - context.urDdiTable.KernelExp.pfnSuggestMaxCooperativeGroupCountExp; + getContext() + ->urDdiTable.KernelExp.pfnSuggestMaxCooperativeGroupCountExp; if (nullptr == pfnSuggestMaxCooperativeGroupCountExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hKernel) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -9037,7 +9063,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSuggestMaxCooperativeGroupCountExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hKernel)) { refCountContext.logInvalidReference(hKernel); } @@ -9072,13 +9098,13 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueTimestampRecordingExp( ///< reports the timestamp recorded when the command is executed on the device. ) { auto pfnTimestampRecordingExp = - context.urDdiTable.EnqueueExp.pfnTimestampRecordingExp; + getContext()->urDdiTable.EnqueueExp.pfnTimestampRecordingExp; if (nullptr == pfnTimestampRecordingExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -9104,7 +9130,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueTimestampRecordingExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } @@ -9146,13 +9172,13 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueKernelLaunchCustomExp( ///< kernel execution instance. ) { auto pfnKernelLaunchCustomExp = - context.urDdiTable.EnqueueExp.pfnKernelLaunchCustomExp; + getContext()->urDdiTable.EnqueueExp.pfnKernelLaunchCustomExp; if (nullptr == pfnKernelLaunchCustomExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -9178,12 +9204,12 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueKernelLaunchCustomExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hKernel)) { refCountContext.logInvalidReference(hKernel); } @@ -9206,13 +9232,13 @@ __urdlllocal ur_result_t UR_APICALL urProgramBuildExp( const char * pOptions ///< [in][optional] pointer to build options null-terminated string. ) { - auto pfnBuildExp = context.urDdiTable.ProgramExp.pfnBuildExp; + auto pfnBuildExp = getContext()->urDdiTable.ProgramExp.pfnBuildExp; if (nullptr == pfnBuildExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hProgram) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -9222,7 +9248,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramBuildExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hProgram)) { refCountContext.logInvalidReference(hProgram); } @@ -9243,13 +9269,13 @@ __urdlllocal ur_result_t UR_APICALL urProgramCompileExp( const char * pOptions ///< [in][optional] pointer to build options null-terminated string. ) { - auto pfnCompileExp = context.urDdiTable.ProgramExp.pfnCompileExp; + auto pfnCompileExp = getContext()->urDdiTable.ProgramExp.pfnCompileExp; if (nullptr == pfnCompileExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hProgram) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -9259,7 +9285,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramCompileExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hProgram)) { refCountContext.logInvalidReference(hProgram); } @@ -9285,13 +9311,13 @@ __urdlllocal ur_result_t UR_APICALL urProgramLinkExp( ur_program_handle_t *phProgram ///< [out] pointer to handle of program object created. ) { - auto pfnLinkExp = context.urDdiTable.ProgramExp.pfnLinkExp; + auto pfnLinkExp = getContext()->urDdiTable.ProgramExp.pfnLinkExp; if (nullptr == pfnLinkExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -9313,7 +9339,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramLinkExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } @@ -9331,13 +9357,13 @@ __urdlllocal ur_result_t UR_APICALL urUSMImportExp( void *pMem, ///< [in] pointer to host memory object size_t size ///< [in] size in bytes of the host memory object to be imported ) { - auto pfnImportExp = context.urDdiTable.USMExp.pfnImportExp; + auto pfnImportExp = getContext()->urDdiTable.USMExp.pfnImportExp; if (nullptr == pfnImportExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -9347,7 +9373,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMImportExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } @@ -9363,13 +9389,13 @@ __urdlllocal ur_result_t UR_APICALL urUSMReleaseExp( ur_context_handle_t hContext, ///< [in] handle of the context object void *pMem ///< [in] pointer to host memory object ) { - auto pfnReleaseExp = context.urDdiTable.USMExp.pfnReleaseExp; + auto pfnReleaseExp = getContext()->urDdiTable.USMExp.pfnReleaseExp; if (nullptr == pfnReleaseExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -9379,7 +9405,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMReleaseExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hContext)) { refCountContext.logInvalidReference(hContext); } @@ -9397,13 +9423,13 @@ __urdlllocal ur_result_t UR_APICALL urUsmP2PEnablePeerAccessExp( ur_device_handle_t peerDevice ///< [in] handle of the peer device object ) { auto pfnEnablePeerAccessExp = - context.urDdiTable.UsmP2PExp.pfnEnablePeerAccessExp; + getContext()->urDdiTable.UsmP2PExp.pfnEnablePeerAccessExp; if (nullptr == pfnEnablePeerAccessExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == commandDevice) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -9413,12 +9439,12 @@ __urdlllocal ur_result_t UR_APICALL urUsmP2PEnablePeerAccessExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(commandDevice)) { refCountContext.logInvalidReference(commandDevice); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(peerDevice)) { refCountContext.logInvalidReference(peerDevice); } @@ -9436,13 +9462,13 @@ __urdlllocal ur_result_t UR_APICALL urUsmP2PDisablePeerAccessExp( ur_device_handle_t peerDevice ///< [in] handle of the peer device object ) { auto pfnDisablePeerAccessExp = - context.urDdiTable.UsmP2PExp.pfnDisablePeerAccessExp; + getContext()->urDdiTable.UsmP2PExp.pfnDisablePeerAccessExp; if (nullptr == pfnDisablePeerAccessExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == commandDevice) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -9452,12 +9478,12 @@ __urdlllocal ur_result_t UR_APICALL urUsmP2PDisablePeerAccessExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(commandDevice)) { refCountContext.logInvalidReference(commandDevice); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(peerDevice)) { refCountContext.logInvalidReference(peerDevice); } @@ -9486,13 +9512,13 @@ __urdlllocal ur_result_t UR_APICALL urUsmP2PPeerAccessGetInfoExp( pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of the queried propName. ) { auto pfnPeerAccessGetInfoExp = - context.urDdiTable.UsmP2PExp.pfnPeerAccessGetInfoExp; + getContext()->urDdiTable.UsmP2PExp.pfnPeerAccessGetInfoExp; if (nullptr == pfnPeerAccessGetInfoExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == commandDevice) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -9518,12 +9544,12 @@ __urdlllocal ur_result_t UR_APICALL urUsmP2PPeerAccessGetInfoExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(commandDevice)) { refCountContext.logInvalidReference(commandDevice); } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(peerDevice)) { refCountContext.logInvalidReference(peerDevice); } @@ -9561,13 +9587,13 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueNativeCommandExp( ///< been enqueued in nativeEnqueueFunc. ) { auto pfnNativeCommandExp = - context.urDdiTable.EnqueueExp.pfnNativeCommandExp; + getContext()->urDdiTable.EnqueueExp.pfnNativeCommandExp; if (nullptr == pfnNativeCommandExp) { return UR_RESULT_ERROR_UNINITIALIZED; } - if (context.enableParameterValidation) { + if (getContext()->enableParameterValidation) { if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -9594,7 +9620,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueNativeCommandExp( } } - if (context.enableLifetimeValidation && + if (getContext()->enableLifetimeValidation && !refCountContext.isReferenceValid(hQueue)) { refCountContext.logInvalidReference(hQueue); } @@ -9619,15 +9645,15 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetGlobalProcAddrTable( ur_global_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_validation_layer::context.urDdiTable.Global; + auto &dditable = ur_validation_layer::getContext()->urDdiTable.Global; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_validation_layer::context.version) != + if (UR_MAJOR_VERSION(ur_validation_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_validation_layer::context.version) > + UR_MINOR_VERSION(ur_validation_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -9666,15 +9692,16 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetBindlessImagesExpProcAddrTable( ur_bindless_images_exp_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_validation_layer::context.urDdiTable.BindlessImagesExp; + auto &dditable = + ur_validation_layer::getContext()->urDdiTable.BindlessImagesExp; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_validation_layer::context.version) != + if (UR_MAJOR_VERSION(ur_validation_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_validation_layer::context.version) > + UR_MINOR_VERSION(ur_validation_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -9771,15 +9798,16 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetCommandBufferExpProcAddrTable( ur_command_buffer_exp_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_validation_layer::context.urDdiTable.CommandBufferExp; + auto &dditable = + ur_validation_layer::getContext()->urDdiTable.CommandBufferExp; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_validation_layer::context.version) != + if (UR_MAJOR_VERSION(ur_validation_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_validation_layer::context.version) > + UR_MINOR_VERSION(ur_validation_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -9887,15 +9915,15 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetContextProcAddrTable( ur_context_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_validation_layer::context.urDdiTable.Context; + auto &dditable = ur_validation_layer::getContext()->urDdiTable.Context; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_validation_layer::context.version) != + if (UR_MAJOR_VERSION(ur_validation_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_validation_layer::context.version) > + UR_MINOR_VERSION(ur_validation_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -9942,15 +9970,15 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetEnqueueProcAddrTable( ur_enqueue_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_validation_layer::context.urDdiTable.Enqueue; + auto &dditable = ur_validation_layer::getContext()->urDdiTable.Enqueue; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_validation_layer::context.version) != + if (UR_MAJOR_VERSION(ur_validation_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_validation_layer::context.version) > + UR_MINOR_VERSION(ur_validation_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -10056,15 +10084,15 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetEnqueueExpProcAddrTable( ur_enqueue_exp_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_validation_layer::context.urDdiTable.EnqueueExp; + auto &dditable = ur_validation_layer::getContext()->urDdiTable.EnqueueExp; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_validation_layer::context.version) != + if (UR_MAJOR_VERSION(ur_validation_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_validation_layer::context.version) > + UR_MINOR_VERSION(ur_validation_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -10104,15 +10132,15 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetEventProcAddrTable( ur_event_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_validation_layer::context.urDdiTable.Event; + auto &dditable = ur_validation_layer::getContext()->urDdiTable.Event; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_validation_layer::context.version) != + if (UR_MAJOR_VERSION(ur_validation_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_validation_layer::context.version) > + UR_MINOR_VERSION(ur_validation_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -10161,15 +10189,15 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetKernelProcAddrTable( ur_kernel_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_validation_layer::context.urDdiTable.Kernel; + auto &dditable = ur_validation_layer::getContext()->urDdiTable.Kernel; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_validation_layer::context.version) != + if (UR_MAJOR_VERSION(ur_validation_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_validation_layer::context.version) > + UR_MINOR_VERSION(ur_validation_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -10247,15 +10275,15 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetKernelExpProcAddrTable( ur_kernel_exp_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_validation_layer::context.urDdiTable.KernelExp; + auto &dditable = ur_validation_layer::getContext()->urDdiTable.KernelExp; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_validation_layer::context.version) != + if (UR_MAJOR_VERSION(ur_validation_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_validation_layer::context.version) > + UR_MINOR_VERSION(ur_validation_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -10283,15 +10311,15 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetMemProcAddrTable( ur_mem_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_validation_layer::context.urDdiTable.Mem; + auto &dditable = ur_validation_layer::getContext()->urDdiTable.Mem; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_validation_layer::context.version) != + if (UR_MAJOR_VERSION(ur_validation_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_validation_layer::context.version) > + UR_MINOR_VERSION(ur_validation_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -10348,15 +10376,15 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetPhysicalMemProcAddrTable( ur_physical_mem_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_validation_layer::context.urDdiTable.PhysicalMem; + auto &dditable = ur_validation_layer::getContext()->urDdiTable.PhysicalMem; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_validation_layer::context.version) != + if (UR_MAJOR_VERSION(ur_validation_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_validation_layer::context.version) > + UR_MINOR_VERSION(ur_validation_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -10388,15 +10416,15 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetPlatformProcAddrTable( ur_platform_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_validation_layer::context.urDdiTable.Platform; + auto &dditable = ur_validation_layer::getContext()->urDdiTable.Platform; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_validation_layer::context.version) != + if (UR_MAJOR_VERSION(ur_validation_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_validation_layer::context.version) > + UR_MINOR_VERSION(ur_validation_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -10440,15 +10468,15 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetProgramProcAddrTable( ur_program_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_validation_layer::context.urDdiTable.Program; + auto &dditable = ur_validation_layer::getContext()->urDdiTable.Program; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_validation_layer::context.version) != + if (UR_MAJOR_VERSION(ur_validation_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_validation_layer::context.version) > + UR_MINOR_VERSION(ur_validation_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -10521,15 +10549,15 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetProgramExpProcAddrTable( ur_program_exp_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_validation_layer::context.urDdiTable.ProgramExp; + auto &dditable = ur_validation_layer::getContext()->urDdiTable.ProgramExp; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_validation_layer::context.version) != + if (UR_MAJOR_VERSION(ur_validation_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_validation_layer::context.version) > + UR_MINOR_VERSION(ur_validation_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -10561,15 +10589,15 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetQueueProcAddrTable( ur_queue_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_validation_layer::context.urDdiTable.Queue; + auto &dditable = ur_validation_layer::getContext()->urDdiTable.Queue; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_validation_layer::context.version) != + if (UR_MAJOR_VERSION(ur_validation_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_validation_layer::context.version) > + UR_MINOR_VERSION(ur_validation_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -10617,15 +10645,15 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetSamplerProcAddrTable( ur_sampler_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_validation_layer::context.urDdiTable.Sampler; + auto &dditable = ur_validation_layer::getContext()->urDdiTable.Sampler; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_validation_layer::context.version) != + if (UR_MAJOR_VERSION(ur_validation_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_validation_layer::context.version) > + UR_MINOR_VERSION(ur_validation_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -10668,15 +10696,15 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetUSMProcAddrTable( ur_usm_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_validation_layer::context.urDdiTable.USM; + auto &dditable = ur_validation_layer::getContext()->urDdiTable.USM; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_validation_layer::context.version) != + if (UR_MAJOR_VERSION(ur_validation_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_validation_layer::context.version) > + UR_MINOR_VERSION(ur_validation_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -10726,15 +10754,15 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetUSMExpProcAddrTable( ur_usm_exp_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_validation_layer::context.urDdiTable.USMExp; + auto &dditable = ur_validation_layer::getContext()->urDdiTable.USMExp; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_validation_layer::context.version) != + if (UR_MAJOR_VERSION(ur_validation_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_validation_layer::context.version) > + UR_MINOR_VERSION(ur_validation_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -10766,15 +10794,15 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetUsmP2PExpProcAddrTable( ur_usm_p2p_exp_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_validation_layer::context.urDdiTable.UsmP2PExp; + auto &dditable = ur_validation_layer::getContext()->urDdiTable.UsmP2PExp; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_validation_layer::context.version) != + if (UR_MAJOR_VERSION(ur_validation_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_validation_layer::context.version) > + UR_MINOR_VERSION(ur_validation_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -10809,15 +10837,15 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetVirtualMemProcAddrTable( ur_virtual_mem_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_validation_layer::context.urDdiTable.VirtualMem; + auto &dditable = ur_validation_layer::getContext()->urDdiTable.VirtualMem; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_validation_layer::context.version) != + if (UR_MAJOR_VERSION(ur_validation_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_validation_layer::context.version) > + UR_MINOR_VERSION(ur_validation_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } @@ -10862,15 +10890,15 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetDeviceProcAddrTable( ur_device_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers ) { - auto &dditable = ur_validation_layer::context.urDdiTable.Device; + auto &dditable = ur_validation_layer::getContext()->urDdiTable.Device; if (nullptr == pDdiTable) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_MAJOR_VERSION(ur_validation_layer::context.version) != + if (UR_MAJOR_VERSION(ur_validation_layer::getContext()->version) != UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_validation_layer::context.version) > + UR_MINOR_VERSION(ur_validation_layer::getContext()->version) > UR_MINOR_VERSION(version)) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } diff --git a/source/loader/layers/validation/ur_validation_layer.cpp b/source/loader/layers/validation/ur_validation_layer.cpp index 3e040fcc50..dbbf6c7769 100644 --- a/source/loader/layers/validation/ur_validation_layer.cpp +++ b/source/loader/layers/validation/ur_validation_layer.cpp @@ -14,7 +14,7 @@ #include namespace ur_validation_layer { -context_t context; +context_t *getContext() { return context_t::get(); } /////////////////////////////////////////////////////////////////////////////// context_t::context_t() : logger(logger::create_logger("validation")) {} @@ -29,14 +29,14 @@ context_t::~context_t() {} result == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) \ return UR_RESULT_SUCCESS; \ if (result != UR_RESULT_SUCCESS) { \ - context.logger.error("Unexpected non-success result code from {}", \ - #result); \ + getContext()->logger.error( \ + "Unexpected non-success result code from {}", #result); \ assert(0); \ return result; \ } ur_result_t bounds(ur_mem_handle_t buffer, size_t offset, size_t size) { - auto pfnMemGetInfo = context.urDdiTable.Mem.pfnGetInfo; + auto pfnMemGetInfo = getContext()->urDdiTable.Mem.pfnGetInfo; size_t bufferSize = 0; RETURN_ON_FAILURE(pfnMemGetInfo(buffer, UR_MEM_INFO_SIZE, @@ -51,7 +51,7 @@ ur_result_t bounds(ur_mem_handle_t buffer, size_t offset, size_t size) { ur_result_t bounds(ur_mem_handle_t buffer, ur_rect_offset_t offset, ur_rect_region_t region) { - auto pfnMemGetInfo = context.urDdiTable.Mem.pfnGetInfo; + auto pfnMemGetInfo = getContext()->urDdiTable.Mem.pfnGetInfo; size_t bufferSize = 0; RETURN_ON_FAILURE(pfnMemGetInfo(buffer, UR_MEM_INFO_SIZE, @@ -73,8 +73,9 @@ ur_result_t bounds(ur_mem_handle_t buffer, ur_rect_offset_t offset, ur_result_t bounds(ur_queue_handle_t queue, const void *ptr, size_t offset, size_t size) { - auto pfnQueueGetInfo = context.urDdiTable.Queue.pfnGetInfo; - auto pfnUSMGetMemAllocInfo = context.urDdiTable.USM.pfnGetMemAllocInfo; + auto pfnQueueGetInfo = getContext()->urDdiTable.Queue.pfnGetInfo; + auto pfnUSMGetMemAllocInfo = + getContext()->urDdiTable.USM.pfnGetMemAllocInfo; ur_context_handle_t urContext = nullptr; RETURN_ON_FAILURE(pfnQueueGetInfo(queue, UR_QUEUE_INFO_CONTEXT, @@ -105,7 +106,7 @@ ur_result_t bounds(ur_queue_handle_t queue, const void *ptr, size_t offset, ur_result_t boundsImage(ur_mem_handle_t image, ur_rect_offset_t origin, ur_rect_region_t region) { - auto pfnMemImageGetInfo = context.urDdiTable.Mem.pfnImageGetInfo; + auto pfnMemImageGetInfo = getContext()->urDdiTable.Mem.pfnImageGetInfo; size_t width = 0; RETURN_ON_FAILURE(pfnMemImageGetInfo(image, UR_IMAGE_INFO_WIDTH, diff --git a/source/loader/layers/validation/ur_validation_layer.hpp b/source/loader/layers/validation/ur_validation_layer.hpp index c72932c453..18e388d5c9 100644 --- a/source/loader/layers/validation/ur_validation_layer.hpp +++ b/source/loader/layers/validation/ur_validation_layer.hpp @@ -18,7 +18,8 @@ namespace ur_validation_layer { /////////////////////////////////////////////////////////////////////////////// -class __urdlllocal context_t : public proxy_layer_context_t { +class __urdlllocal context_t : public proxy_layer_context_t, + public AtomicSingleton { public: bool enableParameterValidation = false; bool enableLeakChecking = false; @@ -58,6 +59,6 @@ ur_result_t bounds(ur_queue_handle_t queue, const void *ptr, size_t offset, ur_result_t boundsImage(ur_mem_handle_t image, ur_rect_offset_t origin, ur_rect_region_t region); -extern context_t context; +context_t *getContext(); } // namespace ur_validation_layer diff --git a/source/loader/linux/lib_init.cpp b/source/loader/linux/lib_init.cpp deleted file mode 100644 index d7c73d982b..0000000000 --- a/source/loader/linux/lib_init.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/* - * - * Copyright (C) 2022-2023 Intel Corporation - * - * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. - * See LICENSE.TXT - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - */ - -#include "ur_lib.hpp" - -namespace ur_lib { - -void __attribute__((constructor)) createLibContext() { - context = new context_t; -} - -void __attribute__((destructor)) deleteLibContext() { delete context; } - -} // namespace ur_lib diff --git a/source/loader/linux/loader_init.cpp b/source/loader/linux/loader_init.cpp deleted file mode 100644 index 8becec8b5b..0000000000 --- a/source/loader/linux/loader_init.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/* - * - * Copyright (C) 2022-2023 Intel Corporation - * - * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. - * See LICENSE.TXT - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - */ - -#include "ur_loader.hpp" - -namespace ur_loader { - -void __attribute__((constructor)) createLoaderContext() { - context = new context_t; -} - -void __attribute__((destructor)) deleteLoaderContext() { delete context; } - -} // namespace ur_loader diff --git a/source/loader/ur_ldrddi.cpp b/source/loader/ur_ldrddi.cpp index d064254461..7dfdcade14 100644 --- a/source/loader/ur_ldrddi.cpp +++ b/source/loader/ur_ldrddi.cpp @@ -52,7 +52,7 @@ __urdlllocal ur_result_t UR_APICALL urAdapterGet( size_t adapterIndex = 0; if (nullptr != phAdapters && NumEntries != 0) { - for (auto &platform : context->platforms) { + for (auto &platform : getContext()->platforms) { if (platform.initStatus != UR_RESULT_SUCCESS) { continue; } @@ -75,7 +75,7 @@ __urdlllocal ur_result_t UR_APICALL urAdapterGet( } if (pNumAdapters != nullptr) { - *pNumAdapters = static_cast(context->platforms.size()); + *pNumAdapters = static_cast(getContext()->platforms.size()); } return result; @@ -8202,14 +8202,14 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetGlobalProcAddrTable( return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (ur_loader::context->version < version) { + if (ur_loader::getContext()->version < version) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } ur_result_t result = UR_RESULT_SUCCESS; // Load the device-platform DDI tables - for (auto &platform : ur_loader::context->platforms) { + for (auto &platform : ur_loader::getContext()->platforms) { if (platform.initStatus != UR_RESULT_SUCCESS) { continue; } @@ -8223,8 +8223,8 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetGlobalProcAddrTable( } if (UR_RESULT_SUCCESS == result) { - if (ur_loader::context->platforms.size() != 1 || - ur_loader::context->forceIntercept) { + if (ur_loader::getContext()->platforms.size() != 1 || + ur_loader::getContext()->forceIntercept) { // return pointers to loader's DDIs pDdiTable->pfnAdapterGet = ur_loader::urAdapterGet; pDdiTable->pfnAdapterRelease = ur_loader::urAdapterRelease; @@ -8235,7 +8235,7 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetGlobalProcAddrTable( } else { // return pointers directly to platform's DDIs *pDdiTable = - ur_loader::context->platforms.front().dditable.ur.Global; + ur_loader::getContext()->platforms.front().dditable.ur.Global; } } @@ -8260,14 +8260,14 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetBindlessImagesExpProcAddrTable( return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (ur_loader::context->version < version) { + if (ur_loader::getContext()->version < version) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } ur_result_t result = UR_RESULT_SUCCESS; // Load the device-platform DDI tables - for (auto &platform : ur_loader::context->platforms) { + for (auto &platform : ur_loader::getContext()->platforms) { if (platform.initStatus != UR_RESULT_SUCCESS) { continue; } @@ -8284,8 +8284,8 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetBindlessImagesExpProcAddrTable( } if (UR_RESULT_SUCCESS == result) { - if (ur_loader::context->platforms.size() != 1 || - ur_loader::context->forceIntercept) { + if (ur_loader::getContext()->platforms.size() != 1 || + ur_loader::getContext()->forceIntercept) { // return pointers to loader's DDIs pDdiTable->pfnUnsampledImageHandleDestroyExp = ur_loader::urBindlessImagesUnsampledImageHandleDestroyExp; @@ -8323,7 +8323,8 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetBindlessImagesExpProcAddrTable( ur_loader::urBindlessImagesSignalExternalSemaphoreExp; } else { // return pointers directly to platform's DDIs - *pDdiTable = ur_loader::context->platforms.front() + *pDdiTable = ur_loader::getContext() + ->platforms.front() .dditable.ur.BindlessImagesExp; } } @@ -8349,14 +8350,14 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetCommandBufferExpProcAddrTable( return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (ur_loader::context->version < version) { + if (ur_loader::getContext()->version < version) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } ur_result_t result = UR_RESULT_SUCCESS; // Load the device-platform DDI tables - for (auto &platform : ur_loader::context->platforms) { + for (auto &platform : ur_loader::getContext()->platforms) { if (platform.initStatus != UR_RESULT_SUCCESS) { continue; } @@ -8373,8 +8374,8 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetCommandBufferExpProcAddrTable( } if (UR_RESULT_SUCCESS == result) { - if (ur_loader::context->platforms.size() != 1 || - ur_loader::context->forceIntercept) { + if (ur_loader::getContext()->platforms.size() != 1 || + ur_loader::getContext()->forceIntercept) { // return pointers to loader's DDIs pDdiTable->pfnCreateExp = ur_loader::urCommandBufferCreateExp; pDdiTable->pfnRetainExp = ur_loader::urCommandBufferRetainExp; @@ -8416,7 +8417,8 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetCommandBufferExpProcAddrTable( ur_loader::urCommandBufferCommandGetInfoExp; } else { // return pointers directly to platform's DDIs - *pDdiTable = ur_loader::context->platforms.front() + *pDdiTable = ur_loader::getContext() + ->platforms.front() .dditable.ur.CommandBufferExp; } } @@ -8442,14 +8444,14 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetContextProcAddrTable( return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (ur_loader::context->version < version) { + if (ur_loader::getContext()->version < version) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } ur_result_t result = UR_RESULT_SUCCESS; // Load the device-platform DDI tables - for (auto &platform : ur_loader::context->platforms) { + for (auto &platform : ur_loader::getContext()->platforms) { if (platform.initStatus != UR_RESULT_SUCCESS) { continue; } @@ -8463,8 +8465,8 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetContextProcAddrTable( } if (UR_RESULT_SUCCESS == result) { - if (ur_loader::context->platforms.size() != 1 || - ur_loader::context->forceIntercept) { + if (ur_loader::getContext()->platforms.size() != 1 || + ur_loader::getContext()->forceIntercept) { // return pointers to loader's DDIs pDdiTable->pfnCreate = ur_loader::urContextCreate; pDdiTable->pfnRetain = ur_loader::urContextRetain; @@ -8478,7 +8480,7 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetContextProcAddrTable( } else { // return pointers directly to platform's DDIs *pDdiTable = - ur_loader::context->platforms.front().dditable.ur.Context; + ur_loader::getContext()->platforms.front().dditable.ur.Context; } } @@ -8503,14 +8505,14 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetEnqueueProcAddrTable( return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (ur_loader::context->version < version) { + if (ur_loader::getContext()->version < version) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } ur_result_t result = UR_RESULT_SUCCESS; // Load the device-platform DDI tables - for (auto &platform : ur_loader::context->platforms) { + for (auto &platform : ur_loader::getContext()->platforms) { if (platform.initStatus != UR_RESULT_SUCCESS) { continue; } @@ -8524,8 +8526,8 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetEnqueueProcAddrTable( } if (UR_RESULT_SUCCESS == result) { - if (ur_loader::context->platforms.size() != 1 || - ur_loader::context->forceIntercept) { + if (ur_loader::getContext()->platforms.size() != 1 || + ur_loader::getContext()->forceIntercept) { // return pointers to loader's DDIs pDdiTable->pfnKernelLaunch = ur_loader::urEnqueueKernelLaunch; pDdiTable->pfnEventsWait = ur_loader::urEnqueueEventsWait; @@ -8561,7 +8563,7 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetEnqueueProcAddrTable( } else { // return pointers directly to platform's DDIs *pDdiTable = - ur_loader::context->platforms.front().dditable.ur.Enqueue; + ur_loader::getContext()->platforms.front().dditable.ur.Enqueue; } } @@ -8586,14 +8588,14 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetEnqueueExpProcAddrTable( return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (ur_loader::context->version < version) { + if (ur_loader::getContext()->version < version) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } ur_result_t result = UR_RESULT_SUCCESS; // Load the device-platform DDI tables - for (auto &platform : ur_loader::context->platforms) { + for (auto &platform : ur_loader::getContext()->platforms) { if (platform.initStatus != UR_RESULT_SUCCESS) { continue; } @@ -8608,8 +8610,8 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetEnqueueExpProcAddrTable( } if (UR_RESULT_SUCCESS == result) { - if (ur_loader::context->platforms.size() != 1 || - ur_loader::context->forceIntercept) { + if (ur_loader::getContext()->platforms.size() != 1 || + ur_loader::getContext()->forceIntercept) { // return pointers to loader's DDIs pDdiTable->pfnKernelLaunchCustomExp = ur_loader::urEnqueueKernelLaunchCustomExp; @@ -8621,8 +8623,9 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetEnqueueExpProcAddrTable( ur_loader::urEnqueueNativeCommandExp; } else { // return pointers directly to platform's DDIs - *pDdiTable = - ur_loader::context->platforms.front().dditable.ur.EnqueueExp; + *pDdiTable = ur_loader::getContext() + ->platforms.front() + .dditable.ur.EnqueueExp; } } @@ -8647,14 +8650,14 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetEventProcAddrTable( return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (ur_loader::context->version < version) { + if (ur_loader::getContext()->version < version) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } ur_result_t result = UR_RESULT_SUCCESS; // Load the device-platform DDI tables - for (auto &platform : ur_loader::context->platforms) { + for (auto &platform : ur_loader::getContext()->platforms) { if (platform.initStatus != UR_RESULT_SUCCESS) { continue; } @@ -8668,8 +8671,8 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetEventProcAddrTable( } if (UR_RESULT_SUCCESS == result) { - if (ur_loader::context->platforms.size() != 1 || - ur_loader::context->forceIntercept) { + if (ur_loader::getContext()->platforms.size() != 1 || + ur_loader::getContext()->forceIntercept) { // return pointers to loader's DDIs pDdiTable->pfnGetInfo = ur_loader::urEventGetInfo; pDdiTable->pfnGetProfilingInfo = ur_loader::urEventGetProfilingInfo; @@ -8683,7 +8686,7 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetEventProcAddrTable( } else { // return pointers directly to platform's DDIs *pDdiTable = - ur_loader::context->platforms.front().dditable.ur.Event; + ur_loader::getContext()->platforms.front().dditable.ur.Event; } } @@ -8708,14 +8711,14 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetKernelProcAddrTable( return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (ur_loader::context->version < version) { + if (ur_loader::getContext()->version < version) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } ur_result_t result = UR_RESULT_SUCCESS; // Load the device-platform DDI tables - for (auto &platform : ur_loader::context->platforms) { + for (auto &platform : ur_loader::getContext()->platforms) { if (platform.initStatus != UR_RESULT_SUCCESS) { continue; } @@ -8729,8 +8732,8 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetKernelProcAddrTable( } if (UR_RESULT_SUCCESS == result) { - if (ur_loader::context->platforms.size() != 1 || - ur_loader::context->forceIntercept) { + if (ur_loader::getContext()->platforms.size() != 1 || + ur_loader::getContext()->forceIntercept) { // return pointers to loader's DDIs pDdiTable->pfnCreate = ur_loader::urKernelCreate; pDdiTable->pfnGetInfo = ur_loader::urKernelGetInfo; @@ -8754,7 +8757,7 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetKernelProcAddrTable( } else { // return pointers directly to platform's DDIs *pDdiTable = - ur_loader::context->platforms.front().dditable.ur.Kernel; + ur_loader::getContext()->platforms.front().dditable.ur.Kernel; } } @@ -8779,14 +8782,14 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetKernelExpProcAddrTable( return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (ur_loader::context->version < version) { + if (ur_loader::getContext()->version < version) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } ur_result_t result = UR_RESULT_SUCCESS; // Load the device-platform DDI tables - for (auto &platform : ur_loader::context->platforms) { + for (auto &platform : ur_loader::getContext()->platforms) { if (platform.initStatus != UR_RESULT_SUCCESS) { continue; } @@ -8801,15 +8804,16 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetKernelExpProcAddrTable( } if (UR_RESULT_SUCCESS == result) { - if (ur_loader::context->platforms.size() != 1 || - ur_loader::context->forceIntercept) { + if (ur_loader::getContext()->platforms.size() != 1 || + ur_loader::getContext()->forceIntercept) { // return pointers to loader's DDIs pDdiTable->pfnSuggestMaxCooperativeGroupCountExp = ur_loader::urKernelSuggestMaxCooperativeGroupCountExp; } else { // return pointers directly to platform's DDIs - *pDdiTable = - ur_loader::context->platforms.front().dditable.ur.KernelExp; + *pDdiTable = ur_loader::getContext() + ->platforms.front() + .dditable.ur.KernelExp; } } @@ -8834,14 +8838,14 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetMemProcAddrTable( return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (ur_loader::context->version < version) { + if (ur_loader::getContext()->version < version) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } ur_result_t result = UR_RESULT_SUCCESS; // Load the device-platform DDI tables - for (auto &platform : ur_loader::context->platforms) { + for (auto &platform : ur_loader::getContext()->platforms) { if (platform.initStatus != UR_RESULT_SUCCESS) { continue; } @@ -8855,8 +8859,8 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetMemProcAddrTable( } if (UR_RESULT_SUCCESS == result) { - if (ur_loader::context->platforms.size() != 1 || - ur_loader::context->forceIntercept) { + if (ur_loader::getContext()->platforms.size() != 1 || + ur_loader::getContext()->forceIntercept) { // return pointers to loader's DDIs pDdiTable->pfnImageCreate = ur_loader::urMemImageCreate; pDdiTable->pfnBufferCreate = ur_loader::urMemBufferCreate; @@ -8872,7 +8876,8 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetMemProcAddrTable( pDdiTable->pfnImageGetInfo = ur_loader::urMemImageGetInfo; } else { // return pointers directly to platform's DDIs - *pDdiTable = ur_loader::context->platforms.front().dditable.ur.Mem; + *pDdiTable = + ur_loader::getContext()->platforms.front().dditable.ur.Mem; } } @@ -8897,14 +8902,14 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetPhysicalMemProcAddrTable( return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (ur_loader::context->version < version) { + if (ur_loader::getContext()->version < version) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } ur_result_t result = UR_RESULT_SUCCESS; // Load the device-platform DDI tables - for (auto &platform : ur_loader::context->platforms) { + for (auto &platform : ur_loader::getContext()->platforms) { if (platform.initStatus != UR_RESULT_SUCCESS) { continue; } @@ -8919,16 +8924,17 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetPhysicalMemProcAddrTable( } if (UR_RESULT_SUCCESS == result) { - if (ur_loader::context->platforms.size() != 1 || - ur_loader::context->forceIntercept) { + if (ur_loader::getContext()->platforms.size() != 1 || + ur_loader::getContext()->forceIntercept) { // return pointers to loader's DDIs pDdiTable->pfnCreate = ur_loader::urPhysicalMemCreate; pDdiTable->pfnRetain = ur_loader::urPhysicalMemRetain; pDdiTable->pfnRelease = ur_loader::urPhysicalMemRelease; } else { // return pointers directly to platform's DDIs - *pDdiTable = - ur_loader::context->platforms.front().dditable.ur.PhysicalMem; + *pDdiTable = ur_loader::getContext() + ->platforms.front() + .dditable.ur.PhysicalMem; } } @@ -8953,14 +8959,14 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetPlatformProcAddrTable( return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (ur_loader::context->version < version) { + if (ur_loader::getContext()->version < version) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } ur_result_t result = UR_RESULT_SUCCESS; // Load the device-platform DDI tables - for (auto &platform : ur_loader::context->platforms) { + for (auto &platform : ur_loader::getContext()->platforms) { if (platform.initStatus != UR_RESULT_SUCCESS) { continue; } @@ -8974,8 +8980,8 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetPlatformProcAddrTable( } if (UR_RESULT_SUCCESS == result) { - if (ur_loader::context->platforms.size() != 1 || - ur_loader::context->forceIntercept) { + if (ur_loader::getContext()->platforms.size() != 1 || + ur_loader::getContext()->forceIntercept) { // return pointers to loader's DDIs pDdiTable->pfnGet = ur_loader::urPlatformGet; pDdiTable->pfnGetInfo = ur_loader::urPlatformGetInfo; @@ -8989,7 +8995,7 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetPlatformProcAddrTable( } else { // return pointers directly to platform's DDIs *pDdiTable = - ur_loader::context->platforms.front().dditable.ur.Platform; + ur_loader::getContext()->platforms.front().dditable.ur.Platform; } } @@ -9014,14 +9020,14 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetProgramProcAddrTable( return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (ur_loader::context->version < version) { + if (ur_loader::getContext()->version < version) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } ur_result_t result = UR_RESULT_SUCCESS; // Load the device-platform DDI tables - for (auto &platform : ur_loader::context->platforms) { + for (auto &platform : ur_loader::getContext()->platforms) { if (platform.initStatus != UR_RESULT_SUCCESS) { continue; } @@ -9035,8 +9041,8 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetProgramProcAddrTable( } if (UR_RESULT_SUCCESS == result) { - if (ur_loader::context->platforms.size() != 1 || - ur_loader::context->forceIntercept) { + if (ur_loader::getContext()->platforms.size() != 1 || + ur_loader::getContext()->forceIntercept) { // return pointers to loader's DDIs pDdiTable->pfnCreateWithIL = ur_loader::urProgramCreateWithIL; pDdiTable->pfnCreateWithBinary = @@ -9060,7 +9066,7 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetProgramProcAddrTable( } else { // return pointers directly to platform's DDIs *pDdiTable = - ur_loader::context->platforms.front().dditable.ur.Program; + ur_loader::getContext()->platforms.front().dditable.ur.Program; } } @@ -9085,14 +9091,14 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetProgramExpProcAddrTable( return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (ur_loader::context->version < version) { + if (ur_loader::getContext()->version < version) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } ur_result_t result = UR_RESULT_SUCCESS; // Load the device-platform DDI tables - for (auto &platform : ur_loader::context->platforms) { + for (auto &platform : ur_loader::getContext()->platforms) { if (platform.initStatus != UR_RESULT_SUCCESS) { continue; } @@ -9107,16 +9113,17 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetProgramExpProcAddrTable( } if (UR_RESULT_SUCCESS == result) { - if (ur_loader::context->platforms.size() != 1 || - ur_loader::context->forceIntercept) { + if (ur_loader::getContext()->platforms.size() != 1 || + ur_loader::getContext()->forceIntercept) { // return pointers to loader's DDIs pDdiTable->pfnBuildExp = ur_loader::urProgramBuildExp; pDdiTable->pfnCompileExp = ur_loader::urProgramCompileExp; pDdiTable->pfnLinkExp = ur_loader::urProgramLinkExp; } else { // return pointers directly to platform's DDIs - *pDdiTable = - ur_loader::context->platforms.front().dditable.ur.ProgramExp; + *pDdiTable = ur_loader::getContext() + ->platforms.front() + .dditable.ur.ProgramExp; } } @@ -9141,14 +9148,14 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetQueueProcAddrTable( return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (ur_loader::context->version < version) { + if (ur_loader::getContext()->version < version) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } ur_result_t result = UR_RESULT_SUCCESS; // Load the device-platform DDI tables - for (auto &platform : ur_loader::context->platforms) { + for (auto &platform : ur_loader::getContext()->platforms) { if (platform.initStatus != UR_RESULT_SUCCESS) { continue; } @@ -9162,8 +9169,8 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetQueueProcAddrTable( } if (UR_RESULT_SUCCESS == result) { - if (ur_loader::context->platforms.size() != 1 || - ur_loader::context->forceIntercept) { + if (ur_loader::getContext()->platforms.size() != 1 || + ur_loader::getContext()->forceIntercept) { // return pointers to loader's DDIs pDdiTable->pfnGetInfo = ur_loader::urQueueGetInfo; pDdiTable->pfnCreate = ur_loader::urQueueCreate; @@ -9177,7 +9184,7 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetQueueProcAddrTable( } else { // return pointers directly to platform's DDIs *pDdiTable = - ur_loader::context->platforms.front().dditable.ur.Queue; + ur_loader::getContext()->platforms.front().dditable.ur.Queue; } } @@ -9202,14 +9209,14 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetSamplerProcAddrTable( return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (ur_loader::context->version < version) { + if (ur_loader::getContext()->version < version) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } ur_result_t result = UR_RESULT_SUCCESS; // Load the device-platform DDI tables - for (auto &platform : ur_loader::context->platforms) { + for (auto &platform : ur_loader::getContext()->platforms) { if (platform.initStatus != UR_RESULT_SUCCESS) { continue; } @@ -9223,8 +9230,8 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetSamplerProcAddrTable( } if (UR_RESULT_SUCCESS == result) { - if (ur_loader::context->platforms.size() != 1 || - ur_loader::context->forceIntercept) { + if (ur_loader::getContext()->platforms.size() != 1 || + ur_loader::getContext()->forceIntercept) { // return pointers to loader's DDIs pDdiTable->pfnCreate = ur_loader::urSamplerCreate; pDdiTable->pfnRetain = ur_loader::urSamplerRetain; @@ -9236,7 +9243,7 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetSamplerProcAddrTable( } else { // return pointers directly to platform's DDIs *pDdiTable = - ur_loader::context->platforms.front().dditable.ur.Sampler; + ur_loader::getContext()->platforms.front().dditable.ur.Sampler; } } @@ -9261,14 +9268,14 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetUSMProcAddrTable( return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (ur_loader::context->version < version) { + if (ur_loader::getContext()->version < version) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } ur_result_t result = UR_RESULT_SUCCESS; // Load the device-platform DDI tables - for (auto &platform : ur_loader::context->platforms) { + for (auto &platform : ur_loader::getContext()->platforms) { if (platform.initStatus != UR_RESULT_SUCCESS) { continue; } @@ -9282,8 +9289,8 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetUSMProcAddrTable( } if (UR_RESULT_SUCCESS == result) { - if (ur_loader::context->platforms.size() != 1 || - ur_loader::context->forceIntercept) { + if (ur_loader::getContext()->platforms.size() != 1 || + ur_loader::getContext()->forceIntercept) { // return pointers to loader's DDIs pDdiTable->pfnHostAlloc = ur_loader::urUSMHostAlloc; pDdiTable->pfnDeviceAlloc = ur_loader::urUSMDeviceAlloc; @@ -9296,7 +9303,8 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetUSMProcAddrTable( pDdiTable->pfnPoolGetInfo = ur_loader::urUSMPoolGetInfo; } else { // return pointers directly to platform's DDIs - *pDdiTable = ur_loader::context->platforms.front().dditable.ur.USM; + *pDdiTable = + ur_loader::getContext()->platforms.front().dditable.ur.USM; } } @@ -9321,14 +9329,14 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetUSMExpProcAddrTable( return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (ur_loader::context->version < version) { + if (ur_loader::getContext()->version < version) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } ur_result_t result = UR_RESULT_SUCCESS; // Load the device-platform DDI tables - for (auto &platform : ur_loader::context->platforms) { + for (auto &platform : ur_loader::getContext()->platforms) { if (platform.initStatus != UR_RESULT_SUCCESS) { continue; } @@ -9342,8 +9350,8 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetUSMExpProcAddrTable( } if (UR_RESULT_SUCCESS == result) { - if (ur_loader::context->platforms.size() != 1 || - ur_loader::context->forceIntercept) { + if (ur_loader::getContext()->platforms.size() != 1 || + ur_loader::getContext()->forceIntercept) { // return pointers to loader's DDIs pDdiTable->pfnPitchedAllocExp = ur_loader::urUSMPitchedAllocExp; pDdiTable->pfnImportExp = ur_loader::urUSMImportExp; @@ -9351,7 +9359,7 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetUSMExpProcAddrTable( } else { // return pointers directly to platform's DDIs *pDdiTable = - ur_loader::context->platforms.front().dditable.ur.USMExp; + ur_loader::getContext()->platforms.front().dditable.ur.USMExp; } } @@ -9376,14 +9384,14 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetUsmP2PExpProcAddrTable( return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (ur_loader::context->version < version) { + if (ur_loader::getContext()->version < version) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } ur_result_t result = UR_RESULT_SUCCESS; // Load the device-platform DDI tables - for (auto &platform : ur_loader::context->platforms) { + for (auto &platform : ur_loader::getContext()->platforms) { if (platform.initStatus != UR_RESULT_SUCCESS) { continue; } @@ -9398,8 +9406,8 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetUsmP2PExpProcAddrTable( } if (UR_RESULT_SUCCESS == result) { - if (ur_loader::context->platforms.size() != 1 || - ur_loader::context->forceIntercept) { + if (ur_loader::getContext()->platforms.size() != 1 || + ur_loader::getContext()->forceIntercept) { // return pointers to loader's DDIs pDdiTable->pfnEnablePeerAccessExp = ur_loader::urUsmP2PEnablePeerAccessExp; @@ -9409,8 +9417,9 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetUsmP2PExpProcAddrTable( ur_loader::urUsmP2PPeerAccessGetInfoExp; } else { // return pointers directly to platform's DDIs - *pDdiTable = - ur_loader::context->platforms.front().dditable.ur.UsmP2PExp; + *pDdiTable = ur_loader::getContext() + ->platforms.front() + .dditable.ur.UsmP2PExp; } } @@ -9435,14 +9444,14 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetVirtualMemProcAddrTable( return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (ur_loader::context->version < version) { + if (ur_loader::getContext()->version < version) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } ur_result_t result = UR_RESULT_SUCCESS; // Load the device-platform DDI tables - for (auto &platform : ur_loader::context->platforms) { + for (auto &platform : ur_loader::getContext()->platforms) { if (platform.initStatus != UR_RESULT_SUCCESS) { continue; } @@ -9457,8 +9466,8 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetVirtualMemProcAddrTable( } if (UR_RESULT_SUCCESS == result) { - if (ur_loader::context->platforms.size() != 1 || - ur_loader::context->forceIntercept) { + if (ur_loader::getContext()->platforms.size() != 1 || + ur_loader::getContext()->forceIntercept) { // return pointers to loader's DDIs pDdiTable->pfnGranularityGetInfo = ur_loader::urVirtualMemGranularityGetInfo; @@ -9470,8 +9479,9 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetVirtualMemProcAddrTable( pDdiTable->pfnGetInfo = ur_loader::urVirtualMemGetInfo; } else { // return pointers directly to platform's DDIs - *pDdiTable = - ur_loader::context->platforms.front().dditable.ur.VirtualMem; + *pDdiTable = ur_loader::getContext() + ->platforms.front() + .dditable.ur.VirtualMem; } } @@ -9496,14 +9506,14 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetDeviceProcAddrTable( return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (ur_loader::context->version < version) { + if (ur_loader::getContext()->version < version) { return UR_RESULT_ERROR_UNSUPPORTED_VERSION; } ur_result_t result = UR_RESULT_SUCCESS; // Load the device-platform DDI tables - for (auto &platform : ur_loader::context->platforms) { + for (auto &platform : ur_loader::getContext()->platforms) { if (platform.initStatus != UR_RESULT_SUCCESS) { continue; } @@ -9517,8 +9527,8 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetDeviceProcAddrTable( } if (UR_RESULT_SUCCESS == result) { - if (ur_loader::context->platforms.size() != 1 || - ur_loader::context->forceIntercept) { + if (ur_loader::getContext()->platforms.size() != 1 || + ur_loader::getContext()->forceIntercept) { // return pointers to loader's DDIs pDdiTable->pfnGet = ur_loader::urDeviceGet; pDdiTable->pfnGetInfo = ur_loader::urDeviceGetInfo; @@ -9534,7 +9544,7 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetDeviceProcAddrTable( } else { // return pointers directly to platform's DDIs *pDdiTable = - ur_loader::context->platforms.front().dditable.ur.Device; + ur_loader::getContext()->platforms.front().dditable.ur.Device; } } diff --git a/source/loader/ur_lib.cpp b/source/loader/ur_lib.cpp index d2ed4853a8..b1eccc5180 100644 --- a/source/loader/ur_lib.cpp +++ b/source/loader/ur_lib.cpp @@ -15,10 +15,11 @@ // (not quite sure why windows.h is being included here) #ifndef NOMINMAX #define NOMINMAX +#include "ur_api.h" #endif // !NOMINMAX -#include "ur_lib.hpp" #include "logger/ur_logger.hpp" +#include "ur_lib.hpp" #include "ur_loader.hpp" #include // for std::memcpy @@ -26,13 +27,13 @@ namespace ur_lib { /////////////////////////////////////////////////////////////////////////////// -context_t *context; +context_t *getContext() { return context_t::get(); } /////////////////////////////////////////////////////////////////////////////// context_t::context_t() { - for (auto l : layers) { - if (l->isAvailable()) { - for (auto &layerName : l->getNames()) { + for (auto &[layer, _] : layers) { + if (layer->isAvailable()) { + for (auto &layerName : layer->getNames()) { availableLayers += layerName + ";"; } } @@ -62,18 +63,20 @@ void context_t::parseEnvEnabledLayers() { } void context_t::initLayers() const { - for (auto &l : layers) { - if (l->isAvailable()) { - l->init(&context->urDdiTable, enabledLayerNames, codelocData); + for (auto &[layer, _] : layers) { + if (layer->isAvailable()) { + layer->init(&getContext()->urDdiTable, enabledLayerNames, + codelocData); } } } void context_t::tearDownLayers() const { - for (auto &l : layers) { - if (l->isAvailable()) { - l->tearDown(); + for (auto &[layer, destroy] : layers) { + if (layer->isAvailable()) { + layer->tearDown(); } + destroy(); } } @@ -85,10 +88,10 @@ __urdlllocal ur_result_t context_t::Init( logger::init(logger_name); logger::debug("Logger {} initialized successfully!", logger_name); - result = ur_loader::context->init(); + result = ur_loader::getContext()->init(); if (UR_RESULT_SUCCESS == result) { - result = urLoaderInit(); + result = ddiInit(); } if (hLoaderConfig) { @@ -144,14 +147,14 @@ ur_result_t urLoaderConfigGetInfo(ur_loader_config_handle_t hLoaderConfig, switch (propName) { case UR_LOADER_CONFIG_INFO_AVAILABLE_LAYERS: { if (pPropSizeRet) { - *pPropSizeRet = context->availableLayers.size() + 1; + *pPropSizeRet = getContext()->availableLayers.size() + 1; } if (pPropValue) { char *outString = static_cast(pPropValue); - if (propSize != context->availableLayers.size() + 1) { + if (propSize != getContext()->availableLayers.size() + 1) { return UR_RESULT_ERROR_INVALID_SIZE; } - std::memcpy(outString, context->availableLayers.data(), + std::memcpy(outString, getContext()->availableLayers.data(), propSize - 1); outString[propSize - 1] = '\0'; } @@ -185,17 +188,37 @@ ur_result_t urLoaderConfigEnableLayer(ur_loader_config_handle_t hLoaderConfig, if (!pLayerName) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (!context->layerExists(std::string(pLayerName))) { + if (!getContext()->layerExists(std::string(pLayerName))) { return UR_RESULT_ERROR_LAYER_NOT_PRESENT; } hLoaderConfig->enabledLayers.insert(pLayerName); return UR_RESULT_SUCCESS; } +ur_result_t UR_APICALL urLoaderInit(ur_device_init_flags_t device_flags, + ur_loader_config_handle_t hLoaderConfig) { + if (UR_DEVICE_INIT_FLAGS_MASK & device_flags) { + return UR_RESULT_ERROR_INVALID_ENUMERATION; + } + + auto p = ur_lib::getContext(); + + static ur_result_t result = UR_RESULT_SUCCESS; + std::call_once(p->initOnce, [p, device_flags, hLoaderConfig]() { + result = p->Init(device_flags, hLoaderConfig); + }); + + return result; +} + ur_result_t urLoaderTearDown() { - context->tearDownLayers(); + int ret = ur_lib::context_t::release([](context_t *context) { + context->tearDownLayers(); + ur_loader::context_t::forceDelete(); + delete context; + }); - return UR_RESULT_SUCCESS; + return ret == 0 ? UR_RESULT_SUCCESS : UR_RESULT_ERROR_UNINITIALIZED; } ur_result_t diff --git a/source/loader/ur_lib.hpp b/source/loader/ur_lib.hpp index 839c0041d9..515c72697b 100644 --- a/source/loader/ur_lib.hpp +++ b/source/loader/ur_lib.hpp @@ -52,7 +52,7 @@ struct ur_loader_config_handle_t_ { namespace ur_lib { /////////////////////////////////////////////////////////////////////////////// -class __urdlllocal context_t { +class __urdlllocal context_t : public AtomicSingleton { public: #ifdef DYNAMIC_LOAD_LOADER HMODULE loader = nullptr; @@ -66,16 +66,20 @@ class __urdlllocal context_t { ur_result_t Init(ur_device_init_flags_t dflags, ur_loader_config_handle_t hLoaderConfig); - ur_result_t urLoaderInit(); + ur_result_t ddiInit(); ur_dditable_t urDdiTable = {}; - const std::vector layers = { - &ur_validation_layer::context, + using LayerData = std::pair; + const std::vector layers = { + {ur_validation_layer::getContext(), + ur_validation_layer::context_t::forceDelete}, #if UR_ENABLE_TRACING - &ur_tracing_layer::context, + {ur_tracing_layer::getContext(), + ur_tracing_layer::context_t::forceDelete}, #endif #if UR_ENABLE_SANITIZER - &ur_sanitizer_layer::context + {ur_sanitizer_layer::getContext(), + ur_sanitizer_layer::context_t::forceDelete}, #endif }; std::string availableLayers; @@ -89,7 +93,8 @@ class __urdlllocal context_t { void tearDownLayers() const; }; -extern context_t *context; +context_t *getContext(); + ur_result_t urLoaderConfigCreate(ur_loader_config_handle_t *phLoaderConfig); ur_result_t urLoaderConfigRetain(ur_loader_config_handle_t hLoaderConfig); ur_result_t urLoaderConfigRelease(ur_loader_config_handle_t hLoaderConfig); @@ -99,6 +104,8 @@ ur_result_t urLoaderConfigGetInfo(ur_loader_config_handle_t hLoaderConfig, size_t *pPropSizeRet); ur_result_t urLoaderConfigEnableLayer(ur_loader_config_handle_t hLoaderConfig, const char *pLayerName); +ur_result_t UR_APICALL urLoaderInit(ur_device_init_flags_t device_flags, + ur_loader_config_handle_t); ur_result_t urLoaderTearDown(); ur_result_t urLoaderConfigSetCodeLocationCallback(ur_loader_config_handle_t hLoaderConfig, diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index dd72354f3a..0109dc6e0d 100644 --- a/source/loader/ur_libapi.cpp +++ b/source/loader/ur_libapi.cpp @@ -223,17 +223,7 @@ ur_result_t UR_APICALL urLoaderInit( ur_loader_config_handle_t hLoaderConfig ///< [in][optional] Handle of loader config handle. ) try { - - if (UR_DEVICE_INIT_FLAGS_MASK & device_flags) { - return UR_RESULT_ERROR_INVALID_ENUMERATION; - } - - static ur_result_t result = UR_RESULT_SUCCESS; - std::call_once(ur_lib::context->initOnce, [device_flags, hLoaderConfig]() { - result = ur_lib::context->Init(device_flags, hLoaderConfig); - }); - - return result; + return ur_lib::urLoaderInit(device_flags, hLoaderConfig); } catch (...) { return exceptionToResult(std::current_exception()); } @@ -287,7 +277,7 @@ ur_result_t UR_APICALL urAdapterGet( uint32_t * pNumAdapters ///< [out][optional] returns the total number of adapters available. ) try { - auto pfnAdapterGet = ur_lib::context->urDdiTable.Global.pfnAdapterGet; + auto pfnAdapterGet = ur_lib::getContext()->urDdiTable.Global.pfnAdapterGet; if (nullptr == pfnAdapterGet) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -317,7 +307,7 @@ ur_result_t UR_APICALL urAdapterRelease( ur_adapter_handle_t hAdapter ///< [in][release] Adapter handle to release ) try { auto pfnAdapterRelease = - ur_lib::context->urDdiTable.Global.pfnAdapterRelease; + ur_lib::getContext()->urDdiTable.Global.pfnAdapterRelease; if (nullptr == pfnAdapterRelease) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -343,7 +333,8 @@ ur_result_t UR_APICALL urAdapterRelease( ur_result_t UR_APICALL urAdapterRetain( ur_adapter_handle_t hAdapter ///< [in] Adapter handle to retain ) try { - auto pfnAdapterRetain = ur_lib::context->urDdiTable.Global.pfnAdapterRetain; + auto pfnAdapterRetain = + ur_lib::getContext()->urDdiTable.Global.pfnAdapterRetain; if (nullptr == pfnAdapterRetain) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -406,7 +397,7 @@ ur_result_t UR_APICALL urAdapterGetLastError( ///< be stored. ) try { auto pfnAdapterGetLastError = - ur_lib::context->urDdiTable.Global.pfnAdapterGetLastError; + ur_lib::getContext()->urDdiTable.Global.pfnAdapterGetLastError; if (nullptr == pfnAdapterGetLastError) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -456,7 +447,7 @@ ur_result_t UR_APICALL urAdapterGetInfo( pPropSizeRet ///< [out][optional] pointer to the actual number of bytes being queried by pPropValue. ) try { auto pfnAdapterGetInfo = - ur_lib::context->urDdiTable.Global.pfnAdapterGetInfo; + ur_lib::getContext()->urDdiTable.Global.pfnAdapterGetInfo; if (nullptr == pfnAdapterGetInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -505,7 +496,7 @@ ur_result_t UR_APICALL urPlatformGet( uint32_t * pNumPlatforms ///< [out][optional] returns the total number of platforms available. ) try { - auto pfnGet = ur_lib::context->urDdiTable.Platform.pfnGet; + auto pfnGet = ur_lib::getContext()->urDdiTable.Platform.pfnGet; if (nullptr == pfnGet) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -560,7 +551,7 @@ ur_result_t UR_APICALL urPlatformGetInfo( size_t * pPropSizeRet ///< [out][optional] pointer to the actual number of bytes being queried by pPlatformInfo. ) try { - auto pfnGetInfo = ur_lib::context->urDdiTable.Platform.pfnGetInfo; + auto pfnGetInfo = ur_lib::getContext()->urDdiTable.Platform.pfnGetInfo; if (nullptr == pfnGetInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -591,7 +582,7 @@ ur_result_t UR_APICALL urPlatformGetApiVersion( ur_api_version_t *pVersion ///< [out] api version ) try { auto pfnGetApiVersion = - ur_lib::context->urDdiTable.Platform.pfnGetApiVersion; + ur_lib::getContext()->urDdiTable.Platform.pfnGetApiVersion; if (nullptr == pfnGetApiVersion) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -630,7 +621,7 @@ ur_result_t UR_APICALL urPlatformGetNativeHandle( phNativePlatform ///< [out] a pointer to the native handle of the platform. ) try { auto pfnGetNativeHandle = - ur_lib::context->urDdiTable.Platform.pfnGetNativeHandle; + ur_lib::getContext()->urDdiTable.Platform.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -671,7 +662,7 @@ ur_result_t UR_APICALL urPlatformCreateWithNativeHandle( phPlatform ///< [out] pointer to the handle of the platform object created. ) try { auto pfnCreateWithNativeHandle = - ur_lib::context->urDdiTable.Platform.pfnCreateWithNativeHandle; + ur_lib::getContext()->urDdiTable.Platform.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -716,7 +707,7 @@ ur_result_t UR_APICALL urPlatformGetBackendOption( ///< the frontend option. ) try { auto pfnGetBackendOption = - ur_lib::context->urDdiTable.Platform.pfnGetBackendOption; + ur_lib::getContext()->urDdiTable.Platform.pfnGetBackendOption; if (nullptr == pfnGetBackendOption) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -773,7 +764,7 @@ ur_result_t UR_APICALL urDeviceGet( uint32_t *pNumDevices ///< [out][optional] pointer to the number of devices. ///< pNumDevices will be updated with the total number of devices available. ) try { - auto pfnGet = ur_lib::context->urDdiTable.Device.pfnGet; + auto pfnGet = ur_lib::getContext()->urDdiTable.Device.pfnGet; if (nullptr == pfnGet) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -874,7 +865,7 @@ ur_result_t UR_APICALL urDeviceGetInfo( size_t * pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of the queried propName. ) try { - auto pfnGetInfo = ur_lib::context->urDdiTable.Device.pfnGetInfo; + auto pfnGetInfo = ur_lib::getContext()->urDdiTable.Device.pfnGetInfo; if (nullptr == pfnGetInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -914,7 +905,7 @@ ur_result_t UR_APICALL urDeviceRetain( ur_device_handle_t hDevice ///< [in] handle of the device to get a reference of. ) try { - auto pfnRetain = ur_lib::context->urDdiTable.Device.pfnRetain; + auto pfnRetain = ur_lib::getContext()->urDdiTable.Device.pfnRetain; if (nullptr == pfnRetain) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -951,7 +942,7 @@ ur_result_t UR_APICALL urDeviceRelease( ur_device_handle_t hDevice ///< [in][release] handle of the device to release. ) try { - auto pfnRelease = ur_lib::context->urDdiTable.Device.pfnRelease; + auto pfnRelease = ur_lib::getContext()->urDdiTable.Device.pfnRelease; if (nullptr == pfnRelease) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -1002,7 +993,7 @@ ur_result_t UR_APICALL urDevicePartition( pNumDevicesRet ///< [out][optional] pointer to the number of sub-devices the device can be ///< partitioned into according to the partitioning property. ) try { - auto pfnPartition = ur_lib::context->urDdiTable.Device.pfnPartition; + auto pfnPartition = ur_lib::getContext()->urDdiTable.Device.pfnPartition; if (nullptr == pfnPartition) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -1051,7 +1042,8 @@ ur_result_t UR_APICALL urDeviceSelectBinary( pSelectedBinary ///< [out] the index of the selected binary in the input array of binaries. ///< If a suitable binary was not found the function returns ::UR_RESULT_ERROR_INVALID_BINARY. ) try { - auto pfnSelectBinary = ur_lib::context->urDdiTable.Device.pfnSelectBinary; + auto pfnSelectBinary = + ur_lib::getContext()->urDdiTable.Device.pfnSelectBinary; if (nullptr == pfnSelectBinary) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -1090,7 +1082,7 @@ ur_result_t UR_APICALL urDeviceGetNativeHandle( *phNativeDevice ///< [out] a pointer to the native handle of the device. ) try { auto pfnGetNativeHandle = - ur_lib::context->urDdiTable.Device.pfnGetNativeHandle; + ur_lib::getContext()->urDdiTable.Device.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -1130,7 +1122,7 @@ ur_result_t UR_APICALL urDeviceCreateWithNativeHandle( *phDevice ///< [out] pointer to the handle of the device object created. ) try { auto pfnCreateWithNativeHandle = - ur_lib::context->urDdiTable.Device.pfnCreateWithNativeHandle; + ur_lib::getContext()->urDdiTable.Device.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -1170,7 +1162,7 @@ ur_result_t UR_APICALL urDeviceGetGlobalTimestamps( ///< correlates with the Device's global timestamp value ) try { auto pfnGetGlobalTimestamps = - ur_lib::context->urDdiTable.Device.pfnGetGlobalTimestamps; + ur_lib::getContext()->urDdiTable.Device.pfnGetGlobalTimestamps; if (nullptr == pfnGetGlobalTimestamps) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -1219,7 +1211,7 @@ ur_result_t UR_APICALL urContextCreate( ur_context_handle_t *phContext ///< [out] pointer to handle of context object created ) try { - auto pfnCreate = ur_lib::context->urDdiTable.Context.pfnCreate; + auto pfnCreate = ur_lib::getContext()->urDdiTable.Context.pfnCreate; if (nullptr == pfnCreate) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -1255,7 +1247,7 @@ ur_result_t UR_APICALL urContextRetain( ur_context_handle_t hContext ///< [in] handle of the context to get a reference of. ) try { - auto pfnRetain = ur_lib::context->urDdiTable.Context.pfnRetain; + auto pfnRetain = ur_lib::getContext()->urDdiTable.Context.pfnRetain; if (nullptr == pfnRetain) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -1288,7 +1280,7 @@ ur_result_t UR_APICALL urContextRelease( ur_context_handle_t hContext ///< [in][release] handle of the context to release. ) try { - auto pfnRelease = ur_lib::context->urDdiTable.Context.pfnRelease; + auto pfnRelease = ur_lib::getContext()->urDdiTable.Context.pfnRelease; if (nullptr == pfnRelease) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -1344,7 +1336,7 @@ ur_result_t UR_APICALL urContextGetInfo( size_t * pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of the queried propName. ) try { - auto pfnGetInfo = ur_lib::context->urDdiTable.Context.pfnGetInfo; + auto pfnGetInfo = ur_lib::getContext()->urDdiTable.Context.pfnGetInfo; if (nullptr == pfnGetInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -1383,7 +1375,7 @@ ur_result_t UR_APICALL urContextGetNativeHandle( phNativeContext ///< [out] a pointer to the native handle of the context. ) try { auto pfnGetNativeHandle = - ur_lib::context->urDdiTable.Context.pfnGetNativeHandle; + ur_lib::getContext()->urDdiTable.Context.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -1424,7 +1416,7 @@ ur_result_t UR_APICALL urContextCreateWithNativeHandle( phContext ///< [out] pointer to the handle of the context object created. ) try { auto pfnCreateWithNativeHandle = - ur_lib::context->urDdiTable.Context.pfnCreateWithNativeHandle; + ur_lib::getContext()->urDdiTable.Context.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -1465,7 +1457,7 @@ ur_result_t UR_APICALL urContextSetExtendedDeleter( pUserData ///< [in][out][optional] pointer to data to be passed to callback. ) try { auto pfnSetExtendedDeleter = - ur_lib::context->urDdiTable.Context.pfnSetExtendedDeleter; + ur_lib::getContext()->urDdiTable.Context.pfnSetExtendedDeleter; if (nullptr == pfnSetExtendedDeleter) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -1536,7 +1528,7 @@ ur_result_t UR_APICALL urMemImageCreate( void *pHost, ///< [in][optional] pointer to the buffer data ur_mem_handle_t *phMem ///< [out] pointer to handle of image object created ) try { - auto pfnImageCreate = ur_lib::context->urDdiTable.Mem.pfnImageCreate; + auto pfnImageCreate = ur_lib::getContext()->urDdiTable.Mem.pfnImageCreate; if (nullptr == pfnImageCreate) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -1588,7 +1580,7 @@ ur_result_t UR_APICALL urMemBufferCreate( ur_mem_handle_t *phBuffer ///< [out] pointer to handle of the memory buffer created ) try { - auto pfnBufferCreate = ur_lib::context->urDdiTable.Mem.pfnBufferCreate; + auto pfnBufferCreate = ur_lib::getContext()->urDdiTable.Mem.pfnBufferCreate; if (nullptr == pfnBufferCreate) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -1623,7 +1615,7 @@ ur_result_t UR_APICALL urMemBufferCreate( ur_result_t UR_APICALL urMemRetain( ur_mem_handle_t hMem ///< [in] handle of the memory object to get access ) try { - auto pfnRetain = ur_lib::context->urDdiTable.Mem.pfnRetain; + auto pfnRetain = ur_lib::getContext()->urDdiTable.Mem.pfnRetain; if (nullptr == pfnRetain) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -1654,7 +1646,7 @@ ur_result_t UR_APICALL urMemRelease( ur_mem_handle_t hMem ///< [in][release] handle of the memory object to release ) try { - auto pfnRelease = ur_lib::context->urDdiTable.Mem.pfnRelease; + auto pfnRelease = ur_lib::getContext()->urDdiTable.Mem.pfnRelease; if (nullptr == pfnRelease) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -1704,7 +1696,7 @@ ur_result_t UR_APICALL urMemBufferPartition( *phMem ///< [out] pointer to the handle of sub buffer created ) try { auto pfnBufferPartition = - ur_lib::context->urDdiTable.Mem.pfnBufferPartition; + ur_lib::getContext()->urDdiTable.Mem.pfnBufferPartition; if (nullptr == pfnBufferPartition) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -1749,7 +1741,7 @@ ur_result_t UR_APICALL urMemGetNativeHandle( *phNativeMem ///< [out] a pointer to the native handle of the mem. ) try { auto pfnGetNativeHandle = - ur_lib::context->urDdiTable.Mem.pfnGetNativeHandle; + ur_lib::getContext()->urDdiTable.Mem.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -1788,7 +1780,7 @@ ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( *phMem ///< [out] pointer to handle of buffer memory object created. ) try { auto pfnBufferCreateWithNativeHandle = - ur_lib::context->urDdiTable.Mem.pfnBufferCreateWithNativeHandle; + ur_lib::getContext()->urDdiTable.Mem.pfnBufferCreateWithNativeHandle; if (nullptr == pfnBufferCreateWithNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -1833,7 +1825,7 @@ ur_result_t UR_APICALL urMemImageCreateWithNativeHandle( *phMem ///< [out] pointer to handle of image memory object created. ) try { auto pfnImageCreateWithNativeHandle = - ur_lib::context->urDdiTable.Mem.pfnImageCreateWithNativeHandle; + ur_lib::getContext()->urDdiTable.Mem.pfnImageCreateWithNativeHandle; if (nullptr == pfnImageCreateWithNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -1889,7 +1881,7 @@ ur_result_t UR_APICALL urMemGetInfo( size_t * pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of the queried propName. ) try { - auto pfnGetInfo = ur_lib::context->urDdiTable.Mem.pfnGetInfo; + auto pfnGetInfo = ur_lib::getContext()->urDdiTable.Mem.pfnGetInfo; if (nullptr == pfnGetInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -1943,7 +1935,7 @@ ur_result_t UR_APICALL urMemImageGetInfo( size_t * pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of the queried propName. ) try { - auto pfnImageGetInfo = ur_lib::context->urDdiTable.Mem.pfnImageGetInfo; + auto pfnImageGetInfo = ur_lib::getContext()->urDdiTable.Mem.pfnImageGetInfo; if (nullptr == pfnImageGetInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -1991,7 +1983,7 @@ ur_result_t UR_APICALL urSamplerCreate( ur_sampler_handle_t *phSampler ///< [out] pointer to handle of sampler object created ) try { - auto pfnCreate = ur_lib::context->urDdiTable.Sampler.pfnCreate; + auto pfnCreate = ur_lib::getContext()->urDdiTable.Sampler.pfnCreate; if (nullptr == pfnCreate) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -2023,7 +2015,7 @@ ur_result_t UR_APICALL urSamplerRetain( ur_sampler_handle_t hSampler ///< [in] handle of the sampler object to get access ) try { - auto pfnRetain = ur_lib::context->urDdiTable.Sampler.pfnRetain; + auto pfnRetain = ur_lib::getContext()->urDdiTable.Sampler.pfnRetain; if (nullptr == pfnRetain) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -2055,7 +2047,7 @@ ur_result_t UR_APICALL urSamplerRelease( ur_sampler_handle_t hSampler ///< [in][release] handle of the sampler object to release ) try { - auto pfnRelease = ur_lib::context->urDdiTable.Sampler.pfnRelease; + auto pfnRelease = ur_lib::getContext()->urDdiTable.Sampler.pfnRelease; if (nullptr == pfnRelease) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -2103,7 +2095,7 @@ ur_result_t UR_APICALL urSamplerGetInfo( size_t * pPropSizeRet ///< [out][optional] size in bytes returned in sampler property value ) try { - auto pfnGetInfo = ur_lib::context->urDdiTable.Sampler.pfnGetInfo; + auto pfnGetInfo = ur_lib::getContext()->urDdiTable.Sampler.pfnGetInfo; if (nullptr == pfnGetInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -2142,7 +2134,7 @@ ur_result_t UR_APICALL urSamplerGetNativeHandle( phNativeSampler ///< [out] a pointer to the native handle of the sampler. ) try { auto pfnGetNativeHandle = - ur_lib::context->urDdiTable.Sampler.pfnGetNativeHandle; + ur_lib::getContext()->urDdiTable.Sampler.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -2182,7 +2174,7 @@ ur_result_t UR_APICALL urSamplerCreateWithNativeHandle( phSampler ///< [out] pointer to the handle of the sampler object created. ) try { auto pfnCreateWithNativeHandle = - ur_lib::context->urDdiTable.Sampler.pfnCreateWithNativeHandle; + ur_lib::getContext()->urDdiTable.Sampler.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -2240,7 +2232,7 @@ ur_result_t UR_APICALL urUSMHostAlloc( size, ///< [in] minimum size in bytes of the USM memory object to be allocated void **ppMem ///< [out] pointer to USM host memory object ) try { - auto pfnHostAlloc = ur_lib::context->urDdiTable.USM.pfnHostAlloc; + auto pfnHostAlloc = ur_lib::getContext()->urDdiTable.USM.pfnHostAlloc; if (nullptr == pfnHostAlloc) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -2299,7 +2291,7 @@ ur_result_t UR_APICALL urUSMDeviceAlloc( size, ///< [in] minimum size in bytes of the USM memory object to be allocated void **ppMem ///< [out] pointer to USM device memory object ) try { - auto pfnDeviceAlloc = ur_lib::context->urDdiTable.USM.pfnDeviceAlloc; + auto pfnDeviceAlloc = ur_lib::getContext()->urDdiTable.USM.pfnDeviceAlloc; if (nullptr == pfnDeviceAlloc) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -2359,7 +2351,7 @@ ur_result_t UR_APICALL urUSMSharedAlloc( size, ///< [in] minimum size in bytes of the USM memory object to be allocated void **ppMem ///< [out] pointer to USM shared memory object ) try { - auto pfnSharedAlloc = ur_lib::context->urDdiTable.USM.pfnSharedAlloc; + auto pfnSharedAlloc = ur_lib::getContext()->urDdiTable.USM.pfnSharedAlloc; if (nullptr == pfnSharedAlloc) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -2387,7 +2379,7 @@ ur_result_t UR_APICALL urUSMFree( ur_context_handle_t hContext, ///< [in] handle of the context object void *pMem ///< [in] pointer to USM memory object ) try { - auto pfnFree = ur_lib::context->urDdiTable.USM.pfnFree; + auto pfnFree = ur_lib::getContext()->urDdiTable.USM.pfnFree; if (nullptr == pfnFree) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -2429,7 +2421,7 @@ ur_result_t UR_APICALL urUSMGetMemAllocInfo( pPropSizeRet ///< [out][optional] bytes returned in USM allocation property ) try { auto pfnGetMemAllocInfo = - ur_lib::context->urDdiTable.USM.pfnGetMemAllocInfo; + ur_lib::getContext()->urDdiTable.USM.pfnGetMemAllocInfo; if (nullptr == pfnGetMemAllocInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -2469,7 +2461,7 @@ ur_result_t UR_APICALL urUSMPoolCreate( ///< ::ur_usm_pool_limits_desc_t ur_usm_pool_handle_t *ppPool ///< [out] pointer to USM memory pool ) try { - auto pfnPoolCreate = ur_lib::context->urDdiTable.USM.pfnPoolCreate; + auto pfnPoolCreate = ur_lib::getContext()->urDdiTable.USM.pfnPoolCreate; if (nullptr == pfnPoolCreate) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -2492,7 +2484,7 @@ ur_result_t UR_APICALL urUSMPoolCreate( ur_result_t UR_APICALL urUSMPoolRetain( ur_usm_pool_handle_t pPool ///< [in] pointer to USM memory pool ) try { - auto pfnPoolRetain = ur_lib::context->urDdiTable.USM.pfnPoolRetain; + auto pfnPoolRetain = ur_lib::getContext()->urDdiTable.USM.pfnPoolRetain; if (nullptr == pfnPoolRetain) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -2522,7 +2514,7 @@ ur_result_t UR_APICALL urUSMPoolRetain( ur_result_t UR_APICALL urUSMPoolRelease( ur_usm_pool_handle_t pPool ///< [in][release] pointer to USM memory pool ) try { - auto pfnPoolRelease = ur_lib::context->urDdiTable.USM.pfnPoolRelease; + auto pfnPoolRelease = ur_lib::getContext()->urDdiTable.USM.pfnPoolRelease; if (nullptr == pfnPoolRelease) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -2564,7 +2556,7 @@ ur_result_t UR_APICALL urUSMPoolGetInfo( size_t * pPropSizeRet ///< [out][optional] size in bytes returned in pool property value ) try { - auto pfnPoolGetInfo = ur_lib::context->urDdiTable.USM.pfnPoolGetInfo; + auto pfnPoolGetInfo = ur_lib::getContext()->urDdiTable.USM.pfnPoolGetInfo; if (nullptr == pfnPoolGetInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -2617,7 +2609,7 @@ ur_result_t UR_APICALL urVirtualMemGranularityGetInfo( pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of the queried propName." ) try { auto pfnGranularityGetInfo = - ur_lib::context->urDdiTable.VirtualMem.pfnGranularityGetInfo; + ur_lib::getContext()->urDdiTable.VirtualMem.pfnGranularityGetInfo; if (nullptr == pfnGranularityGetInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -2652,7 +2644,7 @@ ur_result_t UR_APICALL urVirtualMemReserve( ppStart ///< [out] pointer to the returned address at the start of reserved virtual ///< memory range. ) try { - auto pfnReserve = ur_lib::context->urDdiTable.VirtualMem.pfnReserve; + auto pfnReserve = ur_lib::getContext()->urDdiTable.VirtualMem.pfnReserve; if (nullptr == pfnReserve) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -2680,7 +2672,7 @@ ur_result_t UR_APICALL urVirtualMemFree( pStart, ///< [in] pointer to the start of the virtual memory range to free. size_t size ///< [in] size in bytes of the virtual memory range to free. ) try { - auto pfnFree = ur_lib::context->urDdiTable.VirtualMem.pfnFree; + auto pfnFree = ur_lib::getContext()->urDdiTable.VirtualMem.pfnFree; if (nullptr == pfnFree) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -2717,7 +2709,7 @@ ur_result_t UR_APICALL urVirtualMemMap( ur_virtual_mem_access_flags_t flags ///< [in] access flags for the physical memory mapping. ) try { - auto pfnMap = ur_lib::context->urDdiTable.VirtualMem.pfnMap; + auto pfnMap = ur_lib::getContext()->urDdiTable.VirtualMem.pfnMap; if (nullptr == pfnMap) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -2749,7 +2741,7 @@ ur_result_t UR_APICALL urVirtualMemUnmap( pStart, ///< [in] pointer to the start of the mapped virtual memory range size_t size ///< [in] size in bytes of the virtual memory range. ) try { - auto pfnUnmap = ur_lib::context->urDdiTable.VirtualMem.pfnUnmap; + auto pfnUnmap = ur_lib::getContext()->urDdiTable.VirtualMem.pfnUnmap; if (nullptr == pfnUnmap) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -2781,7 +2773,8 @@ ur_result_t UR_APICALL urVirtualMemSetAccess( ur_virtual_mem_access_flags_t flags ///< [in] access flags to set for the mapped virtual memory range. ) try { - auto pfnSetAccess = ur_lib::context->urDdiTable.VirtualMem.pfnSetAccess; + auto pfnSetAccess = + ur_lib::getContext()->urDdiTable.VirtualMem.pfnSetAccess; if (nullptr == pfnSetAccess) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -2821,7 +2814,7 @@ ur_result_t UR_APICALL urVirtualMemGetInfo( size_t * pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of the queried propName." ) try { - auto pfnGetInfo = ur_lib::context->urDdiTable.VirtualMem.pfnGetInfo; + auto pfnGetInfo = ur_lib::getContext()->urDdiTable.VirtualMem.pfnGetInfo; if (nullptr == pfnGetInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -2860,7 +2853,7 @@ ur_result_t UR_APICALL urPhysicalMemCreate( ur_physical_mem_handle_t * phPhysicalMem ///< [out] pointer to handle of physical memory object created. ) try { - auto pfnCreate = ur_lib::context->urDdiTable.PhysicalMem.pfnCreate; + auto pfnCreate = ur_lib::getContext()->urDdiTable.PhysicalMem.pfnCreate; if (nullptr == pfnCreate) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -2884,7 +2877,7 @@ ur_result_t UR_APICALL urPhysicalMemRetain( ur_physical_mem_handle_t hPhysicalMem ///< [in] handle of the physical memory object to retain. ) try { - auto pfnRetain = ur_lib::context->urDdiTable.PhysicalMem.pfnRetain; + auto pfnRetain = ur_lib::getContext()->urDdiTable.PhysicalMem.pfnRetain; if (nullptr == pfnRetain) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -2908,7 +2901,7 @@ ur_result_t UR_APICALL urPhysicalMemRelease( ur_physical_mem_handle_t hPhysicalMem ///< [in][release] handle of the physical memory object to release. ) try { - auto pfnRelease = ur_lib::context->urDdiTable.PhysicalMem.pfnRelease; + auto pfnRelease = ur_lib::getContext()->urDdiTable.PhysicalMem.pfnRelease; if (nullptr == pfnRelease) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -2957,7 +2950,8 @@ ur_result_t UR_APICALL urProgramCreateWithIL( ur_program_handle_t *phProgram ///< [out] pointer to handle of program object created. ) try { - auto pfnCreateWithIL = ur_lib::context->urDdiTable.Program.pfnCreateWithIL; + auto pfnCreateWithIL = + ur_lib::getContext()->urDdiTable.Program.pfnCreateWithIL; if (nullptr == pfnCreateWithIL) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -3012,7 +3006,7 @@ ur_result_t UR_APICALL urProgramCreateWithBinary( *phProgram ///< [out] pointer to handle of Program object created. ) try { auto pfnCreateWithBinary = - ur_lib::context->urDdiTable.Program.pfnCreateWithBinary; + ur_lib::getContext()->urDdiTable.Program.pfnCreateWithBinary; if (nullptr == pfnCreateWithBinary) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -3055,7 +3049,7 @@ ur_result_t UR_APICALL urProgramBuild( const char * pOptions ///< [in][optional] pointer to build options null-terminated string. ) try { - auto pfnBuild = ur_lib::context->urDdiTable.Program.pfnBuild; + auto pfnBuild = ur_lib::getContext()->urDdiTable.Program.pfnBuild; if (nullptr == pfnBuild) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -3097,7 +3091,7 @@ ur_result_t UR_APICALL urProgramCompile( const char * pOptions ///< [in][optional] pointer to build options null-terminated string. ) try { - auto pfnCompile = ur_lib::context->urDdiTable.Program.pfnCompile; + auto pfnCompile = ur_lib::getContext()->urDdiTable.Program.pfnCompile; if (nullptr == pfnCompile) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -3147,7 +3141,7 @@ ur_result_t UR_APICALL urProgramLink( ur_program_handle_t *phProgram ///< [out] pointer to handle of program object created. ) try { - auto pfnLink = ur_lib::context->urDdiTable.Program.pfnLink; + auto pfnLink = ur_lib::getContext()->urDdiTable.Program.pfnLink; if (nullptr == pfnLink) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -3180,7 +3174,7 @@ ur_result_t UR_APICALL urProgramLink( ur_result_t UR_APICALL urProgramRetain( ur_program_handle_t hProgram ///< [in] handle for the Program to retain ) try { - auto pfnRetain = ur_lib::context->urDdiTable.Program.pfnRetain; + auto pfnRetain = ur_lib::getContext()->urDdiTable.Program.pfnRetain; if (nullptr == pfnRetain) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -3214,7 +3208,7 @@ ur_result_t UR_APICALL urProgramRelease( ur_program_handle_t hProgram ///< [in][release] handle for the Program to release ) try { - auto pfnRelease = ur_lib::context->urDdiTable.Program.pfnRelease; + auto pfnRelease = ur_lib::getContext()->urDdiTable.Program.pfnRelease; if (nullptr == pfnRelease) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -3268,7 +3262,7 @@ ur_result_t UR_APICALL urProgramGetFunctionPointer( ppFunctionPointer ///< [out] Returns the pointer to the function if it is found in the program. ) try { auto pfnGetFunctionPointer = - ur_lib::context->urDdiTable.Program.pfnGetFunctionPointer; + ur_lib::getContext()->urDdiTable.Program.pfnGetFunctionPointer; if (nullptr == pfnGetFunctionPointer) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -3319,7 +3313,7 @@ ur_result_t UR_APICALL urProgramGetGlobalVariablePointer( ppGlobalVariablePointerRet ///< [out] Returns the pointer to the global variable if it is found in the program. ) try { auto pfnGetGlobalVariablePointer = - ur_lib::context->urDdiTable.Program.pfnGetGlobalVariablePointer; + ur_lib::getContext()->urDdiTable.Program.pfnGetGlobalVariablePointer; if (nullptr == pfnGetGlobalVariablePointer) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -3372,7 +3366,7 @@ ur_result_t UR_APICALL urProgramGetInfo( size_t * pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of the queried propName. ) try { - auto pfnGetInfo = ur_lib::context->urDdiTable.Program.pfnGetInfo; + auto pfnGetInfo = ur_lib::getContext()->urDdiTable.Program.pfnGetInfo; if (nullptr == pfnGetInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -3415,7 +3409,8 @@ ur_result_t UR_APICALL urProgramGetBuildInfo( pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of data being ///< queried by propName. ) try { - auto pfnGetBuildInfo = ur_lib::context->urDdiTable.Program.pfnGetBuildInfo; + auto pfnGetBuildInfo = + ur_lib::getContext()->urDdiTable.Program.pfnGetBuildInfo; if (nullptr == pfnGetBuildInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -3457,7 +3452,7 @@ ur_result_t UR_APICALL urProgramSetSpecializationConstants( ///< descriptions ) try { auto pfnSetSpecializationConstants = - ur_lib::context->urDdiTable.Program.pfnSetSpecializationConstants; + ur_lib::getContext()->urDdiTable.Program.pfnSetSpecializationConstants; if (nullptr == pfnSetSpecializationConstants) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -3496,7 +3491,7 @@ ur_result_t UR_APICALL urProgramGetNativeHandle( phNativeProgram ///< [out] a pointer to the native handle of the program. ) try { auto pfnGetNativeHandle = - ur_lib::context->urDdiTable.Program.pfnGetNativeHandle; + ur_lib::getContext()->urDdiTable.Program.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -3536,7 +3531,7 @@ ur_result_t UR_APICALL urProgramCreateWithNativeHandle( phProgram ///< [out] pointer to the handle of the program object created. ) try { auto pfnCreateWithNativeHandle = - ur_lib::context->urDdiTable.Program.pfnCreateWithNativeHandle; + ur_lib::getContext()->urDdiTable.Program.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -3572,7 +3567,7 @@ ur_result_t UR_APICALL urKernelCreate( ur_kernel_handle_t *phKernel ///< [out] pointer to handle of kernel object created. ) try { - auto pfnCreate = ur_lib::context->urDdiTable.Kernel.pfnCreate; + auto pfnCreate = ur_lib::getContext()->urDdiTable.Kernel.pfnCreate; if (nullptr == pfnCreate) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -3610,7 +3605,8 @@ ur_result_t UR_APICALL urKernelSetArgValue( const void *pArgValue ///< [in] argument value represented as matching arg type. ) try { - auto pfnSetArgValue = ur_lib::context->urDdiTable.Kernel.pfnSetArgValue; + auto pfnSetArgValue = + ur_lib::getContext()->urDdiTable.Kernel.pfnSetArgValue; if (nullptr == pfnSetArgValue) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -3645,7 +3641,8 @@ ur_result_t UR_APICALL urKernelSetArgLocal( const ur_kernel_arg_local_properties_t *pProperties ///< [in][optional] pointer to local buffer properties. ) try { - auto pfnSetArgLocal = ur_lib::context->urDdiTable.Kernel.pfnSetArgLocal; + auto pfnSetArgLocal = + ur_lib::getContext()->urDdiTable.Kernel.pfnSetArgLocal; if (nullptr == pfnSetArgLocal) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -3697,7 +3694,7 @@ ur_result_t UR_APICALL urKernelGetInfo( pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of data being ///< queried by propName. ) try { - auto pfnGetInfo = ur_lib::context->urDdiTable.Kernel.pfnGetInfo; + auto pfnGetInfo = ur_lib::getContext()->urDdiTable.Kernel.pfnGetInfo; if (nullptr == pfnGetInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -3737,7 +3734,8 @@ ur_result_t UR_APICALL urKernelGetGroupInfo( pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of data being ///< queried by propName. ) try { - auto pfnGetGroupInfo = ur_lib::context->urDdiTable.Kernel.pfnGetGroupInfo; + auto pfnGetGroupInfo = + ur_lib::getContext()->urDdiTable.Kernel.pfnGetGroupInfo; if (nullptr == pfnGetGroupInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -3775,7 +3773,7 @@ ur_result_t UR_APICALL urKernelGetSubGroupInfo( ///< queried by propName. ) try { auto pfnGetSubGroupInfo = - ur_lib::context->urDdiTable.Kernel.pfnGetSubGroupInfo; + ur_lib::getContext()->urDdiTable.Kernel.pfnGetSubGroupInfo; if (nullptr == pfnGetSubGroupInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -3809,7 +3807,7 @@ ur_result_t UR_APICALL urKernelGetSubGroupInfo( ur_result_t UR_APICALL urKernelRetain( ur_kernel_handle_t hKernel ///< [in] handle for the Kernel to retain ) try { - auto pfnRetain = ur_lib::context->urDdiTable.Kernel.pfnRetain; + auto pfnRetain = ur_lib::getContext()->urDdiTable.Kernel.pfnRetain; if (nullptr == pfnRetain) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -3843,7 +3841,7 @@ ur_result_t UR_APICALL urKernelRelease( ur_kernel_handle_t hKernel ///< [in][release] handle for the Kernel to release ) try { - auto pfnRelease = ur_lib::context->urDdiTable.Kernel.pfnRelease; + auto pfnRelease = ur_lib::getContext()->urDdiTable.Kernel.pfnRelease; if (nullptr == pfnRelease) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -3883,7 +3881,8 @@ ur_result_t UR_APICALL urKernelSetArgPointer( pArgValue ///< [in][optional] Pointer obtained by USM allocation or virtual memory ///< mapping operation. If null then argument value is considered null. ) try { - auto pfnSetArgPointer = ur_lib::context->urDdiTable.Kernel.pfnSetArgPointer; + auto pfnSetArgPointer = + ur_lib::getContext()->urDdiTable.Kernel.pfnSetArgPointer; if (nullptr == pfnSetArgPointer) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -3926,7 +3925,8 @@ ur_result_t UR_APICALL urKernelSetExecInfo( pPropValue ///< [in][typename(propName, propSize)] pointer to memory location holding ///< the property value. ) try { - auto pfnSetExecInfo = ur_lib::context->urDdiTable.Kernel.pfnSetExecInfo; + auto pfnSetExecInfo = + ur_lib::getContext()->urDdiTable.Kernel.pfnSetExecInfo; if (nullptr == pfnSetExecInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -3960,7 +3960,8 @@ ur_result_t UR_APICALL urKernelSetArgSampler( *pProperties, ///< [in][optional] pointer to sampler properties. ur_sampler_handle_t hArgValue ///< [in] handle of Sampler object. ) try { - auto pfnSetArgSampler = ur_lib::context->urDdiTable.Kernel.pfnSetArgSampler; + auto pfnSetArgSampler = + ur_lib::getContext()->urDdiTable.Kernel.pfnSetArgSampler; if (nullptr == pfnSetArgSampler) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -3995,7 +3996,8 @@ ur_result_t UR_APICALL urKernelSetArgMemObj( *pProperties, ///< [in][optional] pointer to Memory object properties. ur_mem_handle_t hArgValue ///< [in][optional] handle of Memory object. ) try { - auto pfnSetArgMemObj = ur_lib::context->urDdiTable.Kernel.pfnSetArgMemObj; + auto pfnSetArgMemObj = + ur_lib::getContext()->urDdiTable.Kernel.pfnSetArgMemObj; if (nullptr == pfnSetArgMemObj) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -4042,7 +4044,7 @@ ur_result_t UR_APICALL urKernelSetSpecializationConstants( pSpecConstants ///< [in] array of specialization constant value descriptions ) try { auto pfnSetSpecializationConstants = - ur_lib::context->urDdiTable.Kernel.pfnSetSpecializationConstants; + ur_lib::getContext()->urDdiTable.Kernel.pfnSetSpecializationConstants; if (nullptr == pfnSetSpecializationConstants) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -4081,7 +4083,7 @@ ur_result_t UR_APICALL urKernelGetNativeHandle( *phNativeKernel ///< [out] a pointer to the native handle of the kernel. ) try { auto pfnGetNativeHandle = - ur_lib::context->urDdiTable.Kernel.pfnGetNativeHandle; + ur_lib::getContext()->urDdiTable.Kernel.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -4124,7 +4126,7 @@ ur_result_t UR_APICALL urKernelCreateWithNativeHandle( *phKernel ///< [out] pointer to the handle of the kernel object created. ) try { auto pfnCreateWithNativeHandle = - ur_lib::context->urDdiTable.Kernel.pfnCreateWithNativeHandle; + ur_lib::getContext()->urDdiTable.Kernel.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -4175,7 +4177,7 @@ ur_result_t UR_APICALL urKernelGetSuggestedLocalWorkSize( ///< suggested local work size that will contain the result of the query ) try { auto pfnGetSuggestedLocalWorkSize = - ur_lib::context->urDdiTable.Kernel.pfnGetSuggestedLocalWorkSize; + ur_lib::getContext()->urDdiTable.Kernel.pfnGetSuggestedLocalWorkSize; if (nullptr == pfnGetSuggestedLocalWorkSize) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -4225,7 +4227,7 @@ ur_result_t UR_APICALL urQueueGetInfo( size_t * pPropSizeRet ///< [out][optional] size in bytes returned in queue property value ) try { - auto pfnGetInfo = ur_lib::context->urDdiTable.Queue.pfnGetInfo; + auto pfnGetInfo = ur_lib::getContext()->urDdiTable.Queue.pfnGetInfo; if (nullptr == pfnGetInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -4272,7 +4274,7 @@ ur_result_t UR_APICALL urQueueCreate( ur_queue_handle_t *phQueue ///< [out] pointer to handle of queue object created ) try { - auto pfnCreate = ur_lib::context->urDdiTable.Queue.pfnCreate; + auto pfnCreate = ur_lib::getContext()->urDdiTable.Queue.pfnCreate; if (nullptr == pfnCreate) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -4307,7 +4309,7 @@ ur_result_t UR_APICALL urQueueCreate( ur_result_t UR_APICALL urQueueRetain( ur_queue_handle_t hQueue ///< [in] handle of the queue object to get access ) try { - auto pfnRetain = ur_lib::context->urDdiTable.Queue.pfnRetain; + auto pfnRetain = ur_lib::getContext()->urDdiTable.Queue.pfnRetain; if (nullptr == pfnRetain) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -4345,7 +4347,7 @@ ur_result_t UR_APICALL urQueueRelease( ur_queue_handle_t hQueue ///< [in][release] handle of the queue object to release ) try { - auto pfnRelease = ur_lib::context->urDdiTable.Queue.pfnRelease; + auto pfnRelease = ur_lib::getContext()->urDdiTable.Queue.pfnRelease; if (nullptr == pfnRelease) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -4386,7 +4388,7 @@ ur_result_t UR_APICALL urQueueGetNativeHandle( *phNativeQueue ///< [out] a pointer to the native handle of the queue. ) try { auto pfnGetNativeHandle = - ur_lib::context->urDdiTable.Queue.pfnGetNativeHandle; + ur_lib::getContext()->urDdiTable.Queue.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -4428,7 +4430,7 @@ ur_result_t UR_APICALL urQueueCreateWithNativeHandle( *phQueue ///< [out] pointer to the handle of the queue object created. ) try { auto pfnCreateWithNativeHandle = - ur_lib::context->urDdiTable.Queue.pfnCreateWithNativeHandle; + ur_lib::getContext()->urDdiTable.Queue.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -4466,7 +4468,7 @@ ur_result_t UR_APICALL urQueueCreateWithNativeHandle( ur_result_t UR_APICALL urQueueFinish( ur_queue_handle_t hQueue ///< [in] handle of the queue to be finished. ) try { - auto pfnFinish = ur_lib::context->urDdiTable.Queue.pfnFinish; + auto pfnFinish = ur_lib::getContext()->urDdiTable.Queue.pfnFinish; if (nullptr == pfnFinish) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -4502,7 +4504,7 @@ ur_result_t UR_APICALL urQueueFinish( ur_result_t UR_APICALL urQueueFlush( ur_queue_handle_t hQueue ///< [in] handle of the queue to be flushed. ) try { - auto pfnFlush = ur_lib::context->urDdiTable.Queue.pfnFlush; + auto pfnFlush = ur_lib::getContext()->urDdiTable.Queue.pfnFlush; if (nullptr == pfnFlush) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -4548,7 +4550,7 @@ ur_result_t UR_APICALL urEventGetInfo( ///< property size_t *pPropSizeRet ///< [out][optional] bytes returned in event property ) try { - auto pfnGetInfo = ur_lib::context->urDdiTable.Event.pfnGetInfo; + auto pfnGetInfo = ur_lib::getContext()->urDdiTable.Event.pfnGetInfo; if (nullptr == pfnGetInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -4595,7 +4597,7 @@ ur_result_t UR_APICALL urEventGetProfilingInfo( ///< propValue ) try { auto pfnGetProfilingInfo = - ur_lib::context->urDdiTable.Event.pfnGetProfilingInfo; + ur_lib::getContext()->urDdiTable.Event.pfnGetProfilingInfo; if (nullptr == pfnGetProfilingInfo) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -4634,7 +4636,7 @@ ur_result_t UR_APICALL urEventWait( phEventWaitList ///< [in][range(0, numEvents)] pointer to a list of events to wait for ///< completion ) try { - auto pfnWait = ur_lib::context->urDdiTable.Event.pfnWait; + auto pfnWait = ur_lib::getContext()->urDdiTable.Event.pfnWait; if (nullptr == pfnWait) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -4665,7 +4667,7 @@ ur_result_t UR_APICALL urEventWait( ur_result_t UR_APICALL urEventRetain( ur_event_handle_t hEvent ///< [in] handle of the event object ) try { - auto pfnRetain = ur_lib::context->urDdiTable.Event.pfnRetain; + auto pfnRetain = ur_lib::getContext()->urDdiTable.Event.pfnRetain; if (nullptr == pfnRetain) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -4696,7 +4698,7 @@ ur_result_t UR_APICALL urEventRetain( ur_result_t UR_APICALL urEventRelease( ur_event_handle_t hEvent ///< [in][release] handle of the event object ) try { - auto pfnRelease = ur_lib::context->urDdiTable.Event.pfnRelease; + auto pfnRelease = ur_lib::getContext()->urDdiTable.Event.pfnRelease; if (nullptr == pfnRelease) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -4735,7 +4737,7 @@ ur_result_t UR_APICALL urEventGetNativeHandle( *phNativeEvent ///< [out] a pointer to the native handle of the event. ) try { auto pfnGetNativeHandle = - ur_lib::context->urDdiTable.Event.pfnGetNativeHandle; + ur_lib::getContext()->urDdiTable.Event.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -4775,7 +4777,7 @@ ur_result_t UR_APICALL urEventCreateWithNativeHandle( *phEvent ///< [out] pointer to the handle of the event object created. ) try { auto pfnCreateWithNativeHandle = - ur_lib::context->urDdiTable.Event.pfnCreateWithNativeHandle; + ur_lib::getContext()->urDdiTable.Event.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -4820,7 +4822,7 @@ ur_result_t UR_APICALL urEventSetCallback( void * pUserData ///< [in][out][optional] pointer to data to be passed to callback. ) try { - auto pfnSetCallback = ur_lib::context->urDdiTable.Event.pfnSetCallback; + auto pfnSetCallback = ur_lib::getContext()->urDdiTable.Event.pfnSetCallback; if (nullptr == pfnSetCallback) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -4892,7 +4894,8 @@ ur_result_t UR_APICALL urEnqueueKernelLaunch( phEvent ///< [out][optional] return an event object that identifies this particular ///< kernel execution instance. ) try { - auto pfnKernelLaunch = ur_lib::context->urDdiTable.Enqueue.pfnKernelLaunch; + auto pfnKernelLaunch = + ur_lib::getContext()->urDdiTable.Enqueue.pfnKernelLaunch; if (nullptr == pfnKernelLaunch) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -4948,7 +4951,7 @@ ur_result_t UR_APICALL urEnqueueEventsWait( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) try { - auto pfnEventsWait = ur_lib::context->urDdiTable.Enqueue.pfnEventsWait; + auto pfnEventsWait = ur_lib::getContext()->urDdiTable.Enqueue.pfnEventsWait; if (nullptr == pfnEventsWait) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -5005,7 +5008,7 @@ ur_result_t UR_APICALL urEnqueueEventsWaitWithBarrier( ///< command instance. ) try { auto pfnEventsWaitWithBarrier = - ur_lib::context->urDdiTable.Enqueue.pfnEventsWaitWithBarrier; + ur_lib::getContext()->urDdiTable.Enqueue.pfnEventsWaitWithBarrier; if (nullptr == pfnEventsWaitWithBarrier) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -5069,7 +5072,7 @@ ur_result_t UR_APICALL urEnqueueMemBufferRead( ///< command instance. ) try { auto pfnMemBufferRead = - ur_lib::context->urDdiTable.Enqueue.pfnMemBufferRead; + ur_lib::getContext()->urDdiTable.Enqueue.pfnMemBufferRead; if (nullptr == pfnMemBufferRead) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -5135,7 +5138,7 @@ ur_result_t UR_APICALL urEnqueueMemBufferWrite( ///< command instance. ) try { auto pfnMemBufferWrite = - ur_lib::context->urDdiTable.Enqueue.pfnMemBufferWrite; + ur_lib::getContext()->urDdiTable.Enqueue.pfnMemBufferWrite; if (nullptr == pfnMemBufferWrite) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -5221,7 +5224,7 @@ ur_result_t UR_APICALL urEnqueueMemBufferReadRect( ///< command instance. ) try { auto pfnMemBufferReadRect = - ur_lib::context->urDdiTable.Enqueue.pfnMemBufferReadRect; + ur_lib::getContext()->urDdiTable.Enqueue.pfnMemBufferReadRect; if (nullptr == pfnMemBufferReadRect) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -5312,7 +5315,7 @@ ur_result_t UR_APICALL urEnqueueMemBufferWriteRect( ///< command instance. ) try { auto pfnMemBufferWriteRect = - ur_lib::context->urDdiTable.Enqueue.pfnMemBufferWriteRect; + ur_lib::getContext()->urDdiTable.Enqueue.pfnMemBufferWriteRect; if (nullptr == pfnMemBufferWriteRect) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -5375,7 +5378,7 @@ ur_result_t UR_APICALL urEnqueueMemBufferCopy( ///< command instance. ) try { auto pfnMemBufferCopy = - ur_lib::context->urDdiTable.Enqueue.pfnMemBufferCopy; + ur_lib::getContext()->urDdiTable.Enqueue.pfnMemBufferCopy; if (nullptr == pfnMemBufferCopy) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -5454,7 +5457,7 @@ ur_result_t UR_APICALL urEnqueueMemBufferCopyRect( ///< command instance. ) try { auto pfnMemBufferCopyRect = - ur_lib::context->urDdiTable.Enqueue.pfnMemBufferCopyRect; + ur_lib::getContext()->urDdiTable.Enqueue.pfnMemBufferCopyRect; if (nullptr == pfnMemBufferCopyRect) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -5522,7 +5525,7 @@ ur_result_t UR_APICALL urEnqueueMemBufferFill( ///< command instance. ) try { auto pfnMemBufferFill = - ur_lib::context->urDdiTable.Enqueue.pfnMemBufferFill; + ur_lib::getContext()->urDdiTable.Enqueue.pfnMemBufferFill; if (nullptr == pfnMemBufferFill) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -5592,7 +5595,8 @@ ur_result_t UR_APICALL urEnqueueMemImageRead( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) try { - auto pfnMemImageRead = ur_lib::context->urDdiTable.Enqueue.pfnMemImageRead; + auto pfnMemImageRead = + ur_lib::getContext()->urDdiTable.Enqueue.pfnMemImageRead; if (nullptr == pfnMemImageRead) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -5664,7 +5668,7 @@ ur_result_t UR_APICALL urEnqueueMemImageWrite( ///< command instance. ) try { auto pfnMemImageWrite = - ur_lib::context->urDdiTable.Enqueue.pfnMemImageWrite; + ur_lib::getContext()->urDdiTable.Enqueue.pfnMemImageWrite; if (nullptr == pfnMemImageWrite) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -5730,7 +5734,8 @@ ur_result_t UR_APICALL urEnqueueMemImageCopy( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) try { - auto pfnMemImageCopy = ur_lib::context->urDdiTable.Enqueue.pfnMemImageCopy; + auto pfnMemImageCopy = + ur_lib::getContext()->urDdiTable.Enqueue.pfnMemImageCopy; if (nullptr == pfnMemImageCopy) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -5802,7 +5807,8 @@ ur_result_t UR_APICALL urEnqueueMemBufferMap( void **ppRetMap ///< [out] return mapped pointer. TODO: move it before ///< numEventsInWaitList? ) try { - auto pfnMemBufferMap = ur_lib::context->urDdiTable.Enqueue.pfnMemBufferMap; + auto pfnMemBufferMap = + ur_lib::getContext()->urDdiTable.Enqueue.pfnMemBufferMap; if (nullptr == pfnMemBufferMap) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -5858,7 +5864,7 @@ ur_result_t UR_APICALL urEnqueueMemUnmap( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) try { - auto pfnMemUnmap = ur_lib::context->urDdiTable.Enqueue.pfnMemUnmap; + auto pfnMemUnmap = ur_lib::getContext()->urDdiTable.Enqueue.pfnMemUnmap; if (nullptr == pfnMemUnmap) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -5919,7 +5925,7 @@ ur_result_t UR_APICALL urEnqueueUSMFill( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) try { - auto pfnUSMFill = ur_lib::context->urDdiTable.Enqueue.pfnUSMFill; + auto pfnUSMFill = ur_lib::getContext()->urDdiTable.Enqueue.pfnUSMFill; if (nullptr == pfnUSMFill) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -5975,7 +5981,7 @@ ur_result_t UR_APICALL urEnqueueUSMMemcpy( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) try { - auto pfnUSMMemcpy = ur_lib::context->urDdiTable.Enqueue.pfnUSMMemcpy; + auto pfnUSMMemcpy = ur_lib::getContext()->urDdiTable.Enqueue.pfnUSMMemcpy; if (nullptr == pfnUSMMemcpy) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -6035,7 +6041,8 @@ ur_result_t UR_APICALL urEnqueueUSMPrefetch( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) try { - auto pfnUSMPrefetch = ur_lib::context->urDdiTable.Enqueue.pfnUSMPrefetch; + auto pfnUSMPrefetch = + ur_lib::getContext()->urDdiTable.Enqueue.pfnUSMPrefetch; if (nullptr == pfnUSMPrefetch) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -6083,7 +6090,7 @@ ur_result_t UR_APICALL urEnqueueUSMAdvise( phEvent ///< [out][optional] return an event object that identifies this particular ///< command instance. ) try { - auto pfnUSMAdvise = ur_lib::context->urDdiTable.Enqueue.pfnUSMAdvise; + auto pfnUSMAdvise = ur_lib::getContext()->urDdiTable.Enqueue.pfnUSMAdvise; if (nullptr == pfnUSMAdvise) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -6151,7 +6158,7 @@ ur_result_t UR_APICALL urEnqueueUSMFill2D( phEvent ///< [out][optional] return an event object that identifies this particular ///< kernel execution instance. ) try { - auto pfnUSMFill2D = ur_lib::context->urDdiTable.Enqueue.pfnUSMFill2D; + auto pfnUSMFill2D = ur_lib::getContext()->urDdiTable.Enqueue.pfnUSMFill2D; if (nullptr == pfnUSMFill2D) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -6217,7 +6224,8 @@ ur_result_t UR_APICALL urEnqueueUSMMemcpy2D( phEvent ///< [out][optional] return an event object that identifies this particular ///< kernel execution instance. ) try { - auto pfnUSMMemcpy2D = ur_lib::context->urDdiTable.Enqueue.pfnUSMMemcpy2D; + auto pfnUSMMemcpy2D = + ur_lib::getContext()->urDdiTable.Enqueue.pfnUSMMemcpy2D; if (nullptr == pfnUSMMemcpy2D) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -6272,7 +6280,7 @@ ur_result_t UR_APICALL urEnqueueDeviceGlobalVariableWrite( ///< kernel execution instance. ) try { auto pfnDeviceGlobalVariableWrite = - ur_lib::context->urDdiTable.Enqueue.pfnDeviceGlobalVariableWrite; + ur_lib::getContext()->urDdiTable.Enqueue.pfnDeviceGlobalVariableWrite; if (nullptr == pfnDeviceGlobalVariableWrite) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -6327,7 +6335,7 @@ ur_result_t UR_APICALL urEnqueueDeviceGlobalVariableRead( ///< kernel execution instance. ) try { auto pfnDeviceGlobalVariableRead = - ur_lib::context->urDdiTable.Enqueue.pfnDeviceGlobalVariableRead; + ur_lib::getContext()->urDdiTable.Enqueue.pfnDeviceGlobalVariableRead; if (nullptr == pfnDeviceGlobalVariableRead) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -6384,7 +6392,8 @@ ur_result_t UR_APICALL urEnqueueReadHostPipe( ///< command ///< and can be used to query or queue a wait for this command to complete. ) try { - auto pfnReadHostPipe = ur_lib::context->urDdiTable.Enqueue.pfnReadHostPipe; + auto pfnReadHostPipe = + ur_lib::getContext()->urDdiTable.Enqueue.pfnReadHostPipe; if (nullptr == pfnReadHostPipe) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -6441,7 +6450,7 @@ ur_result_t UR_APICALL urEnqueueWriteHostPipe( ///< and can be used to query or queue a wait for this command to complete. ) try { auto pfnWriteHostPipe = - ur_lib::context->urDdiTable.Enqueue.pfnWriteHostPipe; + ur_lib::getContext()->urDdiTable.Enqueue.pfnWriteHostPipe; if (nullptr == pfnWriteHostPipe) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -6511,7 +6520,7 @@ ur_result_t UR_APICALL urUSMPitchedAllocExp( size_t *pResultPitch ///< [out] pitch of the allocation ) try { auto pfnPitchedAllocExp = - ur_lib::context->urDdiTable.USMExp.pfnPitchedAllocExp; + ur_lib::getContext()->urDdiTable.USMExp.pfnPitchedAllocExp; if (nullptr == pfnPitchedAllocExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -6547,8 +6556,8 @@ ur_result_t UR_APICALL urBindlessImagesUnsampledImageHandleDestroyExp( hImage ///< [in][release] pointer to handle of image object to destroy ) try { auto pfnUnsampledImageHandleDestroyExp = - ur_lib::context->urDdiTable.BindlessImagesExp - .pfnUnsampledImageHandleDestroyExp; + ur_lib::getContext() + ->urDdiTable.BindlessImagesExp.pfnUnsampledImageHandleDestroyExp; if (nullptr == pfnUnsampledImageHandleDestroyExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -6583,8 +6592,8 @@ ur_result_t UR_APICALL urBindlessImagesSampledImageHandleDestroyExp( hImage ///< [in][release] pointer to handle of image object to destroy ) try { auto pfnSampledImageHandleDestroyExp = - ur_lib::context->urDdiTable.BindlessImagesExp - .pfnSampledImageHandleDestroyExp; + ur_lib::getContext() + ->urDdiTable.BindlessImagesExp.pfnSampledImageHandleDestroyExp; if (nullptr == pfnSampledImageHandleDestroyExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -6630,7 +6639,7 @@ ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( *phImageMem ///< [out] pointer to handle of image memory allocated ) try { auto pfnImageAllocateExp = - ur_lib::context->urDdiTable.BindlessImagesExp.pfnImageAllocateExp; + ur_lib::getContext()->urDdiTable.BindlessImagesExp.pfnImageAllocateExp; if (nullptr == pfnImageAllocateExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -6666,7 +6675,7 @@ ur_result_t UR_APICALL urBindlessImagesImageFreeExp( hImageMem ///< [in][release] handle of image memory to be freed ) try { auto pfnImageFreeExp = - ur_lib::context->urDdiTable.BindlessImagesExp.pfnImageFreeExp; + ur_lib::getContext()->urDdiTable.BindlessImagesExp.pfnImageFreeExp; if (nullptr == pfnImageFreeExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -6714,8 +6723,8 @@ ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( *phImage ///< [out] pointer to handle of image object created ) try { auto pfnUnsampledImageCreateExp = - ur_lib::context->urDdiTable.BindlessImagesExp - .pfnUnsampledImageCreateExp; + ur_lib::getContext() + ->urDdiTable.BindlessImagesExp.pfnUnsampledImageCreateExp; if (nullptr == pfnUnsampledImageCreateExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -6767,7 +6776,8 @@ ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( *phImage ///< [out] pointer to handle of image object created ) try { auto pfnSampledImageCreateExp = - ur_lib::context->urDdiTable.BindlessImagesExp.pfnSampledImageCreateExp; + ur_lib::getContext() + ->urDdiTable.BindlessImagesExp.pfnSampledImageCreateExp; if (nullptr == pfnSampledImageCreateExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -6841,7 +6851,7 @@ ur_result_t UR_APICALL urBindlessImagesImageCopyExp( ///< command instance. ) try { auto pfnImageCopyExp = - ur_lib::context->urDdiTable.BindlessImagesExp.pfnImageCopyExp; + ur_lib::getContext()->urDdiTable.BindlessImagesExp.pfnImageCopyExp; if (nullptr == pfnImageCopyExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -6882,7 +6892,7 @@ ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( size_t *pPropSizeRet ///< [out][optional] returned query value size ) try { auto pfnImageGetInfoExp = - ur_lib::context->urDdiTable.BindlessImagesExp.pfnImageGetInfoExp; + ur_lib::getContext()->urDdiTable.BindlessImagesExp.pfnImageGetInfoExp; if (nullptr == pfnImageGetInfoExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -6922,7 +6932,7 @@ ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( *phImageMem ///< [out] returning memory handle to the individual image ) try { auto pfnMipmapGetLevelExp = - ur_lib::context->urDdiTable.BindlessImagesExp.pfnMipmapGetLevelExp; + ur_lib::getContext()->urDdiTable.BindlessImagesExp.pfnMipmapGetLevelExp; if (nullptr == pfnMipmapGetLevelExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -6958,7 +6968,7 @@ ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( hMem ///< [in][release] handle of image memory to be freed ) try { auto pfnMipmapFreeExp = - ur_lib::context->urDdiTable.BindlessImagesExp.pfnMipmapFreeExp; + ur_lib::getContext()->urDdiTable.BindlessImagesExp.pfnMipmapFreeExp; if (nullptr == pfnMipmapFreeExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -7003,8 +7013,8 @@ ur_result_t UR_APICALL urBindlessImagesImportExternalMemoryExp( *phInteropMem ///< [out] interop memory handle to the external memory ) try { auto pfnImportExternalMemoryExp = - ur_lib::context->urDdiTable.BindlessImagesExp - .pfnImportExternalMemoryExp; + ur_lib::getContext() + ->urDdiTable.BindlessImagesExp.pfnImportExternalMemoryExp; if (nullptr == pfnImportExternalMemoryExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -7050,7 +7060,8 @@ ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( phImageMem ///< [out] image memory handle to the externally allocated memory ) try { auto pfnMapExternalArrayExp = - ur_lib::context->urDdiTable.BindlessImagesExp.pfnMapExternalArrayExp; + ur_lib::getContext() + ->urDdiTable.BindlessImagesExp.pfnMapExternalArrayExp; if (nullptr == pfnMapExternalArrayExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -7086,7 +7097,7 @@ ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( hInteropMem ///< [in][release] handle of interop memory to be freed ) try { auto pfnReleaseInteropExp = - ur_lib::context->urDdiTable.BindlessImagesExp.pfnReleaseInteropExp; + ur_lib::getContext()->urDdiTable.BindlessImagesExp.pfnReleaseInteropExp; if (nullptr == pfnReleaseInteropExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -7129,8 +7140,8 @@ ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreExp( phInteropSemaphore ///< [out] interop semaphore handle to the external semaphore ) try { auto pfnImportExternalSemaphoreExp = - ur_lib::context->urDdiTable.BindlessImagesExp - .pfnImportExternalSemaphoreExp; + ur_lib::getContext() + ->urDdiTable.BindlessImagesExp.pfnImportExternalSemaphoreExp; if (nullptr == pfnImportExternalSemaphoreExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -7167,8 +7178,8 @@ ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( hInteropSemaphore ///< [in][release] handle of interop semaphore to be destroyed ) try { auto pfnDestroyExternalSemaphoreExp = - ur_lib::context->urDdiTable.BindlessImagesExp - .pfnDestroyExternalSemaphoreExp; + ur_lib::getContext() + ->urDdiTable.BindlessImagesExp.pfnDestroyExternalSemaphoreExp; if (nullptr == pfnDestroyExternalSemaphoreExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -7217,8 +7228,8 @@ ur_result_t UR_APICALL urBindlessImagesWaitExternalSemaphoreExp( ///< command instance. ) try { auto pfnWaitExternalSemaphoreExp = - ur_lib::context->urDdiTable.BindlessImagesExp - .pfnWaitExternalSemaphoreExp; + ur_lib::getContext() + ->urDdiTable.BindlessImagesExp.pfnWaitExternalSemaphoreExp; if (nullptr == pfnWaitExternalSemaphoreExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -7270,8 +7281,8 @@ ur_result_t UR_APICALL urBindlessImagesSignalExternalSemaphoreExp( ///< command instance. ) try { auto pfnSignalExternalSemaphoreExp = - ur_lib::context->urDdiTable.BindlessImagesExp - .pfnSignalExternalSemaphoreExp; + ur_lib::getContext() + ->urDdiTable.BindlessImagesExp.pfnSignalExternalSemaphoreExp; if (nullptr == pfnSignalExternalSemaphoreExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -7314,7 +7325,7 @@ ur_result_t UR_APICALL urCommandBufferCreateExp( *phCommandBuffer ///< [out] Pointer to command-Buffer handle. ) try { auto pfnCreateExp = - ur_lib::context->urDdiTable.CommandBufferExp.pfnCreateExp; + ur_lib::getContext()->urDdiTable.CommandBufferExp.pfnCreateExp; if (nullptr == pfnCreateExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -7342,7 +7353,7 @@ ur_result_t UR_APICALL urCommandBufferRetainExp( hCommandBuffer ///< [in] Handle of the command-buffer object. ) try { auto pfnRetainExp = - ur_lib::context->urDdiTable.CommandBufferExp.pfnRetainExp; + ur_lib::getContext()->urDdiTable.CommandBufferExp.pfnRetainExp; if (nullptr == pfnRetainExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -7371,7 +7382,7 @@ ur_result_t UR_APICALL urCommandBufferReleaseExp( hCommandBuffer ///< [in][release] Handle of the command-buffer object. ) try { auto pfnReleaseExp = - ur_lib::context->urDdiTable.CommandBufferExp.pfnReleaseExp; + ur_lib::getContext()->urDdiTable.CommandBufferExp.pfnReleaseExp; if (nullptr == pfnReleaseExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -7400,7 +7411,7 @@ ur_result_t UR_APICALL urCommandBufferFinalizeExp( hCommandBuffer ///< [in] Handle of the command-buffer object. ) try { auto pfnFinalizeExp = - ur_lib::context->urDdiTable.CommandBufferExp.pfnFinalizeExp; + ur_lib::getContext()->urDdiTable.CommandBufferExp.pfnFinalizeExp; if (nullptr == pfnFinalizeExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -7457,7 +7468,8 @@ ur_result_t UR_APICALL urCommandBufferAppendKernelLaunchExp( *phCommand ///< [out][optional] Handle to this command. ) try { auto pfnAppendKernelLaunchExp = - ur_lib::context->urDdiTable.CommandBufferExp.pfnAppendKernelLaunchExp; + ur_lib::getContext() + ->urDdiTable.CommandBufferExp.pfnAppendKernelLaunchExp; if (nullptr == pfnAppendKernelLaunchExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -7509,7 +7521,7 @@ ur_result_t UR_APICALL urCommandBufferAppendUSMMemcpyExp( pSyncPoint ///< [out][optional] Sync point associated with this command. ) try { auto pfnAppendUSMMemcpyExp = - ur_lib::context->urDdiTable.CommandBufferExp.pfnAppendUSMMemcpyExp; + ur_lib::getContext()->urDdiTable.CommandBufferExp.pfnAppendUSMMemcpyExp; if (nullptr == pfnAppendUSMMemcpyExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -7565,7 +7577,7 @@ ur_result_t UR_APICALL urCommandBufferAppendUSMFillExp( pSyncPoint ///< [out][optional] sync point associated with this command. ) try { auto pfnAppendUSMFillExp = - ur_lib::context->urDdiTable.CommandBufferExp.pfnAppendUSMFillExp; + ur_lib::getContext()->urDdiTable.CommandBufferExp.pfnAppendUSMFillExp; if (nullptr == pfnAppendUSMFillExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -7614,7 +7626,8 @@ ur_result_t UR_APICALL urCommandBufferAppendMemBufferCopyExp( pSyncPoint ///< [out][optional] Sync point associated with this command. ) try { auto pfnAppendMemBufferCopyExp = - ur_lib::context->urDdiTable.CommandBufferExp.pfnAppendMemBufferCopyExp; + ur_lib::getContext() + ->urDdiTable.CommandBufferExp.pfnAppendMemBufferCopyExp; if (nullptr == pfnAppendMemBufferCopyExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -7664,7 +7677,8 @@ ur_result_t UR_APICALL urCommandBufferAppendMemBufferWriteExp( pSyncPoint ///< [out][optional] Sync point associated with this command. ) try { auto pfnAppendMemBufferWriteExp = - ur_lib::context->urDdiTable.CommandBufferExp.pfnAppendMemBufferWriteExp; + ur_lib::getContext() + ->urDdiTable.CommandBufferExp.pfnAppendMemBufferWriteExp; if (nullptr == pfnAppendMemBufferWriteExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -7713,7 +7727,8 @@ ur_result_t UR_APICALL urCommandBufferAppendMemBufferReadExp( pSyncPoint ///< [out][optional] Sync point associated with this command. ) try { auto pfnAppendMemBufferReadExp = - ur_lib::context->urDdiTable.CommandBufferExp.pfnAppendMemBufferReadExp; + ur_lib::getContext() + ->urDdiTable.CommandBufferExp.pfnAppendMemBufferReadExp; if (nullptr == pfnAppendMemBufferReadExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -7769,8 +7784,8 @@ ur_result_t UR_APICALL urCommandBufferAppendMemBufferCopyRectExp( pSyncPoint ///< [out][optional] Sync point associated with this command. ) try { auto pfnAppendMemBufferCopyRectExp = - ur_lib::context->urDdiTable.CommandBufferExp - .pfnAppendMemBufferCopyRectExp; + ur_lib::getContext() + ->urDdiTable.CommandBufferExp.pfnAppendMemBufferCopyRectExp; if (nullptr == pfnAppendMemBufferCopyRectExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -7834,8 +7849,8 @@ ur_result_t UR_APICALL urCommandBufferAppendMemBufferWriteRectExp( pSyncPoint ///< [out][optional] Sync point associated with this command. ) try { auto pfnAppendMemBufferWriteRectExp = - ur_lib::context->urDdiTable.CommandBufferExp - .pfnAppendMemBufferWriteRectExp; + ur_lib::getContext() + ->urDdiTable.CommandBufferExp.pfnAppendMemBufferWriteRectExp; if (nullptr == pfnAppendMemBufferWriteRectExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -7897,8 +7912,8 @@ ur_result_t UR_APICALL urCommandBufferAppendMemBufferReadRectExp( pSyncPoint ///< [out][optional] Sync point associated with this command. ) try { auto pfnAppendMemBufferReadRectExp = - ur_lib::context->urDdiTable.CommandBufferExp - .pfnAppendMemBufferReadRectExp; + ur_lib::getContext() + ->urDdiTable.CommandBufferExp.pfnAppendMemBufferReadRectExp; if (nullptr == pfnAppendMemBufferReadRectExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -7952,7 +7967,8 @@ ur_result_t UR_APICALL urCommandBufferAppendMemBufferFillExp( pSyncPoint ///< [out][optional] sync point associated with this command. ) try { auto pfnAppendMemBufferFillExp = - ur_lib::context->urDdiTable.CommandBufferExp.pfnAppendMemBufferFillExp; + ur_lib::getContext() + ->urDdiTable.CommandBufferExp.pfnAppendMemBufferFillExp; if (nullptr == pfnAppendMemBufferFillExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -8009,7 +8025,8 @@ ur_result_t UR_APICALL urCommandBufferAppendUSMPrefetchExp( pSyncPoint ///< [out][optional] sync point associated with this command. ) try { auto pfnAppendUSMPrefetchExp = - ur_lib::context->urDdiTable.CommandBufferExp.pfnAppendUSMPrefetchExp; + ur_lib::getContext() + ->urDdiTable.CommandBufferExp.pfnAppendUSMPrefetchExp; if (nullptr == pfnAppendUSMPrefetchExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -8066,7 +8083,7 @@ ur_result_t UR_APICALL urCommandBufferAppendUSMAdviseExp( pSyncPoint ///< [out][optional] sync point associated with this command. ) try { auto pfnAppendUSMAdviseExp = - ur_lib::context->urDdiTable.CommandBufferExp.pfnAppendUSMAdviseExp; + ur_lib::getContext()->urDdiTable.CommandBufferExp.pfnAppendUSMAdviseExp; if (nullptr == pfnAppendUSMAdviseExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -8113,7 +8130,7 @@ ur_result_t UR_APICALL urCommandBufferEnqueueExp( ///< command-buffer execution instance. ) try { auto pfnEnqueueExp = - ur_lib::context->urDdiTable.CommandBufferExp.pfnEnqueueExp; + ur_lib::getContext()->urDdiTable.CommandBufferExp.pfnEnqueueExp; if (nullptr == pfnEnqueueExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -8142,7 +8159,7 @@ ur_result_t UR_APICALL urCommandBufferRetainCommandExp( hCommand ///< [in] Handle of the command-buffer command. ) try { auto pfnRetainCommandExp = - ur_lib::context->urDdiTable.CommandBufferExp.pfnRetainCommandExp; + ur_lib::getContext()->urDdiTable.CommandBufferExp.pfnRetainCommandExp; if (nullptr == pfnRetainCommandExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -8171,7 +8188,7 @@ ur_result_t UR_APICALL urCommandBufferReleaseCommandExp( hCommand ///< [in][release] Handle of the command-buffer command. ) try { auto pfnReleaseCommandExp = - ur_lib::context->urDdiTable.CommandBufferExp.pfnReleaseCommandExp; + ur_lib::getContext()->urDdiTable.CommandBufferExp.pfnReleaseCommandExp; if (nullptr == pfnReleaseCommandExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -8221,7 +8238,8 @@ ur_result_t UR_APICALL urCommandBufferUpdateKernelLaunchExp( pUpdateKernelLaunch ///< [in] Struct defining how the kernel command is to be updated. ) try { auto pfnUpdateKernelLaunchExp = - ur_lib::context->urDdiTable.CommandBufferExp.pfnUpdateKernelLaunchExp; + ur_lib::getContext() + ->urDdiTable.CommandBufferExp.pfnUpdateKernelLaunchExp; if (nullptr == pfnUpdateKernelLaunchExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -8268,7 +8286,7 @@ ur_result_t UR_APICALL urCommandBufferGetInfoExp( pPropSizeRet ///< [out][optional] bytes returned in command-buffer property ) try { auto pfnGetInfoExp = - ur_lib::context->urDdiTable.CommandBufferExp.pfnGetInfoExp; + ur_lib::getContext()->urDdiTable.CommandBufferExp.pfnGetInfoExp; if (nullptr == pfnGetInfoExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -8316,7 +8334,7 @@ ur_result_t UR_APICALL urCommandBufferCommandGetInfoExp( pPropSizeRet ///< [out][optional] bytes returned in command-buffer command property ) try { auto pfnCommandGetInfoExp = - ur_lib::context->urDdiTable.CommandBufferExp.pfnCommandGetInfoExp; + ur_lib::getContext()->urDdiTable.CommandBufferExp.pfnCommandGetInfoExp; if (nullptr == pfnCommandGetInfoExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -8383,7 +8401,8 @@ ur_result_t UR_APICALL urEnqueueCooperativeKernelLaunchExp( ///< kernel execution instance. ) try { auto pfnCooperativeKernelLaunchExp = - ur_lib::context->urDdiTable.EnqueueExp.pfnCooperativeKernelLaunchExp; + ur_lib::getContext() + ->urDdiTable.EnqueueExp.pfnCooperativeKernelLaunchExp; if (nullptr == pfnCooperativeKernelLaunchExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -8419,8 +8438,8 @@ ur_result_t UR_APICALL urKernelSuggestMaxCooperativeGroupCountExp( uint32_t *pGroupCountRet ///< [out] pointer to maximum number of groups ) try { auto pfnSuggestMaxCooperativeGroupCountExp = - ur_lib::context->urDdiTable.KernelExp - .pfnSuggestMaxCooperativeGroupCountExp; + ur_lib::getContext() + ->urDdiTable.KernelExp.pfnSuggestMaxCooperativeGroupCountExp; if (nullptr == pfnSuggestMaxCooperativeGroupCountExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -8468,7 +8487,7 @@ ur_result_t UR_APICALL urEnqueueTimestampRecordingExp( ///< reports the timestamp recorded when the command is executed on the device. ) try { auto pfnTimestampRecordingExp = - ur_lib::context->urDdiTable.EnqueueExp.pfnTimestampRecordingExp; + ur_lib::getContext()->urDdiTable.EnqueueExp.pfnTimestampRecordingExp; if (nullptr == pfnTimestampRecordingExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -8555,7 +8574,7 @@ ur_result_t UR_APICALL urEnqueueKernelLaunchCustomExp( ///< kernel execution instance. ) try { auto pfnKernelLaunchCustomExp = - ur_lib::context->urDdiTable.EnqueueExp.pfnKernelLaunchCustomExp; + ur_lib::getContext()->urDdiTable.EnqueueExp.pfnKernelLaunchCustomExp; if (nullptr == pfnKernelLaunchCustomExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -8603,7 +8622,7 @@ ur_result_t UR_APICALL urProgramBuildExp( const char * pOptions ///< [in][optional] pointer to build options null-terminated string. ) try { - auto pfnBuildExp = ur_lib::context->urDdiTable.ProgramExp.pfnBuildExp; + auto pfnBuildExp = ur_lib::getContext()->urDdiTable.ProgramExp.pfnBuildExp; if (nullptr == pfnBuildExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -8648,7 +8667,8 @@ ur_result_t UR_APICALL urProgramCompileExp( const char * pOptions ///< [in][optional] pointer to build options null-terminated string. ) try { - auto pfnCompileExp = ur_lib::context->urDdiTable.ProgramExp.pfnCompileExp; + auto pfnCompileExp = + ur_lib::getContext()->urDdiTable.ProgramExp.pfnCompileExp; if (nullptr == pfnCompileExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -8702,7 +8722,7 @@ ur_result_t UR_APICALL urProgramLinkExp( ur_program_handle_t *phProgram ///< [out] pointer to handle of program object created. ) try { - auto pfnLinkExp = ur_lib::context->urDdiTable.ProgramExp.pfnLinkExp; + auto pfnLinkExp = ur_lib::getContext()->urDdiTable.ProgramExp.pfnLinkExp; if (nullptr == pfnLinkExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -8735,7 +8755,7 @@ ur_result_t UR_APICALL urUSMImportExp( void *pMem, ///< [in] pointer to host memory object size_t size ///< [in] size in bytes of the host memory object to be imported ) try { - auto pfnImportExp = ur_lib::context->urDdiTable.USMExp.pfnImportExp; + auto pfnImportExp = ur_lib::getContext()->urDdiTable.USMExp.pfnImportExp; if (nullptr == pfnImportExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -8765,7 +8785,7 @@ ur_result_t UR_APICALL urUSMReleaseExp( ur_context_handle_t hContext, ///< [in] handle of the context object void *pMem ///< [in] pointer to host memory object ) try { - auto pfnReleaseExp = ur_lib::context->urDdiTable.USMExp.pfnReleaseExp; + auto pfnReleaseExp = ur_lib::getContext()->urDdiTable.USMExp.pfnReleaseExp; if (nullptr == pfnReleaseExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -8816,7 +8836,7 @@ ur_result_t UR_APICALL urUsmP2PEnablePeerAccessExp( ur_device_handle_t peerDevice ///< [in] handle of the peer device object ) try { auto pfnEnablePeerAccessExp = - ur_lib::context->urDdiTable.UsmP2PExp.pfnEnablePeerAccessExp; + ur_lib::getContext()->urDdiTable.UsmP2PExp.pfnEnablePeerAccessExp; if (nullptr == pfnEnablePeerAccessExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -8868,7 +8888,7 @@ ur_result_t UR_APICALL urUsmP2PDisablePeerAccessExp( ur_device_handle_t peerDevice ///< [in] handle of the peer device object ) try { auto pfnDisablePeerAccessExp = - ur_lib::context->urDdiTable.UsmP2PExp.pfnDisablePeerAccessExp; + ur_lib::getContext()->urDdiTable.UsmP2PExp.pfnDisablePeerAccessExp; if (nullptr == pfnDisablePeerAccessExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -8926,7 +8946,7 @@ ur_result_t UR_APICALL urUsmP2PPeerAccessGetInfoExp( pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of the queried propName. ) try { auto pfnPeerAccessGetInfoExp = - ur_lib::context->urDdiTable.UsmP2PExp.pfnPeerAccessGetInfoExp; + ur_lib::getContext()->urDdiTable.UsmP2PExp.pfnPeerAccessGetInfoExp; if (nullptr == pfnPeerAccessGetInfoExp) { return UR_RESULT_ERROR_UNINITIALIZED; } @@ -8977,7 +8997,7 @@ ur_result_t UR_APICALL urEnqueueNativeCommandExp( ///< been enqueued in nativeEnqueueFunc. ) try { auto pfnNativeCommandExp = - ur_lib::context->urDdiTable.EnqueueExp.pfnNativeCommandExp; + ur_lib::getContext()->urDdiTable.EnqueueExp.pfnNativeCommandExp; if (nullptr == pfnNativeCommandExp) { return UR_RESULT_ERROR_UNINITIALIZED; } diff --git a/source/loader/ur_libddi.cpp b/source/loader/ur_libddi.cpp index bf28e09a71..4d88bb2044 100644 --- a/source/loader/ur_libddi.cpp +++ b/source/loader/ur_libddi.cpp @@ -17,7 +17,7 @@ namespace ur_lib { /////////////////////////////////////////////////////////////////////////////// -__urdlllocal ur_result_t context_t::urLoaderInit() { +__urdlllocal ur_result_t context_t::ddiInit() { ur_result_t result = UR_RESULT_SUCCESS; if (UR_RESULT_SUCCESS == result) { diff --git a/source/loader/ur_loader.cpp b/source/loader/ur_loader.cpp index b97516d1d5..36b420f01d 100644 --- a/source/loader/ur_loader.cpp +++ b/source/loader/ur_loader.cpp @@ -11,7 +11,7 @@ namespace ur_loader { /////////////////////////////////////////////////////////////////////////////// -context_t *context; +context_t *getContext() { return context_t::get(); } /////////////////////////////////////////////////////////////////////////////// ur_result_t context_t::init() { diff --git a/source/loader/ur_loader.hpp b/source/loader/ur_loader.hpp index 8a0f4a8c23..a180fe9b1d 100644 --- a/source/loader/ur_loader.hpp +++ b/source/loader/ur_loader.hpp @@ -8,6 +8,7 @@ * */ +#include "logger/ur_logger.hpp" #ifndef UR_LOADER_HPP #define UR_LOADER_HPP 1 @@ -28,7 +29,7 @@ struct platform_t { using platform_vector_t = std::vector; -class context_t { +class context_t : public AtomicSingleton { public: ur_api_version_t version = UR_API_VERSION_CURRENT; @@ -41,7 +42,8 @@ class context_t { bool intercept_enabled = false; }; -extern context_t *context; +context_t *getContext(); + extern ur_event_factory_t ur_event_factory; } // namespace ur_loader diff --git a/source/loader/windows/lib_init.cpp b/source/loader/windows/lib_init.cpp deleted file mode 100644 index bf7911f96a..0000000000 --- a/source/loader/windows/lib_init.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright (C) 2021-2023 Intel Corporation - * - * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. - * See LICENSE.TXT - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - */ - -#include "ur_lib.hpp" -#include "ur_loader.hpp" - -namespace ur_lib { - -extern "C" BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, - LPVOID lpvReserved) { - if (fdwReason == DLL_PROCESS_DETACH) { - delete context; - delete ur_loader::context; - } else if (fdwReason == DLL_PROCESS_ATTACH) { - context = new context_t; - ur_loader::context = new ur_loader::context_t; - } - return TRUE; -} - -} // namespace ur_lib diff --git a/source/loader/windows/loader_init.cpp b/source/loader/windows/loader_init.cpp deleted file mode 100644 index 626bdff058..0000000000 --- a/source/loader/windows/loader_init.cpp +++ /dev/null @@ -1,13 +0,0 @@ -/* - * - * Copyright (C) 2021-2023 Intel Corporation - * - * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. - * See LICENSE.TXT - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - */ - -#include "ur_loader.hpp" - -namespace ur_loader {} diff --git a/test/loader/loader_lifetime/CMakeLists.txt b/test/loader/loader_lifetime/CMakeLists.txt index c76ff87d0b..3f8c7f9519 100644 --- a/test/loader/loader_lifetime/CMakeLists.txt +++ b/test/loader/loader_lifetime/CMakeLists.txt @@ -6,6 +6,7 @@ add_executable(test-loader-lifetime urLoaderInit.cpp urLoaderTearDown.cpp + mixed.cpp ) target_link_libraries(test-loader-lifetime diff --git a/test/loader/loader_lifetime/mixed.cpp b/test/loader/loader_lifetime/mixed.cpp new file mode 100644 index 0000000000..7fec9846a4 --- /dev/null +++ b/test/loader/loader_lifetime/mixed.cpp @@ -0,0 +1,61 @@ +// Copyright (C) 2024 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include "fixtures.hpp" +#include "ur_api.h" +#include +#include +#include + +TEST(urLoaderLifetime, ST) { + ur_result_t status = urLoaderTearDown(); + ASSERT_EQ(status, UR_RESULT_ERROR_UNINITIALIZED); + + status = urLoaderInit(0, nullptr); + ASSERT_EQ(status, UR_RESULT_SUCCESS); + status = urLoaderInit(0, nullptr); + ASSERT_EQ(status, UR_RESULT_SUCCESS); + status = urLoaderInit(0, nullptr); + ASSERT_EQ(status, UR_RESULT_SUCCESS); + + status = urLoaderTearDown(); + ASSERT_EQ(status, UR_RESULT_SUCCESS); + status = urLoaderTearDown(); + ASSERT_EQ(status, UR_RESULT_SUCCESS); + status = urLoaderTearDown(); + ASSERT_EQ(status, UR_RESULT_SUCCESS); + status = urLoaderTearDown(); + ASSERT_EQ(status, UR_RESULT_ERROR_UNINITIALIZED); +} + +TEST(urLoaderLifetime, MT) { + std::vector threads; + + for (int th = 0; th < 20; ++th) { + threads.emplace_back([] { + for (int i = 0; i < 1000; ++i) { + ur_result_t status = urLoaderInit(0, nullptr); + ASSERT_EQ(status, UR_RESULT_SUCCESS); + status = urLoaderTearDown(); + ASSERT_EQ(status, UR_RESULT_SUCCESS); + // doing extranous urLoaderTearDown's is not legal + // in multi-threaded contexts because it may + // race with another thread's urLoaderInit. + } + }); + } + + for (auto &thread : threads) { + thread.join(); + } + + ur_result_t status = urLoaderTearDown(); + ASSERT_EQ(status, UR_RESULT_ERROR_UNINITIALIZED); + + status = urLoaderInit(0, nullptr); + ASSERT_EQ(status, UR_RESULT_SUCCESS); + + status = urLoaderTearDown(); + ASSERT_EQ(status, UR_RESULT_SUCCESS); +}