30 inline namespace _V1 {
35 namespace ext::oneapi::experimental::detail {
36 class exec_graph_impl;
66 void setNDRangeLeftover() {
67 for (
int I =
Dims; I < 3; ++I) {
76 if constexpr (
Dims == 3) {
80 for (
int I = 0; I <
Dims; ++I)
87 if constexpr (
Dims == 3) {
91 for (
int I = 0; I <
Dims; ++I)
105 Dims{size_t(DimsArg)} {
106 setNDRangeLeftover();
110 : GlobalSize{NumWorkItems}, GlobalOffset{Offset}, Dims{size_t(DimsArg)} {}
114 : GlobalSize{NumWorkItems}, LocalSize{LocalSize}, GlobalOffset{Offset},
115 Dims{size_t(DimsArg)} {
116 setNDRangeLeftover();
121 :
NDRDescT(padRange(ExecutionRange.get_global_range()),
122 padRange(ExecutionRange.get_local_range()),
123 padId(ExecutionRange.
get_offset()), size_t(DimsArg)) {
124 setNDRangeLeftover();
129 :
NDRDescT(ExecutionRange, Dims_) {}
133 :
NDRDescT(padRange(Range), false, Dims_) {}
136 if (this->Dims !=
size_t(Dims)) {
137 throw std::runtime_error(
138 "Dimensionality of cluster, global and local ranges must be same");
141 for (
int I = 0; I < 3; ++I)
142 ClusterDimensions[I] = (I < Dims) ? N[I] : 1;
165 std::vector<detail::AccessorImplPtr> AccStorage,
166 std::vector<std::shared_ptr<const void>> SharedPtrStorage,
167 std::vector<AccessorImplHost *> Requirements,
168 std::vector<detail::EventImplPtr> Events)
169 : MArgsStorage(
std::move(ArgsStorage)),
170 MAccStorage(
std::move(AccStorage)),
171 MSharedPtrStorage(
std::move(SharedPtrStorage)),
172 MRequirements(
std::move(Requirements)), MEvents(
std::move(Events)) {}
192 : MType(Type), MData(std::move(D)) {
196 if (loc.functionName())
197 MFunctionName = loc.functionName();
199 MFileName = loc.fileName();
200 MLine = loc.lineNumber();
201 MColumn = loc.columnNumber();
204 CG(
CG &&CommandGroup) =
default;
205 CG(
const CG &CommandGroup) =
default;
210 return MData.MArgsStorage;
213 return MData.MAccStorage;
216 return MData.MSharedPtrStorage;
220 return MData.MRequirements;
222 std::vector<detail::EventImplPtr> &
getEvents() {
return MData.MEvents; }
224 virtual std::vector<std::shared_ptr<const void>>
255 std::vector<std::shared_ptr<detail::stream_impl>>
MStreams;
258 bool MKernelIsCooperative =
false;
259 bool MKernelUsesClusterLaunch =
false;
262 std::shared_ptr<detail::kernel_impl> SyclKernel,
263 std::shared_ptr<detail::kernel_bundle_impl> KernelBundle,
265 std::string KernelName,
266 std::vector<std::shared_ptr<detail::stream_impl>> Streams,
267 std::vector<std::shared_ptr<const void>> AuxiliaryResources,
268 CGType Type, ur_kernel_cache_config_t KernelCacheConfig,
269 bool KernelIsCooperative,
bool MKernelUsesClusterLaunch,
271 :
CG(Type, std::move(CGData), std::move(loc)),
272 MNDRDesc(std::move(NDRDesc)), MHostKernel(std::move(HKernel)),
273 MSyclKernel(std::move(SyclKernel)),
274 MKernelBundle(std::move(KernelBundle)), MArgs(std::move(Args)),
275 MKernelName(std::move(KernelName)), MStreams(std::move(Streams)),
276 MAuxiliaryResources(std::move(AuxiliaryResources)),
277 MKernelCacheConfig(std::move(KernelCacheConfig)),
278 MKernelIsCooperative(KernelIsCooperative),
279 MKernelUsesClusterLaunch(MKernelUsesClusterLaunch) {
280 assert(getType() == CGType::Kernel &&
"Wrong type of exec kernel CG.");
287 std::vector<std::shared_ptr<detail::stream_impl>>
getStreams()
const {
291 std::vector<std::shared_ptr<const void>>
293 return MAuxiliaryResources;
298 return MKernelBundle;
309 std::vector<std::shared_ptr<const void>> MAuxiliaryResources;
313 std::vector<std::shared_ptr<const void>> AuxiliaryResources,
315 :
CG(CopyType, std::move(CGData), std::move(loc)), MSrc(Src), MDst(Dst),
316 MAuxiliaryResources{AuxiliaryResources} {}
320 std::vector<std::shared_ptr<const void>>
322 return MAuxiliaryResources;
333 CGFill(std::vector<unsigned char> Pattern,
void *Ptr,
335 :
CG(CGType::Fill, std::move(CGData), std::move(loc)),
347 :
CG(CGType::UpdateHost, std::move(CGData), std::move(loc)),
362 :
CG(CGType::CopyUSM, std::move(CGData), std::move(loc)), MSrc(Src),
363 MDst(Dst), MLength(Length) {}
372 std::vector<unsigned char> MPattern;
377 CGFillUSM(std::vector<unsigned char> Pattern,
void *DstPtr,
size_t Length,
379 :
CG(CGType::FillUSM, std::move(CGData), std::move(loc)),
380 MPattern(std::move(Pattern)), MDst(DstPtr), MLength(Length) {}
383 const std::vector<unsigned char> &
getPattern() {
return MPattern; }
394 :
CG(CGType::PrefetchUSM, std::move(CGData), std::move(loc)),
395 MDst(DstPtr), MLength(Length) {}
404 ur_usm_advice_flags_t MAdvice;
407 CGAdviseUSM(
void *DstPtr,
size_t Length, ur_usm_advice_flags_t Advice,
410 :
CG(Type, std::move(CGData), std::move(loc)), MDst(DstPtr),
411 MLength(Length), MAdvice(Advice) {}
421 CGBarrier(std::vector<detail::EventImplPtr> EventsWaitWithBarrier,
424 :
CG(Type, std::move(CGData), std::move(loc)),
425 MEventsWaitWithBarrier(std::move(EventsWaitWithBarrier)) {}
431 :
CG(CGType::ProfilingTag, std::move(CGData), std::move(loc)) {}
444 CGCopy2DUSM(
void *Src,
void *Dst,
size_t SrcPitch,
size_t DstPitch,
447 :
CG(CGType::Copy2DUSM, std::move(CGData), std::move(loc)), MSrc(Src),
448 MDst(Dst), MSrcPitch(SrcPitch), MDstPitch(DstPitch), MWidth(Width),
461 std::vector<unsigned char> MPattern;
468 CGFill2DUSM(std::vector<unsigned char> Pattern,
void *DstPtr,
size_t Pitch,
471 :
CG(CGType::Fill2DUSM, std::move(CGData), std::move(loc)),
472 MPattern(std::move(Pattern)), MDst(DstPtr), MPitch(Pitch),
473 MWidth(Width), MHeight(Height) {}
478 const std::vector<unsigned char> &
getPattern()
const {
return MPattern; }
493 :
CG(CGType::Memset2DUSM, std::move(CGData), std::move(loc)),
494 MValue(Value), MDst(DstPtr), MPitch(Pitch), MWidth(Width),
505 std::string PipeName;
515 :
CG(CGType::ReadWriteHostPipe, std::move(CGData), std::move(loc)),
516 PipeName(Name), Blocking(Block), HostPtr(Ptr), TypeSize(Size),
529 void *MDeviceGlobalPtr;
530 bool MIsDeviceImageScoped;
536 bool IsDeviceImageScoped,
size_t NumBytes,
size_t Offset,
539 :
CG(CGType::CopyToDeviceGlobal, std::move(CGData), std::move(loc)),
540 MSrc(Src), MDeviceGlobalPtr(DeviceGlobalPtr),
541 MIsDeviceImageScoped(IsDeviceImageScoped), MNumBytes(NumBytes),
553 void *MDeviceGlobalPtr;
555 bool MIsDeviceImageScoped;
561 bool IsDeviceImageScoped,
size_t NumBytes,
564 :
CG(CGType::CopyFromDeviceGlobal, std::move(CGData), std::move(loc)),
565 MDeviceGlobalPtr(DeviceGlobalPtr), MDest(Dest),
566 MIsDeviceImageScoped(IsDeviceImageScoped), MNumBytes(NumBytes),
579 ur_image_desc_t MSrcImageDesc;
580 ur_image_desc_t MDstImageDesc;
581 ur_image_format_t MSrcImageFormat;
582 ur_image_format_t MDstImageFormat;
583 ur_exp_image_copy_flags_t MImageCopyFlags;
584 ur_rect_offset_t MSrcOffset;
585 ur_rect_offset_t MDstOffset;
586 ur_rect_region_t MCopyExtent;
590 ur_image_desc_t DstImageDesc, ur_image_format_t SrcImageFormat,
591 ur_image_format_t DstImageFormat,
592 ur_exp_image_copy_flags_t ImageCopyFlags,
593 ur_rect_offset_t SrcOffset, ur_rect_offset_t DstOffset,
596 :
CG(CGType::CopyImage, std::move(CGData), std::move(loc)), MSrc(Src),
597 MDst(Dst), MSrcImageDesc(SrcImageDesc), MDstImageDesc(DstImageDesc),
598 MSrcImageFormat(SrcImageFormat), MDstImageFormat(DstImageFormat),
599 MImageCopyFlags(ImageCopyFlags), MSrcOffset(SrcOffset),
600 MDstOffset(DstOffset), MCopyExtent(CopyExtent) {}
608 ur_exp_image_copy_flags_t
getCopyFlags()
const {
return MImageCopyFlags; }
616 ur_exp_external_semaphore_handle_t MExternalSemaphore;
617 std::optional<uint64_t> MWaitValue;
621 std::optional<uint64_t> WaitValue,
623 :
CG(CGType::SemaphoreWait, std::move(CGData), std::move(loc)),
624 MExternalSemaphore(ExternalSemaphore), MWaitValue(WaitValue) {}
627 assert(MExternalSemaphore !=
nullptr &&
628 "MExternalSemaphore has not been defined yet.");
629 return MExternalSemaphore;
636 ur_exp_external_semaphore_handle_t MExternalSemaphore;
637 std::optional<uint64_t> MSignalValue;
641 std::optional<uint64_t> SignalValue,
644 :
CG(CGType::SemaphoreSignal, std::move(CGData), std::move(loc)),
645 MExternalSemaphore(ExternalSemaphore), MSignalValue(SignalValue) {}
648 if (MExternalSemaphore ==
nullptr)
650 "getExternalSemaphore(): MExternalSemaphore has not been "
652 return MExternalSemaphore;
661 std::shared_ptr<sycl::ext::oneapi::experimental::detail::exec_graph_impl>
665 const ur_exp_command_buffer_handle_t &CommandBuffer,
666 const std::shared_ptr<
670 MCommandBuffer(CommandBuffer), MExecGraph(ExecGraph) {}
677 std::shared_ptr<detail::queue_impl>
MQueue;
683 std::shared_ptr<detail::queue_impl> Queue,
684 std::shared_ptr<detail::context_impl> Context,
687 :
CG(Type, std::move(CGData), std::move(loc)),
688 MHostTask(std::move(
HostTask)), MQueue(Queue), MContext(Context),
689 MArgs(std::move(Args)) {}
The file contains implementations of accessor class.
ArgDesc(sycl::detail::kernel_param_kind_t Type, void *Ptr, int Size, int Index)
sycl::detail::kernel_param_kind_t MType
"Advise USM" command group class.
ur_usm_advice_flags_t getAdvice()
CGAdviseUSM(void *DstPtr, size_t Length, ur_usm_advice_flags_t Advice, CG::StorageInitHelper CGData, CGType Type, detail::code_location loc={})
std::vector< detail::EventImplPtr > MEventsWaitWithBarrier
CGBarrier(std::vector< detail::EventImplPtr > EventsWaitWithBarrier, CG::StorageInitHelper CGData, CGType Type, detail::code_location loc={})
"Copy 2D USM" command group class.
size_t getDstPitch() const
size_t getSrcPitch() const
CGCopy2DUSM(void *Src, void *Dst, size_t SrcPitch, size_t DstPitch, size_t Width, size_t Height, CG::StorageInitHelper CGData, detail::code_location loc={})
"Copy to device_global" command group class.
void * getDeviceGlobalPtr()
bool isDeviceImageScoped()
CGCopyFromDeviceGlobal(void *DeviceGlobalPtr, void *Dest, bool IsDeviceImageScoped, size_t NumBytes, size_t Offset, CG::StorageInitHelper CGData, detail::code_location loc={})
"Copy Image" command group class.
ur_rect_offset_t getSrcOffset() const
ur_rect_region_t getCopyExtent() const
ur_image_format_t getSrcFormat() const
ur_image_format_t getDstFormat() const
CGCopyImage(void *Src, void *Dst, ur_image_desc_t SrcImageDesc, ur_image_desc_t DstImageDesc, ur_image_format_t SrcImageFormat, ur_image_format_t DstImageFormat, ur_exp_image_copy_flags_t ImageCopyFlags, ur_rect_offset_t SrcOffset, ur_rect_offset_t DstOffset, ur_rect_region_t CopyExtent, CG::StorageInitHelper CGData, detail::code_location loc={})
ur_image_desc_t getDstDesc() const
ur_image_desc_t getSrcDesc() const
ur_exp_image_copy_flags_t getCopyFlags() const
ur_rect_offset_t getDstOffset() const
"Copy to device_global" command group class.
void * getDeviceGlobalPtr()
CGCopyToDeviceGlobal(void *Src, void *DeviceGlobalPtr, bool IsDeviceImageScoped, size_t NumBytes, size_t Offset, CG::StorageInitHelper CGData, detail::code_location loc={})
bool isDeviceImageScoped()
"Copy USM" command group class.
CGCopyUSM(void *Src, void *Dst, size_t Length, CG::StorageInitHelper CGData, detail::code_location loc={})
"Copy memory" command group class.
void clearAuxiliaryResources() override
CGCopy(CGType CopyType, void *Src, void *Dst, CG::StorageInitHelper CGData, std::vector< std::shared_ptr< const void >> AuxiliaryResources, detail::code_location loc={})
std::vector< std::shared_ptr< const void > > getAuxiliaryResources() const override
"Execute command-buffer" command group class.
CGExecCommandBuffer(const ur_exp_command_buffer_handle_t &CommandBuffer, const std::shared_ptr< sycl::ext::oneapi::experimental::detail::exec_graph_impl > &ExecGraph, CG::StorageInitHelper CGData)
std::shared_ptr< sycl::ext::oneapi::experimental::detail::exec_graph_impl > MExecGraph
ur_exp_command_buffer_handle_t MCommandBuffer
"Execute kernel" command group class.
CGExecKernel(NDRDescT NDRDesc, std::shared_ptr< HostKernelBase > HKernel, std::shared_ptr< detail::kernel_impl > SyclKernel, std::shared_ptr< detail::kernel_bundle_impl > KernelBundle, CG::StorageInitHelper CGData, std::vector< ArgDesc > Args, std::string KernelName, std::vector< std::shared_ptr< detail::stream_impl >> Streams, std::vector< std::shared_ptr< const void >> AuxiliaryResources, CGType Type, ur_kernel_cache_config_t KernelCacheConfig, bool KernelIsCooperative, bool MKernelUsesClusterLaunch, detail::code_location loc={})
std::shared_ptr< detail::kernel_bundle_impl > MKernelBundle
std::vector< std::shared_ptr< const void > > getAuxiliaryResources() const override
std::vector< std::shared_ptr< const void > > MAuxiliaryResources
void clearAuxiliaryResources() override
std::string getKernelName() const
std::vector< ArgDesc > MArgs
NDRDescT MNDRDesc
Stores ND-range description.
std::shared_ptr< detail::kernel_impl > MSyclKernel
std::shared_ptr< HostKernelBase > MHostKernel
CGExecKernel(const CGExecKernel &CGExec)=default
std::vector< std::shared_ptr< detail::stream_impl > > getStreams() const
ur_kernel_cache_config_t MKernelCacheConfig
std::vector< std::shared_ptr< detail::stream_impl > > MStreams
std::shared_ptr< detail::kernel_bundle_impl > getKernelBundle()
std::vector< ArgDesc > getArguments() const
"Fill 2D USM" command group class.
CGFill2DUSM(std::vector< unsigned char > Pattern, void *DstPtr, size_t Pitch, size_t Width, size_t Height, CG::StorageInitHelper CGData, detail::code_location loc={})
const std::vector< unsigned char > & getPattern() const
"Fill USM" command group class.
CGFillUSM(std::vector< unsigned char > Pattern, void *DstPtr, size_t Length, CG::StorageInitHelper CGData, detail::code_location loc={})
const std::vector< unsigned char > & getPattern()
"Fill memory" command group class.
std::vector< unsigned char > MPattern
CGFill(std::vector< unsigned char > Pattern, void *Ptr, CG::StorageInitHelper CGData, detail::code_location loc={})
AccessorImplHost * getReqToFill()
CGHostTask(std::shared_ptr< HostTask > HostTask, std::shared_ptr< detail::queue_impl > Queue, std::shared_ptr< detail::context_impl > Context, std::vector< ArgDesc > Args, CG::StorageInitHelper CGData, CGType Type, detail::code_location loc={})
std::shared_ptr< detail::context_impl > MContext
std::shared_ptr< detail::queue_impl > MQueue
std::vector< ArgDesc > MArgs
std::shared_ptr< HostTask > MHostTask
"Memset 2D USM" command group class.
CGMemset2DUSM(char Value, void *DstPtr, size_t Pitch, size_t Width, size_t Height, CG::StorageInitHelper CGData, detail::code_location loc={})
"Prefetch USM" command group class.
CGPrefetchUSM(void *DstPtr, size_t Length, CG::StorageInitHelper CGData, detail::code_location loc={})
CGProfilingTag(CG::StorageInitHelper CGData, detail::code_location loc={})
"ReadWriteHostPipe" command group class.
std::string getPipeName()
CGReadWriteHostPipe(const std::string &Name, bool Block, void *Ptr, size_t Size, bool Read, CG::StorageInitHelper CGData, detail::code_location loc={})
"Semaphore Signal" command group class.
std::optional< uint64_t > getSignalValue() const
ur_exp_external_semaphore_handle_t getExternalSemaphore() const
CGSemaphoreSignal(ur_exp_external_semaphore_handle_t ExternalSemaphore, std::optional< uint64_t > SignalValue, CG::StorageInitHelper CGData, detail::code_location loc={})
"Semaphore Wait" command group class.
ur_exp_external_semaphore_handle_t getExternalSemaphore() const
std::optional< uint64_t > getWaitValue() const
CGSemaphoreWait(ur_exp_external_semaphore_handle_t ExternalSemaphore, std::optional< uint64_t > WaitValue, CG::StorageInitHelper CGData, detail::code_location loc={})
"Update host" command group class.
AccessorImplHost * getReqToUpdate()
CGUpdateHost(void *Ptr, CG::StorageInitHelper CGData, detail::code_location loc={})
Base class for all types of command groups.
std::vector< detail::AccessorImplPtr > & getAccStorage()
std::vector< detail::EventImplPtr > & getEvents()
CG(const CG &CommandGroup)=default
std::vector< std::vector< char > > & getArgsStorage()
virtual void clearAuxiliaryResources()
virtual std::vector< std::shared_ptr< const void > > getAuxiliaryResources() const
CG(CGType Type, StorageInitHelper D, detail::code_location loc={})
std::vector< AccessorImplHost * > & getRequirements()
CG(CG &&CommandGroup)=default
std::vector< std::shared_ptr< const void > > & getSharedPtrStorage()
sycl::range< 3 > GlobalSize
sycl::range< 3 > NumWorkGroups
Number of workgroups, used to record the number of workgroups from the simplest form of parallel_for_...
NDRDescT(sycl::nd_range< Dims_ > ExecutionRange, int DimsArg)
NDRDescT(sycl::range< 3 > NumWorkItems, sycl::id< 3 > Offset, int DimsArg)
NDRDescT & operator=(NDRDescT &&Desc)=default
NDRDescT(sycl::range< Dims_ > Range)
sycl::id< 3 > GlobalOffset
NDRDescT(sycl::range< 3 > N, bool SetNumWorkGroups, int DimsArg)
NDRDescT(sycl::nd_range< Dims_ > ExecutionRange)
NDRDescT(NDRDescT &&Desc)=default
sycl::range< 3 > LocalSize
NDRDescT & operator=(const NDRDescT &Desc)=default
NDRDescT(sycl::range< 3 > NumWorkItems, sycl::range< 3 > LocalSize, sycl::id< 3 > Offset, int DimsArg)
void setClusterDimensions(sycl::range< 3 > N, int Dims)
NDRDescT(const NDRDescT &Desc)=default
Class representing the implementation of command_graph<executable>.
A unique identifier of an item in an index space.
Defines the iteration domain of both the work-groups and the overall dispatch.
Defines the iteration domain of either a single work-group in a parallel dispatch,...
std::shared_ptr< event_impl > EventImplPtr
CGType
Type of the command group.
sycl::detail::kernel_bundle_impl kernel_bundle_impl
std::error_code make_error_code(sycl::errc E) noexcept
Constructs an error code using e and sycl_category()
static size_t get_offset(sycl::id< 3 > id, size_t slice, size_t pitch)
StorageInitHelper(StorageInitHelper &&)=default
std::vector< detail::AccessorImplPtr > MAccStorage
Storage for accessors.
std::vector< std::vector< char > > MArgsStorage
Storage for standard layout arguments.
StorageInitHelper()=default
StorageInitHelper(std::vector< std::vector< char >> ArgsStorage, std::vector< detail::AccessorImplPtr > AccStorage, std::vector< std::shared_ptr< const void >> SharedPtrStorage, std::vector< AccessorImplHost * > Requirements, std::vector< detail::EventImplPtr > Events)
std::vector< std::shared_ptr< const void > > MSharedPtrStorage
Storage for shared_ptrs.
std::vector< detail::EventImplPtr > MEvents
List of events that order the execution of this CG.
StorageInitHelper(const StorageInitHelper &)=default
std::vector< AccessorImplHost * > MRequirements
List of requirements that specify which memory is needed for the command group to be executed.
C++ utilities for Unified Runtime integration.