Skip to content

Commit

Permalink
add support for semaphore-specific device handle list enums (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
bashbaug authored Oct 11, 2023
1 parent a89239b commit efeae73
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion layers/10_cmdbufemu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ It works by intercepting calls to `clGetExtensionFunctionAddressForPlatform` to
If a query succeeds by default then the layer does nothing and simply returns the queried function pointer as-is.
If the query is unsuccessful however, then the layer returns its own function pointer, which will record the contents of the command buffer for later playback.

This command buffer emulation layer currently implements v0.9.0 of the `cl_khr_command_buffer` extension and v0.9.0 of the `cl_khr_command_buffer_mutable_dispatch` extension.
This command buffer emulation layer currently implements v0.9.4 of the `cl_khr_command_buffer` extension and v0.9.0 of the `cl_khr_command_buffer_mutable_dispatch` extension.
The functionality in this emulation layer is sufficient to run the command buffer samples in this repository.

Please note that the emulated command buffers are intended to be functional, but unlike a native implementation, they may not provide any performance benefit over similar code without using command buffers.
Expand Down
2 changes: 1 addition & 1 deletion layers/11_semaemu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ It works by intercepting calls to `clGetExtensionFunctionAddressForPlatform` to
If a query succeeds by default then the layer does nothing and simply returns the queried function pointer as-is.
If the query is unsuccessful however, then the layer returns its own function pointer, which will emulate semaphores using events.

This semaphore emulation layer currently implements v0.9.0 of the `cl_khr_semaphore` extension.
This semaphore emulation layer currently implements v0.9.1 of the `cl_khr_semaphore` extension.
The functionality in this emulation layer is sufficient to run the semaphore samples in this repository.

Please note that the emulated semaphores are intended to be functional, but unlike a native implementation, they may not provide any performance benefit over similar code without using semaphores.
Expand Down
16 changes: 10 additions & 6 deletions layers/11_semaemu/emulate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@
#ifndef CL_KHR_SEMAPHORE_EXTENSION_NAME
#define CL_KHR_SEMAPHORE_EXTENSION_NAME "cl_khr_semaphore"
#endif
#ifndef CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR
#define CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR 0x2053
#define CL_SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR 0
#endif

static constexpr cl_version version_cl_khr_semaphore =
CL_MAKE_VERSION(0, 9, 0);
CL_MAKE_VERSION(0, 9, 1);

SLayerContext& getLayerContext(void)
{
Expand All @@ -48,7 +52,7 @@ typedef struct _cl_semaphore_khr
{
const cl_semaphore_properties_khr* check = properties;
bool found_CL_SEMAPHORE_TYPE_KHR = false;
bool found_CL_DEVICE_HANDLE_LIST_KHR = false;
bool found_CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR = false;
while( errorCode == CL_SUCCESS && check[0] != 0 )
{
cl_int property = (cl_int)check[0];
Expand All @@ -66,16 +70,16 @@ typedef struct _cl_semaphore_khr
check += 2;
}
break;
case CL_DEVICE_HANDLE_LIST_KHR:
if( found_CL_DEVICE_HANDLE_LIST_KHR )
case CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR:
if( found_CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR )
{
errorCode = CL_INVALID_VALUE;
}
else
{
found_CL_DEVICE_HANDLE_LIST_KHR = true;
found_CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR = true;
++check;
while(*check++ != CL_DEVICE_HANDLE_LIST_END_KHR)
while(*check++ != CL_SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR)
{
// TODO: validate device handles.
}
Expand Down

0 comments on commit efeae73

Please sign in to comment.