Skip to content

Commit a4ddf6e

Browse files
committed
Add queue and event handlers
1 parent bb06221 commit a4ddf6e

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 {
@@ -347,12 +348,17 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferEnqueueExp(
347348
return UR_RESULT_ERROR_INVALID_OPERATION;
348349

349350
const uint32_t NumberOfQueues = 1;
350-
351+
cl_event Event;
352+
std::vector<cl_event> CLWaitEvents(numEventsInWaitList);
353+
for (uint32_t i = 0; i < numEventsInWaitList; i++) {
354+
CLWaitEvents[i] = phEventWaitList[i]->get();
355+
}
356+
cl_command_queue CLQueue = hQueue->get();
351357
CL_RETURN_ON_FAILURE(clEnqueueCommandBufferKHR(
352-
NumberOfQueues, cl_adapter::cast<cl_command_queue *>(&hQueue),
353-
hCommandBuffer->CLCommandBuffer, numEventsInWaitList,
354-
cl_adapter::cast<const cl_event *>(phEventWaitList),
355-
cl_adapter::cast<cl_event *>(phEvent)));
356-
358+
NumberOfQueues, &CLQueue, hCommandBuffer->CLCommandBuffer,
359+
numEventsInWaitList, CLWaitEvents.data(), &Event));
360+
if (phEvent) {
361+
*phEvent = new ur_event_handle_t_(Event, hQueue->Context, hQueue);
362+
}
357363
return UR_RESULT_SUCCESS;
358364
}

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)