Giter VIP home page Giter VIP logo

opencl-icd-loader's Introduction

OpenCLTM ICD Loader

This repo contains the source code and tests for the Khronos official OpenCL ICD Loader.

CI Build Status

Windows Build Status Linux Build Status MacOS Build Status

Introduction

OpenCL defines an Installable Client Driver (ICD) mechanism to allow developers to build applications against an Installable Client Driver loader (ICD loader) rather than linking their applications against a specific OpenCL implementation. The ICD Loader is responsible for:

  • Exporting OpenCL API entry points
  • Enumerating OpenCL implementations
  • Forwarding OpenCL API calls to the correct implementation

This repo contains the source code and tests for the Khronos official OpenCL ICD Loader.

Note that this repo does not contain an OpenCL implementation (ICD). You will need to obtain and install an OpenCL implementation for your OpenCL device that supports the OpenCL ICD extension cl_khr_icd to run an application using the OpenCL ICD Loader.

The OpenCL Installable Client Driver extension (cl_khr_icd) is described in the OpenCL extensions specification, which may be found on the Khronos OpenCL Registry.

Build Instructions

While the ICD Loader can be built and installed in isolation, it is part of the OpenCL SDK. If looking for streamlined build experience and a complete development package, refer to the SDK build instructions instead of the following guide.

Dependencies

The OpenCL ICD Loader requires:

  • the OpenCL Headers.
    • It is recommended to install the headers via CMake, however a convenience shorthand is provided. Providing OPENCL_ICD_LOADER_HEADERS_DIR to CMake, one may specify the location of OpenCL Headers. By default, the OpenCL ICD Loader will look for OpenCL Headers in the inc directory.
  • The OpenCL ICD Loader uses CMake for its build system. If CMake is not provided by your build system or OS package manager, please consult the CMake website.

Example Build

For most Windows and Linux usages, the following steps are sufficient to build the OpenCL ICD Loader:

  1. Clone this repo and the OpenCL Headers:

     git clone https://github.com/KhronosGroup/OpenCL-ICD-Loader
     git clone https://github.com/KhronosGroup/OpenCL-Headers
    
  2. Install OpenCL Headers CMake package

     cmake -D CMAKE_INSTALL_PREFIX=./OpenCL-Headers/install -S ./OpenCL-Headers -B ./OpenCL-Headers/build 
     cmake --build ./OpenCL-Headers/build --target install
    
  3. Build and install OpenCL ICD Loader CMake package. (Note that CMAKE_PREFIX_PATH need to be an absolute path. Update as needed.)

     cmake -D CMAKE_PREFIX_PATH=/absolute/path/to/OpenCL-Headers/install -D CMAKE_INSTALL_PREFIX=./OpenCL-ICD-Loader/install -S ./OpenCL-ICD-Loader -B ./OpenCL-ICD-Loader/build 
     cmake --build ./OpenCL-ICD-Loader/build --target install
    

Notes:

  • For x64 Windows builds, you need to instruct the default Visual Studio generator by adding -A x64 to all your command-lines.

  • Some users may prefer to use a CMake GUI frontend, such as cmake-gui or ccmake, vs. the command-line CMake.

Example Use

Example CMake invocation

cmake -D CMAKE_PREFIX_PATH="/chosen/install/prefix/of/headers;/chosen/install/prefix/of/loader" /path/to/opencl/app

and sample CMakeLists.txt

cmake_minimum_required(VERSION 3.0)
cmake_policy(VERSION 3.0...3.18.4)
project(proj)
add_executable(app main.cpp)
find_package(OpenCLHeaders REQUIRED)
find_package(OpenCLICDLoader REQUIRED)
target_link_libraries(app PRIVATE OpenCL::Headers OpenCL::OpenCL)

OpenCL ICD Loader Tests

OpenCL ICD Loader Tests can be run using ctest from the build directory. CTest which is a companion to CMake. The OpenCL ICD Loader Tests can also be run directly by executing icd_loader_test[.exe] executable from the bin folder.

(Note that running the tests manually requires setting up it's env manually, by setting OCL_ICD_FILENAMES to the full path of libOpenCLDriverStub.so/OpenCLDriverStub.dll, something otherwise done by CTest.)

Registering ICDs

The method to installing an ICD is operating system dependent.

Registering an ICD on Linux

Install your ICD by creating a file with the full path to the library of your implementation in /etc/OpenCL/vendors for eg.:

echo full/path/to/libOpenCLDriverStub.so > /etc/OpenCL/vendors/test.icd

Registering an ICD on Windows

Install your ICD by adding a REG_DWORD value to the registry keys:

// For 32-bit operating systems, or 64-bit tests on a 64-bit operating system:
HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\OpenCL\Vendors

// For 32-bit tests on a 64-bit operating system:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Khronos\OpenCL\Vendors

// The name of the REG_DWORD value should be the full path to the library of your implementation, for eg.
// OpenCLDriverStub.dll, and the data for this value should be 0.

About Layers

Layers have been added as an experimental feature in the OpenCL ICD Loader. We do not expect the API or ABI to change significantly, but the OpenCL Working Group reserves the right to do so. The layer support can also be completely deactivated during configuration by using the ENABLE_OPENCL_LAYERS (ON by default) cmake variable:

cmake -DENABLE_OPENCL_LAYERS=OFF

For now, runtime configuration of layers is done using the OPENCL_LAYERS environment variable. A colon (Linux) or semicolon (Windows) list of layers to use can be provided through this environment variable.

We are looking for feedback.

Support

Please create a GitHub issue to report an issue or ask questions.

Contributing

Contributions to the OpenCL ICD Loader are welcomed and encouraged. You will be prompted with a one-time "click-through" CLA dialog as part of submitting your pull request or other contribution to GitHub.

Table of Debug Environment Variables

The following debug environment variables are available for use with the OpenCL ICD loader:

Environment Variable Behavior Example Format
OCL_ICD_FILENAMES Specifies a list of additional ICDs to load. The ICDs will be enumerated first, before any ICDs discovered via default mechanisms. export OCL_ICD_FILENAMES=libVendorA.so:libVendorB.so

set OCL_ICD_FILENAMES=vendor_a.dll;vendor_b.dll
OCL_ICD_VENDORS On Linux and Android, specifies a directory to scan for ICDs to enumerate in place of the default `/etc/OpenCL/vendors'. export OCL_ICD_VENDORS=/my/local/icd/search/path
OPENCL_LAYERS Specifies a list of layers to load. export OPENCL_LAYERS=libLayerA.so:libLayerB.so

set OPENCL_LAYERS=libLayerA.dll;libLayerB.dll
OPENCL_LAYER_PATH On Linux and Android, specifies a directory to scan for layers to enumerate in place of the default `/etc/OpenCL/layers'. export OPENCL_LAYER_PATH=/my/local/layers/search/path
OCL_ICD_ENABLE_TRACE Enable the trace mechanism export OCL_ICD_ENABLE_TRACE=True

set OCL_ICD_ENABLE_TRACE=True
true, T, 1 can also be used here.

opencl-icd-loader's People

Contributors

alycm avatar arturharasimiuk avatar bashbaug avatar cdai2 avatar cos-public avatar gmeeker avatar guoyejun avatar gwawiork avatar isilence avatar jenatali avatar jfpoole avatar johngladp avatar johnkesapidesarm avatar johnplate avatar jrprice avatar kbenzie avatar kepatil avatar kerilk avatar keryell avatar kpet avatar leonbrands avatar lmoriche avatar ltowarek avatar mathiasmagnus avatar mfep avatar nikhiljnv avatar ofirc avatar silvercamel avatar tpboudreau avatar yeah-its-gloria avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opencl-icd-loader's Issues

Add .clang-format

We should enable consistent and testable formatting with a .clang-format.

I'm not particularly picky on the chosen style, as long as we define one :)

Reduce Calls to khrIcdInitialize

I'm trying to figure out why the ICD loader is calling khrIcdInitialize in the places where it is, and if some of the calls can be eliminated.

For reference, the current list of OpenCL APIs that are calling khrIcdInitialize is:

  • clGetPlatformIDs
  • clGetPlatformInfo
  • clGetDeviceIDs
  • clCreateContext
  • clCreateContextFromType
  • clUnloadPlatformCompiler
  • clGetExtensionFunctionAddressForPlatform
  • clGetExtensionFunctionAddress
  • clGetGLContextInfoKHR

I believe the following APIs should be removed from the list, for the specified reasons:

  • clGetPlatformInfo: Requires a cl_platform_id, which must be obtained using clGetPlatformIDs.
  • clGetDeviceIDs: Also requires a cl_platform_id.
  • clCreateContext: Requires a cl_platform_id or a cl_device_id, which must be obtained using clGetPlatformIDs or clGetDeviceIDs.
  • clUnloadPlatformCompiler: Requires a cl_platform_id.
  • clGetExtensionFunctionAddressForPlatform: Requires a cl_platform_id.
  • clGetGLContextInfoKHR: This function is not exported by the ICD loader, so it must be retrieved using clGetExtensionFunctionAddress or clGetExtensionFunctionAddressForPlatform.

Can the list of APIs that call khrIcdInitialize be reduced to:

  • clGetPlatformIDs
  • clCreateContextFromType
  • clGetExtensionFunctionAddress

Environment Variable Support

There have been a few issues requesting support for various OpenCL ICD loader environment variables. For example:

We've seen similar requests on the Intel OpenCL forums, such as:

I know these issues have been closed in the past as "won't fix", but I believe we should reconsider this decision. Note that the Vulkan loader provides support for various environment variables:

I'd like to see OpenCL ICD loader environment variable support at least for loading ICDs from a location other than /etc/OpenCL/vendors, and for controlling debug output to help root-cause installation problems. Are there best practices from the Vulkan loader that we could apply to add similar functionality to the OpenCL ICD loader?

Runtime errors from wrong vendor library

Running OpenCL programs on a host that includes a Nvidia Tesla GPU as well as a Intel Xeon Phi sometimes leads to an error that looks like it originates from the wrong vendor library.

Specifically, executing a program on the Tesla GPU lead to an error expected from the Xeon Phi coprocessor. The error message included HARDWARE FAULT MIC (or something similar) in the name, which hints at the Xeon Phi, also named Many Integrated Core device and registered as mic under /dev.

Removing the Intel ICD from the /etc/OpenCL/vendors/ directory prevented the error from occurring again. However, this prevents dynamic device selection at runtime.

The host is a Linux server running CentOS with the latest available NVIDIA driver and the older Intel OpenCL driver that works for the Xeon Phi. The OpenCL library placed in /etc/lib64 is built from this repository and tested as described in the README.

Windows build doesn't work

NMAKE : fatal error U1077: '"C:\Program Files (x86)\CMake\bin\cmake.exe"' :
return code '0xffffffff'

Stop.

NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio
9.0\VC\BIN\nmake.exe"' : return code '0x2'

Stop.

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:3 (project)

-- Configuring incomplete, errors occurred!
See also "C:/Users/HyperNewbie/Desktop/OpenCL-ICD-Loader-master/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/HyperNewbie/Desktop/OpenCL-ICD-Loader-master/build/CMakeFiles/CMakeError.log".

C:\Users\HyperNewbie\Desktop\OpenCL-ICD-Loader-master\build>nmake

Microsoft (R) Program Maintenance Utility Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.

NMAKE : fatal error U1064: MAKEFILE not found and no target specified
Stop.

Some bugs encountered while building with VS 2017 64bit

  1. The file 'test/loader_test/test_create_calls.c' needs #include <stdlib.h>', needed by the 'malloc' function, otherwise 'write access violation' error is given.

  2. In the file 'test/driver_stub/cl.c', at line no. 510 for the function call 'test_icd_stub_log("clCreateImage2D(' the eighth parameter 'errcode_ret' is missing.

icd_exports path

When ICD-Loader is being used as subproject, CMAKE_SOURCE_DIR in CMakeLists.txt:25 is not producing the correct path to icd_exports.map.
I think that PROJECT_SOURCE_DIR is more suitable.

OpenCL-ICD-Loader for version 1.1

Hello,

we're trying to activate and use GPU vivante gc200 on imx6q board ARM 7 with linux 3.10.31 and distribution opensuse 13.1.

The GPU is opencl 1.1 EP enabled and we are looking for an libOpenCL.so.
OpenCL-ICD-Loader doesn't seem to support OpenCL 1.1., where can we find such a library?

make error

When I run "make" on Linux, it failed and output some errors like this, how can I fix it?

In file included from /home/zhendong404/git/OpenCL-ICD-Loader/icd.c:39:0:
/home/zhendong404/git/OpenCL-ICD-Loader/icd_dispatch.h:1239:37: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘CL_API_SUFFIX__VERSION_2_1’
cl_command_queue command_queue) CL_API_SUFFIX__VERSION_2_1;
^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/zhendong404/git/OpenCL-ICD-Loader/icd_dispatch.h:1245:27: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘CL_API_SUFFIX__VERSION_2_1’
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_2_1;
^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/zhendong404/git/OpenCL-ICD-Loader/icd_dispatch.h:1255:36: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘CL_API_SUFFIX__VERSION_2_1’
size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_2_1;
^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/zhendong404/git/OpenCL-ICD-Loader/icd_dispatch.h:1259:27: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘CL_API_SUFFIX__VERSION_2_1’
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_2_1;
^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/zhendong404/git/OpenCL-ICD-Loader/icd_dispatch.h:1269:23: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘CL_API_SUFFIX__VERSION_2_1’
cl_event * event) CL_API_SUFFIX__VERSION_2_1;
^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/zhendong404/git/OpenCL-ICD-Loader/icd_dispatch.h:1274:32: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘CL_API_SUFFIX__VERSION_2_1’
cl_ulong * host_timestamp) CL_API_SUFFIX__VERSION_2_1;
^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/zhendong404/git/OpenCL-ICD-Loader/icd_dispatch.h:1278:32: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘CL_API_SUFFIX__VERSION_2_1’
cl_ulong * host_timestamp) CL_API_SUFFIX__VERSION_2_1;
^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/zhendong404/git/OpenCL-ICD-Loader/icd_dispatch.h:1455:5: error: unknown type name ‘KHRpfn_clCloneKernel’
KHRpfn_clCloneKernel clCloneKernel;
^~~~~~~~~~~~~~~~~~~~
/home/zhendong404/git/OpenCL-ICD-Loader/icd_dispatch.h:1456:5: error: unknown type name ‘KHRpfn_clCreateProgramWithIL’
KHRpfn_clCreateProgramWithIL clCreateProgramWithIL;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/zhendong404/git/OpenCL-ICD-Loader/icd_dispatch.h:1457:5: error: unknown type name ‘KHRpfn_clEnqueueSVMMigrateMem’
KHRpfn_clEnqueueSVMMigrateMem clEnqueueSVMMigrateMem;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/zhendong404/git/OpenCL-ICD-Loader/icd_dispatch.h:1458:5: error: unknown type name ‘KHRpfn_clGetDeviceAndHostTimer’
KHRpfn_clGetDeviceAndHostTimer clGetDeviceAndHostTimer;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/zhendong404/git/OpenCL-ICD-Loader/icd_dispatch.h:1459:5: error: unknown type name ‘KHRpfn_clGetHostTimer’
KHRpfn_clGetHostTimer clGetHostTimer;
^~~~~~~~~~~~~~~~~~~~~
/home/zhendong404/git/OpenCL-ICD-Loader/icd_dispatch.h:1460:5: error: unknown type name ‘KHRpfn_clGetKernelSubGroupInfo’
KHRpfn_clGetKernelSubGroupInfo clGetKernelSubGroupInfo;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/zhendong404/git/OpenCL-ICD-Loader/icd_dispatch.h:1461:5: error: unknown type name ‘KHRpfn_clSetDefaultDeviceCommandQueue’
KHRpfn_clSetDefaultDeviceCommandQueue clSetDefaultDeviceCommandQueue;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Syntax error in icd_dispatch.h under GCC 5.5.0

Hi,

Building this project fails for me:

$ make
mkdir -p build && cd build && cmake ..
-- The C compiler identification is GNU 5.5.0
-- The CXX compiler identification is GNU 5.5.0
-- Check for working C compiler: /home/linuxbrew/.linuxbrew/bin/cc
-- Check for working C compiler: /home/linuxbrew/.linuxbrew/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /home/linuxbrew/.linuxbrew/bin/c++
-- Check for working CXX compiler: /home/linuxbrew/.linuxbrew/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/cec/phd/third_party/OpenCL-ICD-Loader/build
make -C build
make[1]: Entering directory '/home/cec/phd/third_party/OpenCL-ICD-Loader/build'
make[2]: Entering directory '/home/cec/phd/third_party/OpenCL-ICD-Loader/build'
make[3]: Entering directory '/home/cec/phd/third_party/OpenCL-ICD-Loader/build'
Scanning dependencies of target OpenCL
make[3]: Leaving directory '/home/cec/phd/third_party/OpenCL-ICD-Loader/build'
make[3]: Entering directory '/home/cec/phd/third_party/OpenCL-ICD-Loader/build'
[  4%] Building C object CMakeFiles/OpenCL.dir/icd.c.o
In file included from /home/cec/phd/third_party/OpenCL-ICD-Loader/icd.c:39:0:
/home/cec/phd/third_party/OpenCL-ICD-Loader/icd_dispatch.h:329:38: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'CL_API_SUFFIX__VERSION_2_2'
     const void*          spec_value) CL_API_SUFFIX__VERSION_2_2;
                                      ^
/home/cec/phd/third_party/OpenCL-ICD-Loader/icd_dispatch.h:334:37: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'CL_API_SUFFIX__VERSION_2_2'
     void *               user_data) CL_API_SUFFIX__VERSION_2_2;
                                     ^
In file included from /home/cec/phd/third_party/OpenCL-ICD-Loader/icd.c:39:0:
/home/cec/phd/third_party/OpenCL-ICD-Loader/icd_dispatch.h:1249:37: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'CL_API_SUFFIX__VERSION_2_1'
     cl_command_queue command_queue) CL_API_SUFFIX__VERSION_2_1;
                                     ^
/home/cec/phd/third_party/OpenCL-ICD-Loader/icd_dispatch.h:1255:27: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'CL_API_SUFFIX__VERSION_2_1'
     cl_int * errcode_ret) CL_API_SUFFIX__VERSION_2_1;
                           ^
/home/cec/phd/third_party/OpenCL-ICD-Loader/icd_dispatch.h:1265:36: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'CL_API_SUFFIX__VERSION_2_1'
     size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_2_1;
                                    ^
/home/cec/phd/third_party/OpenCL-ICD-Loader/icd_dispatch.h:1269:27: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'CL_API_SUFFIX__VERSION_2_1'
     cl_int * errcode_ret) CL_API_SUFFIX__VERSION_2_1;
                           ^
/home/cec/phd/third_party/OpenCL-ICD-Loader/icd_dispatch.h:1279:23: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'CL_API_SUFFIX__VERSION_2_1'
     cl_event * event) CL_API_SUFFIX__VERSION_2_1;
                       ^
/home/cec/phd/third_party/OpenCL-ICD-Loader/icd_dispatch.h:1284:32: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'CL_API_SUFFIX__VERSION_2_1'
     cl_ulong * host_timestamp) CL_API_SUFFIX__VERSION_2_1;
                                ^
/home/cec/phd/third_party/OpenCL-ICD-Loader/icd_dispatch.h:1288:32: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'CL_API_SUFFIX__VERSION_2_1'
     cl_ulong * host_timestamp) CL_API_SUFFIX__VERSION_2_1;
                                ^
/home/cec/phd/third_party/OpenCL-ICD-Loader/icd_dispatch.h:1465:5: error: unknown type name 'KHRpfn_clCloneKernel'
     KHRpfn_clCloneKernel                            clCloneKernel;
     ^
/home/cec/phd/third_party/OpenCL-ICD-Loader/icd_dispatch.h:1466:5: error: unknown type name 'KHRpfn_clCreateProgramWithIL'
     KHRpfn_clCreateProgramWithIL                    clCreateProgramWithIL;
     ^
/home/cec/phd/third_party/OpenCL-ICD-Loader/icd_dispatch.h:1467:5: error: unknown type name 'KHRpfn_clEnqueueSVMMigrateMem'
     KHRpfn_clEnqueueSVMMigrateMem                   clEnqueueSVMMigrateMem;
     ^
/home/cec/phd/third_party/OpenCL-ICD-Loader/icd_dispatch.h:1468:5: error: unknown type name 'KHRpfn_clGetDeviceAndHostTimer'
     KHRpfn_clGetDeviceAndHostTimer                  clGetDeviceAndHostTimer;
     ^
/home/cec/phd/third_party/OpenCL-ICD-Loader/icd_dispatch.h:1469:5: error: unknown type name 'KHRpfn_clGetHostTimer'
     KHRpfn_clGetHostTimer                           clGetHostTimer;
     ^
/home/cec/phd/third_party/OpenCL-ICD-Loader/icd_dispatch.h:1470:5: error: unknown type name 'KHRpfn_clGetKernelSubGroupInfo'
     KHRpfn_clGetKernelSubGroupInfo                  clGetKernelSubGroupInfo;
     ^
/home/cec/phd/third_party/OpenCL-ICD-Loader/icd_dispatch.h:1471:5: error: unknown type name 'KHRpfn_clSetDefaultDeviceCommandQueue'
     KHRpfn_clSetDefaultDeviceCommandQueue           clSetDefaultDeviceCommandQueue;
     ^
/home/cec/phd/third_party/OpenCL-ICD-Loader/icd_dispatch.h:1474:5: error: unknown type name 'KHRpfn_clSetProgramReleaseCallback'
     KHRpfn_clSetProgramReleaseCallback              clSetProgramReleaseCallback;
     ^
/home/cec/phd/third_party/OpenCL-ICD-Loader/icd_dispatch.h:1475:5: error: unknown type name 'KHRpfn_clSetProgramSpecializationConstant'
     KHRpfn_clSetProgramSpecializationConstant       clSetProgramSpecializationConstant;
     ^
CMakeFiles/OpenCL.dir/build.make:62: recipe for target 'CMakeFiles/OpenCL.dir/icd.c.o' failed
make[3]: *** [CMakeFiles/OpenCL.dir/icd.c.o] Error 1
make[3]: Leaving directory '/home/cec/phd/third_party/OpenCL-ICD-Loader/build'
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/OpenCL.dir/all' failed
make[2]: *** [CMakeFiles/OpenCL.dir/all] Error 2
make[2]: Leaving directory '/home/cec/phd/third_party/OpenCL-ICD-Loader/build'
Makefile:94: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/home/cec/phd/third_party/OpenCL-ICD-Loader/build'
Makefile:12: recipe for target 'do_build' failed
make: *** [do_build] Error 2

This is building under 16.04.4 LTS using Linuxbrew's GCC:

$ /home/linuxbrew/.linuxbrew/bin/gcc --version
gcc (Homebrew gcc 5.5.0_4) 5.5.0

Cheers,
Chris

How to build ICD with CMake?

I know this isn't the best place to ask a question like this, but I've not been able to find help on google, and there's nowhere else for me to ask

Following the steps in the readme, I'm building the ICD with cmake:

Clone this repo:
git clone https://github.com/KhronosGroup/OpenCL-ICD-Loader

Obtain the OpenCL Headers, if you are not planning to use system OpenCL headers. Headers may be obtained from the Khronos OpenCL Headers repository.

Create a build directory:
cd OpenCL-ICD-Loader
mkdir build
cd build

Invoke cmake to generate solution files, Makefiles, or files for other build systems.
cmake ..

I've done the above 4 steps with no issue so far, but then comes step 5:
"Build using the CMake-generated files."

I have no idea what this means to how to do it, can someone help?

P.S. I've looked in the build folder and nothing seems to be related to building the ICD, merely just source code or metadata

Error when building OpenCL ICD Loader using MinGW

Compilation of OpenCL ICD Loader using MinGW gcc fails. Compiler complains about missing InitOnceExecuteOnce function, then linker complains about missing dl lib. More details about this problem and workaround needed to get libOpenCL.a are in this thread on StackOverflow. Please fix this.

BTW, please also add some option to easily get static lib instead of shared one. I am going to link this lib with app used for computations on one of BOINC projects. It is easier to link everything statically and distribute single binary than having to provide additional libs.

Need ProductVersion string?

In the StringInfoFile Block in OpenCL.rc, there is a FileVersion string but no ProductVersion. Should there be a ProductVersion string? Some releases want to control the FileVersion, but leave the ProductVersion alone.

Disable testing when ICD Loader is included in other projects?

Currently, the ICD loader CMakefile unconditionally includes CTest, and enables tests based on BUILD_TESTING. This is great for the ICD loader project itself, but a little awkward when the ICD loader is included in other projects, especially when the other projects also include tests.

Should we disable ICD loader testing when the ICD loader is included in other projects?

I this this is as simple as changing this:

include (CTest)
if (BUILD_TESTING)

to this:

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
    include(CTest)
endif()
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)

More info here:

https://cliutils.gitlab.io/modern-cmake/chapters/testing.html

Support non-root user installs

It would be extremely useful if the ICD loader supported installing OpenCL implementations not as the root user on Unix-like systems.

For example, AMD's APP SDK implementation used to support an environment variable OPENCL_VENDOR_PATH (not sure if they still do?) which could be used to specify what directory to look for ICD files in, defaulting to /etc/OpenCL/vendors if this environment variable is not set.

I'm not sure what the equivalent behavior on Windows might look like.

hello, looks like something broke circa commit 47f05fad43621aa1637427d857d639d0ecfbb7cd

Hello.
Something broke within the last 10 days. It used to work.
Probably 47f05fa
Cross-compiling under ubuntu 18.04.3 for target Win10x64.

[14:17:54][DEBUG] Running 'ninja -j 4 ' in '/home/u/Desktop/_working/workdir/x86_64/OpenCL-ICD-Loader_git'
[1/4] Building CXX object CMakeFiles/OpenCL.dir/loader/windows/icd_windows_apppackage.cpp.obj
FAILED: CMakeFiles/OpenCL.dir/loader/windows/icd_windows_apppackage.cpp.obj 
/home/u/Desktop/_working/workdir/toolchain/x86_64-w64-mingw32/bin/x86_64-w64-mingw32-g++ --sysroot=/home/u/Desktop/_working/workdir/toolchain/x86_64-w64-mingw32  -DCL_TARGET_OPENCL_VERSION=220 -DOpenCL_EXPORTS -Iinc -I. -Iloader -O3  -fstack-protector-all  -D_FORTIFY_SOURCE=2 -O3 -DNDEBUG -MD -MT CMakeFiles/OpenCL.dir/loader/windows/icd_windows_apppackage.cpp.obj -MF CMakeFiles/OpenCL.dir/loader/windows/icd_windows_apppackage.cpp.obj.d -o CMakeFiles/OpenCL.dir/loader/windows/icd_windows_apppackage.cpp.obj -c loader/windows/icd_windows_apppackage.cpp
loader/windows/icd_windows_apppackage.cpp:27:10: fatal error: windows.management.deployment.h: No such file or directory
   27 | #include <windows.management.deployment.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
[2/4] Building C object CMakeFiles/OpenCL.dir/loader/windows/icd_windows_envvars.c.obj
[3/4] Building C object CMakeFiles/OpenCL.dir/loader/windows/icd_windows_hkr.c.obj
FAILED: CMakeFiles/OpenCL.dir/loader/windows/icd_windows_hkr.c.obj 
/home/u/Desktop/_working/workdir/toolchain/x86_64-w64-mingw32/bin/x86_64-w64-mingw32-gcc --sysroot=/home/u/Desktop/_working/workdir/toolchain/x86_64-w64-mingw32 -DCL_TARGET_OPENCL_VERSION=220 -DOpenCL_EXPORTS -Iinc -I. -Iloader -O3  -fstack-protector-all  -D_FORTIFY_SOURCE=2 -O3 -DNDEBUG -MD -MT CMakeFiles/OpenCL.dir/loader/windows/icd_windows_hkr.c.obj -MF CMakeFiles/OpenCL.dir/loader/windows/icd_windows_hkr.c.obj.d -o CMakeFiles/OpenCL.dir/loader/windows/icd_windows_hkr.c.obj   -c loader/windows/icd_windows_hkr.c
loader/windows/icd_windows_hkr.c: In function 'khrIcdOsVendorsEnumerateHKR':
loader/windows/icd_windows_hkr.c:217:21: error: 'CM_GETIDLIST_FILTER_CLASS' undeclared (first use in this function); did you mean 'CM_GETIDLIST_FILTER_BITS'?
  217 |     ULONG ulFlags = CM_GETIDLIST_FILTER_CLASS |
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~
      |                     CM_GETIDLIST_FILTER_BITS
loader/windows/icd_windows_hkr.c:217:21: note: each undeclared identifier is reported only once for each function it appears in
loader/windows/icd_windows_hkr.c:218:21: error: 'CM_GETIDLIST_FILTER_PRESENT' undeclared (first use in this function); did you mean 'CM_GETIDLIST_FILTER_BITS'?
  218 |                     CM_GETIDLIST_FILTER_PRESENT;
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                     CM_GETIDLIST_FILTER_BITS
loader/windows/icd_windows_hkr.c:343:22: error: 'DEVPKEY_Device_ClassGuid' undeclared (first use in this function)
  343 |                     &DEVPKEY_Device_ClassGuid,
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~
ninja: build stopped: subcommand failed.

compile error file missing

/home/user/Desktop/OpenCL-ICD-Loader/icd.h:53:10: fatal error: CL/cl.h: No such file or directory
#include <CL/cl.h>
^~~~~~~~~

Building with 2.0 Headers

Hey all,
I need to compile the ICD Loader / OpenCL libraries using 2.0 headers. When I do it, the compiler complains about not finding "CL_API_SUFFIX__VERSION_2_2" for the dispatcher. Is there any compiler flag / define, that I can use to exclude 2.2 and 2.1 features? The sources for the 2.0 ICD Loader, would also help. Can they be found somewhere on the Web? Going back in the commits of this project, I only get to Version 2.1. I also found this Open Source project: https://github.com/OCL-dev/ocl-icd, but it would be nice to have a clean Khronos solution.

Thanks,
Siggy

won't build any more after commit "Added OpenCL Universal Driver Support for Win10 RS3"

I cross-compile this under ubuntu to run under Windows 10.

Until this commit "Added OpenCL Universal Driver Support for Win10 RS3" it used to work fine using this script:

  do_git_checkout https://github.com/KhronosGroup/OpenCL-Headers.git OpenCL-Headers
  cd OpenCL-Headers || exit 1 
    mkdir -pv "${mingw_w64_x86_64_prefix}/include/CL"  
    mkdir -pv "${mingw_w64_x86_64_prefix}/include/OpenCL"
    cd opencl22/CL  || exit 1 # nvidia is v1.2 as at 2017.05.28 but the ICD loader requires latest
	   cp -fv *.h "$mingw_w64_x86_64_prefix/include/CL/" || exit 1 
	   cp -fv *.h "$mingw_w64_x86_64_prefix/include/OpenCL/" || exit 1 
    cd ../..
  cd ..
  # 2. the icd loader
  do_git_checkout https://github.com/KhronosGroup/OpenCL-ICD-Loader.git OpenCL-ICD-Loader
  cd OpenCL-ICD-Loader || exit 1 
	 rm -fv "libOpenCL.dll.a"
	 rm -fv "$mingw_w64_x86_64_prefix/lib/libOpenCL.dll.a"
	 rm -fv "OpenCL.a"
	 rm -fv "$mingw_w64_x86_64_prefix/lib/OpenCL.a"
    apply_patch https://raw.githubusercontent.com/hydra3333/ffmpeg-windows-build-helpers-withOpenCL/master/patches/0001-OpenCL-git-prefix-static.patch # "-p1"
    if [ "$1" = "32" ]; then   # this patch applies only to 32bit 
      apply_patch https://raw.githubusercontent.com/hydra3333/ffmpeg-windows-build-helpers-withOpenCL/master/patches/0001-OpenCL-icd-windows-c.patch #"-p1"
    elif [ "$1" = "64" ]; then   # this patch applies only to 64bit 
      echo "inside build_openCL_icd and bits=$1 ... no need to patch icd_windows.c "
    else
      echo "inside build_openCL_icd and bits=$1 which is not 32 or 64 !!  Aborting."
      exit 1
    fi
    cmake –G”Unix Makefiles” . -DENABLE_STATIC_RUNTIME=1 -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_RANLIB=${cross_prefix}ranlib -DCMAKE_C_COMPILER=${cross_prefix}gcc -DCMAKE_CXX_COMPILER=${cross_prefix}g++ -DCMAKE_RC_COMPILER=${cross_prefix}windres -DCMAKE_INSTALL_PREFIX=$mingw_w64_x86_64_prefix -DBUILD_SHARED_LIBS=OFF -DCMAKE_FIND_ROOT_PATH=$mingw_w64_x86_64_prefix || exit 1
    make clean || exit 1 
    make -j $cpu_count || exit 1 
    cp -fv "OpenCL.a" "$mingw_w64_x86_64_prefix/lib/libOpenCL.dll.a" || exit 1       # brute force link success by copying to known .a filenames 
  cd ..

Now, using the same build script, it aborts with this error:

/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/win32/OpenCL-ICD-Loader/icd_windows_hkr.c:45:10: 
fatal error: Devpkey.h: No such file or directory
 #include <Devpkey.h>
          ^~~~~~~~~~~
compilation terminated.
cmake –G”Unix Makefiles” . -DENABLE_STATIC_RUNTIME=1 -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_RANLIB=/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-i686/bin/i686-w64-mingw32-ranlib -DCMAKE_C_COMPILER=/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-i686/bin/i686-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-i686/bin/i686-w64-mingw32-g++ -DCMAKE_RC_COMPILER=/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-i686/bin/i686-w64-mingw32-windres -DCMAKE_INSTALL_PREFIX=/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-i686/i686-w64-mingw32 -DBUILD_SHARED_LIBS=OFF -DCMAKE_FIND_ROOT_PATH=/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-i686/i686-w64-mingw32 
-- The C compiler identification is GNU 7.2.0
-- The CXX compiler identification is GNU 7.2.0
-- Check for working C compiler: /home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-i686/bin/i686-w64-mingw32-gcc
-- Check for working C compiler: /home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-i686/bin/i686-w64-mingw32-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-i686/bin/i686-w64-mingw32-g++
-- Check for working CXX compiler: /home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-i686/bin/i686-w64-mingw32-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    ENABLE_STATIC_RUNTIME

-- Build files have been written to: /home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/win32/OpenCL-ICD-Loader
make clean
make -j 2 
Scanning dependencies of target IcdLog
Scanning dependencies of target OpenCL
[  3%] Building C object test/platform/CMakeFiles/IcdLog.dir/icd_test_log.c.obj
[  7%] Building C object CMakeFiles/OpenCL.dir/icd.c.obj
[ 11%] Linking C shared library ../../bin/libIcdLog.dll
[ 11%] Built target IcdLog
Scanning dependencies of target OpenCLDriverStub
[ 15%] Building C object test/driver_stub/CMakeFiles/OpenCLDriverStub.dir/cl.c.obj
[ 19%] Building C object test/driver_stub/CMakeFiles/OpenCLDriverStub.dir/cl_ext.c.obj
[ 23%] Building C object test/driver_stub/CMakeFiles/OpenCLDriverStub.dir/cl_gl.c.obj
[ 26%] Building C object test/driver_stub/CMakeFiles/OpenCLDriverStub.dir/icd.c.obj
[ 30%] Linking C shared library ../../bin/libOpenCLDriverStub.dll
Warning: resolving _clGetExtensionFunctionAddress by linking to _clGetExtensionFunctionAddress@4
Use --enable-stdcall-fixup to disable these warnings
Use --disable-stdcall-fixup to disable these fixups
Warning: resolving _clIcdGetPlatformIDsKHR by linking to _clIcdGetPlatformIDsKHR@12
[ 30%] Built target OpenCLDriverStub
[ 34%] Building C object CMakeFiles/OpenCL.dir/icd_dispatch.c.obj
[ 38%] Building C object CMakeFiles/OpenCL.dir/icd_windows.c.obj
[ 42%] Building C object CMakeFiles/OpenCL.dir/icd_windows_hkr.c.obj
/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/win32/OpenCL-ICD-Loader/icd_windows_hkr.c:45:10:
fatal error: Devpkey.h: No such file or directory
 #include <Devpkey.h>
          ^~~~~~~~~~~
compilation terminated.
CMakeFiles/OpenCL.dir/build.make:138: recipe for target 'CMakeFiles/OpenCL.dir/icd_windows_hkr.c.obj' failed
make[2]: *** [CMakeFiles/OpenCL.dir/icd_windows_hkr.c.obj] Error 1
make[2]: *** Waiting for unfinished jobs....
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/OpenCL.dir/all' failed
make[1]: *** [CMakeFiles/OpenCL.dir/all] Error 2
Makefile:94: recipe for target 'all' failed
make: *** [all] Error 2

ICD-Loader cannot be built on Windows 7 due to missing GL headers

Hi kepatil,

As mentioned in your comment on issue #9 I created a new issue.

I cannot build the ICD-Loader for Windows 7.

I am using CMake, from Kitware in version 3.7.2 and Visual C++ 2010 Express - ENU in version 10.0.40219. Due to this VC++ version I modified the "build_using_cmake.bat" file in line 1:
call "%VS90COMNTOOLS%/vsvars32.bat"

I also had to add a "GL" folder and the "gl.h" file to the "inc" folder. But here the first problem occurred since dependent on the "gl.h" file I use I get different errors.
I do not have OpenGL installed and I don't want to install OpenGL from the drivers. I am also not sure why OpenGL is really required for the ICD Loader here.

I am using the GL headers from this GitHub repo:
OpenGL headers

But more on the errors: If I compile with the GLES/gl.h in inc/GL I get the following error:
Microsoft (R) Program Maintenance Utility Version 10.00.30319.01 Copyright (C) Microsoft Corporation. All rights reserved. [ 4%] Building C object CMakeFiles/OpenCL.dir/icd.c.obj icd.c D:\OpenCL\OpenCL-ICD-Loader-master\inc\GL/gl.h(37) : fatal error C1083: Cannot open include file: "GLES/glplatform.h": No such file or directory NMAKE : fatal error U1077: "C:\PROGRA~2\MICROS~2.0\VC\bin\cl.exe" : return code "0x2" Stop. NMAKE : fatal error U1077: "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\nmake.exe" : return code "0x2" Stop. NMAKE : fatal error U1077: "C:\Program Files (x86)\Microsoft Visual Studio 1 0.0\VC\BIN\nmake.exe"' : return code "0x2" Stop.

Adding the GLES folder and the glpatform.h file does not fix this problem:
Microsoft (R) Program Maintenance Utility Version 10.00.30319.01 Copyright (C) Microsoft Corporation. All rights reserved. [ 4%] Building C object CMakeFiles/OpenCL.dir/icd.c.obj icd.c D:\OpenCL\OpenCL-ICD-Loader-master\inc\GLES/glplatform.h(28) : fatal error C1083: Cannot open include file: "KHR/khrplatform.h": No such file or directory NMAKE : fatal error U1077: "C:\PROGRA~2\MICROS~2.0\VC\bin\cl.exe" : return code "0x2" Stop. NMAKE : fatal error U1077: "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\nmake.exe" : return code "0x2" Stop. NMAKE : fatal error U1077: "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\nmake.exe" : return code "0x2" Stop.

I obviously don't have this file and have no clue where to get it. If I create a folder KHR and put this file in I get the same error as you can observe below:

Using the gl.h file from the GLSC folder (1.0.1) did not work either:
Microsoft (R) Program Maintenance Utility Version 10.00.30319.01 Copyright (C) Microsoft Corporation. All rights reserved. [ 4%] Building C object CMakeFiles/OpenCL.dir/icd.c.obj icd.c D:\OpenCL\OpenCL-ICD-Loader-master\icd.c(207) : error C2143: syntax error : missing ";" before "const" D:\OpenCL\OpenCL-ICD-Loader-master\icd.c(209) : error C2065: "property" : undeclared identifier D:\OpenCL\OpenCL-ICD-Loader-master\icd.c(209) : warning C4047: "=" : "int" differs in levels of indirection from "const cl_context_properties *" D:\OpenCL\OpenCL-ICD-Loader-master\icd.c(209) : error C2065: "property" : undeclared identifier D:\OpenCL\OpenCL-ICD-Loader-master\icd.c(209) : error C2065: "property" : undeclared identifier D:\OpenCL\OpenCL-ICD-Loader-master\icd.c(209) : error C2109: subscript requires array or pointer type D:\OpenCL\OpenCL-ICD-Loader-master\icd.c(209) : error C2065: "property" : undeclared identifier D:\OpenCL\OpenCL-ICD-Loader-master\icd.c(211) : error C2065: "property" : undeclared identifier D:\OpenCL\OpenCL-ICD-Loader-master\icd.c(211) : error C2109: subscript requires array or pointer type D:\OpenCL\OpenCL-ICD-Loader-master\icd.c(213) : error C2065: "property" : undeclared identifier D:\OpenCL\OpenCL-ICD-Loader-master\icd.c(213) : error C2109: subscript requires array or pointer type NMAKE : fatal error U1077: "C:\PROGRA~2\MICROS~2.0\VC\bin\cl.exe" : return code "0x2" Stop. NMAKE : fatal error U1077: "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\nmake.exe" : return code "0x2" Stop. NMAKE : fatal error U1077: "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\nmake.exe" : return code "0x2" Stop.

This means even more confusing errors. By the way, these are the same errors you get if you build without a GL folder (and therefore no gl.h file).

In any case I was able to build the ICD Loader and test ist successfully on an Ubuntu Linux 16.04 LTS running in a virtual machine, with as far as I can tell no OpenGL files available besides the one I added manually from the above mentioned OpenGL repo (I used the GLES/gl.h in the inc/GL folder).

It would be great if you can help me here.

Regards,
viswph

New release/tag

I understand this needs some alignment with the OpenCL-headers repository, but the current and only tag v2020.03.13 gives me troubles compiling on Ubuntu because of the multiple defined ret_val issue which got fixed two weeks later in this pull.

As a workaround I could return to always syncing my project to the master branch, but it feels like a step backward, since they make my project's builds unstable:
a. There is a chance the master branch of this repository and the master branch of the OpenCL-headers repository are out of sync.
b. New features, bugfixed functionality, is pushed to the master branch which gives unexpected compiler errors in my build or functionality changes in my project.

TLDR: Could you please add a new release/tag to improve stability in downstream projects? Thanks

Test entry points that came after OpenCL 1.2

There are some simple smoke tests in this repo, but only entry points up until OpenCL 1.2 are tested. OpenCL 2.0, 2.1, 2.2, and extensions added in that timeframe are not tested.

Adding tests is very formulaic, I added two for experimental entry points here: #108

The flip side of them being so formulaic is that they really are just smoke tests.

Broken handling of 32-bit apps/OS

Inspecting the OpenCL loader, I noticed that the commit

introduced a loader bug when running a 32-bit application. An analogous bug was added to the Vulkan loader. The Vulkan bug was fixed by

OpenCL needs a similar fix.

The problem can be seen by inspecting the following code from 188be60#diff-cdc4e03135a98264f91c20e2919d407f:

#ifdef _WIN64
static const char OPENCL_REG_SUB_KEY[] = "OpenCLDriverName";
#else
static const char OPENCL_REG_SUB_KEY[] = "OpenCLDriverNameWow";
#endif

This does the wrong thing when running a 32-bit application on a 64-bit OS, and it does the wrong thing when running a 32-bit application on a 32-bit OS.

See the Vulkan commit cited above for an example of how to fix it.

build error: 'DEVPKEY_Device_ClassGuid' undeclared

Just now encountered this build error.
Cross-compiling under Ubuntu18.04 for Win10x64.

-- Build files have been written to: /_working/workdir/x86_64/OpenCL-ICD-Loader_git
[1/8] Building RC object CMakeFiles/OpenCL.dir/loader/windows/OpenCL.rc.res
[2/8] Building C object CMakeFiles/OpenCL.dir/loader/windows/icd_windows_dxgk.c.obj
[3/8] Building C object CMakeFiles/OpenCL.dir/loader/windows/icd_windows_envvars.c.obj
[4/8] Building C object CMakeFiles/OpenCL.dir/loader/windows/icd_windows_hkr.c.obj
FAILED: CMakeFiles/OpenCL.dir/loader/windows/icd_windows_hkr.c.obj
/_working/workdir/toolchain/x86_64-w64-mingw32/bin/x86_64-w64-mingw32-gcc --sysroot=/_working/workdir/toolchain/x86_64-w64-mingw32 -DCL_TARGET_OPENCL_VERSION=220 -DOpenCL_EXPORTS -Iinc -I. -Iloader -O3  -fstack-protector-all  -D_FORTIFY_SOURCE=2 -O3 -DNDEBUG -MD -MT CMakeFiles/OpenCL.dir/loader/windows/icd_windows_hkr.c.obj -MF CMakeFiles/OpenCL.dir/loader/windows/icd_windows_hkr.c.obj.d -o CMakeFiles/OpenCL.dir/loader/windows/icd_windows_hkr.c.obj   -c loader/windows/icd_windows_hkr.c
loader/windows/icd_windows_hkr.c: In function 'khrIcdOsVendorsEnumerateHKR':
loader/windows/icd_windows_hkr.c:217:21: error: 'CM_GETIDLIST_FILTER_CLASS' undeclared (first use in this function); did you mean 'CM_GETIDLIST_FILTER_BITS'?
  217 |     ULONG ulFlags = CM_GETIDLIST_FILTER_CLASS |
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~
      |                     CM_GETIDLIST_FILTER_BITS
loader/windows/icd_windows_hkr.c:217:21: note: each undeclared identifier is reported only once for each function it appears in
loader/windows/icd_windows_hkr.c:218:21: error: 'CM_GETIDLIST_FILTER_PRESENT' undeclared (first use in this function); did you mean 'CM_GETIDLIST_FILTER_BITS'?
  218 |                     CM_GETIDLIST_FILTER_PRESENT;
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                     CM_GETIDLIST_FILTER_BITS
loader/windows/icd_windows_hkr.c:343:22: error: 'DEVPKEY_Device_ClassGuid' undeclared (first use in this function)
  343 |                     &DEVPKEY_Device_ClassGuid,
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~
[5/8] Building C object CMakeFiles/OpenCL.dir/loader/windows/icd_windows.c.obj
loader/windows/icd_windows.c: In function 'khrIcdOsVendorsEnumerate':
loader/windows/icd_windows.c:192:64: warning: passing argument 2 of 'pCreateDXGIFactory' from incompatible pointer type [-Wincompatible-pointer-types]
  192 |             HRESULT hr = pCreateDXGIFactory(&IID_IDXGIFactory, &pFactory);
      |                                                                ^~~~~~~~~
      |                                                                |
      |                                                                IDXGIFactory ** {aka struct IDXGIFactory **}
loader/windows/icd_windows.c:192:64: note: expected 'void **' but argument is of type 'IDXGIFactory **' {aka 'struct IDXGIFactory **'}
loader/windows/icd_windows.c: In function 'khrIcdOsVendorsEnumerateOnce':
loader/windows/icd_windows.c:244:5: warning: implicit declaration of function 'InitOnceExecuteOnce' [-Wimplicit-function-declaration]
  244 |     InitOnceExecuteOnce(&initialized, khrIcdOsVendorsEnumerate, NULL, NULL);
      |     ^~~~~~~~~~~~~~~~~~~
[6/8] Building C object CMakeFiles/OpenCL.dir/loader/icd.c.obj
[7/8] Building C object CMakeFiles/OpenCL.dir/loader/icd_dispatch.c.obj
ninja: build stopped: subcommand failed.

clCreateContext return unknown error code when create gl sharing context.

When I switch code from intel opencl sdk to the icd loader, the clCreateContext fails, but intel sdk works fine when calling clCreateContext with a GPU type device.
If I call clCreateContext without gl sharing properties, icd loader works fine.

Sample code as below:

		cl_int err = CL_SUCCESS;
                //get nvidia platform and gpu type device omitted.
		cl_context_properties properties[] = {
			CL_GL_CONTEXT_KHR, (cl_context_properties)wglGetCurrentContext(),
			CL_WGL_HDC_KHR, (cl_context_properties)wglGetCurrentDC(),
			CL_CONTEXT_PLATFORM, (cl_context_properties)targetPlatform,
			0 
		};
		cl::g_ctx = clCreateContext(properties, 1, &device, NULL, NULL, &err);//if call clCreateContext(NULL, 1, &device, NULL, NULL, &err); no error occur.
		CL_CHECK(err);//this err code is -9999.

My Environment is: windows 10, NVIDIA gtx1050ti with driver version R398.36 (r398_35-2) / 22.20.16.4735 (7-7-2017)

AMD opencl uses REG_MULTI_SZ for OpenCLDriverName

I Have a windows system with both Nvidia and AMD gpus, both individual vendor opencl driver work when used directly. Using this ICD the amd driver fails to be detected because AMD have used
REG_MULTI_SZ rather than REG_SZ for the OpenCLDriverName.

I know this is technically AMD's fault as they are going against the docs here
https://github.com/KhronosGroup/OpenCL-Docs/blob/master/ext/cl_khr_icd.txt#L71

If the maintainers want to allow this small deviation from the spec: See pull request for quick fix. #85

Consider: Remove Batch File and Makefile and Switch Entirely to CMake

I'm opening this issue to discuss removing the included Makefile (for Linux) and batch file (for Windows) and switching entirely to a CMake build system instead. This is inspired by several related issues and pull requests. For example:

Since the Makefile and batch file use CMake anyhow, can we simply remove them and update the README to describe how to use CMake directly instead?

won't cross-compile any more now that headers changed :( :(

Modified header version to be 1.2 for nvidia compatibility (and changed that ONLY). Nothing else changed.

But now this icd loader will not build :( :(

Cross-compile under ubuntu/mingw64 used to work fine up to yesterday.

Log below.

[03:02:21][INFO] C-Making 'opencl_icd' with: . -G"Unix Makefiles" -DCMAKE_SYSTEM_PROCESSOR="x86_64" -DENABLE_STATIC_RUNTIME=1 -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_RANLIB=/home/u/Desktop/ds27/workdir/toolchain/x86_64-w64-mingw32/bin/x86_64-w64-mingw32-ranlib -DCMAKE_C_COMPILER=/home/u/Desktop/ds27/workdir/toolchain/x86_64-w64-mingw32/bin/x86_64-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=/home/u/Desktop/ds27/workdir/toolchain/x86_64-w64-mingw32/bin/x86_64-w64-mingw32-g++ -DCMAKE_RC_COMPILER=/home/u/Desktop/ds27/workdir/toolchain/x86_64-w64-mingw32/bin/x86_64-w64-mingw32-windres -DCMAKE_FIND_ROOT_PATH=/home/u/Desktop/ds27/workdir/toolchain/x86_64-w64-mingw32/x86_64-w64-mingw32 -DCMAKE_INSTALL_PREFIX=/home/u/Desktop/ds27/workdir/toolchain/x86_64-w64-mingw32/x86_64-w64-mingw32 -DBUILD_SHARED_LIBS=OFF
-- The C compiler identification is GNU 8.1.1
-- The CXX compiler identification is GNU 8.1.1
-- Check for working C compiler: /home/u/Desktop/ds27/workdir/toolchain/x86_64-w64-mingw32/bin/x86_64-w64-mingw32-gcc
-- Check for working C compiler: /home/u/Desktop/ds27/workdir/toolchain/x86_64-w64-mingw32/bin/x86_64-w64-mingw32-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /home/u/Desktop/ds27/workdir/toolchain/x86_64-w64-mingw32/bin/x86_64-w64-mingw32-g++
-- Check for working CXX compiler: /home/u/Desktop/ds27/workdir/toolchain/x86_64-w64-mingw32/bin/x86_64-w64-mingw32-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    ENABLE_STATIC_RUNTIME


-- Build files have been written to: /home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git
[03:02:23][INFO] Making 'opencl_icd' with:  in /home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git
Scanning dependencies of target IcdLog
Scanning dependencies of target OpenCL
[ 15%] Building C object CMakeFiles/OpenCL.dir/icd_dispatch.c.obj
[ 15%] Building C object test/platform/CMakeFiles/IcdLog.dir/icd_test_log.c.obj
[ 15%] Building C object CMakeFiles/OpenCL.dir/icd.c.obj
[ 15%] Building C object CMakeFiles/OpenCL.dir/icd_windows.c.obj
In file included from /home/u/Desktop/ds27/workdir/toolchain/x86_64-w64-mingw32/include/CL/cl.h:36,
                 from /home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd.h:53,
                 from /home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_windows.c:38:
/home/u/Desktop/ds27/workdir/toolchain/x86_64-w64-mingw32/include/CL/cl_version.h:34:9: note: #pragma message: cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 120 (OpenCL 1.2) for NVIDIA compatibility
 #pragma message("cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 120 (OpenCL 1.2) for NVIDIA compatibility")
         ^~~~~~~
In file included from /home/u/Desktop/ds27/workdir/toolchain/x86_64-w64-mingw32/include/CL/cl.h:36,
                 from /home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_dispatch.h:58,
                 from /home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_dispatch.c:38:
/home/u/Desktop/ds27/workdir/toolchain/x86_64-w64-mingw32/include/CL/cl_version.h:34:9: note: #pragma message: cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 120 (OpenCL 1.2) for NVIDIA compatibility
 #pragma message("cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 120 (OpenCL 1.2) for NVIDIA compatibility")
         ^~~~~~~
In file included from /home/u/Desktop/ds27/workdir/toolchain/x86_64-w64-mingw32/include/CL/cl.h:36,
                 from /home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd.h:53,
                 from /home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd.c:38:
/home/u/Desktop/ds27/workdir/toolchain/x86_64-w64-mingw32/include/CL/cl_version.h:34:9: note: #pragma message: cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 120 (OpenCL 1.2) for NVIDIA compatibility
 #pragma message("cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 120 (OpenCL 1.2) for NVIDIA compatibility")
         ^~~~~~~
In file included from /home/u/Desktop/ds27/workdir/toolchain/x86_64-w64-mingw32/include/CL/cl.h:36,
                 from /home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/test/platform/icd_test_log.c:5:
/home/u/Desktop/ds27/workdir/toolchain/x86_64-w64-mingw32/include/CL/cl_version.h:34:9: note: #pragma message: cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 120 (OpenCL 1.2) for NVIDIA compatibility
 #pragma message("cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 120 (OpenCL 1.2) for NVIDIA compatibility")
         ^~~~~~~
In file included from /home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_windows.c:39:
/home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_windows_hkr.h:58:19: warning: 'DEVPKEY_Device_ClassGuid' initialized and declared 'extern'
 DEFINE_DEVPROPKEY(DEVPKEY_Device_ClassGuid,              0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 10);    // DEVPROP_TYPE_GUID
                   ^~~~~~~~~~~~~~~~~~~~~~~~
/home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_windows_hkr.h:56:124: note: in definition of macro 'DEFINE_DEVPROPKEY'
 #define DEFINE_DEVPROPKEY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) extern const DEVPROPKEY DECLSPEC_SELECTANY name = { { l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } }, pid }
                                                                                                                            ^~~~
[ 19%] Linking C shared library ../../bin/libIcdLog.dll
[ 19%] Built target IcdLog
Scanning dependencies of target OpenCLDriverStub
[ 23%] Building C object test/driver_stub/CMakeFiles/OpenCLDriverStub.dir/cl.c.obj
In file included from /home/u/Desktop/ds27/workdir/toolchain/x86_64-w64-mingw32/include/CL/cl.h:36,
                 from /home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/test/driver_stub/cl.c:17:
/home/u/Desktop/ds27/workdir/toolchain/x86_64-w64-mingw32/include/CL/cl_version.h:34:9: note: #pragma message: cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 120 (OpenCL 1.2) for NVIDIA compatibility
 #pragma message("cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 120 (OpenCL 1.2) for NVIDIA compatibility")
         ^~~~~~~
/home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_windows.c: In function 'khrIcdOsVendorsEnumerateOnce':
/home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_windows.c:135:5: warning: implicit declaration of function 'InitOnceExecuteOnce' [-Wimplicit-function-declaration]
     InitOnceExecuteOnce(&initialized, khrIcdOsVendorsEnumerate, NULL, NULL);
     ^~~~~~~~~~~~~~~~~~~
[ 26%] Building C object CMakeFiles/OpenCL.dir/icd_windows_hkr.c.obj
In file included from /home/u/Desktop/ds27/workdir/toolchain/x86_64-w64-mingw32/include/CL/cl.h:36,
                 from /home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd.h:53,
                 from /home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_windows_hkr.c:38:
/home/u/Desktop/ds27/workdir/toolchain/x86_64-w64-mingw32/include/CL/cl_version.h:34:9: note: #pragma message: cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 120 (OpenCL 1.2) for NVIDIA compatibility
 #pragma message("cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 120 (OpenCL 1.2) for NVIDIA compatibility")
         ^~~~~~~
[ 30%] Building C object test/driver_stub/CMakeFiles/OpenCLDriverStub.dir/cl_ext.c.obj
In file included from /home/u/Desktop/ds27/workdir/toolchain/x86_64-w64-mingw32/include/CL/cl.h:36,
                 from /home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/test/driver_stub/cl_ext.c:4:
/home/u/Desktop/ds27/workdir/toolchain/x86_64-w64-mingw32/include/CL/cl_version.h:34:9: note: #pragma message: cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 120 (OpenCL 1.2) for NVIDIA compatibility
 #pragma message("cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 120 (OpenCL 1.2) for NVIDIA compatibility")
         ^~~~~~~
In file included from /home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_windows_hkr.c:39:
/home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_windows_hkr.h:58:19: warning: 'DEVPKEY_Device_ClassGuid' initialized and declared 'extern'
 DEFINE_DEVPROPKEY(DEVPKEY_Device_ClassGuid,              0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 10);    // DEVPROP_TYPE_GUID
                   ^~~~~~~~~~~~~~~~~~~~~~~~
/home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_windows_hkr.h:56:124: note: in definition of macro 'DEFINE_DEVPROPKEY'
 #define DEFINE_DEVPROPKEY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) extern const DEVPROPKEY DECLSPEC_SELECTANY name = { { l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } }, pid }
                                                                                                                            ^~~~
[ 34%] Building C object test/driver_stub/CMakeFiles/OpenCLDriverStub.dir/cl_gl.c.obj
In file included from /home/u/Desktop/ds27/workdir/toolchain/x86_64-w64-mingw32/include/CL/cl.h:36,
                 from /home/u/Desktop/ds27/workdir/toolchain/x86_64-w64-mingw32/include/CL/cl_gl.h:35,
                 from /home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/test/driver_stub/cl_gl.c:1:
/home/u/Desktop/ds27/workdir/toolchain/x86_64-w64-mingw32/include/CL/cl_version.h:34:9: note: #pragma message: cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 120 (OpenCL 1.2) for NVIDIA compatibility
 #pragma message("cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 120 (OpenCL 1.2) for NVIDIA compatibility")
         ^~~~~~~
In file included from /home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_dispatch.c:38:
/home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_dispatch.h:160:11: error: unknown type name 'cl_queue_properties'
     const cl_queue_properties * /* properties */,
           ^~~~~~~~~~~~~~~~~~~
/home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_dispatch.h:223:11: error: unknown type name 'cl_pipe_properties'
     const cl_pipe_properties * /* properties */,
           ^~~~~~~~~~~~~~~~~~
/home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_dispatch.h:228:5: error: unknown type name 'cl_pipe_info'; did you mean 'cl_image_info'?
     cl_pipe_info /* param_name */,
     ^~~~~~~~~~~~
     cl_image_info
In file included from /home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd.c:39:
/home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_dispatch.h:160:11: error: unknown type name 'cl_queue_properties'
     const cl_queue_properties * /* properties */,
           ^~~~~~~~~~~~~~~~~~~
/home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_dispatch.h:223:11: error: unknown type name 'cl_pipe_properties'
     const cl_pipe_properties * /* properties */,
           ^~~~~~~~~~~~~~~~~~
/home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_dispatch.h:235:5: error: unknown type name 'cl_svm_mem_flags'; did you mean 'cl_svm_mem_flags_arm'?
     cl_svm_mem_flags /* flags */,
     ^~~~~~~~~~~~~~~~
     cl_svm_mem_flags_arm
/home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_dispatch.h:264:11: error: unknown type name 'cl_sampler_properties'
     const cl_sampler_properties * /* sampler_properties */,
           ^~~~~~~~~~~~~~~~~~~~~
/home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_dispatch.h:228:5: error: unknown type name 'cl_pipe_info'; did you mean 'cl_image_info'?
     cl_pipe_info /* param_name */,
     ^~~~~~~~~~~~
     cl_image_info
/home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_dispatch.h:406:5: error: unknown type name 'cl_kernel_exec_info'; did you mean 'cl_kernel_exec_info_arm'?
     cl_kernel_exec_info  /* param_name */,
     ^~~~~~~~~~~~~~~~~~~
     cl_kernel_exec_info_arm
In file included from /home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_dispatch.c:38:
/home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_dispatch.h:1449:5: error: unknown type name 'KHRpfn_clGetPipeInfo'
     KHRpfn_clGetPipeInfo                            clGetPipeInfo;
     ^~~~~~~~~~~~~~~~~~~~
/home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_dispatch.h:1450:5: error: unknown type name 'KHRpfn_clSVMAlloc'
     KHRpfn_clSVMAlloc                               clSVMAlloc;
     ^~~~~~~~~~~~~~~~~
/home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_dispatch.h:1459:5: error: unknown type name 'KHRpfn_clSetKernelExecInfo'
     KHRpfn_clSetKernelExecInfo                      clSetKernelExecInfo;
     ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_dispatch.h:235:5: error: unknown type name 'cl_svm_mem_flags'; did you mean 'cl_svm_mem_flags_arm'?
     cl_svm_mem_flags /* flags */,
     ^~~~~~~~~~~~~~~~
     cl_svm_mem_flags_arm
/home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_dispatch.h:264:11: error: unknown type name 'cl_sampler_properties'
     const cl_sampler_properties * /* sampler_properties */,
           ^~~~~~~~~~~~~~~~~~~~~
/home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_dispatch.c:2309:11: error: unknown type name 'cl_queue_properties'
     const cl_queue_properties * properties,
           ^~~~~~~~~~~~~~~~~~~
/home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_dispatch.c:2326:11: error: unknown type name 'cl_pipe_properties'
     const cl_pipe_properties * properties,
           ^~~~~~~~~~~~~~~~~~
/home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_dispatch.c:2342:5: error: unknown type name 'cl_pipe_info'; did you mean 'cl_image_info'?
     cl_pipe_info param_name,
     ^~~~~~~~~~~~
     cl_image_info
/home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_dispatch.h:406:5: error: unknown type name 'cl_kernel_exec_info'; did you mean 'cl_kernel_exec_info_arm'?
     cl_kernel_exec_info  /* param_name */,
     ^~~~~~~~~~~~~~~~~~~
     cl_kernel_exec_info_arm
In file included from /home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd.c:39:
/home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_dispatch.h:1449:5: error: unknown type name 'KHRpfn_clGetPipeInfo'
     KHRpfn_clGetPipeInfo                            clGetPipeInfo;
     ^~~~~~~~~~~~~~~~~~~~
/home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_dispatch.h:1450:5: error: unknown type name 'KHRpfn_clSVMAlloc'
     KHRpfn_clSVMAlloc                               clSVMAlloc;
     ^~~~~~~~~~~~~~~~~
/home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_dispatch.h:1459:5: error: unknown type name 'KHRpfn_clSetKernelExecInfo'
     KHRpfn_clSetKernelExecInfo                      clSetKernelExecInfo;
     ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_dispatch.c:2359:5: error: unknown type name 'cl_svm_mem_flags'; did you mean 'cl_svm_mem_flags_arm'?
     cl_svm_mem_flags flags,
     ^~~~~~~~~~~~~~~~
     cl_svm_mem_flags_arm
/home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_dispatch.c:2502:11: error: unknown type name 'cl_sampler_properties'
     const cl_sampler_properties *  sampler_properties,
           ^~~~~~~~~~~~~~~~~~~~~
CMakeFiles/OpenCL.dir/build.make:63: recipe for target 'CMakeFiles/OpenCL.dir/icd.c.obj' failed
make[2]: *** [CMakeFiles/OpenCL.dir/icd.c.obj] Error 1
make[2]: *** Waiting for unfinished jobs....
/home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_dispatch.c:2528:5: error: unknown type name 'cl_kernel_exec_info'; did you mean 'cl_kernel_exec_info_arm'?
     cl_kernel_exec_info  param_name,
     ^~~~~~~~~~~~~~~~~~~
     cl_kernel_exec_info_arm
[ 38%] Building C object test/driver_stub/CMakeFiles/OpenCLDriverStub.dir/icd.c.obj
CMakeFiles/OpenCL.dir/build.make:88: recipe for target 'CMakeFiles/OpenCL.dir/icd_dispatch.c.obj' failed
make[2]: *** [CMakeFiles/OpenCL.dir/icd_dispatch.c.obj] Error 1
In file included from /home/u/Desktop/ds27/workdir/toolchain/x86_64-w64-mingw32/include/CL/cl.h:36,
                 from /home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/test/driver_stub/icd.c:15:
/home/u/Desktop/ds27/workdir/toolchain/x86_64-w64-mingw32/include/CL/cl_version.h:34:9: note: #pragma message: cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 120 (OpenCL 1.2) for NVIDIA compatibility
 #pragma message("cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 120 (OpenCL 1.2) for NVIDIA compatibility")
         ^~~~~~~
/home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_windows_hkr.c: In function 'khrIcdOsVendorsEnumerateHKR':
/home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git/icd_windows_hkr.c:354:23: warning: implicit declaration of function 'CM_Get_DevNode_PropertyW'; did you mean 'CM_Set_DevNode_Problem'? [-Wimplicit-function-declaration]
                 ret = CM_Get_DevNode_PropertyW(
                       ^~~~~~~~~~~~~~~~~~~~~~~~
                       CM_Set_DevNode_Problem
[ 42%] Linking C shared library ../../bin/libOpenCLDriverStub.dll
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/OpenCL.dir/all' failed
make[1]: *** [CMakeFiles/OpenCL.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 42%] Built target OpenCLDriverStub
Makefile:94: recipe for target 'all' failed
make: *** [all] Error 2
[03:02:26][ERROR] Error [2] running process: 'make  -j 4' in '/home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git'
[03:02:26][ERROR] You can try deleting the product/dependency folder: '/home/u/Desktop/ds27/workdir/x86_64/OpenCL-ICD-Loader_git' and re-run the script
+ exit 1

make test fails.

Hello,
I have successfully built icd_loader; and also modified /etc/OpenCL/vendors/test.icd to point to the DriverStub.so built from icd_loader. Then I tried to run make 'test. It failed with the following errors:
make -C build test
make[1]: Entering directory '/home/xxxx/xxx/icd/build'
Running tests...
Test project /home/xxxx/xxx/icd/build
Start 1: OPENCL_ICD_LOADER_TEST
1/1 Test #1: OPENCL_ICD_LOADER_TEST ...........***Exception: SegFault 0.79 sec

0% tests passed, 1 tests failed out of 1

Total Test time (real) = 0.79 sec

The following tests FAILED:
1 - OPENCL_ICD_LOADER_TEST (SEGFAULT)
Errors while running CTest

...

What is the wrong here?

thanks,

steven

Add .clang-tidy and enable higher warning level

The number of checks that we can use is highly limited since this is a C project, not C++ and we have to do a few things that are UB strictly speaking (like void * <-> function pointer casts), but there are a few things we can enable that are still useful. Examples:


Note that this requires the generation of a compilation database which is most easily achieved by passing -DCMAKE_EXPORT_COMPILE_COMMANDS=ON to CMake >= 3.4. This shouldn't be much of a problem, as the way I set up the testing matrix in #65 makes it easy to switch out different build tools for different jobs in the matrix (just add another Conan profile). This way we can use this feature on our CI and still ensure that the project builds correctly with older CMake versions.

'wcstombs': This function or variable may be unsafe

Hello,
I tried to build ID_loader on Windows ver. 1903 (SDK 10.0.18362.0 and WDK 10.0.18362.1)
and got the following error:
OpenCL-ICD-Loader\windows\icd_windows_dxgk.c(142): error C4996: 'wcstombs': This function or variable may be unsafe. Consider using wcstombs_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
Can you help me solve this problem?

Move the dispatch table declaration to OpenCL-Headers?

The various function pointer types as well as the declaration for the dispatch table in icd_dispatch.h would be easier to reuse directly in OpenCL implementations if they were part of OpenCL-Headers.

It seems to me that only the declaration for the structure types at the bottom of the file should be part of the ICD loader itself.

Is there a good reason to not do that?

Debian 9 x64 cannot build

Tried to build the project and failed with this output:

makemkdir -p build && cd build && cmake ..
-- The CXX compiler identification is GNU 6.3.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/said-debian/Downloads/OpenCL-ICD-Loader-master/build
make -C build
make[1]: Entering directory '/home/said-debian/Downloads/OpenCL-ICD-Loader-master/build'
make[2]: Entering directory '/home/said-debian/Downloads/OpenCL-ICD-Loader-master/build'
make[3]: Entering directory '/home/said-debian/Downloads/OpenCL-ICD-Loader-master/build'
Scanning dependencies of target OpenCL
make[3]: Leaving directory '/home/said-debian/Downloads/OpenCL-ICD-Loader-master/build'
make[3]: Entering directory '/home/said-debian/Downloads/OpenCL-ICD-Loader-master/build'
[  4%] Building C object CMakeFiles/OpenCL.dir/icd.c.o
In file included from /home/said-debian/Downloads/OpenCL-ICD-Loader-master/icd.c:39:0:
/home/said-debian/Downloads/OpenCL-ICD-Loader-master/icd_dispatch.h:334:38: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘CL_API_SUFFIX__VERSION_2_2’
     const void*          spec_value) CL_API_SUFFIX__VERSION_2_2;
                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/said-debian/Downloads/OpenCL-ICD-Loader-master/icd_dispatch.h:339:37: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘CL_API_SUFFIX__VERSION_2_2’
     void *               user_data) CL_API_SUFFIX__VERSION_2_2;
                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/said-debian/Downloads/OpenCL-ICD-Loader-master/icd.c:39:0:
/home/said-debian/Downloads/OpenCL-ICD-Loader-master/icd_dispatch.h:1479:5: error: unknown type name ‘KHRpfn_clSetProgramReleaseCallback’
     KHRpfn_clSetProgramReleaseCallback              clSetProgramReleaseCallback;
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/said-debian/Downloads/OpenCL-ICD-Loader-master/icd_dispatch.h:1480:5: error: unknown type name ‘KHRpfn_clSetProgramSpecializationConstant’
     KHRpfn_clSetProgramSpecializationConstant       clSetProgramSpecializationConstant;
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CMakeFiles/OpenCL.dir/build.make:62: recipe for target 'CMakeFiles/OpenCL.dir/icd.c.o' failed
make[3]: *** [CMakeFiles/OpenCL.dir/icd.c.o] Error 1
make[3]: Leaving directory '/home/said-debian/Downloads/OpenCL-ICD-Loader-master/build'
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/OpenCL.dir/all' failed
make[2]: *** [CMakeFiles/OpenCL.dir/all] Error 2
make[2]: Leaving directory '/home/said-debian/Downloads/OpenCL-ICD-Loader-master/build'
Makefile:94: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/home/said-debian/Downloads/OpenCL-ICD-Loader-master/build'
Makefile:12: recipe for target 'do_build' failed
make: *** [do_build] Error 2

Trying to build the Loader causes error

I've been trying to build it with instructions from readme, but whenever I try to build in step 5, I get this error:

D:\OpenCL-ICD-Loader\build> make

make[1]: Entering directory '/cygdrive/d/OpenCL-ICD-Loader/build'
make[2]: Entering directory '/cygdrive/d/OpenCL-ICD-Loader/build'
Scanning dependencies of target OpenCL
make[2]: Leaving directory '/cygdrive/d/OpenCL-ICD-Loader/build'
make[2]: Entering directory '/cygdrive/d/OpenCL-ICD-Loader/build'
[  4%] Building C object CMakeFiles/OpenCL.dir/loader/icd.c.o
/cygdrive/d/OpenCL-ICD-Loader/loader/icd.c: In function 'loader_get_next_path':
/cygdrive/d/OpenCL-ICD-Loader/loader/icd.c:199:25: error: 'PATH_SEPARATOR' undeclared (first use in this function)
  199 |     next = strchr(path, PATH_SEPARATOR);
      |                         ^~~~~~~~~~~~~~
/cygdrive/d/OpenCL-ICD-Loader/loader/icd.c:199:25: note: each undeclared identifier is reported only once for each function it appears in
make[2]: *** [CMakeFiles/OpenCL.dir/build.make:63: CMakeFiles/OpenCL.dir/loader/icd.c.o] Error 1
make[2]: Leaving directory '/cygdrive/d/OpenCL-ICD-Loader/build'
make[1]: *** [CMakeFiles/Makefile2:297: CMakeFiles/OpenCL.dir/all] Error 2
make[1]: Leaving directory '/cygdrive/d/OpenCL-ICD-Loader/build'
make: *** [Makefile:141: all] Error 2

build error: CL_API_SUFFIX__VERSION_2_2 in icd_dispatch.h

Hello,
I just checkout repo, and use 'make' to build. It reports the following error:
...
OpenCL-ICD-Loader/icd_dispatch.h:329:38: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘CL_API_SUFFIX__VERSION_2_2’
const void* spec_value) CL_API_SUFFIX__VERSION_2_2;

...

can someone shed some lights on this solution?

thanks,

Failes to compile in Fedora 32

openCl failes to compile in Fedora 32 due to multiple definitions of ret_val in the loader_test.

I've attached
diff.txt

the diffs to have a common ret_val, if this was what was intended, Although from a quick look at the code making each one static may also work

make fails when following the instruction

Instruction mention to define OPENCL_ICD_LOADER_HEADERS_DIR to include header and has no effect so fails. Please test before publishing, otherwise it is useless.
root@sriov-guest:/git.co/khronos# env | grep OPENCL
OPENCL_ICD_LOADER_HEADERS_DIR=/git.co/khronos/OpenCL-Headers/CL/
root@sriov-guest:/git.co/khronos# cd OpenCL-ICD-Loader/
root@sriov-guest:/git.co/khronos/OpenCL-ICD-Loader# pwd
/git.co/khronos/OpenCL-ICD-Loader
root@sriov-guest:/git.co/khronos/OpenCL-ICD-Loader# ls
CL CMakeLists.txt CODE_OF_CONDUCT.md LICENSE README.md build inc loader test
root@sriov-guest:/git.co/khronos/OpenCL-ICD-Loader# cd build
root@sriov-guest:/git.co/khronos/OpenCL-ICD-Loader/build# cmake ..
-- Configuring done
-- Generating done
-- Build files have been written to: /git.co/khronos/OpenCL-ICD-Loader/build
root@sriov-guest:/git.co/khronos/OpenCL-ICD-Loader/build# make
[ 20%] Built target OpenCL
[ 24%] Building C object test/log/CMakeFiles/IcdLog.dir/icd_test_log.c.o
/git.co/khronos/OpenCL-ICD-Loader/test/log/icd_test_log.c:5:9: fatal error: CL/cl.h: No such file or directory
#include<CL/cl.h>
^~~~~~~~~
compilation terminated.
test/log/CMakeFiles/IcdLog.dir/build.make:62: recipe for target 'test/log/CMakeFiles/IcdLog.dir/icd_test_log.c.o' failed
make[2]: *** [test/log/CMakeFiles/IcdLog.dir/icd_test_log.c.o] Error 1
CMakeFiles/Makefile2:1042: recipe for target 'test/log/CMakeFiles/IcdLog.dir/all' failed
make[1]: *** [test/log/CMakeFiles/IcdLog.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
root@sriov-guest:/git.co/khronos/OpenCL-ICD-Loader/build#

icd_loader_test test fails

make -C build test
make[1]: Entering directory `/software/packages/OpenCL-ICD-Loader/build'
Running tests...
Test project /software/packages/OpenCL-ICD-Loader/build
Start 1: OPENCL_ICD_LOADER_TEST
1/1 Test #1: OPENCL_ICD_LOADER_TEST ...........***Failed 0.11 sec

0% tests passed, 1 tests failed out of 1

Total Test time (real) = 0.12 sec

The following tests FAILED:
1 - OPENCL_ICD_LOADER_TEST (Failed)
Errors while running CTest
make[1]: *** [test] Error 8
make[1]: Leaving directory `/software/packages/OpenCL-ICD-Loader/build'
make: *** [test] Error 2

Running test directly gives:
ERROR: App log and stub log differ.
ICD Loader Test FAILED

Any suggestions? Using OpenCL 2.2

Improved Unit Testing Feedback

I've been experimenting with alternate ways to test the OpenCL ICD loader, with the following goals in mind:

  1. Use a modern unit testing framework.
  2. Test as much as possible without needing to manually setup a stub ICD.
  3. Automatically generate as much test content as possible.

I have something working and I'm looking for feedback before proceeding further, mostly because there is still some manual work needed to setup each test, and I won't spend the time doing this if it looks like things aren't moving in the right direction.

Some details:

  • My work is staged here:

    https://github.com/bashbaug/OpenCL-ICD-Loader/tree/improved-testing

    Most of the new code is currently in the "test_new" directory. I can create a WIP pull request if that is easier for review.

  • I'm using Googletest for now, which I am most familiar with, but I can switch to a different testing framework if desired.

  • I've managed to generate almost all of the "recorder" ICD, which I use for testing. The "recorder" ICD simply records each of the arguments it received in memory before returning. The test code can then ensure that the arguments that were recorded match the arguments that it passed. This is very similar to the existing "stub" ICD, except it records the arguments in memory rather than in a file.

  • I've managed to generate a "template" to simplify test development for each API, but some parts of the template still need to be filled in manually. If anyone has ideas to completely generate each test I'd love to hear them!

  • Things this won't test: any of the ICD discovery code, such as the code to scan the registry or /etc/OpenCL/vendors.

What I'm looking for:

  • Is this helpful? Should I keep going?

  • Are there any suggested tweaks to the test "template" before I start adding the remaining APIs?

Aside: I think we should be able to automatically generate a bunch of the ICD loader code itself, similar to the way I've generated the recorder ICD and test template. I plan to look at this at some point in the near future, but if someone else wants to take a look at it first, the gen_tester.py script could be a helpful place to start from.

Thanks!

Memory leak in icd.c

Khronos ICD library do not free allocated memory at runtime. Our team discovered a memory leak with the ICD library. Appreciate it if this could be fixed.

\icd\icd.c
You need to add free in icd.c file, the numbers are the line numbers.
183 *prevNextPointer = vendor;
184 }
185 free(vendor);
186 free(suffix);

187 KHR_ICD_TRACE("successfully added vendor %s with suffix %s\n", libraryName, suffix);
188
189 }
190
191 Done:
192
193 if (library)
194

Skip tests on build

Hello,

Is it possible to skip all tests on build?
Is there a Cmake configuration option that can disable the generation of all test(s)?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.