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

Clarify Acquire/Release behavior for external memory #1176

Merged
merged 4 commits into from
Jul 16, 2024
Merged
Changes from 1 commit
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
34 changes: 34 additions & 0 deletions api/opencl_runtime_layer.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -5427,6 +5427,23 @@ handle is used by an OpenCL command queued to a command-queue without being
acquired.
This is to guarantee that the state of the memory objects is up-to-date and
they are accessible to OpenCL.

The following restrictions shall apply -
* Each memory object must be acquired only once. Acquiring memory object
kpet marked this conversation as resolved.
Show resolved Hide resolved
multiple times without releasing it may result in implementation defined
kpet marked this conversation as resolved.
Show resolved Hide resolved
behavior.
* The acquire must be performed on a command-queue associated with a device
that was one of the devices specified via {CL_MEM_DEVICE_HANDLE_LIST_KHR}
when the memory object was imported using {clCreateBufferWithProperties} or
{clCreateImageWithProperties}. If {CL_MEM_DEVICE_HANDLE_LIST_KHR} was not
specified, the acquire can be performed on a command-queue associated with
any device in the context.
* The memory object will be acquired on all devices specified
kpet marked this conversation as resolved.
Show resolved Hide resolved
via {CL_MEM_DEVICE_HANDLE_LIST_KHR} when the memory object was imported
using {clCreateBufferWithProperties} or {clCreateImageWithProperties}.
If {CL_MEM_DEVICE_HANDLE_LIST_KHR} was not specified, the memory objects
kpet marked this conversation as resolved.
Show resolved Hide resolved
will be aquired on all devices in the context.
kpet marked this conversation as resolved.
Show resolved Hide resolved

See <<cl_khr_external_memory-Sample-Code, "`Example with Acquire /
Release`">> for more details on how to use this API.

Expand Down Expand Up @@ -5503,6 +5520,23 @@ Applications must release the memory objects that are acquired using
commands in the other API.
This is to guarantee that the state of memory objects is up-to-date and they
are accessible to the other API.

The following restrictions shall apply -
* Each memory object must be released only once. Releasing memory object
multiple times without acquiring it may result in implementation defined
behavior.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strictly speaking this is ambiguous (and so is the mirror statement above for acquire operations). There might be a better formulation, possibly describing this in terms of number of acquire/release operations but the current text is a clear step forward so fine if you want to merge it as is.

* The release must be performed on a command-queue associated with a device
that was one of the devices specified via {CL_MEM_DEVICE_HANDLE_LIST_KHR}
when the memory object was imported using {clCreateBufferWithProperties} or
{clCreateImageWithProperties}. If {CL_MEM_DEVICE_HANDLE_LIST_KHR} was not
specified, the acquire can be performed on a command-queue associated with
Copy link

@bcalidas bcalidas May 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The release can be performed on a command queue ...

any device in the context.
* The memory object will be released on all devices specified via
{CL_MEM_DEVICE_HANDLE_LIST_KHR} when the memory object was imported
using {clCreateBufferWithProperties} or {clCreateImageWithProperties}.
If {CL_MEM_DEVICE_HANDLE_LIST_KHR} was not specified, the memory object
will be released on all devices in the context.

kpet marked this conversation as resolved.
Show resolved Hide resolved
See "`Example with Acquire / Release`" provided in
<<cl_khr_external_memory-Sample-Code>> for more details on how to use this
API.
Expand Down