Skip to content

Commit

Permalink
move ManagedQueue
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanZyne committed Mar 13, 2024
1 parent 726435d commit e198d84
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 23 deletions.
23 changes: 0 additions & 23 deletions source/loader/layers/sanitizer/asan_interceptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
12 changes: 12 additions & 0 deletions source/loader/layers/sanitizer/ur_sanitizer_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
14 changes: 14 additions & 0 deletions source/loader/layers/sanitizer/ur_sanitizer_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e198d84

Please sign in to comment.