From e198d84bc27bbff0795d6f4ebe92c1aa961cf0e0 Mon Sep 17 00:00:00 2001 From: "Zhao, Yang2" Date: Tue, 12 Mar 2024 23:09:47 -0700 Subject: [PATCH] move ManagedQueue --- .../layers/sanitizer/asan_interceptor.cpp | 23 ------------------- .../layers/sanitizer/ur_sanitizer_utils.cpp | 12 ++++++++++ .../layers/sanitizer/ur_sanitizer_utils.hpp | 14 +++++++++++ 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/source/loader/layers/sanitizer/asan_interceptor.cpp b/source/loader/layers/sanitizer/asan_interceptor.cpp index 894927a3e5..e5657ca012 100644 --- a/source/loader/layers/sanitizer/asan_interceptor.cpp +++ b/source/loader/layers/sanitizer/asan_interceptor.cpp @@ -51,29 +51,6 @@ constexpr auto kSPIR_DeviceSanitizerReportMem = "__DeviceSanitizerReportMem"; constexpr auto kSPIR_AsanDeviceGlobalCount = "__AsanDeviceGlobalCount"; constexpr auto kSPIR_AsanDeviceGlobalMetadata = "__AsanDeviceGlobalMetadata"; -struct ManagedQueue { - ManagedQueue(ur_context_handle_t Context, ur_device_handle_t Device) { - [[maybe_unused]] auto Result = context.urDdiTable.Queue.pfnCreate( - Context, Device, nullptr, &Handle); - assert(Result == UR_RESULT_SUCCESS); - } - - ~ManagedQueue() { - [[maybe_unused]] auto Result = - context.urDdiTable.Queue.pfnRelease(Handle); - assert(Result == UR_RESULT_SUCCESS); - } - - // Disable copy semantics - ManagedQueue(const ManagedQueue &) = delete; - ManagedQueue &operator=(const ManagedQueue &) = delete; - - operator ur_queue_handle_t() { return Handle; } - - private: - ur_queue_handle_t Handle = nullptr; -}; - uptr MemToShadow_CPU(uptr USM_SHADOW_BASE, uptr UPtr) { return USM_SHADOW_BASE + (UPtr >> 3); } diff --git a/source/loader/layers/sanitizer/ur_sanitizer_utils.cpp b/source/loader/layers/sanitizer/ur_sanitizer_utils.cpp index 7511679091..a18dc9f89d 100644 --- a/source/loader/layers/sanitizer/ur_sanitizer_utils.cpp +++ b/source/loader/layers/sanitizer/ur_sanitizer_utils.cpp @@ -15,6 +15,18 @@ 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); + assert(Result == UR_RESULT_SUCCESS); +} + +ManagedQueue::~ManagedQueue() { + [[maybe_unused]] auto Result = context.urDdiTable.Queue.pfnRelease(Handle); + assert(Result == UR_RESULT_SUCCESS); +} + ur_context_handle_t GetContext(ur_queue_handle_t Queue) { ur_context_handle_t Context{}; [[maybe_unused]] auto Result = context.urDdiTable.Queue.pfnGetInfo( diff --git a/source/loader/layers/sanitizer/ur_sanitizer_utils.hpp b/source/loader/layers/sanitizer/ur_sanitizer_utils.hpp index fbe74a78ed..47d9d4bf3b 100644 --- a/source/loader/layers/sanitizer/ur_sanitizer_utils.hpp +++ b/source/loader/layers/sanitizer/ur_sanitizer_utils.hpp @@ -16,6 +16,20 @@ namespace ur_sanitizer_layer { +struct ManagedQueue { + ManagedQueue(ur_context_handle_t Context, ur_device_handle_t Device); + ~ManagedQueue(); + + // Disable copy semantics + ManagedQueue(const ManagedQueue &) = delete; + ManagedQueue &operator=(const ManagedQueue &) = delete; + + operator ur_queue_handle_t() { return Handle; } + + private: + ur_queue_handle_t Handle = nullptr; +}; + ur_context_handle_t GetContext(ur_queue_handle_t Queue); ur_context_handle_t GetContext(ur_program_handle_t Program); ur_device_handle_t GetDevice(ur_queue_handle_t Queue);