Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove virtual from L0 V2 queues #2635

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions scripts/templates/queue_api.cpp.mako
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ from templates import helper as th
// Do not edit. This file is auto generated from a template: scripts/templates/queue_api.cpp.mako

#include "queue_api.hpp"
#include "queue_handle.hpp"
#include "ur_util.hpp"

ur_queue_handle_t_::~ur_queue_handle_t_() {}
ur_queue_t_::~ur_queue_t_() {}

## FUNCTION ###################################################################
namespace ${x}::level_zero {
Expand All @@ -37,7 +38,7 @@ ${th.make_func_name(n, tags, obj)}(
%endfor
)
try {
return ${obj['params'][0]['name']}->${th.transform_queue_related_function_name(n, tags, obj, format=["name"])};
return ${obj['params'][0]['name']}->get().${th.transform_queue_related_function_name(n, tags, obj, format=["name"])};
} catch(...) {
return exceptionToResult(std::current_exception());
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/templates/queue_api.hpp.mako
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ from templates import helper as th
#include <ur_api.h>
#include <ze_api.h>

struct ur_queue_handle_t_ {
virtual ~ur_queue_handle_t_();
struct ur_queue_t_ {
virtual ~ur_queue_t_();

virtual void deferEventFree(ur_event_handle_t hEvent) = 0;

Expand Down
3 changes: 2 additions & 1 deletion source/adapters/level_zero/v2/command_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "../helpers/kernel_helpers.hpp"
#include "../ur_interface_loader.hpp"
#include "logger/ur_logger.hpp"
#include "queue_handle.hpp"

namespace {

Expand Down Expand Up @@ -141,7 +142,7 @@ ur_result_t urCommandBufferEnqueueExp(
ur_exp_command_buffer_handle_t hCommandBuffer, ur_queue_handle_t hQueue,
uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList,
ur_event_handle_t *phEvent) try {
return hQueue->enqueueCommandBuffer(
return hQueue->get().enqueueCommandBuffer(
hCommandBuffer->commandListManager.getZeCommandList(), phEvent,
numEventsInWaitList, phEventWaitList);
} catch (...) {
Expand Down
2 changes: 1 addition & 1 deletion source/adapters/level_zero/v2/command_list_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
ur_command_list_manager::ur_command_list_manager(
ur_context_handle_t context, ur_device_handle_t device,
v2::raii::command_list_unique_handle &&commandList, v2::event_flags_t flags,
ur_queue_handle_t queue)
ur_queue_t_ *queue)
: context(context), device(device),
eventPool(context->eventPoolCache.borrow(device->Id.value(), flags)),
zeCommandList(std::move(commandList)), queue(queue) {
Expand Down
4 changes: 2 additions & 2 deletions source/adapters/level_zero/v2/command_list_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct ur_command_list_manager : public _ur_object {
ur_device_handle_t device,
v2::raii::command_list_unique_handle &&commandList,
v2::event_flags_t flags = v2::EVENT_FLAGS_COUNTER,
ur_queue_handle_t_ *queue = nullptr);
ur_queue_t_ *queue = nullptr);
~ur_command_list_manager();

ur_result_t appendKernelLaunch(ur_kernel_handle_t hKernel, uint32_t workDim,
Expand All @@ -47,6 +47,6 @@ struct ur_command_list_manager : public _ur_object {
ur_device_handle_t device;
v2::raii::cache_borrowed_event_pool eventPool;
v2::raii::command_list_unique_handle zeCommandList;
ur_queue_handle_t queue;
ur_queue_t_ *queue;
std::vector<ze_event_handle_t> waitList;
};
5 changes: 3 additions & 2 deletions source/adapters/level_zero/v2/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "event_pool.hpp"
#include "event_provider.hpp"
#include "queue_api.hpp"
#include "queue_handle.hpp"

#include "../ur_interface_loader.hpp"

Expand Down Expand Up @@ -93,7 +94,7 @@ ur_event_handle_t_::ur_event_handle_t_(
: hContext(hContext), event_pool(pool), hZeEvent(std::move(hZeEvent)),
flags(flags), profilingData(getZeEvent()) {}

void ur_event_handle_t_::resetQueueAndCommand(ur_queue_handle_t hQueue,
void ur_event_handle_t_::resetQueueAndCommand(ur_queue_t_ *hQueue,
ur_command_t commandType) {
this->hQueue = hQueue;
this->commandType = commandType;
Expand Down Expand Up @@ -182,7 +183,7 @@ ur_event_handle_t_::getEventEndTimestampAndHandle() {
return {profilingData.eventEndTimestampAddr(), getZeEvent()};
}

ur_queue_handle_t ur_event_handle_t_::getQueue() const { return hQueue; }
ur_queue_t_ *ur_event_handle_t_::getQueue() const { return hQueue; }

ur_context_handle_t ur_event_handle_t_::getContext() const { return hContext; }

Expand Down
7 changes: 4 additions & 3 deletions source/adapters/level_zero/v2/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <ur_api.h>
#include <ze_api.h>

#include "adapters/level_zero/v2/queue_api.hpp"
#include "common.hpp"
#include "event_provider.hpp"

Expand Down Expand Up @@ -61,7 +62,7 @@ struct ur_event_handle_t_ : _ur_object {
const ur_event_native_properties_t *pProperties);

// Set the queue and command that this event is associated with
void resetQueueAndCommand(ur_queue_handle_t hQueue, ur_command_t commandType);
void resetQueueAndCommand(ur_queue_t_ *hQueue, ur_command_t commandType);

// releases event immediately
ur_result_t forceRelease();
Expand All @@ -86,7 +87,7 @@ struct ur_event_handle_t_ : _ur_object {
bool isProfilingEnabled() const;

// Queue associated with this event. Can be nullptr (for native events)
ur_queue_handle_t getQueue() const;
ur_queue_t_ *getQueue() const;

// Context associated with this event
ur_context_handle_t getContext() const;
Expand Down Expand Up @@ -119,7 +120,7 @@ struct ur_event_handle_t_ : _ur_object {

// queue and commandType that this event is associated with, set by enqueue
// commands
ur_queue_handle_t hQueue = nullptr;
ur_queue_t_ *hQueue = nullptr;
ur_command_t commandType = UR_COMMAND_FORCE_UINT32;

v2::event_flags_t flags;
Expand Down
6 changes: 4 additions & 2 deletions source/adapters/level_zero/v2/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "kernel.hpp"
#include "memory.hpp"
#include "queue_api.hpp"
#include "queue_handle.hpp"

#include "../device.hpp"
#include "../helpers/kernel_helpers.hpp"
Expand Down Expand Up @@ -656,8 +657,9 @@ ur_result_t urKernelGetSuggestedLocalWorkSize(
std::copy(pGlobalWorkSize, pGlobalWorkSize + workDim, globalWorkSize3D);

ur_device_handle_t hDevice;
UR_CALL(hQueue->queueGetInfo(UR_QUEUE_INFO_DEVICE, sizeof(hDevice),
reinterpret_cast<void *>(&hDevice), nullptr));
UR_CALL(hQueue->get().queueGetInfo(UR_QUEUE_INFO_DEVICE, sizeof(hDevice),
reinterpret_cast<void *>(&hDevice),
nullptr));

UR_CALL(getSuggestedLocalWorkSize(hDevice, hKernel->getZeHandle(hDevice),
globalWorkSize3D, localWorkSize));
Expand Down
Loading
Loading