52 changed files with 11846 additions and 47 deletions
@ -0,0 +1,35 @@ |
|||
cmake_minimum_required (VERSION 2.6) |
|||
cmake_policy(SET CMP0015 NEW) |
|||
set(CMAKE_AUTOMOC OFF) |
|||
|
|||
aux_source_directory(. SRC_LIST) |
|||
|
|||
include_directories(BEFORE ..) |
|||
|
|||
project (OPENCL_ICD_LOADER) |
|||
|
|||
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_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_ICD PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,../../khronos_icd/icd_exports.map") |
|||
endif () |
|||
|
|||
target_link_libraries (OpenCL_ICD ${CMAKE_DL_LIBS}) |
|||
target_include_directories(OpenCL_ICD PUBLIC ${OpenCL_INCLUDE_DIR}) |
|||
|
|||
enable_testing() |
|||
add_subdirectory (test) |
@ -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. |
|||
|
@ -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} |
@ -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 |
@ -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 <windows.h> |
|||
|
|||
#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 |
|||
|
@ -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). |
|||
|
@ -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 .. |
|||
|
@ -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 <stdlib.h> |
|||
#include <string.h> |
|||
|
|||
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]; |
|||
} |
|||
} |
|||
} |
|||
|
@ -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 <CL/cl.h> |
|||
#include <CL/cl_ext.h> |
|||
|
|||
/*
|
|||
* 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 <stdio.h> |
|||
#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 |
|||
|
File diff suppressed because it is too large
File diff suppressed because it is too large
@ -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; |
@ -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 <dlfcn.h> |
|||
#include <stdio.h> |
|||
#include <string.h> |
|||
#include <stdlib.h> |
|||
#include <sys/types.h> |
|||
#include <dirent.h> |
|||
|
|||
/*
|
|||
* |
|||
* 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); |
|||
} |
|||
|
@ -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 <stdio.h> |
|||
#include <windows.h> |
|||
#include <winreg.h> |
|||
|
|||
/*
|
|||
* |
|||
* 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); |
|||
} |
|||
|
@ -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 |
|||
|
@ -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) |
@ -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 |
@ -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) |
@ -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 |
File diff suppressed because it is too large
@ -0,0 +1,35 @@ |
|||
#include <string.h> |
|||
|
|||
#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; |
|||
} |
|||
|
@ -0,0 +1,221 @@ |
|||
#include <CL/cl_gl.h> |
|||
#include <CL/cl_gl_ext.h> |
|||
#include <platform/icd_test_log.h> |
|||
|
|||
// 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; |
|||
} |
@ -0,0 +1,3 @@ |
|||
EXPORTS |
|||
clGetExtensionFunctionAddress |
|||
clIcdGetPlatformIDsKHR |
@ -0,0 +1,185 @@ |
|||
#include <stdio.h> |
|||
#include <string.h> |
|||
#include <stdlib.h> |
|||
#include <assert.h> |
|||
#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); |
|||
} |
@ -0,0 +1,8 @@ |
|||
{ |
|||
global: |
|||
clGetExtensionFunctionAddress; |
|||
clGetPlatformInfo; |
|||
|
|||
local: |
|||
*; |
|||
}; |
@ -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_ */ |
@ -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__ */ |
@ -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_ */ |
@ -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) |
@ -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 |
@ -0,0 +1,43 @@ |
|||
#include <CL/cl.h> |
|||
#include <stdio.h> |
|||
#include <platform/icd_test_log.h> |
|||
|
|||
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); |
|||
} |
@ -0,0 +1,36 @@ |
|||
#include <stdio.h> |
|||
#include <string.h> |
|||
#include <malloc.h> |
|||
#include <platform/icd_test_log.h> |
|||
|
|||
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; |
|||
} |
|||
|
@ -0,0 +1,47 @@ |
|||
#include<stdio.h> |
|||
#include<CL/cl.h> |
|||
#include<platform/icd_test_log.h> |
|||
#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; |
|||
} |
|||
} |
File diff suppressed because it is too large
@ -0,0 +1,461 @@ |
|||
#include <CL/cl.h> |
|||
#include "param_struct.h" |
|||
#include <platform/icd_test_log.h> |
|||
|
|||
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<NUM_ITEMS_clEnqueueReadBuffer; i++) { |
|||
test_clEnqueueReadBuffer(&clEnqueueReadBufferData[i]); |
|||
} |
|||
|
|||
for (i=0; i<NUM_ITEMS_clEnqueueWriteBuffer; i++) { |
|||
test_clEnqueueWriteBuffer(&clEnqueueWriteBufferData[i]); |
|||
} |
|||
|
|||
for (i=0; i<NUM_ITEMS_clEnqueueReadBufferRect; i++) { |
|||
test_clEnqueueReadBufferRect(&clEnqueueReadBufferRectData[i]); |
|||
} |
|||
|
|||
for (i=0; i<NUM_ITEMS_clEnqueueWriteBufferRect; i++) { |
|||
test_clEnqueueWriteBufferRect(&clEnqueueWriteBufferRectData[i]); |
|||
} |
|||
|
|||
for (i=0; i<NUM_ITEMS_clEnqueueFillBuffer; i++) { |
|||
test_clEnqueueFillBuffer(&clEnqueueFillBufferData[i]); |
|||
} |
|||
|
|||
for (i=0; i<NUM_ITEMS_clEnqueueCopyBuffer; i++) { |
|||
test_clEnqueueCopyBuffer(&clEnqueueCopyBufferData[i]); |
|||
} |
|||
|
|||
for (i=0; i<NUM_ITEMS_clEnqueueCopyBufferRect; i++) { |
|||
test_clEnqueueCopyBufferRect(&clEnqueueCopyBufferRectData[i]); |
|||
} |
|||
|
|||
for (i=0; i<NUM_ITEMS_clEnqueueMapBuffer; i++) { |
|||
test_clEnqueueMapBuffer(&clEnqueueMapBufferData[i]); |
|||
} |
|||
|
|||
for (i=0; i<NUM_ITEMS_clRetainMemObject; i++) { |
|||
test_clRetainMemObject(&clRetainMemObjectData[i]); |
|||
} |
|||
|
|||
for (i=0; i<NUM_ITEMS_clSetMemObjectDestructorCallback; i++) { |
|||
test_clSetMemObjectDestructorCallback(&clSetMemObjectDestructorCallbackData[i]); |
|||
} |
|||
|
|||
for (i=0; i<NUM_ITEMS_clEnqueueUnmapMemObject; i++) { |
|||
test_clEnqueueUnmapMemObject(&clEnqueueUnmapMemObjectData[i]); |
|||
} |
|||
|
|||
for (i=0; i<NUM_ITEMS_clGetMemObjectInfo; i++) { |
|||
test_clGetMemObjectInfo(&clGetMemObjectInfoData[i]); |
|||
} |
|||
|
|||
return 0; |
|||
} |
|||
|
@ -0,0 +1,64 @@ |
|||
#include <CL/cl.h> |
|||
#include "param_struct.h" |
|||
#include <platform/icd_test_log.h> |
|||
|
|||
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<NUM_ITEMS_clRetainCommandQueue; i++) { |
|||
test_clRetainCommandQueue(&clRetainCommandQueueData[i]); |
|||
} |
|||
|
|||
for (i=0; i<NUM_ITEMS_clGetCommandQueueInfo; i++) { |
|||
test_clGetCommandQueueInfo(&clGetCommandQueueInfoData[i]); |
|||
} |
|||
|
|||
return 0; |
|||
|
|||
} |
@ -0,0 +1,345 @@ |
|||
#define CL_USE_DEPRECATED_OPENCL_1_0_APIS |
|||
#define CL_USE_DEPRECATED_OPENCL_1_1_APIS |
|||
|
|||
#include <CL/cl.h> |
|||
#include <CL/cl_gl.h> |
|||
#include <CL/cl_gl_ext.h> |
|||
#include "param_struct.h" |
|||
#include <platform/icd_test_log.h> |
|||
|
|||
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<NUM_ITEMS_clCreateFromGLBuffer;i++) |
|||
test_clCreateFromGLBuffer(&clCreateFromGLBufferData[i]); |
|||
|
|||
for(i=0;i<NUM_ITEMS_clCreateFromGLTexture;i++) |
|||
test_clCreateFromGLTexture(&clCreateFromGLTextureData[i]); |
|||
|
|||
for(i=0;i<NUM_ITEMS_clCreateFromGLTexture2D;i++) |
|||
test_clCreateFromGLTexture2D(&clCreateFromGLTexture2DData[i]); |
|||
|
|||
for(i=0;i<NUM_ITEMS_clCreateFromGLTexture3D;i++) |
|||
test_clCreateFromGLTexture3D(&clCreateFromGLTexture3DData[i]); |
|||
|
|||
for(i=0;i<NUM_ITEMS_clCreateFromGLRenderbuffer;i++) |
|||
test_clCreateFromGLRenderbuffer(&clCreateFromGLRenderbufferData[i]); |
|||
|
|||
for(i=0;i<NUM_ITEMS_clGetGLObjectInfo;i++) |
|||
test_clGetGLObjectInfo(&clGetGLObjectInfoData[i]); |
|||
|
|||
for(i=0;i<NUM_ITEMS_clGetGLTextureInfo;i++) |
|||
test_clGetGLTextureInfo(&clGetGLTextureInfoData[i]); |
|||
|
|||
for(i=0;i<NUM_ITEMS_clEnqueueAcquireGLObjects;i++) |
|||
test_clEnqueueAcquireGLObjects(&clEnqueueAcquireGLObjectsData[i]); |
|||
|
|||
for(i=0;i<NUM_ITEMS_clEnqueueReleaseGLObjects;i++) |
|||
test_clEnqueueReleaseGLObjects(&clEnqueueReleaseGLObjectsData[i]); |
|||
|
|||
for(i=0;i<NUM_ITEMS_clCreateEventFromGLsyncKHR;i++) |
|||
test_clCreateEventFromGLsyncKHR(&clCreateEventFromGLsyncKHRData[i]); |
|||
|
|||
for(i=0;i<NUM_ITEMS_clGetGLContextInfoKHR;i++) |
|||
test_clGetGLContextInfoKHR(&clGetGLContextInfoKHRData[i]); |
|||
|
|||
return 0; |
|||
} |
@ -0,0 +1,767 @@ |
|||
#include <string.h> |
|||
|
|||
#define CL_USE_DEPRECATED_OPENCL_1_0_APIS |
|||
#define CL_USE_DEPRECATED_OPENCL_1_1_APIS |
|||
|
|||
#include <CL/cl.h> |
|||
#include "param_struct.h" |
|||
#include <platform/icd_test_log.h> |
|||
|
|||
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; |
|||
} |
|||
|
@ -0,0 +1,362 @@ |
|||
#include <CL/cl.h> |
|||
#include "param_struct.h" |
|||
#include <platform/icd_test_log.h> |
|||
|
|||
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<NUM_ITEMS_clGetSupportedImageFormats; i++) { |
|||
test_clGetSupportedImageFormats(&clGetSupportedImageFormatsData[i]); |
|||
} |
|||
|
|||
for (i = 0; i<NUM_ITEMS_clEnqueueCopyImageToBuffer; i++) { |
|||
test_clEnqueueCopyImageToBuffer(&clEnqueueCopyImageToBufferData[i]); |
|||
} |
|||
|
|||
for (i = 0; i<NUM_ITEMS_clEnqueueCopyBufferToImage; i++) { |
|||
test_clEnqueueCopyBufferToImage(&clEnqueueCopyBufferToImageData[i]); |
|||
} |
|||
|
|||
for (i = 0; i<NUM_ITEMS_clEnqueueMapImage; i++) { |
|||
test_clEnqueueMapImage(&clEnqueueMapImageData[i]); |
|||
} |
|||
|
|||
for (i = 0; i<NUM_ITEMS_clEnqueueReadImage; i++) { |
|||
test_clEnqueueReadImage(&clEnqueueReadImageData[i]); |
|||
} |
|||
|
|||
for (i = 0; i<NUM_ITEMS_clEnqueueWriteImage; i++) { |
|||
test_clEnqueueWriteImage(&clEnqueueWriteImageData[i]); |
|||
} |
|||
|
|||
for (i = 0; i<NUM_ITEMS_clEnqueueFillImage; i++) { |
|||
test_clEnqueueFillImage(&clEnqueueFillImageData[i]); |
|||
} |
|||
|
|||
for (i = 0; i<NUM_ITEMS_clEnqueueCopyImage; i++) { |
|||
test_clEnqueueCopyImage(&clEnqueueCopyImageData[i]); |
|||
} |
|||
|
|||
for (i = 0; i<NUM_ITEMS_clGetImageInfo; i++) { |
|||
test_clGetImageInfo(&clGetImageInfoData[i]); |
|||
} |
|||
|
|||
return 0; |
|||
|
|||
} |
@ -0,0 +1,596 @@ |
|||
#ifndef CL_USE_DEPRECATED_OPENCL_1_1_APIS |
|||
#define CL_USE_DEPRECATED_OPENCL_1_1_APIS |
|||
#endif |
|||
|
|||
#include <CL/cl.h> |
|||
#include "param_struct.h" |
|||
#include <platform/icd_test_log.h> |
|||
|
|||
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<NUM_ITEMS_clRetainKernel; i++) { |
|||
test_clRetainKernel(&clRetainKernelData[i]); |
|||
} |
|||
|
|||
for (i=0; i<NUM_ITEMS_clSetKernelArg; i++) { |
|||
test_clSetKernelArg(&clSetKernelArgData[i]); |
|||
} |
|||
|
|||
for (i=0; i<NUM_ITEMS_clGetKernelInfo; i++) { |
|||
test_clGetKernelInfo(&clGetKernelInfoData[i]); |
|||
} |
|||
|
|||
for (i=0; i<NUM_ITEMS_clGetKernelArgInfo; i++) { |
|||
test_clGetKernelArgInfo(&clGetKernelArgInfoData[i]); |
|||
} |
|||
|
|||
for (i=0; i<NUM_ITEMS_clGetKernelWorkGroupInfo; i++) { |
|||
test_clGetKernelWorkGroupInfo(&clGetKernelWorkGroupInfoData[i]); |
|||
} |
|||
|
|||
for (i=0; i<NUM_ITEMS_clEnqueueMigrateMemObjects; i++) { |
|||
test_clEnqueueMigrateMemObjects(&clEnqueueMigrateMemObjectsData[i]); |
|||
} |
|||
|
|||
for (i=0; i<NUM_ITEMS_clEnqueueNDRangeKernel; i++) { |
|||
test_clEnqueueNDRangeKernel(&clEnqueueNDRangeKernelData[i]); |
|||
} |
|||
|
|||
for (i=0; i<NUM_ITEMS_clEnqueueTask; i++) { |
|||
test_clEnqueueTask(&clEnqueueTaskData[i]); |
|||
} |
|||
|
|||
for (i=0; i<NUM_ITEMS_clEnqueueNativeKernel; i++) { |
|||
test_clEnqueueNativeKernel(&clEnqueueNativeKernelData[i]); |
|||
} |
|||
|
|||
for (i=0; i<NUM_ITEMS_clSetUserEventStatus; i++) { |
|||
test_clSetUserEventStatus(&clSetUserEventStatusData[i]); |
|||
} |
|||
|
|||
for (i=0; i<NUM_ITEMS_clWaitForEvents; i++) { |
|||
test_clWaitForEvents(&clWaitForEventsData[i]); |
|||
} |
|||
|
|||
for (i=0; i<NUM_ITEMS_clGetEventInfo; i++) { |
|||
test_clGetEventInfo(&clGetEventInfoData[i]); |
|||
} |
|||
|
|||
for (i=0; i<NUM_ITEMS_clSetEventCallback; i++) { |
|||
test_clSetEventCallback(&clSetEventCallbackData[i]); |
|||
} |
|||
|
|||
for (i=0; i<NUM_ITEMS_clRetainEvent; i++) { |
|||
test_clRetainEvent(&clRetainEventData[i]); |
|||
} |
|||
|
|||
for (i=0; i<NUM_ITEMS_clEnqueueMarker; i++) { |
|||
test_clEnqueueMarker(&clEnqueueMarkerData[i]); |
|||
} |
|||
|
|||
for (i=0; i<NUM_ITEMS_clEnqueueBarrier; i++) { |
|||
test_clEnqueueBarrier(&clEnqueueBarrierData[i]); |
|||
} |
|||
|
|||
for (i=0; i<NUM_ITEMS_clEnqueueMarkerWithWaitList; i++) { |
|||
test_clEnqueueMarkerWithWaitList(&clEnqueueMarkerWithWaitListData[i]); |
|||
} |
|||
|
|||
for (i=0; i<NUM_ITEMS_clEnqueueBarrierWithWaitList; i++) { |
|||
test_clEnqueueBarrierWithWaitList(&clEnqueueBarrierWithWaitListData[i]); |
|||
} |
|||
|
|||
for (i=0; i<NUM_ITEMS_clGetEventProfilingInfo; i++) { |
|||
test_clGetEventProfilingInfo(&clGetEventProfilingInfoData[i]); |
|||
} |
|||
|
|||
for (i=0; i<NUM_ITEMS_clFlush; i++) { |
|||
test_clFlush(&clFlushData[i]); |
|||
} |
|||
|
|||
for (i=0; i<NUM_ITEMS_clFinish; i++) { |
|||
test_clFinish(&clFinishData[i]); |
|||
} |
|||
|
|||
return 0; |
|||
} |
@ -0,0 +1,183 @@ |
|||
#include <CL/cl.h> |
|||
#include "param_struct.h" |
|||
#include <platform/icd_test_log.h> |
|||
|
|||
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<NUM_ITEMS_clRetainContext;i++) { |
|||
test_clRetainContext(&clRetainContextData[i]); |
|||
} |
|||
|
|||
for (i = 0;i<NUM_ITEMS_clGetContextInfo;i++) { |
|||
test_clGetContextInfo(&clGetContextInfoData[i]); |
|||
} |
|||
|
|||
#if 0 |
|||
for (i = 0;i<NUM_ITEMS_clGetPlatformInfo;i++) { |
|||
test_clGetPlatformInfo(&clGetPlatformInfoData[i]); |
|||
} |
|||
#endif |
|||
|
|||
for (i = 0;i<NUM_ITEMS_clGetDeviceInfo;i++) { |
|||
test_clGetDeviceInfo(&clGetDeviceInfoData[i]); |
|||
} |
|||
|
|||
for (i = 0;i<NUM_ITEMS_clCreateSubDevices;i++) { |
|||
test_clCreateSubDevices(&clCreateSubDevicesData[i]); |
|||
} |
|||
|
|||
for (i = 0;i<NUM_ITEMS_clRetainDevice;i++) { |
|||
test_clRetainDevice(&clRetainDeviceData[i]); |
|||
} |
|||
|
|||
return 0; |
|||
} |
@ -0,0 +1,260 @@ |
|||
#include <CL/cl.h> |
|||
#include "param_struct.h" |
|||
#include <platform/icd_test_log.h> |
|||
|
|||
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<NUM_ITEMS_clRetainProgram;i++) { |
|||
test_clRetainProgram(&clRetainProgramData[i]); |
|||
} |
|||
|
|||
for (i=0;i<NUM_ITEMS_clBuildProgram;i++) { |
|||
test_clBuildProgram(&clBuildProgramData[i]); |
|||
} |
|||
|
|||
for (i=0;i<NUM_ITEMS_clCompileProgram;i++) { |
|||
test_clCompileProgram(&clCompileProgramData[i]); |
|||
} |
|||
|
|||
for (i=0;i<NUM_ITEMS_clLinkProgram;i++) { |
|||
test_clLinkProgram(&clLinkProgramData[i]); |
|||
} |
|||
|
|||
for (i=0;i<NUM_ITEMS_clGetExtensionFunctionAddressForPlatform;i++) { |
|||
test_clGetExtensionFunctionAddressForPlatform(&clGetExtensionFunctionAddressForPlatformData[i]); |
|||
} |
|||
|
|||
for (i=0;i<NUM_ITEMS_clUnloadPlatformCompiler;i++) { |
|||
test_clUnloadPlatformCompiler(&clUnloadPlatformCompilerData[i]); |
|||
} |
|||
|
|||
for (i=0;i<NUM_ITEMS_clGetProgramInfo;i++) { |
|||
test_clGetProgramInfo(&clGetProgramInfoData[i]); |
|||
} |
|||
|
|||
for (i=0;i<NUM_ITEMS_clGetProgramBuildInfo;i++) { |
|||
test_clGetProgramBuildInfo(&clGetProgramBuildInfoData[i]); |
|||
} |
|||
|
|||
return 0; |
|||
|
|||
} |
|||
|
@ -0,0 +1,64 @@ |
|||
#include <CL/cl.h> |
|||
#include "param_struct.h" |
|||
#include <platform/icd_test_log.h> |
|||
|
|||
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<NUM_ITEMS_clRetainSampler;i++) { |
|||
test_clRetainSampler (&clRetainSamplerData[i]); |
|||
} |
|||
|
|||
for (i=0;i<NUM_ITEMS_clGetSamplerInfo;i++) { |
|||
test_clGetSamplerInfo(&clGetSamplerInfoData[i]); |
|||
} |
|||
|
|||
return 0; |
|||
} |
|||
|
@ -0,0 +1,2 @@ |
|||
add_library (IcdLog SHARED icd_test_log.c) |
|||
target_include_directories(IcdLog PUBLIC ${OpenCL_INCLUDE_DIR}) |
@ -0,0 +1,15 @@ |
|||
# Set this if system does not have OpenCL headers in standard include directory
|
|||
CL_HEADER_PATH := ../../ |
|||
|
|||
.PHONY: clean |
|||
|
|||
CFLAGS := -I${CL_HEADER_PATH} |
|||
CFLAGS += -fPIC |
|||
|
|||
OUTDIR := ../../bin |
|||
|
|||
${OUTDIR}/libIcdLog.so: icd_test_log.c |
|||
${CC} ${CFLAGS} -shared -Wl,-soname,libIcdLog.so -o $@ $^ |
|||
|
|||
clean: |
|||
rm -f ${OUTDIR}/libIcdLog.so |
@ -0,0 +1,98 @@ |
|||
#include<sys/stat.h> |
|||
#include<stdlib.h> |
|||
#include<stdio.h> |
|||
#include<stdarg.h> |
|||
#include<CL/cl.h> |
|||
#include<platform/icd_test_log.h> |
|||
|
|||
#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); |
|||
} |
Loading…
Reference in new issue