From d4c39b88c5b1d1a245bce61dcd4059a9ca7017d8 Mon Sep 17 00:00:00 2001 From: Laurent Morichetti Date: Mon, 3 Feb 2020 13:26:46 -0800 Subject: [PATCH] Merge branch 'origin/pghafari/opencl' into lmoriche/amd-master-next --- opencl/CMakeLists.txt | 124 +- opencl/{api/opencl => }/amdocl/CMakeLists.txt | 71 +- opencl/{api/opencl => }/amdocl/amdocl.def.in | 2 - opencl/{api/opencl => }/amdocl/amdocl.map | 0 opencl/{api/opencl => }/amdocl/amdocl.map.in | 0 opencl/{api/opencl => }/amdocl/amdocl.rc | 0 opencl/{api/opencl => }/amdocl/cl_agent_amd.h | 0 opencl/{api/opencl => }/amdocl/cl_command.cpp | 0 opencl/{api/opencl => }/amdocl/cl_common.hpp | 0 opencl/{api/opencl => }/amdocl/cl_context.cpp | 0 opencl/{api/opencl => }/amdocl/cl_counter.cpp | 0 opencl/{api/opencl => }/amdocl/cl_d3d10.cpp | 0 .../{api/opencl => }/amdocl/cl_d3d10_amd.hpp | 0 opencl/{api/opencl => }/amdocl/cl_d3d11.cpp | 0 .../{api/opencl => }/amdocl/cl_d3d11_amd.hpp | 0 opencl/{api/opencl => }/amdocl/cl_d3d9.cpp | 0 .../{api/opencl => }/amdocl/cl_d3d9_amd.hpp | 0 .../opencl => }/amdocl/cl_debugger_amd.cpp | 0 .../{api/opencl => }/amdocl/cl_debugger_amd.h | 0 opencl/{api/opencl => }/amdocl/cl_device.cpp | 2 +- opencl/{api/opencl => }/amdocl/cl_event.cpp | 0 opencl/{api/opencl => }/amdocl/cl_execute.cpp | 0 opencl/{api/opencl => }/amdocl/cl_gl.cpp | 0 opencl/{api/opencl => }/amdocl/cl_gl_amd.hpp | 0 opencl/{api/opencl => }/amdocl/cl_icd.cpp | 0 opencl/{api/opencl => }/amdocl/cl_icd_amd.h | 0 opencl/{api/opencl => }/amdocl/cl_kernel.h | 0 .../opencl => }/amdocl/cl_kernel_info_amd.cpp | 0 .../opencl => }/amdocl/cl_kernel_info_amd.h | 0 .../opencl => }/amdocl/cl_lqdflash_amd.cpp | 0 .../{api/opencl => }/amdocl/cl_lqdflash_amd.h | 0 opencl/{api/opencl => }/amdocl/cl_memobj.cpp | 0 opencl/{api/opencl => }/amdocl/cl_object.cpp | 0 opencl/{api/opencl => }/amdocl/cl_p2p_amd.cpp | 0 opencl/{api/opencl => }/amdocl/cl_p2p_amd.h | 0 opencl/{api/opencl => }/amdocl/cl_pipe.cpp | 0 .../opencl => }/amdocl/cl_platform_amd.cpp | 0 .../{api/opencl => }/amdocl/cl_platform_amd.h | 0 .../opencl => }/amdocl/cl_profile_amd.cpp | 0 .../{api/opencl => }/amdocl/cl_profile_amd.h | 0 opencl/{api/opencl => }/amdocl/cl_program.cpp | 0 opencl/{api/opencl => }/amdocl/cl_sampler.cpp | 0 opencl/{api/opencl => }/amdocl/cl_sdi_amd.cpp | 0 opencl/{api/opencl => }/amdocl/cl_sdi_amd.h | 0 .../opencl => }/amdocl/cl_semaphore_amd.h | 0 opencl/{api/opencl => }/amdocl/cl_svm.cpp | 0 .../amdocl/cl_thread_trace_amd.cpp | 0 .../opencl => }/amdocl/cl_thread_trace_amd.h | 0 opencl/amdocl/cmake/modules/FindROCR.cmake | 16 + opencl/amdocl/cmake/modules/FindROCT.cmake | 16 + opencl/amdocl/cmake/modules/bc2h.cmake | 39 + .../{api/opencl => }/amdocl/gl_functions.hpp | 0 .../opencl => }/amdocl/glibc_functions.cpp | 0 .../khronos/icd/loader/linux/icd_linux.c | 204 -- .../khronos/icd/loader/windows/OpenCL.rc | 70 - .../khronos/icd/loader/windows/icd_windows.c | 180 -- .../icd/loader/windows/icd_windows_dxgk.c | 145 -- .../icd/loader/windows/icd_windows_dxgk.h | 40 - .../icd/loader/windows/icd_windows_hkr.h | 40 - opencl/{api/opencl => }/config/amdocl32.icd | 0 opencl/{api/opencl => }/config/amdocl64.icd | 0 opencl/configure | 0 .../opencl => }/khronos/headers/EGL/egl.h | 0 .../opencl => }/khronos/headers/EGL/eglext.h | 0 .../khronos/headers/EGL/eglplatform.h | 0 .../opencl => }/khronos/headers/GL/glext.h | 0 .../khronos/headers/KHR/khrplatform.h | 0 .../khronos/headers/opencl1.2/CL/cl.h | 0 .../khronos/headers/opencl1.2/CL/cl.hpp | 0 .../khronos/headers/opencl1.2/CL/cl_d3d10.h | 0 .../khronos/headers/opencl1.2/CL/cl_d3d11.h | 0 .../opencl1.2/CL/cl_dx9_media_sharing.h | 0 .../khronos/headers/opencl1.2/CL/cl_ext.h | 0 .../khronos/headers/opencl1.2/CL/cl_gl.h | 0 .../khronos/headers/opencl1.2/CL/cl_gl_ext.h | 0 .../headers/opencl1.2/CL/cl_platform.h | 0 .../khronos/headers/opencl1.2/CL/opencl.h | 0 .../khronos/headers/opencl2.0/CL/cl.h | 0 .../khronos/headers/opencl2.0/CL/cl.hpp | 0 .../khronos/headers/opencl2.0/CL/cl2.hpp | 0 .../khronos/headers/opencl2.0/CL/cl_d3d10.h | 0 .../khronos/headers/opencl2.0/CL/cl_d3d11.h | 0 .../opencl2.0/CL/cl_dx9_media_sharing.h | 0 .../khronos/headers/opencl2.0/CL/cl_egl.h | 0 .../khronos/headers/opencl2.0/CL/cl_ext.h | 0 .../khronos/headers/opencl2.0/CL/cl_gl.h | 0 .../khronos/headers/opencl2.0/CL/cl_gl_ext.h | 0 .../headers/opencl2.0/CL/cl_platform.h | 0 .../khronos/headers/opencl2.0/CL/opencl.h | 0 .../khronos/headers/opencl2.1/CL/cl.h | 0 .../khronos/headers/opencl2.1/CL/cl.hpp | 0 .../khronos/headers/opencl2.1/CL/cl2.hpp | 0 .../khronos/headers/opencl2.1/CL/cl_d3d10.h | 0 .../khronos/headers/opencl2.1/CL/cl_d3d11.h | 0 .../opencl2.1/CL/cl_dx9_media_sharing.h | 0 .../khronos/headers/opencl2.1/CL/cl_egl.h | 0 .../khronos/headers/opencl2.1/CL/cl_ext.h | 0 .../khronos/headers/opencl2.1/CL/cl_gl.h | 0 .../khronos/headers/opencl2.1/CL/cl_gl_ext.h | 0 .../headers/opencl2.1/CL/cl_platform.h | 0 .../khronos/headers/opencl2.1/CL/opencl.h | 0 .../khronos/headers/opencl2.2/CL/cl.h | 0 .../khronos/headers/opencl2.2/CL/cl.hpp | 0 .../khronos/headers/opencl2.2/CL/cl2.hpp | 0 .../khronos/headers/opencl2.2/CL/cl_d3d10.h | 0 .../khronos/headers/opencl2.2/CL/cl_d3d11.h | 0 .../opencl2.2/CL/cl_dx9_media_sharing.h | 0 .../khronos/headers/opencl2.2/CL/cl_egl.h | 0 .../khronos/headers/opencl2.2/CL/cl_ext.h | 0 .../khronos/headers/opencl2.2/CL/cl_gl.h | 0 .../khronos/headers/opencl2.2/CL/cl_gl_ext.h | 0 .../headers/opencl2.2/CL/cl_platform.h | 0 .../khronos/headers/opencl2.2/CL/opencl.h | 0 opencl/khronos/icd/.appveyor.yml | 20 + opencl/khronos/icd/.gitignore | 4 + opencl/khronos/icd/.travis.yml | 18 + opencl/khronos/icd/CMakeLists.txt | 137 ++ opencl/khronos/icd/CODE_OF_CONDUCT.md | 1 + opencl/khronos/icd/LICENSE | 201 ++ .../{api/opencl => }/khronos/icd/LICENSE.txt | 0 opencl/khronos/icd/README.md | 127 ++ opencl/khronos/icd/inc/README.txt | 14 + .../{api/opencl => }/khronos/icd/loader/icd.c | 134 +- .../{api/opencl => }/khronos/icd/loader/icd.h | 51 +- .../khronos/icd/loader/icd_cmake_config.h.in | 2 + .../khronos/icd/loader/icd_dispatch.c | 92 +- .../khronos/icd/loader/icd_dispatch.h | 62 +- opencl/khronos/icd/loader/icd_envvars.h | 26 + opencl/khronos/icd/loader/icd_platform.h | 39 + .../khronos/icd/loader/linux/icd_exports.map | 165 ++ opencl/khronos/icd/loader/linux/icd_linux.c | 175 ++ .../icd/loader/linux/icd_linux_envvars.c | 62 + opencl/khronos/icd/loader/windows/OpenCL.def | 162 ++ opencl/khronos/icd/loader/windows/OpenCL.rc | 62 + .../khronos/icd/loader/windows/icd_windows.c | 154 ++ .../icd/loader/windows/icd_windows_dxgk.c | 154 ++ .../icd/loader/windows/icd_windows_dxgk.h | 21 + .../icd/loader/windows/icd_windows_envvars.c | 47 + .../icd/loader/windows/icd_windows_hkr.c | 73 +- .../icd/loader/windows/icd_windows_hkr.h | 21 + opencl/khronos/icd/test/CMakeLists.txt | 7 + .../icd/test/driver_stub/CMakeLists.txt | 10 + opencl/khronos/icd/test/driver_stub/cl.c | 1919 +++++++++++++++++ opencl/khronos/icd/test/driver_stub/cl_ext.c | 35 + opencl/khronos/icd/test/driver_stub/cl_gl.c | 221 ++ .../icd/test/driver_stub/driver_stub.def | 2 + opencl/khronos/icd/test/driver_stub/icd.c | 186 ++ .../test/driver_stub/icd_driver_exports.map | 8 + .../icd/test/driver_stub/icd_structs.h | 18 + .../khronos/icd/test/driver_stub/rename_api.h | 106 + .../icd/test/inc/platform/icd_test_log.h | 20 + .../icd/test/loader_test/CMakeLists.txt | 15 + .../khronos/icd/test/loader_test/callbacks.c | 43 + .../icd/test/loader_test/icd_test_match.c | 38 + opencl/khronos/icd/test/loader_test/main.c | 45 + .../icd/test/loader_test/param_struct.h | 1110 ++++++++++ .../icd/test/loader_test/test_buffer_object.c | 463 ++++ .../icd/test/loader_test/test_cl_runtime.c | 64 + .../khronos/icd/test/loader_test/test_clgl.c | 347 +++ .../icd/test/loader_test/test_create_calls.c | 769 +++++++ .../icd/test/loader_test/test_image_objects.c | 364 ++++ .../icd/test/loader_test/test_kernel.c | 600 ++++++ .../icd/test/loader_test/test_platforms.c | 183 ++ .../test/loader_test/test_program_objects.c | 260 +++ .../test/loader_test/test_sampler_objects.c | 64 + opencl/khronos/icd/test/log/CMakeLists.txt | 4 + opencl/khronos/icd/test/log/icd_test_log.c | 103 + 167 files changed, 8931 insertions(+), 1046 deletions(-) rename opencl/{api/opencl => }/amdocl/CMakeLists.txt (51%) rename opencl/{api/opencl => }/amdocl/amdocl.def.in (98%) rename opencl/{api/opencl => }/amdocl/amdocl.map (100%) rename opencl/{api/opencl => }/amdocl/amdocl.map.in (100%) rename opencl/{api/opencl => }/amdocl/amdocl.rc (100%) rename opencl/{api/opencl => }/amdocl/cl_agent_amd.h (100%) rename opencl/{api/opencl => }/amdocl/cl_command.cpp (100%) rename opencl/{api/opencl => }/amdocl/cl_common.hpp (100%) rename opencl/{api/opencl => }/amdocl/cl_context.cpp (100%) rename opencl/{api/opencl => }/amdocl/cl_counter.cpp (100%) rename opencl/{api/opencl => }/amdocl/cl_d3d10.cpp (100%) rename opencl/{api/opencl => }/amdocl/cl_d3d10_amd.hpp (100%) rename opencl/{api/opencl => }/amdocl/cl_d3d11.cpp (100%) rename opencl/{api/opencl => }/amdocl/cl_d3d11_amd.hpp (100%) rename opencl/{api/opencl => }/amdocl/cl_d3d9.cpp (100%) rename opencl/{api/opencl => }/amdocl/cl_d3d9_amd.hpp (100%) rename opencl/{api/opencl => }/amdocl/cl_debugger_amd.cpp (100%) rename opencl/{api/opencl => }/amdocl/cl_debugger_amd.h (100%) rename opencl/{api/opencl => }/amdocl/cl_device.cpp (99%) rename opencl/{api/opencl => }/amdocl/cl_event.cpp (100%) rename opencl/{api/opencl => }/amdocl/cl_execute.cpp (100%) rename opencl/{api/opencl => }/amdocl/cl_gl.cpp (100%) rename opencl/{api/opencl => }/amdocl/cl_gl_amd.hpp (100%) rename opencl/{api/opencl => }/amdocl/cl_icd.cpp (100%) rename opencl/{api/opencl => }/amdocl/cl_icd_amd.h (100%) rename opencl/{api/opencl => }/amdocl/cl_kernel.h (100%) rename opencl/{api/opencl => }/amdocl/cl_kernel_info_amd.cpp (100%) rename opencl/{api/opencl => }/amdocl/cl_kernel_info_amd.h (100%) rename opencl/{api/opencl => }/amdocl/cl_lqdflash_amd.cpp (100%) rename opencl/{api/opencl => }/amdocl/cl_lqdflash_amd.h (100%) rename opencl/{api/opencl => }/amdocl/cl_memobj.cpp (100%) rename opencl/{api/opencl => }/amdocl/cl_object.cpp (100%) rename opencl/{api/opencl => }/amdocl/cl_p2p_amd.cpp (100%) rename opencl/{api/opencl => }/amdocl/cl_p2p_amd.h (100%) rename opencl/{api/opencl => }/amdocl/cl_pipe.cpp (100%) rename opencl/{api/opencl => }/amdocl/cl_platform_amd.cpp (100%) rename opencl/{api/opencl => }/amdocl/cl_platform_amd.h (100%) rename opencl/{api/opencl => }/amdocl/cl_profile_amd.cpp (100%) rename opencl/{api/opencl => }/amdocl/cl_profile_amd.h (100%) rename opencl/{api/opencl => }/amdocl/cl_program.cpp (100%) rename opencl/{api/opencl => }/amdocl/cl_sampler.cpp (100%) rename opencl/{api/opencl => }/amdocl/cl_sdi_amd.cpp (100%) rename opencl/{api/opencl => }/amdocl/cl_sdi_amd.h (100%) rename opencl/{api/opencl => }/amdocl/cl_semaphore_amd.h (100%) rename opencl/{api/opencl => }/amdocl/cl_svm.cpp (100%) rename opencl/{api/opencl => }/amdocl/cl_thread_trace_amd.cpp (100%) rename opencl/{api/opencl => }/amdocl/cl_thread_trace_amd.h (100%) create mode 100644 opencl/amdocl/cmake/modules/FindROCR.cmake create mode 100644 opencl/amdocl/cmake/modules/FindROCT.cmake create mode 100644 opencl/amdocl/cmake/modules/bc2h.cmake rename opencl/{api/opencl => }/amdocl/gl_functions.hpp (100%) rename opencl/{api/opencl => }/amdocl/glibc_functions.cpp (100%) delete mode 100644 opencl/api/opencl/khronos/icd/loader/linux/icd_linux.c delete mode 100644 opencl/api/opencl/khronos/icd/loader/windows/OpenCL.rc delete mode 100644 opencl/api/opencl/khronos/icd/loader/windows/icd_windows.c delete mode 100644 opencl/api/opencl/khronos/icd/loader/windows/icd_windows_dxgk.c delete mode 100644 opencl/api/opencl/khronos/icd/loader/windows/icd_windows_dxgk.h delete mode 100644 opencl/api/opencl/khronos/icd/loader/windows/icd_windows_hkr.h rename opencl/{api/opencl => }/config/amdocl32.icd (100%) rename opencl/{api/opencl => }/config/amdocl64.icd (100%) create mode 100644 opencl/configure rename opencl/{api/opencl => }/khronos/headers/EGL/egl.h (100%) rename opencl/{api/opencl => }/khronos/headers/EGL/eglext.h (100%) rename opencl/{api/opencl => }/khronos/headers/EGL/eglplatform.h (100%) rename opencl/{api/opencl => }/khronos/headers/GL/glext.h (100%) rename opencl/{api/opencl => }/khronos/headers/KHR/khrplatform.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl1.2/CL/cl.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl1.2/CL/cl.hpp (100%) rename opencl/{api/opencl => }/khronos/headers/opencl1.2/CL/cl_d3d10.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl1.2/CL/cl_d3d11.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl1.2/CL/cl_dx9_media_sharing.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl1.2/CL/cl_ext.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl1.2/CL/cl_gl.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl1.2/CL/cl_gl_ext.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl1.2/CL/cl_platform.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl1.2/CL/opencl.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.0/CL/cl.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.0/CL/cl.hpp (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.0/CL/cl2.hpp (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.0/CL/cl_d3d10.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.0/CL/cl_d3d11.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.0/CL/cl_dx9_media_sharing.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.0/CL/cl_egl.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.0/CL/cl_ext.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.0/CL/cl_gl.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.0/CL/cl_gl_ext.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.0/CL/cl_platform.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.0/CL/opencl.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.1/CL/cl.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.1/CL/cl.hpp (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.1/CL/cl2.hpp (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.1/CL/cl_d3d10.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.1/CL/cl_d3d11.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.1/CL/cl_dx9_media_sharing.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.1/CL/cl_egl.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.1/CL/cl_ext.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.1/CL/cl_gl.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.1/CL/cl_gl_ext.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.1/CL/cl_platform.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.1/CL/opencl.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.2/CL/cl.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.2/CL/cl.hpp (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.2/CL/cl2.hpp (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.2/CL/cl_d3d10.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.2/CL/cl_d3d11.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.2/CL/cl_dx9_media_sharing.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.2/CL/cl_egl.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.2/CL/cl_ext.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.2/CL/cl_gl.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.2/CL/cl_gl_ext.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.2/CL/cl_platform.h (100%) rename opencl/{api/opencl => }/khronos/headers/opencl2.2/CL/opencl.h (100%) create mode 100644 opencl/khronos/icd/.appveyor.yml create mode 100644 opencl/khronos/icd/.gitignore create mode 100644 opencl/khronos/icd/.travis.yml create mode 100644 opencl/khronos/icd/CMakeLists.txt create mode 100644 opencl/khronos/icd/CODE_OF_CONDUCT.md create mode 100644 opencl/khronos/icd/LICENSE rename opencl/{api/opencl => }/khronos/icd/LICENSE.txt (100%) create mode 100644 opencl/khronos/icd/README.md create mode 100644 opencl/khronos/icd/inc/README.txt rename opencl/{api/opencl => }/khronos/icd/loader/icd.c (62%) rename opencl/{api/opencl => }/khronos/icd/loader/icd.h (70%) create mode 100644 opencl/khronos/icd/loader/icd_cmake_config.h.in rename opencl/{api/opencl => }/khronos/icd/loader/icd_dispatch.c (97%) rename opencl/{api/opencl => }/khronos/icd/loader/icd_dispatch.h (96%) create mode 100644 opencl/khronos/icd/loader/icd_envvars.h create mode 100644 opencl/khronos/icd/loader/icd_platform.h create mode 100644 opencl/khronos/icd/loader/linux/icd_exports.map create mode 100644 opencl/khronos/icd/loader/linux/icd_linux.c create mode 100644 opencl/khronos/icd/loader/linux/icd_linux_envvars.c create mode 100644 opencl/khronos/icd/loader/windows/OpenCL.def create mode 100644 opencl/khronos/icd/loader/windows/OpenCL.rc create mode 100644 opencl/khronos/icd/loader/windows/icd_windows.c create mode 100644 opencl/khronos/icd/loader/windows/icd_windows_dxgk.c create mode 100644 opencl/khronos/icd/loader/windows/icd_windows_dxgk.h create mode 100644 opencl/khronos/icd/loader/windows/icd_windows_envvars.c rename opencl/{api/opencl => }/khronos/icd/loader/windows/icd_windows_hkr.c (81%) create mode 100644 opencl/khronos/icd/loader/windows/icd_windows_hkr.h create mode 100644 opencl/khronos/icd/test/CMakeLists.txt create mode 100644 opencl/khronos/icd/test/driver_stub/CMakeLists.txt create mode 100644 opencl/khronos/icd/test/driver_stub/cl.c create mode 100644 opencl/khronos/icd/test/driver_stub/cl_ext.c create mode 100644 opencl/khronos/icd/test/driver_stub/cl_gl.c create mode 100644 opencl/khronos/icd/test/driver_stub/driver_stub.def create mode 100644 opencl/khronos/icd/test/driver_stub/icd.c create mode 100644 opencl/khronos/icd/test/driver_stub/icd_driver_exports.map create mode 100644 opencl/khronos/icd/test/driver_stub/icd_structs.h create mode 100644 opencl/khronos/icd/test/driver_stub/rename_api.h create mode 100644 opencl/khronos/icd/test/inc/platform/icd_test_log.h create mode 100644 opencl/khronos/icd/test/loader_test/CMakeLists.txt create mode 100644 opencl/khronos/icd/test/loader_test/callbacks.c create mode 100644 opencl/khronos/icd/test/loader_test/icd_test_match.c create mode 100644 opencl/khronos/icd/test/loader_test/main.c create mode 100644 opencl/khronos/icd/test/loader_test/param_struct.h create mode 100644 opencl/khronos/icd/test/loader_test/test_buffer_object.c create mode 100644 opencl/khronos/icd/test/loader_test/test_cl_runtime.c create mode 100644 opencl/khronos/icd/test/loader_test/test_clgl.c create mode 100644 opencl/khronos/icd/test/loader_test/test_create_calls.c create mode 100644 opencl/khronos/icd/test/loader_test/test_image_objects.c create mode 100644 opencl/khronos/icd/test/loader_test/test_kernel.c create mode 100644 opencl/khronos/icd/test/loader_test/test_platforms.c create mode 100644 opencl/khronos/icd/test/loader_test/test_program_objects.c create mode 100644 opencl/khronos/icd/test/loader_test/test_sampler_objects.c create mode 100644 opencl/khronos/icd/test/log/CMakeLists.txt create mode 100644 opencl/khronos/icd/test/log/icd_test_log.c diff --git a/opencl/CMakeLists.txt b/opencl/CMakeLists.txt index 22e010104f..747f94e96d 100644 --- a/opencl/CMakeLists.txt +++ b/opencl/CMakeLists.txt @@ -1,112 +1,24 @@ cmake_minimum_required(VERSION 3.4.3) if (POLICY CMP0048) - cmake_policy(SET CMP0048 NEW) - set(PROJ_VERSION VERSION 1.5.0) + cmake_policy(SET CMP0048 NEW) + set(PROJ_VERSION VERSION 1.5.0) endif() -# FIXME: Remove following line after enabling COMGR by default -set(USE_COMGR_LIBRARY "no" CACHE STRING "Do not enable COMGR by default") +project(opencl) -# Build ROCm-OpenCL with ccache if the package is present. -set(ROCM_OPENCL_CCACHE_BUILD OFF CACHE BOOL "Set to ON for a ccache enabled build") -if(ROCM_OPENCL_CCACHE_BUILD) - find_program(CCACHE_PROGRAM ccache) - if(CCACHE_PROGRAM) - set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_PROGRAM}) - else() - message(FATAL_ERROR "Unable to find the program ccache. Set ROCM_OPENCL_CCACHE_BUILD to OFF") - endif() +#example command: +#cmake -DVDI_DIR=/home/pghafari/git-vdi/opencl -DUSE_COMGR_LIBRARY=yes -DCMAKE_PREFIX_PATH="/home/pghafari/rocmgitvdi/support/lib/comgr;/home/pghafari/rocmgitvdi/support/lib/comgr/build;" -DLLVM_INCLUDES=/home/pghafari/rocmgit/llvm-project/llvm/include -DLIBVDI_STATIC_DIR=/home/pghafari/git-vdi/opencl/build -DCMAKE_MODULE_PATH=/home/pghafari/rocmgit/opencl/cmake/modules .. - # FIXME: Remove following if block after enabling COMGR by default - if (${USE_COMGR_LIBRARY} STREQUAL "no") - set(LLVM_CCACHE_BUILD ON CACHE BOOL "") - set(ROCM_DEVICE_LIBS_CCACHE_BUILD ON CACHE BOOL "") - set(ROCM_OPENCL_DRIVER_CCACHE_BUILD ON CACHE BOOL "") - endif() # if (${USE_COMGR_LIBRARY} STREQUAL "no") -endif() +set(OPENCL_ICD_LOADER_HEADERS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/khronos/headers/opencl2.2" CACHE PATH "") +set(BUILD_SHARED_LIBS "Build shared libs" ON) -project(rocm-opencl) - -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") -set(OPENCL_ICD_LOADER_HEADERS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2" CACHE PATH "") - -find_package(ROCT REQUIRED) -find_package(ROCR REQUIRED) - -# FIXME: Remove following if block after enabling COMGR by default -if (${USE_COMGR_LIBRARY} STREQUAL "no") - set(LLVM_INCLUDE_TESTS OFF CACHE BOOL "") - set(LLVM_BUILD_TOOLS OFF CACHE BOOL "") - set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "") - set(LLVM_TARGETS_TO_BUILD "AMDGPU" CACHE STRING "") - set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "") - set(CLANG_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "") - - # override default option value in library and driver - set(GENERIC_IS_ZERO ON CACHE BOOL ON FORCE) - - add_subdirectory(compiler/llvm EXCLUDE_FROM_ALL) - - find_package(LLVM REQUIRED CONFIG PATHS ${CMAKE_BINARY_DIR}/compiler/llvm NO_DEFAULT_PATH) - - list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}") - include(AddLLVM) - - add_definitions(${LLVM_DEFINITIONS}) - # TODO: add find_package for Clang and lld, and also use LLVM/Clang variables got from their config - include_directories(${CMAKE_SOURCE_DIR}/compiler/llvm/tools/clang/include) - include_directories(${CMAKE_BINARY_DIR}/compiler/llvm/tools/clang/include) - include_directories(${CMAKE_SOURCE_DIR}/compiler/llvm/tools/lld/include) - - # TODO: move AMDGPU.h header to include folder - include_directories(${CMAKE_SOURCE_DIR}/compiler/llvm/lib/Target/AMDGPU) - include_directories(${CMAKE_BINARY_DIR}/compiler/llvm/lib/Target/AMDGPU) - - set(BUILD_HC_LIB OFF CACHE BOOL "") - set(ROCM_DEVICELIB_INCLUDE_TESTS OFF CACHE BOOL "") - set(AMDGCN_TARGETS_LIB_LIST "AMDGCN_LIB_TARGETS") - set(AMDGCN_TARGETS_LIB_DEPS "AMDGCN_DEP_TARGETS") - set(AMDGPU_TARGET_TRIPLE "amdgcn-amd-amdhsa") - add_subdirectory(library/amdgcn EXCLUDE_FROM_ALL) - add_subdirectory(compiler/driver EXCLUDE_FROM_ALL) - - install(PROGRAMS $ $ - DESTINATION bin/x86_64 - COMPONENT DEV) - - foreach(AMDGCN_LIB_TARGET ${AMDGCN_LIB_TARGETS}) - get_target_property(lib_file_name ${AMDGCN_LIB_TARGET} ARCHIVE_OUTPUT_NAME) - get_target_property(lib_file_path ${AMDGCN_LIB_TARGET} ARCHIVE_OUTPUT_DIRECTORY) - install(FILES ${lib_file_path}/${lib_file_name}.amdgcn.bc - DESTINATION lib/x86_64/bitcode - COMPONENT DEV) - endforeach() -endif() # if (${USE_COMGR_LIBRARY} STREQUAL "no") - -if(${USE_COMGR_LIBRARY} MATCHES "yes") - set(COMGR_DYN_DLL "yes") - add_definitions(-DCOMGR_DYN_DLL) - add_definitions(-DUSE_COMGR_LIBRARY) - if( ${BUILD_HIP} MATCHES "yes") - add_subdirectory(api/hip) - endif() -endif() - -add_subdirectory(api/opencl/amdocl) -add_subdirectory(compiler/lib/loaders/elf/utils/libelf) -add_subdirectory(runtime) +add_subdirectory(khronos/icd) +add_subdirectory(amdocl) add_subdirectory(tools/clinfo) -set(BUILD_SHARED_LIBS "Build shared libs" ON) -add_subdirectory(api/opencl/khronos/icd) - ###--- Packaging ------------------------------------------------------------### -find_package(ROCM QUIET CONFIG PATHS /opt/rocm) -include(ROCMSetupVersion) -rocm_setup_version( VERSION "2.0.0" ) - # MAIN package install(PROGRAMS $ DESTINATION bin/x86_64 @@ -122,7 +34,7 @@ install(PROGRAMS $ COMPONENT MAIN) # DEV package -install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2/CL" +install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/khronos/headers/opencl2.2/CL" DESTINATION include COMPONENT DEV USE_SOURCE_PERMISSIONS @@ -141,28 +53,30 @@ set(CPACK_PACKAGE_CONTACT "Advanced Micro Devices Inc.") set(CPACK_PACKAGE_VENDOR "AMD") set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/rocm/opencl") -set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) +set(CPACK_PACKAGE_VERSION_MAJOR "1") +set(CPACK_PACKAGE_VERSION_MINOR "2") +set(CPACK_PACKAGE_VERSION_PATCH "0") # Debian CPACK variables set(CPACK_DEB_COMPONENT_INSTALL ON) -set(CPACK_DEBIAN_MAIN_FILE_NAME "rocm-opencl-${PROJECT_VERSION}-Linux.deb") +set(CPACK_DEBIAN_MAIN_FILE_NAME "rocm-opencl-1.2.0.deb") set(CPACK_DEBIAN_MAIN_PACKAGE_NAME "rocm-opencl") set(CPACK_DEBIAN_MAIN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/DEB/postinst;${CMAKE_CURRENT_SOURCE_DIR}/DEB/prerm") -set(CPACK_DEBIAN_FILE_NAME "rocm-opencl-dev-${PROJECT_VERSION}-Linux.deb") -set(CPACK_DEBIAN_PACKAGE_NAME "rocm-opencl-dev") -set(CPACK_DEBIAN_PACKAGE_DEPENDS "rocm-opencl") +set(CPACK_DEBIAN_DEV_FILE_NAME "rocm-opencl-dev-1.2.0.deb") +set(CPACK_DEBIAN_DEV_PACKAGE_NAME "rocm-opencl-dev") +set(CPACK_DEBIAN_DEV_PACKAGE_DEPENDS "rocm-opencl") # RPM CPACK variables set(CPACK_RPM_COMPONENT_INSTALL ON) -set(CPACK_RPM_MAIN_FILE_NAME "rocm-opencl-${PROJECT_VERSION}-Linux.rpm") +set(CPACK_RPM_MAIN_FILE_NAME "rocm-opencl-1.2.0.rpm") set(CPACK_RPM_MAIN_PACKAGE_NAME "rocm-opencl") set(CPACK_RPM_MAIN_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/RPM/rpm_post") set(CPACK_RPM_MAIN_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/RPM/rpm_postun") -set(CPACK_RPM_DEV_FILE_NAME "rocm-opencl-devel-${PROJECT_VERSION}-Linux.rpm") +set(CPACK_RPM_DEV_FILE_NAME "rocm-opencl-devel-1.2.0.rpm") set(CPACK_RPM_DEV_PACKAGE_NAME "rocm-opencl-devel") set(CPACK_RPM_DEV_PACKAGE_DEPENDS "rocm-opencl") diff --git a/opencl/api/opencl/amdocl/CMakeLists.txt b/opencl/amdocl/CMakeLists.txt similarity index 51% rename from opencl/api/opencl/amdocl/CMakeLists.txt rename to opencl/amdocl/CMakeLists.txt index 8ea8517f39..7533d9c7d5 100644 --- a/opencl/api/opencl/amdocl/CMakeLists.txt +++ b/opencl/amdocl/CMakeLists.txt @@ -1,4 +1,5 @@ -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC") # Some linker flags, -Wl,--unresolved-symbols=report-all being one of them, requires -shared-libasan if using -fsanitize=address. # If -Wl,--unresolved-symbols=report-all is removed from CMAKE_SHARED_LINKER_FLAGS, then update this snippet @@ -6,10 +7,15 @@ if(CMAKE_CXX_FLAGS MATCHES "fsanitize=address") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -shared-libasan") endif() -set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-Bsymbolic -Wl,--unresolved-symbols=report-all -Wl,--version-script=${CMAKE_SOURCE_DIR}/api/opencl/amdocl/amdocl.map") +set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-Bsymbolic -Wl,--unresolved-symbols=report-all -Wl,--version-script=${CMAKE_SOURCE_DIR}/amdocl/amdocl.map") set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") + +find_package(ROCT REQUIRED) +find_package(ROCR REQUIRED) + add_definitions(-DLINUX -D__x86_64__ -D__AMD64__ -DUNIX_OS -DqLittleEndian -DOPENCL_MAJOR=2 -DOPENCL_MINOR=0 -DWITH_AQL -DWITH_ONLINE_COMPILER -DATI_OS_LINUX -DATI_ARCH_X86 -DLITTLEENDIAN_CPU -DATI_BITS_64 -DATI_COMP_GCC -DWITH_HSA_DEVICE -DWITH_TARGET_AMDGCN -DOPENCL_EXPORTS -DCL_USE_DEPRECATED_OPENCL_1_0_APIS -DCL_USE_DEPRECATED_OPENCL_1_1_APIS -DCL_USE_DEPRECATED_OPENCL_1_2_APIS -DCL_USE_DEPRECATED_OPENCL_2_0_APIS -DVEGA10_ONLY=false -DWITH_LIGHTNING_COMPILER) if(CMAKE_BUILD_TYPE MATCHES "^Debug$") @@ -17,29 +23,31 @@ if(CMAKE_BUILD_TYPE MATCHES "^Debug$") endif() include_directories(${ROCR_INCLUDES}) -if (DEFINED LLVM_INCLUDES AND NOT ${LLVM_INCLUDES} STREQUAL "") - include_directories(${LLVM_INCLUDES}) -endif() # if (DEFINED LLVM_INCLUDES AND NOT ${LLVM_INCLUDES} STREQUAL "") -include_directories(${CMAKE_SOURCE_DIR}/runtime) -include_directories(${CMAKE_SOURCE_DIR}/api/opencl) -include_directories(${CMAKE_SOURCE_DIR}/api/opencl/khronos) -include_directories(${CMAKE_SOURCE_DIR}/api/opencl/khronos/headers) -include_directories(${CMAKE_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2) +if (DEFINED LLVM_INCLUDES AND NOT ${LLVM_INCLUDES} STREQUAL "") + include_directories(${LLVM_INCLUDES}) + endif() # if (DEFINED LLVM_INCLUDES AND NOT ${LLVM_INCLUDES} STREQUAL "") + +include_directories(${CMAKE_SOURCE_DIR}) +include_directories(${CMAKE_SOURCE_DIR}/khronos) +include_directories(${CMAKE_SOURCE_DIR}/khronos/headers) +include_directories(${CMAKE_SOURCE_DIR}/khronos/headers/opencl2.2) if(${USE_COMGR_LIBRARY} MATCHES "yes") add_definitions(-DUSE_COMGR_LIBRARY -DCOMGR_DYN_DLL) find_package(amd_comgr REQUIRED CONFIG) include_directories("$") else() - include_directories(${CMAKE_SOURCE_DIR}/compiler/driver/src) + # include_directories(${CMAKE_SOURCE_DIR}/compiler/driver/src) endif() -include_directories(${CMAKE_SOURCE_DIR}/compiler/lib) -include_directories(${CMAKE_SOURCE_DIR}/compiler/lib/include) -include_directories(${CMAKE_SOURCE_DIR}/compiler/lib/backends/common) -include_directories(${CMAKE_SOURCE_DIR}/compiler/lib/loaders) -include_directories(${CMAKE_SOURCE_DIR}/compiler/lib/loaders/elf/utils/libelf) -include_directories(${CMAKE_SOURCE_DIR}/compiler/lib/loaders/elf/utils/common) -include_directories(${CMAKE_SOURCE_DIR}/compiler/tools) +include_directories(${VDI_DIR}) +include_directories(${VDI_DIR}/include) +include_directories(${VDI_DIR}/compiler/lib) +include_directories(${VDI_DIR}/compiler/lib/include) +include_directories(${VDI_DIR}/compiler/lib/backends/common) +#include_directories(${VDI_DIR}/compiler/lib/loaders) +include_directories(${VDI_DIR}/elf/utils/libelf) +include_directories(${VDI_DIR}/elf/utils/common) +#include_directories(${VDI_DIR}/compiler/tools) if(UNIX) set(ADDITIONAL_LIBRARIES glibc_functions.cpp) @@ -47,7 +55,7 @@ else() set(ADDITIONAL_LIBRARIES "") endif() -add_library(amdocl64 SHARED +add_library(amdocl64_obj OBJECT cl_memobj.cpp cl_program.cpp cl_sdi_amd.cpp @@ -73,12 +81,23 @@ add_library(amdocl64 SHARED cl_context.cpp cl_profile_amd.cpp cl_p2p_amd.cpp - $ - $ + # $ + #$ ${ADDITIONAL_LIBRARIES} ) -if(${USE_COMGR_LIBRARY} MATCHES "yes") - target_link_libraries(amdocl64 oclelf pthread dl ${ROCT_LIBRARIES} ${ROCR_LIBRARIES}) -else() - target_link_libraries(amdocl64 opencl_driver oclelf pthread dl ${ROCT_LIBRARIES} ${ROCR_LIBRARIES}) -endif() + +add_library(amdocl64 SHARED + $ +) +add_library(amdocl64_static STATIC + $ +) + +add_library(amdvdi_static STATIC IMPORTED) +set_target_properties(amdvdi_static PROPERTIES IMPORTED_LOCATION "${LIBVDI_STATIC_DIR}/libamdvdi_static.a") + +#add_library(oclelf STATIC IMPORTED) +#set_target_properties(oclelf PROPERTIES IMPORTED_LOCATION "${LIBOCLELF_STATIC_PATH}/liboclelf.a") +target_link_libraries(amdocl64_static amdvdi_static pthread dl ${ROCT_LIBRARIES} ${ROCR_LIBRARIES}) + +target_link_libraries(amdocl64 amdvdi_static pthread dl ${ROCT_LIBRARIES} ${ROCR_LIBRARIES}) diff --git a/opencl/api/opencl/amdocl/amdocl.def.in b/opencl/amdocl/amdocl.def.in similarity index 98% rename from opencl/api/opencl/amdocl/amdocl.def.in rename to opencl/amdocl/amdocl.def.in index 78df2030fd..650c3ff7fa 100644 --- a/opencl/api/opencl/amdocl/amdocl.def.in +++ b/opencl/amdocl/amdocl.def.in @@ -172,5 +172,3 @@ aclDumpBinary #if (OPENCL_MAJOR > 2) || (OPENCL_MAJOR == 2 && OPENCL_MINOR >= 1) clCreateProgramWithIL #endif -#if !defined(OPENCL_MAINLINE) -#endif diff --git a/opencl/api/opencl/amdocl/amdocl.map b/opencl/amdocl/amdocl.map similarity index 100% rename from opencl/api/opencl/amdocl/amdocl.map rename to opencl/amdocl/amdocl.map diff --git a/opencl/api/opencl/amdocl/amdocl.map.in b/opencl/amdocl/amdocl.map.in similarity index 100% rename from opencl/api/opencl/amdocl/amdocl.map.in rename to opencl/amdocl/amdocl.map.in diff --git a/opencl/api/opencl/amdocl/amdocl.rc b/opencl/amdocl/amdocl.rc similarity index 100% rename from opencl/api/opencl/amdocl/amdocl.rc rename to opencl/amdocl/amdocl.rc diff --git a/opencl/api/opencl/amdocl/cl_agent_amd.h b/opencl/amdocl/cl_agent_amd.h similarity index 100% rename from opencl/api/opencl/amdocl/cl_agent_amd.h rename to opencl/amdocl/cl_agent_amd.h diff --git a/opencl/api/opencl/amdocl/cl_command.cpp b/opencl/amdocl/cl_command.cpp similarity index 100% rename from opencl/api/opencl/amdocl/cl_command.cpp rename to opencl/amdocl/cl_command.cpp diff --git a/opencl/api/opencl/amdocl/cl_common.hpp b/opencl/amdocl/cl_common.hpp similarity index 100% rename from opencl/api/opencl/amdocl/cl_common.hpp rename to opencl/amdocl/cl_common.hpp diff --git a/opencl/api/opencl/amdocl/cl_context.cpp b/opencl/amdocl/cl_context.cpp similarity index 100% rename from opencl/api/opencl/amdocl/cl_context.cpp rename to opencl/amdocl/cl_context.cpp diff --git a/opencl/api/opencl/amdocl/cl_counter.cpp b/opencl/amdocl/cl_counter.cpp similarity index 100% rename from opencl/api/opencl/amdocl/cl_counter.cpp rename to opencl/amdocl/cl_counter.cpp diff --git a/opencl/api/opencl/amdocl/cl_d3d10.cpp b/opencl/amdocl/cl_d3d10.cpp similarity index 100% rename from opencl/api/opencl/amdocl/cl_d3d10.cpp rename to opencl/amdocl/cl_d3d10.cpp diff --git a/opencl/api/opencl/amdocl/cl_d3d10_amd.hpp b/opencl/amdocl/cl_d3d10_amd.hpp similarity index 100% rename from opencl/api/opencl/amdocl/cl_d3d10_amd.hpp rename to opencl/amdocl/cl_d3d10_amd.hpp diff --git a/opencl/api/opencl/amdocl/cl_d3d11.cpp b/opencl/amdocl/cl_d3d11.cpp similarity index 100% rename from opencl/api/opencl/amdocl/cl_d3d11.cpp rename to opencl/amdocl/cl_d3d11.cpp diff --git a/opencl/api/opencl/amdocl/cl_d3d11_amd.hpp b/opencl/amdocl/cl_d3d11_amd.hpp similarity index 100% rename from opencl/api/opencl/amdocl/cl_d3d11_amd.hpp rename to opencl/amdocl/cl_d3d11_amd.hpp diff --git a/opencl/api/opencl/amdocl/cl_d3d9.cpp b/opencl/amdocl/cl_d3d9.cpp similarity index 100% rename from opencl/api/opencl/amdocl/cl_d3d9.cpp rename to opencl/amdocl/cl_d3d9.cpp diff --git a/opencl/api/opencl/amdocl/cl_d3d9_amd.hpp b/opencl/amdocl/cl_d3d9_amd.hpp similarity index 100% rename from opencl/api/opencl/amdocl/cl_d3d9_amd.hpp rename to opencl/amdocl/cl_d3d9_amd.hpp diff --git a/opencl/api/opencl/amdocl/cl_debugger_amd.cpp b/opencl/amdocl/cl_debugger_amd.cpp similarity index 100% rename from opencl/api/opencl/amdocl/cl_debugger_amd.cpp rename to opencl/amdocl/cl_debugger_amd.cpp diff --git a/opencl/api/opencl/amdocl/cl_debugger_amd.h b/opencl/amdocl/cl_debugger_amd.h similarity index 100% rename from opencl/api/opencl/amdocl/cl_debugger_amd.h rename to opencl/amdocl/cl_debugger_amd.h diff --git a/opencl/api/opencl/amdocl/cl_device.cpp b/opencl/amdocl/cl_device.cpp similarity index 99% rename from opencl/api/opencl/amdocl/cl_device.cpp rename to opencl/amdocl/cl_device.cpp index 8bc2301e62..156004e69d 100644 --- a/opencl/api/opencl/amdocl/cl_device.cpp +++ b/opencl/amdocl/cl_device.cpp @@ -111,7 +111,7 @@ RUNTIME_ENTRY(cl_int, clGetPlatformInfo, value = "Advanced Micro Devices, Inc."; break; case CL_PLATFORM_EXTENSIONS: - value = "cl_khr_icd " NOT_MAINLINE("cl_amd_object_metadata ") + value = "cl_khr_icd " #ifdef _WIN32 "cl_khr_d3d10_sharing " "cl_khr_d3d11_sharing " diff --git a/opencl/api/opencl/amdocl/cl_event.cpp b/opencl/amdocl/cl_event.cpp similarity index 100% rename from opencl/api/opencl/amdocl/cl_event.cpp rename to opencl/amdocl/cl_event.cpp diff --git a/opencl/api/opencl/amdocl/cl_execute.cpp b/opencl/amdocl/cl_execute.cpp similarity index 100% rename from opencl/api/opencl/amdocl/cl_execute.cpp rename to opencl/amdocl/cl_execute.cpp diff --git a/opencl/api/opencl/amdocl/cl_gl.cpp b/opencl/amdocl/cl_gl.cpp similarity index 100% rename from opencl/api/opencl/amdocl/cl_gl.cpp rename to opencl/amdocl/cl_gl.cpp diff --git a/opencl/api/opencl/amdocl/cl_gl_amd.hpp b/opencl/amdocl/cl_gl_amd.hpp similarity index 100% rename from opencl/api/opencl/amdocl/cl_gl_amd.hpp rename to opencl/amdocl/cl_gl_amd.hpp diff --git a/opencl/api/opencl/amdocl/cl_icd.cpp b/opencl/amdocl/cl_icd.cpp similarity index 100% rename from opencl/api/opencl/amdocl/cl_icd.cpp rename to opencl/amdocl/cl_icd.cpp diff --git a/opencl/api/opencl/amdocl/cl_icd_amd.h b/opencl/amdocl/cl_icd_amd.h similarity index 100% rename from opencl/api/opencl/amdocl/cl_icd_amd.h rename to opencl/amdocl/cl_icd_amd.h diff --git a/opencl/api/opencl/amdocl/cl_kernel.h b/opencl/amdocl/cl_kernel.h similarity index 100% rename from opencl/api/opencl/amdocl/cl_kernel.h rename to opencl/amdocl/cl_kernel.h diff --git a/opencl/api/opencl/amdocl/cl_kernel_info_amd.cpp b/opencl/amdocl/cl_kernel_info_amd.cpp similarity index 100% rename from opencl/api/opencl/amdocl/cl_kernel_info_amd.cpp rename to opencl/amdocl/cl_kernel_info_amd.cpp diff --git a/opencl/api/opencl/amdocl/cl_kernel_info_amd.h b/opencl/amdocl/cl_kernel_info_amd.h similarity index 100% rename from opencl/api/opencl/amdocl/cl_kernel_info_amd.h rename to opencl/amdocl/cl_kernel_info_amd.h diff --git a/opencl/api/opencl/amdocl/cl_lqdflash_amd.cpp b/opencl/amdocl/cl_lqdflash_amd.cpp similarity index 100% rename from opencl/api/opencl/amdocl/cl_lqdflash_amd.cpp rename to opencl/amdocl/cl_lqdflash_amd.cpp diff --git a/opencl/api/opencl/amdocl/cl_lqdflash_amd.h b/opencl/amdocl/cl_lqdflash_amd.h similarity index 100% rename from opencl/api/opencl/amdocl/cl_lqdflash_amd.h rename to opencl/amdocl/cl_lqdflash_amd.h diff --git a/opencl/api/opencl/amdocl/cl_memobj.cpp b/opencl/amdocl/cl_memobj.cpp similarity index 100% rename from opencl/api/opencl/amdocl/cl_memobj.cpp rename to opencl/amdocl/cl_memobj.cpp diff --git a/opencl/api/opencl/amdocl/cl_object.cpp b/opencl/amdocl/cl_object.cpp similarity index 100% rename from opencl/api/opencl/amdocl/cl_object.cpp rename to opencl/amdocl/cl_object.cpp diff --git a/opencl/api/opencl/amdocl/cl_p2p_amd.cpp b/opencl/amdocl/cl_p2p_amd.cpp similarity index 100% rename from opencl/api/opencl/amdocl/cl_p2p_amd.cpp rename to opencl/amdocl/cl_p2p_amd.cpp diff --git a/opencl/api/opencl/amdocl/cl_p2p_amd.h b/opencl/amdocl/cl_p2p_amd.h similarity index 100% rename from opencl/api/opencl/amdocl/cl_p2p_amd.h rename to opencl/amdocl/cl_p2p_amd.h diff --git a/opencl/api/opencl/amdocl/cl_pipe.cpp b/opencl/amdocl/cl_pipe.cpp similarity index 100% rename from opencl/api/opencl/amdocl/cl_pipe.cpp rename to opencl/amdocl/cl_pipe.cpp diff --git a/opencl/api/opencl/amdocl/cl_platform_amd.cpp b/opencl/amdocl/cl_platform_amd.cpp similarity index 100% rename from opencl/api/opencl/amdocl/cl_platform_amd.cpp rename to opencl/amdocl/cl_platform_amd.cpp diff --git a/opencl/api/opencl/amdocl/cl_platform_amd.h b/opencl/amdocl/cl_platform_amd.h similarity index 100% rename from opencl/api/opencl/amdocl/cl_platform_amd.h rename to opencl/amdocl/cl_platform_amd.h diff --git a/opencl/api/opencl/amdocl/cl_profile_amd.cpp b/opencl/amdocl/cl_profile_amd.cpp similarity index 100% rename from opencl/api/opencl/amdocl/cl_profile_amd.cpp rename to opencl/amdocl/cl_profile_amd.cpp diff --git a/opencl/api/opencl/amdocl/cl_profile_amd.h b/opencl/amdocl/cl_profile_amd.h similarity index 100% rename from opencl/api/opencl/amdocl/cl_profile_amd.h rename to opencl/amdocl/cl_profile_amd.h diff --git a/opencl/api/opencl/amdocl/cl_program.cpp b/opencl/amdocl/cl_program.cpp similarity index 100% rename from opencl/api/opencl/amdocl/cl_program.cpp rename to opencl/amdocl/cl_program.cpp diff --git a/opencl/api/opencl/amdocl/cl_sampler.cpp b/opencl/amdocl/cl_sampler.cpp similarity index 100% rename from opencl/api/opencl/amdocl/cl_sampler.cpp rename to opencl/amdocl/cl_sampler.cpp diff --git a/opencl/api/opencl/amdocl/cl_sdi_amd.cpp b/opencl/amdocl/cl_sdi_amd.cpp similarity index 100% rename from opencl/api/opencl/amdocl/cl_sdi_amd.cpp rename to opencl/amdocl/cl_sdi_amd.cpp diff --git a/opencl/api/opencl/amdocl/cl_sdi_amd.h b/opencl/amdocl/cl_sdi_amd.h similarity index 100% rename from opencl/api/opencl/amdocl/cl_sdi_amd.h rename to opencl/amdocl/cl_sdi_amd.h diff --git a/opencl/api/opencl/amdocl/cl_semaphore_amd.h b/opencl/amdocl/cl_semaphore_amd.h similarity index 100% rename from opencl/api/opencl/amdocl/cl_semaphore_amd.h rename to opencl/amdocl/cl_semaphore_amd.h diff --git a/opencl/api/opencl/amdocl/cl_svm.cpp b/opencl/amdocl/cl_svm.cpp similarity index 100% rename from opencl/api/opencl/amdocl/cl_svm.cpp rename to opencl/amdocl/cl_svm.cpp diff --git a/opencl/api/opencl/amdocl/cl_thread_trace_amd.cpp b/opencl/amdocl/cl_thread_trace_amd.cpp similarity index 100% rename from opencl/api/opencl/amdocl/cl_thread_trace_amd.cpp rename to opencl/amdocl/cl_thread_trace_amd.cpp diff --git a/opencl/api/opencl/amdocl/cl_thread_trace_amd.h b/opencl/amdocl/cl_thread_trace_amd.h similarity index 100% rename from opencl/api/opencl/amdocl/cl_thread_trace_amd.h rename to opencl/amdocl/cl_thread_trace_amd.h diff --git a/opencl/amdocl/cmake/modules/FindROCR.cmake b/opencl/amdocl/cmake/modules/FindROCR.cmake new file mode 100644 index 0000000000..2b198dcf8f --- /dev/null +++ b/opencl/amdocl/cmake/modules/FindROCR.cmake @@ -0,0 +1,16 @@ +# Try to find ROCR (Radeon Open Compute Runtime) +# +# Once found, this will define: +# - ROCR_FOUND - ROCR status (found or not found) +# - ROCR_INCLUDES - Required ROCR include directories +# - ROCR_LIBRARIES - Required ROCR libraries +find_path(FIND_ROCR_INCLUDES hsa.h HINTS /opt/rocm/include /opt/rocm/hsa/include PATH_SUFFIXES hsa) +find_library(FIND_ROCR_LIBRARIES hsa-runtime64 HINTS /opt/rocm/lib /opt/rocm/hsa/lib) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(ROCR DEFAULT_MSG + FIND_ROCR_INCLUDES FIND_ROCR_LIBRARIES) +mark_as_advanced(FIND_ROCR_INCLUDES FIND_ROCR_LIBRARIES) + +set(ROCR_INCLUDES ${FIND_ROCR_INCLUDES}) +set(ROCR_LIBRARIES ${FIND_ROCR_LIBRARIES}) diff --git a/opencl/amdocl/cmake/modules/FindROCT.cmake b/opencl/amdocl/cmake/modules/FindROCT.cmake new file mode 100644 index 0000000000..37f08fcff7 --- /dev/null +++ b/opencl/amdocl/cmake/modules/FindROCT.cmake @@ -0,0 +1,16 @@ +# Try to find ROCT (Radeon Open Compute Thunk) +# +# Once found, this will define: +# - ROCT_FOUND - ROCT status (found or not found) +# - ROCT_INCLUDES - Required ROCT include directories +# - ROCT_LIBRARIES - Required ROCT libraries +find_path(FIND_ROCT_INCLUDES hsakmt.h HINTS /opt/rocm/include) +find_library(FIND_ROCT_LIBRARIES hsakmt HINTS /opt/rocm/lib) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(ROCT DEFAULT_MSG + FIND_ROCT_INCLUDES FIND_ROCT_LIBRARIES) +mark_as_advanced(FIND_ROCT_INCLUDES FIND_ROCT_LIBRARIES) + +set(ROCT_INCLUDES ${FIND_ROCT_INCLUDES}) +set(ROCT_LIBRARIES ${FIND_ROCT_LIBRARIES}) diff --git a/opencl/amdocl/cmake/modules/bc2h.cmake b/opencl/amdocl/cmake/modules/bc2h.cmake new file mode 100644 index 0000000000..4b88abe87a --- /dev/null +++ b/opencl/amdocl/cmake/modules/bc2h.cmake @@ -0,0 +1,39 @@ +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/bc2h.c +"#include \n" +"int main(int argc, char **argv){\n" +" FILE *ifp, *ofp;\n" +" int c, i, l;\n" +" if (argc != 4) return 1;\n" +" ifp = fopen(argv[1], \"rb\");\n" +" if (!ifp) return 1;\n" +" i = fseek(ifp, 0, SEEK_END);\n" +" if (i < 0) return 1;\n" +" l = ftell(ifp);\n" +" if (l < 0) return 1;\n" +" i = fseek(ifp, 0, SEEK_SET);\n" +" if (i < 0) return 1;\n" +" ofp = fopen(argv[2], \"wb+\");\n" +" if (!ofp) return 1;\n" +" fprintf(ofp, \"#define %s_size %d\\n\\n\"\n" +" \"#if defined __GNUC__\\n\"\n" +" \"__attribute__((aligned (4096)))\\n\"\n" +" \"#elif defined _MSC_VER\\n\"\n" +" \"__declspec(align(4096))\\n\"\n" +" \"#endif\\n\"\n" +" \"static const unsigned char %s[%s_size+1] = {\",\n" +" argv[3], l,\n" +" argv[3], argv[3]);\n" +" i = 0;\n" +" while ((c = getc(ifp)) != EOF) {\n" +" if (0 == (i&7)) fprintf(ofp, \"\\n \");\n" +" fprintf(ofp, \" 0x%02x,\", c);\n" +" ++i;\n" +" }\n" +" fprintf(ofp, \" 0x00\\n};\\n\\n\");\n" +" fclose(ifp);\n" +" fclose(ofp);\n" +" return 0;\n" +"}\n" +) + +add_executable(bc2h ${CMAKE_CURRENT_BINARY_DIR}/bc2h.c) diff --git a/opencl/api/opencl/amdocl/gl_functions.hpp b/opencl/amdocl/gl_functions.hpp similarity index 100% rename from opencl/api/opencl/amdocl/gl_functions.hpp rename to opencl/amdocl/gl_functions.hpp diff --git a/opencl/api/opencl/amdocl/glibc_functions.cpp b/opencl/amdocl/glibc_functions.cpp similarity index 100% rename from opencl/api/opencl/amdocl/glibc_functions.cpp rename to opencl/amdocl/glibc_functions.cpp diff --git a/opencl/api/opencl/khronos/icd/loader/linux/icd_linux.c b/opencl/api/opencl/khronos/icd/loader/linux/icd_linux.c deleted file mode 100644 index b5f2959d9d..0000000000 --- a/opencl/api/opencl/khronos/icd/loader/linux/icd_linux.c +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Copyright (c) 2016 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software source and associated documentation files (the "Materials"), - * to deal in the Materials without restriction, including without limitation - * the rights to use, copy, modify, compile, merge, publish, distribute, - * sublicense, and/or sell copies of the Materials, and to permit persons to - * whom the Materials are furnished to do so, subject the following terms and - * conditions: - * - * All modifications to the Materials used to create a binary that is - * distributed to third parties shall be provided to Khronos with an - * unrestricted license to use for the purposes of implementing bug fixes and - * enhancements to the Materials; - * - * If the binary is used as part of an OpenCL(TM) implementation, whether binary - * is distributed together with or separately to that implementation, then - * recipient must become an OpenCL Adopter and follow the published OpenCL - * conformance process for that implementation, details at: - * http://www.khronos.org/conformance/; - * - * The above copyright notice, the OpenCL trademark license, and this permission - * notice shall be included in all copies or substantial portions of the - * Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN - * THE MATERIALS. - * - * OpenCL is a trademark of Apple Inc. used under license by Khronos. - */ - -#include "icd.h" -#include -#include -#include -#include -#include -#include -#include - -static pthread_once_t initialized = PTHREAD_ONCE_INIT; - -/* - * - * Vendor enumeration functions - * - */ - -// go through the list of vendors in the two configuration files -void khrIcdOsVendorsEnumerate(void) -{ - DIR *dir = NULL; - struct dirent *dirEntry = NULL; - char *vendorPath; - - vendorPath = getenv("OPENCL_VENDOR_PATH"); - if (vendorPath == NULL) - { -#ifdef __ANDROID__ - vendorPath = "/system/vendor/Khronos/OpenCL/vendors/"; -#else - vendorPath = "/etc/OpenCL/vendors/"; -#endif // ANDROID - } - - // open the directory - dir = opendir(vendorPath); - if (NULL == dir) - { - KHR_ICD_TRACE("Failed to open path %s\n", vendorPath); - goto Cleanup; - } - - // attempt to load all files in the directory - for (dirEntry = readdir(dir); dirEntry; dirEntry = readdir(dir) ) - { - switch(dirEntry->d_type) - { - case DT_UNKNOWN: - case DT_REG: - case DT_LNK: - { - const char* extension = ".icd"; - FILE *fin = NULL; - char* fileName = NULL; - char* buffer = NULL; - long bufferSize = 0; - - // make sure the file name ends in .icd - if (strlen(extension) > strlen(dirEntry->d_name) ) - { - break; - } - if (strcmp(dirEntry->d_name + strlen(dirEntry->d_name) - strlen(extension), extension) ) - { - break; - } - - // allocate space for the full path of the vendor library name - fileName = malloc(strlen(dirEntry->d_name) + 1 + strlen(vendorPath) + 1); - if (!fileName) - { - KHR_ICD_TRACE("Failed allocate space for ICD file path\n"); - break; - } - sprintf(fileName, "%s/%s", vendorPath, dirEntry->d_name); - - // open the file and read its contents - fin = fopen(fileName, "r"); - if (!fin) - { - free(fileName); - break; - } - fseek(fin, 0, SEEK_END); - bufferSize = ftell(fin); - - buffer = malloc(bufferSize+1); - if (!buffer) - { - free(fileName); - fclose(fin); - break; - } - memset(buffer, 0, bufferSize+1); - fseek(fin, 0, SEEK_SET); - if (bufferSize != (long)fread(buffer, 1, bufferSize, fin) ) - { - free(fileName); - free(buffer); - fclose(fin); - break; - } - // ignore a newline at the end of the file - if (buffer[bufferSize-1] == '\n') buffer[bufferSize-1] = '\0'; - - // load the string read from the file - khrIcdVendorAdd(buffer); - - free(fileName); - free(buffer); - fclose(fin); - } - break; - default: - break; - } - } - -Cleanup: - - // free resources and exit - if (dir) - { - closedir(dir); - } - - KHRicdVendor *vendorIterator; - for (vendorIterator = khrIcdVendors; vendorIterator; vendorIterator = vendorIterator->next) - { - if (vendorIterator->libName != NULL) - { - free(vendorIterator->libName); - vendorIterator->libName = NULL; - } - } -} - -// go through the list of vendors only once -void khrIcdOsVendorsEnumerateOnce(void) -{ - pthread_once(&initialized, khrIcdOsVendorsEnumerate); -} - -/* - * - * Dynamic library loading functions - * - */ - -// dynamically load a library. returns NULL on failure -void *khrIcdOsLibraryLoad(const char *libraryName) -{ - return dlopen (libraryName, RTLD_NOW); -} - -// get a function pointer from a loaded library. returns NULL on failure. -void *khrIcdOsLibraryGetFunctionAddress(void *library, const char *functionName) -{ - return dlsym(library, functionName); -} - -// unload a library -void khrIcdOsLibraryUnload(void *library) -{ - dlclose(library); -} - diff --git a/opencl/api/opencl/khronos/icd/loader/windows/OpenCL.rc b/opencl/api/opencl/khronos/icd/loader/windows/OpenCL.rc deleted file mode 100644 index 16914f4f53..0000000000 --- a/opencl/api/opencl/khronos/icd/loader/windows/OpenCL.rc +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2016 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software source and associated documentation files (the "Materials"), - * to deal in the Materials without restriction, including without limitation - * the rights to use, copy, modify, compile, merge, publish, distribute, - * sublicense, and/or sell copies of the Materials, and to permit persons to - * whom the Materials are furnished to do so, subject the following terms and - * conditions: - * - * All modifications to the Materials used to create a binary that is - * distributed to third parties shall be provided to Khronos with an - * unrestricted license to use for the purposes of implementing bug fixes and - * enhancements to the Materials; - * - * If the binary is used as part of an OpenCL(TM) implementation, whether binary - * is distributed together with or separately to that implementation, then - * recipient must become an OpenCL Adopter and follow the published OpenCL - * conformance process for that implementation, details at: - * http://www.khronos.org/conformance/; - * - * The above copyright notice, the OpenCL trademark license, and this permission - * notice shall be included in all copies or substantial portions of the - * Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN - * THE MATERIALS. - * - * OpenCL is a trademark of Apple Inc. used under license by Khronos. - */ - -#include - -#ifdef RC_INVOKED - -VS_VERSION_INFO VERSIONINFO -FILEVERSION 2,2,1,0 -PRODUCTVERSION 2,2,1,0 -FILETYPE VFT_DLL - -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904E4" - BEGIN - VALUE "FileDescription" ,"OpenCL Client DLL" - VALUE "ProductName" ,"Khronos OpenCL ICD" - VALUE "LegalCopyright" ,"Copyright \251 The Khronos Group Inc 2016" - VALUE "FileVersion" ,"2.2.1.0" - VALUE "CompanyName" ,"Khronos Group" - VALUE "InternalName" ,"OpenCL" - VALUE "OriginalFilename","OpenCL.dll" - END - END - - BLOCK "VarFileInfo" - BEGIN - // extend this line for localized versions - VALUE "Translation", 0x0409, 0x04E4 - END -END - -#endif - diff --git a/opencl/api/opencl/khronos/icd/loader/windows/icd_windows.c b/opencl/api/opencl/khronos/icd/loader/windows/icd_windows.c deleted file mode 100644 index 93f9df8ac0..0000000000 --- a/opencl/api/opencl/khronos/icd/loader/windows/icd_windows.c +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) 2016 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software source and associated documentation files (the "Materials"), - * to deal in the Materials without restriction, including without limitation - * the rights to use, copy, modify, compile, merge, publish, distribute, - * sublicense, and/or sell copies of the Materials, and to permit persons to - * whom the Materials are furnished to do so, subject the following terms and - * conditions: - * - * All modifications to the Materials used to create a binary that is - * distributed to third parties shall be provided to Khronos with an - * unrestricted license to use for the purposes of implementing bug fixes and - * enhancements to the Materials; - * - * If the binary is used as part of an OpenCL(TM) implementation, whether binary - * is distributed together with or separately to that implementation, then - * recipient must become an OpenCL Adopter and follow the published OpenCL - * conformance process for that implementation, details at: - * http://www.khronos.org/conformance/; - * - * The above copyright notice, the OpenCL trademark license, and this permission - * notice shall be included in all copies or substantial portions of the - * Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN - * THE MATERIALS. - * - * OpenCL is a trademark of Apple Inc. used under license by Khronos. - */ - -#include "icd.h" -#include "icd_windows_hkr.h" -#include "icd_windows_dxgk.h" -#include -#include -#include - -static INIT_ONCE initialized = INIT_ONCE_STATIC_INIT; - -/* - * - * Vendor enumeration functions - * - */ - -// go through the list of vendors in the registry and call khrIcdVendorAdd -// for each vendor encountered -BOOL CALLBACK khrIcdOsVendorsEnumerate(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *lpContext) -{ - LONG result; - const char* platformsName = "SOFTWARE\\Khronos\\OpenCL\\Vendors"; - HKEY platformsKey = NULL; - DWORD dwIndex; - - if (!khrIcdOsVendorsEnumerateDXGK()) - { - KHR_ICD_TRACE("Failed to load via DXGK interface on RS4, continuing\n"); - if (!khrIcdOsVendorsEnumerateHKR()) - { - KHR_ICD_TRACE("Failed to enumerate HKR entries, continuing\n"); - } - } - - KHR_ICD_TRACE("Opening key HKLM\\%s...\n", platformsName); - result = RegOpenKeyExA( - HKEY_LOCAL_MACHINE, - platformsName, - 0, - KEY_READ, - &platformsKey); - if (ERROR_SUCCESS != result) - { - KHR_ICD_TRACE("Failed to open platforms key %s, continuing\n", platformsName); - return FALSE; - } - - // for each value - for (dwIndex = 0;; ++dwIndex) - { - char cszLibraryName[1024] = {0}; - DWORD dwLibraryNameSize = sizeof(cszLibraryName); - DWORD dwLibraryNameType = 0; - DWORD dwValue = 0; - DWORD dwValueSize = sizeof(dwValue); - - // read the value name - KHR_ICD_TRACE("Reading value %d...\n", dwIndex); - result = RegEnumValueA( - platformsKey, - dwIndex, - cszLibraryName, - &dwLibraryNameSize, - NULL, - &dwLibraryNameType, - (LPBYTE)&dwValue, - &dwValueSize); - // if RegEnumKeyEx fails, we are done with the enumeration - if (ERROR_SUCCESS != result) - { - KHR_ICD_TRACE("Failed to read value %d, done reading key.\n", dwIndex); - break; - } - KHR_ICD_TRACE("Value %s found...\n", cszLibraryName); - - // Require that the value be a DWORD and equal zero - if (REG_DWORD != dwLibraryNameType) - { - KHR_ICD_TRACE("Value not a DWORD, skipping\n"); - continue; - } - if (dwValue) - { - KHR_ICD_TRACE("Value not zero, skipping\n"); - continue; - } - - // add the library - khrIcdVendorAdd(cszLibraryName); - } - - result = RegCloseKey(platformsKey); - if (ERROR_SUCCESS != result) - { - KHR_ICD_TRACE("Failed to close platforms key %s, ignoring\n", platformsName); - } - - KHRicdVendor *vendorIterator; - for (vendorIterator = khrIcdVendors; vendorIterator; vendorIterator = vendorIterator->next) - { - if (vendorIterator->libName != NULL) - { - free(vendorIterator->libName); - vendorIterator->libName = NULL; - } - } - - return TRUE; -} - -// go through the list of vendors only once -void khrIcdOsVendorsEnumerateOnce() -{ - InitOnceExecuteOnce(&initialized, khrIcdOsVendorsEnumerate, NULL, NULL); -} - -/* - * - * Dynamic library loading functions - * - */ - -// dynamically load a library. returns NULL on failure -void *khrIcdOsLibraryLoad(const char *libraryName) -{ - return (void *)LoadLibraryA(libraryName); -} - -// get a function pointer from a loaded library. returns NULL on failure. -void *khrIcdOsLibraryGetFunctionAddress(void *library, const char *functionName) -{ - if (!library || !functionName) - { - return NULL; - } - return GetProcAddress( (HMODULE)library, functionName); -} - -// unload a library. -void khrIcdOsLibraryUnload(void *library) -{ - FreeLibrary( (HMODULE)library); -} - diff --git a/opencl/api/opencl/khronos/icd/loader/windows/icd_windows_dxgk.c b/opencl/api/opencl/khronos/icd/loader/windows/icd_windows_dxgk.c deleted file mode 100644 index 4b5a2de842..0000000000 --- a/opencl/api/opencl/khronos/icd/loader/windows/icd_windows_dxgk.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2017 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software source and associated documentation files (the "Materials"), - * to deal in the Materials without restriction, including without limitation - * the rights to use, copy, modify, compile, merge, publish, distribute, - * sublicense, and/or sell copies of the Materials, and to permit persons to - * whom the Materials are furnished to do so, subject the following terms and - * conditions: - * - * All modifications to the Materials used to create a binary that is - * distributed to third parties shall be provided to Khronos with an - * unrestricted license to use for the purposes of implementing bug fixes and - * enhancements to the Materials; - * - * If the binary is used as part of an OpenCL(TM) implementation, whether binary - * is distributed together with or separately to that implementation, then - * recipient must become an OpenCL Adopter and follow the published OpenCL - * conformance process for that implementation, details at: - * http://www.khronos.org/conformance/; - * - * The above copyright notice, the OpenCL trademark license, and this permission - * notice shall be included in all copies or substantial portions of the - * Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN - * THE MATERIALS. - * - * OpenCL is a trademark of Apple Inc. used under license by Khronos. - */ - -#include "icd.h" -#include -#include "icd_windows_dxgk.h" -#include - -#ifndef NTSTATUS -typedef LONG NTSTATUS; -#define STATUS_SUCCESS ((NTSTATUS)0x00000000L) -#define STATUS_BUFFER_TOO_SMALL ((NTSTATUS)0xC0000023) -#define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0) -#endif - -#include "d3dkmthk.h" - -bool khrIcdOsVendorsEnumerateDXGK(void) -{ -#if defined(DXGKDDI_INTERFACE_VERSION_WDDM2_4) && (DXGKDDI_INTERFACE_VERSION >= DXGKDDI_INTERFACE_VERSION_WDDM2_4) - { - D3DKMT_ADAPTERINFO* pAdapterInfo; - D3DKMT_ENUMADAPTERS2 EnumAdapters; - NTSTATUS Status = STATUS_SUCCESS; - - // Get handle to GDI Runtime - HMODULE h = LoadLibrary("gdi32.dll"); - - char cszLibraryName[1024] = { 0 }; - EnumAdapters.NumAdapters = 0; - EnumAdapters.pAdapters = NULL; - PFND3DKMT_ENUMADAPTERS2 pEnumAdapters2 = (PFND3DKMT_ENUMADAPTERS2)GetProcAddress((HMODULE)h, "D3DKMTEnumAdapters2"); - if (!pEnumAdapters2) - { - FreeLibrary(h); - return FALSE; - } - Status = pEnumAdapters2(&EnumAdapters); - if (!NT_SUCCESS(Status) && (Status != STATUS_BUFFER_TOO_SMALL)) - { - FreeLibrary(h); - return FALSE; - } - pAdapterInfo = (D3DKMT_ADAPTERINFO*)malloc(sizeof(D3DKMT_ADAPTERINFO)*(EnumAdapters.NumAdapters)); - EnumAdapters.pAdapters = pAdapterInfo; - Status = pEnumAdapters2(&EnumAdapters); - if (!NT_SUCCESS(Status)) - { - FreeLibrary(h); - if (pAdapterInfo) free(pAdapterInfo); - return FALSE; - } - for (UINT AdapterIndex = 0; AdapterIndex < EnumAdapters.NumAdapters; AdapterIndex++) - { - D3DDDI_QUERYREGISTRY_INFO QueryArgs = {0}; - D3DDDI_QUERYREGISTRY_INFO* pQueryArgs = &QueryArgs; - D3DDDI_QUERYREGISTRY_INFO* pQueryBuffer = NULL; - QueryArgs.QueryType = D3DDDI_QUERYREGISTRY_ADAPTERKEY; - QueryArgs.QueryFlags.TranslatePath = TRUE; - QueryArgs.ValueType = REG_SZ; -#ifdef _WIN64 - wcscpy_s(QueryArgs.ValueName, ARRAYSIZE(L"OpenCLDriverName"), L"OpenCLDriverName"); -#else - wcscpy_s(QueryArgs.ValueName, ARRAYSIZE(L"OpenCLDriverNameWow"), L"OpenCLDriverNameWow"); -#endif - D3DKMT_QUERYADAPTERINFO QueryAdapterInfo = {0}; - QueryAdapterInfo.hAdapter = pAdapterInfo[AdapterIndex].hAdapter; - QueryAdapterInfo.Type = KMTQAITYPE_QUERYREGISTRY; - QueryAdapterInfo.pPrivateDriverData = &QueryArgs; - QueryAdapterInfo.PrivateDriverDataSize = sizeof(QueryArgs); - Status = D3DKMTQueryAdapterInfo(&QueryAdapterInfo); - if (!NT_SUCCESS(Status)) - { - FreeLibrary(h); - if (pAdapterInfo) free(pAdapterInfo); - return FALSE; - } - if (NT_SUCCESS(Status) && pQueryArgs->Status == D3DDDI_QUERYREGISTRY_STATUS_BUFFER_OVERFLOW) - { - unsigned int QueryBufferSize = sizeof(D3DDDI_QUERYREGISTRY_INFO) + QueryArgs.OutputValueSize; - pQueryBuffer = (D3DDDI_QUERYREGISTRY_INFO*)malloc(QueryBufferSize); - memcpy(pQueryBuffer, &QueryArgs, sizeof(D3DDDI_QUERYREGISTRY_INFO)); - QueryAdapterInfo.pPrivateDriverData = pQueryBuffer; - QueryAdapterInfo.PrivateDriverDataSize = QueryBufferSize; - Status = D3DKMTQueryAdapterInfo(&QueryAdapterInfo); - pQueryArgs = pQueryBuffer; - } - if (NT_SUCCESS(Status) && pQueryArgs->Status == D3DDDI_QUERYREGISTRY_STATUS_SUCCESS) - { - wchar_t* pWchar = pQueryArgs->OutputString; - unsigned int i = 0; - memset(cszLibraryName, 0, sizeof(cszLibraryName)); - { - while ((*pWchar != L'\0') && (i<1023)) - { - cszLibraryName[i] = (char)*pWchar; - i++; - pWchar++; - } - if (i < 1023) khrIcdVendorAdd(cszLibraryName); - } - } - if (pQueryBuffer) free(pQueryBuffer); - } - if (pAdapterInfo) free(pAdapterInfo); - FreeLibrary(h); - return TRUE; - } -#endif - return FALSE; -} diff --git a/opencl/api/opencl/khronos/icd/loader/windows/icd_windows_dxgk.h b/opencl/api/opencl/khronos/icd/loader/windows/icd_windows_dxgk.h deleted file mode 100644 index 8851815d0d..0000000000 --- a/opencl/api/opencl/khronos/icd/loader/windows/icd_windows_dxgk.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2017 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software source and associated documentation files (the "Materials"), - * to deal in the Materials without restriction, including without limitation - * the rights to use, copy, modify, compile, merge, publish, distribute, - * sublicense, and/or sell copies of the Materials, and to permit persons to - * whom the Materials are furnished to do so, subject the following terms and - * conditions: - * - * All modifications to the Materials used to create a binary that is - * distributed to third parties shall be provided to Khronos with an - * unrestricted license to use for the purposes of implementing bug fixes and - * enhancements to the Materials; - * - * If the binary is used as part of an OpenCL(TM) implementation, whether binary - * is distributed together with or separately to that implementation, then - * recipient must become an OpenCL Adopter and follow the published OpenCL - * conformance process for that implementation, details at: - * http://www.khronos.org/conformance/; - * - * The above copyright notice, the OpenCL trademark license, and this permission - * notice shall be included in all copies or substantial portions of the - * Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN - * THE MATERIALS. - * - * OpenCL is a trademark of Apple Inc. used under license by Khronos. - */ - -#include - -bool khrIcdOsVendorsEnumerateDXGK(void); diff --git a/opencl/api/opencl/khronos/icd/loader/windows/icd_windows_hkr.h b/opencl/api/opencl/khronos/icd/loader/windows/icd_windows_hkr.h deleted file mode 100644 index b10d15a579..0000000000 --- a/opencl/api/opencl/khronos/icd/loader/windows/icd_windows_hkr.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2017 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software source and associated documentation files (the "Materials"), - * to deal in the Materials without restriction, including without limitation - * the rights to use, copy, modify, compile, merge, publish, distribute, - * sublicense, and/or sell copies of the Materials, and to permit persons to - * whom the Materials are furnished to do so, subject the following terms and - * conditions: - * - * All modifications to the Materials used to create a binary that is - * distributed to third parties shall be provided to Khronos with an - * unrestricted license to use for the purposes of implementing bug fixes and - * enhancements to the Materials; - * - * If the binary is used as part of an OpenCL(TM) implementation, whether binary - * is distributed together with or separately to that implementation, then - * recipient must become an OpenCL Adopter and follow the published OpenCL - * conformance process for that implementation, details at: - * http://www.khronos.org/conformance/; - * - * The above copyright notice, the OpenCL trademark license, and this permission - * notice shall be included in all copies or substantial portions of the - * Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN - * THE MATERIALS. - * - * OpenCL is a trademark of Apple Inc. used under license by Khronos. - */ - -#include - -bool khrIcdOsVendorsEnumerateHKR(void); diff --git a/opencl/api/opencl/config/amdocl32.icd b/opencl/config/amdocl32.icd similarity index 100% rename from opencl/api/opencl/config/amdocl32.icd rename to opencl/config/amdocl32.icd diff --git a/opencl/api/opencl/config/amdocl64.icd b/opencl/config/amdocl64.icd similarity index 100% rename from opencl/api/opencl/config/amdocl64.icd rename to opencl/config/amdocl64.icd diff --git a/opencl/configure b/opencl/configure new file mode 100644 index 0000000000..e69de29bb2 diff --git a/opencl/api/opencl/khronos/headers/EGL/egl.h b/opencl/khronos/headers/EGL/egl.h similarity index 100% rename from opencl/api/opencl/khronos/headers/EGL/egl.h rename to opencl/khronos/headers/EGL/egl.h diff --git a/opencl/api/opencl/khronos/headers/EGL/eglext.h b/opencl/khronos/headers/EGL/eglext.h similarity index 100% rename from opencl/api/opencl/khronos/headers/EGL/eglext.h rename to opencl/khronos/headers/EGL/eglext.h diff --git a/opencl/api/opencl/khronos/headers/EGL/eglplatform.h b/opencl/khronos/headers/EGL/eglplatform.h similarity index 100% rename from opencl/api/opencl/khronos/headers/EGL/eglplatform.h rename to opencl/khronos/headers/EGL/eglplatform.h diff --git a/opencl/api/opencl/khronos/headers/GL/glext.h b/opencl/khronos/headers/GL/glext.h similarity index 100% rename from opencl/api/opencl/khronos/headers/GL/glext.h rename to opencl/khronos/headers/GL/glext.h diff --git a/opencl/api/opencl/khronos/headers/KHR/khrplatform.h b/opencl/khronos/headers/KHR/khrplatform.h similarity index 100% rename from opencl/api/opencl/khronos/headers/KHR/khrplatform.h rename to opencl/khronos/headers/KHR/khrplatform.h diff --git a/opencl/api/opencl/khronos/headers/opencl1.2/CL/cl.h b/opencl/khronos/headers/opencl1.2/CL/cl.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl1.2/CL/cl.h rename to opencl/khronos/headers/opencl1.2/CL/cl.h diff --git a/opencl/api/opencl/khronos/headers/opencl1.2/CL/cl.hpp b/opencl/khronos/headers/opencl1.2/CL/cl.hpp similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl1.2/CL/cl.hpp rename to opencl/khronos/headers/opencl1.2/CL/cl.hpp diff --git a/opencl/api/opencl/khronos/headers/opencl1.2/CL/cl_d3d10.h b/opencl/khronos/headers/opencl1.2/CL/cl_d3d10.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl1.2/CL/cl_d3d10.h rename to opencl/khronos/headers/opencl1.2/CL/cl_d3d10.h diff --git a/opencl/api/opencl/khronos/headers/opencl1.2/CL/cl_d3d11.h b/opencl/khronos/headers/opencl1.2/CL/cl_d3d11.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl1.2/CL/cl_d3d11.h rename to opencl/khronos/headers/opencl1.2/CL/cl_d3d11.h diff --git a/opencl/api/opencl/khronos/headers/opencl1.2/CL/cl_dx9_media_sharing.h b/opencl/khronos/headers/opencl1.2/CL/cl_dx9_media_sharing.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl1.2/CL/cl_dx9_media_sharing.h rename to opencl/khronos/headers/opencl1.2/CL/cl_dx9_media_sharing.h diff --git a/opencl/api/opencl/khronos/headers/opencl1.2/CL/cl_ext.h b/opencl/khronos/headers/opencl1.2/CL/cl_ext.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl1.2/CL/cl_ext.h rename to opencl/khronos/headers/opencl1.2/CL/cl_ext.h diff --git a/opencl/api/opencl/khronos/headers/opencl1.2/CL/cl_gl.h b/opencl/khronos/headers/opencl1.2/CL/cl_gl.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl1.2/CL/cl_gl.h rename to opencl/khronos/headers/opencl1.2/CL/cl_gl.h diff --git a/opencl/api/opencl/khronos/headers/opencl1.2/CL/cl_gl_ext.h b/opencl/khronos/headers/opencl1.2/CL/cl_gl_ext.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl1.2/CL/cl_gl_ext.h rename to opencl/khronos/headers/opencl1.2/CL/cl_gl_ext.h diff --git a/opencl/api/opencl/khronos/headers/opencl1.2/CL/cl_platform.h b/opencl/khronos/headers/opencl1.2/CL/cl_platform.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl1.2/CL/cl_platform.h rename to opencl/khronos/headers/opencl1.2/CL/cl_platform.h diff --git a/opencl/api/opencl/khronos/headers/opencl1.2/CL/opencl.h b/opencl/khronos/headers/opencl1.2/CL/opencl.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl1.2/CL/opencl.h rename to opencl/khronos/headers/opencl1.2/CL/opencl.h diff --git a/opencl/api/opencl/khronos/headers/opencl2.0/CL/cl.h b/opencl/khronos/headers/opencl2.0/CL/cl.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.0/CL/cl.h rename to opencl/khronos/headers/opencl2.0/CL/cl.h diff --git a/opencl/api/opencl/khronos/headers/opencl2.0/CL/cl.hpp b/opencl/khronos/headers/opencl2.0/CL/cl.hpp similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.0/CL/cl.hpp rename to opencl/khronos/headers/opencl2.0/CL/cl.hpp diff --git a/opencl/api/opencl/khronos/headers/opencl2.0/CL/cl2.hpp b/opencl/khronos/headers/opencl2.0/CL/cl2.hpp similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.0/CL/cl2.hpp rename to opencl/khronos/headers/opencl2.0/CL/cl2.hpp diff --git a/opencl/api/opencl/khronos/headers/opencl2.0/CL/cl_d3d10.h b/opencl/khronos/headers/opencl2.0/CL/cl_d3d10.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.0/CL/cl_d3d10.h rename to opencl/khronos/headers/opencl2.0/CL/cl_d3d10.h diff --git a/opencl/api/opencl/khronos/headers/opencl2.0/CL/cl_d3d11.h b/opencl/khronos/headers/opencl2.0/CL/cl_d3d11.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.0/CL/cl_d3d11.h rename to opencl/khronos/headers/opencl2.0/CL/cl_d3d11.h diff --git a/opencl/api/opencl/khronos/headers/opencl2.0/CL/cl_dx9_media_sharing.h b/opencl/khronos/headers/opencl2.0/CL/cl_dx9_media_sharing.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.0/CL/cl_dx9_media_sharing.h rename to opencl/khronos/headers/opencl2.0/CL/cl_dx9_media_sharing.h diff --git a/opencl/api/opencl/khronos/headers/opencl2.0/CL/cl_egl.h b/opencl/khronos/headers/opencl2.0/CL/cl_egl.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.0/CL/cl_egl.h rename to opencl/khronos/headers/opencl2.0/CL/cl_egl.h diff --git a/opencl/api/opencl/khronos/headers/opencl2.0/CL/cl_ext.h b/opencl/khronos/headers/opencl2.0/CL/cl_ext.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.0/CL/cl_ext.h rename to opencl/khronos/headers/opencl2.0/CL/cl_ext.h diff --git a/opencl/api/opencl/khronos/headers/opencl2.0/CL/cl_gl.h b/opencl/khronos/headers/opencl2.0/CL/cl_gl.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.0/CL/cl_gl.h rename to opencl/khronos/headers/opencl2.0/CL/cl_gl.h diff --git a/opencl/api/opencl/khronos/headers/opencl2.0/CL/cl_gl_ext.h b/opencl/khronos/headers/opencl2.0/CL/cl_gl_ext.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.0/CL/cl_gl_ext.h rename to opencl/khronos/headers/opencl2.0/CL/cl_gl_ext.h diff --git a/opencl/api/opencl/khronos/headers/opencl2.0/CL/cl_platform.h b/opencl/khronos/headers/opencl2.0/CL/cl_platform.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.0/CL/cl_platform.h rename to opencl/khronos/headers/opencl2.0/CL/cl_platform.h diff --git a/opencl/api/opencl/khronos/headers/opencl2.0/CL/opencl.h b/opencl/khronos/headers/opencl2.0/CL/opencl.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.0/CL/opencl.h rename to opencl/khronos/headers/opencl2.0/CL/opencl.h diff --git a/opencl/api/opencl/khronos/headers/opencl2.1/CL/cl.h b/opencl/khronos/headers/opencl2.1/CL/cl.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.1/CL/cl.h rename to opencl/khronos/headers/opencl2.1/CL/cl.h diff --git a/opencl/api/opencl/khronos/headers/opencl2.1/CL/cl.hpp b/opencl/khronos/headers/opencl2.1/CL/cl.hpp similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.1/CL/cl.hpp rename to opencl/khronos/headers/opencl2.1/CL/cl.hpp diff --git a/opencl/api/opencl/khronos/headers/opencl2.1/CL/cl2.hpp b/opencl/khronos/headers/opencl2.1/CL/cl2.hpp similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.1/CL/cl2.hpp rename to opencl/khronos/headers/opencl2.1/CL/cl2.hpp diff --git a/opencl/api/opencl/khronos/headers/opencl2.1/CL/cl_d3d10.h b/opencl/khronos/headers/opencl2.1/CL/cl_d3d10.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.1/CL/cl_d3d10.h rename to opencl/khronos/headers/opencl2.1/CL/cl_d3d10.h diff --git a/opencl/api/opencl/khronos/headers/opencl2.1/CL/cl_d3d11.h b/opencl/khronos/headers/opencl2.1/CL/cl_d3d11.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.1/CL/cl_d3d11.h rename to opencl/khronos/headers/opencl2.1/CL/cl_d3d11.h diff --git a/opencl/api/opencl/khronos/headers/opencl2.1/CL/cl_dx9_media_sharing.h b/opencl/khronos/headers/opencl2.1/CL/cl_dx9_media_sharing.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.1/CL/cl_dx9_media_sharing.h rename to opencl/khronos/headers/opencl2.1/CL/cl_dx9_media_sharing.h diff --git a/opencl/api/opencl/khronos/headers/opencl2.1/CL/cl_egl.h b/opencl/khronos/headers/opencl2.1/CL/cl_egl.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.1/CL/cl_egl.h rename to opencl/khronos/headers/opencl2.1/CL/cl_egl.h diff --git a/opencl/api/opencl/khronos/headers/opencl2.1/CL/cl_ext.h b/opencl/khronos/headers/opencl2.1/CL/cl_ext.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.1/CL/cl_ext.h rename to opencl/khronos/headers/opencl2.1/CL/cl_ext.h diff --git a/opencl/api/opencl/khronos/headers/opencl2.1/CL/cl_gl.h b/opencl/khronos/headers/opencl2.1/CL/cl_gl.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.1/CL/cl_gl.h rename to opencl/khronos/headers/opencl2.1/CL/cl_gl.h diff --git a/opencl/api/opencl/khronos/headers/opencl2.1/CL/cl_gl_ext.h b/opencl/khronos/headers/opencl2.1/CL/cl_gl_ext.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.1/CL/cl_gl_ext.h rename to opencl/khronos/headers/opencl2.1/CL/cl_gl_ext.h diff --git a/opencl/api/opencl/khronos/headers/opencl2.1/CL/cl_platform.h b/opencl/khronos/headers/opencl2.1/CL/cl_platform.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.1/CL/cl_platform.h rename to opencl/khronos/headers/opencl2.1/CL/cl_platform.h diff --git a/opencl/api/opencl/khronos/headers/opencl2.1/CL/opencl.h b/opencl/khronos/headers/opencl2.1/CL/opencl.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.1/CL/opencl.h rename to opencl/khronos/headers/opencl2.1/CL/opencl.h diff --git a/opencl/api/opencl/khronos/headers/opencl2.2/CL/cl.h b/opencl/khronos/headers/opencl2.2/CL/cl.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.2/CL/cl.h rename to opencl/khronos/headers/opencl2.2/CL/cl.h diff --git a/opencl/api/opencl/khronos/headers/opencl2.2/CL/cl.hpp b/opencl/khronos/headers/opencl2.2/CL/cl.hpp similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.2/CL/cl.hpp rename to opencl/khronos/headers/opencl2.2/CL/cl.hpp diff --git a/opencl/api/opencl/khronos/headers/opencl2.2/CL/cl2.hpp b/opencl/khronos/headers/opencl2.2/CL/cl2.hpp similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.2/CL/cl2.hpp rename to opencl/khronos/headers/opencl2.2/CL/cl2.hpp diff --git a/opencl/api/opencl/khronos/headers/opencl2.2/CL/cl_d3d10.h b/opencl/khronos/headers/opencl2.2/CL/cl_d3d10.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.2/CL/cl_d3d10.h rename to opencl/khronos/headers/opencl2.2/CL/cl_d3d10.h diff --git a/opencl/api/opencl/khronos/headers/opencl2.2/CL/cl_d3d11.h b/opencl/khronos/headers/opencl2.2/CL/cl_d3d11.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.2/CL/cl_d3d11.h rename to opencl/khronos/headers/opencl2.2/CL/cl_d3d11.h diff --git a/opencl/api/opencl/khronos/headers/opencl2.2/CL/cl_dx9_media_sharing.h b/opencl/khronos/headers/opencl2.2/CL/cl_dx9_media_sharing.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.2/CL/cl_dx9_media_sharing.h rename to opencl/khronos/headers/opencl2.2/CL/cl_dx9_media_sharing.h diff --git a/opencl/api/opencl/khronos/headers/opencl2.2/CL/cl_egl.h b/opencl/khronos/headers/opencl2.2/CL/cl_egl.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.2/CL/cl_egl.h rename to opencl/khronos/headers/opencl2.2/CL/cl_egl.h diff --git a/opencl/api/opencl/khronos/headers/opencl2.2/CL/cl_ext.h b/opencl/khronos/headers/opencl2.2/CL/cl_ext.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.2/CL/cl_ext.h rename to opencl/khronos/headers/opencl2.2/CL/cl_ext.h diff --git a/opencl/api/opencl/khronos/headers/opencl2.2/CL/cl_gl.h b/opencl/khronos/headers/opencl2.2/CL/cl_gl.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.2/CL/cl_gl.h rename to opencl/khronos/headers/opencl2.2/CL/cl_gl.h diff --git a/opencl/api/opencl/khronos/headers/opencl2.2/CL/cl_gl_ext.h b/opencl/khronos/headers/opencl2.2/CL/cl_gl_ext.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.2/CL/cl_gl_ext.h rename to opencl/khronos/headers/opencl2.2/CL/cl_gl_ext.h diff --git a/opencl/api/opencl/khronos/headers/opencl2.2/CL/cl_platform.h b/opencl/khronos/headers/opencl2.2/CL/cl_platform.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.2/CL/cl_platform.h rename to opencl/khronos/headers/opencl2.2/CL/cl_platform.h diff --git a/opencl/api/opencl/khronos/headers/opencl2.2/CL/opencl.h b/opencl/khronos/headers/opencl2.2/CL/opencl.h similarity index 100% rename from opencl/api/opencl/khronos/headers/opencl2.2/CL/opencl.h rename to opencl/khronos/headers/opencl2.2/CL/opencl.h diff --git a/opencl/khronos/icd/.appveyor.yml b/opencl/khronos/icd/.appveyor.yml new file mode 100644 index 0000000000..6b4f86a278 --- /dev/null +++ b/opencl/khronos/icd/.appveyor.yml @@ -0,0 +1,20 @@ +os: + - Visual Studio 2017 + #- Visual Studio 2015 + +platform: + - Win32 + - x64 + +configuration: + - Debug + - Release + +before_build: + - git clone --depth=1 https://github.com/KhronosGroup/OpenCL-Headers inc/OpenCL-Headers + - cmake -DOPENCL_ICD_LOADER_HEADERS_DIR=inc/OpenCL-Headers -H. -Bbuild -A%PLATFORM% + +build: + project: build\OPENCL_ICD_LOADER.sln + parallel: true + verbosity: normal diff --git a/opencl/khronos/icd/.gitignore b/opencl/khronos/icd/.gitignore new file mode 100644 index 0000000000..9bb7c139d7 --- /dev/null +++ b/opencl/khronos/icd/.gitignore @@ -0,0 +1,4 @@ +inc/CL/ +inc/EGL/ +inc/KHR/ +build/ diff --git a/opencl/khronos/icd/.travis.yml b/opencl/khronos/icd/.travis.yml new file mode 100644 index 0000000000..0f09d809e8 --- /dev/null +++ b/opencl/khronos/icd/.travis.yml @@ -0,0 +1,18 @@ +language: cpp + +compiler: + - gcc + #- clang + +os: + - linux + #- osx + +before_install: + - git clone https://github.com/KhronosGroup/OpenCL-Headers inc/OpenCL-Headers + +script: + - mkdir -p build + - cd build + - cmake -DOPENCL_ICD_LOADER_HEADERS_DIR=../inc/OpenCL-Headers .. + - make diff --git a/opencl/khronos/icd/CMakeLists.txt b/opencl/khronos/icd/CMakeLists.txt new file mode 100644 index 0000000000..21da30d17a --- /dev/null +++ b/opencl/khronos/icd/CMakeLists.txt @@ -0,0 +1,137 @@ +cmake_minimum_required (VERSION 2.8.11) + +project (OPENCL_ICD_LOADER) +include (GNUInstallDirs) +find_package (Threads REQUIRED) + +# The option below allows building the ICD Loader library as a shared library +# (ON, default) or a static library (OFF). +# +# Khronos OpenCL Working Group strongly recommends building and using the ICD +# loader as a shared library due to the following benefits: +# +# 1. The shared library can be updated independent of the application. This +# allows releasing new fixes and features in the ICD loader without updating +# the application. +# +# In rare cases when there are backward-incompatible changes to the ICD +# loader (due to platform requirements, for instance), using a shared +# library allows updating the library to make the transition seamless to +# installed applications. +# +# 2. On platforms that require the ICD mechanism there are multiple vendors +# shipping their OpenCL implementations. The vendor installers collaborate +# to make sure that the installed ICD shared library version is suitable for +# working with all vendor implementations installed on the system. +# +# If applications statically link to ICD Loader then that version of the ICD +# loader may not work with one or more installed vendor implementations. +# +# Using the OpenCL ICD loader as a static library is NOT recommended for +# end-user installations in general. However in some controlled environments it +# may be useful to simplify the build and distribution of the application. E.g. +# in test farms, or in cases where the end-user system configs are known in +# advance. Use it with discretion. +option (BUILD_SHARED_LIBS "Build shared libs" ON) + +include(CheckFunctionExists) +check_function_exists(secure_getenv HAVE_SECURE_GETENV) +check_function_exists(__secure_getenv HAVE___SECURE_GETENV) +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 + loader/icd.c + loader/icd.h + loader/icd_dispatch.c + loader/icd_dispatch.h + loader/icd_envvars.h + loader/icd_platform.h) + +if (WIN32) + list (APPEND OPENCL_ICD_LOADER_SOURCES + loader/windows/icd_windows.c + loader/windows/icd_windows_dxgk.c + loader/windows/icd_windows_dxgk.h + loader/windows/icd_windows_envvars.c + loader/windows/icd_windows_hkr.c + loader/windows/icd_windows_hkr.h + loader/windows/OpenCL.def + loader/windows/OpenCL.rc) + # Only add the DXSDK include directory if the environment variable is + # defined. Since the DXSDK has merged into the Windows SDK, this is + # only required in rare cases. + if (DEFINED ENV{DXSDK_DIR} AND NOT (MINGW OR MSYS OR CYGWIN)) + include_directories ($ENV{DXSDK_DIR}/Include) + endif () +else () + list (APPEND OPENCL_ICD_LOADER_SOURCES + loader/linux/icd_linux.c + loader/linux/icd_linux_envvars.c + loader/linux/icd_exports.map) +endif () + +set (OPENCL_ICD_LOADER_HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc CACHE PATH "Path to OpenCL Headers") + +add_library (OpenCL ${OPENCL_ICD_LOADER_SOURCES}) +set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1") + +if (WIN32) + target_link_libraries (OpenCL cfgmgr32.lib) + + option (OPENCL_ICD_LOADER_REQUIRE_WDK "Build with D3DKMT support, which requires the Windows WDK." ON) + if (OPENCL_ICD_LOADER_REQUIRE_WDK) + if(DEFINED ENV{WDKContentRoot}) + file(GLOB D3DKMT_HEADER "$ENV{WDKContentRoot}/Include/*/km/d3dkmthk.h") + else() + file(GLOB D3DKMT_HEADER "$ENV{HOMEDRIVE}/Program Files */Windows Kits/10/Include/*/km/d3dkmthk.h") + endif() + + if(D3DKMT_HEADER) + list(GET D3DKMT_HEADER -1 LATEST_D3DKMT_HEADER) + get_filename_component(WDK_DIRECTORY ${LATEST_D3DKMT_HEADER} DIRECTORY) + get_filename_component(WDK_DIRECTORY ${WDK_DIRECTORY} DIRECTORY) + message(STATUS "Found the Windows WDK in: ${WDK_DIRECTORY}") + target_compile_definitions(OpenCL PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK) + target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/um) + target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/km) + target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/shared) + else() + message(FATAL_ERROR "The Windows WDK was not found. Consider disabling OPENCL_ICD_LOADER_REQUIRE_WDK. Aborting.") + endif() + endif() + + if(NOT USE_DYNAMIC_VCXX_RUNTIME) + string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") + string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") + string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}") + string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}") + string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}") + string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") + string(REPLACE "/MDd" "/MTd" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") + string(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") + endif() +else() + if (APPLE) + target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT}) + else () + set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map") + target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT}) + endif () +endif () + +include_directories (${OPENCL_ICD_LOADER_HEADERS_DIR}) +add_definitions (-DCL_TARGET_OPENCL_VERSION=220) + +target_include_directories (OpenCL PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader) +target_link_libraries (OpenCL ${CMAKE_DL_LIBS}) + +include (CTest) +if (BUILD_TESTING) + add_subdirectory (test) +endif() + +install (TARGETS OpenCL + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/opencl/khronos/icd/CODE_OF_CONDUCT.md b/opencl/khronos/icd/CODE_OF_CONDUCT.md new file mode 100644 index 0000000000..a11610bd30 --- /dev/null +++ b/opencl/khronos/icd/CODE_OF_CONDUCT.md @@ -0,0 +1 @@ +A reminder that this issue tracker is managed by the Khronos Group. Interactions here should follow the Khronos Code of Conduct (https://www.khronos.org/developers/code-of-conduct), which prohibits aggressive or derogatory language. Please keep the discussion friendly and civil. diff --git a/opencl/khronos/icd/LICENSE b/opencl/khronos/icd/LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/opencl/khronos/icd/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/opencl/api/opencl/khronos/icd/LICENSE.txt b/opencl/khronos/icd/LICENSE.txt similarity index 100% rename from opencl/api/opencl/khronos/icd/LICENSE.txt rename to opencl/khronos/icd/LICENSE.txt diff --git a/opencl/khronos/icd/README.md b/opencl/khronos/icd/README.md new file mode 100644 index 0000000000..ee8499a606 --- /dev/null +++ b/opencl/khronos/icd/README.md @@ -0,0 +1,127 @@ +# OpenCL ICD Loader + +This repo contains the source code and tests for the Khronos official OpenCL ICD Loader. + +## CI Build Status + +[![Windows Build Status](https://ci.appveyor.com/api/projects/status/47uhjgp5h4de2f63/branch/master?svg=true)](https://ci.appveyor.com/project/Khronoswebmaster/opencl-icd-loader/branch/master) [![Linux OSX Build Status](https://travis-ci.com/KhronosGroup/opencl-icd-loader.svg?branch=master)](https://travis-ci.com/KhronosGroup/opencl-icd-loader) + +## Introduction + +OpenCL defines an *Installable Client Driver* (ICD) mechanism to allow developers to build applications against an *Installable Client Driver* loader (ICD loader) rather than linking their applications against a specific OpenCL implementation. +The ICD Loader is responsible for: + +* Exporting OpenCL API entry points +* Enumerating OpenCL implementations +* Forwarding OpenCL API calls to the correct implementation + +This repo contains the source code and tests for the Khronos official OpenCL ICD Loader. + +Note that this repo does not contain an OpenCL implementation (ICD). +You will need to obtain and install an OpenCL implementation for your OpenCL device that supports the OpenCL ICD extension `cl_khr_icd` to run an application using the OpenCL ICD Loader. + +The OpenCL *Installable Client Driver* extension (`cl_khr_icd`) is described in the OpenCL extensions specification, which may be found on the [Khronos OpenCL Registry](https://www.khronos.org/registry/OpenCL/). + +## Build Instructions + +### Dependencies + +The OpenCL ICD Loader requires OpenCL Headers. +To use system OpenCL Headers, please specify the OpenCL Header location using the CMake variable `OPENCL_ICD_LOADER_HEADERS_DIR`. +By default, the OpenCL ICD Loader will look for OpenCL Headers in the `inc` directory. + +By default, the OpenCL ICD Loader on Windows requires the Windows Driver Kit (WDK). +An OpenCL ICD Loader may be built without the Windows Driver Kit using the CMake variable `OPENCL_ICD_LOADER_REQUIRE_WDK`, however this option should be used with caution since it may prevent the OpenCL ICD Loader from enumerating some OpenCL implementations. +This dependency may be removed in the future. + +The OpenCL ICD Loader uses CMake for its build system. +If CMake is not provided by your build system or OS package manager, please consult the [CMake website](https://cmake.org). + +### Build and Install Directories + +A common convention is to place the `build` directory in the top directory of the repository and to place the `install` directory as a child of the `build` directory. +The remainder of these instructions follow this convention, although you may place these directories in any location. + +### Example Usage + +For most Windows and Linux usages, the following steps are sufficient to build the OpenCL ICD Loader: + +1. Clone this repo: + + git clone https://github.com/KhronosGroup/OpenCL-ICD-Loader + +1. Obtain the OpenCL Headers, if you are not planning to use system OpenCL headers. +Headers may be obtained from the [Khronos OpenCL Headers](https://github.com/KhronosGroup/OpenCL-Headers) repository. + +1. Create a `build` directory: + + cd OpenCL-ICD-Loader + mkdir build + cd build + +1. Invoke `cmake` to generate solution files, Makefiles, or files for other build systems. + + cmake .. + +1. Build using the CMake-generated files. + +Notes: + +* For 64-bit Windows builds, you may need to specify a 64-bit generator manually, for example: + + cmake.exe -G "Visual Studio 14 2015 Win64" .. + +* Some users may prefer to use a CMake GUI frontend, such as `cmake-gui` or `ccmake`, vs. the command-line CMake. + +## OpenCL ICD Loader Tests + +OpenCL ICD Loader Tests can be run using `ctest`, which is a companion to CMake. +The OpenCL ICD Loader Tests can also be run directly by executing icd_loader_test(.exe) executable from the bin folder. + +### Test Setup + +The OpenCL ICD Loader Tests use a "stub" ICD, which must be set up manually. +The OpenCL ICD Loader Tests will "fail" if the "stub" ICD is not set up correctly. +The method to install the "stub" ICD is operating system dependent. + +On Linux, install the "stub" ICD by creating a file with the full path to the "stub" ICD in `/etc/OpenCL/vendors`: + + echo full/path/to/libOpenCLDriverStub.so > /etc/OpenCL/vendors/test.icd + +On Windows, add the "stub" ICD by adding a `REG_DWORD` value to the registry keys: + + // For 32-bit operating systems, or 64-bit tests on a 64-bit operating system: + HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\OpenCL\Vendors + + // For 32-bit tests on a 64-bit operating system: + HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Khronos\OpenCL\Vendors + + // The name of the REG_DWORD value should be the full path to the "stub" ICD + // OpenCLDriverStub.dll, and the data for this value should be 0. + +### Running Tests + +To run the tests, invoke `ctest` from the `build` directory. +The CMake-generated build files may be able to invoke the OpenCL ICD Loader tests as well. + +### Test Cleanup + +Manually remove the file or registry keys added during Test Setup. + +## Support + +Please create a GitHub issue to report an issue or ask questions. + +## Contributing + +Contributions to the OpenCL ICD Loader are welcomed and encouraged. +You will be prompted with a one-time "click-through" CLA dialog as part of submitting your pull request or other contribution to GitHub. + +## Table of Debug Environment Variables + +The following debug environment variables are available for use with the OpenCL ICD loader: + +| Environment Variable | Behavior | Example Format | +|:---------------------------------:|---------------------|----------------------| +| OCL_ICD_FILENAMES | Specifies a list of additional ICDs to load. The ICDs will be enumerated first, before any ICDs discovered via default mechanisms. | `export OCL_ICD_FILENAMES=libVendorA.so:libVendorB.so`

`set OCL_ICD_FILENAMES=vendor_a.dll;vendor_b.dll` | +| OCL_ICD_VENDORS | On Linux and Android, specifies a directory to scan for ICDs to enumerate in place of the default `/etc/OpenCL/vendors'. | `export OCL_ICD_VENDORS=/my/local/icd/search/path` | diff --git a/opencl/khronos/icd/inc/README.txt b/opencl/khronos/icd/inc/README.txt new file mode 100644 index 0000000000..9209d44d1c --- /dev/null +++ b/opencl/khronos/icd/inc/README.txt @@ -0,0 +1,14 @@ +Copy or symlink OpenCL headers here, inside a CL directory, so that +the structure of the inc directory looks something like this: + +inc/CL/cl_d3d10.h +inc/CL/cl_d3d11.h +inc/CL/cl_dx9_media_sharing.h +inc/CL/cl_egl.h +inc/CL/cl_ext.h +inc/CL/cl_gl_ext.h +inc/CL/cl_gl.h +inc/CL/cl.h +inc/CL/cl.hpp +inc/CL/cl_platform.h +inc/CL/opencl.h diff --git a/opencl/api/opencl/khronos/icd/loader/icd.c b/opencl/khronos/icd/loader/icd.c similarity index 62% rename from opencl/api/opencl/khronos/icd/loader/icd.c rename to opencl/khronos/icd/loader/icd.c index 8405e5a5ab..ea8306ab1a 100644 --- a/opencl/api/opencl/khronos/icd/loader/icd.c +++ b/opencl/khronos/icd/loader/icd.c @@ -1,42 +1,24 @@ /* - * Copyright (c) 2016 The Khronos Group Inc. + * Copyright (c) 2016-2019 The Khronos Group Inc. * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software source and associated documentation files (the "Materials"), - * to deal in the Materials without restriction, including without limitation - * the rights to use, copy, modify, compile, merge, publish, distribute, - * sublicense, and/or sell copies of the Materials, and to permit persons to - * whom the Materials are furnished to do so, subject the following terms and - * conditions: + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * All modifications to the Materials used to create a binary that is - * distributed to third parties shall be provided to Khronos with an - * unrestricted license to use for the purposes of implementing bug fixes and - * enhancements to the Materials; + * http://www.apache.org/licenses/LICENSE-2.0 * - * If the binary is used as part of an OpenCL(TM) implementation, whether binary - * is distributed together with or separately to that implementation, then - * recipient must become an OpenCL Adopter and follow the published OpenCL - * conformance process for that implementation, details at: - * http://www.khronos.org/conformance/; - * - * The above copyright notice, the OpenCL trademark license, and this permission - * notice shall be included in all copies or substantial portions of the - * Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN - * THE MATERIALS. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * * OpenCL is a trademark of Apple Inc. used under license by Khronos. */ #include "icd.h" #include "icd_dispatch.h" +#include "icd_envvars.h" #include #include @@ -75,17 +57,6 @@ void khrIcdVendorAdd(const char *libraryName) goto Done; } - // get the library's file name - const char *libName = libraryName; - const char *c; - for (c = libraryName; *c; ++c) - { - if ((*c == '\\') || (*c == '/')) - { - libName = c + 1; - } - } - // ensure that we haven't already loaded this vendor for (vendorIterator = khrIcdVendors; vendorIterator; vendorIterator = vendorIterator->next) { @@ -94,11 +65,6 @@ void khrIcdVendorAdd(const char *libraryName) KHR_ICD_TRACE("already loaded vendor %s, nothing to do here\n", libraryName); goto Done; } - if (!strcmp(vendorIterator->libName, libName)) - { - KHR_ICD_TRACE("already loaded library %s, nothing to do here\n", libName); - goto Done; - } } // get the library's clGetExtensionFunctionAddress pointer @@ -196,8 +162,6 @@ void khrIcdVendorAdd(const char *libraryName) KHR_ICD_TRACE("failed get platform handle to library\n"); continue; } - vendor->libName = (char *)malloc(strlen(libName) + 1); - strcpy(vendor->libName, libName); vendor->clGetExtensionFunctionAddress = p_clGetExtensionFunctionAddress; vendor->platform = platforms[i]; vendor->suffix = suffix; @@ -205,23 +169,12 @@ void khrIcdVendorAdd(const char *libraryName) // add this vendor to the list of vendors at the tail { KHRicdVendor **prevNextPointer = NULL; - for (prevNextPointer = &khrIcdVendors; *prevNextPointer; prevNextPointer = &( (*prevNextPointer)->next) ) - { - if (!strcmp(vendor->suffix, (*prevNextPointer)->suffix)) { - free(suffix); - free(vendor); - vendor = NULL; - KHR_ICD_TRACE("already loaded vendor with suffix %s, nothing to do here\n", suffix); - break; - } - } - if (vendor) - { - *prevNextPointer = vendor; - KHR_ICD_TRACE("successfully added vendor %s with suffix %s\n", libraryName, suffix); - } + for (prevNextPointer = &khrIcdVendors; *prevNextPointer; prevNextPointer = &( (*prevNextPointer)->next) ); + *prevNextPointer = vendor; } + KHR_ICD_TRACE("successfully added vendor %s with suffix %s\n", libraryName, suffix); + } Done: @@ -236,22 +189,63 @@ Done: } } +// Get next file or dirname given a string list or registry key path. +// Note: the input string may be modified! +static char *loader_get_next_path(char *path) { + size_t len; + char *next; + + if (path == NULL) return NULL; + next = strchr(path, PATH_SEPARATOR); + if (next == NULL) { + len = strlen(path); + next = path + len; + } else { + *next = '\0'; + next++; + } + + return next; +} + +void khrIcdVendorsEnumerateEnv(void) +{ + char* icdFilenames = khrIcd_secure_getenv("OCL_ICD_FILENAMES"); + char* cur_file = NULL; + char* next_file = NULL; + if (icdFilenames) + { + KHR_ICD_TRACE("Found OCL_ICD_FILENAMES environment variable.\n"); + + next_file = icdFilenames; + while (NULL != next_file && *next_file != '\0') { + cur_file = next_file; + next_file = loader_get_next_path(cur_file); + + khrIcdVendorAdd(cur_file); + } + + khrIcd_free_getenv(icdFilenames); + } +} + void khrIcdContextPropertiesGetPlatform(const cl_context_properties *properties, cl_platform_id *outPlatform) { if (properties == NULL && khrIcdVendors != NULL) { *outPlatform = khrIcdVendors[0].platform; - return; } - - const cl_context_properties *property = (cl_context_properties *)NULL; - *outPlatform = NULL; - for (property = properties; property && property[0]; property += 2) + else { - if ((cl_context_properties)CL_CONTEXT_PLATFORM == property[0]) + const cl_context_properties *property = (cl_context_properties *)NULL; + *outPlatform = NULL; + for (property = properties; property && property[0]; property += 2) { - *outPlatform = (cl_platform_id)property[1]; - } + if ((cl_context_properties)CL_CONTEXT_PLATFORM == property[0]) + { + *outPlatform = (cl_platform_id)property[1]; + } + } } } diff --git a/opencl/api/opencl/khronos/icd/loader/icd.h b/opencl/khronos/icd/loader/icd.h similarity index 70% rename from opencl/api/opencl/khronos/icd/loader/icd.h rename to opencl/khronos/icd/loader/icd.h index bb8a985dab..34751e958c 100644 --- a/opencl/api/opencl/khronos/icd/loader/icd.h +++ b/opencl/khronos/icd/loader/icd.h @@ -1,36 +1,17 @@ /* - * Copyright (c) 2016 The Khronos Group Inc. + * Copyright (c) 2016-2019 The Khronos Group Inc. * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software source and associated documentation files (the "Materials"), - * to deal in the Materials without restriction, including without limitation - * the rights to use, copy, modify, compile, merge, publish, distribute, - * sublicense, and/or sell copies of the Materials, and to permit persons to - * whom the Materials are furnished to do so, subject the following terms and - * conditions: + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * All modifications to the Materials used to create a binary that is - * distributed to third parties shall be provided to Khronos with an - * unrestricted license to use for the purposes of implementing bug fixes and - * enhancements to the Materials; + * http://www.apache.org/licenses/LICENSE-2.0 * - * If the binary is used as part of an OpenCL(TM) implementation, whether binary - * is distributed together with or separately to that implementation, then - * recipient must become an OpenCL Adopter and follow the published OpenCL - * conformance process for that implementation, details at: - * http://www.khronos.org/conformance/; - * - * The above copyright notice, the OpenCL trademark license, and this permission - * notice shall be included in all copies or substantial portions of the - * Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN - * THE MATERIALS. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * * OpenCL is a trademark of Apple Inc. used under license by Khronos. */ @@ -38,6 +19,8 @@ #ifndef _ICD_H_ #define _ICD_H_ +#include "icd_platform.h" + #ifndef CL_USE_DEPRECATED_OPENCL_1_0_APIS #define CL_USE_DEPRECATED_OPENCL_1_0_APIS #endif @@ -53,10 +36,6 @@ #include #include -#ifdef _WIN32 -#include -#endif - /* * type definitions */ @@ -88,9 +67,6 @@ struct KHRicdVendorRec // the loaded library object (true type varies on Linux versus Windows) void *library; - // the file name of the library - char *libName; - // the extension suffix for this platform char *suffix; @@ -123,6 +99,9 @@ void khrIcdInitialize(void); // n.b, this call is OS-specific void khrIcdOsVendorsEnumerateOnce(void); +// read vendors from environment variables +void khrIcdVendorsEnumerateEnv(void); + // add a vendor's implementation to the list of libraries void khrIcdVendorAdd(const char *libraryName); diff --git a/opencl/khronos/icd/loader/icd_cmake_config.h.in b/opencl/khronos/icd/loader/icd_cmake_config.h.in new file mode 100644 index 0000000000..3bbc46127a --- /dev/null +++ b/opencl/khronos/icd/loader/icd_cmake_config.h.in @@ -0,0 +1,2 @@ +#cmakedefine HAVE_SECURE_GETENV +#cmakedefine HAVE___SECURE_GETENV diff --git a/opencl/api/opencl/khronos/icd/loader/icd_dispatch.c b/opencl/khronos/icd/loader/icd_dispatch.c similarity index 97% rename from opencl/api/opencl/khronos/icd/loader/icd_dispatch.c rename to opencl/khronos/icd/loader/icd_dispatch.c index c329cd62c0..df967cb902 100644 --- a/opencl/api/opencl/khronos/icd/loader/icd_dispatch.c +++ b/opencl/khronos/icd/loader/icd_dispatch.c @@ -1,36 +1,17 @@ /* - * Copyright (c) 2016 The Khronos Group Inc. + * Copyright (c) 2012-2019 The Khronos Group Inc. * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software source and associated documentation files (the "Materials"), - * to deal in the Materials without restriction, including without limitation - * the rights to use, copy, modify, compile, merge, publish, distribute, - * sublicense, and/or sell copies of the Materials, and to permit persons to - * whom the Materials are furnished to do so, subject the following terms and - * conditions: + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * All modifications to the Materials used to create a binary that is - * distributed to third parties shall be provided to Khronos with an - * unrestricted license to use for the purposes of implementing bug fixes and - * enhancements to the Materials; + * http://www.apache.org/licenses/LICENSE-2.0 * - * If the binary is used as part of an OpenCL(TM) implementation, whether binary - * is distributed together with or separately to that implementation, then - * recipient must become an OpenCL Adopter and follow the published OpenCL - * conformance process for that implementation, details at: - * http://www.khronos.org/conformance/; - * - * The above copyright notice, the OpenCL trademark license, and this permission - * notice shall be included in all copies or substantial portions of the - * Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN - * THE MATERIALS. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * * OpenCL is a trademark of Apple Inc. used under license by Khronos. */ @@ -1378,14 +1359,21 @@ CL_API_ENTRY void * CL_API_CALL clGetExtensionFunctionAddressForPlatform(cl_platform_id platform, const char * function_name) CL_API_SUFFIX__VERSION_1_2 { + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(function_name, NULL); + // make sure the ICD is initialized khrIcdInitialize(); // return any ICD-aware extensions + + // Most extensions, including multi-vendor KHR and EXT extensions, + // do not need to be ICD-aware and do not require any ICD loader + // modifications. The KHR and EXT extensions below were added for + // backwards compatibility only. #define CL_COMMON_EXTENSION_ENTRYPOINT_ADD(name) if (!strcmp(function_name, #name) ) return (void *)(size_t)&name - // Are these core or ext? This is unclear, but they appear to be - // independent from cl_khr_gl_sharing. + // Functions supporting the creation of OpenCL Memory Objects + // from OpenGL Objects (cl_apple_gl_sharing, cl_khr_gl_sharing) CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLBuffer); CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLTexture); CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLTexture2D); @@ -1440,10 +1428,12 @@ clGetExtensionFunctionAddressForPlatform(cl_platform_id platform, /* cl_khr_sub_groups */ CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetKernelSubGroupInfoKHR); - // fall back to vendor extension detection + #undef CL_COMMON_EXTENSION_ENTRYPOINT_ADD - // FIXME Now that we have a platform id here, we need to validate that it isn't NULL, so shouldn't we have an errcode_ret - // KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(platform, CL_INVALID_PLATFORM); + // This is not an ICD-aware extension, so call into the implementation + // to get the extension function address. + + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, NULL); return platform->dispatch->clGetExtensionFunctionAddressForPlatform( platform, function_name); @@ -1581,17 +1571,25 @@ clEnqueueBarrier(cl_command_queue command_queue) CL_EXT_SUFFIX__VERSION_1_1_DEPR CL_API_ENTRY void * CL_API_CALL clGetExtensionFunctionAddress(const char *function_name) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED { - size_t function_name_length = strlen(function_name); + size_t function_name_length = 0; KHRicdVendor* vendor = NULL; + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(function_name, NULL); + // make sure the ICD is initialized khrIcdInitialize(); + function_name_length = strlen(function_name); // return any ICD-aware extensions + + // Most extensions, including multi-vendor KHR and EXT extensions, + // do not need to be ICD-aware and do not require any ICD loader + // modifications. The KHR and EXT extensions below were added for + // backwards compatibility only. #define CL_COMMON_EXTENSION_ENTRYPOINT_ADD(name) if (!strcmp(function_name, #name) ) return (void *)(size_t)&name - // Are these core or ext? This is unclear, but they appear to be - // independent from cl_khr_gl_sharing. + // Functions supporting the creation of OpenCL Memory Objects + // from OpenGL Objects (cl_apple_gl_sharing, cl_khr_gl_sharing) CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLBuffer); CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLTexture); CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLTexture2D); @@ -1646,6 +1644,8 @@ clGetExtensionFunctionAddress(const char *function_name) CL_EXT_SUFFIX__VERSION_ /* cl_khr_sub_groups */ CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetKernelSubGroupInfoKHR); + #undef CL_COMMON_EXTENSION_ENTRYPOINT_ADD + // fall back to vendor extension detection for (vendor = khrIcdVendors; vendor; vendor = vendor->next) { @@ -1666,7 +1666,7 @@ clGetExtensionFunctionAddress(const char *function_name) CL_EXT_SUFFIX__VERSION_ CL_API_ENTRY cl_mem CL_API_CALL clCreateFromGLBuffer( cl_context context, cl_mem_flags flags, - GLuint bufobj, + cl_GLuint bufobj, int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 { KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); @@ -1698,9 +1698,9 @@ CL_API_ENTRY cl_mem CL_API_CALL clCreateFromGLTexture( CL_API_ENTRY cl_mem CL_API_CALL clCreateFromGLTexture2D( cl_context context, cl_mem_flags flags, - GLenum target, - GLint miplevel, - GLuint texture, + cl_GLenum target, + cl_GLint miplevel, + cl_GLuint texture, cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 { KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); @@ -1716,9 +1716,9 @@ CL_API_ENTRY cl_mem CL_API_CALL clCreateFromGLTexture2D( CL_API_ENTRY cl_mem CL_API_CALL clCreateFromGLTexture3D( cl_context context, cl_mem_flags flags, - GLenum target, - GLint miplevel, - GLuint texture, + cl_GLenum target, + cl_GLint miplevel, + cl_GLuint texture, cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 { KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); @@ -1734,7 +1734,7 @@ CL_API_ENTRY cl_mem CL_API_CALL clCreateFromGLTexture3D( CL_API_ENTRY cl_mem CL_API_CALL clCreateFromGLRenderbuffer( cl_context context, cl_mem_flags flags, - GLuint renderbuffer, + cl_GLuint renderbuffer, cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 { KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); @@ -1748,7 +1748,7 @@ CL_API_ENTRY cl_mem CL_API_CALL clCreateFromGLRenderbuffer( CL_API_ENTRY cl_int CL_API_CALL clGetGLObjectInfo( cl_mem memobj, cl_gl_object_type * gl_object_type, - GLuint * gl_object_name) CL_API_SUFFIX__VERSION_1_0 + cl_GLuint * gl_object_name) CL_API_SUFFIX__VERSION_1_0 { KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); return memobj->dispatch->clGetGLObjectInfo( diff --git a/opencl/api/opencl/khronos/icd/loader/icd_dispatch.h b/opencl/khronos/icd/loader/icd_dispatch.h similarity index 96% rename from opencl/api/opencl/khronos/icd/loader/icd_dispatch.h rename to opencl/khronos/icd/loader/icd_dispatch.h index 7bc54ac8a5..22af3354c6 100644 --- a/opencl/api/opencl/khronos/icd/loader/icd_dispatch.h +++ b/opencl/khronos/icd/loader/icd_dispatch.h @@ -1,36 +1,17 @@ /* - * Copyright (c) 2016 The Khronos Group Inc. + * Copyright (c) 2016-2019 The Khronos Group Inc. * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software source and associated documentation files (the "Materials"), - * to deal in the Materials without restriction, including without limitation - * the rights to use, copy, modify, compile, merge, publish, distribute, - * sublicense, and/or sell copies of the Materials, and to permit persons to - * whom the Materials are furnished to do so, subject the following terms and - * conditions: + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * All modifications to the Materials used to create a binary that is - * distributed to third parties shall be provided to Khronos with an - * unrestricted license to use for the purposes of implementing bug fixes and - * enhancements to the Materials; + * http://www.apache.org/licenses/LICENSE-2.0 * - * If the binary is used as part of an OpenCL(TM) implementation, whether binary - * is distributed together with or separately to that implementation, then - * recipient must become an OpenCL Adopter and follow the published OpenCL - * conformance process for that implementation, details at: - * http://www.khronos.org/conformance/; - * - * The above copyright notice, the OpenCL trademark license, and this permission - * notice shall be included in all copies or substantial portions of the - * Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN - * THE MATERIALS. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * * OpenCL is a trademark of Apple Inc. used under license by Khronos. */ @@ -66,11 +47,6 @@ #include #include #endif -#if !defined(__ANDROID__) -#include -#else -#include -#endif #include #include #include @@ -801,7 +777,7 @@ typedef CL_API_ENTRY void * (CL_API_CALL *KHRpfn_clGetExtensionFunctionAddress)( typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromGLBuffer)( cl_context context, cl_mem_flags flags, - GLuint bufobj, + cl_GLuint bufobj, int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromGLTexture)( @@ -815,29 +791,29 @@ typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromGLTexture)( typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromGLTexture2D)( cl_context context, cl_mem_flags flags, - GLenum target, - GLint miplevel, - GLuint texture, + cl_GLenum target, + cl_GLint miplevel, + cl_GLuint texture, cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromGLTexture3D)( cl_context context, cl_mem_flags flags, - GLenum target, - GLint miplevel, - GLuint texture, + cl_GLenum target, + cl_GLint miplevel, + cl_GLuint texture, cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromGLRenderbuffer)( cl_context context, cl_mem_flags flags, - GLuint renderbuffer, + cl_GLuint renderbuffer, cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetGLObjectInfo)( cl_mem memobj, cl_gl_object_type * gl_object_type, - GLuint * gl_object_name) CL_API_SUFFIX__VERSION_1_0; + cl_GLuint * gl_object_name) CL_API_SUFFIX__VERSION_1_0; typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetGLTextureInfo)( cl_mem memobj, diff --git a/opencl/khronos/icd/loader/icd_envvars.h b/opencl/khronos/icd/loader/icd_envvars.h new file mode 100644 index 0000000000..0d34d3d60c --- /dev/null +++ b/opencl/khronos/icd/loader/icd_envvars.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2016-2019 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#ifndef _ICD_ENVVARS_H_ +#define _ICD_ENVVARS_H_ + +char *khrIcd_getenv(const char *name); +char *khrIcd_secure_getenv(const char *name); +void khrIcd_free_getenv(char *val); + +#endif diff --git a/opencl/khronos/icd/loader/icd_platform.h b/opencl/khronos/icd/loader/icd_platform.h new file mode 100644 index 0000000000..b16d0dbe22 --- /dev/null +++ b/opencl/khronos/icd/loader/icd_platform.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2016-2019 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#ifndef _ICD_PLATFORM_H_ +#define _ICD_PLATFORM_H_ + +#if defined(__linux__) || defined(__APPLE__) + +#define PATH_SEPARATOR ':' +#define DIRECTORY_SYMBOL '/' +#ifdef __ANDROID__ +#define ICD_VENDOR_PATH "/system/vendor/Khronos/OpenCL/vendors/"; +#else +#define ICD_VENDOR_PATH "/etc/OpenCL/vendors/"; +#endif // ANDROID + +#elif defined(_WIN32) + +#define PATH_SEPARATOR ';' +#define DIRECTORY_SYMBOL '\\' + +#endif + +#endif diff --git a/opencl/khronos/icd/loader/linux/icd_exports.map b/opencl/khronos/icd/loader/linux/icd_exports.map new file mode 100644 index 0000000000..c716a39248 --- /dev/null +++ b/opencl/khronos/icd/loader/linux/icd_exports.map @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2016-2019 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +OPENCL_1.0 { + global: + clBuildProgram; + clCreateBuffer; + clCreateCommandQueue; + clCreateContext; + clCreateContextFromType; + clCreateFromGLBuffer; + clCreateFromGLRenderbuffer; + clCreateFromGLTexture2D; + clCreateFromGLTexture3D; + clCreateImage2D; + clCreateImage3D; + clCreateKernel; + clCreateKernelsInProgram; + clCreateProgramWithBinary; + clCreateProgramWithSource; + clCreateSampler; + clEnqueueAcquireGLObjects; + clEnqueueBarrier; + clEnqueueCopyBuffer; + clEnqueueCopyBufferToImage; + clEnqueueCopyImage; + clEnqueueCopyImageToBuffer; + clEnqueueMapBuffer; + clEnqueueMapImage; + clEnqueueMarker; + clEnqueueNDRangeKernel; + clEnqueueNativeKernel; + clEnqueueReadBuffer; + clEnqueueReadImage; + clEnqueueReleaseGLObjects; + clEnqueueTask; + clEnqueueUnmapMemObject; + clEnqueueWaitForEvents; + clEnqueueWriteBuffer; + clEnqueueWriteImage; + clFinish; + clFlush; + clGetCommandQueueInfo; + clGetContextInfo; + clGetDeviceIDs; + clGetDeviceInfo; + clGetEventInfo; + clGetEventProfilingInfo; + clGetExtensionFunctionAddress; + clGetGLObjectInfo; + clGetGLTextureInfo; + clGetImageInfo; + clGetKernelInfo; + clGetKernelWorkGroupInfo; + clGetMemObjectInfo; + clGetPlatformIDs; + clGetPlatformInfo; + clGetProgramBuildInfo; + clGetProgramInfo; + clGetSamplerInfo; + clGetSupportedImageFormats; + clReleaseCommandQueue; + clReleaseContext; + clReleaseEvent; + clReleaseKernel; + clReleaseMemObject; + clReleaseProgram; + clReleaseSampler; + clRetainCommandQueue; + clRetainContext; + clRetainEvent; + clRetainKernel; + clRetainMemObject; + clRetainProgram; + clRetainSampler; + clSetCommandQueueProperty; + clSetKernelArg; + clUnloadCompiler; + clWaitForEvents; + + local: + /* Everything else is local to ICD. */ + *; +}; + +OPENCL_1.1 { + global: + clCreateSubBuffer; + clCreateUserEvent; + clEnqueueCopyBufferRect; + clEnqueueReadBufferRect; + clEnqueueWriteBufferRect; + clSetEventCallback; + clSetMemObjectDestructorCallback; + clSetUserEventStatus; +} OPENCL_1.0; + +OPENCL_1.2 { + global: + clCompileProgram; + clCreateFromGLTexture; + clCreateImage; + clCreateProgramWithBuiltInKernels; + clCreateSubDevices; + clEnqueueBarrierWithWaitList; + clEnqueueFillBuffer; + clEnqueueFillImage; + clEnqueueMarkerWithWaitList; + clEnqueueMigrateMemObjects; + clGetExtensionFunctionAddressForPlatform; + clGetKernelArgInfo; + clLinkProgram; + clReleaseDevice; + clRetainDevice; + clUnloadPlatformCompiler; +} OPENCL_1.1; + +OPENCL_2.0 { + global: + clCreateCommandQueueWithProperties; + clCreatePipe; + clGetPipeInfo; + clSVMAlloc; + clSVMFree; + clEnqueueSVMFree; + clEnqueueSVMMemcpy; + clEnqueueSVMMemFill; + clEnqueueSVMMap; + clEnqueueSVMUnmap; + clCreateSamplerWithProperties; + clSetKernelArgSVMPointer; + clSetKernelExecInfo; +} OPENCL_1.2; + +OPENCL_2.1 { + global: + clCloneKernel; + clCreateProgramWithIL; + clEnqueueSVMMigrateMem; + clGetDeviceAndHostTimer; + clGetHostTimer; + clGetKernelSubGroupInfo; + clSetDefaultDeviceCommandQueue; +} OPENCL_2.0; + +OPENCL_2.2 { + global: + clSetProgramReleaseCallback; + clSetProgramSpecializationConstant; +} OPENCL_2.1; diff --git a/opencl/khronos/icd/loader/linux/icd_linux.c b/opencl/khronos/icd/loader/linux/icd_linux.c new file mode 100644 index 0000000000..f6ae79022b --- /dev/null +++ b/opencl/khronos/icd/loader/linux/icd_linux.c @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2016-2019 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#include "icd.h" +#include "icd_envvars.h" + +#include +#include +#include +#include +#include +#include +#include + +static pthread_once_t initialized = PTHREAD_ONCE_INIT; + +/* + * + * Vendor enumeration functions + * + */ + +// go through the list of vendors in the two configuration files +void khrIcdOsVendorsEnumerate(void) +{ + DIR *dir = NULL; + struct dirent *dirEntry = NULL; + char* vendorPath = ICD_VENDOR_PATH; + char* envPath = NULL; + + khrIcdVendorsEnumerateEnv(); + + envPath = khrIcd_secure_getenv("OCL_ICD_VENDORS"); + if (NULL != envPath) + { + vendorPath = envPath; + } + + dir = opendir(vendorPath); + if (NULL == dir) + { + KHR_ICD_TRACE("Failed to open path %s, continuing\n", vendorPath); + } + else + { + // attempt to load all files in the directory + for (dirEntry = readdir(dir); dirEntry; dirEntry = readdir(dir) ) + { + switch(dirEntry->d_type) + { + case DT_UNKNOWN: + case DT_REG: + case DT_LNK: + { + const char* extension = ".icd"; + FILE *fin = NULL; + char* fileName = NULL; + char* buffer = NULL; + long bufferSize = 0; + + // make sure the file name ends in .icd + if (strlen(extension) > strlen(dirEntry->d_name) ) + { + break; + } + if (strcmp(dirEntry->d_name + strlen(dirEntry->d_name) - strlen(extension), extension) ) + { + break; + } + + // allocate space for the full path of the vendor library name + fileName = malloc(strlen(dirEntry->d_name) + strlen(vendorPath) + 1); + if (!fileName) + { + KHR_ICD_TRACE("Failed allocate space for ICD file path\n"); + break; + } + sprintf(fileName, "%s%s", vendorPath, dirEntry->d_name); + + // open the file and read its contents + fin = fopen(fileName, "r"); + if (!fin) + { + free(fileName); + break; + } + fseek(fin, 0, SEEK_END); + bufferSize = ftell(fin); + + buffer = malloc(bufferSize+1); + if (!buffer) + { + free(fileName); + fclose(fin); + break; + } + memset(buffer, 0, bufferSize+1); + fseek(fin, 0, SEEK_SET); + if (bufferSize != (long)fread(buffer, 1, bufferSize, fin) ) + { + free(fileName); + free(buffer); + fclose(fin); + break; + } + // ignore a newline at the end of the file + if (buffer[bufferSize-1] == '\n') buffer[bufferSize-1] = '\0'; + + // load the string read from the file + khrIcdVendorAdd(buffer); + + free(fileName); + free(buffer); + fclose(fin); + } + break; + default: + break; + } + } + + closedir(dir); + } + + if (NULL != envPath) + { + khrIcd_free_getenv(envPath); + } +} + +// go through the list of vendors only once +void khrIcdOsVendorsEnumerateOnce(void) +{ + pthread_once(&initialized, khrIcdOsVendorsEnumerate); +} + +/* + * + * Dynamic library loading functions + * + */ + +// dynamically load a library. returns NULL on failure +void *khrIcdOsLibraryLoad(const char *libraryName) +{ + return dlopen (libraryName, RTLD_NOW); +} + +// get a function pointer from a loaded library. returns NULL on failure. +void *khrIcdOsLibraryGetFunctionAddress(void *library, const char *functionName) +{ + return dlsym(library, functionName); +} + +// unload a library +void khrIcdOsLibraryUnload(void *library) +{ + dlclose(library); +} + diff --git a/opencl/khronos/icd/loader/linux/icd_linux_envvars.c b/opencl/khronos/icd/loader/linux/icd_linux_envvars.c new file mode 100644 index 0000000000..4af5a082d8 --- /dev/null +++ b/opencl/khronos/icd/loader/linux/icd_linux_envvars.c @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2016-2019 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +// for secure_getenv(): +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + +#include "icd_cmake_config.h" + +#include + +char *khrIcd_getenv(const char *name) { + // No allocation of memory necessary for Linux. + return getenv(name); +} + +char *khrIcd_secure_getenv(const char *name) { +#if defined(__APPLE__) + // Apple does not appear to have a secure getenv implementation. + // The main difference between secure getenv and getenv is that secure getenv + // returns NULL if the process is being run with elevated privileges by a normal user. + // The idea is to prevent the reading of malicious environment variables by a process + // that can do damage. + // This algorithm is derived from glibc code that sets an internal + // variable (__libc_enable_secure) if the process is running under setuid or setgid. + return geteuid() != getuid() || getegid() != getgid() ? NULL : khrIcd_getenv(name); +#else +// Linux +#ifdef HAVE_SECURE_GETENV + return secure_getenv(name); +#elif defined(HAVE___SECURE_GETENV) + return __secure_getenv(name); +#else +#pragma message( \ + "Warning: Falling back to non-secure getenv for environmental lookups! Consider" \ + " updating to a different libc.") + return khrIcd_getenv(name); +#endif +#endif +} + +void khrIcd_free_getenv(char *val) { + // No freeing of memory necessary for Linux, but we should at least touch + // val to get rid of compiler warnings. + (void)val; +} diff --git a/opencl/khronos/icd/loader/windows/OpenCL.def b/opencl/khronos/icd/loader/windows/OpenCL.def new file mode 100644 index 0000000000..98abc9b127 --- /dev/null +++ b/opencl/khronos/icd/loader/windows/OpenCL.def @@ -0,0 +1,162 @@ +; +; Copyright (c) 2016-2019 The Khronos Group Inc. +; +; Licensed under the Apache License, Version 2.0 (the "License"); +; you may not use this file except in compliance with the License. +; You may obtain a copy of the License at +; +; http://www.apache.org/licenses/LICENSE-2.0 +; +; Unless required by applicable law or agreed to in writing, software +; distributed under the License is distributed on an "AS IS" BASIS, +; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +; See the License for the specific language governing permissions and +; limitations under the License. +; +; OpenCL is a trademark of Apple Inc. used under license by Khronos. + +EXPORTS + +; +; Note: +; +; 1. Functions are grouped into blocks according to the OpenCL API version they +; were introduced in. +; +; 2. Function blocks are sorted in ascending order of the API version. +; +; 3. Functions within a block are sorted alphabetically. +; + +; OpenCL 1.0 API +clBuildProgram +clCreateBuffer +clCreateCommandQueue +clCreateContext +clCreateContextFromType +clCreateFromGLBuffer +clCreateFromGLRenderbuffer +clCreateFromGLTexture2D +clCreateFromGLTexture3D +clCreateImage2D +clCreateImage3D +clCreateKernel +clCreateKernelsInProgram +clCreateProgramWithBinary +clCreateProgramWithSource +clCreateSampler +clEnqueueAcquireGLObjects +clEnqueueBarrier +clEnqueueCopyBuffer +clEnqueueCopyBufferToImage +clEnqueueCopyImage +clEnqueueCopyImageToBuffer +clEnqueueMapBuffer +clEnqueueMapImage +clEnqueueMarker +clEnqueueNDRangeKernel +clEnqueueNativeKernel +clEnqueueReadBuffer +clEnqueueReadImage +clEnqueueReleaseGLObjects +clEnqueueTask +clEnqueueUnmapMemObject +clEnqueueWaitForEvents +clEnqueueWriteBuffer +clEnqueueWriteImage +clFinish +clFlush +clGetCommandQueueInfo +clGetContextInfo +clGetDeviceIDs +clGetDeviceInfo +clGetEventInfo +clGetEventProfilingInfo +clGetExtensionFunctionAddress +clGetGLObjectInfo +clGetGLTextureInfo +clGetImageInfo +clGetKernelInfo +clGetKernelWorkGroupInfo +clGetMemObjectInfo +clGetPlatformIDs +clGetPlatformInfo +clGetProgramBuildInfo +clGetProgramInfo +clGetSamplerInfo +clGetSupportedImageFormats +clReleaseCommandQueue +clReleaseContext +clReleaseEvent +clReleaseKernel +clReleaseMemObject +clReleaseProgram +clReleaseSampler +clRetainCommandQueue +clRetainContext +clRetainEvent +clRetainKernel +clRetainMemObject +clRetainProgram +clRetainSampler +clSetCommandQueueProperty +clSetKernelArg +clUnloadCompiler +clWaitForEvents + +; OpenCL 1.1 API +clCreateSubBuffer +clCreateUserEvent +clEnqueueCopyBufferRect +clEnqueueReadBufferRect +clEnqueueWriteBufferRect +clSetEventCallback +clSetMemObjectDestructorCallback +clSetUserEventStatus + +; OpenCL 1.2 API +clCompileProgram +clCreateFromGLTexture +clCreateImage +clCreateProgramWithBuiltInKernels +clCreateSubDevices +clEnqueueBarrierWithWaitList +clEnqueueFillBuffer +clEnqueueFillImage +clEnqueueMarkerWithWaitList +clEnqueueMigrateMemObjects +clGetExtensionFunctionAddressForPlatform +clGetKernelArgInfo +clLinkProgram +clReleaseDevice +clRetainDevice +clUnloadPlatformCompiler + +; OpenCL 2.0 API +clCreateCommandQueueWithProperties +clCreatePipe +clCreateSamplerWithProperties +clEnqueueSVMFree +clEnqueueSVMMap +clEnqueueSVMMemcpy +clEnqueueSVMMemFill +clEnqueueSVMUnmap +clGetPipeInfo +clSetKernelArgSVMPointer +clSetKernelExecInfo +clSVMAlloc +clSVMFree + +; OpenCL 2.1 API +clCloneKernel +clCreateProgramWithIL +clEnqueueSVMMigrateMem +clGetDeviceAndHostTimer +clGetHostTimer +clGetKernelSubGroupInfo +clSetDefaultDeviceCommandQueue + +; OpenCL 2.2 API +clSetProgramReleaseCallback +clSetProgramSpecializationConstant + diff --git a/opencl/khronos/icd/loader/windows/OpenCL.rc b/opencl/khronos/icd/loader/windows/OpenCL.rc new file mode 100644 index 0000000000..e70ef06e97 --- /dev/null +++ b/opencl/khronos/icd/loader/windows/OpenCL.rc @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2016-2019 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#include + +#define OPENCL_ICD_LOADER_VERSION_MAJOR 2 +#define OPENCL_ICD_LOADER_VERSION_MINOR 2 +#define OPENCL_ICD_LOADER_VERSION_REV 3 + +#ifdef RC_INVOKED + +#define OPENCL_ICD_LOADER_VAL(_v) #_v +#define OPENCL_ICD_LOADER_TOSTRING(_d) OPENCL_ICD_LOADER_VAL(_d) +#define OPENCL_ICD_LOADER_VERSION_STRING \ + OPENCL_ICD_LOADER_TOSTRING(OPENCL_ICD_LOADER_VERSION_MAJOR) "." \ + OPENCL_ICD_LOADER_TOSTRING(OPENCL_ICD_LOADER_VERSION_MINOR) "." \ + OPENCL_ICD_LOADER_TOSTRING(OPENCL_ICD_LOADER_VERSION_REV) + +VS_VERSION_INFO VERSIONINFO +FILEVERSION OPENCL_ICD_LOADER_VERSION_MAJOR,OPENCL_ICD_LOADER_VERSION_MINOR,OPENCL_ICD_LOADER_VERSION_REV,0 +PRODUCTVERSION OPENCL_ICD_LOADER_VERSION_MAJOR,OPENCL_ICD_LOADER_VERSION_MINOR,OPENCL_ICD_LOADER_VERSION_REV,0 +FILETYPE VFT_DLL + +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + BEGIN + VALUE "FileDescription" ,"OpenCL Client DLL" + VALUE "ProductName" ,"Khronos OpenCL ICD Loader" + VALUE "LegalCopyright" ,"Copyright \251 The Khronos Group Inc 2016-2019" + VALUE "FileVersion" ,OPENCL_ICD_LOADER_VERSION_STRING ".0" + VALUE "CompanyName" ,"Khronos Group" + VALUE "InternalName" ,"OpenCL" + VALUE "OriginalFilename","OpenCL.dll" + END + END + + BLOCK "VarFileInfo" + BEGIN + // extend this line for localized versions + VALUE "Translation", 0x0409, 0x04E4 + END +END + +#endif + diff --git a/opencl/khronos/icd/loader/windows/icd_windows.c b/opencl/khronos/icd/loader/windows/icd_windows.c new file mode 100644 index 0000000000..9c87817586 --- /dev/null +++ b/opencl/khronos/icd/loader/windows/icd_windows.c @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2016-2019 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#include "icd.h" +#include "icd_windows_hkr.h" +#include "icd_windows_dxgk.h" +#include +#include +#include + +static INIT_ONCE initialized = INIT_ONCE_STATIC_INIT; + +/* + * + * Vendor enumeration functions + * + */ + +// go through the list of vendors in the registry and call khrIcdVendorAdd +// for each vendor encountered +BOOL CALLBACK khrIcdOsVendorsEnumerate(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *lpContext) +{ + LONG result; + const char* platformsName = "SOFTWARE\\Khronos\\OpenCL\\Vendors"; + HKEY platformsKey = NULL; + DWORD dwIndex; + + khrIcdVendorsEnumerateEnv(); + + if (!khrIcdOsVendorsEnumerateDXGK()) + { + KHR_ICD_TRACE("Failed to load via DXGK interface on RS4, continuing\n"); + if (!khrIcdOsVendorsEnumerateHKR()) + { + KHR_ICD_TRACE("Failed to enumerate HKR entries, continuing\n"); + } + } + + KHR_ICD_TRACE("Opening key HKLM\\%s...\n", platformsName); + result = RegOpenKeyExA( + HKEY_LOCAL_MACHINE, + platformsName, + 0, + KEY_READ, + &platformsKey); + if (ERROR_SUCCESS != result) + { + KHR_ICD_TRACE("Failed to open platforms key %s, continuing\n", platformsName); + } + else + { + // for each value + for (dwIndex = 0;; ++dwIndex) + { + char cszLibraryName[1024] = {0}; + DWORD dwLibraryNameSize = sizeof(cszLibraryName); + DWORD dwLibraryNameType = 0; + DWORD dwValue = 0; + DWORD dwValueSize = sizeof(dwValue); + + // read the value name + KHR_ICD_TRACE("Reading value %d...\n", dwIndex); + result = RegEnumValueA( + platformsKey, + dwIndex, + cszLibraryName, + &dwLibraryNameSize, + NULL, + &dwLibraryNameType, + (LPBYTE)&dwValue, + &dwValueSize); + // if RegEnumKeyEx fails, we are done with the enumeration + if (ERROR_SUCCESS != result) + { + KHR_ICD_TRACE("Failed to read value %d, done reading key.\n", dwIndex); + break; + } + KHR_ICD_TRACE("Value %s found...\n", cszLibraryName); + + // Require that the value be a DWORD and equal zero + if (REG_DWORD != dwLibraryNameType) + { + KHR_ICD_TRACE("Value not a DWORD, skipping\n"); + continue; + } + if (dwValue) + { + KHR_ICD_TRACE("Value not zero, skipping\n"); + continue; + } + + // add the library + khrIcdVendorAdd(cszLibraryName); + } + + result = RegCloseKey(platformsKey); + if (ERROR_SUCCESS != result) + { + KHR_ICD_TRACE("Failed to close platforms key %s, ignoring\n", platformsName); + } + } + + return TRUE; +} + +// go through the list of vendors only once +void khrIcdOsVendorsEnumerateOnce() +{ + InitOnceExecuteOnce(&initialized, khrIcdOsVendorsEnumerate, NULL, NULL); +} + +/* + * + * Dynamic library loading functions + * + */ + +// dynamically load a library. returns NULL on failure +void *khrIcdOsLibraryLoad(const char *libraryName) +{ + return (void *)LoadLibraryA(libraryName); +} + +// get a function pointer from a loaded library. returns NULL on failure. +void *khrIcdOsLibraryGetFunctionAddress(void *library, const char *functionName) +{ + if (!library || !functionName) + { + return NULL; + } + return GetProcAddress( (HMODULE)library, functionName); +} + +// unload a library. +void khrIcdOsLibraryUnload(void *library) +{ + FreeLibrary( (HMODULE)library); +} + diff --git a/opencl/khronos/icd/loader/windows/icd_windows_dxgk.c b/opencl/khronos/icd/loader/windows/icd_windows_dxgk.c new file mode 100644 index 0000000000..8cc3fb9b7b --- /dev/null +++ b/opencl/khronos/icd/loader/windows/icd_windows_dxgk.c @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2017-2019 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#include "icd.h" +#include "icd_windows_dxgk.h" + +#if defined(OPENCL_ICD_LOADER_REQUIRE_WDK) +#include + +#ifndef NTSTATUS +typedef LONG NTSTATUS; +#define STATUS_SUCCESS ((NTSTATUS)0x00000000L) +#define STATUS_BUFFER_TOO_SMALL ((NTSTATUS)0xC0000023) +#define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0) +#endif + +#include +#endif + +bool khrIcdOsVendorsEnumerateDXGK(void) +{ + bool ret = false; +#if defined(OPENCL_ICD_LOADER_REQUIRE_WDK) +#if defined(DXGKDDI_INTERFACE_VERSION_WDDM2_4) && (DXGKDDI_INTERFACE_VERSION >= DXGKDDI_INTERFACE_VERSION_WDDM2_4) + { + D3DKMT_ADAPTERINFO* pAdapterInfo = NULL; + D3DKMT_ENUMADAPTERS2 EnumAdapters; + NTSTATUS Status = STATUS_SUCCESS; + + // Get handle to GDI Runtime + HMODULE h = LoadLibrary("gdi32.dll"); + KHR_ICD_ASSERT(h != NULL); + + char cszLibraryName[MAX_PATH] = { 0 }; + PFND3DKMT_ENUMADAPTERS2 pEnumAdapters2 = (PFND3DKMT_ENUMADAPTERS2)GetProcAddress((HMODULE)h, "D3DKMTEnumAdapters2"); + if (!pEnumAdapters2) + { + KHR_ICD_TRACE("GetProcAddress failed for D3DKMT_ENUMADAPTERS2\n"); + goto out; + } + while (1) + { + EnumAdapters.NumAdapters = 0; + EnumAdapters.pAdapters = NULL; + Status = pEnumAdapters2(&EnumAdapters); + if (Status == STATUS_BUFFER_TOO_SMALL) + { + // Number of Adapters increased between calls, retry; + continue; + } + else if (!NT_SUCCESS(Status)) + { + KHR_ICD_TRACE("D3DKMT_ENUMADAPTERS2 status != SUCCESS\n"); + goto out; + } + break; + } + pAdapterInfo = (D3DKMT_ADAPTERINFO*)malloc(sizeof(D3DKMT_ADAPTERINFO)*(EnumAdapters.NumAdapters)); + if (pAdapterInfo == NULL) + { + KHR_ICD_TRACE("Allocation failure for AdapterInfo buffer\n"); + goto out; + } + EnumAdapters.pAdapters = pAdapterInfo; + Status = pEnumAdapters2(&EnumAdapters); + if (!NT_SUCCESS(Status)) + { + KHR_ICD_TRACE("D3DKMT_ENUMADAPTERS2 status != SUCCESS\n"); + goto out; + } + for (UINT AdapterIndex = 0; AdapterIndex < EnumAdapters.NumAdapters; AdapterIndex++) + { + D3DDDI_QUERYREGISTRY_INFO QueryArgs = {0}; + D3DDDI_QUERYREGISTRY_INFO* pQueryArgs = &QueryArgs; + D3DDDI_QUERYREGISTRY_INFO* pQueryBuffer = NULL; + QueryArgs.QueryType = D3DDDI_QUERYREGISTRY_ADAPTERKEY; + QueryArgs.QueryFlags.TranslatePath = TRUE; + QueryArgs.ValueType = REG_SZ; +#ifdef _WIN64 + wcscpy_s(QueryArgs.ValueName, ARRAYSIZE(L"OpenCLDriverName"), L"OpenCLDriverName"); +#else + // There is no WOW prefix for 32bit Windows hence make a specific check + BOOL is_wow64; + if (IsWow64Process(GetCurrentProcess(), &is_wow64) && is_wow64) + { + wcscpy_s(QueryArgs.ValueName, ARRAYSIZE(L"OpenCLDriverNameWow"), L"OpenCLDriverNameWow"); + } + else + { + wcscpy_s(QueryArgs.ValueName, ARRAYSIZE(L"OpenCLDriverName"), L"OpenCLDriverName"); + } +#endif + D3DKMT_QUERYADAPTERINFO QueryAdapterInfo = {0}; + QueryAdapterInfo.hAdapter = pAdapterInfo[AdapterIndex].hAdapter; + QueryAdapterInfo.Type = KMTQAITYPE_QUERYREGISTRY; + QueryAdapterInfo.pPrivateDriverData = &QueryArgs; + QueryAdapterInfo.PrivateDriverDataSize = sizeof(QueryArgs); + Status = D3DKMTQueryAdapterInfo(&QueryAdapterInfo); + if (!NT_SUCCESS(Status)) + { + KHR_ICD_TRACE("D3DKMT_QUERYADAPTERINFO status != SUCCESS\n"); + goto out; + } + if (NT_SUCCESS(Status) && pQueryArgs->Status == D3DDDI_QUERYREGISTRY_STATUS_BUFFER_OVERFLOW) + { + ULONG QueryBufferSize = sizeof(D3DDDI_QUERYREGISTRY_INFO) + QueryArgs.OutputValueSize; + pQueryBuffer = (D3DDDI_QUERYREGISTRY_INFO*)malloc(QueryBufferSize); + memcpy(pQueryBuffer, &QueryArgs, sizeof(D3DDDI_QUERYREGISTRY_INFO)); + QueryAdapterInfo.pPrivateDriverData = pQueryBuffer; + QueryAdapterInfo.PrivateDriverDataSize = QueryBufferSize; + Status = D3DKMTQueryAdapterInfo(&QueryAdapterInfo); + pQueryArgs = pQueryBuffer; + } + if (NT_SUCCESS(Status) && pQueryArgs->Status == D3DDDI_QUERYREGISTRY_STATUS_SUCCESS) + { + wchar_t* pWchar = pQueryArgs->OutputString; + memset(cszLibraryName, 0, sizeof(cszLibraryName)); + { + size_t len = wcstombs(cszLibraryName, pWchar, sizeof(cszLibraryName)); + KHR_ICD_ASSERT(len == (sizeof(cszLibraryName) - 1)); + khrIcdVendorAdd(cszLibraryName); + } + } + else if (Status == STATUS_INVALID_PARAMETER && pQueryArgs->Status == D3DDDI_QUERYREGISTRY_STATUS_FAIL) + { + free(pQueryBuffer); + goto out; + } + free(pQueryBuffer); + } + ret = true; +out: + free(pAdapterInfo); + FreeLibrary(h); + } +#endif +#endif + return ret; +} diff --git a/opencl/khronos/icd/loader/windows/icd_windows_dxgk.h b/opencl/khronos/icd/loader/windows/icd_windows_dxgk.h new file mode 100644 index 0000000000..f6cb65d4c9 --- /dev/null +++ b/opencl/khronos/icd/loader/windows/icd_windows_dxgk.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2017-2019 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#include + +bool khrIcdOsVendorsEnumerateDXGK(void); diff --git a/opencl/khronos/icd/loader/windows/icd_windows_envvars.c b/opencl/khronos/icd/loader/windows/icd_windows_envvars.c new file mode 100644 index 0000000000..c68cab6b1d --- /dev/null +++ b/opencl/khronos/icd/loader/windows/icd_windows_envvars.c @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2016-2019 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#include + +char *khrIcd_getenv(const char *name) { + char *retVal; + DWORD valSize; + + valSize = GetEnvironmentVariableA(name, NULL, 0); + + // valSize DOES include the null terminator, so for any set variable + // will always be at least 1. If it's 0, the variable wasn't set. + if (valSize == 0) return NULL; + + // Allocate the space necessary for the registry entry + retVal = (char *)malloc(valSize); + + if (NULL != retVal) { + GetEnvironmentVariableA(name, retVal, valSize); + } + + return retVal; +} + +char *khrIcd_secure_getenv(const char *name) { + return khrIcd_getenv(name); +} + +void khrIcd_free_getenv(char *val) { + free((void *)val); +} diff --git a/opencl/api/opencl/khronos/icd/loader/windows/icd_windows_hkr.c b/opencl/khronos/icd/loader/windows/icd_windows_hkr.c similarity index 81% rename from opencl/api/opencl/khronos/icd/loader/windows/icd_windows_hkr.c rename to opencl/khronos/icd/loader/windows/icd_windows_hkr.c index 076b60f5ad..338718143c 100644 --- a/opencl/api/opencl/khronos/icd/loader/windows/icd_windows_hkr.c +++ b/opencl/khronos/icd/loader/windows/icd_windows_hkr.c @@ -1,36 +1,17 @@ /* - * Copyright (c) 2017 The Khronos Group Inc. + * Copyright (c) 2017-2019 The Khronos Group Inc. * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software source and associated documentation files (the "Materials"), - * to deal in the Materials without restriction, including without limitation - * the rights to use, copy, modify, compile, merge, publish, distribute, - * sublicense, and/or sell copies of the Materials, and to permit persons to - * whom the Materials are furnished to do so, subject the following terms and - * conditions: + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * All modifications to the Materials used to create a binary that is - * distributed to third parties shall be provided to Khronos with an - * unrestricted license to use for the purposes of implementing bug fixes and - * enhancements to the Materials; + * http://www.apache.org/licenses/LICENSE-2.0 * - * If the binary is used as part of an OpenCL(TM) implementation, whether binary - * is distributed together with or separately to that implementation, then - * recipient must become an OpenCL Adopter and follow the published OpenCL - * conformance process for that implementation, details at: - * http://www.khronos.org/conformance/; - * - * The above copyright notice, the OpenCL trademark license, and this permission - * notice shall be included in all copies or substantial portions of the - * Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN - * THE MATERIALS. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * * OpenCL is a trademark of Apple Inc. used under license by Khronos. */ @@ -42,7 +23,7 @@ #include #include #include -#include +#include #include // This GUID was only added to devguid.h on Windows SDK v10.0.16232 which @@ -63,12 +44,31 @@ typedef enum mem = NULL; \ } while (0) -#ifdef _WIN64 static const char OPENCL_REG_SUB_KEY[] = "OpenCLDriverName"; -#else -static const char OPENCL_REG_SUB_KEY[] = "OpenCLDriverNameWow"; + +#ifndef _WIN64 +static const char OPENCL_REG_SUB_KEY_WOW[] = "OpenCLDriverNameWow"; #endif +// Do not free the memory returned by this function. +static const char* GetOpenCLRegKeyName(void) +{ +#ifdef _WIN64 + return OPENCL_REG_SUB_KEY; +#else + // The suffix/substring "WoW" is meaningful only when a 32-bit + // application is running on a 64-bit Windows OS. A 32-bit application + // running on a 32-bit OS uses non-WoW names. + BOOL is_wow64; + if (IsWow64Process(GetCurrentProcess(), &is_wow64) && is_wow64) + { + return OPENCL_REG_SUB_KEY_WOW; + } + + return OPENCL_REG_SUB_KEY; +#endif +} + static bool ReadOpenCLKey(DEVINST dnDevNode) { HKEY hkey = 0; @@ -96,7 +96,7 @@ static bool ReadOpenCLKey(DEVINST dnDevNode) { result = RegQueryValueExA( hkey, - OPENCL_REG_SUB_KEY, + GetOpenCLRegKeyName(), NULL, &dwLibraryNameType, NULL, @@ -117,7 +117,7 @@ static bool ReadOpenCLKey(DEVINST dnDevNode) result = RegQueryValueExA( hkey, - OPENCL_REG_SUB_KEY, + GetOpenCLRegKeyName(), NULL, &dwLibraryNameType, (LPBYTE)cszOclPath, @@ -168,7 +168,6 @@ static DeviceProbeResult ProbeDevice(DEVINST devnode) devnode, 0); - // TODO: consider extracting warning messages out of this function if (CR_SUCCESS != ret) { KHR_ICD_TRACE(" WARNING: failed to probe the status of the device 0x%x\n", ret); @@ -341,8 +340,6 @@ bool khrIcdOsVendorsEnumerateHKR(void) &szGuid, 0); - KHR_ICD_ASSERT(devpropType == DEVPROP_TYPE_GUID); - if (CR_SUCCESS != ret || !IsEqualGUID(&OCL_GUID_DEVCLASS_SOFTWARECOMPONENT, &guid)) { diff --git a/opencl/khronos/icd/loader/windows/icd_windows_hkr.h b/opencl/khronos/icd/loader/windows/icd_windows_hkr.h new file mode 100644 index 0000000000..698fe5a3cc --- /dev/null +++ b/opencl/khronos/icd/loader/windows/icd_windows_hkr.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2017-2019 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#include + +bool khrIcdOsVendorsEnumerateHKR(void); diff --git a/opencl/khronos/icd/test/CMakeLists.txt b/opencl/khronos/icd/test/CMakeLists.txt new file mode 100644 index 0000000000..a158995888 --- /dev/null +++ b/opencl/khronos/icd/test/CMakeLists.txt @@ -0,0 +1,7 @@ +include_directories (./inc) + +add_subdirectory (log) +add_subdirectory (driver_stub) +add_subdirectory (loader_test) + +add_test (NAME opencl_icd_loader_test COMMAND icd_loader_test) diff --git a/opencl/khronos/icd/test/driver_stub/CMakeLists.txt b/opencl/khronos/icd/test/driver_stub/CMakeLists.txt new file mode 100644 index 0000000000..47b3bd273e --- /dev/null +++ b/opencl/khronos/icd/test/driver_stub/CMakeLists.txt @@ -0,0 +1,10 @@ + +set (OPENCL_DRIVER_STUB_SOURCES cl.c cl_ext.c cl_gl.c icd.c) + +if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") + list (APPEND OPENCL_DRIVER_STUB_SOURCES driver_stub.def) +endif () + +add_library (OpenCLDriverStub ${OPENCL_DRIVER_STUB_SOURCES}) + +target_link_libraries (OpenCLDriverStub IcdLog) diff --git a/opencl/khronos/icd/test/driver_stub/cl.c b/opencl/khronos/icd/test/driver_stub/cl.c new file mode 100644 index 0000000000..802192348b --- /dev/null +++ b/opencl/khronos/icd/test/driver_stub/cl.c @@ -0,0 +1,1919 @@ +#include +#include +#include + +#ifndef CL_USE_DEPRECATED_OPENCL_1_0_APIS +#define CL_USE_DEPRECATED_OPENCL_1_0_APIS +#endif + +#ifndef CL_USE_DEPRECATED_OPENCL_1_1_APIS +#define CL_USE_DEPRECATED_OPENCL_1_1_APIS +#endif + +// Need to rename all CL API functions to prevent ICD loader functions calling +// themselves via the dispatch table. Include this before cl headers. +#include "rename_api.h" + +#include +#include +#include "icd_structs.h" + +#define CL_PLATFORM_ICD_SUFFIX_KHR 0x0920 +CL_API_ENTRY cl_int CL_API_CALL +clIcdGetPlatformIDsKHR(cl_uint, cl_platform_id *, cl_uint *); + +struct _cl_platform_id +{ + CLIicdDispatchTable* dispatch; + const char *profile; + const char *version; + const char *name; + const char *vendor; + const char *extensions; + const char *suffix; +}; + +struct _cl_device_id +{ + CLIicdDispatchTable* dispatch; +}; + +struct _cl_context +{ + CLIicdDispatchTable* dispatch; +}; + +struct _cl_command_queue +{ + CLIicdDispatchTable* dispatch; +}; + +struct _cl_mem +{ + CLIicdDispatchTable* dispatch; +}; + +struct _cl_program +{ + CLIicdDispatchTable* dispatch; +}; + +struct _cl_kernel +{ + CLIicdDispatchTable* dispatch; +}; + +struct _cl_event +{ + CLIicdDispatchTable* dispatch; +}; + +struct _cl_sampler +{ + CLIicdDispatchTable* dispatch; +}; + +static CLIicdDispatchTable* dispatchTable = NULL; +static cl_platform_id platform = NULL; +static cl_bool initialized = CL_FALSE; + +CL_API_ENTRY cl_int CL_API_CALL +clGetPlatformIDs(cl_uint num_entries , + cl_platform_id * platforms , + cl_uint * num_platforms) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clGetPlatformIDs(%u, %p, %p)\n", + num_entries, + platforms, + num_platforms); + return_value = clIcdGetPlatformIDsKHR(num_entries, platforms, num_platforms); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetPlatformInfo(cl_platform_id platform, + cl_platform_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int ret = CL_SUCCESS; + const char *returnString = NULL; + size_t returnStringLength = 0; + /*test_icd_stub_log("clGetPlatformInfo(%p, %u, %u, %p, %p)\n", + platform, + param_name, + param_value_size, + param_value, + param_value_size_ret);*/ + + // validate the arguments + if (param_value_size == 0 && param_value != NULL) { + ret = CL_INVALID_VALUE; + goto done; + } + // select the string to return + switch(param_name) { + case CL_PLATFORM_PROFILE: + returnString = platform->profile; + break; + case CL_PLATFORM_VERSION: + returnString = platform->version; + break; + case CL_PLATFORM_NAME: + returnString = platform->name; + break; + case CL_PLATFORM_VENDOR: + returnString = platform->vendor; + break; + case CL_PLATFORM_EXTENSIONS: + returnString = platform->extensions; + break; + case CL_PLATFORM_ICD_SUFFIX_KHR: + returnString = platform->suffix; + break; + default: + ret = CL_INVALID_VALUE; + goto done; + } + + // make sure the buffer passed in is big enough for the result + returnStringLength = strlen(returnString)+1; + if (param_value_size && param_value_size < returnStringLength) { + ret = CL_INVALID_VALUE; + goto done; + } + + // pass the data back to the user + if (param_value) { + memcpy(param_value, returnString, returnStringLength); + } + if (param_value_size_ret) { + *param_value_size_ret = returnStringLength; + } + +done: + /*test_icd_stub_log("Value returned: %d\n", + return_value);*/ + return ret; +} + + +/* Device APIs */ +CL_API_ENTRY cl_int CL_API_CALL +clGetDeviceIDs(cl_platform_id platform, + cl_device_type device_type, + cl_uint num_entries, + cl_device_id * devices, + cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int ret = CL_SUCCESS; + + if ((num_entries > 1 || num_entries < 0) && devices != NULL) { + ret = CL_INVALID_VALUE; + goto done; + } + + if (devices != NULL) { + cl_device_id obj = (cl_device_id) malloc(sizeof(*obj)); + obj->dispatch = dispatchTable; + devices[0] = obj; + } + if (num_devices) { + *num_devices = 1; + } + +done: + test_icd_stub_log("clGetDeviceIDs(%p, %x, %u, %p, %p)\n", + platform, + device_type, + num_entries, + devices, + num_devices); + test_icd_stub_log("Value returned: %d\n", ret); + return ret; +} + + + +CL_API_ENTRY cl_int CL_API_CALL +clGetDeviceInfo(cl_device_id device, + cl_device_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clGetDeviceInfo(%p, %u, %u, %p, %p)\n", + device, + param_name, + param_value_size, + param_value, + param_value_size_ret); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clCreateSubDevices(cl_device_id in_device, + const cl_device_partition_property *properties, + cl_uint num_entries, + cl_device_id *out_devices, + cl_uint *num_devices) CL_API_SUFFIX__VERSION_1_2 +{ + + cl_int return_value = CL_OUT_OF_RESOURCES; + + test_icd_stub_log("clCreateSubDevices(%p, %p, %u, %p, %p)\n", + in_device, + properties, + num_entries, + out_devices, + num_devices); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + + +CL_API_ENTRY cl_int CL_API_CALL +clRetainDevice(cl_device_id device) CL_API_SUFFIX__VERSION_1_2 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clRetainDevice(%p)\n", device); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + + +CL_API_ENTRY cl_int CL_API_CALL +clReleaseDevice(cl_device_id device) CL_API_SUFFIX__VERSION_1_2 + +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clReleaseDevice(%p)\n", device); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + + +/* Context APIs */ +CL_API_ENTRY cl_context CL_API_CALL +clCreateContext(const cl_context_properties * properties, + cl_uint num_devices , + const cl_device_id * devices, + void (CL_CALLBACK * pfn_notify)(const char *, const void *, size_t, void *), + void * user_data, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_context obj = (cl_context) malloc(sizeof(struct _cl_context)); + obj->dispatch = dispatchTable; + test_icd_stub_log("clCreateContext(%p, %u, %p, %p, %p, %p)\n", + properties, + num_devices, + devices, + pfn_notify, + user_data, + errcode_ret); + pfn_notify(NULL, NULL, 0, NULL); + test_icd_stub_log("createcontext_callback(%p, %p, %u, %p)\n", + NULL, + NULL, + 0, + NULL); + + test_icd_stub_log("Value returned: %p\n", obj); + return obj; +} + + +CL_API_ENTRY cl_context CL_API_CALL +clCreateContextFromType(const cl_context_properties * properties, + cl_device_type device_type, + void (CL_CALLBACK * pfn_notify)(const char *, const void *, size_t, void *), + void * user_data, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_context obj = (cl_context) malloc(sizeof(struct _cl_context)); + obj->dispatch = dispatchTable; + test_icd_stub_log("clCreateContextFromType(%p, %x, %p, %p, %p)\n", + properties, + device_type, + pfn_notify, + user_data, + errcode_ret); + pfn_notify(NULL, NULL, 0, NULL); + + test_icd_stub_log ("createcontext_callback(%p, %p, %u, %p)\n", + NULL, + NULL, + 0, + NULL); + + test_icd_stub_log("Value returned: %p\n", + obj); + return obj; +} + +CL_API_ENTRY cl_int CL_API_CALL +clRetainContext(cl_context context) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clRetainContext(%p)\n", context); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clReleaseContext(cl_context context) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clReleaseContext(%p)\n", context); + free(context); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetContextInfo(cl_context context, + cl_context_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clGetContextInfo(%p, %u, %u, %p, %p)\n", + context, + param_name, + param_value_size, + param_value, + param_value_size_ret); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +/* Command Queue APIs */ +CL_API_ENTRY cl_command_queue CL_API_CALL +clCreateCommandQueue(cl_context context, + cl_device_id device, + cl_command_queue_properties properties, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_command_queue obj = (cl_command_queue) malloc(sizeof(struct _cl_command_queue)); + obj->dispatch = dispatchTable; + test_icd_stub_log("clCreateCommandQueue(%p, %p, %x, %p)\n", + context, + device, + properties, + errcode_ret); + + test_icd_stub_log("Value returned: %p\n", obj); + return obj; +} + +CL_API_ENTRY cl_int CL_API_CALL +clSetCommandQueueProperty(cl_command_queue command_queue , + cl_command_queue_properties properties , + cl_bool enable , + cl_command_queue_properties * old_properties) CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clSetCommandQueueProperty(%p, %p, %u, %p)\n", + command_queue, + properties, + enable, + old_properties); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clRetainCommandQueue(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clRetainCommandQueue(%p)\n", command_queue); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clReleaseCommandQueue(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clReleaseCommandQueue(%p)\n", command_queue); + free(command_queue); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetCommandQueueInfo(cl_command_queue command_queue , + cl_command_queue_info param_name , + size_t param_value_size , + void * param_value , + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clGetCommandQueueInfo(%p, %u, %u, %p, %p)\n", + command_queue, + param_name, + param_value_size, + param_value, + param_value_size_ret); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + + + +/* Memory Object APIs */ +CL_API_ENTRY cl_mem CL_API_CALL +clCreateBuffer(cl_context context , + cl_mem_flags flags , + size_t size , + void * host_ptr , + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_mem obj = (cl_mem) malloc(sizeof(struct _cl_mem)); + obj->dispatch = dispatchTable; + test_icd_stub_log("clCreateBuffer(%p, %x, %u, %p, %p)\n", + context, + flags, + size, + host_ptr, + errcode_ret); + + test_icd_stub_log("Value returned: %p\n", obj); + return obj; +} + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateSubBuffer(cl_mem buffer , + cl_mem_flags flags , + cl_buffer_create_type buffer_create_type , + const void * buffer_create_info , + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_1 +{ + cl_mem obj = (cl_mem) malloc(sizeof(struct _cl_mem)); + obj->dispatch = dispatchTable; + test_icd_stub_log("clCreateSubBuffer(%p, %x, %u, %p, %p)\n", + buffer, + flags, + buffer_create_type, + buffer_create_info, + errcode_ret); + + test_icd_stub_log("Value returned: %p\n", obj); + return obj; +} + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateImage(cl_context context, + cl_mem_flags flags, + const cl_image_format * image_format, + const cl_image_desc * image_desc, + void * host_ptr, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2 +{ + cl_mem obj = (cl_mem) malloc(sizeof(struct _cl_mem)); + obj->dispatch = dispatchTable; + test_icd_stub_log("clCreateImage(%p, %x, %p, %p, %p, %p)\n", + context, + flags, + image_format, + image_desc, + host_ptr, + errcode_ret); + + test_icd_stub_log("Value returned: %p\n", obj); + return obj; +} + + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateImage2D(cl_context context , + cl_mem_flags flags , + const cl_image_format * image_format , + size_t image_width , + size_t image_height , + size_t image_row_pitch , + void * host_ptr , + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_mem obj = (cl_mem) malloc(sizeof(struct _cl_mem)); + obj->dispatch = dispatchTable; + test_icd_stub_log("clCreateImage2D(%p, %x, %p, %u, %u, %u, %p, %p)\n", + context, + flags, + image_format, + image_width, + image_height, + image_row_pitch, + host_ptr, + errcode_ret); + + test_icd_stub_log("Value returned: %p\n", obj); + return obj; +} + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateImage3D(cl_context context, + cl_mem_flags flags, + const cl_image_format * image_format, + size_t image_width, + size_t image_height , + size_t image_depth , + size_t image_row_pitch , + size_t image_slice_pitch , + void * host_ptr , + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_mem obj = (cl_mem) malloc(sizeof(struct _cl_mem)); + obj->dispatch = dispatchTable; + test_icd_stub_log("clCreateImage3D(%p, %x, %p, %u, %u, %u, %u, %u, %p, %p)\n", + context, + flags, + image_format, + image_width, + image_height, + image_depth, + image_row_pitch, + image_slice_pitch, + host_ptr, + errcode_ret); + + test_icd_stub_log("Value returned: %p\n", obj); + return obj; +} + +CL_API_ENTRY cl_int CL_API_CALL +clRetainMemObject(cl_mem memobj) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clRetainMemObject(%p)\n", memobj); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clReleaseMemObject(cl_mem memobj) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clReleaseMemObject(%p)\n", memobj); + free(memobj); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetSupportedImageFormats(cl_context context, + cl_mem_flags flags, + cl_mem_object_type image_type , + cl_uint num_entries , + cl_image_format * image_formats , + cl_uint * num_image_formats) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clGetSupportedImageFormats(%p, %x, %u, %u, %p, %p)\n", + context, + flags, + image_type, + num_entries, + image_formats, + num_image_formats); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetMemObjectInfo(cl_mem memobj , + cl_mem_info param_name , + size_t param_value_size , + void * param_value , + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clGetMemObjectInfo(%p, %u, %u, %p, %p)\n", + memobj, + param_name, + param_value_size, + param_value, + param_value_size_ret); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetImageInfo(cl_mem image , + cl_image_info param_name , + size_t param_value_size , + void * param_value , + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clGetImageInfo(%p, %u, %u, %p, %p)\n", + image, + param_name, + param_value_size, + param_value, + param_value_size_ret); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clSetMemObjectDestructorCallback(cl_mem memobj , + void (CL_CALLBACK * pfn_notify)(cl_mem memobj , void* user_data), + void * user_data) CL_API_SUFFIX__VERSION_1_1 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clSetMemObjectDestructorCallback(%p, %p, %p)\n", + memobj, + pfn_notify, + user_data); + pfn_notify(memobj, NULL); + test_icd_stub_log("setmemobjectdestructor_callback(%p, %p)\n", + memobj, + NULL); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +/* Sampler APIs */ +CL_API_ENTRY cl_sampler CL_API_CALL +clCreateSampler(cl_context context , + cl_bool normalized_coords , + cl_addressing_mode addressing_mode , + cl_filter_mode filter_mode , + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_sampler obj = (cl_sampler) malloc(sizeof(struct _cl_sampler)); + obj->dispatch = dispatchTable; + test_icd_stub_log("clCreateSampler(%p, %u, %u, %u, %p)\n", + context, + normalized_coords, + addressing_mode, + filter_mode, + errcode_ret); + + test_icd_stub_log("Value returned: %p\n", obj); + return obj; +} + +CL_API_ENTRY cl_int CL_API_CALL +clRetainSampler(cl_sampler sampler) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clRetainSampler(%p)\n", sampler); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clReleaseSampler(cl_sampler sampler) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clReleaseSampler(%p)\n", sampler); + free(sampler); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetSamplerInfo(cl_sampler sampler , + cl_sampler_info param_name , + size_t param_value_size , + void * param_value , + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clGetSamplerInfo(%p, %u, %u, %p, %p)\n", + sampler, + param_name, + param_value_size, + param_value, + param_value_size_ret); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +/* Program Object APIs */ +CL_API_ENTRY cl_program CL_API_CALL +clCreateProgramWithSource(cl_context context , + cl_uint count , + const char ** strings , + const size_t * lengths , + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_program obj = (cl_program) malloc(sizeof(struct _cl_program)); + obj->dispatch = dispatchTable; + test_icd_stub_log("clCreateProgramWithSource(%p, %u, %p, %p, %p)\n", + context, + count, + strings, + lengths, + errcode_ret); + + test_icd_stub_log("Value returned: %p\n", obj); + return obj; +} + +CL_API_ENTRY cl_program CL_API_CALL +clCreateProgramWithBinary(cl_context context , + cl_uint num_devices , + const cl_device_id * device_list , + const size_t * lengths , + const unsigned char ** binaries , + cl_int * binary_status , + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_program obj = (cl_program) malloc(sizeof(struct _cl_program)); + obj->dispatch = dispatchTable; + test_icd_stub_log("clCreateProgramWithBinary(%p, %u, %p, %p, %p, %p, %p)\n", + context, + num_devices, + device_list, + lengths, + binaries, + binary_status, + errcode_ret); + + test_icd_stub_log("Value returned: %p\n", obj); + return obj; +} + +CL_API_ENTRY cl_program CL_API_CALL +clCreateProgramWithBuiltInKernels(cl_context context , + cl_uint num_devices , + const cl_device_id * device_list , + const char * kernel_names , + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2 +{ + cl_program obj = (cl_program) malloc(sizeof(struct _cl_program)); + obj->dispatch = dispatchTable; + test_icd_stub_log("clCreateProgramWithBuiltInKernels(%p, %u, %p, %p, %p)\n", + context, + num_devices, + device_list, + kernel_names, + errcode_ret); + + test_icd_stub_log("Value returned: %p\n", obj); + return obj; +} + + +CL_API_ENTRY cl_int CL_API_CALL +clRetainProgram(cl_program program) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clRetainProgram(%p)\n", + program); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clReleaseProgram(cl_program program) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clReleaseProgram(%p)\n", program); + free(program); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clBuildProgram(cl_program program , + cl_uint num_devices , + const cl_device_id * device_list , + const char * options , + void (CL_CALLBACK * pfn_notify)(cl_program program , void * user_data), + void * user_data) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clBuildProgram(%p, %u, %p, %p, %p, %p)\n", + program, + num_devices, + device_list, + options, + pfn_notify, + user_data); + pfn_notify(program, NULL); + test_icd_stub_log("program_callback(%p, %p)\n", program, NULL); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clUnloadCompiler(void) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clUnloadCompiler()\n"); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clCompileProgram(cl_program program , + cl_uint num_devices , + const cl_device_id * device_list , + const char * options , + cl_uint num_input_headers , + const cl_program * input_headers, + const char ** header_include_names , + void (CL_CALLBACK * pfn_notify)(cl_program program , void * user_data), + void * user_data) CL_API_SUFFIX__VERSION_1_2 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clCompileProgram(%p, %u, %p, %p, %u, %p, %p, %p)\n", + program, + num_devices, + device_list, + options, + num_input_headers, + header_include_names, + pfn_notify, + user_data); + pfn_notify(program, NULL); + test_icd_stub_log("program_callback(%p, %p)\n", program, NULL); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_program CL_API_CALL +clLinkProgram(cl_context context , + cl_uint num_devices , + const cl_device_id * device_list , + const char * options , + cl_uint num_input_programs , + const cl_program * input_programs , + void (CL_CALLBACK * pfn_notify)(cl_program program , void * user_data), + void * user_data , + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2 +{ + cl_program obj = (cl_program) malloc(sizeof(cl_program)); + obj->dispatch = dispatchTable; + test_icd_stub_log("clLinkProgram(%p, %u, %p, %p, %u, %p, %p, %p, %p)\n", + context, + num_devices, + device_list, + options, + num_input_programs, + input_programs, + pfn_notify, + user_data, + errcode_ret); + pfn_notify(obj, NULL); + test_icd_stub_log("program_callback(%p, %p)\n", obj, NULL); + test_icd_stub_log("Value returned: %p\n", obj); + return obj; +} + + +CL_API_ENTRY cl_int CL_API_CALL +clUnloadPlatformCompiler(cl_platform_id platform) CL_API_SUFFIX__VERSION_1_2 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clUnloadPlatformCompiler(%p)\n", platform); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetProgramInfo(cl_program program , + cl_program_info param_name , + size_t param_value_size , + void * param_value , + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clGetProgramInfo(%p, %u, %u, %p, %p)\n", + program, + param_name, + param_value_size, + param_value, + param_value_size_ret); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetProgramBuildInfo(cl_program program , + cl_device_id device , + cl_program_build_info param_name , + size_t param_value_size , + void * param_value , + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clGetProgramBuildInfo(%p, %p, %u, %u, %p, %p)\n", + program, + device, + param_name, + param_value_size, + param_value, + param_value_size_ret); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +/* Kernel Object APIs */ +CL_API_ENTRY cl_kernel CL_API_CALL +clCreateKernel(cl_program program , + const char * kernel_name , + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_kernel obj = (cl_kernel) malloc(sizeof(struct _cl_kernel)); + obj->dispatch = dispatchTable; + test_icd_stub_log("clCreateKernel(%p, %p, %p)\n", + program, + kernel_name, + errcode_ret); + + test_icd_stub_log("Value returned: %p\n", obj); + return obj; +} + +CL_API_ENTRY cl_int CL_API_CALL +clCreateKernelsInProgram(cl_program program , + cl_uint num_kernels , + cl_kernel * kernels , + cl_uint * num_kernels_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clCreateKernelsInProgram(%p, %u, %p, %p)\n", + program, + num_kernels, + kernels, + num_kernels_ret); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clRetainKernel(cl_kernel kernel) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clRetainKernel(%p)\n", kernel); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clReleaseKernel(cl_kernel kernel) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clReleaseKernel(%p)\n", kernel); + free(kernel); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clSetKernelArg(cl_kernel kernel , + cl_uint arg_index , + size_t arg_size , + const void * arg_value) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clSetKernelArg(%p, %u, %u, %p)\n", + kernel, + arg_index, + arg_size, + arg_value); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetKernelInfo(cl_kernel kernel , + cl_kernel_info param_name , + size_t param_value_size , + void * param_value , + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clGetKernelInfo(%p, %u, %u, %p, %p)\n", + kernel, + param_name, + param_value_size, + param_value, + param_value_size_ret); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetKernelArgInfo(cl_kernel kernel , + cl_uint arg_indx , + cl_kernel_arg_info param_name , + size_t param_value_size , + void * param_value , + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_2 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clGetKernelArgInfo(%p, %u, %u, %u, %p, %p)\n", + kernel, + arg_indx, + param_name, + param_value_size, + param_value, + param_value_size_ret); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetKernelWorkGroupInfo(cl_kernel kernel , + cl_device_id device , + cl_kernel_work_group_info param_name , + size_t param_value_size , + void * param_value , + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clGetKernelWorkGroupInfo(%p, %p, %u, %u, %p, %p)\n", + kernel, + device, + param_name, + param_value_size, + param_value, + param_value_size_ret); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +/* Event Object APIs */ +CL_API_ENTRY cl_int CL_API_CALL +clWaitForEvents(cl_uint num_events , + const cl_event * event_list) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clWaitForEvents(%u, %p)\n", + num_events, + event_list); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetEventInfo(cl_event event , + cl_event_info param_name , + size_t param_value_size , + void * param_value , + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clGetEventInfo(%p, %u, %u, %p, %p)\n", + event, + param_name, + param_value_size, + param_value, + param_value_size_ret); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_event CL_API_CALL +clCreateUserEvent(cl_context context , + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_1 +{ + cl_event obj = (cl_event) malloc(sizeof(struct _cl_event)); + obj->dispatch = dispatchTable; + test_icd_stub_log("clCreateUserEvent(%p, %p)\n", context, errcode_ret); + test_icd_stub_log("Value returned: %p\n", obj); + return obj; +} + +CL_API_ENTRY cl_int CL_API_CALL +clRetainEvent(cl_event event) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clRetainEvent(%p)\n", event); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clReleaseEvent(cl_event event) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clReleaseEvent(%p)\n", event); + free(event); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clSetUserEventStatus(cl_event event , + cl_int execution_status) CL_API_SUFFIX__VERSION_1_1 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clSetUserEventStatus(%p, %d)\n", + event, + execution_status); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clSetEventCallback(cl_event event , + cl_int command_exec_callback_type , + void (CL_CALLBACK * pfn_notify)(cl_event, cl_int, void *), + void * user_data) CL_API_SUFFIX__VERSION_1_1 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clSetEventCallback(%p, %d, %p, %p)\n", + event, + command_exec_callback_type, + pfn_notify, + user_data); + pfn_notify(event, command_exec_callback_type, NULL); + test_icd_stub_log("setevent_callback(%p, %d, %p)\n", + event, + command_exec_callback_type, + NULL); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +/* Profiling APIs */ +CL_API_ENTRY cl_int CL_API_CALL +clGetEventProfilingInfo(cl_event event , + cl_profiling_info param_name , + size_t param_value_size , + void * param_value , + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clGetEventProfilingInfo(%p, %u, %u, %p, %p)\n", + event, + param_name, + param_value_size, + param_value, + param_value_size_ret); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +/* Flush and Finish APIs */ +CL_API_ENTRY cl_int CL_API_CALL +clFlush(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clFlush(%p)\n", command_queue); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clFinish(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clFinish(%p)\n", command_queue); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +/* Enqueued Commands APIs */ +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueReadBuffer(cl_command_queue command_queue , + cl_mem buffer , + cl_bool blocking_read , + size_t offset , + size_t cb , + void * ptr , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueReadBuffer(%p, %p, %u, %u, %u, %p, %u, %p, %p)\n", + command_queue, + buffer, + blocking_read, + offset, + cb, + ptr, + num_events_in_wait_list, + event_wait_list, event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueReadBufferRect(cl_command_queue command_queue , + cl_mem buffer , + cl_bool blocking_read , + const size_t * buffer_origin , + const size_t * host_origin , + const size_t * region , + size_t buffer_row_pitch , + size_t buffer_slice_pitch , + size_t host_row_pitch , + size_t host_slice_pitch , + void * ptr , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_1 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueReadBufferRect(%p, %p, %u, %p, %p, %p, %u, %u, %u, %u, %p, %u, %p, %p)\n", + command_queue, + buffer, + blocking_read, + buffer_origin, + host_origin, + region, + buffer_row_pitch, + buffer_slice_pitch, + host_row_pitch, + host_slice_pitch, + ptr, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueWriteBuffer(cl_command_queue command_queue , + cl_mem buffer , + cl_bool blocking_write , + size_t offset , + size_t cb , + const void * ptr , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueWriteBuffer(%p, %p, %u, %u, %u, %p, %u, %p, %p)\n", + command_queue, + buffer, + blocking_write, + offset, + cb, + ptr, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueWriteBufferRect(cl_command_queue command_queue , + cl_mem buffer , + cl_bool blocking_write , + const size_t * buffer_origin , + const size_t * host_origin , + const size_t * region , + size_t buffer_row_pitch , + size_t buffer_slice_pitch , + size_t host_row_pitch , + size_t host_slice_pitch , + const void * ptr , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_1 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueWriteBufferRect(%p, %p, %u, %p, %p, %p, %u, %u, %u, %u, %p, %u, %p, %p)\n", + command_queue, + buffer, + blocking_write, + buffer_origin, + host_origin, + region, + buffer_row_pitch, + buffer_slice_pitch, + host_row_pitch, + host_slice_pitch, + ptr, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueCopyBuffer(cl_command_queue command_queue , + cl_mem src_buffer , + cl_mem dst_buffer , + size_t src_offset , + size_t dst_offset , + size_t cb , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueCopyBuffer(%p, %p, %p, %u, %u, %u, %u, %p, %p)\n", + command_queue, + src_buffer, + dst_buffer, + src_offset, + dst_offset, + cb, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueCopyBufferRect(cl_command_queue command_queue , + cl_mem src_buffer , + cl_mem dst_buffer , + const size_t * src_origin , + const size_t * dst_origin , + const size_t * region , + size_t src_row_pitch , + size_t src_slice_pitch , + size_t dst_row_pitch , + size_t dst_slice_pitch , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_1 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueCopyBufferRect(%p, %p, %p, %p, %p, %p, %u, %u, %u, %u, %u, %p, %p)\n", + command_queue, + src_buffer, + dst_buffer, + src_origin, + dst_origin, + region, + src_row_pitch, + src_slice_pitch, + dst_row_pitch, + dst_slice_pitch, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueFillBuffer(cl_command_queue command_queue , + cl_mem buffer , + const void * pattern , + size_t pattern_size , + size_t offset , + size_t cb , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_2 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueFillBuffer(%p, %p, %p, %u, %u, %u, %u, %p, %p)\n", + command_queue, + buffer, + pattern, + pattern_size, + offset, + cb, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueFillImage(cl_command_queue command_queue , + cl_mem image , + const void * fill_color , + const size_t * origin , + const size_t * region , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_2 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueFillImage(%p, %p, %p, %p, %p, %u, %p, %p)\n", + command_queue, + image, + fill_color, + origin, + region, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueReadImage(cl_command_queue command_queue , + cl_mem image , + cl_bool blocking_read , + const size_t * origin , + const size_t * region , + size_t row_pitch , + size_t slice_pitch , + void * ptr , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueReadImage(%p, %p, %u, %p, %p, %u, %u, %p, %u, %p, %p)\n", + command_queue, + image, + blocking_read, + origin, + region, + row_pitch, + slice_pitch, + ptr, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueWriteImage(cl_command_queue command_queue , + cl_mem image , + cl_bool blocking_write , + const size_t * origin , + const size_t * region , + size_t input_row_pitch , + size_t input_slice_pitch , + const void * ptr , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueWriteImage(%p, %p, %u, %p, %p, %u, %u, %p, %u, %p, %p)\n", + command_queue, + image, + blocking_write, + origin, + region, + input_row_pitch, + input_slice_pitch, + ptr, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueCopyImage(cl_command_queue command_queue , + cl_mem src_image , + cl_mem dst_image , + const size_t * src_origin , + const size_t * dst_origin , + const size_t * region , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueCopyImage(%p, %p, %p, %p, %p, %p, %u, %p, %p)\n", + command_queue, + src_image, + dst_image, + src_origin, + dst_origin, + region, + num_events_in_wait_list, + event_wait_list , + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueCopyImageToBuffer(cl_command_queue command_queue , + cl_mem src_image , + cl_mem dst_buffer , + const size_t * src_origin , + const size_t * region , + size_t dst_offset , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueCopyImageToBuffer(%p, %p, %p, %p, %p, %u, %u, %p, %p)\n", + command_queue, + src_image, + dst_buffer, + src_origin, + region, + dst_offset, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueCopyBufferToImage(cl_command_queue command_queue , + cl_mem src_buffer , + cl_mem dst_image , + size_t src_offset , + const size_t * dst_origin , + const size_t * region , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueCopyBufferToImage(%p, %p, %p, %u, %p, %p, %u, %p, %p)\n", + command_queue, + src_buffer, + dst_image, + src_offset, + dst_origin, + region, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY void * CL_API_CALL +clEnqueueMapBuffer(cl_command_queue command_queue , + cl_mem buffer , + cl_bool blocking_map , + cl_map_flags map_flags , + size_t offset , + size_t cb , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event , + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + void *return_value = (void *) malloc(sizeof(void *)); + test_icd_stub_log("clEnqueueMapBuffer(%p, %p, %u, %x, %u, %u, %u, %p, %p, %p)\n", + command_queue, + buffer, + blocking_map, + map_flags, + offset, + cb, + num_events_in_wait_list, + event_wait_list, + event, + errcode_ret); + + test_icd_stub_log("Value returned: %p\n", return_value); + return return_value; +} + +CL_API_ENTRY void * CL_API_CALL +clEnqueueMapImage(cl_command_queue command_queue , + cl_mem image , + cl_bool blocking_map , + cl_map_flags map_flags , + const size_t * origin , + const size_t * region , + size_t * image_row_pitch , + size_t * image_slice_pitch , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event , + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + void *return_value = (void *) malloc(sizeof(void *)); + test_icd_stub_log("clEnqueueMapImage(%p, %p, %u, %x, %p, %p, %p, %p, %u, %p, %p, %p)\n", + command_queue, + image, + blocking_map, + map_flags, + origin, + region, + image_row_pitch, + image_slice_pitch, + num_events_in_wait_list, + event_wait_list, + event, + errcode_ret); + + test_icd_stub_log("Value returned: %p\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueUnmapMemObject(cl_command_queue command_queue , + cl_mem memobj , + void * mapped_ptr , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueUnmapMemObject(%p, %p, %p, %u, %p, %p)\n", + command_queue, + memobj, + mapped_ptr, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueMigrateMemObjects(cl_command_queue command_queue , + cl_uint num_mem_objects , + const cl_mem * mem_objects , + cl_mem_migration_flags flags , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_2 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueMigrateMemObjects(%p, %u, %p, %x, %u, %p, %p)\n", + command_queue, + num_mem_objects, + mem_objects, + flags, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueNDRangeKernel(cl_command_queue command_queue , + cl_kernel kernel , + cl_uint work_dim , + const size_t * global_work_offset , + const size_t * global_work_size , + const size_t * local_work_size , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueNDRangeKernel(%p, %p, %u, %p, %p, %p, %u, %p, %p)\n", + command_queue, + kernel, + work_dim, + global_work_offset, + global_work_size, + local_work_size, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueTask(cl_command_queue command_queue , + cl_kernel kernel , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueTask(%p, %p, %u, %p, %p)\n", + command_queue, + kernel, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueNativeKernel(cl_command_queue command_queue , + void (CL_CALLBACK *user_func)(void *), + void * args , + size_t cb_args , + cl_uint num_mem_objects , + const cl_mem * mem_list , + const void ** args_mem_loc , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueNativeKernel(%p, %p, %p, %u, %u, %p, %p, %u, %p, %p)\n", + command_queue, + user_func, + args, + cb_args, + num_mem_objects, + mem_list, + args_mem_loc, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY void * CL_API_CALL +clGetExtensionFunctionAddressForPlatform(cl_platform_id platform , + const char * func_name) CL_API_SUFFIX__VERSION_1_2 +{ + void *return_value = (void *) malloc(sizeof(void *)); + test_icd_stub_log("clGetExtensionFunctionAddressForPlatform(%p, %p)\n", + platform, + func_name); + + test_icd_stub_log("Value returned: %p\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueMarkerWithWaitList(cl_command_queue command_queue , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_2 + +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueMarkerWithWaitList(%p, %u, %p, %p)\n", + command_queue, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueBarrierWithWaitList(cl_command_queue command_queue , + cl_uint num_events_in_wait_list , + const cl_event * event_wait_list , + cl_event * event) CL_API_SUFFIX__VERSION_1_2 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueBarrierWithWaitList(%p, %u, %p, %p)\n", + command_queue, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +extern CL_API_ENTRY cl_int CL_API_CALL +clSetPrintfCallback(cl_context context , + void (CL_CALLBACK * pfn_notify)(cl_context program , + cl_uint printf_data_len , + char * printf_data_ptr , + void * user_data), + void * user_data) CL_API_SUFFIX__VERSION_1_2 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clSetPrintfCallback(%p, %p, %p)\n", + context, + pfn_notify, + user_data); + pfn_notify(context, 0, NULL, NULL); + test_icd_stub_log("setprintf_callback(%p, %u, %p, %p)\n", + context, + 0, + NULL, + NULL); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueMarker(cl_command_queue command_queue , + cl_event * event) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueMarker(%p, %p)\n", command_queue, event); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueWaitForEvents(cl_command_queue command_queue , + cl_uint num_events , + const cl_event * event_list) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueWaitForEvents(%p, %u, %p)\n", + command_queue, + num_events, + event_list); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueBarrier(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clEnqueueBarrier(%p)\n", command_queue); + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + +extern cl_int cliIcdDispatchTableCreate(CLIicdDispatchTable **outDispatchTable); + +CL_API_ENTRY cl_int CL_API_CALL +clIcdGetPlatformIDsKHR(cl_uint num_entries, + cl_platform_id * platforms, + cl_uint * num_platforms) +{ + cl_int result = CL_SUCCESS; + if (!initialized) { + result = cliIcdDispatchTableCreate(&dispatchTable); + platform = (cl_platform_id) malloc(sizeof(struct _cl_platform_id)); + memset(platform, 0, sizeof(struct _cl_platform_id)); + + platform->dispatch = dispatchTable; + platform->version = "OpenCL 1.2 Stub"; + platform->vendor = "stubvendorxxx"; + platform->profile = "stubprofilexxx"; + platform->name = "ICD_LOADER_TEST_OPENCL_STUB"; + platform->extensions = "cl_khr_icd cl_khr_gl cl_khr_d3d10"; + platform->suffix = "ilts"; + platform->dispatch = dispatchTable; + initialized = CL_TRUE; + } + + if ((platforms && num_entries >1) || + (platforms && num_entries <= 0) || + (!platforms && num_entries >= 1)) { + result = CL_INVALID_VALUE; + goto Done; + } + + if (platforms && num_entries == 1) { + platforms[0] = platform; + } + +Done: + if (num_platforms) { + *num_platforms = 1; + } + + return result; +} + diff --git a/opencl/khronos/icd/test/driver_stub/cl_ext.c b/opencl/khronos/icd/test/driver_stub/cl_ext.c new file mode 100644 index 0000000000..ece0c591b2 --- /dev/null +++ b/opencl/khronos/icd/test/driver_stub/cl_ext.c @@ -0,0 +1,35 @@ +#include + +#define CL_USE_DEPRECATED_OPENCL_1_1_APIS +#include "CL/cl.h" +#include "CL/cl_ext.h" + +struct driverStubextFunc_st +{ + const char *name; + void *func; +}; + +#define EXT_FUNC(name) { #name, (void*)(name) } + +static struct driverStubextFunc_st clExtensions[] = +{ + EXT_FUNC(clIcdGetPlatformIDsKHR), +}; + +static const int clExtensionCount = sizeof(clExtensions) / sizeof(clExtensions[0]); + +CL_API_ENTRY void * CL_API_CALL +clGetExtensionFunctionAddress(const char *name) +{ + int ii; + + for (ii = 0; ii < clExtensionCount; ii++) { + if (!strcmp(name, clExtensions[ii].name)) { + return clExtensions[ii].func; + } + } + + return NULL; +} + diff --git a/opencl/khronos/icd/test/driver_stub/cl_gl.c b/opencl/khronos/icd/test/driver_stub/cl_gl.c new file mode 100644 index 0000000000..3cc5cbb80a --- /dev/null +++ b/opencl/khronos/icd/test/driver_stub/cl_gl.c @@ -0,0 +1,221 @@ +#include +#include +#include + +// Need to rename all CL API functions to prevent ICD loader functions calling +// themselves via the dispatch table. Include this before cl headers. +#include "rename_api.h" + +#define SIZE_T_MAX (size_t) 0xFFFFFFFFFFFFFFFFULL + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromGLBuffer(cl_context context , + cl_mem_flags flags , + cl_GLuint bufret_mem , + int * errcode_ret ) CL_API_SUFFIX__VERSION_1_0 +{ + cl_mem ret_mem = (cl_mem)(SIZE_T_MAX); + test_icd_stub_log("clCreateFromGLBuffer(%p, %x, %u, %p)\n", + context, + flags, + bufret_mem, + errcode_ret); + test_icd_stub_log("Value returned: %p\n", + ret_mem); + return ret_mem; +} + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromGLTexture(cl_context context , + cl_mem_flags flags , + cl_GLenum target , + cl_GLint miplevel , + cl_GLuint texture , + cl_int * errcode_ret ) CL_API_SUFFIX__VERSION_1_2 +{ + cl_mem ret_mem = (cl_mem)(SIZE_T_MAX); + test_icd_stub_log("clCreateFromGLTexture(%p, %x, %d, %d, %u, %p)\n", + context , + flags , + target , + miplevel , + texture , + errcode_ret ); + test_icd_stub_log("Value returned: %p\n", + ret_mem); + return ret_mem; +} + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromGLTexture2D(cl_context context, + cl_mem_flags flags, + cl_GLenum target, + cl_GLint miplevel, + cl_GLuint texture, + cl_int * errcode_ret ) CL_API_SUFFIX__VERSION_1_0 +{ + cl_mem ret_mem = (cl_mem)(SIZE_T_MAX); + test_icd_stub_log("clCreateFromGLTexture2D(%p, %x, %d, %d, %u, %p)\n", + context, + flags, + target, + miplevel, + texture, + errcode_ret ); + test_icd_stub_log("Value returned: %p\n", + ret_mem); + return ret_mem; +} + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromGLTexture3D(cl_context context, + cl_mem_flags flags, + cl_GLenum target, + cl_GLint miplevel, + cl_GLuint texture, + cl_int * errcode_ret ) CL_API_SUFFIX__VERSION_1_0 + +{ + cl_mem ret_mem = (cl_mem)(SIZE_T_MAX); + test_icd_stub_log("clCreateFromGLTexture3D(%p, %x, %d, %d, %u, %p)\n", + context, + flags, + target, + miplevel, + texture, + errcode_ret ); + test_icd_stub_log("Value returned: %p\n", + ret_mem); + return ret_mem; +} + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromGLRenderbuffer(cl_context context, + cl_mem_flags flags, + cl_GLuint renderbuffer, + cl_int * errcode_ret ) CL_API_SUFFIX__VERSION_1_0 +{ + cl_mem ret_mem = (cl_mem)(SIZE_T_MAX); + test_icd_stub_log("clCreateFromGLRenderbuffer(%p, %x, %d, %p)\n", + context, + flags, + renderbuffer, + errcode_ret); + test_icd_stub_log("Value returned: %p\n", + ret_mem); + return ret_mem; +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetGLObjectInfo(cl_mem memobj, + cl_gl_object_type * gl_object_type, + cl_GLuint * gl_object_name ) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int ret_val = -5; + test_icd_stub_log("clGetGLObjectInfo(%p, %p, %p)\n", + memobj, + gl_object_type, + gl_object_name); + test_icd_stub_log("Value returned: %p\n", + ret_val); + return ret_val; +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetGLTextureInfo(cl_mem memobj, + cl_gl_texture_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret ) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int ret_val = -5; + test_icd_stub_log("clGetGLTextureInfo(%p, %u, %u, %p, %p)\n", + memobj, + param_name, + param_value_size, + param_value, + param_value_size_ret ); + test_icd_stub_log("Value returned: %p\n", + ret_val); + return ret_val; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueAcquireGLObjects(cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem * mem_objects, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event ) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int ret_val = -5; + test_icd_stub_log("clEnqueueAcquireGLObjects(%p, %u, %p, %u, %p, %p)\n", + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); + + test_icd_stub_log("Value returned: %p\n", + ret_val); + return ret_val; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueReleaseGLObjects(cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem * mem_objects, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event ) CL_API_SUFFIX__VERSION_1_0 + +{ + cl_int ret_val = -5; + test_icd_stub_log("clEnqueueReleaseGLObjects(%p, %u, %p, %u, %p, %p)\n", + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); + test_icd_stub_log("Value returned: %p\n", + ret_val); + return ret_val; +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetGLContextInfoKHR(const cl_context_properties * properties, + cl_gl_context_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret ) CL_API_SUFFIX__VERSION_1_0 +{ + cl_int ret_val = -5; + test_icd_stub_log("clGetGLContextInfoKHR(%p, %u, %u, %p, %p)\n", + properties, + param_name, + param_value_size, + param_value, + param_value_size_ret); + + test_icd_stub_log("Value returned: %p\n", + ret_val); + return ret_val; +} + +CL_API_ENTRY cl_event CL_API_CALL +clCreateEventFromGLsyncKHR(cl_context context , + cl_GLsync cl_GLsync , + cl_int * errcode_ret ) CL_EXT_SUFFIX__VERSION_1_1 + +{ + cl_event ret_event = (cl_event)(SIZE_T_MAX); + test_icd_stub_log("clCreateEventFromGLsyncKHR(%p, %p, %p)\n", + context, + cl_GLsync, + errcode_ret); + test_icd_stub_log("Value returned: %p\n", + ret_event); + return ret_event; +} diff --git a/opencl/khronos/icd/test/driver_stub/driver_stub.def b/opencl/khronos/icd/test/driver_stub/driver_stub.def new file mode 100644 index 0000000000..1ec276011a --- /dev/null +++ b/opencl/khronos/icd/test/driver_stub/driver_stub.def @@ -0,0 +1,2 @@ +EXPORTS +clGetExtensionFunctionAddress diff --git a/opencl/khronos/icd/test/driver_stub/icd.c b/opencl/khronos/icd/test/driver_stub/icd.c new file mode 100644 index 0000000000..d2b1b2bd09 --- /dev/null +++ b/opencl/khronos/icd/test/driver_stub/icd.c @@ -0,0 +1,186 @@ +#include +#include +#include +#include +#include "icd_structs.h" + +#define CL_USE_DEPRECATED_OPENCL_1_0_APIS +#define CL_USE_DEPRECATED_OPENCL_1_1_APIS +#define CL_USE_DEPRECATED_OPENCL_1_2_APIS + +// Need to rename all CL API functions to prevent ICD loader functions calling +// themselves via the dispatch table. Include this before cl headers. +#include "rename_api.h" + +#include "CL/cl.h" +#include "CL/cl_gl.h" +#include "CL/cl_gl_ext.h" + +/* + * Prototypes for deprecated functions no longer present in cl.h + */ +extern CL_API_ENTRY cl_int CL_API_CALL +clSetCommandQueueProperty(cl_command_queue /* command_queue */, + cl_command_queue_properties /* properties */, + cl_bool /* enable */, + cl_command_queue_properties * /* old_properties */); + +#define ICD_DISPATCH_TABLE_ENTRY(fn) \ + assert(dispatchTable->entryCount < 256); \ + dispatchTable->entries[dispatchTable->entryCount++] = (void*)(fn) + +cl_int cliIcdDispatchTableCreate(CLIicdDispatchTable **outDispatchTable) +{ + CLIicdDispatchTable *dispatchTable = NULL; + cl_int result = CL_SUCCESS; + + // allocate the public handle + dispatchTable = (CLIicdDispatchTable *) malloc(sizeof(*dispatchTable)); + if (!dispatchTable) { + result = CL_OUT_OF_HOST_MEMORY; + goto Error; + } + memset(dispatchTable, 0, sizeof(*dispatchTable)); + + // OpenCL 1.0 + ICD_DISPATCH_TABLE_ENTRY ( clGetPlatformIDs ); + ICD_DISPATCH_TABLE_ENTRY ( clGetPlatformInfo ); + ICD_DISPATCH_TABLE_ENTRY ( clGetDeviceIDs ); + ICD_DISPATCH_TABLE_ENTRY ( clGetDeviceInfo ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateContext ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateContextFromType ); + ICD_DISPATCH_TABLE_ENTRY ( clRetainContext ); + ICD_DISPATCH_TABLE_ENTRY ( clReleaseContext ); + ICD_DISPATCH_TABLE_ENTRY ( clGetContextInfo ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateCommandQueue ); + ICD_DISPATCH_TABLE_ENTRY ( clRetainCommandQueue ); + ICD_DISPATCH_TABLE_ENTRY ( clReleaseCommandQueue ); + ICD_DISPATCH_TABLE_ENTRY ( clGetCommandQueueInfo ); + ICD_DISPATCH_TABLE_ENTRY ( clSetCommandQueueProperty ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateBuffer ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateImage2D ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateImage3D ); + ICD_DISPATCH_TABLE_ENTRY ( clRetainMemObject ); + ICD_DISPATCH_TABLE_ENTRY ( clReleaseMemObject ); + ICD_DISPATCH_TABLE_ENTRY ( clGetSupportedImageFormats ); + ICD_DISPATCH_TABLE_ENTRY ( clGetMemObjectInfo ); + ICD_DISPATCH_TABLE_ENTRY ( clGetImageInfo ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateSampler ); + ICD_DISPATCH_TABLE_ENTRY ( clRetainSampler ); + ICD_DISPATCH_TABLE_ENTRY ( clReleaseSampler ); + ICD_DISPATCH_TABLE_ENTRY ( clGetSamplerInfo ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateProgramWithSource ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateProgramWithBinary ); + ICD_DISPATCH_TABLE_ENTRY ( clRetainProgram ); + ICD_DISPATCH_TABLE_ENTRY ( clReleaseProgram ); + ICD_DISPATCH_TABLE_ENTRY ( clBuildProgram ); + ICD_DISPATCH_TABLE_ENTRY ( clUnloadCompiler ); + ICD_DISPATCH_TABLE_ENTRY ( clGetProgramInfo ); + ICD_DISPATCH_TABLE_ENTRY ( clGetProgramBuildInfo ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateKernel ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateKernelsInProgram ); + ICD_DISPATCH_TABLE_ENTRY ( clRetainKernel ); + ICD_DISPATCH_TABLE_ENTRY ( clReleaseKernel ); + ICD_DISPATCH_TABLE_ENTRY ( clSetKernelArg ); + ICD_DISPATCH_TABLE_ENTRY ( clGetKernelInfo ); + ICD_DISPATCH_TABLE_ENTRY ( clGetKernelWorkGroupInfo ); + ICD_DISPATCH_TABLE_ENTRY ( clWaitForEvents ); + ICD_DISPATCH_TABLE_ENTRY ( clGetEventInfo ); + ICD_DISPATCH_TABLE_ENTRY ( clRetainEvent ); + ICD_DISPATCH_TABLE_ENTRY ( clReleaseEvent ); + ICD_DISPATCH_TABLE_ENTRY ( clGetEventProfilingInfo ); + ICD_DISPATCH_TABLE_ENTRY ( clFlush ); + ICD_DISPATCH_TABLE_ENTRY ( clFinish ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueReadBuffer ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueWriteBuffer ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueCopyBuffer ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueReadImage ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueWriteImage ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueCopyImage ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueCopyImageToBuffer ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueCopyBufferToImage ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueMapBuffer ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueMapImage ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueUnmapMemObject ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueNDRangeKernel ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueTask ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueNativeKernel ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueMarker ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueWaitForEvents ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueBarrier ); + ICD_DISPATCH_TABLE_ENTRY ( clGetExtensionFunctionAddress ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateFromGLBuffer ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateFromGLTexture2D ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateFromGLTexture3D ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateFromGLRenderbuffer ); + ICD_DISPATCH_TABLE_ENTRY ( clGetGLObjectInfo ); + ICD_DISPATCH_TABLE_ENTRY ( clGetGLTextureInfo ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueAcquireGLObjects ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueReleaseGLObjects ); + + // cl_khr_gl_sharing + ICD_DISPATCH_TABLE_ENTRY ( clGetGLContextInfoKHR ); + + // cl_khr_d3d10_sharing (windows-only) +#if 0 && defined(_WIN32) + ICD_DISPATCH_TABLE_ENTRY ( clGetDeviceIDsFromD3D10KHR ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateFromD3D10BufferKHR ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateFromD3D10Texture2DKHR ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateFromD3D10Texture3DKHR ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueAcquireD3D10ObjectsKHR ); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueReleaseD3D10ObjectsKHR ); +#else + ICD_DISPATCH_TABLE_ENTRY( NULL ); + ICD_DISPATCH_TABLE_ENTRY( NULL ); + ICD_DISPATCH_TABLE_ENTRY( NULL ); + ICD_DISPATCH_TABLE_ENTRY( NULL ); + ICD_DISPATCH_TABLE_ENTRY( NULL ); + ICD_DISPATCH_TABLE_ENTRY( NULL ); +#endif + + // OpenCL 1.1 + ICD_DISPATCH_TABLE_ENTRY ( clSetEventCallback); + ICD_DISPATCH_TABLE_ENTRY ( clCreateSubBuffer); + ICD_DISPATCH_TABLE_ENTRY ( clSetMemObjectDestructorCallback); + ICD_DISPATCH_TABLE_ENTRY ( clCreateUserEvent); + ICD_DISPATCH_TABLE_ENTRY ( clSetUserEventStatus); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueReadBufferRect); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueWriteBufferRect); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueCopyBufferRect); + + ICD_DISPATCH_TABLE_ENTRY ( /*clCreateSubDevicesEXT*/NULL); + ICD_DISPATCH_TABLE_ENTRY ( /*clRetainDeviceEXT*/ NULL); + ICD_DISPATCH_TABLE_ENTRY ( /*clReleaseDevice*/NULL); + + ICD_DISPATCH_TABLE_ENTRY ( clCreateEventFromGLsyncKHR); + + ICD_DISPATCH_TABLE_ENTRY ( clCreateSubDevices); + ICD_DISPATCH_TABLE_ENTRY ( clRetainDevice); + ICD_DISPATCH_TABLE_ENTRY ( clReleaseDevice); + ICD_DISPATCH_TABLE_ENTRY ( clCreateImage); + ICD_DISPATCH_TABLE_ENTRY ( clCreateProgramWithBuiltInKernels); + ICD_DISPATCH_TABLE_ENTRY ( clCompileProgram); + ICD_DISPATCH_TABLE_ENTRY ( clLinkProgram); + ICD_DISPATCH_TABLE_ENTRY ( clUnloadPlatformCompiler); + ICD_DISPATCH_TABLE_ENTRY ( clGetKernelArgInfo); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueFillBuffer); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueFillImage); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueMigrateMemObjects); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueMarkerWithWaitList); + ICD_DISPATCH_TABLE_ENTRY ( clEnqueueBarrierWithWaitList); + ICD_DISPATCH_TABLE_ENTRY ( clGetExtensionFunctionAddressForPlatform); + ICD_DISPATCH_TABLE_ENTRY ( clCreateFromGLTexture); + + // return success + *outDispatchTable = dispatchTable; + return CL_SUCCESS; + +Error: + return result; +} + +void +cliIcdDispatchTableDestroy(CLIicdDispatchTable *dispatchTable) +{ + free(dispatchTable); +} diff --git a/opencl/khronos/icd/test/driver_stub/icd_driver_exports.map b/opencl/khronos/icd/test/driver_stub/icd_driver_exports.map new file mode 100644 index 0000000000..c6386a26ea --- /dev/null +++ b/opencl/khronos/icd/test/driver_stub/icd_driver_exports.map @@ -0,0 +1,8 @@ +{ + global: +clGetExtensionFunctionAddress; +clGetPlatformInfo; + + local: + *; +}; diff --git a/opencl/khronos/icd/test/driver_stub/icd_structs.h b/opencl/khronos/icd/test/driver_stub/icd_structs.h new file mode 100644 index 0000000000..4b7e68b118 --- /dev/null +++ b/opencl/khronos/icd/test/driver_stub/icd_structs.h @@ -0,0 +1,18 @@ +#ifndef _ICD_STRUCTS_H_ +#define _ICD_STRUCTS_H_ + +typedef struct CLIicdDispatchTable_st CLIicdDispatchTable; +typedef struct CLIplatform_st CLIplatform; + +struct CLIicdDispatchTable_st +{ + void *entries[256]; + int entryCount; +}; + +struct CLIplatform_st +{ + CLIicdDispatchTable* dispatch; +}; + +#endif /* _ICD_STRUCTS_H_ */ diff --git a/opencl/khronos/icd/test/driver_stub/rename_api.h b/opencl/khronos/icd/test/driver_stub/rename_api.h new file mode 100644 index 0000000000..7d5130cec3 --- /dev/null +++ b/opencl/khronos/icd/test/driver_stub/rename_api.h @@ -0,0 +1,106 @@ +#ifndef _RENAME_API_H_ +#define _RENAME_API_H_ + +#define clGetPlatformIDs ___clGetPlatformIDs +#define clGetPlatformInfo ___clGetPlatformInfo +#define clGetDeviceIDs ___clGetDeviceIDs +#define clGetDeviceInfo ___clGetDeviceInfo +#define clCreateSubDevices ___clCreateSubDevices +#define clRetainDevice ___clRetainDevice +#define clReleaseDevice ___clReleaseDevice +#define clCreateContext ___clCreateContext +#define clCreateContextFromType ___clCreateContextFromType +#define clRetainContext ___clRetainContext +#define clReleaseContext ___clReleaseContext +#define clGetContextInfo ___clGetContextInfo +#define clCreateCommandQueue ___clCreateCommandQueue +#define clSetCommandQueueProperty ___clSetCommandQueueProperty +#define clRetainCommandQueue ___clRetainCommandQueue +#define clReleaseCommandQueue ___clReleaseCommandQueue +#define clGetCommandQueueInfo ___clGetCommandQueueInfo +#define clCreateBuffer ___clCreateBuffer +#define clCreateSubBuffer ___clCreateSubBuffer +#define clCreateImage ___clCreateImage +#define clCreateImage2D ___clCreateImage2D +#define clCreateImage3D ___clCreateImage3D +#define clRetainMemObject ___clRetainMemObject +#define clReleaseMemObject ___clReleaseMemObject +#define clGetSupportedImageFormats ___clGetSupportedImageFormats +#define clGetMemObjectInfo ___clGetMemObjectInfo +#define clGetImageInfo ___clGetImageInfo +#define clSetMemObjectDestructorCallback ___clSetMemObjectDestructorCallback +#define clCreateSampler ___clCreateSampler +#define clRetainSampler ___clRetainSampler +#define clReleaseSampler ___clReleaseSampler +#define clGetSamplerInfo ___clGetSamplerInfo +#define clCreateProgramWithSource ___clCreateProgramWithSource +#define clCreateProgramWithBinary ___clCreateProgramWithBinary +#define clCreateProgramWithBuiltInKernels ___clCreateProgramWithBuiltInKernels +#define clRetainProgram ___clRetainProgram +#define clReleaseProgram ___clReleaseProgram +#define clBuildProgram ___clBuildProgram +#define clUnloadCompiler ___clUnloadCompiler +#define clCompileProgram ___clCompileProgram +#define clLinkProgram ___clLinkProgram +#define clUnloadPlatformCompiler ___clUnloadPlatformCompiler +#define clGetProgramInfo ___clGetProgramInfo +#define clGetProgramBuildInfo ___clGetProgramBuildInfo +#define clCreateKernel ___clCreateKernel +#define clCreateKernelsInProgram ___clCreateKernelsInProgram +#define clRetainKernel ___clRetainKernel +#define clReleaseKernel ___clReleaseKernel +#define clSetKernelArg ___clSetKernelArg +#define clGetKernelInfo ___clGetKernelInfo +#define clGetKernelArgInfo ___clGetKernelArgInfo +#define clGetKernelWorkGroupInfo ___clGetKernelWorkGroupInfo +#define clWaitForEvents ___clWaitForEvents +#define clGetEventInfo ___clGetEventInfo +#define clCreateUserEvent ___clCreateUserEvent +#define clRetainEvent ___clRetainEvent +#define clReleaseEvent ___clReleaseEvent +#define clSetUserEventStatus ___clSetUserEventStatus +#define clSetEventCallback ___clSetEventCallback +#define clGetEventProfilingInfo ___clGetEventProfilingInfo +#define clFlush ___clFlush +#define clFinish ___clFinish +#define clEnqueueReadBuffer ___clEnqueueReadBuffer +#define clEnqueueReadBufferRect ___clEnqueueReadBufferRect +#define clEnqueueWriteBuffer ___clEnqueueWriteBuffer +#define clEnqueueWriteBufferRect ___clEnqueueWriteBufferRect +#define clEnqueueCopyBuffer ___clEnqueueCopyBuffer +#define clEnqueueCopyBufferRect ___clEnqueueCopyBufferRect +#define clEnqueueFillBuffer ___clEnqueueFillBuffer +#define clEnqueueFillImage ___clEnqueueFillImage +#define clEnqueueReadImage ___clEnqueueReadImage +#define clEnqueueWriteImage ___clEnqueueWriteImage +#define clEnqueueCopyImage ___clEnqueueCopyImage +#define clEnqueueCopyImageToBuffer ___clEnqueueCopyImageToBuffer +#define clEnqueueCopyBufferToImage ___clEnqueueCopyBufferToImage +#define clEnqueueMapBuffer ___clEnqueueMapBuffer +#define clEnqueueMapImage ___clEnqueueMapImage +#define clEnqueueUnmapMemObject ___clEnqueueUnmapMemObject +#define clEnqueueMigrateMemObjects ___clEnqueueMigrateMemObjects +#define clEnqueueNDRangeKernel ___clEnqueueNDRangeKernel +#define clEnqueueTask ___clEnqueueTask +#define clEnqueueNativeKernel ___clEnqueueNativeKernel +#define clGetExtensionFunctionAddressForPlatform ___clGetExtensionFunctionAddressForPlatform +#define clEnqueueMarkerWithWaitList ___clEnqueueMarkerWithWaitList +#define clEnqueueBarrierWithWaitList ___clEnqueueBarrierWithWaitList +#define clSetPrintfCallback ___clSetPrintfCallback +#define clEnqueueMarker ___clEnqueueMarker +#define clEnqueueWaitForEvents ___clEnqueueWaitForEvents +#define clEnqueueBarrier ___clEnqueueBarrier + +#define clCreateFromGLBuffer ___clCreateFromGLBuffer +#define clCreateFromGLTexture ___clCreateFromGLTexture +#define clCreateFromGLTexture2D ___clCreateFromGLTexture2D +#define clCreateFromGLTexture3D ___clCreateFromGLTexture3D +#define clCreateFromGLRenderbuffer ___clCreateFromGLRenderbuffer +#define clGetGLObjectInfo ___clGetGLObjectInfo +#define clGetGLTextureInfo ___clGetGLTextureInfo +#define clEnqueueAcquireGLObjects ___clEnqueueAcquireGLObjects +#define clEnqueueReleaseGLObjects ___clEnqueueReleaseGLObjects +#define clGetGLContextInfoKHR ___clGetGLContextInfoKHR +#define clCreateEventFromGLsyncKHR ___clCreateEventFromGLsyncKHR + +#endif /* __RENAME_API_H__ */ diff --git a/opencl/khronos/icd/test/inc/platform/icd_test_log.h b/opencl/khronos/icd/test/inc/platform/icd_test_log.h new file mode 100644 index 0000000000..6db0bfe6ab --- /dev/null +++ b/opencl/khronos/icd/test/inc/platform/icd_test_log.h @@ -0,0 +1,20 @@ +#ifndef _ICD_TEST_LOG_H_ +#define _ICD_TEST_LOG_H_ + +#if defined (_WIN32) +#define DllExport __declspec( dllexport ) +#else +#define DllExport +#endif + +DllExport int test_icd_initialize_app_log(void); +DllExport void test_icd_app_log(const char *format, ...); +DllExport void test_icd_close_app_log(void); +DllExport char *test_icd_get_stub_log(void); + +DllExport int test_icd_initialize_stub_log(void); +DllExport void test_icd_stub_log(const char *format, ...); +DllExport void test_icd_close_stub_log(void); +DllExport char *test_icd_get_app_log(void); + +#endif /* _ICD_TEST_LOG_H_ */ diff --git a/opencl/khronos/icd/test/loader_test/CMakeLists.txt b/opencl/khronos/icd/test/loader_test/CMakeLists.txt new file mode 100644 index 0000000000..ddc675b422 --- /dev/null +++ b/opencl/khronos/icd/test/loader_test/CMakeLists.txt @@ -0,0 +1,15 @@ +add_executable (icd_loader_test + test_kernel.c + main.c + test_platforms.c + icd_test_match.c + test_program_objects.c + test_sampler_objects.c + test_buffer_object.c + test_cl_runtime.c + callbacks.c + test_create_calls.c + test_clgl.c + test_image_objects.c ) + +target_link_libraries (icd_loader_test OpenCL IcdLog) diff --git a/opencl/khronos/icd/test/loader_test/callbacks.c b/opencl/khronos/icd/test/loader_test/callbacks.c new file mode 100644 index 0000000000..8e0b4934bc --- /dev/null +++ b/opencl/khronos/icd/test/loader_test/callbacks.c @@ -0,0 +1,43 @@ +#include +#include +#include + +void CL_CALLBACK createcontext_callback(const char* _a, const void* _b, size_t _c, void* _d) +{ + test_icd_app_log("createcontext_callback(%p, %p, %u, %p)\n", + _a, + _b, + _c, + _d); +} + +void CL_CALLBACK setmemobjectdestructor_callback(cl_mem _a, void* _b) +{ + test_icd_app_log("setmemobjectdestructor_callback(%p, %p)\n", + _a, + _b); +} + +void CL_CALLBACK program_callback(cl_program _a, void* _b) +{ + test_icd_app_log("program_callback(%p, %p)\n", + _a, + _b); +} + +void CL_CALLBACK setevent_callback(cl_event _a, cl_int _b, void* _c) +{ + test_icd_app_log("setevent_callback(%p, %d, %p)\n", + _a, + _b, + _c); +} + +void CL_CALLBACK setprintf_callback(cl_context _a, cl_uint _b, char* _c, void* _d ) +{ + test_icd_app_log("setprintf_callback(%p, %u, %p, %p)\n", + _a, + _b, + _c, + _d); +} diff --git a/opencl/khronos/icd/test/loader_test/icd_test_match.c b/opencl/khronos/icd/test/loader_test/icd_test_match.c new file mode 100644 index 0000000000..a8330b4a26 --- /dev/null +++ b/opencl/khronos/icd/test/loader_test/icd_test_match.c @@ -0,0 +1,38 @@ +#include +#include +#ifndef __APPLE__ +#include +#endif +#include + +int test_icd_match() +{ + int error = 0; + char *app_log = NULL, *stub_log = NULL; + + app_log = test_icd_get_app_log(); + if (!app_log) { + printf("ERROR: Could not retrieve app log\n"); + error = 1; + goto End; + } + + stub_log = test_icd_get_stub_log(); + if (!stub_log) { + printf("ERROR: Could not retrieve stub log\n"); + error = 1; + goto End; + } + + if (strcmp(app_log, stub_log)) { + printf("ERROR: App log and stub log differ.\n"); + error = 1; + goto End; + } + +End: + free(app_log); + free(stub_log); + return error; +} + diff --git a/opencl/khronos/icd/test/loader_test/main.c b/opencl/khronos/icd/test/loader_test/main.c new file mode 100644 index 0000000000..1d783d16bf --- /dev/null +++ b/opencl/khronos/icd/test/loader_test/main.c @@ -0,0 +1,45 @@ +#include +#include +#include +#include "param_struct.h" + +extern int test_create_calls(); +extern int test_platforms(); +extern int test_cl_runtime(); +extern int test_kernel(); +extern int test_buffer_object(); +extern int test_program_objects(); +extern int test_image_objects(); +extern int test_sampler_objects(); +extern int test_OpenGL_share(); +extern int test_release_calls(); + +extern int test_icd_match(); + +int main(int argc, char **argv) +{ + test_icd_initialize_app_log(); + test_icd_initialize_stub_log(); + + test_create_calls(); + test_platforms(); + test_cl_runtime(); + test_kernel(); + test_buffer_object(); + test_program_objects(); + test_image_objects(); + test_sampler_objects(); + test_OpenGL_share(); + test_release_calls(); + + test_icd_close_app_log(); + test_icd_close_stub_log(); + + if (test_icd_match()) { + printf("ICD Loader Test FAILED\n"); + return 1; + } else { + printf("ICD Loader Test PASSED\n"); + return 0; + } +} diff --git a/opencl/khronos/icd/test/loader_test/param_struct.h b/opencl/khronos/icd/test/loader_test/param_struct.h new file mode 100644 index 0000000000..06a1f2bf80 --- /dev/null +++ b/opencl/khronos/icd/test/loader_test/param_struct.h @@ -0,0 +1,1110 @@ +#ifndef _PARAM_STRUCT_H_ +#define _PARAM_STRUCT_H_ + +#include +#include +#include + +struct clCreateCommandQueue_st +{ + cl_context context; + cl_device_id device; + cl_command_queue_properties properties; + cl_int *errcode_ret; +}; + +struct clSetCommandQueueProperty_st +{ + cl_command_queue command_queue; + cl_command_queue_properties properties; + cl_bool enable; + cl_command_queue_properties *old_properties; +}; + +struct clGetCommandQueueInfo_st +{ + cl_command_queue command_queue; + cl_command_queue_info param_name; + size_t param_value_size; + void *param_value; + size_t *param_value_size_ret; +}; + +struct clCreateContext_st +{ + const cl_context_properties *properties; + cl_uint num_devices; + const cl_device_id *devices; + void (CL_CALLBACK*pfn_notify)(const char *errinfo, const void *private_info, size_t cb, void *user_data); + void *user_data; + cl_int *errcode_ret; +}; + +struct clCreateContextFromType_st +{ + const cl_context_properties *properties; + cl_device_type device_type; + void (CL_CALLBACK *pfn_notify)(const char *errinfo, const void *private_info, size_t cb,void *user_data); + void *user_data; + cl_int *errcode_ret; +}; + +struct clRetainContext_st +{ + cl_context context; +}; + +struct clReleaseContext_st +{ + cl_context context; +}; + +struct clGetContextInfo_st +{ + cl_context context; + cl_context_info param_name; + size_t param_value_size; + void *param_value; + size_t *param_value_size_ret; +}; + +struct clGetPlatformIDs_st +{ + cl_uint num_entries; + cl_platform_id *platforms; + cl_uint *num_platforms; +}; + +struct clGetPlatformInfo_st +{ + cl_platform_id platform; + cl_platform_info param_name; + size_t param_value_size; + void *param_value; + size_t *param_value_size_ret; +}; + +struct clGetDeviceIDs_st +{ + cl_platform_id platform; + cl_device_type device_type; + cl_uint num_entries; + cl_device_id *devices; + cl_uint *num_devices; +}; + +struct clRetainCommandQueue_st +{ + cl_command_queue command_queue; +}; + +struct clReleaseCommandQueue_st +{ + cl_command_queue command_queue; +}; + +#define NUM_ITEMS_clCreateCommandQueue 1 +#define NUM_ITEMS_clRetainCommandQueue 1 +#define NUM_ITEMS_clReleaseCommandQueue 1 +#define NUM_ITEMS_clGetCommandQueueInfo 1 +#define NUM_ITEMS_clSetCommandQueueProperty 1 +#define NUM_ITEMS_clCreateContext 1 +#define NUM_ITEMS_clCreateContextFromType 1 +#define NUM_ITEMS_clRetainContext 1 +#define NUM_ITEMS_clReleaseContext 1 +#define NUM_ITEMS_clGetContextInfo 1 +#define NUM_ITEMS_clGetPlatformIDs 1 +#define NUM_ITEMS_clGetPlatformInfo 1 +#define NUM_ITEMS_clGetDeviceIDs 1 +#define NUM_ITEMS_clGetDeviceInfo 1 +#define NUM_ITEMS_clCreateSubDevices 1 +#define NUM_ITEMS_clRetainDevice 1 +#define NUM_ITEMS_clReleaseDevice 1 + +struct clGetDeviceInfo_st +{ + cl_device_id device; + cl_device_info param_name; + size_t param_value_size; + void *param_value; + size_t *param_value_size_ret; +}; + +struct clCreateSubDevices_st +{ + cl_device_id in_device; + cl_device_partition_property *properties; + cl_uint num_entries; + cl_device_id *out_devices; + cl_uint *num_devices; +}; + +struct clRetainDevice_st +{ + cl_device_id device; +}; + +struct clReleaseDevice_st +{ + cl_device_id device; +}; + + +#define NUM_ITEMS_clCreateBuffer 1 +#define NUM_ITEMS_clCreateSubBuffer 1 +#define NUM_ITEMS_clEnqueueReadBuffer 1 +#define NUM_ITEMS_clEnqueueWriteBuffer 1 +#define NUM_ITEMS_clEnqueueReadBufferRect 1 +#define NUM_ITEMS_clEnqueueWriteBufferRect 1 +#define NUM_ITEMS_clEnqueueFillBuffer 1 +#define NUM_ITEMS_clEnqueueCopyBuffer 1 +#define NUM_ITEMS_clEnqueueCopyBufferRect 1 +#define NUM_ITEMS_clEnqueueMapBuffer 1 +#define NUM_ITEMS_clRetainMemObject 1 +#define NUM_ITEMS_clReleaseMemObject 1 +#define NUM_ITEMS_clSetMemObjectDestructorCallback 1 +#define NUM_ITEMS_clEnqueueUnmapMemObject 1 +#define NUM_ITEMS_clGetMemObjectInfo 1 + +struct clCreateBuffer_st +{ + cl_context context; + cl_mem_flags flags; + size_t size; + void *host_ptr; + cl_int *errcode_ret; +}; +struct clCreateSubBuffer_st +{ + cl_mem buffer; + cl_mem_flags flags; + cl_buffer_create_type buffer_create_type; + const void *buffer_create_info; + cl_int *errcode_ret; +}; + +struct clEnqueueReadBuffer_st +{ + cl_command_queue command_queue; + cl_mem buffer; + cl_bool blocking_read; + size_t offset; + size_t cb; + void *ptr; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clEnqueueWriteBuffer_st +{ + cl_command_queue command_queue; + cl_mem buffer; + cl_bool blocking_write; + size_t offset; + size_t cb; + const void *ptr; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clEnqueueReadBufferRect_st +{ + cl_command_queue command_queue; + cl_mem buffer; + cl_bool blocking_read; + const size_t * buffer_offset; + const size_t * host_offset; + const size_t * region; + size_t buffer_row_pitch; + size_t buffer_slice_pitch; + size_t host_row_pitch; + size_t host_slice_pitch; + void *ptr; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clEnqueueWriteBufferRect_st +{ + cl_command_queue command_queue; + cl_mem buffer; + cl_bool blocking_write; + const size_t *buffer_offset; + const size_t *host_offset; + const size_t *region; + size_t buffer_row_pitch; + size_t buffer_slice_pitch; + size_t host_row_pitch; + size_t host_slice_pitch; + void *ptr; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clEnqueueFillBuffer_st +{ + cl_command_queue command_queue; + cl_mem buffer; + const void *pattern; + size_t pattern_size; + size_t offset; + size_t cb; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clEnqueueCopyBuffer_st +{ + cl_command_queue command_queue; + cl_mem src_buffer; + cl_mem dst_buffer; + size_t src_offset; + size_t dst_offset; + size_t cb; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clEnqueueCopyBufferRect_st +{ + cl_command_queue command_queue; + cl_mem src_buffer; + cl_mem dst_buffer; + const size_t *src_origin; + const size_t *dst_origin; + const size_t *region; + size_t src_row_pitch; + size_t src_slice_pitch; + size_t dst_row_pitch; + size_t dst_slice_pitch; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clEnqueueMapBuffer_st +{ + cl_command_queue command_queue; + cl_mem buffer; + cl_bool blocking_map; + cl_map_flags map_flags; + size_t offset; + size_t cb; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; + cl_int *errcode_ret; +}; + +struct clRetainMemObject_st +{ + cl_mem memobj; +}; + +struct clReleaseMemObject_st +{ + cl_mem memobj; +}; + +struct clSetMemObjectDestructorCallback_st +{ + cl_mem memobj; + void (CL_CALLBACK *pfn_notify)(cl_mem memobj, void *user_data); + void *user_data; +}; + +struct clEnqueueUnmapMemObject_st +{ + cl_command_queue command_queue; + cl_mem memobj; + void *mapped_ptr; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clGetMemObjectInfo_st +{ + cl_mem memobj; + cl_mem_info param_name; + size_t param_value_size; + void *param_value; + size_t *param_value_size_ret; +}; + +#define NUM_ITEMS_clCreateProgramWithSource 1 +#define NUM_ITEMS_clCreateProgramWithBinary 1 +#define NUM_ITEMS_clCreateProgramWithBuiltInKernels 1 +#define NUM_ITEMS_clRetainProgram 1 +#define NUM_ITEMS_clReleaseProgram 1 +#define NUM_ITEMS_clBuildProgram 1 +#define NUM_ITEMS_clCompileProgram 1 +#define NUM_ITEMS_clLinkProgram 1 +#define NUM_ITEMS_clUnloadPlatformCompiler 1 +#define NUM_ITEMS_clGetProgramInfo 1 +#define NUM_ITEMS_clGetProgramBuildInfo 1 +#define NUM_ITEMS_clUnloadCompiler 1 +#define NUM_ITEMS_clGetExtensionFunctionAddress 1 +#define NUM_ITEMS_clGetExtensionFunctionAddressForPlatform 1 + +struct clCreateProgramWithSource_st +{ + cl_context context; + cl_uint count; + const char **strings; + const size_t *lengths; + cl_int *errcode_ret; +}; + +struct clCreateProgramWithBinary_st +{ + cl_context context; + cl_uint num_devices; + const cl_device_id *device_list; + const size_t *lengths; + const unsigned char **binaries; + cl_int *binary_status; + cl_int *errcode_ret; +}; + +struct clCreateProgramWithBuiltInKernels_st +{ + cl_context context; + cl_uint num_devices; + const cl_device_id *device_list; + const char *kernel_names; + cl_int *errcode_ret; +}; + +struct clRetainProgram_st +{ + cl_program program; +}; + +struct clReleaseProgram_st +{ + cl_program program; +}; + +struct clBuildProgram_st +{ + cl_program program; + cl_uint num_devices; + const cl_device_id *device_list; + const char *options; + void (CL_CALLBACK*pfn_notify)(cl_program program, void *user_data); + void *user_data; +}; + +struct clCompileProgram_st +{ + cl_program program; + cl_uint num_devices; + const cl_device_id *device_list; + const char *options; + cl_uint num_input_headers; + const cl_program *headers; + const char **header_include_names; + void (CL_CALLBACK *pfn_notify)(cl_program program, void * user_data); + void *user_data; +}; + +struct clLinkProgram_st +{ + cl_context context; + cl_uint num_devices; + const cl_device_id *device_list; + const char *options; + cl_uint num_input_programs; + const cl_program *input_programs; + void (CL_CALLBACK *pfn_notify)(cl_program program, void *user_data); + void *user_data; + cl_int *errcode_ret; +}; + +struct clUnloadPlatformCompiler_st +{ + cl_platform_id platform; +}; + +#if 0 +struct clUnloadCompiler_st +{ + void ; +}; +#endif + +struct clGetExtensionFunctionAddress_st +{ + const char *func_name; +}; + +struct clGetExtensionFunctionAddressForPlatform_st +{ + cl_platform_id platform; + const char *func_name; +}; + +struct clGetProgramInfo_st +{ + cl_program program; + cl_program_info param_name; + size_t param_value_size; + void *param_value; + size_t *param_value_size_ret; +}; + +struct clGetProgramBuildInfo_st +{ + cl_program program; + cl_device_id device; + cl_program_build_info param_name; + size_t param_value_size; + void *param_value; + size_t *param_value_size_ret; +}; + +#define NUM_ITEMS_clCreateImage2D 1 +#define NUM_ITEMS_clCreateImage3D 1 +#define NUM_ITEMS_clCreateImage 1 +#define NUM_ITEMS_clGetSupportedImageFormats 1 +#define NUM_ITEMS_clEnqueueCopyImageToBuffer 1 +#define NUM_ITEMS_clEnqueueCopyBufferToImage 1 +#define NUM_ITEMS_clEnqueueMapImage 1 +#define NUM_ITEMS_clEnqueueReadImage 1 +#define NUM_ITEMS_clEnqueueWriteImage 1 +#define NUM_ITEMS_clEnqueueFillImage 1 +#define NUM_ITEMS_clEnqueueCopyImage 1 +#define NUM_ITEMS_clGetMemObjectInfo 1 +#define NUM_ITEMS_clGetImageInfo 1 + +struct clCreateImage_st +{ + cl_context context; + cl_mem_flags flags; + const cl_image_format *image_format; + const cl_image_desc *image_desc; + void *host_ptr; + cl_int *errcode_ret; +}; + +struct clCreateImage2D_st +{ + cl_context context; + cl_mem_flags flags; + const cl_image_format *image_format; + size_t image_width; + size_t image_height; + size_t image_row_pitch; + void *host_ptr; + cl_int *errcode_ret; +}; + +struct clCreateImage3D_st +{ + cl_context context; + cl_mem_flags flags; + const cl_image_format *image_format; + size_t image_width; + size_t image_height; + size_t image_depth; + size_t image_row_pitch; + size_t image_slice_pitch; + void *host_ptr; + cl_int *errcode_ret; +}; + +struct clGetSupportedImageFormats_st +{ + cl_context context; + cl_mem_flags flags; + cl_mem_object_type image_type; + cl_uint num_entries; + cl_image_format *image_formats; + cl_uint *num_image_formats; +}; + +struct clEnqueueCopyImageToBuffer_st +{ + cl_command_queue command_queue; + cl_mem src_image; + cl_mem dst_buffer; + const size_t *src_origin; + const size_t *region; + size_t dst_offset; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clEnqueueCopyBufferToImage_st +{ + cl_command_queue command_queue; + cl_mem src_buffer; + cl_mem dst_image; + size_t src_offset; + const size_t *dst_origin; + const size_t *region; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clEnqueueMapImage_st +{ + cl_command_queue command_queue; + cl_mem image; + cl_bool blocking_map; + cl_map_flags map_flags; + const size_t *origin; + const size_t *region; + size_t *image_row_pitch; + size_t *image_slice_pitch; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; + cl_int *errcode_ret; +}; + +struct clEnqueueReadImage_st +{ + cl_command_queue command_queue; + cl_mem image; + cl_bool blocking_read; + const size_t *origin; + const size_t *region; + size_t row_pitch; + size_t slice_pitch; + void *ptr; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clEnqueueWriteImage_st +{ + cl_command_queue command_queue; + cl_mem image; + cl_bool blocking_write; + const size_t *origin; + const size_t *region; + size_t input_row_pitch; + size_t input_slice_pitch; + const void *ptr; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clEnqueueFillImage_st +{ + cl_command_queue command_queue; + cl_mem image; + const void *fill_color; + const size_t *origin; + const size_t *region; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clEnqueueCopyImage_st +{ + cl_command_queue command_queue; + cl_mem src_image; + cl_mem dst_image; + const size_t *src_origin; + const size_t *dst_origin; + const size_t *region; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +#if 0 +struct clGetMemObjectInfo_st +{ + cl_mem memobj; + cl_mem_info param_name; + size_t param_value_size; + void *param_value; + size_t *param_value_size_ret; +}; +#endif + +struct clGetImageInfo_st +{ + cl_mem image; + cl_image_info param_name; + size_t param_value_size; + void *param_value; + size_t *param_value_size_ret; +}; + +#define NUM_ITEMS_clCreateSampler 1 +#define NUM_ITEMS_clRetainSampler 1 +#define NUM_ITEMS_clReleaseSampler 1 +#define NUM_ITEMS_clGetSamplerInfo 1 + +struct clCreateSampler_st +{ + cl_context context; + cl_bool normalized_coords; + cl_addressing_mode addressing_mode; + cl_filter_mode filter_mode; + cl_int *errcode_ret; +}; + +struct clRetainSampler_st +{ + cl_sampler sampler; +}; + +struct clReleaseSampler_st +{ + cl_sampler sampler; +}; + +struct clGetSamplerInfo_st +{ + cl_sampler sampler; + cl_sampler_info param_name; + size_t param_value_size; + void *param_value; + size_t *param_value_size_ret; +}; + +#define NUM_ITEMS_clCreateKernel 1 +#define NUM_ITEMS_clCreateKernelsInProgram 1 +#define NUM_ITEMS_clRetainKernel 1 +#define NUM_ITEMS_clReleaseKernel 1 + +struct clCreateKernel_st +{ + cl_program program; + const char *kernel_name; + cl_int *errcode_ret; +}; + +struct clCreateKernelsInProgram_st +{ + cl_program program; + cl_uint num_kernels; + cl_kernel *kernels; + cl_uint *num_kernels_ret; +}; + +struct clRetainKernel_st +{ + cl_kernel kernel; +}; + +struct clReleaseKernel_st +{ + cl_kernel kernel; +}; + +#define NUM_ITEMS_clSetKernelArg 1 +#define NUM_ITEMS_clGetKernelInfo 1 +#define NUM_ITEMS_clGetKernelArgInfo 1 +#define NUM_ITEMS_clGetKernelWorkGroupInfo 1 + +struct clSetKernelArg_st +{ + cl_kernel kernel; + cl_uint arg_index; + size_t arg_size; + const void *arg_value; +}; + +struct clGetKernelInfo_st +{ + cl_kernel kernel; + cl_kernel_info param_name; + size_t param_value_size; + void *param_value; + size_t *param_value_size_ret; +}; + +struct clGetKernelArgInfo_st +{ + cl_kernel kernel; + cl_uint arg_indx; + cl_kernel_arg_info param_name; + size_t param_value_size; + void *param_value; + size_t *param_value_size_ret; +}; + +struct clGetKernelWorkGroupInfo_st +{ + cl_kernel kernel; + cl_device_id device; + cl_kernel_work_group_info param_name; + size_t param_value_size; + void *param_value; + size_t *param_value_size_ret; +}; + +#define NUM_ITEMS_clEnqueueMigrateMemObjects 1 +#define NUM_ITEMS_clEnqueueNDRangeKernel 1 +#define NUM_ITEMS_clEnqueueTask 1 +#define NUM_ITEMS_clEnqueueNativeKernel 1 + +struct clEnqueueMigrateMemObjects_st +{ + cl_command_queue command_queue; + cl_uint num_mem_objects; + const cl_mem *mem_objects; + cl_mem_migration_flags flags; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clEnqueueNDRangeKernel_st +{ + cl_command_queue command_queue; + cl_kernel kernel; cl_uint work_dim; + const size_t *global_work_offset; + const size_t *global_work_size; + const size_t *local_work_size; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clEnqueueTask_st +{ + cl_command_queue command_queue; + cl_kernel kernel; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clEnqueueNativeKernel_st +{ + cl_command_queue command_queue; + void (CL_CALLBACK *user_func)(void *); + void *args; + size_t cb_args; + cl_uint num_mem_objects; + const cl_mem *mem_list; + const void **args_mem_loc; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +#define NUM_ITEMS_clCreateUserEvent 1 +#define NUM_ITEMS_clSetUserEventStatus 1 +#define NUM_ITEMS_clWaitForEvents 1 +#define NUM_ITEMS_clGetEventInfo 1 +#define NUM_ITEMS_clSetEventCallback 1 +#define NUM_ITEMS_clRetainEvent 1 +#define NUM_ITEMS_clReleaseEvent 1 + +struct clCreateUserEvent_st +{ + cl_context context; + cl_int *errcode_ret; +}; + +struct clSetUserEventStatus_st +{ + cl_event event; + cl_int execution_status; +}; + +struct clWaitForEvents_st +{ + cl_uint num_events; + const cl_event *event_list; +}; + +struct clGetEventInfo_st +{ + cl_event event; + cl_event_info param_name; + size_t param_value_size; + void *param_value; + size_t *param_value_size_ret; +}; + +struct clSetEventCallback_st +{ + cl_event event; + cl_int command_exec_callback_type; + void (CL_CALLBACK *pfn_event_notify)(cl_event event, cl_int event_command_exec_status,void *user_data); + void *user_data; +}; + +struct clRetainEvent_st +{ + cl_event event; +}; + +struct clReleaseEvent_st +{ + cl_event event; +}; + +#define NUM_ITEMS_clEnqueueMarker 1 +#define NUM_ITEMS_clEnqueueWaitForEvents 1 +#define NUM_ITEMS_clEnqueueBarrier 1 +#define NUM_ITEMS_clEnqueueMarkerWithWaitList 1 +#define NUM_ITEMS_clEnqueueBarrierWithWaitList 1 + +struct clEnqueueMarker_st +{ + cl_command_queue command_queue; + cl_event *event; +}; + +struct clEnqueueWaitForEvents_st +{ + cl_command_queue command_queue; + cl_uint num_events; + const cl_event *event_list; +}; + +struct clEnqueueBarrier_st +{ + cl_command_queue command_queue; +}; + +struct clEnqueueMarkerWithWaitList_st +{ + cl_command_queue command_queue; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clEnqueueBarrierWithWaitList_st +{ + cl_command_queue command_queue; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +#define NUM_ITEMS_clGetEventProfilingInfo 1 + +struct clGetEventProfilingInfo_st +{ + cl_event event; + cl_profiling_info param_name; + size_t param_value_size; + void *param_value; + size_t *param_value_size_ret; +}; + +#define NUM_ITEMS_clFlush 1 +#define NUM_ITEMS_clFinish 1 + +struct clFlush_st +{ + cl_command_queue command_queue; +}; + +struct clFinish_st +{ + cl_command_queue command_queue; +}; + +#define NUM_ITEMS_clCreateFromGLBuffer 1 +struct clCreateFromGLBuffer_st +{ + cl_context context; + cl_mem_flags flags; + cl_GLuint bufobj; + int *errcode_ret; +}; + +#define NUM_ITEMS_clCreateFromGLTexture 1 +#define NUM_ITEMS_clCreateFromGLTexture2D 1 +#define NUM_ITEMS_clCreateFromGLTexture3D 1 + +struct clCreateFromGLTexture_st +{ + cl_context context; + cl_mem_flags flags; + cl_GLenum texture_target; + cl_GLint miplevel; + cl_GLuint texture; + cl_int *errcode_ret; +}; + +struct clCreateFromGLTexture2D_st +{ + cl_context context; + cl_mem_flags flags; + cl_GLenum texture_target; + cl_GLint miplevel; + cl_GLuint texture; + cl_int *errcode_ret; +}; + +struct clCreateFromGLTexture3D_st +{ + cl_context context; + cl_mem_flags flags; + cl_GLenum texture_target; + cl_GLint miplevel; + cl_GLuint texture; + cl_int *errcode_ret; +}; + +#define NUM_ITEMS_clCreateFromGLRenderbuffer 1 + +struct clCreateFromGLRenderbuffer_st +{ + cl_context context; + cl_mem_flags flags; + cl_GLuint renderbuffer; + cl_int *errcode_ret; +}; + + + // Query Information [9.8.5] +#define NUM_ITEMS_clGetGLObjectInfo 1 +#define NUM_ITEMS_clGetGLTextureInfo 1 + +struct clGetGLObjectInfo_st +{ + cl_mem memobj; + cl_gl_object_type *gl_object_type; + cl_GLuint *gl_object_name; +}; + +struct clGetGLTextureInfo_st +{ + cl_mem memobj; + cl_gl_texture_info param_name; + size_t param_value_size; + void *param_value; + size_t *param_value_size_ret; +}; + +// Share Objects [9.8.6] + +#define NUM_ITEMS_clEnqueueAcquireGLObjects 1 +#define NUM_ITEMS_clEnqueueReleaseGLObjects 1 + +struct clEnqueueAcquireGLObjects_st +{ + cl_command_queue command_queue; + cl_uint num_objects; + const cl_mem *mem_objects; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +struct clEnqueueReleaseGLObjects_st +{ + cl_command_queue command_queue; + cl_uint num_objects; + const cl_mem *mem_objects; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; + +// CL Event Objects > GL Sync Objects [9.9] +#define NUM_ITEMS_clCreateEventFromGLsyncKHR 1 + +struct clCreateEventFromGLsyncKHR_st +{ + cl_context context; + cl_GLsync sync; + cl_int *errcode_ret; +}; + +// CL Context > GL Context; Sharegroup [9.7] +#define NUM_ITEMS_clGetGLContextInfoKHR 1 + +struct clGetGLContextInfoKHR_st +{ + const cl_context_properties *properties; + cl_gl_context_info param_name; + size_t param_value_size; + void *param_value; + size_t *param_value_size_ret; +}; + +#if 0 +// OpenCL/Direct3D 10 Sharing APIs [9.10] + +#define NUM_ITEMS_clGetDeviceIDsFromD3D10KHR 1 +#define NUM_ITEMS_clCreateFromD3D10BufferKHR 1 +#define NUM_ITEMS_clCreateFromD3D10Texture2DKHR 1 +#define NUM_ITEMS_clCreateFromD3D10Texture3DKHR 1 +#define NUM_ITEMS_clEnqueueAcquireD3D10ObjectsKHR 1 +#define NUM_ITEMS_clEnqueueReleaseD3D10ObjectsKHR 1 + +struct clGetDeviceIDsFromD3D10KHR_st +{ + cl_platform_id platform; + cl_d3d10_device_source_khr d3d_device_source; + void *d3d_object; + cl_d3d10_device_set_khr d3d_device_set; + cl_uint num_entries; + cl_device_id *devices; cl_uint *num_devices; +}; + +struct clCreateFromD3D10BufferKHR_st +{ + cl_context context; + cl_mem_flags flags; + ID3D10Buffer *resource; + cl_int *errcode_ret; +}; + +struct clCreateFromD3D10Texture2DKHR_st +{ + cl_context context; + cl_mem_flags flags; + ID3D10Texture2D *resource; + UINT subresource; + cl_int *errcode_ret; +}; + +struct clCreateFromD3D10Texture3DKHR_st +{ + cl_context context; + cl_mem_flags flags; + ID3D10Texture3D *resource; + UINT subresource; + cl_int *errcode_ret; +}; + +struct clEnqueueAcquireD3D10ObjectsKHR_st +{ + cl_command_queue command_queue; + cl_uint num_objects; + const cl_mem *mem_objects; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event;}; + +struct clEnqueueReleaseD3D10ObjectsKHR_st +{ + cl_command_queue command_queue; + cl_uint num_objects; + const cl_mem *mem_objects; + cl_uint num_events_in_wait_list; + const cl_event *event_wait_list; + cl_event *event; +}; +#endif + +#endif /* _PARAM_STRUCT_H_ */ diff --git a/opencl/khronos/icd/test/loader_test/test_buffer_object.c b/opencl/khronos/icd/test/loader_test/test_buffer_object.c new file mode 100644 index 0000000000..1710e88006 --- /dev/null +++ b/opencl/khronos/icd/test/loader_test/test_buffer_object.c @@ -0,0 +1,463 @@ +#include + +#include +#include "param_struct.h" +#include + +extern cl_mem buffer; +extern cl_command_queue command_queue; +extern cl_event event; + +static int ret_val; + +extern void CL_CALLBACK setmemobjectdestructor_callback(cl_mem _a, void* _b); + +const struct clEnqueueReadBuffer_st clEnqueueReadBufferData[NUM_ITEMS_clEnqueueReadBuffer] = +{ + {NULL, NULL, 0, 0, 0, NULL, 0, NULL, NULL} +}; + +const struct clEnqueueWriteBuffer_st clEnqueueWriteBufferData[NUM_ITEMS_clEnqueueWriteBuffer] = +{ + {NULL, NULL, 0, 0, 0, NULL, 0, NULL, NULL} +}; + +const struct clEnqueueReadBufferRect_st clEnqueueReadBufferRectData[NUM_ITEMS_clEnqueueReadBufferRect] = +{ + {NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, NULL, 0, NULL, NULL} +}; + +const struct clEnqueueWriteBufferRect_st clEnqueueWriteBufferRectData[NUM_ITEMS_clEnqueueWriteBufferRect] = +{ + {NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, NULL, 0, NULL, NULL} +}; + +const struct clEnqueueFillBuffer_st clEnqueueFillBufferData[NUM_ITEMS_clEnqueueFillBuffer] = +{ + {NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL} +}; + +const struct clEnqueueCopyBuffer_st clEnqueueCopyBufferData[NUM_ITEMS_clEnqueueCopyBuffer] = +{ + {NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL} +}; + +const struct clEnqueueCopyBufferRect_st clEnqueueCopyBufferRectData[NUM_ITEMS_clEnqueueCopyBufferRect] = +{ + {NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL} +}; + +const struct clEnqueueMapBuffer_st clEnqueueMapBufferData[NUM_ITEMS_clEnqueueMapBuffer] = +{ + {NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL} +}; + +const struct clRetainMemObject_st clRetainMemObjectData[NUM_ITEMS_clRetainMemObject] = +{ + {NULL} +}; + +const struct clSetMemObjectDestructorCallback_st clSetMemObjectDestructorCallbackData[NUM_ITEMS_clSetMemObjectDestructorCallback] = +{ + {NULL, setmemobjectdestructor_callback, NULL} +}; + +const struct clEnqueueUnmapMemObject_st clEnqueueUnmapMemObjectData[NUM_ITEMS_clEnqueueUnmapMemObject] = +{ + {NULL, NULL, NULL, 0, NULL, NULL} +}; + +const struct clGetMemObjectInfo_st clGetMemObjectInfoData[NUM_ITEMS_clGetMemObjectInfo] = +{ + {NULL, 0, 0, NULL, NULL} +}; + +int test_clEnqueueReadBuffer(const struct clEnqueueReadBuffer_st *data) +{ + test_icd_app_log("clEnqueueReadBuffer(%p, %p, %u, %u, %u, %p, %u, %p, %p)\n", + command_queue, + buffer, + data->blocking_read, + data->offset, + data->cb, + data->ptr, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val=clEnqueueReadBuffer(command_queue, + buffer, + data->blocking_read, + data->offset, + data->cb, + data->ptr, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +int test_clEnqueueWriteBuffer(const struct clEnqueueWriteBuffer_st *data) +{ + test_icd_app_log("clEnqueueWriteBuffer(%p, %p, %u, %u, %u, %p, %u, %p, %p)\n", + command_queue, + buffer, + data->blocking_write, + data->offset, + data->cb, + data->ptr, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val=clEnqueueWriteBuffer(command_queue, + buffer, + data->blocking_write, + data->offset, + data->cb, + data->ptr, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +int test_clEnqueueReadBufferRect(const struct clEnqueueReadBufferRect_st *data) +{ + test_icd_app_log("clEnqueueReadBufferRect(%p, %p, %u, %p, %p, %p, %u, %u, %u, %u, %p, %u, %p, %p)\n", + command_queue, + buffer, + data->blocking_read, + data->buffer_offset, + data->host_offset, + data->region, + data->buffer_row_pitch, + data->buffer_slice_pitch, + data->host_row_pitch, + data->host_slice_pitch, + data->ptr, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val=clEnqueueReadBufferRect(command_queue, + buffer, + data->blocking_read, + data->buffer_offset, + data->host_offset, + data->region, + data->buffer_row_pitch, + data->buffer_slice_pitch, + data->host_row_pitch, + data->host_slice_pitch, + data->ptr, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clEnqueueWriteBufferRect(const struct clEnqueueWriteBufferRect_st *data) +{ + test_icd_app_log("clEnqueueWriteBufferRect(%p, %p, %u, %p, %p, %p, %u, %u, %u, %u, %p, %u, %p, %p)\n", + command_queue, + buffer, + data->blocking_write, + data->buffer_offset, + data->host_offset, + data->region, + data->buffer_row_pitch, + data->buffer_slice_pitch, + data->host_row_pitch, + data->host_slice_pitch, + data->ptr, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val=clEnqueueWriteBufferRect(command_queue, + buffer, + data->blocking_write, + data->buffer_offset, + data->host_offset, + data->region, + data->buffer_row_pitch, + data->buffer_slice_pitch, + data->host_row_pitch, + data->host_slice_pitch, + data->ptr, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +int test_clEnqueueFillBuffer(const struct clEnqueueFillBuffer_st *data) +{ + test_icd_app_log("clEnqueueFillBuffer(%p, %p, %p, %u, %u, %u, %u, %p, %p)\n", + command_queue, + buffer, + data->pattern, + data->pattern_size, + data->offset, + data->cb, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val=clEnqueueFillBuffer(command_queue, + buffer, + data->pattern, + data->pattern_size, + data->offset, + data->cb, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clEnqueueCopyBuffer(const struct clEnqueueCopyBuffer_st *data) +{ + test_icd_app_log("clEnqueueCopyBuffer(%p, %p, %p, %u, %u, %u, %u, %p, %p)\n", + command_queue, + data->src_buffer, + buffer, + data->src_offset, + data->dst_offset, + data->cb, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val=clEnqueueCopyBuffer(command_queue, + data->src_buffer, + buffer, + data->src_offset, + data->dst_offset, + data->cb, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clEnqueueCopyBufferRect(const struct clEnqueueCopyBufferRect_st *data) +{ + test_icd_app_log("clEnqueueCopyBufferRect(%p, %p, %p, %p, %p, %p, %u, %u, %u, %u, %u, %p, %p)\n", + command_queue, + buffer, + buffer, + data->src_origin, + data->dst_origin, + data->region, + data->src_row_pitch, + data->src_slice_pitch, + data->dst_row_pitch, + data->dst_slice_pitch, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val=clEnqueueCopyBufferRect(command_queue, + buffer, + buffer, + data->src_origin, + data->dst_origin, + data->region, + data->src_row_pitch, + data->src_slice_pitch, + data->dst_row_pitch, + data->dst_slice_pitch, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clEnqueueMapBuffer(const struct clEnqueueMapBuffer_st *data) +{ + void * return_value; + test_icd_app_log("clEnqueueMapBuffer(%p, %p, %u, %x, %u, %u, %u, %p, %p, %p)\n", + command_queue, + buffer, + data->blocking_map, + data->map_flags, + data->offset, + data->cb, + data->num_events_in_wait_list, + data->event_wait_list, + &event, + data->errcode_ret); + + return_value=clEnqueueMapBuffer(command_queue, + buffer, + data->blocking_map, + data->map_flags, + data->offset, + data->cb, + data->num_events_in_wait_list, + data->event_wait_list, + &event, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", return_value); + + free(return_value); + + return 0; + +} + +int test_clRetainMemObject(const struct clRetainMemObject_st *data) +{ + test_icd_app_log("clRetainMemObject(%p)\n", buffer); + + ret_val=clRetainMemObject(buffer); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clSetMemObjectDestructorCallback(const struct clSetMemObjectDestructorCallback_st *data) +{ + test_icd_app_log("clSetMemObjectDestructorCallback(%p, %p, %p)\n", + buffer, + data->pfn_notify, + data->user_data); + + ret_val=clSetMemObjectDestructorCallback(buffer, + data->pfn_notify, + data->user_data); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clEnqueueUnmapMemObject(const struct clEnqueueUnmapMemObject_st *data) +{ + test_icd_app_log("clEnqueueUnmapMemObject(%p, %p, %p, %u, %p, %p)\n", + command_queue, + buffer, + data->mapped_ptr, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val=clEnqueueUnmapMemObject(command_queue, + buffer, + data->mapped_ptr, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + + +int test_clGetMemObjectInfo (const struct clGetMemObjectInfo_st *data) +{ + test_icd_app_log("clGetMemObjectInfo(%p, %u, %u, %p, %p)\n", + buffer, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + ret_val=clGetMemObjectInfo(buffer, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + test_icd_app_log("Value returned: %d\n",ret_val); + + return 0; +} + +int test_buffer_object() +{ + int i; + for (i=0; i +#include "param_struct.h" +#include + +extern cl_command_queue command_queue; + +cl_int ret_val; + +const struct clRetainCommandQueue_st clRetainCommandQueueData[NUM_ITEMS_clRetainCommandQueue] = { + {NULL} +}; + +const struct clGetCommandQueueInfo_st clGetCommandQueueInfoData[NUM_ITEMS_clGetCommandQueueInfo] = { + {NULL, 0, 0, NULL, NULL} +}; + +int test_clRetainCommandQueue(const struct clRetainCommandQueue_st *data) +{ + test_icd_app_log("clRetainCommandQueue(%p)\n", command_queue); + + ret_val = clRetainCommandQueue(command_queue); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clGetCommandQueueInfo(const struct clGetCommandQueueInfo_st *data) +{ + test_icd_app_log("clGetCommandQueueInfo(%p, %u, %u, %p, %p)\n", + command_queue, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + ret_val = clGetCommandQueueInfo(command_queue, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_cl_runtime() +{ + int i; + + for (i=0; i +#include +#include +#include "param_struct.h" +#include + +extern cl_context context; +extern cl_mem buffer; +extern cl_command_queue command_queue; +extern cl_event event; +extern cl_context_properties context_properties[3]; +cl_int ret_val; +cl_mem ret_mem; + +struct clCreateFromGLBuffer_st clCreateFromGLBufferData[NUM_ITEMS_clCreateFromGLBuffer] = { + {NULL, 0x0, 0, NULL} +}; + +int test_clCreateFromGLBuffer(const struct clCreateFromGLBuffer_st* data) +{ + + test_icd_app_log("clCreateFromGLBuffer(%p, %x, %u, %p)\n", + context, + data->flags, + data->bufobj, + data->errcode_ret); + + ret_mem = clCreateFromGLBuffer(context, + data->flags, + data->bufobj, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", ret_mem); + + return 0; +} + +struct clCreateFromGLTexture_st clCreateFromGLTextureData[NUM_ITEMS_clCreateFromGLTexture] = { + {NULL, 0x0, 0, 0, 0, NULL} +}; + +int test_clCreateFromGLTexture(const struct clCreateFromGLTexture_st* data) +{ + test_icd_app_log("clCreateFromGLTexture(%p, %x, %d, %d, %u, %p)\n", + context, + data->flags, + data->texture_target, + data->miplevel, + data->texture, + data->errcode_ret); + + ret_mem = clCreateFromGLTexture(context, + data->flags, + data->texture_target, + data->miplevel, + data->texture, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", ret_mem); + + return 0; +} + +struct clCreateFromGLTexture2D_st clCreateFromGLTexture2DData[NUM_ITEMS_clCreateFromGLTexture2D] = { + {NULL, 0x0, 0, 0, 0, NULL} +}; + +int test_clCreateFromGLTexture2D(const struct clCreateFromGLTexture2D_st* data) +{ + test_icd_app_log("clCreateFromGLTexture2D(%p, %x, %d, %d, %u, %p)\n", + context, + data->flags, + data->texture_target, + data->miplevel, + data->texture, + data->errcode_ret); + + ret_mem = clCreateFromGLTexture2D(context, + data->flags, + data->texture_target, + data->miplevel, + data->texture, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", ret_mem); + + return 0; +} + +struct clCreateFromGLTexture3D_st clCreateFromGLTexture3DData[NUM_ITEMS_clCreateFromGLTexture3D] = { + {NULL, 0, 0, 0, 0, NULL} +}; + +int test_clCreateFromGLTexture3D(const struct clCreateFromGLTexture3D_st* data) +{ + test_icd_app_log("clCreateFromGLTexture3D(%p, %x, %d, %d, %u, %p)\n", + context, + data->flags, + data->texture_target, + data->miplevel, + data->texture, + data->errcode_ret); + + ret_mem = clCreateFromGLTexture3D(context, + data->flags, + data->texture_target, + data->miplevel, + data->texture, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", ret_mem); + + return 0; +} + +struct clCreateFromGLRenderbuffer_st clCreateFromGLRenderbufferData[NUM_ITEMS_clCreateFromGLRenderbuffer] = { + {NULL, 0x0, 0, NULL} +}; + +int test_clCreateFromGLRenderbuffer(const struct clCreateFromGLRenderbuffer_st* data) +{ + test_icd_app_log("clCreateFromGLRenderbuffer(%p, %x, %d, %p)\n", + context, + data->flags, + data->renderbuffer, + data->errcode_ret); + + ret_mem = clCreateFromGLRenderbuffer(context, + data->flags, + data->renderbuffer, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", ret_mem); + + return 0; +} + +struct clGetGLObjectInfo_st clGetGLObjectInfoData[NUM_ITEMS_clGetGLObjectInfo] = { + {NULL, NULL, NULL} +}; + +int test_clGetGLObjectInfo(const struct clGetGLObjectInfo_st* data) +{ + test_icd_app_log("clGetGLObjectInfo(%p, %p, %p)\n", + buffer, + data->gl_object_type, + data->gl_object_name); + + ret_val = clGetGLObjectInfo(buffer, + data->gl_object_type, + data->gl_object_name); + + test_icd_app_log("Value returned: %p\n", ret_val); + + return ret_val; + +} + +struct clGetGLTextureInfo_st clGetGLTextureInfoData[NUM_ITEMS_clGetGLTextureInfo] = { + {NULL, 0, 0, NULL, NULL} +}; + +int test_clGetGLTextureInfo(const struct clGetGLTextureInfo_st* data) +{ + test_icd_app_log("clGetGLTextureInfo(%p, %u, %u, %p, %p)\n", + buffer, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + ret_val = clGetGLTextureInfo (buffer, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + test_icd_app_log("Value returned: %p\n", ret_val); + + return 0; +} + +struct clEnqueueAcquireGLObjects_st clEnqueueAcquireGLObjectsData[NUM_ITEMS_clEnqueueAcquireGLObjects] = { + {NULL, 0, NULL, 0, NULL, NULL} +}; + +int test_clEnqueueAcquireGLObjects(const struct clEnqueueAcquireGLObjects_st* data) +{ + test_icd_app_log("clEnqueueAcquireGLObjects(%p, %u, %p, %u, %p, %p)\n", + command_queue, + data->num_objects, + data->mem_objects, + data->num_events_in_wait_list, + &event, + &event); + + ret_val = clEnqueueAcquireGLObjects (command_queue, + data->num_objects, + data->mem_objects, + data->num_events_in_wait_list, + &event, + &event); + + test_icd_app_log("Value returned: %p\n", ret_val); + + return 0; +} + +struct clEnqueueReleaseGLObjects_st clEnqueueReleaseGLObjectsData[NUM_ITEMS_clEnqueueReleaseGLObjects] = { + {NULL, 0, NULL, 0, NULL, NULL} +}; + +int test_clEnqueueReleaseGLObjects(const struct clEnqueueReleaseGLObjects_st* data) +{ + test_icd_app_log("clEnqueueReleaseGLObjects(%p, %u, %p, %u, %p, %p)\n", + command_queue, + data->num_objects, + data->mem_objects, + data->num_events_in_wait_list, + &event, + &event); + + ret_val = clEnqueueReleaseGLObjects (command_queue, + data->num_objects, + data->mem_objects, + data->num_events_in_wait_list, + &event, + &event); + + + test_icd_app_log("Value returned: %p\n", ret_val); + + return 0; +} + +struct clCreateEventFromGLsyncKHR_st clCreateEventFromGLsyncKHRData[NUM_ITEMS_clCreateEventFromGLsyncKHR] = { + {NULL, NULL, NULL} +}; + +typedef CL_API_ENTRY cl_event +(CL_API_CALL *PFN_clCreateEventFromGLsyncKHR)(cl_context /* context */, + cl_GLsync /* cl_GLsync */, + cl_int * /* errcode_ret */); + +int test_clCreateEventFromGLsyncKHR(const struct clCreateEventFromGLsyncKHR_st* data) +{ cl_event ret_event; + PFN_clCreateEventFromGLsyncKHR pfn_clCreateEventFromGLsyncKHR = NULL; + + test_icd_app_log("clCreateEventFromGLsyncKHR(%p, %p, %p)\n", + context, + data->sync, + data->errcode_ret); + + pfn_clCreateEventFromGLsyncKHR = clGetExtensionFunctionAddress("clCreateEventFromGLsyncKHR"); + if (!pfn_clCreateEventFromGLsyncKHR) { + test_icd_app_log("clGetExtensionFunctionAddress failed!\n"); + return 1; + } + + ret_event = pfn_clCreateEventFromGLsyncKHR (context, + data->sync, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", ret_event); + return 0; +} + +struct clGetGLContextInfoKHR_st clGetGLContextInfoKHRData[NUM_ITEMS_clGetGLContextInfoKHR] = { + {NULL, 0, 0, NULL, NULL} +}; + +typedef CL_API_ENTRY cl_int +(CL_API_CALL *PFN_clGetGLContextInfoKHR)(const cl_context_properties * /* properties */, + cl_gl_context_info /* param_name */, + size_t /* param_value_size */, + void * /* param_value */, + size_t * /* param_value_size_ret */); + +int test_clGetGLContextInfoKHR(const struct clGetGLContextInfoKHR_st* data) +{ + PFN_clGetGLContextInfoKHR pfn_clGetGLContextInfoKHR = NULL; + test_icd_app_log("clGetGLContextInfoKHR(%p, %u, %u, %p, %p)\n", + context_properties, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + pfn_clGetGLContextInfoKHR = clGetExtensionFunctionAddress("clGetGLContextInfoKHR"); + if (!pfn_clGetGLContextInfoKHR) { + test_icd_app_log("clGetExtensionFunctionAddress failed!\n"); + return 1; + } + + ret_val = pfn_clGetGLContextInfoKHR(context_properties, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + test_icd_app_log("Value returned: %p\n", ret_val); + return 0; + +} + +int test_OpenGL_share() +{ + int i; + + for(i=0;i +#include + +#define CL_USE_DEPRECATED_OPENCL_1_0_APIS +#define CL_USE_DEPRECATED_OPENCL_1_1_APIS +#define CL_USE_DEPRECATED_OPENCL_1_2_APIS + +#include +#include "param_struct.h" +#include + +extern void CL_CALLBACK createcontext_callback(const char* a, const void* b, size_t c, void* d); + +cl_platform_id* all_platforms; +cl_platform_id platform; +cl_uint num_platforms; +cl_context context; +cl_command_queue command_queue; +cl_mem buffer; +cl_mem subBuffer; +cl_mem image; +cl_sampler sampler; +cl_program program; +cl_kernel kernel; +cl_event event; +cl_device_id devices; +cl_context_properties context_properties[3] = { + (cl_context_properties)CL_CONTEXT_PLATFORM, + 0, + 0, +}; + +const struct clGetDeviceIDs_st clGetDeviceIDsData[NUM_ITEMS_clGetDeviceIDs] = +{ + {NULL, 0, 1, NULL, NULL} +}; + +const struct clCreateSampler_st clCreateSamplerData[NUM_ITEMS_clCreateSampler] = +{ + {NULL, 0x0, 0, 0, NULL}, +}; + +const struct clCreateCommandQueue_st clCreateCommandQueueData[NUM_ITEMS_clCreateCommandQueue] = +{ + {NULL, NULL, 0, NULL} +}; + +const struct clCreateContext_st clCreateContextData[NUM_ITEMS_clCreateContext] = +{ + {NULL, 1, NULL, NULL, NULL, NULL} +}; + +const struct clCreateContextFromType_st clCreateContextFromTypeData[NUM_ITEMS_clCreateContextFromType] = +{ + {NULL, 0, createcontext_callback, NULL, NULL} +}; + +const struct clCreateBuffer_st clCreateBufferData[NUM_ITEMS_clCreateBuffer] = +{ + {NULL, 0, 0, NULL, NULL} +}; + +const struct clCreateSubBuffer_st clCreateSubBufferData[NUM_ITEMS_clCreateSubBuffer] = +{ + {NULL, 0, 0, NULL, NULL} +}; + +const struct clCreateImage_st clCreateImageData[NUM_ITEMS_clCreateImage] = +{ + { NULL, 0x0, NULL, NULL, NULL, NULL} +}; + +const struct clCreateImage2D_st clCreateImage2DData[NUM_ITEMS_clCreateImage2D] = +{ + { NULL, 0x0, NULL, 0, 0, 0, NULL, NULL} +}; + +const struct clCreateImage3D_st clCreateImage3DData[NUM_ITEMS_clCreateImage3D] = +{ + { NULL, 0x0, NULL, 0, 0, 0, 0, 0, NULL, NULL } +}; + + +struct clReleaseMemObject_st clReleaseMemObjectData[NUM_ITEMS_clReleaseMemObject] = +{ + {NULL} +}; + +struct clReleaseMemObject_st clReleaseMemObjectDataImage[NUM_ITEMS_clReleaseMemObject] = +{ + {NULL} +};const struct clCreateProgramWithSource_st clCreateProgramWithSourceData[NUM_ITEMS_clCreateProgramWithSource] = +{ + {NULL, 0, NULL, NULL, NULL} +}; + +const struct clCreateProgramWithBinary_st clCreateProgramWithBinaryData[NUM_ITEMS_clCreateProgramWithBinary] = +{ + {NULL, 0, NULL, NULL, NULL, NULL, NULL} +}; + +const struct clCreateProgramWithBuiltInKernels_st clCreateProgramWithBuiltInKernelsData[NUM_ITEMS_clCreateProgramWithBuiltInKernels] = +{ + {NULL, 0, NULL, NULL, NULL} +}; + +const struct clCreateKernel_st clCreateKernelData[NUM_ITEMS_clCreateKernel] = +{ + {NULL, NULL, NULL} +}; + +const struct clCreateKernelsInProgram_st clCreateKernelsInProgramData[NUM_ITEMS_clCreateKernelsInProgram] = +{ + {NULL, 0, NULL, NULL} +}; + +const struct clCreateUserEvent_st clCreateUserEventData[NUM_ITEMS_clCreateUserEvent] = +{ + {NULL, NULL} +}; + +const struct clGetPlatformIDs_st clGetPlatformIDsData[NUM_ITEMS_clGetPlatformIDs] = +{ + {0, NULL, 0} +}; + +/* + * Some log messages cause log mismatches when ICD loader calls a driver + * function while initializing platforms. The functions clGetPlatform* are most + * likely to be called at that time. But nothing stops an ICD loader from + * calling a ICD driver function anytime. + * + * FIXME: Figure out a good way to handle this. + */ +#define ENABLE_MISMATCHING_PRINTS 0 + +int test_clGetPlatformIDs(const struct clGetPlatformIDs_st* data) +{ + cl_int ret_val; + size_t param_val_ret_size; + #define PLATFORM_NAME_SIZE 40 + char platform_name[PLATFORM_NAME_SIZE]; + cl_uint i; + +#if ENABLE_MISMATCHING_PRINTS + test_icd_app_log("clGetPlatformIDs(%u, %p, %p)\n", + data->num_entries, + &platforms, + &num_platforms); +#endif + + ret_val = clGetPlatformIDs(0, + NULL, + &num_platforms); + + if (ret_val != CL_SUCCESS){ + return -1; + } + + all_platforms = (cl_platform_id *) malloc (num_platforms * sizeof(cl_platform_id)); + + ret_val = clGetPlatformIDs(num_platforms, + all_platforms, + NULL); + + if (ret_val != CL_SUCCESS){ + return -1; + } + + for (i = 0; i < num_platforms; i++) { + ret_val = clGetPlatformInfo(all_platforms[i], + CL_PLATFORM_NAME, + PLATFORM_NAME_SIZE, + (void*)platform_name, + ¶m_val_ret_size ); + + if (ret_val == CL_SUCCESS ){ + if(!strcmp(platform_name, "ICD_LOADER_TEST_OPENCL_STUB")) { + platform = all_platforms[i]; + } + } + } + +#if ENABLE_MISMATCHING_PRINTS + test_icd_app_log("Value returned: %d\n", ret_val); +#endif + + return 0; + +} + +int test_clGetDeviceIDs(const struct clGetDeviceIDs_st* data) +{ + int ret_val; + + test_icd_app_log("clGetDeviceIDs(%p, %x, %u, %p, %p)\n", + platform, + data->device_type, + data->num_entries, + &devices, + data->num_devices); + + ret_val = clGetDeviceIDs(platform, + data->device_type, + data->num_entries, + &devices, + data->num_devices); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clCreateContext(const struct clCreateContext_st* data) +{ + test_icd_app_log("clCreateContext(%p, %u, %p, %p, %p, %p)\n", + data->properties, + data->num_devices, + &devices, + &createcontext_callback, + data->user_data, + data->errcode_ret); + + context = clCreateContext(data->properties, + data->num_devices, + &devices, + &createcontext_callback, + data->user_data, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", context); + + return 0; + +} + +int test_clCreateContextFromType(const struct clCreateContextFromType_st* data) +{ + test_icd_app_log("clCreateContextFromType(%p, %x, %p, %p, %p)\n", + context_properties, + data->device_type, + data->pfn_notify, + data->user_data, + data->errcode_ret); + + + context = clCreateContextFromType(context_properties, + data->device_type, + data->pfn_notify, + data->user_data, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", context); + + return 0; + +} + +int test_clCreateCommandQueue(const struct clCreateCommandQueue_st *data) +{ + test_icd_app_log("clCreateCommandQueue(%p, %p, %x, %p)\n", + context, + devices, + data->properties, + data->errcode_ret); + + command_queue = clCreateCommandQueue(context, + devices, + data->properties, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", command_queue); + + return 0; + +} + +int test_clCreateBuffer(const struct clCreateBuffer_st *data) +{ + test_icd_app_log("clCreateBuffer(%p, %x, %u, %p, %p)\n", + context, + data->flags, + data->size, + data->host_ptr, + data->errcode_ret); + + buffer = clCreateBuffer(context, + data->flags, + data->size, + data->host_ptr, + data->errcode_ret); + + clReleaseMemObjectData->memobj = buffer; + + test_icd_app_log("Value returned: %p\n", buffer); + + return 0; + +} + +int test_clCreateSubBuffer(const struct clCreateSubBuffer_st *data) +{ + test_icd_app_log("clCreateSubBuffer(%p, %x, %u, %p, %p)\n", + buffer, + data->flags, + data->buffer_create_type, + data->buffer_create_info, + data->errcode_ret); + + subBuffer = clCreateSubBuffer(buffer, + data->flags, + data->buffer_create_type, + data->buffer_create_info, + data->errcode_ret); + + clReleaseMemObjectData->memobj = buffer; + + test_icd_app_log("Value returned: %p\n", subBuffer); + + return 0; + +} + +int test_clCreateImage(const struct clCreateImage_st *data) +{ + test_icd_app_log("clCreateImage(%p, %x, %p, %p, %p, %p)\n", + context, + data->flags, + data->image_format, + data->image_desc, + data->host_ptr, + data->errcode_ret); + + image = clCreateImage(context, + data->flags, + data->image_format, + data->image_desc, + data->host_ptr, + data->errcode_ret); + + clReleaseMemObjectDataImage[0].memobj = image; + test_icd_app_log("Value returned: %p\n", image); + + return 0; + +} + +int test_clCreateImage2D(const struct clCreateImage2D_st *data) +{ + test_icd_app_log("clCreateImage2D(%p, %x, %p, %u, %u, %u, %p, %p)\n", + context, + data->flags, + data->image_format, + data->image_width, + data->image_height, + data->image_row_pitch, + data->host_ptr, + data->errcode_ret); + + image = clCreateImage2D(context, + data->flags, + data->image_format, + data->image_width, + data->image_height, + data->image_row_pitch, + data->host_ptr, + data->errcode_ret); + + clReleaseMemObjectDataImage[0].memobj = image; + test_icd_app_log("Value returned: %p\n", image); + + return 0; + +} + +int test_clCreateImage3D(const struct clCreateImage3D_st *data) +{ + test_icd_app_log("clCreateImage3D(%p, %x, %p, %u, %u, %u, %u, %u, %p, %p)\n", + context, + data->flags, + data->image_format, + data->image_width, + data->image_height, + data->image_depth, + data->image_row_pitch, + data->image_slice_pitch, + data->host_ptr, + data->errcode_ret); + + image = clCreateImage3D(context, + data->flags, + data->image_format, + data->image_width, + data->image_height, + data->image_depth, + data->image_row_pitch, + data->image_slice_pitch, + data->host_ptr, + data->errcode_ret); + + clReleaseMemObjectDataImage[0].memobj = image; + test_icd_app_log("Value returned: %p\n", image); + + return 0; + +} + +int test_clCreateSampler(const struct clCreateSampler_st *data) +{ + test_icd_app_log("clCreateSampler(%p, %u, %u, %u, %p)\n", + context, + data->normalized_coords, + data->addressing_mode, + data->filter_mode, + data->errcode_ret); + + sampler = clCreateSampler(context, + data->normalized_coords, + data->addressing_mode, + data->filter_mode, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", sampler); + + return 0; + +} + +int test_clCreateProgramWithSource(const struct clCreateProgramWithSource_st *data) +{ + test_icd_app_log("clCreateProgramWithSource(%p, %u, %p, %p, %p)\n", + context, + data->count, + data->strings, + data->lengths, + data->errcode_ret); + + program = clCreateProgramWithSource(context, + data->count, + data->strings, + data->lengths, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", program); + + return 0; + +} + +int test_clCreateProgramWithBinary(const struct clCreateProgramWithBinary_st *data) +{ + test_icd_app_log("clCreateProgramWithBinary(%p, %u, %p, %p, %p, %p, %p)\n", + context, + data->num_devices, + &devices, + data->lengths, + data->binaries, + data->binary_status, + data->errcode_ret); + + program = clCreateProgramWithBinary(context, + data->num_devices, + &devices, + data->lengths, + data->binaries, + data->binary_status, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", program); + + return 0; + +} + +int test_clCreateProgramWithBuiltInKernels(const struct clCreateProgramWithBuiltInKernels_st *data) +{ + test_icd_app_log("clCreateProgramWithBuiltInKernels(%p, %u, %p, %p, %p)\n", + context, + data->num_devices, + &devices, + data->kernel_names, + data->errcode_ret); + + program = clCreateProgramWithBuiltInKernels(context, + data->num_devices, + &devices, + data->kernel_names, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", program); + + return 0; + +} + +int test_clCreateKernel(const struct clCreateKernel_st* data) +{ + test_icd_app_log("clCreateKernel(%p, %p, %p)\n", + program, + data->kernel_name, + data->errcode_ret); + + kernel = clCreateKernel(program, + data->kernel_name, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", kernel); + + return 0; + +} + +int test_clCreateKernelsInProgram(const struct clCreateKernelsInProgram_st* data) +{ + int ret_val; + test_icd_app_log("clCreateKernelsInProgram(%p, %u, %p, %p)\n", + program, + data->num_kernels, + &kernel, + data->num_kernels_ret); + + ret_val = clCreateKernelsInProgram(program, + data->num_kernels, + &kernel, + data->num_kernels_ret); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clCreateUserEvent(const struct clCreateUserEvent_st* data) +{ + test_icd_app_log("clCreateUserEvent(%p, %p)\n", + context, + data->errcode_ret); + + event = clCreateUserEvent(context, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", event); + + return 0; + +} + +const struct clReleaseSampler_st clReleaseSamplerData[NUM_ITEMS_clReleaseSampler] = +{ + { NULL } +}; + +int test_clReleaseSampler(const struct clReleaseSampler_st *data) +{ + int ret_val = CL_OUT_OF_RESOURCES; + + test_icd_app_log("clReleaseSampler(%p)\n", sampler); + + ret_val = clReleaseSampler(sampler); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + + +int test_clReleaseMemObject(const struct clReleaseMemObject_st *data) +{ + int ret_val = -15; + test_icd_app_log("clReleaseMemObject(%p)\n", data->memobj); + + ret_val = clReleaseMemObject(data->memobj); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +const struct clReleaseEvent_st clReleaseEventData[NUM_ITEMS_clReleaseEvent] = +{ + {NULL} +}; + +int test_clReleaseEvent(const struct clReleaseEvent_st* data) +{ + int ret_val = CL_OUT_OF_RESOURCES; + + test_icd_app_log("clReleaseEvent(%p)\n", event); + + ret_val = clReleaseEvent(event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +const struct clReleaseKernel_st clReleaseKernelData[NUM_ITEMS_clReleaseKernel] = +{ + {NULL} +}; + +int test_clReleaseKernel(const struct clReleaseKernel_st* data) +{ + int ret_val = CL_OUT_OF_RESOURCES; + + test_icd_app_log("clReleaseKernel(%p)\n", kernel); + + ret_val = clReleaseKernel(kernel); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +const struct clReleaseProgram_st clReleaseProgramData[NUM_ITEMS_clReleaseProgram] = +{ + {NULL} +}; + +int test_clReleaseProgram(const struct clReleaseProgram_st *data) +{ + int ret_val = CL_OUT_OF_RESOURCES; + + test_icd_app_log("clReleaseProgram(%p)\n", program); + + ret_val = clReleaseProgram(program); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +const struct clReleaseCommandQueue_st clReleaseCommandQueueData[NUM_ITEMS_clReleaseCommandQueue] = +{ + {NULL} +}; + +int test_clReleaseCommandQueue(const struct clReleaseCommandQueue_st *data) +{ + int ret_val = CL_OUT_OF_RESOURCES; + + test_icd_app_log("clReleaseCommandQueue(%p)\n", command_queue); + + ret_val = clReleaseCommandQueue(command_queue); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +const struct clReleaseContext_st clReleaseContextData[NUM_ITEMS_clReleaseContext] = +{ + {NULL} +}; + +int test_clReleaseContext(const struct clReleaseContext_st* data) +{ + int ret_val = CL_OUT_OF_RESOURCES; + + test_icd_app_log("clReleaseContext(%p)\n", context); + + ret_val = clReleaseContext(context); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +const struct clReleaseDevice_st clReleaseDeviceData[NUM_ITEMS_clReleaseDevice] = +{ + {NULL} +}; + +int test_clReleaseDevice(const struct clReleaseDevice_st* data) +{ + int ret_val = CL_OUT_OF_RESOURCES; + + test_icd_app_log("clReleaseDevice(%p)\n", devices); + + ret_val = clReleaseDevice(devices); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_create_calls() +{ + test_clGetPlatformIDs(clGetPlatformIDsData); + + context_properties[1] = (cl_context_properties) platform; + + test_clGetDeviceIDs(clGetDeviceIDsData); + + test_clCreateContext(clCreateContextData); + + test_clReleaseContext(clReleaseContextData); + + test_clCreateContextFromType(clCreateContextFromTypeData); + + test_clCreateCommandQueue(clCreateCommandQueueData); + + test_clCreateBuffer(clCreateBufferData); + + test_clCreateSubBuffer(clCreateSubBufferData); + + test_clCreateImage(clCreateImageData); + + test_clReleaseMemObject(clReleaseMemObjectDataImage); + + test_clCreateImage2D(clCreateImage2DData); + + test_clReleaseMemObject(clReleaseMemObjectDataImage); + + test_clCreateImage3D(clCreateImage3DData); + + test_clCreateSampler(clCreateSamplerData); + + test_clCreateProgramWithSource(clCreateProgramWithSourceData); + + test_clReleaseProgram(clReleaseProgramData); + + test_clCreateProgramWithBinary(clCreateProgramWithBinaryData); + + test_clReleaseProgram(clReleaseProgramData); + + test_clCreateProgramWithBuiltInKernels(clCreateProgramWithBuiltInKernelsData); + + test_clCreateKernel(clCreateKernelData); + + test_clCreateKernelsInProgram(clCreateKernelsInProgramData); + + test_clCreateUserEvent(clCreateUserEventData); + + return 0; + +} + +int test_release_calls() +{ + test_clReleaseSampler(clReleaseSamplerData); + + test_clReleaseMemObject(clReleaseMemObjectData); + + test_clReleaseMemObject(clReleaseMemObjectDataImage); + + test_clReleaseEvent(clReleaseEventData); + + test_clReleaseKernel(clReleaseKernelData); + + test_clReleaseProgram(clReleaseProgramData); + + test_clReleaseCommandQueue(clReleaseCommandQueueData); + + test_clReleaseContext(clReleaseContextData); + + test_clReleaseDevice(clReleaseDeviceData); + + return 0; +} + diff --git a/opencl/khronos/icd/test/loader_test/test_image_objects.c b/opencl/khronos/icd/test/loader_test/test_image_objects.c new file mode 100644 index 0000000000..f399451310 --- /dev/null +++ b/opencl/khronos/icd/test/loader_test/test_image_objects.c @@ -0,0 +1,364 @@ +#include + +#include +#include "param_struct.h" +#include + +extern cl_mem image; +extern cl_context context; +extern cl_command_queue command_queue; +extern cl_event event; +extern cl_mem buffer; + +int ret_val; + +const struct clGetSupportedImageFormats_st clGetSupportedImageFormatsData[NUM_ITEMS_clGetSupportedImageFormats] = +{ + { NULL, 0x0, 0, 0, NULL, NULL } +}; + +const struct clEnqueueCopyImageToBuffer_st clEnqueueCopyImageToBufferData[NUM_ITEMS_clEnqueueCopyImageToBuffer] = +{ + { NULL, NULL, NULL, NULL, NULL, 0, 0, NULL, NULL } +}; + +const struct clEnqueueCopyBufferToImage_st clEnqueueCopyBufferToImageData[NUM_ITEMS_clEnqueueCopyBufferToImage] = +{ + { NULL, NULL, NULL, 0, NULL, NULL, 0, NULL, NULL } +}; + +const struct clEnqueueMapImage_st clEnqueueMapImageData[NUM_ITEMS_clEnqueueMapImage] = +{ + { NULL, NULL, 0, 0x0, NULL, NULL, NULL, NULL,0, NULL, NULL} +}; + +const struct clEnqueueReadImage_st clEnqueueReadImageData[NUM_ITEMS_clEnqueueReadImage] = +{ + { NULL, NULL, 0, NULL, NULL, 0, 0, NULL, 0, NULL, NULL } +}; + +const struct clEnqueueWriteImage_st clEnqueueWriteImageData[NUM_ITEMS_clEnqueueWriteImage] = +{ + { NULL, NULL, 0, NULL, NULL, 0, 0, NULL, 0, NULL, NULL } +}; + +const struct clEnqueueFillImage_st clEnqueueFillImageData[NUM_ITEMS_clEnqueueFillImage] = +{ + { NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL } +}; + +const struct clEnqueueCopyImage_st clEnqueueCopyImageData[NUM_ITEMS_clEnqueueCopyImage] = +{ + { NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL } +}; + +const struct clGetImageInfo_st clGetImageInfoData[NUM_ITEMS_clGetImageInfo] = +{ + { NULL, 0, 0, NULL, NULL} +}; + +int test_clGetSupportedImageFormats(const struct clGetSupportedImageFormats_st *data) +{ + test_icd_app_log("clGetSupportedImageFormats(%p, %x, %u, %u, %p, %p)\n", + context, + data->flags, + data->image_type, + data->num_entries, + data->image_formats, + data->num_image_formats); + + ret_val = clGetSupportedImageFormats(context, + data->flags, + data->image_type, + data->num_entries, + data->image_formats, + data->num_image_formats); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clEnqueueCopyImageToBuffer(const struct clEnqueueCopyImageToBuffer_st *data) +{ + test_icd_app_log("clEnqueueCopyImageToBuffer(%p, %p, %p, %p, %p, %u, %u, %p, %p)\n", + command_queue, + image, + buffer, + data->src_origin, + data->region, + data->dst_offset, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val = clEnqueueCopyImageToBuffer(command_queue, + image, + buffer, + data->src_origin, + data->region, + data->dst_offset, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clEnqueueCopyBufferToImage(const struct clEnqueueCopyBufferToImage_st *data) +{ + test_icd_app_log("clEnqueueCopyBufferToImage(%p, %p, %p, %u, %p, %p, %u, %p, %p)\n", + command_queue, + buffer, + image, + data->src_offset, + data->dst_origin, + data->region, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val = clEnqueueCopyBufferToImage(command_queue, + buffer, + image, + data->src_offset, + data->dst_origin, + data->region, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clEnqueueMapImage(const struct clEnqueueMapImage_st *data) +{ + void *return_value; + test_icd_app_log("clEnqueueMapImage(%p, %p, %u, %x, %p, %p, %p, %p, %u, %p, %p, %p)\n", + command_queue, + image, + data->blocking_map, + data->map_flags, + data->origin, + data->region, + data->image_row_pitch, + data->image_slice_pitch, + data->num_events_in_wait_list, + data->event_wait_list, + &event, + data->errcode_ret); + + return_value = clEnqueueMapImage(command_queue, + image, + data->blocking_map, + data->map_flags, + data->origin, + data->region, + data->image_row_pitch, + data->image_slice_pitch, + data->num_events_in_wait_list, + data->event_wait_list, + &event, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", return_value); + + free(return_value); + + return 0; + +} + +int test_clEnqueueReadImage(const struct clEnqueueReadImage_st *data) +{ + test_icd_app_log("clEnqueueReadImage(%p, %p, %u, %p, %p, %u, %u, %p, %u, %p, %p)\n", + command_queue, + image, + data->blocking_read, + data->origin, + data->region, + data->row_pitch, + data->slice_pitch, + data->ptr, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val = clEnqueueReadImage(command_queue, + image, + data->blocking_read, + data->origin, + data->region, + data->row_pitch, + data->slice_pitch, + data->ptr, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clEnqueueWriteImage(const struct clEnqueueWriteImage_st *data) +{ + test_icd_app_log("clEnqueueWriteImage(%p, %p, %u, %p, %p, %u, %u, %p, %u, %p, %p)\n", + command_queue, + image, + data->blocking_write, + data->origin, + data->region, + data->input_row_pitch, + data->input_slice_pitch, + data->ptr, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val = clEnqueueWriteImage(command_queue, + image, + data->blocking_write, + data->origin, + data->region, + data->input_row_pitch, + data->input_slice_pitch, + data->ptr, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clEnqueueFillImage(const struct clEnqueueFillImage_st *data) +{ + test_icd_app_log("clEnqueueFillImage(%p, %p, %p, %p, %p, %u, %p, %p)\n", + command_queue, + image, + data->fill_color, + data->origin, + data->region, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val = clEnqueueFillImage(command_queue, + image, + data->fill_color, + data->origin, + data->region, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} +int test_clEnqueueCopyImage(const struct clEnqueueCopyImage_st *data) +{ + test_icd_app_log("clEnqueueCopyImage(%p, %p, %p, %p, %p, %p, %u, %p, %p)\n", + command_queue, + image, + image, + data->src_origin, + data->dst_origin, + data->region, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val = clEnqueueCopyImage(command_queue, + image, + image, + data->src_origin, + data->dst_origin, + data->region, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + + +int test_clGetImageInfo(const struct clGetImageInfo_st *data) +{ + test_icd_app_log("clGetImageInfo(%p, %u, %u, %p, %p)\n", + image, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + ret_val = clGetImageInfo(image, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_image_objects() +{ + int i; + + for (i = 0; i +#include "param_struct.h" +#include + +extern cl_kernel kernel; +extern cl_event event; +extern cl_context context; +extern cl_command_queue command_queue; +extern cl_device_id devices; +int ret_val; +extern void CL_CALLBACK setevent_callback(cl_event _a, cl_int _b, void* _c); +extern void CL_CALLBACK setprintf_callback(cl_context _a, cl_uint _b, char* _c, void* _d ); + +struct clRetainKernel_st clRetainKernelData[NUM_ITEMS_clRetainKernel] = +{ + {NULL} +}; + +int test_clRetainKernel(const struct clRetainKernel_st* data) +{ + test_icd_app_log("clRetainKernel(%p)\n", kernel); + + ret_val=clRetainKernel(kernel); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +struct clSetKernelArg_st clSetKernelArgData[NUM_ITEMS_clSetKernelArg] = +{ + {NULL, 0, 0, NULL} +}; + +int test_clSetKernelArg(const struct clSetKernelArg_st* data) +{ + test_icd_app_log("clSetKernelArg(%p, %u, %u, %p)\n", + kernel, + data->arg_index, + data->arg_size, + data->arg_value); + + ret_val=clSetKernelArg(kernel, + data->arg_index, + data->arg_size, + data->arg_value); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +struct clGetKernelInfo_st clGetKernelInfoData[NUM_ITEMS_clGetKernelInfo] = +{ + {NULL, 0, 0, NULL, NULL} +}; + +int test_clGetKernelInfo(const struct clGetKernelInfo_st* data) +{ + test_icd_app_log("clGetKernelInfo(%p, %u, %u, %p, %p)\n", + kernel, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + ret_val=clGetKernelInfo(kernel, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +struct clGetKernelArgInfo_st clGetKernelArgInfoData[NUM_ITEMS_clGetKernelArgInfo] = +{ + {NULL, 0, 0, 0, NULL, NULL} +}; + +int test_clGetKernelArgInfo(const struct clGetKernelArgInfo_st* data) +{ + test_icd_app_log("clGetKernelArgInfo(%p, %u, %u, %u, %p, %p)\n", + kernel, + data->arg_indx, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + ret_val=clGetKernelArgInfo(kernel, + data->arg_indx, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +struct clGetKernelWorkGroupInfo_st clGetKernelWorkGroupInfoData[NUM_ITEMS_clGetKernelWorkGroupInfo] = +{ + {NULL, NULL, 0, 0, NULL, NULL} +}; + +int test_clGetKernelWorkGroupInfo(const struct clGetKernelWorkGroupInfo_st* data) +{ + test_icd_app_log("clGetKernelWorkGroupInfo(%p, %p, %u, %u, %p, %p)\n", + kernel, + devices, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + ret_val=clGetKernelWorkGroupInfo(kernel, + devices, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +struct clEnqueueMigrateMemObjects_st clEnqueueMigrateMemObjectsData[NUM_ITEMS_clEnqueueMigrateMemObjects] = +{ + {NULL, 0, NULL, 0x0, 0, NULL, NULL} +}; + +int test_clEnqueueMigrateMemObjects(const struct clEnqueueMigrateMemObjects_st* data) +{ + test_icd_app_log("clEnqueueMigrateMemObjects(%p, %u, %p, %x, %u, %p, %p)\n", + command_queue, + data->num_mem_objects, + data->mem_objects, + data->flags, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val=clEnqueueMigrateMemObjects(command_queue, + data->num_mem_objects, + data->mem_objects, + data->flags, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +struct clEnqueueNDRangeKernel_st clEnqueueNDRangeKernelData[NUM_ITEMS_clEnqueueNDRangeKernel] = +{ + {NULL, NULL, 0, NULL, NULL, NULL, 0, NULL} +}; + +int test_clEnqueueNDRangeKernel(const struct clEnqueueNDRangeKernel_st* data) +{ + test_icd_app_log("clEnqueueNDRangeKernel(%p, %p, %u, %p, %p, %p, %u, %p, %p)\n", + command_queue, + kernel, + data->work_dim, + data->global_work_offset, + data->global_work_size, + data->local_work_size, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val=clEnqueueNDRangeKernel(command_queue, + kernel, + data->work_dim, + data->global_work_offset, + data->global_work_size, + data->local_work_size, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +struct clEnqueueTask_st clEnqueueTaskData[NUM_ITEMS_clEnqueueTask] = +{ + {NULL, NULL, 0, NULL, NULL} +}; + +int test_clEnqueueTask(const struct clEnqueueTask_st* data) +{ + test_icd_app_log("clEnqueueTask(%p, %p, %u, %p, %p)\n", + command_queue, + kernel, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val=clEnqueueTask(command_queue, + kernel, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} +struct clEnqueueNativeKernel_st clEnqueueNativeKernelData[NUM_ITEMS_clEnqueueNativeKernel] = +{ + {NULL, NULL, NULL, 0, 0, NULL, NULL, 0, NULL, NULL} +}; + +int test_clEnqueueNativeKernel(const struct clEnqueueNativeKernel_st* data) { + test_icd_app_log("clEnqueueNativeKernel(%p, %p, %p, %u, %u, %p, %p, %u, %p, %p)\n", + command_queue, + data->user_func, + data->args, + data->cb_args, + data->num_mem_objects, + data->mem_list, + data->args_mem_loc, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val=clEnqueueNativeKernel(command_queue, + data->user_func, + data->args, + data->cb_args, + data->num_mem_objects, + data->mem_list, + data->args_mem_loc, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + return 0; +} + +struct clSetUserEventStatus_st clSetUserEventStatusData[NUM_ITEMS_clSetUserEventStatus] = +{ + {NULL, 0} +}; + +int test_clSetUserEventStatus(const struct clSetUserEventStatus_st* data) +{ + test_icd_app_log("clSetUserEventStatus(%p, %d)\n", + event, + data->execution_status); + + ret_val=clSetUserEventStatus(event, + data->execution_status); + + test_icd_app_log("Value returned: %d\n", ret_val); + return 0; +} + +struct clWaitForEvents_st clWaitForEventsData[NUM_ITEMS_clWaitForEvents] = +{ + {1, NULL} +}; + +int test_clWaitForEvents(const struct clWaitForEvents_st* data) +{ + test_icd_app_log("clWaitForEvents(%u, %p)\n", + data->num_events, + &event); + + ret_val=clWaitForEvents(data->num_events, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + return 0; +} + +struct clGetEventInfo_st clGetEventInfoData[NUM_ITEMS_clGetEventInfo] = +{ + {NULL, 0, 0, NULL, NULL} +}; + +int test_clGetEventInfo(const struct clGetEventInfo_st* data){ + test_icd_app_log("clGetEventInfo(%p, %u, %u, %p, %p)\n", + event, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + ret_val=clGetEventInfo(event, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +struct clSetEventCallback_st clSetEventCallbackData[NUM_ITEMS_clSetEventCallback] = +{ + {NULL, 0, setevent_callback, NULL} +}; + +int test_clSetEventCallback(const struct clSetEventCallback_st* data) +{ + test_icd_app_log("clSetEventCallback(%p, %d, %p, %p)\n", + event, + data->command_exec_callback_type, + data->pfn_event_notify, + data->user_data); + + ret_val=clSetEventCallback(event, + data->command_exec_callback_type, + data->pfn_event_notify, + data->user_data); + + test_icd_app_log("Value returned: %d\n", ret_val); + return 0; +} + +struct clRetainEvent_st clRetainEventData[NUM_ITEMS_clRetainEvent] = +{ + {NULL} +}; + +int test_clRetainEvent(const struct clRetainEvent_st* data) +{ + test_icd_app_log("clRetainEvent(%p)\n", event); + + ret_val=clRetainEvent(event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +struct clEnqueueMarker_st clEnqueueMarkerData[NUM_ITEMS_clEnqueueMarker] = +{ + {NULL, NULL} +}; + +int test_clEnqueueMarker(const struct clEnqueueMarker_st* data) +{ + test_icd_app_log("clEnqueueMarker(%p, %p)\n", command_queue, &event); + + ret_val = clEnqueueMarker(command_queue, &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +struct clEnqueueMarkerWithWaitList_st clEnqueueMarkerWithWaitListData[NUM_ITEMS_clEnqueueMarkerWithWaitList] = +{ + {NULL, 0, NULL, NULL} +}; + +int test_clEnqueueMarkerWithWaitList(const struct clEnqueueMarkerWithWaitList_st* data) +{ + test_icd_app_log("clEnqueueMarkerWithWaitList(%p, %u, %p, %p)\n", + command_queue, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val=clEnqueueMarkerWithWaitList(command_queue, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +struct clEnqueueBarrierWithWaitList_st clEnqueueBarrierWithWaitListData[NUM_ITEMS_clEnqueueBarrierWithWaitList] = +{ + {NULL, 0, NULL, NULL} +}; +int test_clEnqueueBarrierWithWaitList(const struct clEnqueueBarrierWithWaitList_st* data) +{ + test_icd_app_log("clEnqueueBarrierWithWaitList(%p, %u, %p, %p)\n", + command_queue, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + ret_val=clEnqueueBarrierWithWaitList(command_queue, + data->num_events_in_wait_list, + data->event_wait_list, + &event); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +struct clEnqueueWaitForEvents_st clEnqueueWaitForEventsData[NUM_ITEMS_clEnqueueWaitForEvents] = +{ + {NULL, 0, NULL} +}; + +int test_clEnqueueWaitForEvents(const struct clEnqueueWaitForEvents_st* data) +{ + test_icd_app_log("clEnqueueWaitForEvents(%p, %u, %p)\n", + command_queue, + data->num_events, + data->event_list); + + ret_val = clEnqueueWaitForEvents(command_queue, + data->num_events, + data->event_list); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +struct clEnqueueBarrier_st clEnqueueBarrierData[NUM_ITEMS_clEnqueueBarrier] = +{ + {NULL} +}; + +int test_clEnqueueBarrier(const struct clEnqueueBarrier_st* data) +{ + test_icd_app_log("clEnqueueBarrier(%p)\n", command_queue); + + ret_val = clEnqueueBarrier(command_queue); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} +struct clGetEventProfilingInfo_st clGetEventProfilingInfoData[NUM_ITEMS_clGetEventProfilingInfo] = +{ + {NULL, 0, 0, NULL, NULL} +}; + +int test_clGetEventProfilingInfo(const struct clGetEventProfilingInfo_st* data) +{ + test_icd_app_log("clGetEventProfilingInfo(%p, %u, %u, %p, %p)\n", + event, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + ret_val=clGetEventProfilingInfo(event, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +struct clFlush_st clFlushData[NUM_ITEMS_clFlush] = +{ + {NULL} +}; + +int test_clFlush(const struct clFlush_st* data) +{ + test_icd_app_log("clFlush(%p)\n", command_queue); + + ret_val=clFlush(command_queue); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +struct clFinish_st clFinishData[NUM_ITEMS_clFinish] = +{ + {NULL} +}; + +int test_clFinish(const struct clFinish_st* data) +{ + test_icd_app_log("clFinish(%p)\n", command_queue); + + ret_val=clFinish(command_queue); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +int test_kernel() +{ + int i; + + for (i=0; i +#include "param_struct.h" +#include + +extern cl_context context; + +extern cl_platform_id platform; + +extern cl_device_id devices; + +int ret_val; + +struct clRetainContext_st clRetainContextData[NUM_ITEMS_clRetainContext] = +{ + {NULL} +}; + +struct clGetContextInfo_st clGetContextInfoData[NUM_ITEMS_clGetContextInfo] = +{ + {NULL, 0, 0, NULL, NULL} +}; + + +struct clGetPlatformInfo_st clGetPlatformInfoData[NUM_ITEMS_clGetPlatformInfo] = +{ + {NULL, 0, 0, NULL, NULL} +}; + +struct clGetDeviceInfo_st clGetDeviceInfoData[NUM_ITEMS_clGetDeviceInfo] = +{ + {NULL, 0, 0, NULL, NULL} +}; + +struct clCreateSubDevices_st clCreateSubDevicesData[NUM_ITEMS_clCreateSubDevices] = +{ + {NULL, NULL, 0, NULL, NULL} +}; + + +struct clRetainDevice_st clRetainDeviceData[NUM_ITEMS_clRetainDevice] = +{ + {NULL} +}; + + +int test_clRetainContext(const struct clRetainContext_st* data) +{ + test_icd_app_log("clRetainContext(%p)\n", context); + + ret_val = clRetainContext(context); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + + + +int test_clGetContextInfo(const struct clGetContextInfo_st* data) +{ + test_icd_app_log("clGetContextInfo(%p, %u, %u, %p, %p)\n", + context, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + + ret_val = clGetContextInfo(context, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +int test_clGetPlatformInfo(const struct clGetPlatformInfo_st* data) +{ + test_icd_app_log("clGetPlatformInfo(%p, %u, %u, %p, %p)\n", + platform, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + ret_val = clGetPlatformInfo(platform, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clGetDeviceInfo(const struct clGetDeviceInfo_st* data) +{ + test_icd_app_log("clGetDeviceInfo(%p, %u, %u, %p, %p)\n", + devices, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + ret_val = clGetDeviceInfo(devices, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +int test_clCreateSubDevices(const struct clCreateSubDevices_st* data) +{ + test_icd_app_log("clCreateSubDevices(%p, %p, %u, %p, %p)\n", + devices, + data->properties, + data->num_entries, + &devices, + data->num_devices); + + ret_val = clCreateSubDevices(devices, + data->properties, + data->num_entries, + &devices, + data->num_devices); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +int test_clRetainDevice(const struct clRetainDevice_st* data) +{ + test_icd_app_log("clRetainDevice(%p)\n", devices); + + ret_val = clRetainDevice(devices); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +int test_platforms() +{ + int i; + + for (i = 0;i +#include "param_struct.h" +#include + +extern cl_context context; +extern cl_program program; +extern cl_platform_id platform; +extern cl_device_id devices; + +int ret_val; + +extern void CL_CALLBACK program_callback(cl_program _a, void* _b); + +const struct clRetainProgram_st clRetainProgramData[NUM_ITEMS_clRetainProgram]= +{ + {NULL} +}; + +const struct clBuildProgram_st clBuildProgramData[NUM_ITEMS_clBuildProgram]= +{ + {NULL,0,NULL,NULL,program_callback,NULL} +}; + +const struct clCompileProgram_st clCompileProgramData[NUM_ITEMS_clCompileProgram]= +{ + {NULL,0,NULL,NULL,0,NULL,NULL,program_callback,NULL} +}; + +const struct clLinkProgram_st clLinkProgramData[NUM_ITEMS_clLinkProgram]= +{ + {NULL,0,NULL,NULL,0,NULL,program_callback,NULL,NULL} +}; + +const struct clUnloadPlatformCompiler_st clUnloadPlatformCompilerData[NUM_ITEMS_clUnloadPlatformCompiler]= +{ + {NULL} +}; + +const struct clGetExtensionFunctionAddressForPlatform_st clGetExtensionFunctionAddressForPlatformData[NUM_ITEMS_clGetExtensionFunctionAddressForPlatform]= +{ + {NULL, ""} +}; + +const struct clGetProgramInfo_st clGetProgramInfoData[NUM_ITEMS_clGetProgramInfo]= +{ + {NULL,0,0,NULL,NULL} +}; + +const struct clGetProgramBuildInfo_st clGetProgramBuildInfoData[NUM_ITEMS_clGetProgramBuildInfo]= +{ + {NULL,NULL,0,0,NULL,NULL} +}; + +int test_clRetainProgram(const struct clRetainProgram_st *data) +{ + test_icd_app_log("clRetainProgram(%p)\n", + program); + + ret_val=clRetainProgram(program); + + test_icd_app_log("Value returned: %d\n", + ret_val); + + return 0; + +} + +int test_clBuildProgram(const struct clBuildProgram_st *data) +{ + test_icd_app_log("clBuildProgram(%p, %u, %p, %p, %p, %p)\n", + program, + data->num_devices, + &devices, + data->options, + data->pfn_notify, + data->user_data); + + ret_val=clBuildProgram(program, + data->num_devices, + &devices, + data->options, + data->pfn_notify, + data->user_data); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clCompileProgram(const struct clCompileProgram_st *data) +{ + test_icd_app_log("clCompileProgram(%p, %u, %p, %p, %u, %p, %p, %p)\n", + program, + data->num_devices, + &devices, + data->options, + data->num_input_headers, + data->header_include_names, + data->pfn_notify, + data->user_data); + + ret_val=clCompileProgram(program, + data->num_devices, + &devices, + data->options, + data->num_input_headers, + data->headers, + data->header_include_names, + data->pfn_notify, + data->user_data); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clLinkProgram(const struct clLinkProgram_st *data) +{ + cl_program program; + test_icd_app_log("clLinkProgram(%p, %u, %p, %p, %u, %p, %p, %p, %p)\n", + context, + data->num_devices, + data->device_list, + data->options, + data->num_input_programs, + data->input_programs, + data->pfn_notify, + data->user_data, + data->errcode_ret); + + program=clLinkProgram(context, + data->num_devices, + data->device_list, + data->options, + data->num_input_programs, + data->input_programs, + data->pfn_notify, + data->user_data, + data->errcode_ret); + + test_icd_app_log("Value returned: %p\n", program); + + return 0; + +} + +int test_clUnloadPlatformCompiler(const struct clUnloadPlatformCompiler_st *data) +{ + test_icd_app_log("clUnloadPlatformCompiler(%p)\n", platform); + + ret_val=clUnloadPlatformCompiler(platform); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clGetExtensionFunctionAddressForPlatform(const struct clGetExtensionFunctionAddressForPlatform_st *data) +{ + void *return_value; + test_icd_app_log("clGetExtensionFunctionAddressForPlatform(%p, %p)\n", + platform, + data->func_name); + + return_value=clGetExtensionFunctionAddressForPlatform(platform, + data->func_name); + + test_icd_app_log("Value returned: %p\n", return_value); + + return 0; + +} + +int test_clGetProgramInfo(const struct clGetProgramInfo_st *data) +{ + test_icd_app_log("clGetProgramInfo(%p, %u, %u, %p, %p)\n", + program, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + ret_val=clGetProgramInfo(program, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_clGetProgramBuildInfo(const struct clGetProgramBuildInfo_st *data) +{ + test_icd_app_log("clGetProgramBuildInfo(%p, %p, %u, %u, %p, %p)\n", + program, + data->device, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + ret_val=clGetProgramBuildInfo(program, + data->device, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; + +} + +int test_program_objects() +{ + int i; + + for (i=0;i +#include "param_struct.h" +#include + +extern cl_sampler sampler; +int ret_val; + +const struct clRetainSampler_st clRetainSamplerData[NUM_ITEMS_clRetainSampler]= +{ + { NULL } +}; + +const struct clGetSamplerInfo_st clGetSamplerInfoData[NUM_ITEMS_clGetSamplerInfo]= +{ + { NULL, 0, 0, NULL, NULL } +}; + + +int test_clRetainSampler(const struct clRetainSampler_st *data) +{ + test_icd_app_log("clRetainSampler(%p)\n", sampler); + + ret_val=clRetainSampler(sampler); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +int test_clGetSamplerInfo(const struct clGetSamplerInfo_st *data) +{ + test_icd_app_log("clGetSamplerInfo(%p, %u, %u, %p, %p)\n", + sampler, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + ret_val=clGetSamplerInfo(sampler, + data->param_name, + data->param_value_size, + data->param_value, + data->param_value_size_ret); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + +int test_sampler_objects() +{ + int i; + + for (i=0;i +#include +#include +#include +#include +#include + +#define APP_LOG_FILE "icd_test_app_log.txt" +#define STUB_LOG_FILE "icd_test_stub_log.txt" + +static FILE *app_log_file; +static FILE *stub_log_file; + +int test_icd_initialize_app_log(void) +{ + app_log_file = fopen(APP_LOG_FILE, "w"); + if (!app_log_file) { + printf("Unable to open file %s\n", APP_LOG_FILE); + return -1; + } + + return 0; +} + +void test_icd_close_app_log(void) +{ + fclose(app_log_file); +} + +void test_icd_app_log(const char *format, ...) +{ + va_list args; + va_start(args, format); + vfprintf(app_log_file, format, args); + va_end(args); +} + +int test_icd_initialize_stub_log(void) +{ + stub_log_file = fopen(STUB_LOG_FILE, "w"); + if (!stub_log_file) { + printf("Unable to open file %s\n", STUB_LOG_FILE); + return -1; + } + + return 0; + +} + +void test_icd_close_stub_log(void) +{ + fclose(stub_log_file); +} + +void test_icd_stub_log(const char *format, ...) +{ + va_list args; + va_start(args, format); + vfprintf(stub_log_file, format, args); + va_end(args); +} + +static char *test_icd_get_log(const char *filename) +{ + struct stat statbuf; + FILE *fp; + char *source = NULL; + + fp = fopen(filename, "rb"); + + if (fp) { + size_t fsize = 0; + stat(filename, &statbuf); + fsize = statbuf.st_size; + source = (char *)malloc(fsize+1); // +1 for NULL terminator + if (source) { + if (fsize) { + if (fread(source, fsize, 1, fp) != 1) { + free(source); + source = NULL; + } else { + source[fsize] = '\0'; + } + } else { + // Don't fail when fsize = 0, just return empty string + source[fsize] = '\0'; + } + } + fclose(fp); + } + + return source; +} + +char *test_icd_get_app_log(void) +{ + return test_icd_get_log(APP_LOG_FILE); +} + +char *test_icd_get_stub_log(void) +{ + return test_icd_get_log(STUB_LOG_FILE); +}