From 5e2791ff354e618689bfd7b4665d0036b59cb8c0 Mon Sep 17 00:00:00 2001 From: John Pennycook Date: Thu, 13 Feb 2025 14:07:09 +0000 Subject: [PATCH 1/2] Add get_allocator() to sampled_image --- adoc/chapters/programming_interface.adoc | 7 +++++++ adoc/headers/sampledImage.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/adoc/chapters/programming_interface.adoc b/adoc/chapters/programming_interface.adoc index 67d9ce8e0..38c14d14e 100644 --- a/adoc/chapters/programming_interface.adoc +++ b/adoc/chapters/programming_interface.adoc @@ -6741,6 +6741,13 @@ size_t byte_size() const noexcept due to padding of elements, rows and slices of the image for efficient access. +a@ +[source] +---- +AllocatorT get_allocator() const +---- + a@ Returns the allocator provided to the image. + a@ [source] ---- diff --git a/adoc/headers/sampledImage.h b/adoc/headers/sampledImage.h index 1ce494fb8..f466427db 100644 --- a/adoc/headers/sampledImage.h +++ b/adoc/headers/sampledImage.h @@ -53,6 +53,8 @@ class sampled_image { size_t size() const noexcept; + AllocatorT get_allocator() const; + template sampled_image_accessor get_access(handler& commandGroupHandler, const property_list& propList = {}); From 7d8745ed0e4440fd5d5565373a1ea03137d18f10 Mon Sep 17 00:00:00 2001 From: John Pennycook Date: Thu, 13 Feb 2025 14:34:00 +0000 Subject: [PATCH 2/2] Add sampled_image constructors with AllocatorT --- adoc/chapters/programming_interface.adoc | 142 +++++++++++++++++++++++ adoc/headers/sampledImage.h | 20 ++++ 2 files changed, 162 insertions(+) diff --git a/adoc/chapters/programming_interface.adoc b/adoc/chapters/programming_interface.adoc index 38c14d14e..8aa4c1416 100644 --- a/adoc/chapters/programming_interface.adoc +++ b/adoc/chapters/programming_interface.adoc @@ -6591,6 +6591,36 @@ sampled_image(const void* hostPointer, image_format format, [code]#sampled_image# via an instance of [code]#property_list#. +a@ +[source] +---- +sampled_image(const void* hostPointer, image_format format, + image_sampler sampler, + const range& rangeRef, + AllocatorT allocator, + const property_list& propList = {}) +---- + a@ Construct a SYCL [code]#sampled_image# instance with the + [code]#hostPointer# parameter provided. The [code]#sampled_image# + assumes exclusive access to this memory for the duration of its lifetime. + The host address is [code]#const#, so the host accesses must be + read-only. Since, the [code]#hostPointer# is [code]#const#, this image is only + initialized with this memory and there is no write after its + destruction. + The constructed SYCL [code]#sampled_image# will use the allocator + parameter provided when allocating memory on the host. + The element size of the constructed SYCL [code]#sampled_image# + will be derived from the [code]#format# parameter. + Accessors that read the constructed SYCL [code]#sampled_image# will + use the [code]#sampler# parameter to sample the image. + The range of the constructed SYCL [code]#sampled_image# is + specified by the [code]#rangeRef# parameter provided. + The pitch of the constructed SYCL [code]#sampled_image# will be + the default size determined by the <>. + Zero or more properties can be provided to the constructed SYCL + [code]#sampled_image# via an instance of + [code]#property_list#. + a@ [source] ---- @@ -6621,6 +6651,75 @@ Zero or more properties can be provided to the constructed SYCL [code]#sampled_image# via an instance of [code]#property_list#. +a@ +[source] +---- +sampled_image(const void* hostPointer, image_format format, + image_sampler sampler, + const range& rangeRef, + const range& pitch, + AllocatorT allocator, + const property_list& propList = {}) +---- + a@ Available only when: [code]#Dimensions > 1#. + +Construct a SYCL [code]#sampled_image# instance with the [code]#hostPointer# +parameter provided. The [code]#sampled_image# assumes exclusive access to this +memory for the duration of its lifetime. +The host address is [code]#const#, so the host accesses must be +read-only. Since, the [code]#hostPointer# is [code]#const#, this +image is only initialized with this memory and there is no write after +destruction. +The constructed SYCL [code]#sampled_image# will use the allocator +parameter provided when allocating memory on the host. +The element size of the constructed SYCL [code]#sampled_image# +will be derived from the [code]#format# parameter. +Accessors that read the constructed SYCL [code]#sampled_image# will +use the [code]#sampler# parameter to sample the image. +The range of the constructed SYCL [code]#sampled_image# is +specified by the [code]#rangeRef# parameter provided. +The pitch of the constructed SYCL [code]#sampled_image# will be +the [code]#pitch# parameter provided. +Zero or more properties can be provided to the constructed SYCL +[code]#sampled_image# via an instance of +[code]#property_list#. + +a@ +[source] +---- +sampled_image(std::shared_ptr& hostPointer, + image_format format, + image_sampler sampler, + const range& rangeRef, + const property_list& propList = {}) +---- + a@ When [code]#hostPointer# is not empty, construct a SYCL + [code]#sampled_image# with the contents of its stored pointer. The + [code]#sampled_image# assumes exclusive access to this memory for the + duration of its lifetime. The [code]#sampled_image# also creates its + own internal copy of the [code]#shared_ptr# that shares ownership of the + [code]#hostData# memory, which means the application can safely release + ownership of this [code]#shared_ptr# when the constructor returns. + +When [code]#hostPointer# is empty, construct a SYCL [code]#sampled_image# +with uninitialized memory. + +The host address is [code]#const#, so the host accesses must be +read-only. Since, the [code]#hostPointer# is [code]#const#, this image is only +initialized with this memory and there is no write after its +destruction. +The element size of the constructed SYCL [code]#sampled_image# +will be derived from the [code]#format# parameter. +Accessors that read the constructed SYCL [code]#sampled_image# will +use the [code]#sampler# parameter to sample the image. +The range of the constructed SYCL [code]#sampled_image# is +specified by the [code]#rangeRef# parameter provided. +The pitch of the constructed SYCL [code]#sampled_image# will be +the default size determined by the <>. +Zero or more properties can be provided to the constructed SYCL +[code]#sampled_image# via an instance of +[code]#property_list#. + a@ [source] ---- @@ -6628,6 +6727,7 @@ sampled_image(std::shared_ptr& hostPointer, image_format format, image_sampler sampler, const range& rangeRef, + AllocatorT allocator, const property_list& propList = {}) ---- a@ When [code]#hostPointer# is not empty, construct a SYCL @@ -6645,6 +6745,8 @@ The host address is [code]#const#, so the host accesses must be read-only. Since, the [code]#hostPointer# is [code]#const#, this image is only initialized with this memory and there is no write after its destruction. +The constructed SYCL [code]#sampled_image# will use the allocator +parameter provided when allocating memory on the host. The element size of the constructed SYCL [code]#sampled_image# will be derived from the [code]#format# parameter. Accessors that read the constructed SYCL [code]#sampled_image# will @@ -6694,6 +6796,46 @@ Zero or more properties can be provided to the constructed SYCL [code]#sampled_image# via an instance of [code]#property_list#. +a@ +[source] +---- +sampled_image(std::shared_ptr& hostPointer, + image_format format, + image_sampler sampler, + const range& rangeRef, + const range& pitch, + AllocatorT allocator, + const property_list& propList = {}) +---- + a@ When [code]#hostPointer# is not empty, construct a SYCL + [code]#sampled_image# with the contents of its stored pointer. The + [code]#sampled_image# assumes exclusive access to this memory for the + duration of its lifetime. The [code]#sampled_image# also creates its + own internal copy of the [code]#shared_ptr# that shares ownership of the + [code]#hostData# memory, which means the application can safely release + ownership of this [code]#shared_ptr# when the constructor returns. + +When [code]#hostPointer# is empty, construct a SYCL [code]#sampled_image# +with uninitialized memory. + +The host address is [code]#const#, so the host accesses can be +read-only. Since, the [code]#hostPointer# is [code]#const#, this image is only +initialized with this memory and there is no write after its +destruction. +The constructed SYCL [code]#sampled_image# will use the allocator +parameter provided when allocating memory on the host. +The element size of the constructed SYCL [code]#sampled_image# +will be derived from the [code]#format# parameter. +Accessors that read the constructed SYCL [code]#sampled_image# will +use the [code]#sampler# parameter to sample the image. +The range of the constructed SYCL [code]#sampled_image# is +specified by the [code]#rangeRef# parameter provided. +The pitch of the constructed SYCL [code]#sampled_image# will be +the [code]#pitch# parameter provided. +Zero or more properties can be provided to the constructed SYCL +[code]#sampled_image# via an instance of +[code]#property_list#. + |==== diff --git a/adoc/headers/sampledImage.h b/adoc/headers/sampledImage.h index f466427db..3d9d12974 100644 --- a/adoc/headers/sampledImage.h +++ b/adoc/headers/sampledImage.h @@ -24,22 +24,42 @@ class sampled_image { image_sampler sampler, const range& rangeRef, const property_list& propList = {}); + sampled_image(const void* hostPointer, image_format format, + image_sampler sampler, const range& rangeRef, + AllocatorT allocator, const property_list& propList = {}); + /* Available only when: Dimensions > 1 */ sampled_image(const void* hostPointer, image_format format, image_sampler sampler, const range& rangeRef, const range& pitch, const property_list& propList = {}); + /* Available only when: Dimensions > 1 */ + sampled_image(const void* hostPointer, image_format format, + image_sampler sampler, const range& rangeRef, + const range& pitch, AllocatorT allocator, + const property_list& propList = {}); + sampled_image(std::shared_ptr& hostPointer, image_format format, image_sampler sampler, const range& rangeRef, const property_list& propList = {}); + sampled_image(std::shared_ptr& hostPointer, image_format format, + image_sampler sampler, const range& rangeRef, + AllocatorT allocator, const property_list& propList = {}); + /* Available only when: Dimensions > 1 */ sampled_image(std::shared_ptr& hostPointer, image_format format, image_sampler sampler, const range& rangeRef, const range& pitch, const property_list& propList = {}); + /* Available only when: Dimensions > 1 */ + sampled_image(std::shared_ptr& hostPointer, image_format format, + image_sampler sampler, const range& rangeRef, + const range& pitch, + AllocatorT allocator, const property_list& propList = {}); + /* -- common interface members -- */ /* -- property interface members -- */