Skip to content

Commit 619185f

Browse files
author
Hugh Delaney
authored
[SYCL] Fix race condition in EnqueueNativeCommand (#14717)
Wrong command type was being used for enqueue native command, causing a race condition as the host task codepath was being taken, where another path should have been taken. This fixes #14715 @sarnex
1 parent b68d6fe commit 619185f

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

sycl/include/sycl/handler.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1875,7 +1875,7 @@ class __SYCL_EXPORT handler {
18751875
setArgsToAssociatedAccessors();
18761876

18771877
SetHostTask(std::move(Func));
1878-
setType(detail::CGType::CodeplayHostTask);
1878+
setType(detail::CGType::EnqueueNativeCommand);
18791879
}
18801880

18811881
/// @brief Get the command graph if any associated with this handler. It can

sycl/source/detail/scheduler/commands.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3162,8 +3162,8 @@ ur_result_t ExecCGCommand::enqueueImpQueue() {
31623162
Req->MSYCLMemObj->MRecord->MAllocaCommands;
31633163

31643164
for (AllocaCommandBase *AllocaCmd : AllocaCmds)
3165-
if (HostTask->MQueue->getContextImplPtr() ==
3166-
AllocaCmd->getQueue()->getContextImplPtr()) {
3165+
if (getContext(HostTask->MQueue) ==
3166+
getContext(AllocaCmd->getQueue())) {
31673167
auto MemArg = reinterpret_cast<ur_mem_handle_t>(
31683168
AllocaCmd->getMemAllocation());
31693169
ReqToMem.emplace_back(std::make_pair(Req, MemArg));
@@ -3177,7 +3177,8 @@ ur_result_t ExecCGCommand::enqueueImpQueue() {
31773177

31783178
throw sycl::exception(
31793179
sycl::make_error_code(sycl::errc::runtime),
3180-
"Can't get memory object due to no allocation available ");
3180+
"Can't get memory object due to no allocation available " +
3181+
codeToString(UR_RESULT_ERROR_INVALID_MEM_OBJECT));
31813182
};
31823183
std::for_each(std::begin(HandlerReq), std::end(HandlerReq), ReqToMemConv);
31833184
std::sort(std::begin(ReqToMem), std::end(ReqToMem));

sycl/test-e2e/EnqueueNativeCommand/custom-command-multiple-dev-cuda.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// RUN: %{run} %t.out
44

55
// TODO: Reenable, see https://github.com/intel/llvm/issues/14598
6-
// UNSUPPORTED: windows, linux
6+
// UNSUPPORTED: windows
77

88
#include <cuda.h>
99

0 commit comments

Comments
 (0)