Skip to content

Commit

Permalink
[SYCL][Graph] Only get command handle for updatable command-buffers (i…
Browse files Browse the repository at this point in the history
…ntel#15522)

- Update UR tag to include changes to command-handles
- Update calls to UrCommandBufferAppendKernelLaunch to only request
command handles for updatable command-buffers
- Only store command handles for updatable command-graphs

UR PR: oneapi-src/unified-runtime#2131

---------

Co-authored-by: Kenneth Benzie (Benie) <k.benzie83@gmail.com>
  • Loading branch information
Bensuo and kbenzie authored Oct 22, 2024
1 parent df9a1a6 commit c471c8c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
12 changes: 7 additions & 5 deletions sycl/cmake/modules/FetchUnifiedRuntime.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,13 @@ if(SYCL_UR_USE_FETCH_CONTENT)
endfunction()

set(UNIFIED_RUNTIME_REPO "https://github.com/oneapi-src/unified-runtime.git")
# commit af7e275b509b41f54a66743ebf748dfb51668abf
# Author: Maosu Zhao <maosu.zhao@intel.com>
# Date: Thu Oct 17 16:31:21 2024 +0800
# [DeviceSanitizer] Refactor the code to manage shadow memory (#2127)
set(UNIFIED_RUNTIME_TAG af7e275b509b41f54a66743ebf748dfb51668abf)
# commit c742ca49efb12380a35b8b0b467e6577ab8174ce
# Merge: 3a8bf2c5 504d3b63
# Author: Kenneth Benzie (Benie) <k.benzie@codeplay.com>
# Date: Mon Oct 21 11:55:23 2024 +0100
# Merge pull request #2131 from Bensuo/ben/command-handle-fix
# [EXP][CMDBUF] Make command handle behaviour consistent
set(UNIFIED_RUNTIME_TAG c742ca49efb12380a35b8b0b467e6577ab8174ce)

set(UMF_BUILD_EXAMPLES OFF CACHE INTERNAL "EXAMPLES")
# Due to the use of dependentloadflag and no installer for UMF and hwloc we need
Expand Down
11 changes: 8 additions & 3 deletions sycl/source/detail/graph_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -706,9 +706,11 @@ exec_graph_impl::enqueueNodeDirect(sycl::context Ctx,
ur_result_t Res = sycl::detail::enqueueImpCommandBufferKernel(
Ctx, DeviceImpl, CommandBuffer,
*static_cast<sycl::detail::CGExecKernel *>((Node->MCommandGroup.get())),
Deps, &NewSyncPoint, &NewCommand, nullptr);
Deps, &NewSyncPoint, MIsUpdatable ? &NewCommand : nullptr, nullptr);

MCommandMap[Node] = NewCommand;
if (MIsUpdatable) {
MCommandMap[Node] = NewCommand;
}

if (Res != UR_RESULT_SUCCESS) {
throw sycl::exception(errc::invalid,
Expand Down Expand Up @@ -744,7 +746,10 @@ ur_exp_command_buffer_sync_point_t exec_graph_impl::enqueueNode(
Node->getCGCopy(), AllocaQueue, /*EventNeeded=*/true, CommandBuffer,
Deps);

MCommandMap[Node] = Event->getCommandBufferCommand();
if (MIsUpdatable) {
MCommandMap[Node] = Event->getCommandBufferCommand();
}

return Event->getSyncPoint();
}
void exec_graph_impl::createCommandBuffers(
Expand Down
12 changes: 11 additions & 1 deletion sycl/source/detail/scheduler/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2558,12 +2558,22 @@ ur_result_t enqueueImpCommandBufferKernel(
LocalSize = RequiredWGSize;
}

// Command-buffers which are not updatable cannot return command handles, so
// we query the descriptor here to check if a handle is required.
ur_exp_command_buffer_desc_t CommandBufferDesc{};

Adapter->call<UrApiKind::urCommandBufferGetInfoExp>(
CommandBuffer,
ur_exp_command_buffer_info_t::UR_EXP_COMMAND_BUFFER_INFO_DESCRIPTOR,
sizeof(ur_exp_command_buffer_desc_t), &CommandBufferDesc, nullptr);

ur_result_t Res =
Adapter->call_nocheck<UrApiKind::urCommandBufferAppendKernelLaunchExp>(
CommandBuffer, UrKernel, NDRDesc.Dims, &NDRDesc.GlobalOffset[0],
&NDRDesc.GlobalSize[0], LocalSize, 0, nullptr, SyncPoints.size(),
SyncPoints.size() ? SyncPoints.data() : nullptr, 0, nullptr,
OutSyncPoint, nullptr, OutCommand);
OutSyncPoint, nullptr,
CommandBufferDesc.isUpdatable ? OutCommand : nullptr);

if (!SyclKernelImpl && !Kernel) {
Adapter->call<UrApiKind::urKernelRelease>(UrKernel);
Expand Down

0 comments on commit c471c8c

Please sign in to comment.