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 mechanism to specify named win32 NT handles. #1004

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 2 additions & 0 deletions ext/cl_khr_external_memory.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ External memory handle types added by `cl_khr_external_memory_win32`:
----
CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR 0x2061
CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KMT_KHR 0x2062
CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_NAME_KHR 0x2069
----

=== Modifications to existing APIs added by this spec
Expand Down Expand Up @@ -395,6 +396,7 @@ The `cl_khr_external_memory_win32` extension extends {cl_external_memory_handle_
--
* {CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR} specifies an NT handle that has only limited valid usage outside of OpenCL and other compatible APIs. It must be compatible with the functions DuplicateHandle, CloseHandle, CompareObjectHandles, GetHandleInformation, and SetHandleInformation. It owns a reference to the underlying memory resource represented by its memory object.
* {CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KMT_KHR} specifies a global share handle that has only limited valid usage outside of OpenCL and other compatible APIs. It is not compatible with any native APIs. It does not own a reference to the underlying memory resource represented by its memory object, and will therefore become invalid when all memory objects associated with it are destroyed.
* {CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_NAME_KHR} specifies an NT handle name that has only limited valid usage outside of OpenCL and other compatible APIs. It must be compatible with the functions DuplicateHandle, CloseHandle, CompareObjectHandles, GetHandleInformation, and SetHandleInformation. It owns a reference to the underlying memory resource represented by its memory object.
Copy link

Choose a reason for hiding this comment

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

Are DuplicateHandle, CloseHandle etc. OpenCL commands?

Copy link
Contributor

Choose a reason for hiding this comment

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

They are Windows API calls.

Choose a reason for hiding this comment

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

We are fine with this PR

--

For these extensions, importing memory object payloads from Windows handles does not transfer ownership of the handle to the OpenCL implementation. For handle types defined as NT handles, the application must release handle ownership using the CloseHandle system call when the handle is no longer needed. For handle types defined as NT handles, the imported memory object holds a reference to its payload.
Expand Down
5 changes: 5 additions & 0 deletions ext/cl_khr_external_semaphore.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ External semaphore handle types added by `cl_khr_external_semaphore_win32`:
----
CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KHR 0x2056
CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KMT_KHR 0x2057
CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_NAME_KHR 0x2068
----

=== Modifications to existing APIs added by this spec
Expand Down Expand Up @@ -404,6 +405,7 @@ The `cl_khr_external_semaphore_win32` extension extends {cl_external_semaphore_h
--
* {CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KHR} specifies an NT handle that has only limited valid usage outside of OpenCL and other compatible APIs. It must be compatible with the functions DuplicateHandle, CloseHandle, CompareObjectHandles, GetHandleInformation, and SetHandleInformation. It owns a reference to the underlying synchronization primitive represented by its semaphore object.
* {CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KMT_KHR} specifies a global share handle that has only limited valid usage outside of OpenCL and other compatible APIs. It is not compatible with any native APIs. It does not own a reference to the underlying synchronization primitive represented by its semaphore object, and will therefore become invalid when all semaphore objects associated with it are destroyed.
* {CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_NAME_KHR} specifies an NT handle name that has only limited valid usage outside of OpenCL and other compatible APIs. It must be compatible with the functions DuplicateHandle, CloseHandle, CompareObjectHandles, GetHandleInformation, and SetHandleInformation. It owns a reference to the underlying synchronization primitive represented by its semaphore object.
--

Transference and permanence properties for handle types added by `cl_khr_external_semaphore_win32`:
Expand All @@ -418,6 +420,9 @@ Transference and permanence properties for handle types added by `cl_khr_externa
| {CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KMT_KHR}
| Reference
| Temporary, Permanent
| {CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_NAME_KHR}
| Reference
| Temporary, Permanent
|====

For these extensions, importing a semaphore payload from Windows handles does not transfer ownership of the handle to the OpenCL implementation. For handle types defined as NT handles, the application must release ownership using the CloseHandle system call when the handle is no longer needed.
Expand Down
4 changes: 3 additions & 1 deletion xml/cl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1862,7 +1862,9 @@ server's OpenCL/api-docs repository.
<enum value="0x2065" name="CL_EXTERNAL_MEMORY_HANDLE_D3D12_HEAP_KHR"/>
<enum value="0x2066" name="CL_EXTERNAL_MEMORY_HANDLE_D3D12_RESOURCE_KHR"/>
<enum value="0x2067" name="CL_EXTERNAL_MEMORY_HANDLE_DMA_BUF_KHR"/>
<unused start="0x2068" end="0x2FFF" comment="Reserved to Khronos for interop"/>
<enum value="0x2068" name="CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_NAME_KHR"/>
<enum value="0x2069" name="CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_NAME_KHR"/>
<unused start="0x206A" end="0x2FFF" comment="Reserved to Khronos for interop"/>
</enums>

<enums start="0x3000" end="0x3FFF" name="enums.3000" vendor="Khronos" comment="Platform IDs. Allocate individually.">
Expand Down