Skip to content

Commit 4269b3d

Browse files
committed
[L0 v2] implement urKernelGetSuggestedLocalWorkSize
1 parent 7eae5c8 commit 4269b3d

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

source/adapters/level_zero/v2/api.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,6 @@ ur_result_t urKernelSetSpecializationConstants(
103103
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
104104
}
105105

106-
ur_result_t urKernelGetSuggestedLocalWorkSize(ur_kernel_handle_t hKernel,
107-
ur_queue_handle_t hQueue,
108-
uint32_t numWorkDim,
109-
const size_t *pGlobalWorkOffset,
110-
const size_t *pGlobalWorkSize,
111-
size_t *pSuggestedLocalWorkSize) {
112-
logger::error("{} function not implemented!", __FUNCTION__);
113-
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
114-
}
115-
116106
ur_result_t urEventSetCallback(ur_event_handle_t hEvent,
117107
ur_execution_info_t execStatus,
118108
ur_event_callback_t pfnNotify, void *pUserData) {

source/adapters/level_zero/v2/kernel.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "context.hpp"
1414
#include "kernel.hpp"
1515
#include "memory.hpp"
16+
#include "queue_api.hpp"
1617

1718
#include "../device.hpp"
1819
#include "../helpers/kernel_helpers.hpp"
@@ -624,4 +625,28 @@ ur_result_t urKernelGetInfo(ur_kernel_handle_t hKernel,
624625
} catch (...) {
625626
return exceptionToResult(std::current_exception());
626627
}
628+
629+
ur_result_t urKernelGetSuggestedLocalWorkSize(
630+
ur_kernel_handle_t hKernel, ur_queue_handle_t hQueue, uint32_t workDim,
631+
[[maybe_unused]] const size_t *pGlobalWorkOffset,
632+
const size_t *pGlobalWorkSize, size_t *pSuggestedLocalWorkSize) {
633+
UR_ASSERT(workDim > 0, UR_RESULT_ERROR_INVALID_WORK_DIMENSION);
634+
UR_ASSERT(workDim < 4, UR_RESULT_ERROR_INVALID_WORK_DIMENSION);
635+
UR_ASSERT(pSuggestedLocalWorkSize != nullptr,
636+
UR_RESULT_ERROR_INVALID_NULL_POINTER);
637+
638+
uint32_t localWorkSize[3];
639+
size_t globalWorkSize3D[3]{1, 1, 1};
640+
std::copy(pGlobalWorkSize, pGlobalWorkSize + workDim, globalWorkSize3D);
641+
642+
ur_device_handle_t hDevice;
643+
UR_CALL(hQueue->queueGetInfo(UR_QUEUE_INFO_DEVICE, sizeof(hDevice),
644+
reinterpret_cast<void *>(&hDevice), nullptr));
645+
646+
UR_CALL(getSuggestedLocalWorkSize(hDevice, hKernel->getZeHandle(hDevice),
647+
globalWorkSize3D, localWorkSize));
648+
649+
std::copy(localWorkSize, localWorkSize + workDim, pSuggestedLocalWorkSize);
650+
return UR_RESULT_SUCCESS;
651+
}
627652
} // namespace ur::level_zero

0 commit comments

Comments
 (0)