Skip to content

[L0 v2] implement urKernelGetSuggestedLocalWorkSize #2542

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

Merged
merged 1 commit into from
Jan 9, 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
10 changes: 0 additions & 10 deletions source/adapters/level_zero/v2/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,6 @@ ur_result_t urKernelSetSpecializationConstants(
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

ur_result_t urKernelGetSuggestedLocalWorkSize(ur_kernel_handle_t hKernel,
ur_queue_handle_t hQueue,
uint32_t numWorkDim,
const size_t *pGlobalWorkOffset,
const size_t *pGlobalWorkSize,
size_t *pSuggestedLocalWorkSize) {
logger::error("{} function not implemented!", __FUNCTION__);
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

ur_result_t urEventSetCallback(ur_event_handle_t hEvent,
ur_execution_info_t execStatus,
ur_event_callback_t pfnNotify, void *pUserData) {
Expand Down
25 changes: 25 additions & 0 deletions source/adapters/level_zero/v2/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "context.hpp"
#include "kernel.hpp"
#include "memory.hpp"
#include "queue_api.hpp"

#include "../device.hpp"
#include "../helpers/kernel_helpers.hpp"
Expand Down Expand Up @@ -624,4 +625,28 @@ ur_result_t urKernelGetInfo(ur_kernel_handle_t hKernel,
} catch (...) {
return exceptionToResult(std::current_exception());
}

ur_result_t urKernelGetSuggestedLocalWorkSize(
ur_kernel_handle_t hKernel, ur_queue_handle_t hQueue, uint32_t workDim,
[[maybe_unused]] const size_t *pGlobalWorkOffset,
const size_t *pGlobalWorkSize, size_t *pSuggestedLocalWorkSize) {
UR_ASSERT(workDim > 0, UR_RESULT_ERROR_INVALID_WORK_DIMENSION);
UR_ASSERT(workDim < 4, UR_RESULT_ERROR_INVALID_WORK_DIMENSION);
UR_ASSERT(pSuggestedLocalWorkSize != nullptr,
UR_RESULT_ERROR_INVALID_NULL_POINTER);

uint32_t localWorkSize[3];
size_t globalWorkSize3D[3]{1, 1, 1};
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(getSuggestedLocalWorkSize(hDevice, hKernel->getZeHandle(hDevice),
globalWorkSize3D, localWorkSize));

std::copy(localWorkSize, localWorkSize + workDim, pSuggestedLocalWorkSize);
return UR_RESULT_SUCCESS;
}
} // namespace ur::level_zero
Loading