Skip to content

Commit 1fa0d23

Browse files
authored
Merge pull request #1654 from Bensuo/ewan/debug_log_update
Debug logging in Level Zero command-buffer update
2 parents e16d01c + 35b7de5 commit 1fa0d23

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

source/adapters/level_zero/command_buffer.cpp

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
https://github.com/intel/llvm/blob/sycl/sycl/doc/design/CommandGraph.md#level-zero
1616
*/
1717

18+
// Print the name of a variable and its value in the L0 debug log
19+
#define DEBUG_LOG(VAR) logger::debug(#VAR " {}", VAR);
20+
1821
namespace {
1922
/// Checks the version of the level-zero driver.
2023
/// @param Context Execution context
@@ -495,6 +498,8 @@ urCommandBufferCreateExp(ur_context_handle_t Context, ur_device_handle_t Device,
495498
ZeCommandListDesc.flags = IsInOrder ? ZE_COMMAND_LIST_FLAG_IN_ORDER
496499
: ZE_COMMAND_LIST_FLAG_RELAXED_ORDERING;
497500

501+
DEBUG_LOG(ZeCommandListDesc.flags);
502+
498503
ZeStruct<ze_mutable_command_list_exp_desc_t> ZeMutableCommandListDesc;
499504
if (CommandBufferDesc && CommandBufferDesc->isUpdatable) {
500505
ZeMutableCommandListDesc.flags = 0;
@@ -678,6 +683,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendKernelLaunchExp(
678683
ZE2UR_CALL(
679684
Plt->ZeMutableCmdListExt.zexCommandListGetNextCommandIdExp,
680685
(CommandBuffer->ZeCommandList, &ZeMutableCommandDesc, &CommandId));
686+
DEBUG_LOG(CommandId);
681687
}
682688
try {
683689
if (Command)
@@ -1201,6 +1207,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferUpdateKernelLaunchExp(
12011207
auto SupportedFeatures =
12021208
Command->CommandBuffer->Device->ZeDeviceMutableCmdListsProperties
12031209
->mutableCommandFlags;
1210+
logger::debug("Mutable features supported by device {}", SupportedFeatures);
12041211

12051212
// We need the created descriptors to live till the point when
12061213
// zexCommandListUpdateMutableCommandsExp is called at the end of the
@@ -1228,10 +1235,15 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferUpdateKernelLaunchExp(
12281235
auto MutableGroupOffestDesc =
12291236
std::make_unique<ZeStruct<ze_mutable_global_offset_exp_desc_t>>();
12301237
MutableGroupOffestDesc->commandId = Command->CommandId;
1238+
DEBUG_LOG(MutableGroupOffestDesc->commandId);
12311239
MutableGroupOffestDesc->pNext = NextDesc;
1240+
DEBUG_LOG(MutableGroupOffestDesc->pNext);
12321241
MutableGroupOffestDesc->offsetX = NewGlobalWorkOffset[0];
1242+
DEBUG_LOG(MutableGroupOffestDesc->offsetX);
12331243
MutableGroupOffestDesc->offsetY = Dim >= 2 ? NewGlobalWorkOffset[1] : 0;
1244+
DEBUG_LOG(MutableGroupOffestDesc->offsetY);
12341245
MutableGroupOffestDesc->offsetZ = Dim == 3 ? NewGlobalWorkOffset[2] : 0;
1246+
DEBUG_LOG(MutableGroupOffestDesc->offsetZ);
12351247
NextDesc = MutableGroupOffestDesc.get();
12361248
OffsetDescs.push_back(std::move(MutableGroupOffestDesc));
12371249
}
@@ -1245,10 +1257,15 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferUpdateKernelLaunchExp(
12451257
auto MutableGroupSizeDesc =
12461258
std::make_unique<ZeStruct<ze_mutable_group_size_exp_desc_t>>();
12471259
MutableGroupSizeDesc->commandId = Command->CommandId;
1260+
DEBUG_LOG(MutableGroupSizeDesc->commandId);
12481261
MutableGroupSizeDesc->pNext = NextDesc;
1262+
DEBUG_LOG(MutableGroupSizeDesc->pNext);
12491263
MutableGroupSizeDesc->groupSizeX = NewLocalWorkSize[0];
1264+
DEBUG_LOG(MutableGroupSizeDesc->groupSizeX);
12501265
MutableGroupSizeDesc->groupSizeY = Dim >= 2 ? NewLocalWorkSize[1] : 1;
1266+
DEBUG_LOG(MutableGroupSizeDesc->groupSizeY);
12511267
MutableGroupSizeDesc->groupSizeZ = Dim == 3 ? NewLocalWorkSize[2] : 1;
1268+
DEBUG_LOG(MutableGroupSizeDesc->groupSizeZ);
12521269
NextDesc = MutableGroupSizeDesc.get();
12531270
GroupSizeDescs.push_back(std::move(MutableGroupSizeDesc));
12541271
}
@@ -1273,20 +1290,29 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferUpdateKernelLaunchExp(
12731290
Dim, NewGlobalWorkSize, NewLocalWorkSize));
12741291
auto MutableGroupCountDesc =
12751292
std::make_unique<ZeStruct<ze_mutable_group_count_exp_desc_t>>();
1276-
MutableGroupCountDesc->pNext = NextDesc;
12771293
MutableGroupCountDesc->commandId = Command->CommandId;
1294+
DEBUG_LOG(MutableGroupCountDesc->commandId);
1295+
MutableGroupCountDesc->pNext = NextDesc;
1296+
DEBUG_LOG(MutableGroupCountDesc->pNext);
12781297
MutableGroupCountDesc->pGroupCount = &ZeThreadGroupDimensions;
1298+
DEBUG_LOG(MutableGroupCountDesc->pGroupCount);
12791299
NextDesc = MutableGroupCountDesc.get();
12801300
GroupCountDescs.push_back(std::move(MutableGroupCountDesc));
12811301

12821302
if (UpdateWGSize) {
12831303
auto MutableGroupSizeDesc =
12841304
std::make_unique<ZeStruct<ze_mutable_group_size_exp_desc_t>>();
12851305
MutableGroupSizeDesc->commandId = Command->CommandId;
1306+
DEBUG_LOG(MutableGroupSizeDesc->commandId);
12861307
MutableGroupSizeDesc->pNext = NextDesc;
1308+
DEBUG_LOG(MutableGroupSizeDesc->pNext);
12871309
MutableGroupSizeDesc->groupSizeX = WG[0];
1310+
DEBUG_LOG(MutableGroupSizeDesc->groupSizeX);
12881311
MutableGroupSizeDesc->groupSizeY = WG[1];
1312+
DEBUG_LOG(MutableGroupSizeDesc->groupSizeY);
12891313
MutableGroupSizeDesc->groupSizeZ = WG[2];
1314+
DEBUG_LOG(MutableGroupSizeDesc->groupSizeZ);
1315+
12901316
NextDesc = MutableGroupSizeDesc.get();
12911317
GroupSizeDescs.push_back(std::move(MutableGroupSizeDesc));
12921318
}
@@ -1333,10 +1359,15 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferUpdateKernelLaunchExp(
13331359
auto ZeMutableArgDesc =
13341360
std::make_unique<ZeStruct<ze_mutable_kernel_argument_exp_desc_t>>();
13351361
ZeMutableArgDesc->commandId = Command->CommandId;
1362+
DEBUG_LOG(ZeMutableArgDesc->commandId);
13361363
ZeMutableArgDesc->pNext = NextDesc;
1364+
DEBUG_LOG(ZeMutableArgDesc->pNext);
13371365
ZeMutableArgDesc->argIndex = NewMemObjArgDesc.argIndex;
1366+
DEBUG_LOG(ZeMutableArgDesc->argIndex);
13381367
ZeMutableArgDesc->argSize = sizeof(void *);
1368+
DEBUG_LOG(ZeMutableArgDesc->argSize);
13391369
ZeMutableArgDesc->pArgValue = ZeHandlePtr;
1370+
DEBUG_LOG(ZeMutableArgDesc->pArgValue);
13401371

13411372
NextDesc = ZeMutableArgDesc.get();
13421373
ArgDescs.push_back(std::move(ZeMutableArgDesc));
@@ -1350,10 +1381,15 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferUpdateKernelLaunchExp(
13501381
auto ZeMutableArgDesc =
13511382
std::make_unique<ZeStruct<ze_mutable_kernel_argument_exp_desc_t>>();
13521383
ZeMutableArgDesc->commandId = Command->CommandId;
1384+
DEBUG_LOG(ZeMutableArgDesc->commandId);
13531385
ZeMutableArgDesc->pNext = NextDesc;
1386+
DEBUG_LOG(ZeMutableArgDesc->pNext);
13541387
ZeMutableArgDesc->argIndex = NewPointerArgDesc.argIndex;
1388+
DEBUG_LOG(ZeMutableArgDesc->argIndex);
13551389
ZeMutableArgDesc->argSize = sizeof(void *);
1390+
DEBUG_LOG(ZeMutableArgDesc->argSize);
13561391
ZeMutableArgDesc->pArgValue = NewPointerArgDesc.pNewPointerArg;
1392+
DEBUG_LOG(ZeMutableArgDesc->pArgValue);
13571393

13581394
NextDesc = ZeMutableArgDesc.get();
13591395
ArgDescs.push_back(std::move(ZeMutableArgDesc));
@@ -1367,9 +1403,13 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferUpdateKernelLaunchExp(
13671403
auto ZeMutableArgDesc =
13681404
std::make_unique<ZeStruct<ze_mutable_kernel_argument_exp_desc_t>>();
13691405
ZeMutableArgDesc->commandId = Command->CommandId;
1406+
DEBUG_LOG(ZeMutableArgDesc->commandId);
13701407
ZeMutableArgDesc->pNext = NextDesc;
1408+
DEBUG_LOG(ZeMutableArgDesc->pNext);
13711409
ZeMutableArgDesc->argIndex = NewValueArgDesc.argIndex;
1410+
DEBUG_LOG(ZeMutableArgDesc->argIndex);
13721411
ZeMutableArgDesc->argSize = NewValueArgDesc.argSize;
1412+
DEBUG_LOG(ZeMutableArgDesc->argSize);
13731413
// OpenCL: "the arg_value pointer can be NULL or point to a NULL value
13741414
// in which case a NULL value will be used as the value for the argument
13751415
// declared as a pointer to global or constant memory in the kernel"
@@ -1383,6 +1423,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferUpdateKernelLaunchExp(
13831423
ArgValuePtr = nullptr;
13841424
}
13851425
ZeMutableArgDesc->pArgValue = ArgValuePtr;
1426+
DEBUG_LOG(ZeMutableArgDesc->pArgValue);
13861427
NextDesc = ZeMutableArgDesc.get();
13871428
ArgDescs.push_back(std::move(ZeMutableArgDesc));
13881429
}

0 commit comments

Comments
 (0)