Skip to content

Commit 66b1826

Browse files
committed
Fix command_list_manager.cpp
1 parent 762e385 commit 66b1826

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,10 @@ ur_result_t ur_command_list_manager::appendKernelLaunchUnlocked(
174174
auto zeSignalEvent = getSignalEvent(phEvent, UR_COMMAND_KERNEL_LAUNCH);
175175
auto waitListView = getWaitListView(phEventWaitList, numEventsInWaitList);
176176

177+
std::vector<void *> emptyKMemObj;
177178
UR_CALL(hKernel->prepareForSubmission(
178179
hContext.get(), hDevice.get(), pGlobalWorkOffset, workDim, WG[0], WG[1],
179-
WG[2], getZeCommandList(), waitListView));
180+
WG[2], getZeCommandList(), waitListView, emptyKMemObj));
180181

181182
if (cooperative) {
182183
TRACK_SCOPE_LATENCY("ur_command_list_manager::"
@@ -1122,7 +1123,6 @@ ur_result_t ur_command_list_manager::appendKernelLaunchWithArgsExpNew(
11221123
break;
11231124
case UR_EXP_KERNEL_ARG_TYPE_MEM_OBJ:
11241125
// prepareForSubmission() will save zePtr in kernelMemObj[argIndex]
1125-
hKernel->kernelMemObj[argIndex] = 0;
11261126
hKernel->kernelArgs[argIndex] = &hKernel->kernelMemObj[argIndex];
11271127
UR_CALL(hKernel->addPendingMemoryAllocation(
11281128
{pArgs[argIndex].value.memObjTuple.hMem,
@@ -1139,10 +1139,12 @@ ur_result_t ur_command_list_manager::appendKernelLaunchWithArgsExpNew(
11391139

11401140
// It is needed in case of UR_KERNEL_LAUNCH_PROPERTY_ID_COOPERATIVE
11411141
// to launch the cooperative kernel.
1142-
ze_command_list_append_launch_kernel_param_cooperative_desc_t
1143-
cooperativeDesc = {
1144-
ZE_STRUCTURE_TYPE_COMMAND_LIST_APPEND_PARAM_COOPERATIVE_DESC, nullptr,
1145-
static_cast<ze_bool_t>(true)};
1142+
ZeStruct<ze_command_list_append_launch_kernel_param_cooperative_desc_t>
1143+
cooperativeDesc;
1144+
cooperativeDesc.isCooperative = static_cast<ze_bool_t>(true);
1145+
UR_ASSERT(cooperativeDesc.stype ==
1146+
ZE_STRUCTURE_TYPE_COMMAND_LIST_APPEND_PARAM_COOPERATIVE_DESC,
1147+
UR_RESULT_ERROR_INVALID_VALUE);
11461148

11471149
void *pNext = nullptr;
11481150
if (cooperativeKernelLaunchRequested) {
@@ -1168,7 +1170,7 @@ ur_result_t ur_command_list_manager::appendKernelLaunchWithArgsExpNew(
11681170

11691171
UR_CALL(hKernel->prepareForSubmission(
11701172
hContext.get(), hDevice.get(), pGlobalWorkOffset, workDim, WG[0], WG[1],
1171-
WG[2], getZeCommandList(), waitListView, &hKernel->kernelArgs));
1173+
WG[2], getZeCommandList(), waitListView, hKernel->kernelMemObj));
11721174

11731175
{
11741176
TRACK_SCOPE_LATENCY("ur_command_list_manager::"

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ ur_result_t ur_kernel_handle_t_::prepareForSubmission(
271271
const size_t *pGlobalWorkOffset, uint32_t workDim, uint32_t groupSizeX,
272272
uint32_t groupSizeY, uint32_t groupSizeZ,
273273
ze_command_list_handle_t commandList, wait_list_view &waitListView,
274-
std::vector<void *> *kernelArgs) {
274+
std::vector<void *> &kMemObj) {
275275
auto &deviceKernelOpt = deviceKernels[deviceIndex(hDevice)];
276276
if (!deviceKernelOpt.has_value())
277277
return UR_RESULT_ERROR_INVALID_KERNEL;
@@ -300,20 +300,18 @@ ur_result_t ur_kernel_handle_t_::prepareForSubmission(
300300
}
301301
}
302302

303-
// kernelArgs must be non-nullptr in the path of
303+
// kMemObj must be a non-empty vector in the path of
304304
// zeCommandListAppendLaunchKernelWithArguments()
305-
if (kernelArgs) {
305+
if (!kMemObj.empty()) {
306306
// zeCommandListAppendLaunchKernelWithArguments()
307307
// (==CommandListCoreFamily<gfxCoreFamily>::appendLaunchKernelWithArguments())
308308
// calls setArgumentValue(i, argSize, argValue) for all arguments on its
309-
// own so do not call it here, but save the zePtr pointer in kernelArgs
309+
// own so do not call it here, but save the zePtr pointer in kMemObj
310310
// for this future call.
311-
if (pending.argIndex > kernelArgs->size() - 1) {
311+
if (pending.argIndex > kMemObj.size() - 1) {
312312
return UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_INDEX;
313313
}
314-
UR_ASSERT((*kernelArgs)[pending.argIndex] != nullptr,
315-
UR_RESULT_ERROR_INVALID_NULL_POINTER);
316-
*((void **)(*kernelArgs)[pending.argIndex]) = zePtr;
314+
kMemObj[pending.argIndex] = zePtr;
317315
} else {
318316
// Set the argument only on this device's kernel.
319317
UR_CALL(deviceKernel.setArgPointer(pending.argIndex, zePtr));

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ struct ur_kernel_handle_t_ : ur_object {
9696

9797
// Set all required values for the kernel before submission (including pending
9898
// memory allocations).
99-
// The kernelArgs argument must be non-nullptr
99+
// The kMemObj argument must be a non-empty vector
100100
// in the path of zeCommandListAppendLaunchKernelWithArguments()
101101
ur_result_t prepareForSubmission(ur_context_handle_t hContext,
102102
ur_device_handle_t hDevice,
@@ -105,7 +105,7 @@ struct ur_kernel_handle_t_ : ur_object {
105105
uint32_t groupSizeY, uint32_t groupSizeZ,
106106
ze_command_list_handle_t cmdList,
107107
wait_list_view &waitListView,
108-
std::vector<void *> *kernelArgs = nullptr);
108+
std::vector<void *> &kMemObj);
109109

110110
// Get context of the kernel.
111111
ur_context_handle_t getContext() const { return hProgram->Context; }

0 commit comments

Comments
 (0)