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

cl_khr_icd 2.0.0 loader managed dispatch #227

Open
wants to merge 3 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
16 changes: 14 additions & 2 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,29 @@ jobs:
if /I "${{matrix.BIN}}"=="x64" set REG=reg
if /I "${{matrix.BIN}}"=="x86" set REG=%systemroot%\Syswow64\reg.exe
%REG% ADD HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\OpenCL\Vendors /v %GITHUB_WORKSPACE%/build/Release/OpenCLDriverStub.dll /t REG_DWORD /d 0
%CTEST_EXE% -C Release --output-on-failure --parallel %NUMBER_OF_PROCESSORS%
%CTEST_EXE% -C Release --output-on-failure --parallel %NUMBER_OF_PROCESSORS% -R opencl_icd_loader_test^|cllayerinfo_test
if errorlevel 1 (
exit /b %errorlevel%
)
%REG% DELETE HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\OpenCL\Vendors /v %GITHUB_WORKSPACE%/build/Release/OpenCLDriverStub.dll /f
%REG% ADD HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\OpenCL\Vendors /v %GITHUB_WORKSPACE%/build/Release/OpenCLDriverStubICD2.dll /t REG_DWORD /d 0
%CTEST_EXE% -C Release --output-on-failure --parallel %NUMBER_OF_PROCESSORS% -R opencl_icd_loader_icd2_test^|opencl_icd_loader_icd2_instance_test
if errorlevel 1 (
exit /b %errorlevel%
)
%REG% DELETE HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\OpenCL\Vendors /v %GITHUB_WORKSPACE%/build/Release/OpenCLDriverStubICD2.dll /f
%REG% ADD HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\OpenCL\Vendors /v %GITHUB_WORKSPACE%/build/Debug/OpenCLDriverStub.dll /t REG_DWORD /d 0
%CTEST_EXE% -C Debug --output-on-failure --parallel %NUMBER_OF_PROCESSORS%
%CTEST_EXE% -C Debug --output-on-failure --parallel %NUMBER_OF_PROCESSORS% -R opencl_icd_loader_test^|cllayerinfo_test
if errorlevel 1 (
exit /b %errorlevel%
)
%REG% DELETE HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\OpenCL\Vendors /v %GITHUB_WORKSPACE%/build/Debug/OpenCLDriverStub.dll /f
%REG% ADD HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\OpenCL\Vendors /v %GITHUB_WORKSPACE%/build/Debug/OpenCLDriverStubICD2.dll /t REG_DWORD /d 0
%CTEST_EXE% -C Debug --output-on-failure --parallel %NUMBER_OF_PROCESSORS% -R opencl_icd_loader_icd2_test^|opencl_icd_loader_icd2_instance_test
if errorlevel 1 (
exit /b %errorlevel%
)
%REG% DELETE HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\OpenCL\Vendors /v %GITHUB_WORKSPACE%/build/Debug/OpenCLDriverStubICD2.dll /f

- name: Install
shell: cmd
Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ endif()
# It is currently needed default while the specification is being formalized,
# and to study the performance impact.
option (ENABLE_OPENCL_LAYERS "Enable OpenCL Layers" ON)
option (ENABLE_OPENCL_LOADER_MANAGED_DISPATCH "Enable OpenCL Loader managed dispatch" ON)
include(CMakeDependentOption)
cmake_dependent_option(ENABLE_OPENCL_LAYERINFO "Enable building cllayerinfo tool" ON ENABLE_OPENCL_LAYERS OFF)

Expand All @@ -65,6 +66,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/loader/icd_cmake_config.h.in
${CMAKE_CURRENT_BINARY_DIR}/icd_cmake_config.h)

set (OPENCL_ICD_LOADER_SOURCES
include/cl_khr_icd2.h
loader/icd.c
loader/icd.h
loader/icd_version.h
Expand All @@ -73,6 +75,7 @@ set (OPENCL_ICD_LOADER_SOURCES
loader/icd_dispatch_generated.c
loader/icd_envvars.h
loader/icd_platform.h)
include_directories (include)

if (WIN32)
list (APPEND OPENCL_ICD_LOADER_SOURCES
Expand Down Expand Up @@ -158,6 +161,7 @@ set (OPENCL_COMPILE_DEFINITIONS
OPENCL_ICD_LOADER_VERSION_MINOR=0
OPENCL_ICD_LOADER_VERSION_REV=6
$<$<BOOL:${ENABLE_OPENCL_LAYERS}>:CL_ENABLE_LAYERS>
$<$<BOOL:${ENABLE_OPENCL_LOADER_MANAGED_DISPATCH}>:CL_ENABLE_LOADER_MANAGED_DISPATCH>
)

target_compile_definitions (OpenCL
Expand Down
86 changes: 86 additions & 0 deletions include/cl_khr_icd2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#if !defined(CL_PLATFORM_UNLOADABLE)
#define CL_PLATFORM_UNLOADABLE_KHR 0x0921
#endif

#if defined(CL_ENABLE_LAYERS) && !defined(CL_LAYER_API_VERSION_200)
#define CL_LAYER_API_VERSION_200 200

typedef cl_int CL_API_CALL
clDeinitLayer_t(void);

typedef clDeinitLayer_t *pfn_clDeinitLayer;
#endif //defined(CL_ENABLE_LAYERS) && !defined(CL_LAYER_API_VERSION_200)

#if !defined(CL_ICD2_TAG_KHR)
#if INTPTR_MAX == INT32_MAX
#define CL_ICD2_TAG_KHR ((intptr_t)0x434C3331)
#else
#define CL_ICD2_TAG_KHR ((intptr_t)0x4F50454E434C3331)
#endif

typedef void * CL_API_CALL
clIcdGetFunctionAddressForPlatformKHR_t(
cl_platform_id platform,
const char* func_name);

typedef clIcdGetFunctionAddressForPlatformKHR_t *
clIcdGetFunctionAddressForPlatformKHR_fn;

typedef cl_int CL_API_CALL
clIcdSetPlatformDispatchDataKHR_t(
cl_platform_id platform,
void *disp_data);

typedef clIcdSetPlatformDispatchDataKHR_t *
clIcdSetPlatformDispatchDataKHR_fn;
#endif // !defined(CL_ICD2_TAG_KHR)

#if !defined(CL_INVALID_INSTANCE_KHR)
#define CL_INVALID_INSTANCE_KHR -1154

#define CL_INSTANCE_PROPERTIES_LIST_END_KHR 0

typedef struct _cl_instance_khr *cl_instance_khr;
typedef intptr_t cl_instance_properties_khr;

typedef cl_instance_khr CL_API_CALL
clCreateInstanceKHR_t(
const cl_instance_properties_khr *properties,
cl_int *errcode_ret);

typedef clCreateInstanceKHR_t *
clCreateInstanceKHR_fn;

typedef cl_int CL_API_CALL
clDestroyInstanceKHR_t(
cl_instance_khr instance);

typedef clDestroyInstanceKHR_t *
clDestroyInstanceKHR_fn;

typedef cl_int CL_API_CALL
clGetPlatformIDsForInstanceKHR_t(
cl_instance_khr instance,
cl_uint num_entries,
cl_platform_id *platforms,
cl_uint *num_platforms);

typedef clGetPlatformIDsForInstanceKHR_t *
clGetPlatformIDsForInstanceKHR_fn;

typedef cl_platform_id CL_API_CALL
clIcdCreateInstancePlatformKHR_t(
cl_platform_id platform,
cl_int *errcode_ret);

typedef clIcdCreateInstancePlatformKHR_t *
clIcdCreateInstancePlatformKHR_fn;

typedef cl_int CL_API_CALL
clIcdDestroyInstancePlatformKHR_t(
cl_platform_id platform);

typedef clIcdDestroyInstancePlatformKHR_t *
clIcdDestroyInstancePlatformKHR_fn;

#endif // !defined(CL_INVALID_INSTANCE_KHR)
3 changes: 1 addition & 2 deletions loader/cllayerinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "icd.h"
#include <stdio.h>
#include <stdlib.h>
#include <CL/cl_layer.h>
#if defined(_WIN32)
#include <io.h>
#include <share.h>
Expand Down Expand Up @@ -90,7 +89,7 @@ static void restore_outputs(void)
void printLayerInfo(const struct KHRLayer *layer)
{
cl_layer_api_version api_version = 0;
pfn_clGetLayerInfo p_clGetLayerInfo = (pfn_clGetLayerInfo)(size_t)layer->p_clGetLayerInfo;
pfn_clGetLayerInfo p_clGetLayerInfo = layer->p_clGetLayerInfo;
cl_int result = CL_SUCCESS;
size_t sz;

Expand Down
Loading
Loading