Skip to content

Commit 53a5a9d

Browse files
committed
Add queue and event handlers
1 parent 9309965 commit 53a5a9d

File tree

9 files changed

+421
-285
lines changed

9 files changed

+421
-285
lines changed

source/adapters/opencl/command_buffer.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
#include "command_buffer.hpp"
1212
#include "common.hpp"
1313
#include "context.hpp"
14+
#include "event.hpp"
1415
#include "memory.hpp"
16+
#include "queue.hpp"
1517

1618
UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferCreateExp(
1719
ur_context_handle_t hContext, ur_device_handle_t hDevice,
@@ -30,9 +32,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferCreateExp(
3032

3133
if (!clCreateCommandBufferKHR || Res != CL_SUCCESS)
3234
return UR_RESULT_ERROR_INVALID_OPERATION;
33-
34-
auto CLCommandBuffer = clCreateCommandBufferKHR(
35-
1, cl_adapter::cast<cl_command_queue *>(&Queue), nullptr, &Res);
35+
cl_command_queue CLQueue = Queue->get();
36+
auto CLCommandBuffer = clCreateCommandBufferKHR(1, &CLQueue, nullptr, &Res);
3637
CL_RETURN_ON_FAILURE_AND_SET_NULL(Res, phCommandBuffer);
3738

3839
try {
@@ -313,12 +314,17 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferEnqueueExp(
313314
return UR_RESULT_ERROR_INVALID_OPERATION;
314315

315316
const uint32_t NumberOfQueues = 1;
316-
317+
cl_event Event;
318+
std::vector<cl_event> CLWaitEvents(numEventsInWaitList);
319+
for (uint32_t i = 0; i < numEventsInWaitList; i++) {
320+
CLWaitEvents[i] = phEventWaitList[i]->get();
321+
}
322+
cl_command_queue CLQueue = hQueue->get();
317323
CL_RETURN_ON_FAILURE(clEnqueueCommandBufferKHR(
318-
NumberOfQueues, cl_adapter::cast<cl_command_queue *>(&hQueue),
319-
hCommandBuffer->CLCommandBuffer, numEventsInWaitList,
320-
cl_adapter::cast<const cl_event *>(phEventWaitList),
321-
cl_adapter::cast<cl_event *>(phEvent)));
322-
324+
NumberOfQueues, &CLQueue, hCommandBuffer->CLCommandBuffer,
325+
numEventsInWaitList, CLWaitEvents.data(), &Event));
326+
if (phEvent) {
327+
*phEvent = new ur_event_handle_t_(Event, hQueue->Context, hQueue);
328+
}
323329
return UR_RESULT_SUCCESS;
324330
}

source/adapters/opencl/context.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ urContextGetInfo(ur_context_handle_t hContext, ur_context_info_t propName,
9595
return ReturnValue(hContext->DeviceCount);
9696
}
9797
case UR_CONTEXT_INFO_DEVICES: {
98-
return ReturnValue(hContext->Devices);
98+
return ReturnValue(&hContext->Devices[0], hContext->DeviceCount);
9999
}
100100
case UR_CONTEXT_INFO_REFERENCE_COUNT: {
101101
size_t CheckPropSize = 0;

0 commit comments

Comments
 (0)