Skip to content

Commit b1aab04

Browse files
przemektmalonisaacaulthjabirdDBDuncancppchedy
authored
[SYCL][Bindless][3/4] Add experimental implementation of SYCL bindless images extension (#10454)
This commit stands as the third commit of four to make code review easier, mostly covering the changes made to the user-facing SYCL API for the [bindless images extension proposal](#9842). ### Overview The bindless images extension provides a new interface for allocating, creating, and accessing images in SYCL. Image memory allocation is seperated from image handle creation, and image handles can be passed to kernels without requesting access through accessors. This approach provides much more flexibility to the user, as well as enabling programs to implement features that were impossible to implement using standard SYCL images, such as a texture atlas. In addition to providing a new interface for images, this extension also provides initial experimental support for importing external memory into SYCL. ### Following Split PRs - [4/4] Add tests ### Authors Co-authored-by: Isaac Ault <[email protected]> Co-authored-by: Hugh Bird <[email protected]> Co-authored-by: Duncan Brawley <[email protected]> Co-authored-by: Przemek Malon <[email protected]> Co-authored-by: Chedy Najjar <[email protected]> Co-authored-by: Sean Stirling <[email protected]> Co-authored-by: Peter Zuzek <[email protected]>
1 parent 7c6541d commit b1aab04

26 files changed

+3561
-1
lines changed

llvm/include/llvm/SYCLLowerIR/DeviceConfigFile.td

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@ def AspectExt_intel_memory_clock_rate : Aspect<"ext_intel_memory_clock_rate">;
5050
def AspectExt_intel_memory_bus_width : Aspect<"ext_intel_memory_bus_width">;
5151
def AspectEmulated : Aspect<"emulated">;
5252
def AspectExt_intel_legacy_image : Aspect<"ext_intel_legacy_image">;
53+
def AspectExt_oneapi_bindless_images : Aspect<"ext_oneapi_bindless_images">;
54+
def AspectExt_oneapi_bindless_images_shared_usm : Aspect<"ext_oneapi_bindless_images_shared_usm">;
55+
def AspectExt_oneapi_bindless_images_1d_usm : Aspect<"ext_oneapi_bindless_images_1d_usm">;
56+
def AspectExt_oneapi_bindless_images_2d_usm : Aspect<"ext_oneapi_bindless_images_2d_usm">;
57+
def AspectExt_oneapi_interop_memory_import : Aspect<"ext_oneapi_interop_memory_import">;
58+
def AspectExt_oneapi_interop_memory_export : Aspect<"ext_oneapi_interop_memory_export">;
59+
def AspectExt_oneapi_interop_semaphore_import : Aspect<"ext_oneapi_interop_semaphore_import">;
60+
def AspectExt_oneapi_interop_semaphore_export : Aspect<"ext_oneapi_interop_semaphore_export">;
61+
def AspectExt_oneapi_mipmap : Aspect<"ext_oneapi_mipmap">;
62+
def AspectExt_oneapi_mipmap_anisotropy : Aspect<"ext_oneapi_mipmap_anisotropy">;
63+
def AspectExt_oneapi_mipmap_level_reference : Aspect<"ext_oneapi_mipmap_level_reference">;
5364
// Deprecated aspects
5465
def AspectInt64_base_atomics : Aspect<"int64_base_atomics">;
5566
def AspectInt64_extended_atomics : Aspect<"int64_extended_atomics">;
@@ -94,7 +105,11 @@ def : TargetInfo<"__TestAspectList",
94105
AspectExt_oneapi_native_assert, AspectHost_debuggable, AspectExt_intel_gpu_hw_threads_per_eu,
95106
AspectExt_oneapi_cuda_async_barrier, AspectExt_oneapi_bfloat16_math_functions, AspectExt_intel_free_memory,
96107
AspectExt_intel_device_id, AspectExt_intel_memory_clock_rate, AspectExt_intel_memory_bus_width, AspectEmulated,
97-
AspectExt_intel_legacy_image],
108+
AspectExt_intel_legacy_image, AspectExt_oneapi_bindless_images,
109+
AspectExt_oneapi_bindless_images_shared_usm, AspectExt_oneapi_bindless_images_1d_usm, AspectExt_oneapi_bindless_images_2d_usm,
110+
AspectExt_oneapi_interop_memory_import, AspectExt_oneapi_interop_memory_export,
111+
AspectExt_oneapi_interop_semaphore_import, AspectExt_oneapi_interop_semaphore_export,
112+
AspectExt_oneapi_mipmap, AspectExt_oneapi_mipmap_anisotropy, AspectExt_oneapi_mipmap_level_reference],
98113
[]>;
99114
// This definition serves the only purpose of testing whether the deprecated aspect list defined in here and in SYCL RT
100115
// match.

sycl/include/sycl/detail/cg.hpp

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ class CG {
7373
CopyFromDeviceGlobal = 20,
7474
ReadWriteHostPipe = 21,
7575
ExecCommandBuffer = 22,
76+
CopyImage = 23,
77+
SemaphoreWait = 24,
78+
SemaphoreSignal = 25,
7679
};
7780

7881
struct StorageInitHelper {
@@ -496,6 +499,77 @@ class CGCopyFromDeviceGlobal : public CG {
496499
size_t getNumBytes() { return MNumBytes; }
497500
size_t getOffset() { return MOffset; }
498501
};
502+
/// "Copy Image" command group class.
503+
class CGCopyImage : public CG {
504+
void *MSrc;
505+
void *MDst;
506+
sycl::detail::pi::PiMemImageDesc MImageDesc;
507+
sycl::detail::pi::PiMemImageFormat MImageFormat;
508+
sycl::detail::pi::PiImageCopyFlags MImageCopyFlags;
509+
sycl::detail::pi::PiImageOffset MSrcOffset;
510+
sycl::detail::pi::PiImageOffset MDstOffset;
511+
sycl::detail::pi::PiImageRegion MHostExtent;
512+
sycl::detail::pi::PiImageRegion MCopyExtent;
513+
514+
public:
515+
CGCopyImage(void *Src, void *Dst, sycl::detail::pi::PiMemImageDesc ImageDesc,
516+
sycl::detail::pi::PiMemImageFormat ImageFormat,
517+
sycl::detail::pi::PiImageCopyFlags ImageCopyFlags,
518+
sycl::detail::pi::PiImageOffset SrcOffset,
519+
sycl::detail::pi::PiImageOffset DstOffset,
520+
sycl::detail::pi::PiImageRegion HostExtent,
521+
sycl::detail::pi::PiImageRegion CopyExtent,
522+
CG::StorageInitHelper CGData, detail::code_location loc = {})
523+
: CG(CopyImage, std::move(CGData), std::move(loc)), MSrc(Src), MDst(Dst),
524+
MImageDesc(ImageDesc), MImageFormat(ImageFormat),
525+
MImageCopyFlags(ImageCopyFlags), MSrcOffset(SrcOffset),
526+
MDstOffset(DstOffset), MHostExtent(HostExtent),
527+
MCopyExtent(CopyExtent) {}
528+
529+
void *getSrc() const { return MSrc; }
530+
void *getDst() const { return MDst; }
531+
sycl::detail::pi::PiMemImageDesc getDesc() const { return MImageDesc; }
532+
sycl::detail::pi::PiMemImageFormat getFormat() const { return MImageFormat; }
533+
sycl::detail::pi::PiImageCopyFlags getCopyFlags() const {
534+
return MImageCopyFlags;
535+
}
536+
sycl::detail::pi::PiImageOffset getSrcOffset() const { return MSrcOffset; }
537+
sycl::detail::pi::PiImageOffset getDstOffset() const { return MDstOffset; }
538+
sycl::detail::pi::PiImageRegion getHostExtent() const { return MHostExtent; }
539+
sycl::detail::pi::PiImageRegion getCopyExtent() const { return MCopyExtent; }
540+
};
541+
542+
/// "Semaphore Wait" command group class.
543+
class CGSemaphoreWait : public CG {
544+
sycl::detail::pi::PiInteropSemaphoreHandle MInteropSemaphoreHandle;
545+
546+
public:
547+
CGSemaphoreWait(
548+
sycl::detail::pi::PiInteropSemaphoreHandle InteropSemaphoreHandle,
549+
CG::StorageInitHelper CGData, detail::code_location loc = {})
550+
: CG(SemaphoreWait, std::move(CGData), std::move(loc)),
551+
MInteropSemaphoreHandle(InteropSemaphoreHandle) {}
552+
553+
sycl::detail::pi::PiInteropSemaphoreHandle getInteropSemaphoreHandle() const {
554+
return MInteropSemaphoreHandle;
555+
}
556+
};
557+
558+
/// "Semaphore Signal" command group class.
559+
class CGSemaphoreSignal : public CG {
560+
sycl::detail::pi::PiInteropSemaphoreHandle MInteropSemaphoreHandle;
561+
562+
public:
563+
CGSemaphoreSignal(
564+
sycl::detail::pi::PiInteropSemaphoreHandle InteropSemaphoreHandle,
565+
CG::StorageInitHelper CGData, detail::code_location loc = {})
566+
: CG(SemaphoreSignal, std::move(CGData), std::move(loc)),
567+
MInteropSemaphoreHandle(InteropSemaphoreHandle) {}
568+
569+
sycl::detail::pi::PiInteropSemaphoreHandle getInteropSemaphoreHandle() const {
570+
return MInteropSemaphoreHandle;
571+
}
572+
};
499573

500574
/// "Execute command-buffer" command group class.
501575
class CGExecCommandBuffer : public CG {

sycl/include/sycl/device_aspect_macros.hpp

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,61 @@
218218
#define __SYCL_ALL_DEVICES_HAVE_ext_intel_legacy_image__ 0
219219
#endif
220220

221+
#ifndef __SYCL_ALL_DEVICES_HAVE_ext_oneapi_bindless_images__
222+
// __SYCL_ASPECT(ext_oneapi_bindless_images, 42)
223+
#define __SYCL_ALL_DEVICES_HAVE_ext_oneapi_bindless_images__ 0
224+
#endif
225+
226+
#ifndef __SYCL_ALL_DEVICES_HAVE_ext_oneapi_bindless_images_shared_usm__
227+
//__SYCL_ASPECT(ext_oneapi_bindless_images_shared_usm, 43)
228+
#define __SYCL_ALL_DEVICES_HAVE_ext_oneapi_bindless_images_shared_usm__ 0
229+
#endif
230+
231+
#ifndef __SYCL_ALL_DEVICES_HAVE_ext_oneapi_bindless_images_1d_usm__
232+
//__SYCL_ASPECT(ext_oneapi_bindless_images_1d_usm, 44)
233+
#define __SYCL_ALL_DEVICES_HAVE_ext_oneapi_bindless_images_1d_usm__ 0
234+
#endif
235+
236+
#ifndef __SYCL_ALL_DEVICES_HAVE_ext_oneapi_bindless_images_2d_usm__
237+
//__SYCL_ASPECT(ext_oneapi_bindless_images_2d_usm, 45)
238+
#define __SYCL_ALL_DEVICES_HAVE_ext_oneapi_bindless_images_2d_usm__ 0
239+
#endif
240+
241+
#ifndef __SYCL_ALL_DEVICES_HAVE_ext_oneapi_interop_memory_import__
242+
//__SYCL_ASPECT(ext_oneapi_interop_memory_import, 46)
243+
#define __SYCL_ALL_DEVICES_HAVE_ext_oneapi_interop_memory_import__ 0
244+
#endif
245+
246+
#ifndef __SYCL_ALL_DEVICES_HAVE_ext_oneapi_interop_memory_export__
247+
//__SYCL_ASPECT(ext_oneapi_interop_memory_export, 47)
248+
#define __SYCL_ALL_DEVICES_HAVE_ext_oneapi_interop_memory_export__ 0
249+
#endif
250+
251+
#ifndef __SYCL_ALL_DEVICES_HAVE_ext_oneapi_interop_semaphore_import__
252+
//__SYCL_ASPECT(ext_oneapi_interop_semaphore_import, 48)
253+
#define __SYCL_ALL_DEVICES_HAVE_ext_oneapi_interop_semaphore_import__ 0
254+
#endif
255+
256+
#ifndef __SYCL_ALL_DEVICES_HAVE_ext_oneapi_interop_semaphore_export__
257+
//__SYCL_ASPECT(ext_oneapi_interop_semaphore_export, 49)
258+
#define __SYCL_ALL_DEVICES_HAVE_ext_oneapi_interop_semaphore_export__ 0
259+
#endif
260+
261+
#ifndef __SYCL_ALL_DEVICES_HAVE_ext_oneapi_mipmap__
262+
//__SYCL_ASPECT(ext_oneapi_mipmap, 50)
263+
#define __SYCL_ALL_DEVICES_HAVE_ext_oneapi_mipmap__ 0
264+
#endif
265+
266+
#ifndef __SYCL_ALL_DEVICES_HAVE_ext_oneapi_mipmap_anisotropy__
267+
//__SYCL_ASPECT(ext_oneapi_mipmap_anisotropy, 51)
268+
#define __SYCL_ALL_DEVICES_HAVE_ext_oneapi_mipmap_anisotropy__ 0
269+
#endif
270+
271+
#ifndef __SYCL_ALL_DEVICES_HAVE_ext_oneapi_mipmap_level_reference__
272+
//__SYCL_ASPECT(ext_oneapi_mipmap_level_reference, 52)
273+
#define __SYCL_ALL_DEVICES_HAVE_ext_oneapi_mipmap_level_reference__ 0
274+
#endif
275+
221276
#ifndef __SYCL_ANY_DEVICE_HAS_host__
222277
// __SYCL_ASPECT(host, 0)
223278
#define __SYCL_ANY_DEVICE_HAS_host__ 0
@@ -427,3 +482,58 @@
427482
// __SYCL_ASPECT(ext_intel_legacy_image, 41)
428483
#define __SYCL_ANY_DEVICE_HAS_ext_intel_legacy_image__ 0
429484
#endif
485+
486+
#ifndef __SYCL_ANY_DEVICE_HAS_ext_oneapi_bindless_images__
487+
// __SYCL_ASPECT(ext_oneapi_bindless_images, 42)
488+
#define __SYCL_ANY_DEVICE_HAS_ext_oneapi_bindless_images__ 0
489+
#endif
490+
491+
#ifndef __SYCL_ANY_DEVICE_HAS_ext_oneapi_bindless_images_shared_usm__
492+
//__SYCL_ASPECT(ext_oneapi_bindless_images_shared_usm, 43)
493+
#define __SYCL_ANY_DEVICE_HAS_ext_oneapi_bindless_images_shared_usm__ 0
494+
#endif
495+
496+
#ifndef __SYCL_ANY_DEVICE_HAS_ext_oneapi_bindless_images_1d_usm__
497+
//__SYCL_ASPECT(ext_oneapi_bindless_images_1d_usm, 44)
498+
#define __SYCL_ANY_DEVICE_HAS_ext_oneapi_bindless_images_1d_usm__ 0
499+
#endif
500+
501+
#ifndef __SYCL_ANY_DEVICE_HAS_ext_oneapi_bindless_images_2d_usm__
502+
//__SYCL_ASPECT(ext_oneapi_bindless_images_2d_usm, 45)
503+
#define __SYCL_ANY_DEVICE_HAS_ext_oneapi_bindless_images_2d_usm__ 0
504+
#endif
505+
506+
#ifndef __SYCL_ANY_DEVICE_HAS_ext_oneapi_interop_memory_import__
507+
//__SYCL_ASPECT(ext_oneapi_interop_memory_import, 46)
508+
#define __SYCL_ANY_DEVICE_HAS_ext_oneapi_interop_memory_import__ 0
509+
#endif
510+
511+
#ifndef __SYCL_ANY_DEVICE_HAS_ext_oneapi_interop_memory_export__
512+
//__SYCL_ASPECT(ext_oneapi_interop_memory_export, 47)
513+
#define __SYCL_ANY_DEVICE_HAS_ext_oneapi_interop_memory_export__ 0
514+
#endif
515+
516+
#ifndef __SYCL_ANY_DEVICE_HAS_ext_oneapi_interop_semaphore_import__
517+
//__SYCL_ASPECT(ext_oneapi_interop_semaphore_import, 48)
518+
#define __SYCL_ANY_DEVICE_HAS_ext_oneapi_interop_semaphore_import__ 0
519+
#endif
520+
521+
#ifndef __SYCL_ANY_DEVICE_HAS_ext_oneapi_interop_semaphore_export__
522+
//__SYCL_ASPECT(ext_oneapi_interop_semaphore_export, 49)
523+
#define __SYCL_ANY_DEVICE_HAS_ext_oneapi_interop_semaphore_export__ 0
524+
#endif
525+
526+
#ifndef __SYCL_ANY_DEVICE_HAS_ext_oneapi_mipmap__
527+
//__SYCL_ASPECT(ext_oneapi_mipmap, 50)
528+
#define __SYCL_ANY_DEVICE_HAS_ext_oneapi_mipmap__ 0
529+
#endif
530+
531+
#ifndef __SYCL_ANY_DEVICE_HAS_ext_oneapi_mipmap_anisotropy__
532+
//__SYCL_ASPECT(ext_oneapi_mipmap_anisotropy, 51)
533+
#define __SYCL_ANY_DEVICE_HAS_ext_oneapi_mipmap_anisotropy__ 0
534+
#endif
535+
536+
#ifndef __SYCL_ANY_DEVICE_HAS_ext_oneapi_mipmap_level_reference__
537+
//__SYCL_ASPECT(ext_oneapi_mipmap_level_reference, 52)
538+
#define __SYCL_ANY_DEVICE_HAS_ext_oneapi_mipmap_level_reference__ 0
539+
#endif

0 commit comments

Comments
 (0)