Skip to content

Commit 3a13d76

Browse files
committed
[SYCL][Graphs] Apply fixes from sycl-graph-release
- Formatting fixes - ABI symbol check updates - Small compilation issues fixed
1 parent c06645b commit 3a13d76

17 files changed

+122
-98
lines changed

sycl/include/sycl/detail/pi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2102,7 +2102,7 @@ __SYCL_EXPORT pi_result piPluginGetBackendOption(pi_platform platform,
21022102
__SYCL_EXPORT pi_result piGetDeviceAndHostTimer(pi_device Device,
21032103
uint64_t *DeviceTime,
21042104
uint64_t *HostTime);
2105-
2105+
21062106
/// Command buffer extension
21072107
struct _pi_ext_command_buffer;
21082108
struct _pi_ext_sync_point;

sycl/plugins/hip/pi_hip.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2001,7 +2001,7 @@ pi_result hip_piDeviceGetInfo(pi_device device, pi_device_info param_name,
20012001
PI_ERROR_INVALID_ARG_VALUE);
20022002
return PI_ERROR_PLUGIN_SPECIFIC_ERROR;
20032003

2004-
case PI_EXT_ONEAPI_DEVICE_INFO_COMMAND_BUFFER_SUPPORT {
2004+
case PI_EXT_ONEAPI_DEVICE_INFO_COMMAND_BUFFER_SUPPORT: {
20052005
// Using HIP-Graphs as a backend for PI command-buffers no yet supported
20062006
return getInfo<pi_bool>(param_value_size, param_value, param_value_size_ret,
20072007
false);

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8987,7 +8987,8 @@ pi_result piextCommandBufferNDRangeKernel(
89878987
std::scoped_lock<ur_shared_mutex, ur_shared_mutex> Lock(
89888988
Kernel->Mutex, Kernel->Program->Mutex);
89898989
if (GlobalWorkOffset != NULL) {
8990-
if (!CommandBuffer->Context->getPlatform()->ZeDriverGlobalOffsetExtensionFound) {
8990+
if (!CommandBuffer->Context->getPlatform()
8991+
->ZeDriverGlobalOffsetExtensionFound) {
89918992
urPrint("No global offset extension found on this driver\n");
89928993
return PI_ERROR_INVALID_VALUE;
89938994
}
@@ -9116,10 +9117,12 @@ pi_result piextEnqueueCommandBuffer(pi_ext_command_buffer CommandBuffer,
91169117
ZE_CALL(zeFenceCreate, (ZeCommandQueue, &ZeFenceDesc, &ZeFence));
91179118
// TODO: Refactor so requiring a map iterator is not required here, currently
91189119
// required for executeCommandList though.
9120+
ZeStruct<ze_command_queue_desc_t> ZeQueueDesc;
9121+
ZeQueueDesc.ordinal = QueueGroupOrdinal;
91199122
std::tie(CommandListPtr, std::ignore) = CommandBuffer->CommandListMap.insert(
91209123
std::pair<ze_command_list_handle_t, pi_command_list_info_t>(
91219124
CommandBuffer->ZeCommandList,
9122-
{ZeFence, false, false, ZeCommandQueue, QueueGroupOrdinal}));
9125+
{ZeFence, false, false, ZeCommandQueue, ZeQueueDesc}));
91239126

91249127
Queue->insertActiveBarriers(CommandListPtr, UseCopyEngine);
91259128

sycl/source/detail/event_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ class event_impl {
255255
ensureContextInitialized();
256256
return MContext;
257257
}
258-
258+
259259
// Sets a sync point which is used when this event represents an enqueue to a
260260
// RT::PiExtCommandBuffer.
261261
void setSyncPoint(RT::PiExtSyncPoint SyncPoint) { MSyncPoint = SyncPoint; }

sycl/source/detail/graph_impl.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
//===----------------------------------------------------------------------===//
88

99
#include <detail/graph_impl.hpp>
10+
#include <detail/handler_impl.hpp>
1011
#include <detail/kernel_arg_mask.hpp>
11-
#include <detail/handler_impl.hpp>
1212
#include <detail/program_manager/program_manager.hpp>
1313
#include <detail/queue_impl.hpp>
1414
#include <detail/scheduler/commands.hpp>
@@ -130,8 +130,8 @@ graph_impl::add(const std::vector<std::shared_ptr<node_impl>> &Dep) {
130130
if (!Dep.empty()) {
131131
for (auto N : Dep) {
132132
N->register_successor(NodeImpl, N); // register successor
133-
this->remove_root(NodeImpl); // remove receiver from root node
134-
// list
133+
this->remove_root(NodeImpl); // remove receiver from root node
134+
// list
135135
}
136136
} else {
137137
this->add_root(NodeImpl);
@@ -200,8 +200,8 @@ graph_impl::add(sycl::detail::CG::CGTYPE CGType,
200200
if (!Deps.empty()) {
201201
for (auto N : Deps) {
202202
N->register_successor(NodeImpl, N); // register successor
203-
this->remove_root(NodeImpl); // remove receiver from root node
204-
// list
203+
this->remove_root(NodeImpl); // remove receiver from root node
204+
// list
205205
}
206206
} else {
207207
this->add_root(NodeImpl);

sycl/source/detail/graph_impl.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ class node_impl {
6868

6969
/// Construct a node representing a command-group.
7070
/// @param CGType Type of the command-group.
71-
/// @param CommandGroup The CG which stores the command information for this node.
71+
/// @param CommandGroup The CG which stores the command information for this
72+
/// node.
7273
node_impl(sycl::detail::CG::CGTYPE CGType,
7374
std::unique_ptr<sycl::detail::CG> &&CommandGroup)
7475
: MCGType(CGType), MCommandGroup(std::move(CommandGroup)) {}

sycl/source/detail/scheduler/commands.cpp

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2098,64 +2098,64 @@ void SetArgBasedOnType(
20982098
const std::function<void *(Requirement *Req)> &getMemAllocationFunc,
20992099
const sycl::context &Context, bool IsHost, detail::ArgDesc &Arg,
21002100
size_t NextTrueIndex) {
2101-
switch (Arg.MType) {
2102-
case kernel_param_kind_t::kind_stream:
2101+
switch (Arg.MType) {
2102+
case kernel_param_kind_t::kind_stream:
2103+
break;
2104+
case kernel_param_kind_t::kind_accessor: {
2105+
Requirement *Req = (Requirement *)(Arg.MPtr);
2106+
if (Req->MAccessRange == range<3>({0, 0, 0}))
21032107
break;
2104-
case kernel_param_kind_t::kind_accessor: {
2105-
Requirement *Req = (Requirement *)(Arg.MPtr);
2106-
if (Req->MAccessRange == range<3>({0, 0, 0}))
2107-
break;
2108-
assert(getMemAllocationFunc != nullptr &&
2109-
"We should have caught this earlier.");
2108+
assert(getMemAllocationFunc != nullptr &&
2109+
"We should have caught this earlier.");
21102110

2111-
RT::PiMem MemArg = (RT::PiMem)getMemAllocationFunc(Req);
2112-
if (Context.get_backend() == backend::opencl) {
2113-
Plugin->call<PiApiKind::piKernelSetArg>(Kernel, NextTrueIndex,
2114-
sizeof(RT::PiMem), &MemArg);
2115-
} else {
2116-
Plugin->call<PiApiKind::piextKernelSetArgMemObj>(Kernel, NextTrueIndex,
2117-
&MemArg);
2118-
}
2119-
break;
2120-
}
2121-
case kernel_param_kind_t::kind_std_layout: {
2122-
Plugin->call<PiApiKind::piKernelSetArg>(Kernel, NextTrueIndex, Arg.MSize,
2123-
Arg.MPtr);
2124-
break;
2125-
}
2126-
case kernel_param_kind_t::kind_sampler: {
2127-
sampler *SamplerPtr = (sampler *)Arg.MPtr;
2128-
RT::PiSampler Sampler =
2129-
detail::getSyclObjImpl(*SamplerPtr)->getOrCreateSampler(Context);
2130-
Plugin->call<PiApiKind::piextKernelSetArgSampler>(Kernel, NextTrueIndex,
2131-
&Sampler);
2132-
break;
2133-
}
2134-
case kernel_param_kind_t::kind_pointer: {
2135-
Plugin->call<PiApiKind::piextKernelSetArgPointer>(Kernel, NextTrueIndex,
2136-
Arg.MSize, Arg.MPtr);
2137-
break;
2138-
}
2139-
case kernel_param_kind_t::kind_specialization_constants_buffer: {
2140-
if (IsHost) {
2141-
throw sycl::feature_not_supported(
2142-
"SYCL2020 specialization constants are not yet supported on host "
2143-
"device",
2144-
PI_ERROR_INVALID_OPERATION);
2145-
}
2146-
assert(DeviceImageImpl != nullptr);
2147-
RT::PiMem SpecConstsBuffer = DeviceImageImpl->get_spec_const_buffer_ref();
2148-
// Avoid taking an address of nullptr
2149-
RT::PiMem *SpecConstsBufferArg =
2150-
SpecConstsBuffer ? &SpecConstsBuffer : nullptr;
2111+
RT::PiMem MemArg = (RT::PiMem)getMemAllocationFunc(Req);
2112+
if (Context.get_backend() == backend::opencl) {
2113+
Plugin->call<PiApiKind::piKernelSetArg>(Kernel, NextTrueIndex,
2114+
sizeof(RT::PiMem), &MemArg);
2115+
} else {
21512116
Plugin->call<PiApiKind::piextKernelSetArgMemObj>(Kernel, NextTrueIndex,
2152-
SpecConstsBufferArg);
2153-
break;
2117+
&MemArg);
21542118
}
2155-
case kernel_param_kind_t::kind_invalid:
2156-
throw runtime_error("Invalid kernel param kind", PI_ERROR_INVALID_VALUE);
2157-
break;
2119+
break;
2120+
}
2121+
case kernel_param_kind_t::kind_std_layout: {
2122+
Plugin->call<PiApiKind::piKernelSetArg>(Kernel, NextTrueIndex, Arg.MSize,
2123+
Arg.MPtr);
2124+
break;
2125+
}
2126+
case kernel_param_kind_t::kind_sampler: {
2127+
sampler *SamplerPtr = (sampler *)Arg.MPtr;
2128+
RT::PiSampler Sampler =
2129+
detail::getSyclObjImpl(*SamplerPtr)->getOrCreateSampler(Context);
2130+
Plugin->call<PiApiKind::piextKernelSetArgSampler>(Kernel, NextTrueIndex,
2131+
&Sampler);
2132+
break;
2133+
}
2134+
case kernel_param_kind_t::kind_pointer: {
2135+
Plugin->call<PiApiKind::piextKernelSetArgPointer>(Kernel, NextTrueIndex,
2136+
Arg.MSize, Arg.MPtr);
2137+
break;
2138+
}
2139+
case kernel_param_kind_t::kind_specialization_constants_buffer: {
2140+
if (IsHost) {
2141+
throw sycl::feature_not_supported(
2142+
"SYCL2020 specialization constants are not yet supported on host "
2143+
"device",
2144+
PI_ERROR_INVALID_OPERATION);
21582145
}
2146+
assert(DeviceImageImpl != nullptr);
2147+
RT::PiMem SpecConstsBuffer = DeviceImageImpl->get_spec_const_buffer_ref();
2148+
// Avoid taking an address of nullptr
2149+
RT::PiMem *SpecConstsBufferArg =
2150+
SpecConstsBuffer ? &SpecConstsBuffer : nullptr;
2151+
Plugin->call<PiApiKind::piextKernelSetArgMemObj>(Kernel, NextTrueIndex,
2152+
SpecConstsBufferArg);
2153+
break;
2154+
}
2155+
case kernel_param_kind_t::kind_invalid:
2156+
throw runtime_error("Invalid kernel param kind", PI_ERROR_INVALID_VALUE);
2157+
break;
2158+
}
21592159
}
21602160

21612161
static pi_result SetKernelParamsAndLaunch(

sycl/source/detail/scheduler/commands.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -746,8 +746,7 @@ void SetArgBasedOnType(
746746
size_t NextTrueIndex);
747747

748748
void applyFuncOnFilteredArgs(
749-
const KernelArgMask *EliminatedArgMask,
750-
std::vector<ArgDesc> &Args,
749+
const KernelArgMask *EliminatedArgMask, std::vector<ArgDesc> &Args,
751750
std::function<void(detail::ArgDesc &Arg, int NextTrueIndex)> Func);
752751

753752
void ReverseRangeDimensionsForKernel(NDRDescT &NDR);

sycl/source/detail/scheduler/graph_builder.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -898,8 +898,7 @@ EmptyCommand *Scheduler::GraphBuilder::addEmptyCmd(
898898
return EmptyCmd;
899899
}
900900

901-
template <typename T>
902-
static bool isInteropHostTask(T *Cmd) {
901+
template <typename T> static bool isInteropHostTask(T *Cmd) {
903902
if (Cmd->getCG().getType() != CG::CGTYPE::CodeplayHostTask)
904903
return false;
905904

sycl/source/detail/scheduler/scheduler.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ void Scheduler::waitForRecordToFinish(MemObjRecord *Record,
8888
}
8989

9090
EventImplPtr
91-
Scheduler::addCG(std::unique_ptr<detail::CG> CommandGroup, const QueueImplPtr &Queue,
91+
Scheduler::addCG(std::unique_ptr<detail::CG> CommandGroup,
92+
const QueueImplPtr &Queue,
9293
RT::PiExtCommandBuffer CommandBuffer,
9394
const std::vector<RT::PiExtSyncPoint> &Dependencies) {
9495
EventImplPtr NewEvent = nullptr;

sycl/source/detail/scheduler/scheduler.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -540,10 +540,11 @@ class Scheduler {
540540
/// \return a command that represents command group execution and a bool
541541
/// indicating whether this command should be enqueued to the graph
542542
/// processor right away or not.
543-
GraphBuildResult addCG(std::unique_ptr<detail::CG> CommandGroup, const QueueImplPtr &Queue,
544-
std::vector<Command *> &ToEnqueue,
545-
RT::PiExtCommandBuffer CommandBuffer = nullptr,
546-
const std::vector<RT::PiExtSyncPoint> &Dependencies = {});
543+
GraphBuildResult
544+
addCG(std::unique_ptr<detail::CG> CommandGroup, const QueueImplPtr &Queue,
545+
std::vector<Command *> &ToEnqueue,
546+
RT::PiExtCommandBuffer CommandBuffer = nullptr,
547+
const std::vector<RT::PiExtSyncPoint> &Dependencies = {});
547548

548549
/// Registers a \ref CG "command group" that updates host memory to the
549550
/// latest state.

sycl/test/abi/layout_handler.cpp

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -179,26 +179,42 @@ void foo() {
179179
// CHECK-NEXT: 512 | element_type * _M_ptr
180180
// CHECK-NEXT: 520 | class std::__shared_count<> _M_refcount
181181
// CHECK-NEXT: 520 | _Sp_counted_base<(_Lock_policy)2U> * _M_pi
182-
// CHECK-NEXT: 528 | class std::shared_ptr<class sycl::ext::oneapi::experimental::detail::node_impl> MSubgraphNode
183-
// CHECK-NEXT: 528 | class std::__shared_ptr<class sycl::ext::oneapi::experimental::detail::node_impl> (base)
184-
// CHECK-NEXT: 528 | class std::__shared_ptr_access<class sycl::ext::oneapi::experimental::detail::node_impl, __gnu_cxx::_S_atomic> (base) (empty)
182+
// CHECK-NEXT: 528 | class std::shared_ptr<class sycl::ext::oneapi::experimental::detail::exec_graph_impl> MExecGraph
183+
// CHECK-NEXT: 528 | class std::__shared_ptr<class sycl::ext::oneapi::experimental::detail::exec_graph_impl> (base)
184+
// CHECK-NEXT: 528 | class std::__shared_ptr_access<class sycl::ext::oneapi::experimental::detail::exec_graph_impl, __gnu_cxx::_S_atomic> (base) (empty)
185185
// CHECK-NEXT: 528 | element_type * _M_ptr
186186
// CHECK-NEXT: 536 | class std::__shared_count<> _M_refcount
187187
// CHECK-NEXT: 536 | _Sp_counted_base<(_Lock_policy)2U> * _M_pi
188-
// CHECK-NEXT: 544 | _Bool MIsHost
189-
// CHECK-NEXT: 552 | struct sycl::detail::code_location MCodeLoc
190-
// CHECK-NEXT: 552 | const char * MFileName
191-
// CHECK-NEXT: 560 | const char * MFunctionName
192-
// CHECK-NEXT: 568 | unsigned long MLineNo
193-
// CHECK-NEXT: 576 | unsigned long MColumnNo
194-
// CHECK-NEXT: 584 | _Bool MIsFinalized
195-
// CHECK-NEXT: 592 | class sycl::event MLastEvent
196-
// CHECK-NEXT: 592 | class sycl::detail::OwnerLessBase<class sycl::event> (base) (empty)
197-
// CHECK-NEXT: 592 | class std::shared_ptr<class sycl::detail::event_impl> impl
198-
// CHECK-NEXT: 592 | class std::__shared_ptr<class sycl::detail::event_impl> (base)
199-
// CHECK-NEXT: 592 | class std::__shared_ptr_access<class sycl::detail::event_impl, __gnu_cxx::_S_atomic> (base) (empty)
200-
// CHECK-NEXT: 592 | element_type * _M_ptr
201-
// CHECK-NEXT: 600 | class std::__shared_count<> _M_refcount
202-
// CHECK-NEXT: 600 | _Sp_counted_base<(_Lock_policy)2U> * _M_pi
203-
// CHECK-NEXT: | [sizeof=608, dsize=608, align=8,
204-
// CHECK-NEXT: | nvsize=608, nvalign=8]
188+
// CHECK-NEXT: 544 | class std::shared_ptr<class sycl::ext::oneapi::experimental::detail::node_impl> MSubgraphNode
189+
// CHECK-NEXT: 544 | class std::__shared_ptr<class sycl::ext::oneapi::experimental::detail::node_impl> (base)
190+
// CHECK-NEXT: 544 | class std::__shared_ptr_access<class sycl::ext::oneapi::experimental::detail::node_impl, __gnu_cxx::_S_atomic> (base) (empty)
191+
// CHECK-NEXT: 544 | element_type * _M_ptr
192+
// CHECK-NEXT: 552 | class std::__shared_count<> _M_refcount
193+
// CHECK-NEXT: 552 | _Sp_counted_base<(_Lock_policy)2U> * _M_pi
194+
// CHECK-NEXT: 560 | class std::unique_ptr<class sycl::detail::CG> MGraphNodeCG
195+
// CHECK-NEXT: 560 | struct std::__uniq_ptr_data<class sycl::detail::CG, struct std::default_delete<class sycl::detail::CG> > _M_t
196+
// CHECK-NEXT: 560 | class std::__uniq_ptr_impl<class sycl::detail::CG, struct std::default_delete<class sycl::detail::CG> > (base)
197+
// CHECK-NEXT: 560 | class std::tuple<class sycl::detail::CG *, struct std::default_delete<class sycl::detail::CG> > _M_t
198+
// CHECK-NEXT: 560 | struct std::_Tuple_impl<0, class sycl::detail::CG *, struct std::default_delete<class sycl::detail::CG> > (base)
199+
// CHECK-NEXT: 560 | struct std::_Tuple_impl<1, struct std::default_delete<class sycl::detail::CG> > (base) (empty)
200+
// CHECK-NEXT: 560 | struct std::_Head_base<1, struct std::default_delete<class sycl::detail::CG> > (base) (empty)
201+
// CHECK-NEXT: 560 | struct std::default_delete<class sycl::detail::CG> _M_head_impl (empty)
202+
// CHECK-NEXT: 560 | struct std::_Head_base<0, class sycl::detail::CG *> (base)
203+
// CHECK-NEXT: 560 | class sycl::detail::CG * _M_head_impl
204+
// CHECK-NEXT: 568 | _Bool MIsHost
205+
// CHECK-NEXT: 576 | struct sycl::detail::code_location MCodeLoc
206+
// CHECK-NEXT: 576 | const char * MFileName
207+
// CHECK-NEXT: 584 | const char * MFunctionName
208+
// CHECK-NEXT: 592 | unsigned long MLineNo
209+
// CHECK-NEXT: 600 | unsigned long MColumnNo
210+
// CHECK-NEXT: 608 | _Bool MIsFinalized
211+
// CHECK-NEXT: 616 | class sycl::event MLastEvent
212+
// CHECK-NEXT: 616 | class sycl::detail::OwnerLessBase<class sycl::event> (base) (empty)
213+
// CHECK-NEXT: 616 | class std::shared_ptr<class sycl::detail::event_impl> impl
214+
// CHECK-NEXT: 616 | class std::__shared_ptr<class sycl::detail::event_impl> (base)
215+
// CHECK-NEXT: 616 | class std::__shared_ptr_access<class sycl::detail::event_impl, __gnu_cxx::_S_atomic> (base) (empty)
216+
// CHECK-NEXT: 616 | element_type * _M_ptr
217+
// CHECK-NEXT: 624 | class std::__shared_count<> _M_refcount
218+
// CHECK-NEXT: 624 | _Sp_counted_base<(_Lock_policy)2U> * _M_pi
219+
// CHECK-NEXT: | [sizeof=632, dsize=632, align=8,
220+
// CHECK-NEXT: | nvsize=632, nvalign=8]

sycl/test/abi/pi_level_zero_symbol_check.dump

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ piTearDown
8585
piclProgramCreateWithSource
8686
piextCommandBufferCreate
8787
piextCommandBufferFinalize
88+
piextCommandBufferMemcpyUSM
8889
piextCommandBufferNDRangeKernel
8990
piextCommandBufferRelease
9091
piextCommandBufferRetain

sycl/test/abi/pi_opencl_symbol_check.dump

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ piTearDown
3636
piclProgramCreateWithSource
3737
piextCommandBufferCreate
3838
piextCommandBufferFinalize
39+
piextCommandBufferMemcpyUSM
3940
piextCommandBufferNDRangeKernel
4041
piextCommandBufferRelease
4142
piextCommandBufferRetain

0 commit comments

Comments
 (0)