From 3738af7e3d61ec38e5f9cdb615b3ca0ad22a4f57 Mon Sep 17 00:00:00 2001 From: Hugh Delaney Date: Tue, 23 Jul 2024 16:19:02 +0100 Subject: [PATCH 1/4] Fix race condition Wrong command type was being used, causing code to follow host task codepath. This fixes that. --- sycl/include/sycl/handler.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/include/sycl/handler.hpp b/sycl/include/sycl/handler.hpp index 1e312f04ffc51..5c2f340568518 100644 --- a/sycl/include/sycl/handler.hpp +++ b/sycl/include/sycl/handler.hpp @@ -1841,7 +1841,7 @@ class __SYCL_EXPORT handler { setArgsToAssociatedAccessors(); SetHostTask(std::move(Func)); - setType(detail::CGType::CodeplayHostTask); + setType(detail::CGType::EnqueueNativeCommand); } /// @brief Get the command graph if any associated with this handler. It can From f419975ed918fe2802a589c5754a2a54fdf38c29 Mon Sep 17 00:00:00 2001 From: Hugh Delaney Date: Wed, 24 Jul 2024 10:25:36 +0100 Subject: [PATCH 2/4] Refactor context getting Copy the CodeplayHostTask command in how to get the context. --- sycl/source/detail/scheduler/commands.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sycl/source/detail/scheduler/commands.cpp b/sycl/source/detail/scheduler/commands.cpp index 33eade0cadb70..401bea266a6c9 100644 --- a/sycl/source/detail/scheduler/commands.cpp +++ b/sycl/source/detail/scheduler/commands.cpp @@ -3170,8 +3170,8 @@ pi_int32 ExecCGCommand::enqueueImpQueue() { Req->MSYCLMemObj->MRecord->MAllocaCommands; for (AllocaCommandBase *AllocaCmd : AllocaCmds) - if (HostTask->MQueue->getContextImplPtr() == - AllocaCmd->getQueue()->getContextImplPtr()) { + if (getContext(HostTask->MQueue) == + getContext(AllocaCmd->getQueue())) { auto MemArg = reinterpret_cast(AllocaCmd->getMemAllocation()); ReqToMem.emplace_back(std::make_pair(Req, MemArg)); @@ -3185,7 +3185,8 @@ pi_int32 ExecCGCommand::enqueueImpQueue() { throw sycl::exception( sycl::make_error_code(sycl::errc::runtime), - "Can't get memory object due to no allocation available "); + "Can't get memory object due to no allocation available " + + codeToString(PI_ERROR_INVALID_MEM_OBJECT)); }; std::for_each(std::begin(HandlerReq), std::end(HandlerReq), ReqToMemConv); std::sort(std::begin(ReqToMem), std::end(ReqToMem)); From 3ad165f2b81135cc028d7f6618514ab867a9bd10 Mon Sep 17 00:00:00 2001 From: Hugh Delaney Date: Fri, 26 Jul 2024 11:19:08 +0100 Subject: [PATCH 3/4] Test CI Not to be merged. Get the SYCL PI TRACE. --- .../custom-command-multiple-dev-cuda.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sycl/test-e2e/EnqueueNativeCommand/custom-command-multiple-dev-cuda.cpp b/sycl/test-e2e/EnqueueNativeCommand/custom-command-multiple-dev-cuda.cpp index 47e90e864b04a..a801b13a69b2a 100644 --- a/sycl/test-e2e/EnqueueNativeCommand/custom-command-multiple-dev-cuda.cpp +++ b/sycl/test-e2e/EnqueueNativeCommand/custom-command-multiple-dev-cuda.cpp @@ -1,6 +1,6 @@ -// REQUIRES: cuda -// RUN: %{build} -o %t.out -lcuda -// RUN: %{run} %t.out +// REQUIRES: cuda, cuda_dev_kit +// RUN: %{build} -o %t.out %cuda_options +// RUN: %{run} SYCL_PI_TRACE=-1 %t.out #include #include From 72dc4c9bf559b8a1a7080693ff9e89e241cb2c77 Mon Sep 17 00:00:00 2001 From: Hugh Delaney Date: Mon, 29 Jul 2024 11:01:00 +0100 Subject: [PATCH 4/4] Fix merge with UR types --- sycl/source/detail/scheduler/commands.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sycl/source/detail/scheduler/commands.cpp b/sycl/source/detail/scheduler/commands.cpp index e0868c794292a..5e13f5ba5c8e0 100644 --- a/sycl/source/detail/scheduler/commands.cpp +++ b/sycl/source/detail/scheduler/commands.cpp @@ -3164,8 +3164,8 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { for (AllocaCommandBase *AllocaCmd : AllocaCmds) if (getContext(HostTask->MQueue) == getContext(AllocaCmd->getQueue())) { - auto MemArg = - reinterpret_cast(AllocaCmd->getMemAllocation()); + auto MemArg = reinterpret_cast( + AllocaCmd->getMemAllocation()); ReqToMem.emplace_back(std::make_pair(Req, MemArg)); ReqMems.emplace_back(MemArg); @@ -3178,7 +3178,7 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { throw sycl::exception( sycl::make_error_code(sycl::errc::runtime), "Can't get memory object due to no allocation available " + - codeToString(PI_ERROR_INVALID_MEM_OBJECT)); + codeToString(UR_RESULT_ERROR_INVALID_MEM_OBJECT)); }; std::for_each(std::begin(HandlerReq), std::end(HandlerReq), ReqToMemConv); std::sort(std::begin(ReqToMem), std::end(ReqToMem));