Skip to content

Commit fc672fb

Browse files
authored
[UR] Add launchPropList to arguments of appendKernelLaunchWithArgsExpNew() (#20666)
After replacing `urEnqueueKernelLaunch()` property list with `pNext` chain property structures (commit 66b3b53) the `appendKernelLaunchWithArgsExpNew()` function will need the list of properities, so add `launchPropList` to arguments of `appendKernelLaunchWithArgsExpNew()` (like it is in `appendKernelLaunchWithArgsExpOld()`). It is a preparation for future changes. Signed-off-by: Lukasz Dorau <[email protected]>
1 parent 7e54a2e commit fc672fb

File tree

2 files changed

+33
-25
lines changed

2 files changed

+33
-25
lines changed

unified-runtime/source/adapters/level_zero/v2/command_list_manager.cpp

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,9 +1140,10 @@ ur_result_t ur_command_list_manager::appendKernelLaunchWithArgsExpNew(
11401140
ur_kernel_handle_t hKernel, uint32_t workDim,
11411141
const size_t *pGlobalWorkOffset, const size_t *pGlobalWorkSize,
11421142
const size_t *pLocalWorkSize, uint32_t numArgs,
1143-
const ur_exp_kernel_arg_properties_t *pArgs, uint32_t numEventsInWaitList,
1144-
const ur_event_handle_t *phEventWaitList, ur_event_handle_t phEvent,
1145-
bool cooperativeKernelLaunchRequested) {
1143+
const ur_exp_kernel_arg_properties_t *pArgs,
1144+
const ur_kernel_launch_ext_properties_t *launchPropList,
1145+
uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList,
1146+
ur_event_handle_t phEvent) {
11461147

11471148
ur_result_t checkResult = kernelLaunchChecks(hKernel, workDim);
11481149
if (checkResult != UR_RESULT_SUCCESS) {
@@ -1154,12 +1155,33 @@ ur_result_t ur_command_list_manager::appendKernelLaunchWithArgsExpNew(
11541155
ZeStruct<ze_command_list_append_launch_kernel_param_cooperative_desc_t>
11551156
cooperativeDesc;
11561157
cooperativeDesc.isCooperative = static_cast<ze_bool_t>(true);
1157-
11581158
void *pNext = nullptr;
1159-
if (cooperativeKernelLaunchRequested) {
1159+
bool cooperativeKernelLaunchRequested = false;
1160+
1161+
ur_kernel_launch_ext_properties_t *_launchPropList =
1162+
const_cast<ur_kernel_launch_ext_properties_t *>(launchPropList);
1163+
if (_launchPropList &&
1164+
_launchPropList->flags & UR_KERNEL_LAUNCH_FLAG_COOPERATIVE) {
1165+
cooperativeKernelLaunchRequested = true;
11601166
pNext = &cooperativeDesc;
11611167
}
11621168

1169+
if (_launchPropList &&
1170+
_launchPropList->flags & ~UR_KERNEL_LAUNCH_FLAG_COOPERATIVE) {
1171+
// We don't support any other flags.
1172+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
1173+
}
1174+
1175+
while (_launchPropList != nullptr) {
1176+
if (_launchPropList->stype !=
1177+
as_stype<ur_kernel_launch_ext_properties_t>()) {
1178+
// We don't support any other properties.
1179+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
1180+
}
1181+
_launchPropList = static_cast<ur_kernel_launch_ext_properties_t *>(
1182+
_launchPropList->pNext);
1183+
}
1184+
11631185
ze_kernel_handle_t hZeKernel = hKernel->getZeHandle(hDevice.get());
11641186

11651187
std::scoped_lock<ur_shared_mutex> Lock(hKernel->Mutex);
@@ -1224,27 +1246,12 @@ ur_result_t ur_command_list_manager::appendKernelLaunchWithArgsExp(
12241246

12251247
ur_kernel_launch_ext_properties_t *_launchPropList =
12261248
const_cast<ur_kernel_launch_ext_properties_t *>(launchPropList);
1227-
if (_launchPropList &&
1228-
_launchPropList->flags & ~UR_KERNEL_LAUNCH_FLAG_COOPERATIVE) {
1229-
// We don't support any other flags.
1230-
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
1231-
}
12321249

12331250
if (_launchPropList &&
12341251
_launchPropList->flags & UR_KERNEL_LAUNCH_FLAG_COOPERATIVE) {
12351252
cooperativeKernelLaunchRequested = true;
12361253
}
12371254

1238-
while (_launchPropList != nullptr) {
1239-
if (_launchPropList->stype !=
1240-
as_stype<ur_kernel_launch_ext_properties_t>()) {
1241-
// We don't support any other properties.
1242-
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
1243-
}
1244-
_launchPropList = static_cast<ur_kernel_launch_ext_properties_t *>(
1245-
_launchPropList->pNext);
1246-
}
1247-
12481255
ur_platform_handle_t hPlatform = hContext->getPlatform();
12491256
bool KernelWithArgsSupported =
12501257
hPlatform->ZeCommandListAppendLaunchKernelWithArgumentsExt.Supported;
@@ -1258,8 +1265,8 @@ ur_result_t ur_command_list_manager::appendKernelLaunchWithArgsExp(
12581265
if (RunNewPath) {
12591266
return appendKernelLaunchWithArgsExpNew(
12601267
hKernel, workDim, pGlobalWorkOffset, pGlobalWorkSize, pLocalWorkSize,
1261-
numArgs, pArgs, numEventsInWaitList, phEventWaitList, phEvent,
1262-
cooperativeKernelLaunchRequested);
1268+
numArgs, pArgs, launchPropList, numEventsInWaitList, phEventWaitList,
1269+
phEvent);
12631270
} else {
12641271
// We cannot pass cooperativeKernelLaunchRequested to
12651272
// appendKernelLaunchWithArgsExpOld() because appendKernelLaunch() must

unified-runtime/source/adapters/level_zero/v2/command_list_manager.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,10 @@ struct ur_command_list_manager {
256256
ur_kernel_handle_t hKernel, uint32_t workDim,
257257
const size_t *pGlobalWorkOffset, const size_t *pGlobalWorkSize,
258258
const size_t *pLocalWorkSize, uint32_t numArgs,
259-
const ur_exp_kernel_arg_properties_t *pArgs, uint32_t numEventsInWaitList,
260-
const ur_event_handle_t *phEventWaitList, ur_event_handle_t phEvent,
261-
bool cooperativeKernelLaunchRequested);
259+
const ur_exp_kernel_arg_properties_t *pArgs,
260+
const ur_kernel_launch_ext_properties_t *launchPropList,
261+
uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList,
262+
ur_event_handle_t phEvent);
262263

263264
ur_result_t appendGenericCommandListsExp(
264265
uint32_t numCommandLists, ze_command_list_handle_t *phCommandLists,

0 commit comments

Comments
 (0)