From 24f189b40ae6b2aa3744c7c87380c7f214a4e310 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Tue, 14 Jul 2015 17:17:43 +0200 Subject: [PATCH 1/5] Check in the khronos ICD library Taken from: https://www.khronos.org/registry/cl/ --- CMakeLists.txt | 1 + khronos_icd/CMakeLists.txt | 31 + khronos_icd/LICENSE.txt | 38 + khronos_icd/Makefile | 30 + khronos_icd/OpenCL.def | 143 ++ khronos_icd/OpenCL.rc | 74 + khronos_icd/README.txt | 50 + khronos_icd/build_using_cmake.bat | 11 + khronos_icd/icd.c | 218 ++ khronos_icd/icd.h | 199 ++ khronos_icd/icd_dispatch.c | 2186 +++++++++++++++++ khronos_icd/icd_dispatch.h | 1283 ++++++++++ khronos_icd/icd_exports.map | 153 ++ khronos_icd/icd_linux.c | 178 ++ khronos_icd/icd_windows.c | 152 ++ khronos_icd/inc/README.txt | 14 + khronos_icd/test/CMakeLists.txt | 7 + khronos_icd/test/Makefile | 18 + khronos_icd/test/driver_stub/CMakeLists.txt | 10 + khronos_icd/test/driver_stub/Makefile | 14 + khronos_icd/test/driver_stub/cl.c | 1917 +++++++++++++++ khronos_icd/test/driver_stub/cl_ext.c | 35 + khronos_icd/test/driver_stub/cl_gl.c | 221 ++ khronos_icd/test/driver_stub/driver_stub.def | 3 + khronos_icd/test/driver_stub/icd.c | 185 ++ .../test/driver_stub/icd_driver_exports.map | 8 + khronos_icd/test/driver_stub/icd_structs.h | 18 + khronos_icd/test/driver_stub/rename_api.h | 106 + khronos_icd/test/inc/platform/icd_test_log.h | 20 + khronos_icd/test/loader_test/CMakeLists.txt | 15 + khronos_icd/test/loader_test/Makefile | 16 + khronos_icd/test/loader_test/callbacks.c | 43 + khronos_icd/test/loader_test/icd_test_match.c | 36 + khronos_icd/test/loader_test/main.c | 47 + khronos_icd/test/loader_test/param_struct.h | 1115 +++++++++ .../test/loader_test/test_buffer_object.c | 461 ++++ .../test/loader_test/test_cl_runtime.c | 64 + khronos_icd/test/loader_test/test_clgl.c | 345 +++ .../test/loader_test/test_create_calls.c | 767 ++++++ .../test/loader_test/test_image_objects.c | 362 +++ khronos_icd/test/loader_test/test_kernel.c | 596 +++++ khronos_icd/test/loader_test/test_platforms.c | 183 ++ .../test/loader_test/test_program_objects.c | 260 ++ .../test/loader_test/test_sampler_objects.c | 64 + khronos_icd/test/platform/CMakeLists.txt | 1 + khronos_icd/test/platform/Makefile | 15 + khronos_icd/test/platform/icd_test_log.c | 98 + 47 files changed, 11811 insertions(+) create mode 100644 khronos_icd/CMakeLists.txt create mode 100644 khronos_icd/LICENSE.txt create mode 100644 khronos_icd/Makefile create mode 100644 khronos_icd/OpenCL.def create mode 100644 khronos_icd/OpenCL.rc create mode 100644 khronos_icd/README.txt create mode 100644 khronos_icd/build_using_cmake.bat create mode 100644 khronos_icd/icd.c create mode 100644 khronos_icd/icd.h create mode 100644 khronos_icd/icd_dispatch.c create mode 100644 khronos_icd/icd_dispatch.h create mode 100644 khronos_icd/icd_exports.map create mode 100644 khronos_icd/icd_linux.c create mode 100644 khronos_icd/icd_windows.c create mode 100644 khronos_icd/inc/README.txt create mode 100644 khronos_icd/test/CMakeLists.txt create mode 100644 khronos_icd/test/Makefile create mode 100644 khronos_icd/test/driver_stub/CMakeLists.txt create mode 100644 khronos_icd/test/driver_stub/Makefile create mode 100644 khronos_icd/test/driver_stub/cl.c create mode 100644 khronos_icd/test/driver_stub/cl_ext.c create mode 100644 khronos_icd/test/driver_stub/cl_gl.c create mode 100644 khronos_icd/test/driver_stub/driver_stub.def create mode 100644 khronos_icd/test/driver_stub/icd.c create mode 100644 khronos_icd/test/driver_stub/icd_driver_exports.map create mode 100644 khronos_icd/test/driver_stub/icd_structs.h create mode 100644 khronos_icd/test/driver_stub/rename_api.h create mode 100644 khronos_icd/test/inc/platform/icd_test_log.h create mode 100644 khronos_icd/test/loader_test/CMakeLists.txt create mode 100644 khronos_icd/test/loader_test/Makefile create mode 100644 khronos_icd/test/loader_test/callbacks.c create mode 100644 khronos_icd/test/loader_test/icd_test_match.c create mode 100644 khronos_icd/test/loader_test/main.c create mode 100644 khronos_icd/test/loader_test/param_struct.h create mode 100644 khronos_icd/test/loader_test/test_buffer_object.c create mode 100644 khronos_icd/test/loader_test/test_cl_runtime.c create mode 100644 khronos_icd/test/loader_test/test_clgl.c create mode 100644 khronos_icd/test/loader_test/test_create_calls.c create mode 100644 khronos_icd/test/loader_test/test_image_objects.c create mode 100644 khronos_icd/test/loader_test/test_kernel.c create mode 100644 khronos_icd/test/loader_test/test_platforms.c create mode 100644 khronos_icd/test/loader_test/test_program_objects.c create mode 100644 khronos_icd/test/loader_test/test_sampler_objects.c create mode 100644 khronos_icd/test/platform/CMakeLists.txt create mode 100644 khronos_icd/test/platform/Makefile create mode 100644 khronos_icd/test/platform/icd_test_log.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 6cd9e338f..ef450f721 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -423,6 +423,7 @@ if (GENERAL OR MINER) add_subdirectory(libethash) if (ETHASHCL) add_subdirectory(libethash-cl) + add_subdirectory(khronos_icd) endif () endif () diff --git a/khronos_icd/CMakeLists.txt b/khronos_icd/CMakeLists.txt new file mode 100644 index 000000000..b0cbe58a3 --- /dev/null +++ b/khronos_icd/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required (VERSION 2.6) + +project (OPENCL_ICD_LOADER) + +set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/bin) +set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/bin) + +set (OPENCL_ICD_LOADER_SOURCES icd.c icd_dispatch.c) + +if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") + list (APPEND OPENCL_ICD_LOADER_SOURCES icd_linux.c icd_exports.map) +else () + list (APPEND OPENCL_ICD_LOADER_SOURCES icd_windows.c OpenCL.def) + include_directories ($ENV{DXSDK_DIR}/Include) +endif () + +# Change this to point to a directory containing OpenCL header directory "CL" +# OR copy OpenCL headers to ./inc/CL/ +include_directories (./inc) + +add_library (OpenCL SHARED ${OPENCL_ICD_LOADER_SOURCES}) +set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1") + +if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") + set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,../icd_exports.map") +endif () + +target_link_libraries (OpenCL ${CMAKE_DL_LIBS}) + +enable_testing() +add_subdirectory (test) diff --git a/khronos_icd/LICENSE.txt b/khronos_icd/LICENSE.txt new file mode 100644 index 000000000..81a772bd4 --- /dev/null +++ b/khronos_icd/LICENSE.txt @@ -0,0 +1,38 @@ +Copyright (c) 2012 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 use, copy, modify and compile the Materials to create a binary under the +following terms and conditions: + +1. The Materials shall NOT be distributed to any third party; + +2. The binary may be distributed without restriction, including without +limitation the rights to use, copy, merge, publish, distribute, sublicense, +and/or sell copies, and to permit persons to whom the binary is furnished to +do so; + +3. 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; + +4. 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/; + +5. The above copyright notice 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. + diff --git a/khronos_icd/Makefile b/khronos_icd/Makefile new file mode 100644 index 000000000..886c1dc59 --- /dev/null +++ b/khronos_icd/Makefile @@ -0,0 +1,30 @@ +.PHONY: default do_cmake do_build test package +.PHONY: clean clobber + +BUILD_DIR:=build +BIN_DIR:=bin + +ICD_VERSION:=$(shell grep FileVersion OpenCL.rc | sed "s/.*\([0-9]\+\.[0-9]\+\.[0-9]\+.[0-9]\+\).*/\1/") +PACKAGE_PATH:=/tmp/opencl-icd-${ICD_VERSION}.tgz + +default: do_build + +do_build: do_cmake + ${MAKE} -C ${BUILD_DIR} + +do_cmake: + mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR} && cmake .. + +test: + ${MAKE} -C ${BUILD_DIR} test + +package: clobber + rm -f ${PACKAGE_PATH} + tar -C .. -czf ${PACKAGE_PATH} --exclude .svn icd + @echo "Package created at ${PACKAGE_PATH}" + +clean: + ${MAKE} -C ${BUILD_DIR} clean + +clobber: + rm -rf ${BUILD_DIR} ${BIN_DIR} diff --git a/khronos_icd/OpenCL.def b/khronos_icd/OpenCL.def new file mode 100644 index 000000000..de92e385a --- /dev/null +++ b/khronos_icd/OpenCL.def @@ -0,0 +1,143 @@ +; Copyright (c) 2012 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 use, copy, modify and compile the Materials to create a binary under the +; following terms and conditions: +; +; 1. The Materials shall NOT be distributed to any third party; +; +; 2. The binary may be distributed without restriction, including without +; limitation the rights to use, copy, merge, publish, distribute, sublicense, +; and/or sell copies, and to permit persons to whom the binary is furnished to +; do so; +; +; 3. 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; +; +; 4. 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/; +; +; 5. The above copyright notice 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. + +EXPORTS + +; OpenCL 1.0 +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 diff --git a/khronos_icd/OpenCL.rc b/khronos_icd/OpenCL.rc new file mode 100644 index 000000000..5cddfe553 --- /dev/null +++ b/khronos_icd/OpenCL.rc @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2012 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 use, copy, modify and compile the Materials to create a binary under the + * following terms and conditions: + * + * 1. The Materials shall NOT be distributed to any third party; + * + * 2. The binary may be distributed without restriction, including without + * limitation the rights to use, copy, merge, publish, distribute, sublicense, + * and/or sell copies, and to permit persons to whom the binary is furnished to + * do so; + * + * 3. 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; + * + * 4. 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/; + * + * 5. The above copyright notice 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 1,2,11,0 +PRODUCTVERSION 1,2,11,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 2011" + VALUE "FileVersion" ,"1.2.11.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/khronos_icd/README.txt b/khronos_icd/README.txt new file mode 100644 index 000000000..3b51170e9 --- /dev/null +++ b/khronos_icd/README.txt @@ -0,0 +1,50 @@ +== Building ICD and ICD Test == + +The build system will build ICD Loader library (OpenCL.dll or libOpenCL.so) and +ICD Loader Test binary (icd_loader_test) and some helper libraries for the test. + +=== Linux === + +Run "make" + +=== Windows === + +Run "build_using_cmake.bat" + +== Running ICD Test == + +ICD Test can be run using ctest, which is a companion to cmake. It can also be +run directly by executing icd_loader_test(.exe) executable from the bin folder. + +=== Linux === + +1. Add driver stub as an ICD + echo full/path/to/libOpenCLDriverStub.so > /etc/OpenCL/vendors/test.icd + +2. Run test using ctest + make test + +=== Windows === + +1. Add driver stub as an ICD by adding appropriate registry value + Key for 32-bit apps: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Khronos\OpenCL\Vendors + Key for 64-bit apps: HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\OpenCL\Vendors + + Add a REG_DWORD value: + Name: c:/full/path/to/OpenCLDriverStub.dll + Data: 0 + + Note: The build_using_cmake.bat builds ICD test as a 32-bit binary. + +2. Run test using ctest.exe + cd build + ctest.exe + +== Cleanup == + +Manually remove the registry key or .icd files added for running the ICD test. + +The "build" and "bin" folders are autogenerated by the build so those may be +safely deleted without losing any source code (on Linux "make clobber" will +delete them). + diff --git a/khronos_icd/build_using_cmake.bat b/khronos_icd/build_using_cmake.bat new file mode 100644 index 000000000..f0044db7a --- /dev/null +++ b/khronos_icd/build_using_cmake.bat @@ -0,0 +1,11 @@ +call "%VS90COMNTOOLS%/vsvars32.bat" + +set BUILD_DIR=build +set BIN_DIR=bin + +mkdir %BUILD_DIR% +cd %BUILD_DIR% +cmake -G "NMake Makefiles" ../ +nmake +cd .. + diff --git a/khronos_icd/icd.c b/khronos_icd/icd.c new file mode 100644 index 000000000..c59a7d9b5 --- /dev/null +++ b/khronos_icd/icd.c @@ -0,0 +1,218 @@ +/* + * Copyright (c) 2012 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 use, copy, modify and compile the Materials to create a binary under the + * following terms and conditions: + * + * 1. The Materials shall NOT be distributed to any third party; + * + * 2. The binary may be distributed without restriction, including without + * limitation the rights to use, copy, merge, publish, distribute, sublicense, + * and/or sell copies, and to permit persons to whom the binary is furnished to + * do so; + * + * 3. 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; + * + * 4. 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/; + * + * 5. The above copyright notice 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_dispatch.h" +#include +#include + +KHRicdState khrIcdState = {0}; + +// entrypoint to initialize the ICD and add all vendors +void khrIcdInitialize(void) +{ + // make sure we don't double-initialize + // TODO: this should use an atomic exchange to be thread-safe + if (khrIcdState.initialized) + { + return; + } + khrIcdState.initialized = CL_TRUE; + + // enumerate vendors present on the system + khrIcdOsVendorsEnumerate(); +} + +void khrIcdVendorAdd(const char *libraryName) +{ + void *library = NULL; + cl_int result = CL_SUCCESS; + pfn_clGetExtensionFunctionAddress p_clGetExtensionFunctionAddress = NULL; + pfn_clIcdGetPlatformIDs p_clIcdGetPlatformIDs = NULL; + cl_uint i = 0; + cl_uint platformCount = 0; + cl_platform_id *platforms = NULL; + + // require that the library name be valid + if (!libraryName) + { + goto Done; + } + KHR_ICD_TRACE("attempting to add vendor %s...\n", libraryName); + + // load its library and query its function pointers + library = khrIcdOsLibraryLoad(libraryName); + if (!library) + { + KHR_ICD_TRACE("failed to load library %s\n", libraryName); + goto Done; + } + + // get the library's clGetExtensionFunctionAddress pointer + p_clGetExtensionFunctionAddress = khrIcdOsLibraryGetFunctionAddress(library, "clGetExtensionFunctionAddress"); + if (!p_clGetExtensionFunctionAddress) + { + KHR_ICD_TRACE("failed to get function address clGetExtensionFunctionAddress\n"); + goto Done; + } + + // use that function to get the clIcdGetPlatformIDsKHR function pointer + p_clIcdGetPlatformIDs = p_clGetExtensionFunctionAddress("clIcdGetPlatformIDsKHR"); + if (!p_clIcdGetPlatformIDs) + { + KHR_ICD_TRACE("failed to get extension function address clIcdGetPlatformIDsKHR\n"); + goto Done; + } + + // query the number of platforms available and allocate space to store them + result = p_clIcdGetPlatformIDs(0, NULL, &platformCount); + if (CL_SUCCESS != result) + { + KHR_ICD_TRACE("failed clIcdGetPlatformIDs\n"); + goto Done; + } + platforms = (cl_platform_id *)malloc(platformCount * sizeof(cl_platform_id) ); + if (!platforms) + { + KHR_ICD_TRACE("failed to allocate memory\n"); + goto Done; + } + memset(platforms, 0, platformCount * sizeof(cl_platform_id) ); + result = p_clIcdGetPlatformIDs(platformCount, platforms, NULL); + if (CL_SUCCESS != result) + { + KHR_ICD_TRACE("failed clIcdGetPlatformIDs\n"); + goto Done; + } + + // for each platform, add it + for (i = 0; i < platformCount; ++i) + { + KHRicdVendor* vendor = NULL; + char *suffix; + size_t suffixSize; + + // call clGetPlatformInfo on the returned platform to get the suffix + if (!platforms[i]) + { + continue; + } + result = platforms[i]->dispatch->clGetPlatformInfo( + platforms[i], + CL_PLATFORM_ICD_SUFFIX_KHR, + 0, + NULL, + &suffixSize); + if (CL_SUCCESS != result) + { + continue; + } + suffix = (char *)malloc(suffixSize); + if (!suffix) + { + continue; + } + result = platforms[i]->dispatch->clGetPlatformInfo( + platforms[i], + CL_PLATFORM_ICD_SUFFIX_KHR, + suffixSize, + suffix, + NULL); + if (CL_SUCCESS != result) + { + free(suffix); + continue; + } + + // allocate a structure for the vendor + vendor = (KHRicdVendor*)malloc(sizeof(*vendor) ); + if (!vendor) + { + free(suffix); + KHR_ICD_TRACE("failed to allocate memory\n"); + continue; + } + memset(vendor, 0, sizeof(*vendor) ); + + // populate vendor data + vendor->library = khrIcdOsLibraryLoad(libraryName); + if (!vendor->library) + { + free(suffix); + free(vendor); + KHR_ICD_TRACE("failed get platform handle to library\n"); + continue; + } + vendor->clGetExtensionFunctionAddress = p_clGetExtensionFunctionAddress; + vendor->platform = platforms[i]; + vendor->suffix = suffix; + + // add this vendor to the list of vendors at the tail + { + KHRicdVendor **prevNextPointer = NULL; + for (prevNextPointer = &khrIcdState.vendors; *prevNextPointer; prevNextPointer = &( (*prevNextPointer)->next) ); + *prevNextPointer = vendor; + } + + KHR_ICD_TRACE("successfully added vendor %s with suffix %s\n", libraryName, suffix); + + } + +Done: + + if (library) + { + khrIcdOsLibraryUnload(library); + } +} + +void khrIcdContextPropertiesGetPlatform(const cl_context_properties *properties, cl_platform_id *outPlatform) +{ + const cl_context_properties *property = (cl_context_properties *)NULL; + *outPlatform = NULL; + for (property = properties; property && property[0]; property += 2) + { + if ((cl_context_properties)CL_CONTEXT_PLATFORM == property[0]) + { + *outPlatform = (cl_platform_id)property[1]; + } + } +} + diff --git a/khronos_icd/icd.h b/khronos_icd/icd.h new file mode 100644 index 000000000..637ed707c --- /dev/null +++ b/khronos_icd/icd.h @@ -0,0 +1,199 @@ +/* + * Copyright (c) 2012 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 use, copy, modify and compile the Materials to create a binary under the + * following terms and conditions: + * + * 1. The Materials shall NOT be distributed to any third party; + * + * 2. The binary may be distributed without restriction, including without + * limitation the rights to use, copy, merge, publish, distribute, sublicense, + * and/or sell copies, and to permit persons to whom the binary is furnished to + * do so; + * + * 3. 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; + * + * 4. 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/; + * + * 5. The above copyright notice 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. + */ + +#ifndef _ICD_H_ +#define _ICD_H_ + +#include +#include + +/* + * type definitions + */ + +typedef CL_API_ENTRY cl_int (CL_API_CALL *pfn_clIcdGetPlatformIDs)( + cl_uint num_entries, + cl_platform_id *platforms, + cl_uint *num_platforms) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *pfn_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; + +typedef CL_API_ENTRY void *(CL_API_CALL *pfn_clGetExtensionFunctionAddress)( + const char *function_name) CL_API_SUFFIX__VERSION_1_0; + +typedef struct KHRicdVendorRec KHRicdVendor; +typedef struct KHRicdStateRec KHRicdState; + +/* + * KHRicdVendor + * + * Data for a single ICD vendor platform. + */ +struct KHRicdVendorRec +{ + // the loaded library object (true type varies on Linux versus Windows) + void *library; + + // the extension suffix for this platform + char *suffix; + + // function pointer to the ICD platform IDs extracted from the library + pfn_clGetExtensionFunctionAddress clGetExtensionFunctionAddress; + + // the platform retrieved from clGetIcdPlatformIDsKHR + cl_platform_id platform; + + // next vendor in the list vendors + KHRicdVendor *next; +}; + + +/* + * KHRicdState + * + * The global state of all vendors + * + * TODO: write access to this structure needs to be protected via a mutex + */ + +struct KHRicdStateRec +{ + // has this structure been initialized + cl_bool initialized; + + // the list of vendors which have been loaded + KHRicdVendor *vendors; +}; + +// the global state +extern KHRicdState khrIcdState; + +/* + * khrIcd interface + */ + +// read vendors from system configuration and store the data +// loaded into khrIcdState. this will call the OS-specific +// function khrIcdEnumerateVendors. this is called at every +// dispatch function which may be a valid first call into the +// API (e.g, getPlatformIDs, etc). +void khrIcdInitialize(void); + +// go through the list of vendors (in /etc/OpenCL.conf or through +// the registry) and call khrIcdVendorAdd for each vendor encountered +// n.b, this call is OS-specific +void khrIcdOsVendorsEnumerate(void); + +// add a vendor's implementation to the list of libraries +void khrIcdVendorAdd(const char *libraryName); + +// dynamically load a library. returns NULL on failure +// n.b, this call is OS-specific +void *khrIcdOsLibraryLoad(const char *libraryName); + +// get a function pointer from a loaded library. returns NULL on failure. +// n.b, this call is OS-specific +void *khrIcdOsLibraryGetFunctionAddress(void *library, const char *functionName); + +// unload a library. +// n.b, this call is OS-specific +void khrIcdOsLibraryUnload(void *library); + +// parse properties and determine the platform to use from them +void khrIcdContextPropertiesGetPlatform( + const cl_context_properties *properties, + cl_platform_id *outPlatform); + +// internal tracing macros +#if 0 + #include + #define KHR_ICD_TRACE(...) \ + do \ + { \ + fprintf(stderr, "KHR ICD trace at %s:%d: ", __FILE__, __LINE__); \ + fprintf(stderr, __VA_ARGS__); \ + } while (0) + + #define KHR_ICD_ASSERT(x) \ + do \ + { \ + if (!(x)) \ + { \ + fprintf(stderr, "KHR ICD assert at %s:%d: %s failed", __FILE__, __LINE__, #x); \ + } \ + } while (0) +#else + #define KHR_ICD_TRACE(...) + #define KHR_ICD_ASSERT(x) +#endif + +// if handle is NULL then return invalid_handle_error_code +#define KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(handle,invalid_handle_error_code) \ + do \ + { \ + if (!handle) \ + { \ + return invalid_handle_error_code; \ + } \ + } while (0) + +// if handle is NULL then set errcode_ret to invalid_handle_error and return NULL +// (NULL being an invalid handle) +#define KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(handle,invalid_handle_error) \ + do \ + { \ + if (!handle) \ + { \ + if (errcode_ret) \ + { \ + *errcode_ret = invalid_handle_error; \ + } \ + return NULL; \ + } \ + } while (0) + + +#endif + diff --git a/khronos_icd/icd_dispatch.c b/khronos_icd/icd_dispatch.c new file mode 100644 index 000000000..ce2645a87 --- /dev/null +++ b/khronos_icd/icd_dispatch.c @@ -0,0 +1,2186 @@ +/* + * Copyright (c) 2012 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 use, copy, modify and compile the Materials to create a binary under the + * following terms and conditions: + * + * 1. The Materials shall NOT be distributed to any third party; + * + * 2. The binary may be distributed without restriction, including without + * limitation the rights to use, copy, merge, publish, distribute, sublicense, + * and/or sell copies, and to permit persons to whom the binary is furnished to + * do so; + * + * 3. 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; + * + * 4. 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/; + * + * 5. The above copyright notice 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_dispatch.h" +#include "icd.h" +#include +#include + +// Platform APIs +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 +{ + KHRicdVendor* vendor = NULL; + cl_uint i; + + // initialize the platforms (in case they have not been already) + khrIcdInitialize(); + + if (!num_entries && platforms) + { + return CL_INVALID_VALUE; + } + if (!platforms && !num_platforms) + { + return CL_INVALID_VALUE; + } + // set num_platforms to 0 and set all platform pointers to NULL + if (num_platforms) + { + *num_platforms = 0; + } + for (i = 0; i < num_entries && platforms; ++i) + { + platforms[i] = NULL; + } + // return error if we have no platforms + if (!khrIcdState.vendors) + { + return CL_PLATFORM_NOT_FOUND_KHR; + } + // otherwise enumerate all platforms + for (vendor = khrIcdState.vendors; vendor; vendor = vendor->next) + { + if (num_entries && platforms) + { + *(platforms++) = vendor->platform; + --num_entries; + } + if (num_platforms) + { + ++(*num_platforms); + } + } + return CL_SUCCESS; +} + +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 +{ + // initialize the platforms (in case they have not been already) + khrIcdInitialize(); + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); + return platform->dispatch->clGetPlatformInfo( + platform, + param_name, + param_value_size, + param_value, + param_value_size_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 +{ + // initialize the platforms (in case they have not been already) + khrIcdInitialize(); + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); + return platform->dispatch->clGetDeviceIDs( + platform, + device_type, + num_entries, + devices, + num_devices); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); + return device->dispatch->clGetDeviceInfo( + device, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(in_device, CL_INVALID_DEVICE); + return in_device->dispatch->clCreateSubDevices( + in_device, + properties, + num_entries, + out_devices, + num_devices); +} + +CL_API_ENTRY cl_int CL_API_CALL +clRetainDevice(cl_device_id device) CL_API_SUFFIX__VERSION_1_2 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); + return device->dispatch->clRetainDevice(device); +} + +CL_API_ENTRY cl_int CL_API_CALL +clReleaseDevice(cl_device_id device) CL_API_SUFFIX__VERSION_1_2 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); + return device->dispatch->clReleaseDevice(device); +} + +// 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 +{ + // initialize the platforms (in case they have not been already) + khrIcdInitialize(); + if (!num_devices || !devices) + { + if (errcode_ret) + { + *errcode_ret = CL_INVALID_VALUE; + } + return NULL; + } + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(devices[0], CL_INVALID_DEVICE); + return devices[0]->dispatch->clCreateContext( + properties, + num_devices, + devices, + pfn_notify, + user_data, + errcode_ret); +} + +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_platform_id platform = NULL; + + // initialize the platforms (in case they have not been already) + khrIcdInitialize(); + + // determine the platform to use from the properties specified + khrIcdContextPropertiesGetPlatform(properties, &platform); + + // validate the platform handle and dispatch + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(platform, CL_INVALID_PLATFORM); + return platform->dispatch->clCreateContextFromType( + properties, + device_type, + pfn_notify, + user_data, + errcode_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clRetainContext(cl_context context) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(context, CL_INVALID_CONTEXT); + return context->dispatch->clRetainContext(context); +} + +CL_API_ENTRY cl_int CL_API_CALL +clReleaseContext(cl_context context) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(context, CL_INVALID_CONTEXT); + return context->dispatch->clReleaseContext(context); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(context, CL_INVALID_CONTEXT); + return context->dispatch->clGetContextInfo( + context, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +// 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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateCommandQueue( + context, + device, + properties, + errcode_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clRetainCommandQueue(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clRetainCommandQueue(command_queue); +} + +CL_API_ENTRY cl_int CL_API_CALL +clReleaseCommandQueue(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clReleaseCommandQueue(command_queue); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clGetCommandQueueInfo( + command_queue, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +// 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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateBuffer( + context, + flags, + size, + host_ptr, + errcode_ret); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateImage( + context, + flags, + image_format, + image_desc, + host_ptr, + errcode_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clRetainMemObject(cl_mem memobj) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); + return memobj->dispatch->clRetainMemObject(memobj); +} + + +CL_API_ENTRY cl_int CL_API_CALL +clReleaseMemObject(cl_mem memobj) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); + return memobj->dispatch->clReleaseMemObject(memobj); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(context, CL_INVALID_CONTEXT); + return context->dispatch->clGetSupportedImageFormats( + context, + flags, + image_type, + num_entries, + image_formats, + num_image_formats); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); + return memobj->dispatch->clGetMemObjectInfo( + memobj, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(image, CL_INVALID_MEM_OBJECT); + return image->dispatch->clGetImageInfo( + image, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +// 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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateSampler( + context, + normalized_coords, + addressing_mode, + filter_mode, + errcode_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clRetainSampler(cl_sampler sampler) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(sampler, CL_INVALID_SAMPLER); + return sampler->dispatch->clRetainSampler(sampler); +} + +CL_API_ENTRY cl_int CL_API_CALL +clReleaseSampler(cl_sampler sampler) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(sampler, CL_INVALID_SAMPLER); + return sampler->dispatch->clReleaseSampler(sampler); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(sampler, CL_INVALID_SAMPLER); + return sampler->dispatch->clGetSamplerInfo( + sampler, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +// 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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateProgramWithSource( + context, + count, + strings, + lengths, + errcode_ret); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateProgramWithBinary( + context, + num_devices, + device_list, + lengths, + binaries, + binary_status, + errcode_ret); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateProgramWithBuiltInKernels( + context, + num_devices, + device_list, + kernel_names, + errcode_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clRetainProgram(cl_program program) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); + return program->dispatch->clRetainProgram(program); +} + +CL_API_ENTRY cl_int CL_API_CALL +clReleaseProgram(cl_program program) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); + return program->dispatch->clReleaseProgram(program); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); + return program->dispatch->clBuildProgram( + program, + num_devices, + device_list, + options, + pfn_notify, + user_data); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); + return program->dispatch->clCompileProgram( + program, + num_devices, + device_list, + options, + num_input_headers, + input_headers, + header_include_names, + pfn_notify, + user_data); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clLinkProgram( + context, + num_devices, + device_list, + options, + num_input_programs, + input_programs, + pfn_notify, + user_data, + errcode_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clUnloadPlatformCompiler(cl_platform_id platform) CL_API_SUFFIX__VERSION_1_2 +{ + // initialize the platforms (in case they have not been already) + khrIcdInitialize(); + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); + return platform->dispatch->clUnloadPlatformCompiler(platform); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); + return program->dispatch->clGetProgramInfo( + program, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); + return program->dispatch->clGetProgramBuildInfo( + program, + device, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +// 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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(program, CL_INVALID_PROGRAM); + return program->dispatch->clCreateKernel( + program, + kernel_name, + errcode_ret); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); + return program->dispatch->clCreateKernelsInProgram( + program, + num_kernels, + kernels, + num_kernels_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clRetainKernel(cl_kernel kernel) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); + return kernel->dispatch->clRetainKernel(kernel); +} + +CL_API_ENTRY cl_int CL_API_CALL +clReleaseKernel(cl_kernel kernel) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); + return kernel->dispatch->clReleaseKernel(kernel); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); + return kernel->dispatch->clSetKernelArg( + kernel, + arg_index, + arg_size, + arg_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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); + return kernel->dispatch->clGetKernelInfo( + kernel, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); + return kernel->dispatch->clGetKernelArgInfo( + kernel, + arg_indx, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); + return kernel->dispatch->clGetKernelWorkGroupInfo( + kernel, + device, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +// 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 +{ + if (!num_events || !event_list) + { + return CL_INVALID_VALUE; + } + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event_list[0], CL_INVALID_EVENT); + return event_list[0]->dispatch->clWaitForEvents( + num_events, + event_list); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); + return event->dispatch->clGetEventInfo( + event, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clRetainEvent(cl_event event) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); + return event->dispatch->clRetainEvent(event); +} + +CL_API_ENTRY cl_int CL_API_CALL +clReleaseEvent(cl_event event) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); + return event->dispatch->clReleaseEvent(event); +} + +// 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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); + return event->dispatch->clGetEventProfilingInfo( + event, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +// Flush and Finish APIs +CL_API_ENTRY cl_int CL_API_CALL +clFlush(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clFlush(command_queue); +} + +CL_API_ENTRY cl_int CL_API_CALL +clFinish(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clFinish(command_queue); +} + +// 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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueReadBuffer( + command_queue, + buffer, + blocking_read, + offset, + cb, + ptr, + num_events_in_wait_list, + event_wait_list, + event); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueReadBufferRect( + 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); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueWriteBuffer( + command_queue, + buffer, + blocking_write, + offset, + cb, + ptr, + num_events_in_wait_list, + event_wait_list, + event); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueWriteBufferRect( + 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, + 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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueWriteBufferRect( + 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); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueFillBuffer( + command_queue, + buffer, + pattern, + pattern_size, + offset, + cb, + num_events_in_wait_list, + event_wait_list, + event); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueCopyBuffer( + command_queue, + src_buffer, + dst_buffer, + src_offset, + dst_offset, + cb, + num_events_in_wait_list, + event_wait_list, + event); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueCopyBufferRect( + 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); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueReadImage( + command_queue, + image, + blocking_read, + origin, + region, + row_pitch, + slice_pitch, + ptr, + num_events_in_wait_list, + event_wait_list, + event); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueWriteImage( + command_queue, + image, + blocking_write, + origin, + region, + input_row_pitch, + input_slice_pitch, + ptr, + num_events_in_wait_list, + event_wait_list, + event); +} + +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[3], + const size_t region[3], + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_2 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueFillImage( + command_queue, + image, + fill_color, + origin, + region, + num_events_in_wait_list, + event_wait_list, + event); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueCopyImage( + command_queue, + src_image, + dst_image, + src_origin, + dst_origin, + region, + num_events_in_wait_list, + event_wait_list, + event); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueCopyImageToBuffer( + command_queue, + src_image, + dst_buffer, + src_origin, + region, + dst_offset, + num_events_in_wait_list, + event_wait_list, + event); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueCopyBufferToImage( + command_queue, + src_buffer, + dst_image, + src_offset, + dst_origin, + region, + num_events_in_wait_list, + event_wait_list, + event); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueMapBuffer( + command_queue, + buffer, + blocking_map, + map_flags, + offset, + cb, + num_events_in_wait_list, + event_wait_list, + event, + errcode_ret); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueMapImage( + 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); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueUnmapMemObject( + command_queue, + memobj, + mapped_ptr, + num_events_in_wait_list, + event_wait_list, + event); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueMigrateMemObjects( + command_queue, + num_mem_objects, + mem_objects, + flags, + num_events_in_wait_list, + event_wait_list, + event); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueNDRangeKernel( + command_queue, + kernel, + work_dim, + global_work_offset, + global_work_size, + local_work_size, + num_events_in_wait_list, + event_wait_list, + event); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueTask( + command_queue, + kernel, + num_events_in_wait_list, + event_wait_list, + event); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueNativeKernel( + command_queue, + user_func, + args, + cb_args, + num_mem_objects, + mem_list, + args_mem_loc, + num_events_in_wait_list, + event_wait_list, + event); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueMarkerWithWaitList( + command_queue, + num_events_in_wait_list, + event_wait_list, + event); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueBarrierWithWaitList( + command_queue, + num_events_in_wait_list, + event_wait_list, + event); +} + +CL_API_ENTRY void * CL_API_CALL +clGetExtensionFunctionAddressForPlatform(cl_platform_id platform, + const char * function_name) CL_API_SUFFIX__VERSION_1_2 +{ + // make sure the ICD is initialized + khrIcdInitialize(); + + // return any ICD-aware extensions + #define CL_COMMON_EXTENSION_ENTRYPOINT_ADD(name) if (!strcmp(function_name, #name) ) return (void *)&name + + // Are these core or ext? This is unclear, but they appear to be + // independent from cl_khr_gl_sharing. + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLBuffer); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLTexture); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLTexture2D); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLTexture3D); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLRenderbuffer); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetGLObjectInfo); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetGLTextureInfo); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueAcquireGLObjects); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueReleaseGLObjects); + + // cl_khr_gl_sharing + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetGLContextInfoKHR); + + // cl_khr_gl_event + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateEventFromGLsyncKHR); + +#if defined(_WIN32) + // cl_khr_d3d10_sharing + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetDeviceIDsFromD3D10KHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D10BufferKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D10Texture2DKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D10Texture3DKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueAcquireD3D10ObjectsKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueReleaseD3D10ObjectsKHR); + // cl_khr_d3d11_sharing + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetDeviceIDsFromD3D11KHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D11BufferKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D11Texture2DKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D11Texture3DKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueAcquireD3D11ObjectsKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueReleaseD3D11ObjectsKHR); + // cl_khr_dx9_media_sharing + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetDeviceIDsFromDX9MediaAdapterKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromDX9MediaSurfaceKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueAcquireDX9MediaSurfacesKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueReleaseDX9MediaSurfacesKHR); +#endif + + // cl_ext_device_fission + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateSubDevicesEXT); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clRetainDeviceEXT); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clReleaseDeviceEXT); + + // fall back to vendor extension detection + + // 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); + return platform->dispatch->clGetExtensionFunctionAddressForPlatform( + platform, + function_name); +} + +// Deprecated APIs +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clSetCommandQueueProperty( + command_queue, + properties, + enable, + old_properties); +} + +CL_API_ENTRY cl_int CL_API_CALL +clCreateSubDevicesEXT( + cl_device_id in_device, + const cl_device_partition_property_ext * partition_properties, + cl_uint num_entries, + cl_device_id * out_devices, + cl_uint * num_devices) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(in_device, CL_INVALID_DEVICE); + return in_device->dispatch->clCreateSubDevicesEXT( + in_device, + partition_properties, + num_entries, + out_devices, + num_devices); +} + +CL_API_ENTRY cl_int CL_API_CALL +clRetainDeviceEXT(cl_device_id device) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); + return device->dispatch->clRetainDeviceEXT(device); +} + +CL_API_ENTRY cl_int CL_API_CALL +clReleaseDeviceEXT(cl_device_id device) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); + return device->dispatch->clReleaseDeviceEXT(device); +} + +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_EXT_SUFFIX__VERSION_1_1_DEPRECATED +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateImage2D( + context, + flags, + image_format, + image_width, + image_height, + image_row_pitch, + host_ptr, + errcode_ret); +} + +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_EXT_SUFFIX__VERSION_1_1_DEPRECATED +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateImage3D( + context, + flags, + image_format, + image_width, + image_height, + image_depth, + image_row_pitch, + image_slice_pitch, + host_ptr, + errcode_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clUnloadCompiler(void) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED +{ + return CL_SUCCESS; +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueMarker(cl_command_queue command_queue, + cl_event * event) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueMarker( + command_queue, + event); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueWaitForEvents(cl_command_queue command_queue, + cl_uint num_events, + const cl_event * event_list) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueWaitForEvents( + command_queue, + num_events, + event_list); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueBarrier(cl_command_queue command_queue) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueBarrier(command_queue); +} + +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); + KHRicdVendor* vendor = NULL; + + // make sure the ICD is initialized + khrIcdInitialize(); + + // return any ICD-aware extensions + #define CL_COMMON_EXTENSION_ENTRYPOINT_ADD(name) if (!strcmp(function_name, #name) ) return (void *)&name + + // Are these core or ext? This is unclear, but they appear to be + // independent from cl_khr_gl_sharing. + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLBuffer); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLTexture); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLTexture2D); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLTexture3D); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLRenderbuffer); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetGLObjectInfo); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetGLTextureInfo); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueAcquireGLObjects); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueReleaseGLObjects); + + // cl_khr_gl_sharing + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetGLContextInfoKHR); + + // cl_khr_gl_event + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateEventFromGLsyncKHR); + +#if defined(_WIN32) + // cl_khr_d3d10_sharing + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetDeviceIDsFromD3D10KHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D10BufferKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D10Texture2DKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D10Texture3DKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueAcquireD3D10ObjectsKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueReleaseD3D10ObjectsKHR); + // cl_khr_d3d11_sharing + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetDeviceIDsFromD3D11KHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D11BufferKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D11Texture2DKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D11Texture3DKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueAcquireD3D11ObjectsKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueReleaseD3D11ObjectsKHR); + // cl_khr_dx9_media_sharing + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetDeviceIDsFromDX9MediaAdapterKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromDX9MediaSurfaceKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueAcquireDX9MediaSurfacesKHR); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueReleaseDX9MediaSurfacesKHR); +#endif + + // cl_ext_device_fission + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateSubDevicesEXT); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clRetainDeviceEXT); + CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clReleaseDeviceEXT); + + // fall back to vendor extension detection + for (vendor = khrIcdState.vendors; vendor; vendor = vendor->next) + { + size_t vendor_suffix_length = strlen(vendor->suffix); + if (vendor_suffix_length <= function_name_length && vendor_suffix_length > 0) + { + const char *function_suffix = function_name+function_name_length-vendor_suffix_length; + if (!strcmp(function_suffix, vendor->suffix) ) + { + return vendor->clGetExtensionFunctionAddress(function_name); + } + } + } + return NULL; +} + +// GL and other APIs +CL_API_ENTRY cl_mem CL_API_CALL clCreateFromGLBuffer( + cl_context context, + cl_mem_flags flags, + GLuint bufobj, + int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateFromGLBuffer( + context, + flags, + bufobj, + errcode_ret); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateFromGLTexture( + context, + flags, + target, + miplevel, + texture, + errcode_ret); +} + +CL_API_ENTRY cl_mem CL_API_CALL clCreateFromGLTexture2D( + cl_context context, + cl_mem_flags flags, + GLenum target, + GLint miplevel, + GLuint texture, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateFromGLTexture2D( + context, + flags, + target, + miplevel, + texture, + errcode_ret); +} + +CL_API_ENTRY cl_mem CL_API_CALL clCreateFromGLTexture3D( + cl_context context, + cl_mem_flags flags, + GLenum target, + GLint miplevel, + GLuint texture, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateFromGLTexture3D( + context, + flags, + target, + miplevel, + texture, + errcode_ret); +} + +CL_API_ENTRY cl_mem CL_API_CALL clCreateFromGLRenderbuffer( + cl_context context, + cl_mem_flags flags, + GLuint renderbuffer, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateFromGLRenderbuffer( + context, + flags, + renderbuffer, + errcode_ret); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); + return memobj->dispatch->clGetGLObjectInfo( + memobj, + gl_object_type, + gl_object_name); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); + return memobj->dispatch->clGetGLTextureInfo( + memobj, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueAcquireGLObjects( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueReleaseGLObjects( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} + +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_platform_id platform = NULL; + + // initialize the platforms (in case they have not been already) + khrIcdInitialize(); + + // determine the platform to use from the properties specified + khrIcdContextPropertiesGetPlatform(properties, &platform); + + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); + return platform->dispatch->clGetGLContextInfoKHR( + properties, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +CL_API_ENTRY cl_event CL_API_CALL clCreateEventFromGLsyncKHR( + cl_context context, + cl_GLsync sync, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_1 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateEventFromGLsyncKHR( + context, + sync, + errcode_ret); +} + +#if defined(_WIN32) +/* + * + * cl_d3d10_sharing_khr + * + */ + +CL_API_ENTRY cl_int CL_API_CALL +clGetDeviceIDsFromD3D10KHR( + 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) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); + return platform->dispatch->clGetDeviceIDsFromD3D10KHR( + platform, + d3d_device_source, + d3d_object, + d3d_device_set, + num_entries, + devices, + num_devices); +} + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromD3D10BufferKHR( + cl_context context, + cl_mem_flags flags, + ID3D10Buffer *resource, + cl_int *errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateFromD3D10BufferKHR( + context, + flags, + resource, + errcode_ret); +} + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromD3D10Texture2DKHR( + cl_context context, + cl_mem_flags flags, + ID3D10Texture2D * resource, + UINT subresource, + cl_int * errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateFromD3D10Texture2DKHR( + context, + flags, + resource, + subresource, + errcode_ret); +} + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromD3D10Texture3DKHR( + cl_context context, + cl_mem_flags flags, + ID3D10Texture3D *resource, + UINT subresource, + cl_int *errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateFromD3D10Texture3DKHR( + context, + flags, + resource, + subresource, + errcode_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueAcquireD3D10ObjectsKHR( + 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) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueAcquireD3D10ObjectsKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueReleaseD3D10ObjectsKHR( + 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) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueReleaseD3D10ObjectsKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} + +/* + * + * cl_d3d11_sharing_khr + * + */ + +CL_API_ENTRY cl_int CL_API_CALL +clGetDeviceIDsFromD3D11KHR( + cl_platform_id platform, + cl_d3d11_device_source_khr d3d_device_source, + void * d3d_object, + cl_d3d11_device_set_khr d3d_device_set, + cl_uint num_entries, + cl_device_id * devices, + cl_uint * num_devices) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); + return platform->dispatch->clGetDeviceIDsFromD3D11KHR( + platform, + d3d_device_source, + d3d_object, + d3d_device_set, + num_entries, + devices, + num_devices); +} + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromD3D11BufferKHR( + cl_context context, + cl_mem_flags flags, + ID3D11Buffer * resource, + cl_int * errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateFromD3D11BufferKHR( + context, + flags, + resource, + errcode_ret); +} + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromD3D11Texture2DKHR( + cl_context context, + cl_mem_flags flags, + ID3D11Texture2D * resource, + UINT subresource, + cl_int * errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateFromD3D11Texture2DKHR( + context, + flags, + resource, + subresource, + errcode_ret); +} + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromD3D11Texture3DKHR( + cl_context context, + cl_mem_flags flags, + ID3D11Texture3D * resource, + UINT subresource, + cl_int * errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateFromD3D11Texture3DKHR( + context, + flags, + resource, + subresource, + errcode_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueAcquireD3D11ObjectsKHR( + 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) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueAcquireD3D11ObjectsKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueReleaseD3D11ObjectsKHR( + 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) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueReleaseD3D11ObjectsKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} + +/* + * + * cl_khr_dx9_media_sharing + * + */ + +CL_API_ENTRY cl_int CL_API_CALL +clGetDeviceIDsFromDX9MediaAdapterKHR( + cl_platform_id platform, + cl_uint num_media_adapters, + cl_dx9_media_adapter_type_khr * media_adapters_type, + void * media_adapters[], + cl_dx9_media_adapter_set_khr media_adapter_set, + cl_uint num_entries, + cl_device_id * devices, + cl_uint * num_devices) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); + return platform->dispatch->clGetDeviceIDsFromDX9MediaAdapterKHR( + platform, + num_media_adapters, + media_adapters_type, + media_adapters, + media_adapter_set, + num_entries, + devices, + num_devices); +} + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromDX9MediaSurfaceKHR( + cl_context context, + cl_mem_flags flags, + cl_dx9_media_adapter_type_khr adapter_type, + void * surface_info, + cl_uint plane, + cl_int * errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateFromDX9MediaSurfaceKHR( + context, + flags, + adapter_type, + surface_info, + plane, + errcode_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueAcquireDX9MediaSurfacesKHR( + 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) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueAcquireDX9MediaSurfacesKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} + +CL_API_ENTRY cl_int CL_API_CALL +clEnqueueReleaseDX9MediaSurfacesKHR( + cl_command_queue command_queue, + cl_uint num_objects, + cl_mem * mem_objects, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return command_queue->dispatch->clEnqueueReleaseDX9MediaSurfacesKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} + +#endif + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); + return event->dispatch->clSetEventCallback( + event, + command_exec_callback_type, + pfn_notify, + user_data); +} + +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 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(buffer, CL_INVALID_MEM_OBJECT); + return buffer->dispatch->clCreateSubBuffer( + buffer, + flags, + buffer_create_type, + buffer_create_info, + errcode_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clSetMemObjectDestructorCallback( + cl_mem memobj, + void (CL_CALLBACK * pfn_notify)( cl_mem, void*), + void * user_data ) CL_API_SUFFIX__VERSION_1_1 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); + return memobj->dispatch->clSetMemObjectDestructorCallback( + memobj, + pfn_notify, + user_data); +} + +CL_API_ENTRY cl_event CL_API_CALL +clCreateUserEvent( + cl_context context, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_1 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return context->dispatch->clCreateUserEvent( + context, + errcode_ret); +} + +CL_API_ENTRY cl_int CL_API_CALL +clSetUserEventStatus( + cl_event event, + cl_int execution_status) CL_API_SUFFIX__VERSION_1_1 +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); + return event->dispatch->clSetUserEventStatus( + event, + execution_status); +} + diff --git a/khronos_icd/icd_dispatch.h b/khronos_icd/icd_dispatch.h new file mode 100644 index 000000000..0d14fd08c --- /dev/null +++ b/khronos_icd/icd_dispatch.h @@ -0,0 +1,1283 @@ +/* + * Copyright (c) 2012 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 use, copy, modify and compile the Materials to create a binary under the + * following terms and conditions: + * + * 1. The Materials shall NOT be distributed to any third party; + * + * 2. The binary may be distributed without restriction, including without + * limitation the rights to use, copy, merge, publish, distribute, sublicense, + * and/or sell copies, and to permit persons to whom the binary is furnished to + * do so; + * + * 3. 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; + * + * 4. 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/; + * + * 5. The above copyright notice 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. + */ + +#ifndef _ICD_DISPATCH_H_ +#define _ICD_DISPATCH_H_ + +#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 + +// cl.h +#include + +// cl_gl.h and required files +#ifdef _WIN32 +#include +#include +#include +#include +#include +#include +#endif +#include +#include +#include +#include + +/* + * + * function pointer typedefs + * + */ + +// Platform APIs +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetPlatformIDs)( + cl_uint num_entries, + cl_platform_id * platforms, + cl_uint * num_platforms) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +// Device APIs +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clCreateSubDevices)( + cl_device_id in_device, + const cl_device_partition_property * partition_properties, + cl_uint num_entries, + cl_device_id * out_devices, + cl_uint * num_devices); + +typedef CL_API_ENTRY cl_int (CL_API_CALL * KHRpfn_clRetainDevice)( + cl_device_id device) CL_API_SUFFIX__VERSION_1_2; + +typedef CL_API_ENTRY cl_int (CL_API_CALL * KHRpfn_clReleaseDevice)( + cl_device_id device) CL_API_SUFFIX__VERSION_1_2; + +// Context APIs +typedef CL_API_ENTRY cl_context (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_context (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clRetainContext)( + cl_context context) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clReleaseContext)( + cl_context context) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +// Command Queue APIs +typedef CL_API_ENTRY cl_command_queue (CL_API_CALL *KHRpfn_clCreateCommandQueue)( + cl_context context, + cl_device_id device, + cl_command_queue_properties properties, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clRetainCommandQueue)( + cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clReleaseCommandQueue)( + cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +// Memory Object APIs +typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateBuffer)( + cl_context context, + cl_mem_flags flags, + size_t size, + void * host_ptr, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clRetainMemObject)(cl_mem memobj) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clReleaseMemObject)(cl_mem memobj) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +// Sampler APIs +typedef CL_API_ENTRY cl_sampler (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clRetainSampler)(cl_sampler sampler) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clReleaseSampler)(cl_sampler sampler) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +// Program Object APIs +typedef CL_API_ENTRY cl_program (CL_API_CALL *KHRpfn_clCreateProgramWithSource)( + cl_context context, + cl_uint count, + const char ** strings, + const size_t * lengths, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_program (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_program (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clRetainProgram)(cl_program program) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clReleaseProgram)(cl_program program) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_program (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clUnloadPlatformCompiler)( + cl_platform_id platform) CL_API_SUFFIX__VERSION_1_2; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +// Kernel Object APIs +typedef CL_API_ENTRY cl_kernel (CL_API_CALL *KHRpfn_clCreateKernel)( + cl_program program, + const char * kernel_name, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clCreateKernelsInProgram)( + cl_program program, + cl_uint num_kernels, + cl_kernel * kernels, + cl_uint * num_kernels_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clRetainKernel)(cl_kernel kernel) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clReleaseKernel)(cl_kernel kernel) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clSetKernelArg)( + cl_kernel kernel, + cl_uint arg_index, + size_t arg_size, + const void * arg_value) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +// Event Object APIs +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clWaitForEvents)( + cl_uint num_events, + const cl_event * event_list) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clRetainEvent)(cl_event event) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clReleaseEvent)(cl_event event) CL_API_SUFFIX__VERSION_1_0; + +// Profiling APIs +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +// Flush and Finish APIs +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clFlush)(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clFinish)(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0; + +// Enqueued Commands APIs +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueWriteBufferRect)( + 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, + 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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueFillImage)( + cl_command_queue command_queue, + cl_mem image, + const void * fill_color, + const size_t origin[3], + const size_t region[3], + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_2; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY void * (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY void * (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY void * (CL_API_CALL *KHRpfn_clGetExtensionFunctionAddressForPlatform)( + cl_platform_id platform, + const char * function_name) CL_API_SUFFIX__VERSION_1_2; + +// Deprecated APIs +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_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_EXT_SUFFIX__VERSION_1_1_DEPRECATED; + +typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_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_EXT_SUFFIX__VERSION_1_1_DEPRECATED; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clUnloadCompiler)(void) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueMarker)( + cl_command_queue command_queue, + cl_event * event) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueWaitForEvents)( + cl_command_queue command_queue, + cl_uint num_events, + const cl_event * event_list) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueBarrier)(cl_command_queue command_queue) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; + +typedef CL_API_ENTRY void * (CL_API_CALL *KHRpfn_clGetExtensionFunctionAddress)(const char *function_name) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; + +// GL and other APIs +typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromGLBuffer)( + cl_context context, + cl_mem_flags flags, + GLuint bufobj, + int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_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; + +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_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_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_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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_khr_gl_sharing */ +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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_khr_gl_event */ +typedef CL_API_ENTRY cl_event (CL_API_CALL *KHRpfn_clCreateEventFromGLsyncKHR)( + cl_context context, + cl_GLsync sync, + cl_int *errcode_ret); + + +#if defined(_WIN32) + +/* cl_khr_d3d10_sharing */ + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetDeviceIDsFromD3D10KHR)( + 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) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromD3D10BufferKHR)( + cl_context context, + cl_mem_flags flags, + ID3D10Buffer * resource, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromD3D10Texture2DKHR)( + cl_context context, + cl_mem_flags flags, + ID3D10Texture2D * resource, + UINT subresource, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromD3D10Texture3DKHR)( + cl_context context, + cl_mem_flags flags, + ID3D10Texture3D * resource, + UINT subresource, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueAcquireD3D10ObjectsKHR)( + 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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueReleaseD3D10ObjectsKHR)( + 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; + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetDeviceIDsFromD3D10KHR( + 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); + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromD3D10BufferKHR( + cl_context context, + cl_mem_flags flags, + ID3D10Buffer *resource, + cl_int *errcode_ret); + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromD3D10Texture2DKHR( + cl_context context, + cl_mem_flags flags, + ID3D10Texture2D * resource, + UINT subresource, + cl_int * errcode_ret); + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromD3D10Texture3DKHR( + cl_context context, + cl_mem_flags flags, + ID3D10Texture3D *resource, + UINT subresource, + cl_int *errcode_ret); + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueAcquireD3D10ObjectsKHR( + 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); + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueReleaseD3D10ObjectsKHR( + 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_khr_d3d11_sharing */ +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetDeviceIDsFromD3D11KHR)( + cl_platform_id platform, + cl_d3d11_device_source_khr d3d_device_source, + void * d3d_object, + cl_d3d11_device_set_khr d3d_device_set, + cl_uint num_entries, + cl_device_id * devices, + cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_2; + +typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromD3D11BufferKHR)( + cl_context context, + cl_mem_flags flags, + ID3D11Buffer * resource, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; + +typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromD3D11Texture2DKHR)( + cl_context context, + cl_mem_flags flags, + ID3D11Texture2D * resource, + UINT subresource, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; + +typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromD3D11Texture3DKHR)( + cl_context context, + cl_mem_flags flags, + ID3D11Texture3D * resource, + UINT subresource, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueAcquireD3D11ObjectsKHR)( + 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_2; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueReleaseD3D11ObjectsKHR)( + 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_2; + +/* cl_khr_dx9_media_sharing */ +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetDeviceIDsFromDX9MediaAdapterKHR)( + cl_platform_id platform, + cl_uint num_media_adapters, + cl_dx9_media_adapter_type_khr * media_adapters_type, + void * media_adapters, + cl_dx9_media_adapter_set_khr media_adapter_set, + cl_uint num_entries, + cl_device_id * devices, + cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_2; + +typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromDX9MediaSurfaceKHR)( + cl_context context, + cl_mem_flags flags, + cl_dx9_media_adapter_type_khr adapter_type, + void * surface_info, + cl_uint plane, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueAcquireDX9MediaSurfacesKHR)( + 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_2; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueReleaseDX9MediaSurfacesKHR)( + cl_command_queue command_queue, + cl_uint num_objects, + 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_2; + +/* cl_khr_d3d11_sharing */ +extern CL_API_ENTRY cl_int CL_API_CALL +clGetDeviceIDsFromD3D11KHR( + cl_platform_id platform, + cl_d3d11_device_source_khr d3d_device_source, + void * d3d_object, + cl_d3d11_device_set_khr d3d_device_set, + cl_uint num_entries, + cl_device_id * devices, + cl_uint * num_devices); + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromD3D11BufferKHR( + cl_context context, + cl_mem_flags flags, + ID3D11Buffer * resource, + cl_int * errcode_ret); + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromD3D11Texture2DKHR( + cl_context context, + cl_mem_flags flags, + ID3D11Texture2D * resource, + UINT subresource, + cl_int * errcode_ret); + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromD3D11Texture3DKHR( + cl_context context, + cl_mem_flags flags, + ID3D11Texture3D * resource, + UINT subresource, + cl_int * errcode_ret); + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueAcquireD3D11ObjectsKHR( + 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); + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueReleaseD3D11ObjectsKHR( + 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_khr_dx9_media_sharing */ +extern CL_API_ENTRY cl_int CL_API_CALL +clGetDeviceIDsFromDX9MediaAdapterKHR( + cl_platform_id platform, + cl_uint num_media_adapters, + cl_dx9_media_adapter_type_khr * media_adapter_type, + void * media_adapters, + cl_dx9_media_adapter_set_khr media_adapter_set, + cl_uint num_entries, + cl_device_id * devices, + cl_uint * num_devices); + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromDX9MediaSurfaceKHR( + cl_context context, + cl_mem_flags flags, + cl_dx9_media_adapter_type_khr adapter_type, + void * surface_info, + cl_uint plane, + cl_int * errcode_ret); + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueAcquireDX9MediaSurfacesKHR( + 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); + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueReleaseDX9MediaSurfacesKHR( + cl_command_queue command_queue, + cl_uint num_objects, + cl_mem * mem_objects, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event); + +#else + +/* cl_khr_d3d10_sharing */ +typedef void *KHRpfn_clGetDeviceIDsFromD3D10KHR; +typedef void *KHRpfn_clCreateFromD3D10BufferKHR; +typedef void *KHRpfn_clCreateFromD3D10Texture2DKHR; +typedef void *KHRpfn_clCreateFromD3D10Texture3DKHR; +typedef void *KHRpfn_clEnqueueAcquireD3D10ObjectsKHR; +typedef void *KHRpfn_clEnqueueReleaseD3D10ObjectsKHR; + +/* cl_khr_d3d11_sharing */ +typedef void *KHRpfn_clGetDeviceIDsFromD3D11KHR; +typedef void *KHRpfn_clCreateFromD3D11BufferKHR; +typedef void *KHRpfn_clCreateFromD3D11Texture2DKHR; +typedef void *KHRpfn_clCreateFromD3D11Texture3DKHR; +typedef void *KHRpfn_clEnqueueAcquireD3D11ObjectsKHR; +typedef void *KHRpfn_clEnqueueReleaseD3D11ObjectsKHR; + +/* cl_khr_dx9_media_sharing */ +typedef void *KHRpfn_clCreateFromDX9MediaSurfaceKHR; +typedef void *KHRpfn_clEnqueueAcquireDX9MediaSurfacesKHR; +typedef void *KHRpfn_clEnqueueReleaseDX9MediaSurfacesKHR; +typedef void *KHRpfn_clGetDeviceIDsFromDX9MediaAdapterKHR; + +#endif + +/* OpenCL 1.1 */ + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_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; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clSetMemObjectDestructorCallback)( + cl_mem /* memobj */, + void (CL_CALLBACK * /*pfn_notify*/)( cl_mem /* memobj */, void* /*user_data*/), + void * /*user_data */ ) CL_API_SUFFIX__VERSION_1_1; + +typedef CL_API_ENTRY cl_event (CL_API_CALL *KHRpfn_clCreateUserEvent)( + cl_context /* context */, + cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_1; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clSetUserEventStatus)( + cl_event /* event */, + cl_int /* execution_status */) CL_API_SUFFIX__VERSION_1_1; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clCreateSubDevicesEXT)( + cl_device_id in_device, + const cl_device_partition_property_ext * partition_properties, + cl_uint num_entries, + cl_device_id * out_devices, + cl_uint * num_devices); + +typedef CL_API_ENTRY cl_int (CL_API_CALL * KHRpfn_clRetainDeviceEXT)( + cl_device_id device) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL * KHRpfn_clReleaseDeviceEXT)( + cl_device_id device) CL_API_SUFFIX__VERSION_1_0; + +/* + * + * vendor dispatch table structure + * + * note that the types in the structure KHRicdVendorDispatch mirror the function + * names listed in the string table khrIcdVendorDispatchFunctionNames + * + */ + +typedef struct KHRicdVendorDispatchRec KHRicdVendorDispatch; + +struct KHRicdVendorDispatchRec +{ + KHRpfn_clGetPlatformIDs clGetPlatformIDs; + KHRpfn_clGetPlatformInfo clGetPlatformInfo; + KHRpfn_clGetDeviceIDs clGetDeviceIDs; + KHRpfn_clGetDeviceInfo clGetDeviceInfo; + KHRpfn_clCreateContext clCreateContext; + KHRpfn_clCreateContextFromType clCreateContextFromType; + KHRpfn_clRetainContext clRetainContext; + KHRpfn_clReleaseContext clReleaseContext; + KHRpfn_clGetContextInfo clGetContextInfo; + KHRpfn_clCreateCommandQueue clCreateCommandQueue; + KHRpfn_clRetainCommandQueue clRetainCommandQueue; + KHRpfn_clReleaseCommandQueue clReleaseCommandQueue; + KHRpfn_clGetCommandQueueInfo clGetCommandQueueInfo; + KHRpfn_clSetCommandQueueProperty clSetCommandQueueProperty; + KHRpfn_clCreateBuffer clCreateBuffer; + KHRpfn_clCreateImage2D clCreateImage2D; + KHRpfn_clCreateImage3D clCreateImage3D; + KHRpfn_clRetainMemObject clRetainMemObject; + KHRpfn_clReleaseMemObject clReleaseMemObject; + KHRpfn_clGetSupportedImageFormats clGetSupportedImageFormats; + KHRpfn_clGetMemObjectInfo clGetMemObjectInfo; + KHRpfn_clGetImageInfo clGetImageInfo; + KHRpfn_clCreateSampler clCreateSampler; + KHRpfn_clRetainSampler clRetainSampler; + KHRpfn_clReleaseSampler clReleaseSampler; + KHRpfn_clGetSamplerInfo clGetSamplerInfo; + KHRpfn_clCreateProgramWithSource clCreateProgramWithSource; + KHRpfn_clCreateProgramWithBinary clCreateProgramWithBinary; + KHRpfn_clRetainProgram clRetainProgram; + KHRpfn_clReleaseProgram clReleaseProgram; + KHRpfn_clBuildProgram clBuildProgram; + KHRpfn_clUnloadCompiler clUnloadCompiler; + KHRpfn_clGetProgramInfo clGetProgramInfo; + KHRpfn_clGetProgramBuildInfo clGetProgramBuildInfo; + KHRpfn_clCreateKernel clCreateKernel; + KHRpfn_clCreateKernelsInProgram clCreateKernelsInProgram; + KHRpfn_clRetainKernel clRetainKernel; + KHRpfn_clReleaseKernel clReleaseKernel; + KHRpfn_clSetKernelArg clSetKernelArg; + KHRpfn_clGetKernelInfo clGetKernelInfo; + KHRpfn_clGetKernelWorkGroupInfo clGetKernelWorkGroupInfo; + KHRpfn_clWaitForEvents clWaitForEvents; + KHRpfn_clGetEventInfo clGetEventInfo; + KHRpfn_clRetainEvent clRetainEvent; + KHRpfn_clReleaseEvent clReleaseEvent; + KHRpfn_clGetEventProfilingInfo clGetEventProfilingInfo; + KHRpfn_clFlush clFlush; + KHRpfn_clFinish clFinish; + KHRpfn_clEnqueueReadBuffer clEnqueueReadBuffer; + KHRpfn_clEnqueueWriteBuffer clEnqueueWriteBuffer; + KHRpfn_clEnqueueCopyBuffer clEnqueueCopyBuffer; + KHRpfn_clEnqueueReadImage clEnqueueReadImage; + KHRpfn_clEnqueueWriteImage clEnqueueWriteImage; + KHRpfn_clEnqueueCopyImage clEnqueueCopyImage; + KHRpfn_clEnqueueCopyImageToBuffer clEnqueueCopyImageToBuffer; + KHRpfn_clEnqueueCopyBufferToImage clEnqueueCopyBufferToImage; + KHRpfn_clEnqueueMapBuffer clEnqueueMapBuffer; + KHRpfn_clEnqueueMapImage clEnqueueMapImage; + KHRpfn_clEnqueueUnmapMemObject clEnqueueUnmapMemObject; + KHRpfn_clEnqueueNDRangeKernel clEnqueueNDRangeKernel; + KHRpfn_clEnqueueTask clEnqueueTask; + KHRpfn_clEnqueueNativeKernel clEnqueueNativeKernel; + KHRpfn_clEnqueueMarker clEnqueueMarker; + KHRpfn_clEnqueueWaitForEvents clEnqueueWaitForEvents; + KHRpfn_clEnqueueBarrier clEnqueueBarrier; + KHRpfn_clGetExtensionFunctionAddress clGetExtensionFunctionAddress; + KHRpfn_clCreateFromGLBuffer clCreateFromGLBuffer; + KHRpfn_clCreateFromGLTexture2D clCreateFromGLTexture2D; + KHRpfn_clCreateFromGLTexture3D clCreateFromGLTexture3D; + KHRpfn_clCreateFromGLRenderbuffer clCreateFromGLRenderbuffer; + KHRpfn_clGetGLObjectInfo clGetGLObjectInfo; + KHRpfn_clGetGLTextureInfo clGetGLTextureInfo; + KHRpfn_clEnqueueAcquireGLObjects clEnqueueAcquireGLObjects; + KHRpfn_clEnqueueReleaseGLObjects clEnqueueReleaseGLObjects; + KHRpfn_clGetGLContextInfoKHR clGetGLContextInfoKHR; + + KHRpfn_clGetDeviceIDsFromD3D10KHR clGetDeviceIDsFromD3D10KHR; + KHRpfn_clCreateFromD3D10BufferKHR clCreateFromD3D10BufferKHR; + KHRpfn_clCreateFromD3D10Texture2DKHR clCreateFromD3D10Texture2DKHR; + KHRpfn_clCreateFromD3D10Texture3DKHR clCreateFromD3D10Texture3DKHR; + KHRpfn_clEnqueueAcquireD3D10ObjectsKHR clEnqueueAcquireD3D10ObjectsKHR; + KHRpfn_clEnqueueReleaseD3D10ObjectsKHR clEnqueueReleaseD3D10ObjectsKHR; + + KHRpfn_clSetEventCallback clSetEventCallback; + KHRpfn_clCreateSubBuffer clCreateSubBuffer; + KHRpfn_clSetMemObjectDestructorCallback clSetMemObjectDestructorCallback; + KHRpfn_clCreateUserEvent clCreateUserEvent; + KHRpfn_clSetUserEventStatus clSetUserEventStatus; + KHRpfn_clEnqueueReadBufferRect clEnqueueReadBufferRect; + KHRpfn_clEnqueueWriteBufferRect clEnqueueWriteBufferRect; + KHRpfn_clEnqueueCopyBufferRect clEnqueueCopyBufferRect; + + KHRpfn_clCreateSubDevicesEXT clCreateSubDevicesEXT; + KHRpfn_clRetainDeviceEXT clRetainDeviceEXT; + KHRpfn_clReleaseDeviceEXT clReleaseDeviceEXT; + + KHRpfn_clCreateEventFromGLsyncKHR clCreateEventFromGLsyncKHR; + + KHRpfn_clCreateSubDevices clCreateSubDevices; + KHRpfn_clRetainDevice clRetainDevice; + KHRpfn_clReleaseDevice clReleaseDevice; + KHRpfn_clCreateImage clCreateImage; + KHRpfn_clCreateProgramWithBuiltInKernels clCreateProgramWithBuiltInKernels; + KHRpfn_clCompileProgram clCompileProgram; + KHRpfn_clLinkProgram clLinkProgram; + KHRpfn_clUnloadPlatformCompiler clUnloadPlatformCompiler; + KHRpfn_clGetKernelArgInfo clGetKernelArgInfo; + KHRpfn_clEnqueueFillBuffer clEnqueueFillBuffer; + KHRpfn_clEnqueueFillImage clEnqueueFillImage; + KHRpfn_clEnqueueMigrateMemObjects clEnqueueMigrateMemObjects; + KHRpfn_clEnqueueMarkerWithWaitList clEnqueueMarkerWithWaitList; + KHRpfn_clEnqueueBarrierWithWaitList clEnqueueBarrierWithWaitList; + KHRpfn_clGetExtensionFunctionAddressForPlatform clGetExtensionFunctionAddressForPlatform; + KHRpfn_clCreateFromGLTexture clCreateFromGLTexture; + + KHRpfn_clGetDeviceIDsFromD3D11KHR clGetDeviceIDsFromD3D11KHR; + KHRpfn_clCreateFromD3D11BufferKHR clCreateFromD3D11BufferKHR; + KHRpfn_clCreateFromD3D11Texture2DKHR clCreateFromD3D11Texture2DKHR; + KHRpfn_clCreateFromD3D11Texture3DKHR clCreateFromD3D11Texture3DKHR; + KHRpfn_clCreateFromDX9MediaSurfaceKHR clCreateFromDX9MediaSurfaceKHR; + KHRpfn_clEnqueueAcquireD3D11ObjectsKHR clEnqueueAcquireD3D11ObjectsKHR; + KHRpfn_clEnqueueReleaseD3D11ObjectsKHR clEnqueueReleaseD3D11ObjectsKHR; + + KHRpfn_clGetDeviceIDsFromDX9MediaAdapterKHR clGetDeviceIDsFromDX9MediaAdapterKHR; + KHRpfn_clEnqueueAcquireDX9MediaSurfacesKHR clEnqueueAcquireDX9MediaSurfacesKHR; + KHRpfn_clEnqueueReleaseDX9MediaSurfacesKHR clEnqueueReleaseDX9MediaSurfacesKHR; + +}; + +/* + * + * vendor dispatch table structure + * + */ + +struct _cl_platform_id +{ + KHRicdVendorDispatch *dispatch; +}; + +struct _cl_device_id +{ + KHRicdVendorDispatch *dispatch; +}; + +struct _cl_context +{ + KHRicdVendorDispatch *dispatch; +}; + +struct _cl_command_queue +{ + KHRicdVendorDispatch *dispatch; +}; + +struct _cl_mem +{ + KHRicdVendorDispatch *dispatch; +}; + +struct _cl_program +{ + KHRicdVendorDispatch *dispatch; +}; + +struct _cl_kernel +{ + KHRicdVendorDispatch *dispatch; +}; + +struct _cl_event +{ + KHRicdVendorDispatch *dispatch; +}; + +struct _cl_sampler +{ + KHRicdVendorDispatch *dispatch; +}; + +#endif // _ICD_DISPATCH_H_ + diff --git a/khronos_icd/icd_exports.map b/khronos_icd/icd_exports.map new file mode 100644 index 000000000..3d8a24ed7 --- /dev/null +++ b/khronos_icd/icd_exports.map @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2012 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 use, copy, modify and compile the Materials to create a binary under the + * following terms and conditions: + * + * 1. The Materials shall NOT be distributed to any third party; + * + * 2. The binary may be distributed without restriction, including without + * limitation the rights to use, copy, merge, publish, distribute, sublicense, + * and/or sell copies, and to permit persons to whom the binary is furnished to + * do so; + * + * 3. 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; + * + * 4. 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/; + * + * 5. The above copyright notice 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. + */ + +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; diff --git a/khronos_icd/icd_linux.c b/khronos_icd/icd_linux.c new file mode 100644 index 000000000..26b7df937 --- /dev/null +++ b/khronos_icd/icd_linux.c @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2012 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 use, copy, modify and compile the Materials to create a binary under the + * following terms and conditions: + * + * 1. The Materials shall NOT be distributed to any third party; + * + * 2. The binary may be distributed without restriction, including without + * limitation the rights to use, copy, merge, publish, distribute, sublicense, + * and/or sell copies, and to permit persons to whom the binary is furnished to + * do so; + * + * 3. 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; + * + * 4. 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/; + * + * 5. The above copyright notice 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 + +/* + * + * 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 = "/etc/OpenCL/vendors/"; + + // 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) + 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); + } +} + +/* + * + * 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/khronos_icd/icd_windows.c b/khronos_icd/icd_windows.c new file mode 100644 index 000000000..f30d4503c --- /dev/null +++ b/khronos_icd/icd_windows.c @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2012 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 use, copy, modify and compile the Materials to create a binary under the + * following terms and conditions: + * + * 1. The Materials shall NOT be distributed to any third party; + * + * 2. The binary may be distributed without restriction, including without + * limitation the rights to use, copy, merge, publish, distribute, sublicense, + * and/or sell copies, and to permit persons to whom the binary is furnished to + * do so; + * + * 3. 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; + * + * 4. 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/; + * + * 5. The above copyright notice 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 + +/* + * + * Vendor enumeration functions + * + */ + +// go through the list of vendors in the registry and call khrIcdVendorAdd +// for each vendor encountered +void khrIcdOsVendorsEnumerate() +{ + LONG result; + const char* platformsName = "SOFTWARE\\Khronos\\OpenCL\\Vendors"; + HKEY platformsKey = NULL; + DWORD dwIndex; + + 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; + } + + // 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); + } +} + +/* + * + * 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/khronos_icd/inc/README.txt b/khronos_icd/inc/README.txt new file mode 100644 index 000000000..cd635c13a --- /dev/null +++ b/khronos_icd/inc/README.txt @@ -0,0 +1,14 @@ +Copy OpenCL headers here, inside a directory named "CL", so that the inc folder +looks like this: + +inc/CL/cl_d3d10.h +inc/CL/cl_d3d11.h +inc/CL/cl_dx9_media_sharing.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/khronos_icd/test/CMakeLists.txt b/khronos_icd/test/CMakeLists.txt new file mode 100644 index 000000000..ed84476d9 --- /dev/null +++ b/khronos_icd/test/CMakeLists.txt @@ -0,0 +1,7 @@ +include_directories (./inc) + +add_subdirectory (platform) +add_subdirectory (driver_stub) +add_subdirectory (loader_test) + +add_test (OPENCL_ICD_LOADER_TEST ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/icd_loader_test) diff --git a/khronos_icd/test/Makefile b/khronos_icd/test/Makefile new file mode 100644 index 000000000..db52dc5cc --- /dev/null +++ b/khronos_icd/test/Makefile @@ -0,0 +1,18 @@ + +.PHONY: all platform driver_stub loader_test clean + +all: platform driver_stub loader_test + +platform: + ${MAKE} -C platform + +driver_stub: + ${MAKE} -C driver_stub + +loader_test: + ${MAKE} -C loader_test + +clean: + ${MAKE} -C platform clean + ${MAKE} -C driver_stub clean + ${MAKE} -C loader_test clean diff --git a/khronos_icd/test/driver_stub/CMakeLists.txt b/khronos_icd/test/driver_stub/CMakeLists.txt new file mode 100644 index 000000000..13048172f --- /dev/null +++ b/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 SHARED ${OPENCL_DRIVER_STUB_SOURCES}) + +target_link_libraries (OpenCLDriverStub IcdLog) diff --git a/khronos_icd/test/driver_stub/Makefile b/khronos_icd/test/driver_stub/Makefile new file mode 100644 index 000000000..dd79b51cd --- /dev/null +++ b/khronos_icd/test/driver_stub/Makefile @@ -0,0 +1,14 @@ +CC := gcc +CFLAGS := -I ../inc -I ../../ -fPIC -g -O0 + +OUTDIR := ../../bin + +${OUTDIR}/libOpenCLDriverStub.so: cl.c cl_ext.c cl_gl.c icd.c + ${CC} ${CFLAGS} -shared -Wl,-soname,$@ \ + -Wl,--version-script,icd_driver_exports.map \ + -o $@ $^ ${OUTDIR}/libIcdLog.so + +.PHONY: clean + +clean: + rm -f ${OUTDIR}/libOpenCLDriverStub.so diff --git a/khronos_icd/test/driver_stub/cl.c b/khronos_icd/test/driver_stub/cl.c new file mode 100644 index 000000000..f84074e4a --- /dev/null +++ b/khronos_icd/test/driver_stub/cl.c @@ -0,0 +1,1917 @@ +#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 result = CL_SUCCESS; + cl_int return_value = 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) { + return CL_INVALID_VALUE; + } + // 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: + /*test_icd_stub_log("Value returned: %d\n", + CL_INVALID_VALUE);*/ + return CL_INVALID_VALUE; + break; + } + + // make sure the buffer passed in is big enough for the result + returnStringLength = strlen(returnString)+1; + if (param_value_size && param_value_size < returnStringLength) { + /*test_icd_stub_log("Value returned: %d\n", + CL_INVALID_VALUE);*/ + return CL_INVALID_VALUE; + } + + // 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; + } + + /*test_icd_stub_log("Value returned: %d\n", + return_value);*/ + return return_value; +} + + +/* 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 return_value = CL_SUCCESS; + + if ((num_entries > 1 || num_entries < 0) && devices != NULL) { + return_value = CL_INVALID_VALUE; + } + else { + cl_device_id obj = (cl_device_id) malloc(sizeof(cl_device_id)); + obj->dispatch = dispatchTable; + *devices = obj; + } + if (num_devices) { + *num_devices = 1; + } + + 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", CL_SUCCESS); + return CL_SUCCESS; +} + + + +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); + + 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/khronos_icd/test/driver_stub/cl_ext.c b/khronos_icd/test/driver_stub/cl_ext.c new file mode 100644 index 000000000..ece0c591b --- /dev/null +++ b/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/khronos_icd/test/driver_stub/cl_gl.c b/khronos_icd/test/driver_stub/cl_gl.c new file mode 100644 index 000000000..3cc5cbb80 --- /dev/null +++ b/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/khronos_icd/test/driver_stub/driver_stub.def b/khronos_icd/test/driver_stub/driver_stub.def new file mode 100644 index 000000000..5b238e8e1 --- /dev/null +++ b/khronos_icd/test/driver_stub/driver_stub.def @@ -0,0 +1,3 @@ +EXPORTS +clGetExtensionFunctionAddress +clIcdGetPlatformIDsKHR diff --git a/khronos_icd/test/driver_stub/icd.c b/khronos_icd/test/driver_stub/icd.c new file mode 100644 index 000000000..e456e431a --- /dev/null +++ b/khronos_icd/test/driver_stub/icd.c @@ -0,0 +1,185 @@ +#include +#include +#include +#include +#include "icd_structs.h" + +#define CL_USE_DEPRECATED_OPENCL_1_1_APIS +#define CL_USE_DEPRECATED_OPENCL_1_0_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/khronos_icd/test/driver_stub/icd_driver_exports.map b/khronos_icd/test/driver_stub/icd_driver_exports.map new file mode 100644 index 000000000..c6386a26e --- /dev/null +++ b/khronos_icd/test/driver_stub/icd_driver_exports.map @@ -0,0 +1,8 @@ +{ + global: +clGetExtensionFunctionAddress; +clGetPlatformInfo; + + local: + *; +}; diff --git a/khronos_icd/test/driver_stub/icd_structs.h b/khronos_icd/test/driver_stub/icd_structs.h new file mode 100644 index 000000000..4b7e68b11 --- /dev/null +++ b/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/khronos_icd/test/driver_stub/rename_api.h b/khronos_icd/test/driver_stub/rename_api.h new file mode 100644 index 000000000..7d5130cec --- /dev/null +++ b/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/khronos_icd/test/inc/platform/icd_test_log.h b/khronos_icd/test/inc/platform/icd_test_log.h new file mode 100644 index 000000000..6db0bfe6a --- /dev/null +++ b/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/khronos_icd/test/loader_test/CMakeLists.txt b/khronos_icd/test/loader_test/CMakeLists.txt new file mode 100644 index 000000000..ddc675b42 --- /dev/null +++ b/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/khronos_icd/test/loader_test/Makefile b/khronos_icd/test/loader_test/Makefile new file mode 100644 index 000000000..4b0dfe33d --- /dev/null +++ b/khronos_icd/test/loader_test/Makefile @@ -0,0 +1,16 @@ +CC := gcc +CFLAGS := -I ../inc -I ../../ -g -O0 + +OUTDIR := ../../bin + +${OUTDIR}/icd_loader_test: main.c callbacks.c icd_test_match.c + +${OUTDIR}/icd_loader_test: test_buffer_object.c test_clgl.c test_cl_runtime.c test_create_calls.c test_image_objects.c + +${OUTDIR}/icd_loader_test: test_kernel.c test_platforms.c test_program_objects.c test_sampler_objects.c + ${CC} ${CFLAGS} ${OUTDIR}/libOpenCL.so -o $@ $^ ${OUTDIR}/libIcdLog.so + +.PHONY: clean + +clean: + rm -f ${OUTDIR}/icd_loader_test diff --git a/khronos_icd/test/loader_test/callbacks.c b/khronos_icd/test/loader_test/callbacks.c new file mode 100644 index 000000000..8e0b4934b --- /dev/null +++ b/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/khronos_icd/test/loader_test/icd_test_match.c b/khronos_icd/test/loader_test/icd_test_match.c new file mode 100644 index 000000000..a58bb5fcc --- /dev/null +++ b/khronos_icd/test/loader_test/icd_test_match.c @@ -0,0 +1,36 @@ +#include +#include +#include +#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/khronos_icd/test/loader_test/main.c b/khronos_icd/test/loader_test/main.c new file mode 100644 index 000000000..a933946fa --- /dev/null +++ b/khronos_icd/test/loader_test/main.c @@ -0,0 +1,47 @@ +#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 initialize_log(); +extern int test_icd_match(); + +extern int test_OpenGL_share(); +extern int test_Direct3D10_share(); + +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_Direct3D10_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/khronos_icd/test/loader_test/param_struct.h b/khronos_icd/test/loader_test/param_struct.h new file mode 100644 index 000000000..1e1aab619 --- /dev/null +++ b/khronos_icd/test/loader_test/param_struct.h @@ -0,0 +1,1115 @@ +#ifndef _PARAM_STRUCT_H_ +#define _PARAM_STRUCT_H_ + +#include +#include +#include + +#ifdef _WIN32 +#include /* Needed for gl.h */ +#endif +#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; + size_t 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; + 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; + GLenum texture_target; + GLint miplevel; + GLuint texture; + cl_int *errcode_ret; +}; + +struct clCreateFromGLTexture2D_st +{ + cl_context context; + cl_mem_flags flags; + GLenum texture_target; + GLint miplevel; + GLuint texture; + cl_int *errcode_ret; +}; + +struct clCreateFromGLTexture3D_st +{ + cl_context context; + cl_mem_flags flags; + GLenum texture_target; + GLint miplevel; + GLuint texture; + cl_int *errcode_ret; +}; + +#define NUM_ITEMS_clCreateFromGLRenderbuffer 1 + +struct clCreateFromGLRenderbuffer_st +{ + cl_context context; + cl_mem_flags flags; + 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; + 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/khronos_icd/test/loader_test/test_buffer_object.c b/khronos_icd/test/loader_test/test_buffer_object.c new file mode 100644 index 000000000..85a2178c6 --- /dev/null +++ b/khronos_icd/test/loader_test/test_buffer_object.c @@ -0,0 +1,461 @@ +#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); + +} + +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 + +#define CL_USE_DEPRECATED_OPENCL_1_0_APIS +#define CL_USE_DEPRECATED_OPENCL_1_1_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/khronos_icd/test/loader_test/test_image_objects.c b/khronos_icd/test/loader_test/test_image_objects.c new file mode 100644 index 000000000..0c47d1300 --- /dev/null +++ b/khronos_icd/test/loader_test/test_image_objects.c @@ -0,0 +1,362 @@ +#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; + } +} + +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; + } +} + +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); +} From c50f58e0a9174659b10ed5e769d5d9bcbbcc4899 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Tue, 14 Jul 2015 17:35:32 +0200 Subject: [PATCH 2/5] Make ICD compile with our out of source build --- khronos_icd/CMakeLists.txt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/khronos_icd/CMakeLists.txt b/khronos_icd/CMakeLists.txt index b0cbe58a3..f746d0759 100644 --- a/khronos_icd/CMakeLists.txt +++ b/khronos_icd/CMakeLists.txt @@ -1,9 +1,12 @@ cmake_minimum_required (VERSION 2.6) +cmake_policy(SET CMP0015 NEW) +set(CMAKE_AUTOMOC OFF) -project (OPENCL_ICD_LOADER) +aux_source_directory(. SRC_LIST) + +include_directories(BEFORE ..) -set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/bin) -set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/bin) +project (OPENCL_ICD_LOADER) set (OPENCL_ICD_LOADER_SOURCES icd.c icd_dispatch.c) @@ -22,7 +25,7 @@ add_library (OpenCL SHARED ${OPENCL_ICD_LOADER_SOURCES}) set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1") if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") - set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,../icd_exports.map") + set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,../../khronos_icd/icd_exports.map") endif () target_link_libraries (OpenCL ${CMAKE_DL_LIBS}) From 89dfa35f9e948da9de2db20dd480469c1e80e9d9 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Wed, 15 Jul 2015 10:43:14 +0200 Subject: [PATCH 3/5] Link to Khronos ICD instead of OpenCL --- exp/CMakeLists.txt | 2 +- khronos_icd/CMakeLists.txt | 8 ++++---- libethash-cl/CMakeLists.txt | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/exp/CMakeLists.txt b/exp/CMakeLists.txt index e6360317f..be7cec3d9 100644 --- a/exp/CMakeLists.txt +++ b/exp/CMakeLists.txt @@ -30,6 +30,6 @@ target_link_libraries(${EXECUTABLE} p2p) if (ETHASHCL) target_link_libraries(${EXECUTABLE} ethash-cl) target_link_libraries(${EXECUTABLE} ethash) - target_link_libraries(${EXECUTABLE} ${OpenCL_LIBRARIES}) + target_link_libraries(${EXECUTABLE} OpenCL_ICD) endif() install( TARGETS ${EXECUTABLE} DESTINATION bin) diff --git a/khronos_icd/CMakeLists.txt b/khronos_icd/CMakeLists.txt index f746d0759..9fc7ad2cd 100644 --- a/khronos_icd/CMakeLists.txt +++ b/khronos_icd/CMakeLists.txt @@ -21,14 +21,14 @@ endif () # OR copy OpenCL headers to ./inc/CL/ include_directories (./inc) -add_library (OpenCL SHARED ${OPENCL_ICD_LOADER_SOURCES}) -set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1") +add_library (OpenCL_ICD SHARED ${OPENCL_ICD_LOADER_SOURCES}) +set_target_properties (OpenCL_ICD PROPERTIES VERSION "1.2" SOVERSION "1") if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") - set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,../../khronos_icd/icd_exports.map") + set_target_properties (OpenCL_ICD PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,../../khronos_icd/icd_exports.map") endif () -target_link_libraries (OpenCL ${CMAKE_DL_LIBS}) +target_link_libraries (OpenCL_ICD ${CMAKE_DL_LIBS}) enable_testing() add_subdirectory (test) diff --git a/libethash-cl/CMakeLists.txt b/libethash-cl/CMakeLists.txt index 9dc45fcf5..8fa7c97f3 100644 --- a/libethash-cl/CMakeLists.txt +++ b/libethash-cl/CMakeLists.txt @@ -24,7 +24,7 @@ include_directories(${Boost_INCLUDE_DIRS}) include_directories(${OpenCL_INCLUDE_DIRS}) include_directories(..) add_library(${EXECUTABLE} ${SRC_LIST} ${HEADERS}) -TARGET_LINK_LIBRARIES(${EXECUTABLE} ${OpenCL_LIBRARIES} ethash) +TARGET_LINK_LIBRARIES(${EXECUTABLE} OpenCL_ICD ethash) install( TARGETS ${EXECUTABLE} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib ) install( FILES ${HEADERS} DESTINATION include/${EXECUTABLE} ) From abe869600b7653afb5346ea49ca2bf8620d5411b Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Wed, 15 Jul 2015 10:49:38 +0200 Subject: [PATCH 4/5] Query Platforms checks for special not found value This value is provided by the Khronos ICD --- libethash-cl/ethash_cl_miner.cpp | 62 +++++++++++++++----------------- 1 file changed, 28 insertions(+), 34 deletions(-) diff --git a/libethash-cl/ethash_cl_miner.cpp b/libethash-cl/ethash_cl_miner.cpp index 942819ba8..dc806be1b 100644 --- a/libethash-cl/ethash_cl_miner.cpp +++ b/libethash-cl/ethash_cl_miner.cpp @@ -78,16 +78,30 @@ ethash_cl_miner::~ethash_cl_miner() finish(); } +// Quite ugly. Saves us a lot of typing on these static functions +// since we can't keep the platforms vector in the class (static class/functions) +// +// LTODO: With a bit of general refactoring this could go away and platforms +// be queried only once and kept in the class. +#define ETHASHCL_GET_PLATFORMS(platforms_, failStmt_) \ + do { \ + try \ + { \ + cl::Platform::get(&platforms_); \ + } \ + catch (cl::Error const& err) \ + { \ + int errCode = err.err(); \ + if (errCode == CL_PLATFORM_NOT_FOUND_KHR) \ + ETHCL_LOG("No OpenCL platforms found"); \ + failStmt_; \ + } \ + } while(0) + string ethash_cl_miner::platform_info(unsigned _platformId, unsigned _deviceId) { vector platforms; - cl::Platform::get(&platforms); - if (platforms.empty()) - { - ETHCL_LOG("No OpenCL platforms found."); - return string(); - } - + ETHASHCL_GET_PLATFORMS(platforms, return string()); // get GPU device of the selected platform unsigned platform_num = min(_platformId, platforms.size() - 1); vector devices = getDevices(platforms, _platformId); @@ -119,19 +133,14 @@ std::vector ethash_cl_miner::getDevices(std::vector co unsigned ethash_cl_miner::getNumPlatforms() { vector platforms; - cl::Platform::get(&platforms); + ETHASHCL_GET_PLATFORMS(platforms, return 0); return platforms.size(); } unsigned ethash_cl_miner::getNumDevices(unsigned _platformId) { vector platforms; - cl::Platform::get(&platforms); - if (platforms.empty()) - { - ETHCL_LOG("No OpenCL platforms found."); - return 0; - } + ETHASHCL_GET_PLATFORMS(platforms, return 0); vector devices = getDevices(platforms, _platformId); if (devices.empty()) @@ -192,12 +201,7 @@ unsigned ethash_cl_miner::s_initialGlobalWorkSize = ethash_cl_miner::c_defaultGl bool ethash_cl_miner::searchForAllDevices(function _callback) { vector platforms; - cl::Platform::get(&platforms); - if (platforms.empty()) - { - ETHCL_LOG("No OpenCL platforms found."); - return false; - } + ETHASHCL_GET_PLATFORMS(platforms, return false); for (unsigned i = 0; i < platforms.size(); ++i) if (searchForAllDevices(i, _callback)) return true; @@ -208,7 +212,7 @@ bool ethash_cl_miner::searchForAllDevices(function _cal bool ethash_cl_miner::searchForAllDevices(unsigned _platformId, function _callback) { vector platforms; - cl::Platform::get(&platforms); + ETHASHCL_GET_PLATFORMS(platforms, return false); if (_platformId >= platforms.size()) return false; @@ -223,12 +227,7 @@ bool ethash_cl_miner::searchForAllDevices(unsigned _platformId, function _callback) { vector platforms; - cl::Platform::get(&platforms); - if (platforms.empty()) - { - ETHCL_LOG("No OpenCL platforms found."); - return; - } + ETHASHCL_GET_PLATFORMS(platforms, return); for (unsigned i = 0; i < platforms.size(); ++i) doForAllDevices(i, _callback); } @@ -236,7 +235,7 @@ void ethash_cl_miner::doForAllDevices(function _callbac void ethash_cl_miner::doForAllDevices(unsigned _platformId, function _callback) { vector platforms; - cl::Platform::get(&platforms); + ETHASHCL_GET_PLATFORMS(platforms, return); if (_platformId >= platforms.size()) return; @@ -275,12 +274,7 @@ bool ethash_cl_miner::init( try { vector platforms; - cl::Platform::get(&platforms); - if (platforms.empty()) - { - ETHCL_LOG("No OpenCL platforms found."); - return false; - } + ETHASHCL_GET_PLATFORMS(platforms, return false); // use selected platform _platformId = min(_platformId, platforms.size() - 1); From 04a58ea06c0f6321dd798f94db24f37ef5f70f50 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Wed, 15 Jul 2015 14:56:24 +0200 Subject: [PATCH 5/5] Add OpenCL include directories to ICD - Also make it PUBLIC in cmake so that all who link to it will also get the OpenCL headers --- ethminer/CMakeLists.txt | 3 --- exp/CMakeLists.txt | 3 --- khronos_icd/CMakeLists.txt | 1 + khronos_icd/test/platform/CMakeLists.txt | 1 + libethash-cl/CMakeLists.txt | 1 - libethcore/CMakeLists.txt | 4 ---- 6 files changed, 2 insertions(+), 11 deletions(-) diff --git a/ethminer/CMakeLists.txt b/ethminer/CMakeLists.txt index 90889ae12..c321f0e5d 100644 --- a/ethminer/CMakeLists.txt +++ b/ethminer/CMakeLists.txt @@ -9,9 +9,6 @@ if (JSONRPC) include_directories(BEFORE ${JSONCPP_INCLUDE_DIRS}) include_directories(${JSON_RPC_CPP_INCLUDE_DIRS}) endif() -if (ETHASHCL) - include_directories(${OpenCL_INCLUDE_DIRS}) -endif () set(EXECUTABLE ethminer) diff --git a/exp/CMakeLists.txt b/exp/CMakeLists.txt index be7cec3d9..41940beef 100644 --- a/exp/CMakeLists.txt +++ b/exp/CMakeLists.txt @@ -6,9 +6,6 @@ aux_source_directory(. SRC_LIST) include_directories(BEFORE ${JSONCPP_INCLUDE_DIRS}) include_directories(BEFORE ..) include_directories(${DB_INCLUDE_DIRS}) -if (ETHASHCL) - include_directories(${OpenCL_INCLUDE_DIRS}) -endif () set(EXECUTABLE exp) diff --git a/khronos_icd/CMakeLists.txt b/khronos_icd/CMakeLists.txt index 9fc7ad2cd..b71a7c433 100644 --- a/khronos_icd/CMakeLists.txt +++ b/khronos_icd/CMakeLists.txt @@ -29,6 +29,7 @@ if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") endif () target_link_libraries (OpenCL_ICD ${CMAKE_DL_LIBS}) +target_include_directories(OpenCL_ICD PUBLIC ${OpenCL_INCLUDE_DIR}) enable_testing() add_subdirectory (test) diff --git a/khronos_icd/test/platform/CMakeLists.txt b/khronos_icd/test/platform/CMakeLists.txt index b35ca9336..c8af58a76 100644 --- a/khronos_icd/test/platform/CMakeLists.txt +++ b/khronos_icd/test/platform/CMakeLists.txt @@ -1 +1,2 @@ add_library (IcdLog SHARED icd_test_log.c) +target_include_directories(IcdLog PUBLIC ${OpenCL_INCLUDE_DIR}) \ No newline at end of file diff --git a/libethash-cl/CMakeLists.txt b/libethash-cl/CMakeLists.txt index 8fa7c97f3..70f711a76 100644 --- a/libethash-cl/CMakeLists.txt +++ b/libethash-cl/CMakeLists.txt @@ -21,7 +21,6 @@ set(HEADERS ${OUR_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/ethash_cl_miner_kernel.h) include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${Boost_INCLUDE_DIRS}) -include_directories(${OpenCL_INCLUDE_DIRS}) include_directories(..) add_library(${EXECUTABLE} ${SRC_LIST} ${HEADERS}) TARGET_LINK_LIBRARIES(${EXECUTABLE} OpenCL_ICD ethash) diff --git a/libethcore/CMakeLists.txt b/libethcore/CMakeLists.txt index 4dd626642..73ea75c8c 100644 --- a/libethcore/CMakeLists.txt +++ b/libethcore/CMakeLists.txt @@ -12,10 +12,6 @@ aux_source_directory(. SRC_LIST) include_directories(BEFORE ..) include_directories(${Boost_INCLUDE_DIRS}) -if (ETHASHCL) - include_directories(${OpenCL_INCLUDE_DIRS}) -endif () - if (CPUID_FOUND) include_directories(${Cpuid_INCLUDE_DIRS}) endif ()