Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add allocator functions to sampled_image #722

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 149 additions & 0 deletions adoc/chapters/programming_interface.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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<Dimensions>& 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 <<sycl-runtime>>.
Zero or more properties can be provided to the constructed SYCL
[code]#sampled_image# via an instance of
[code]#property_list#.

a@
[source]
----
Expand Down Expand Up @@ -6621,6 +6651,39 @@ 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<Dimensions>& rangeRef,
const range<Dimensions - 1>& 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]
----
Expand Down Expand Up @@ -6657,6 +6720,82 @@ 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<const void>& hostPointer,
image_format format,
image_sampler sampler,
const range<Dimensions>& rangeRef,
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 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 <<sycl-runtime>>.
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<const void>& hostPointer,
image_format format,
image_sampler sampler,
const range<Dimensions>& rangeRef,
const range<Dimensions - 1>& pitch,
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 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]
----
Expand All @@ -6665,6 +6804,7 @@ sampled_image(std::shared_ptr<const void>& hostPointer,
image_sampler sampler,
const range<Dimensions>& rangeRef,
const range<Dimensions - 1>& pitch,
AllocatorT allocator,
const property_list& propList = {})
----
a@ When [code]#hostPointer# is not empty, construct a SYCL
Expand All @@ -6682,6 +6822,8 @@ 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
Expand Down Expand Up @@ -6741,6 +6883,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]
----
Expand Down
22 changes: 22 additions & 0 deletions adoc/headers/sampledImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,42 @@ class sampled_image {
image_sampler sampler, const range<Dimensions>& rangeRef,
const property_list& propList = {});

sampled_image(const void* hostPointer, image_format format,
image_sampler sampler, const range<Dimensions>& 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<Dimensions>& rangeRef,
const range<Dimensions - 1>& pitch,
const property_list& propList = {});

/* Available only when: Dimensions > 1 */
sampled_image(const void* hostPointer, image_format format,
image_sampler sampler, const range<Dimensions>& rangeRef,
const range<Dimensions - 1>& pitch, AllocatorT allocator,
const property_list& propList = {});

sampled_image(std::shared_ptr<const void>& hostPointer, image_format format,
image_sampler sampler, const range<Dimensions>& rangeRef,
const property_list& propList = {});

sampled_image(std::shared_ptr<const void>& hostPointer, image_format format,
image_sampler sampler, const range<Dimensions>& rangeRef,
AllocatorT allocator, const property_list& propList = {});

/* Available only when: Dimensions > 1 */
sampled_image(std::shared_ptr<const void>& hostPointer, image_format format,
image_sampler sampler, const range<Dimensions>& rangeRef,
const range<Dimensions - 1>& pitch,
const property_list& propList = {});

/* Available only when: Dimensions > 1 */
sampled_image(std::shared_ptr<const void>& hostPointer, image_format format,
image_sampler sampler, const range<Dimensions>& rangeRef,
const range<Dimensions - 1>& pitch,
AllocatorT allocator, const property_list& propList = {});

/* -- common interface members -- */

/* -- property interface members -- */
Expand All @@ -53,6 +73,8 @@ class sampled_image {

size_t size() const noexcept;

AllocatorT get_allocator() const;

template <typename DataT, image_target Targ = image_target::device>
sampled_image_accessor<DataT, Dimensions, Targ>
get_access(handler& commandGroupHandler, const property_list& propList = {});
Expand Down