diff --git a/.github/workflows/presubmit.yml b/.github/workflows/presubmit.yml new file mode 100644 index 00000000..2cc221fe --- /dev/null +++ b/.github/workflows/presubmit.yml @@ -0,0 +1,764 @@ +name: Presubmit + +on: + push: + paths-ignore: + - '**/*.md' + pull_request: + paths-ignore: + - '**/*.md' + +jobs: + linux: + runs-on: ubuntu-latest + defaults: + run: + shell: bash + strategy: + matrix: + CMAKE: [3.26.4] + CMAKE_C_EXTENSIONS: + - OFF + - ON + C_COMPILER: + - gcc-11 + - gcc-13 + - clang-14 + - clang-16 + BIN: [64] + CONF: + - GEN: Unix Makefiles + CONFIG: Debug + - GEN: Unix Makefiles + CONFIG: Release + - GEN: Ninja Multi-Config + CONFIG: Release + IMAGE: + - khronosgroup/docker-images:opencl-sdk-intelcpu-ubuntu-22.04.20230717 + include: + - CMAKE: system + C_COMPILER: gcc-9 + BIN: 64 + CONF: + GEN: Unix Makefiles + CONFIG: Debug + IMAGE: khronosgroup/docker-images:opencl-sdk-intelcpu-ubuntu-20.04.20230717 + - CMAKE: system + C_COMPILER: gcc-9 + BIN: 64 + CONF: + GEN: Unix Makefiles + CONFIG: Release + IMAGE: khronosgroup/docker-images:opencl-sdk-intelcpu-ubuntu-20.04.20230717 + - CMAKE: system + C_COMPILER: gcc-9 + BIN: 32 + CONF: + GEN: Unix Makefiles + CONFIG: Debug + IMAGE: khronosgroup/docker-images:opencl-sdk-intelcpu-ubuntu-20.04.20230717 + - CMAKE: system + C_COMPILER: gcc-9 + BIN: 32 + CONF: + GEN: Unix Makefiles + CONFIG: Release + IMAGE: khronosgroup/docker-images:opencl-sdk-intelcpu-ubuntu-20.04.20230717 + container: ${{matrix.IMAGE}} + env: + CMAKE_EXE: /opt/Kitware/CMake/${{ matrix.CMAKE }}/bin/cmake + CPACK_EXE: /opt/Kitware/CMake/${{ matrix.CMAKE }}/bin/cpack + CTEST_EXE: /opt/Kitware/CMake/${{ matrix.CMAKE }}/bin/ctest + CC: ${{matrix.C_COMPILER}} + CFLAGS: -Wall -Wextra -Werror -pedantic -m${{matrix.BIN}} + DEB_INSTALLATION_PATH: /usr + + steps: + - name: Install system CMake + if: ${{matrix.CMAKE}} == 'system' + run: apt-get update -qq && apt-get install -y cmake && + echo "CMAKE_EXE=cmake" >> "$GITHUB_ENV" && + echo "CPACK_EXE=cpack" >> "$GITHUB_ENV" && + echo "CTEST_EXE=ctest" >> "$GITHUB_ENV" + + - name: Checkout OpenCL-ICD-Loader + uses: actions/checkout@v4 + + - name: Checkout OpenCL-Headers + uses: actions/checkout@v4 + with: + path: external/OpenCL-Headers + repository: KhronosGroup/OpenCL-Headers + + - name: Configure, install & package OpenCL-Headers + run: $CMAKE_EXE + -G "${{matrix.CONF.GEN}}" + `if [[ "${{matrix.CONF.GEN}}" == "Unix Makefiles" ]]; then echo "-D CMAKE_BUILD_TYPE=${{matrix.CONF.CONFIG}}"; fi` + -D CMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/external/OpenCL-Headers/install + -D CPACK_PACKAGING_INSTALL_PREFIX=$DEB_INSTALLATION_PATH + -D BUILD_TESTING=OFF + -D CMAKE_C_EXTENSIONS=${{matrix.CMAKE_C_EXTENSIONS}} + -S $GITHUB_WORKSPACE/external/OpenCL-Headers + -B $GITHUB_WORKSPACE/external/OpenCL-Headers/build && + $CMAKE_EXE + --build $GITHUB_WORKSPACE/external/OpenCL-Headers/build + --target install + --parallel `nproc` && + $CPACK_EXE + --config "$GITHUB_WORKSPACE/external/OpenCL-Headers/build/CPackConfig.cmake" + -G DEB + -C ${{matrix.CONF.CONFIG}} + -B "$GITHUB_WORKSPACE/external/OpenCL-Headers/package-deb" + + - name: Configure + run: $CMAKE_EXE + -G "${{matrix.CONF.GEN}}" + `if [[ "${{matrix.CONF.GEN}}" == "Unix Makefiles" ]]; then echo "-D CMAKE_BUILD_TYPE=${{matrix.CONF.CONFIG}}"; fi` + -D BUILD_TESTING=ON + -D CMAKE_C_EXTENSIONS=${{matrix.CMAKE_C_EXTENSIONS}} + -D CMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/install + -D CMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/external/OpenCL-Headers/install + -D CPACK_PACKAGING_INSTALL_PREFIX=$DEB_INSTALLATION_PATH + -S $GITHUB_WORKSPACE + -B $GITHUB_WORKSPACE/build + + - name: Build + run: if [[ "${{matrix.CONF.GEN}}" == "Unix Makefiles" ]]; + then + $CMAKE_EXE --build $GITHUB_WORKSPACE/build --config ${{matrix.CONF.CONFIG}} --parallel `nproc`; + else + $CMAKE_EXE --build $GITHUB_WORKSPACE/build --config Debug; + $CMAKE_EXE --build $GITHUB_WORKSPACE/build --config Release; + fi + + - name: Test + working-directory: ${{runner.workspace}}/OpenCL-ICD-Loader/build + run: if [[ "${{matrix.CONF.GEN}}" == "Unix Makefiles" ]]; + then + $CTEST_EXE --output-on-failure --no-tests=error --parallel `nproc`; + else + $CTEST_EXE --output-on-failure --no-tests=error -C Debug --parallel `nproc`; + $CTEST_EXE --output-on-failure --no-tests=error -C Release --parallel `nproc`; + fi + + - name: Package DEB + run: $CPACK_EXE + --config "$GITHUB_WORKSPACE/build/CPackConfig.cmake" + -G DEB + -C ${{matrix.CONF.CONFIG}} + -B "$GITHUB_WORKSPACE/package-deb" + + - name: Consume (DEB) + run: dpkg -i $GITHUB_WORKSPACE/external/OpenCL-Headers/package-deb/*.deb && + dpkg -i $GITHUB_WORKSPACE/package-deb/*.deb && + $CMAKE_EXE + -G "${{matrix.CONF.GEN}}" + `if [[ "${{matrix.CONF.GEN}}" == "Unix Makefiles" ]]; then echo "-D CMAKE_BUILD_TYPE=${{matrix.CONF.CONFIG}}"; fi` + -D DRIVER_STUB_PATH=$GITHUB_WORKSPACE/build/`if [[ "${{matrix.CONF.GEN}}" == "Unix Makefiles" ]]; then echo "libOpenCLDriverStub.so"; else echo "${{ matrix.CONF.CONFIG }}/libOpenCLDriverStub.so"; fi` + -S $GITHUB_WORKSPACE/test/pkgconfig/bare + -B $GITHUB_WORKSPACE/build_package && + if [[ "${{matrix.CONF.GEN}}" == "Unix Makefiles" ]]; + then + $CMAKE_EXE --build $GITHUB_WORKSPACE/build_package --config ${{matrix.CONF.CONFIG}} --parallel `nproc`; + else + $CMAKE_EXE --build $GITHUB_WORKSPACE/build_package --config Debug; + $CMAKE_EXE --build $GITHUB_WORKSPACE/build_package --config Release; + fi + + - name: Run consume test (DEB) + if: matrix.BIN != 32 + working-directory: ${{runner.workspace}}/OpenCL-ICD-Loader/build_package + run: if [[ "${{matrix.CONF.GEN}}" == "Unix Makefiles" ]]; + then + $CTEST_EXE -C ${{matrix.CONF.CONFIG}} --output-on-failure --no-tests=error --parallel `nproc`; + else + $CTEST_EXE -C Debug --output-on-failure --no-tests=error --parallel `nproc`; + $CTEST_EXE -C Release --output-on-failure --no-tests=error --parallel `nproc`; + fi + + - name: Test pkg-config (DEB) + # We expect no pre-processor and compile flags (--cflags) but we do expect link flags (--libs) + run: if [[ $(pkg-config OpenCL --cflags) ]]; + then + exit 1; + fi && + pkg-config OpenCL --libs | grep -q "\-lOpenCL" + + - name: Test cllayerinfo (DEB) + run: cllayerinfo + + - name: Uninstall (DEB) + run: apt-get remove -y "khronos-opencl-loader*" opencl-c-headers + + - name: Test install + run: $CMAKE_EXE --build $GITHUB_WORKSPACE/build --target install --config ${{matrix.CONF.CONFIG}} --parallel `nproc` + + - name: Consume (install) + run: $CMAKE_EXE + -G "${{matrix.CONF.GEN}}" + `if [[ "${{matrix.CONF.GEN}}" == "Unix Makefiles" ]]; then echo "-D CMAKE_BUILD_TYPE=${{matrix.CONF.CONFIG}}"; fi` + -D CMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/install;$GITHUB_WORKSPACE/external/OpenCL-Headers/install" + -D DRIVER_STUB_PATH=$GITHUB_WORKSPACE/build/`if [[ "${{matrix.CONF.GEN}}" == "Unix Makefiles" ]]; then echo "libOpenCLDriverStub.so"; else echo "${{ matrix.CONF.CONFIG }}/libOpenCLDriverStub.so"; fi` + -S $GITHUB_WORKSPACE/test/pkgconfig/bare + -B $GITHUB_WORKSPACE/build_install && + if [[ "${{matrix.CONF.GEN}}" == "Unix Makefiles" ]]; + then + $CMAKE_EXE --build $GITHUB_WORKSPACE/build_install --parallel `nproc`; + else + $CMAKE_EXE --build $GITHUB_WORKSPACE/build_install --config Debug; + $CMAKE_EXE --build $GITHUB_WORKSPACE/build_install --config Release; + fi + + - name: Run consume test (install) + if: matrix.BIN != 32 + working-directory: ${{runner.workspace}}/OpenCL-ICD-Loader/build_install + run: if [[ "${{matrix.CONF.GEN}}" == "Unix Makefiles" ]]; + then + $CTEST_EXE -C ${{matrix.CONF.CONFIG}} --output-on-failure --no-tests=error --parallel `nproc`; + else + $CTEST_EXE -C Debug --output-on-failure --no-tests=error --parallel `nproc`; + $CTEST_EXE -C Release --output-on-failure --no-tests=error --parallel `nproc`; + fi + + - name: Test pkg-config (install) + # We expect no pre-processor and compile flags (--cflags) but we do expect link flags (--libs) + run: export PKG_CONFIG_PATH="$GITHUB_WORKSPACE/install/lib/pkgconfig:$GITHUB_WORKSPACE/external/OpenCL-Headers/install/share/pkgconfig" && + pkg-config OpenCL --cflags | grep -q "\-I$GITHUB_WORKSPACE/external/OpenCL-Headers/install/include" && + pkg-config OpenCL --libs | grep -q "\-L$GITHUB_WORKSPACE/install/lib \-lOpenCL" + + windows: + runs-on: windows-latest + defaults: + run: + shell: pwsh + strategy: + matrix: + VER: [v142, v143, clangcl] + GEN: [Visual Studio 17 2022, Ninja Multi-Config] + BIN: [x64] + CMAKE_C_EXTENSIONS: + - OFF + - ON + exclude: + - VER: clangcl + GEN: Ninja Multi-Config + include: + - VER: v142 + GEN: Visual Studio 17 2022 + BIN: x86 + env: + NINJA_URL: https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-win.zip + NINJA_ROOT: C:\Tools\Ninja + VS_ROOT: 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise' + UseMultiToolTask: true # Better parallel MSBuild execution + EnforceProcessCountAcrossBuilds: 'true' + MultiProcMaxCount: '3' + # C4152: nonstandard extension, function/data pointer conversion in expression + # C4201: nonstandard extension used: nameless struct/union + # C4310: cast truncates constant value + CFLAGS: /W4 /WX /wd4152 /wd4201 /wd4310 + + steps: + - name: Cache Ninja install + if: matrix.GEN == 'Ninja Multi-Config' + id: ninja-install + uses: actions/cache@v4 + with: + path: | + C:\Tools\Ninja + key: ${{runner.os}}-ninja-${{env.NINJA_URL}} + + - name: Install Ninja + if: matrix.GEN == 'Ninja Multi-Config' && steps.ninja-install.outputs.cache-hit != 'true' + run: | + Invoke-WebRequest ${env:NINJA_URL} -OutFile ~\Downloads\ninja-win.zip + Expand-Archive ~\Downloads\ninja-win.zip -DestinationPath ${env:NINJA_ROOT}\ + Remove-Item ~\Downloads\* + + - name: Checkout OpenCL-ICD-Loader + uses: actions/checkout@v4 + + - name: Checkout OpenCL-Headers + uses: actions/checkout@v4 + with: + repository: KhronosGroup/OpenCL-Headers + path: external/OpenCL-Headers + + - name: Build & install OpenCL-Headers (MSBuild) + if: matrix.GEN == 'Visual Studio 17 2022' + run: | + $BIN = if('${{matrix.BIN}}' -eq 'x86') {'Win32'} else {'x64'} + & cmake ` + -G "${{matrix.GEN}}" ` + -A $BIN ` + -T ${{matrix.VER}} ` + -D BUILD_TESTING=OFF ` + -D CMAKE_C_EXTENSIONS=${{matrix.CMAKE_C_EXTENSIONS}} ` + -D CMAKE_INSTALL_PREFIX=${env:GITHUB_WORKSPACE}\external\OpenCL-Headers\install ` + -S ${env:GITHUB_WORKSPACE}\external\OpenCL-Headers ` + -B ${env:GITHUB_WORKSPACE}\external\OpenCL-Headers\build + if ($LASTEXITCODE -ne 0) { throw "Configuring OpenCL-Headers failed." } + & cmake ` + --build "${env:GITHUB_WORKSPACE}\external\OpenCL-Headers\build" ` + --target install ` + -- ` + /verbosity:minimal ` + /maxCpuCount ` + /noLogo + if ($LASTEXITCODE -ne 0) { throw "Building OpenCL-Headers failed." } + + - name: Build & install OpenCL-Headers (Ninja Multi-Config) + if: matrix.GEN == 'Ninja Multi-Config' + run: | + $VER = switch ('${{matrix.VER}}') { ` + 'v142' {'14.2'} ` + 'v143' {'14.4'} } + Import-Module "${env:VS_ROOT}\Common7\Tools\Microsoft.VisualStudio.DevShell.dll" + Enter-VsDevShell -VsInstallPath ${env:VS_ROOT} -SkipAutomaticLocation -DevCmdArguments "-host_arch=x64 -arch=${{matrix.BIN}} -vcvars_ver=$VER" + & cmake ` + -G "${{matrix.GEN}}" ` + -D CMAKE_MAKE_PROGRAM="${env:NINJA_ROOT}\ninja.exe" ` + -D BUILD_TESTING=OFF ` + -D CMAKE_C_EXTENSIONS=${{matrix.CMAKE_C_EXTENSIONS}} ` + -D CMAKE_INSTALL_PREFIX=${env:GITHUB_WORKSPACE}\external\OpenCL-Headers\install ` + -S ${env:GITHUB_WORKSPACE}\external\OpenCL-Headers ` + -B ${env:GITHUB_WORKSPACE}\external\OpenCL-Headers\build + if ($LASTEXITCODE -ne 0) { throw "Configuring OpenCL-Headers failed." } + & cmake ` + --build "${env:GITHUB_WORKSPACE}\external\OpenCL-Headers\build" ` + --target install ` + -- ` + -j ${env:NUMBER_OF_PROCESSORS} + if ($LASTEXITCODE -ne 0) { throw "Building OpenCL-Headers failed." } + + - name: Configure (MSBuild) + if: matrix.GEN == 'Visual Studio 17 2022' + run: | + $BIN = if('${{matrix.BIN}}' -eq 'x86') {'Win32'} else {'x64'} + & cmake ` + -G "${{matrix.GEN}}" ` + -A $BIN ` + -T ${{matrix.VER}} ` + -D BUILD_TESTING=ON ` + -D CMAKE_C_EXTENSIONS=${{matrix.CMAKE_C_EXTENSIONS}} ` + -D CMAKE_INSTALL_PREFIX=${env:GITHUB_WORKSPACE}\install ` + -D CMAKE_PREFIX_PATH=${env:GITHUB_WORKSPACE}\external\OpenCL-Headers\install ` + -S ${env:GITHUB_WORKSPACE} ` + -B ${env:GITHUB_WORKSPACE}\build + if ($LASTEXITCODE -ne 0) { throw "Configuring OpenCL-ICD-Loader failed." } + + - name: Configure (Ninja Multi-Config) + if: matrix.GEN == 'Ninja Multi-Config' + run: | + $VER = switch ('${{matrix.VER}}') { ` + 'v142' {'14.2'} ` + 'v143' {'14.4'} } + Import-Module "${env:VS_ROOT}\Common7\Tools\Microsoft.VisualStudio.DevShell.dll" + Enter-VsDevShell -VsInstallPath ${env:VS_ROOT} -SkipAutomaticLocation -DevCmdArguments "-host_arch=x64 -arch=${{matrix.BIN}} -vcvars_ver=$VER" + & cmake ` + -G "${{matrix.GEN}}" ` + -D CMAKE_MAKE_PROGRAM="${env:NINJA_ROOT}\ninja.exe" ` + -D BUILD_TESTING=ON ` + -D CMAKE_C_EXTENSIONS=${{matrix.CMAKE_C_EXTENSIONS}} ` + -D CMAKE_EXE_LINKER_FLAGS=/INCREMENTAL ` + -D CMAKE_INSTALL_PREFIX=${env:GITHUB_WORKSPACE}\install ` + -D CMAKE_PREFIX_PATH=${env:GITHUB_WORKSPACE}\external\OpenCL-Headers\install ` + -S ${env:GITHUB_WORKSPACE} ` + -B ${env:GITHUB_WORKSPACE}\build + if ($LASTEXITCODE -ne 0) { throw "Configuring OpenCL-ICD-Loader failed." } + + - name: Build (MSBuild) + if: matrix.GEN == 'Visual Studio 17 2022' + run: | + foreach ($Config in 'Release','Debug') { + & cmake ` + --build "${env:GITHUB_WORKSPACE}\build" ` + --config $Config ` + -- ` + /verbosity:minimal ` + /maxCpuCount ` + /noLogo + if ($LASTEXITCODE -ne 0) { throw "Building OpenCL-ICD-Loader in $Config failed." } + } + + - name: Build (Ninja Multi-Config) + if: matrix.GEN == 'Ninja Multi-Config' + run: | + $VER = switch ('${{matrix.VER}}') { ` + 'v142' {'14.2'} ` + 'v143' {'14.4'} } + Import-Module "${env:VS_ROOT}\Common7\Tools\Microsoft.VisualStudio.DevShell.dll" + Enter-VsDevShell -VsInstallPath ${env:VS_ROOT} -SkipAutomaticLocation -DevCmdArguments "-host_arch=x64 -arch=${{matrix.BIN}} -vcvars_ver=$VER" + foreach ($Config in 'Release','Debug') { + & cmake ` + --build "${env:GITHUB_WORKSPACE}\build" ` + --config $Config ` + -- ` + -j ${env:NUMBER_OF_PROCESSORS} + if ($LASTEXITCODE -ne 0) { throw "Building OpenCL-ICD-Loader in $Config failed." } + } + + - name: Test + working-directory: ${{runner.workspace}}/OpenCL-ICD-Loader/build + run: | + $REG = if('${{matrix.BIN}}' -eq 'x64') {"reg"} else {"${env:SystemRoot}\Syswow64\reg.exe"} + $KEY_NAME = "HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\OpenCL\Vendors" + foreach ($Config in 'Release','Debug') { + $VALUE_NAME = "${env:GITHUB_WORKSPACE}/build/$Config/OpenCLDriverStub.dll" + $VALUE_NAME_2 = "${env:GITHUB_WORKSPACE}/build/$Config/OpenCLDriverStubICD2.dll" + & $REG ADD $KEY_NAME /v $VALUE_NAME /t REG_DWORD /d 0 + if ($LASTEXITCODE -ne 0) { throw "Editing registry failed." } + & $REG ADD $KEY_NAME /v $VALUE_NAME_2 /t REG_DWORD /d 0 + if ($LASTEXITCODE -ne 0) { throw "Editing registry failed." } + & ctest -C $Config --output-on-failure --no-tests=error --parallel ${env:NUMBER_OF_PROCESSORS} + if ($LASTEXITCODE -ne 0) { throw "Testing OpenCL-ICD-Loader in $Config failed." } + & $REG DELETE $KEY_NAME /v $VALUE_NAME_2 /f + if ($LASTEXITCODE -ne 0) { throw "Editing registry failed." } + & $REG DELETE $KEY_NAME /v $VALUE_NAME /f + if ($LASTEXITCODE -ne 0) { throw "Editing registry failed." } + } + + - name: Install + run: | + & cmake ` + --build "${env:GITHUB_WORKSPACE}\build" ` + --config Release ` + --target install + if ($LASTEXITCODE -ne 0) { throw "Installing OpenCL-ICD-Loader failed." } + + - name: "Consume (MSBuild standalone): Configure/Build/Test" + if: matrix.GEN == 'Visual Studio 17 2022' + run: | + $BIN = if('${{matrix.BIN}}' -eq 'x86') {'Win32'} else {'x64'} + & cmake ` + -G '${{matrix.GEN}}' ` + -A $BIN ` + -T ${{matrix.VER}} ` + -D CMAKE_C_EXTENSIONS=${{matrix.CMAKE_C_EXTENSIONS}} ` + -D CMAKE_EXE_LINKER_FLAGS=/INCREMENTAL ` + -D CMAKE_PREFIX_PATH="${env:GITHUB_WORKSPACE}\external\OpenCL-Headers\install;${env:GITHUB_WORKSPACE}\install" ` + -D DRIVER_STUB_PATH="${env:GITHUB_WORKSPACE}\build\Release\OpenCLDriverStub.dll" ` + -S "${env:GITHUB_WORKSPACE}\test\pkgconfig\bare" ` + -B "${env:GITHUB_WORKSPACE}\downstream\pkgconfig\bare" + if ($LASTEXITCODE -ne 0) { throw "Configuring OpenCL-ICD-Loader standalone consume test failed." } + $REG = if('${{matrix.BIN}}' -eq 'x64') {"reg"} else {"${env:SystemRoot}\Syswow64\reg.exe"} + $KEY_NAME = "HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\OpenCL\Vendors" + $VALUE_NAME = "${env:GITHUB_WORKSPACE}/build/Release/OpenCLDriverStub.dll" + $VALUE_NAME_2 = "${env:GITHUB_WORKSPACE}/build/Release/OpenCLDriverStubICD2.dll" + & $REG ADD $KEY_NAME /v $VALUE_NAME /t REG_DWORD /d 0 + if ($LASTEXITCODE -ne 0) { throw "Editing registry failed." } + & $REG ADD $KEY_NAME /v $VALUE_NAME_2 /t REG_DWORD /d 0 + if ($LASTEXITCODE -ne 0) { throw "Editing registry failed." } + foreach ($Config in 'Release','Debug') { + & cmake ` + --build "${env:GITHUB_WORKSPACE}\downstream\pkgconfig\bare" ` + --config $Config + if ($LASTEXITCODE -ne 0) { throw "Building OpenCL-ICD-Loader standalone consume test in $Config failed." } + & cd ${env:GITHUB_WORKSPACE}\downstream\pkgconfig\bare + & ctest --output-on-failure --no-tests=error -C $Config + if ($LASTEXITCODE -ne 0) { throw "Running OpenCL-ICD-Loader standalone consume test in $Config failed." } + } + & $REG DELETE $KEY_NAME /v $VALUE_NAME /f + if ($LASTEXITCODE -ne 0) { throw "Editing registry failed." } + & $REG DELETE $KEY_NAME /v $VALUE_NAME_2 /f + if ($LASTEXITCODE -ne 0) { throw "Editing registry failed." } + + - name: "Consume (Ninja-Multi-Config standalone): Configure/Build/Test" + if: matrix.GEN == 'Ninja Multi-Config' + run: | + $VER = switch ('${{matrix.VER}}') { ` + 'v142' {'14.2'} ` + 'v143' {'14.4'} } + Import-Module "${env:VS_ROOT}\Common7\Tools\Microsoft.VisualStudio.DevShell.dll" + Enter-VsDevShell -VsInstallPath ${env:VS_ROOT} -SkipAutomaticLocation -DevCmdArguments "-host_arch=x64 -arch=${{matrix.BIN}} -vcvars_ver=$VER" + & cmake ` + -G '${{matrix.GEN}}' ` + -D CMAKE_MAKE_PROGRAM="${env:NINJA_ROOT}\ninja.exe" ` + -D CMAKE_C_EXTENSIONS=${{matrix.CMAKE_C_EXTENSIONS}} ` + -D CMAKE_EXE_LINKER_FLAGS=/INCREMENTAL ` + -D CMAKE_PREFIX_PATH="${env:GITHUB_WORKSPACE}\external\OpenCL-Headers\install;${env:GITHUB_WORKSPACE}\install" ` + -D DRIVER_STUB_PATH="${env:GITHUB_WORKSPACE}\build\Release\OpenCLDriverStub.dll" ` + -S "${env:GITHUB_WORKSPACE}\test\pkgconfig\bare" ` + -B "${env:GITHUB_WORKSPACE}\downstream\pkgconfig\bare" + if ($LASTEXITCODE -ne 0) { throw "Configuring OpenCL-ICD-Loader standalone consume test failed." } + $REG = if('${{matrix.BIN}}' -eq 'x64') {"reg"} else {"${env:SystemRoot}\Syswow64\reg.exe"} + $KEY_NAME = "HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\OpenCL\Vendors" + $VALUE_NAME = "${env:GITHUB_WORKSPACE}/build/Release/OpenCLDriverStub.dll" + $VALUE_NAME_2 = "${env:GITHUB_WORKSPACE}/build/Release/OpenCLDriverStubICD2.dll" + & $REG ADD $KEY_NAME /v $VALUE_NAME /t REG_DWORD /d 0 + if ($LASTEXITCODE -ne 0) { throw "Editing registry failed." } + & $REG ADD $KEY_NAME /v $VALUE_NAME_2 /t REG_DWORD /d 0 + if ($LASTEXITCODE -ne 0) { throw "Editing registry failed." } + foreach ($Config in 'Release','Debug') { + & cmake ` + --build "${env:GITHUB_WORKSPACE}\downstream\pkgconfig\bare" ` + --config $Config + if ($LASTEXITCODE -ne 0) { throw "Building OpenCL-ICD-Loader standalone consume test in $Config failed." } + & cd ${env:GITHUB_WORKSPACE}\downstream\pkgconfig\bare + & ctest --output-on-failure --no-tests=error -C $Config + if ($LASTEXITCODE -ne 0) { throw "Running OpenCL-ICD-Loader standalone consume test in $Config failed." } + } + & $REG DELETE $KEY_NAME /v $VALUE_NAME /f + if ($LASTEXITCODE -ne 0) { throw "Editing registry failed." } + & $REG DELETE $KEY_NAME /v $VALUE_NAME_2 /f + if ($LASTEXITCODE -ne 0) { throw "Editing registry failed." } + + - name: Consume (Emulate SDK presence) + run: | + New-Item -Type Directory -Path ${env:GITHUB_WORKSPACE}\install\share\cmake\OpenCL + $workspace = ${env:GITHUB_WORKSPACE}.replace("\", "/") + New-Item -Type File -Path ${env:GITHUB_WORKSPACE}\install\share\cmake\OpenCL\OpenCLConfig.cmake -Value "include(`"$workspace/external/OpenCL-Headers/install/share/cmake/OpenCLHeaders/OpenCLHeadersTargets.cmake`")`r`ninclude(`"`${CMAKE_CURRENT_LIST_DIR}/../OpenCLICDLoader/OpenCLICDLoaderTargets.cmake`")" + + - name: "Consume (MSBuild SDK): Configure/Build/Test" + if: matrix.GEN == 'Visual Studio 17 2022' + run: | + $BIN = if('${{matrix.BIN}}' -eq 'x86') {'Win32'} else {'x64'} + & cmake ` + -G '${{matrix.GEN}}' ` + -A $BIN ` + -T ${{matrix.VER}} ` + -D CMAKE_C_EXTENSIONS=${{matrix.CMAKE_C_EXTENSIONS}} ` + -D CMAKE_EXE_LINKER_FLAGS=/INCREMENTAL ` + -D CMAKE_PREFIX_PATH="${env:GITHUB_WORKSPACE}\external\OpenCL-Headers\install;${env:GITHUB_WORKSPACE}\install" ` + -D DRIVER_STUB_PATH="${env:GITHUB_WORKSPACE}\build\Release\OpenCLDriverStub.dll" ` + -S "${env:GITHUB_WORKSPACE}\test\pkgconfig\sdk" ` + -B "${env:GITHUB_WORKSPACE}\downstream\pkgconfig\sdk" + if ($LASTEXITCODE -ne 0) { throw "Configuring OpenCL-ICD-Loader in-SDK consume test failed." } + $REG = if('${{matrix.BIN}}' -eq 'x64') {"reg"} else {"${env:SystemRoot}\Syswow64\reg.exe"} + $KEY_NAME = "HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\OpenCL\Vendors" + $VALUE_NAME = "${env:GITHUB_WORKSPACE}/build/Release/OpenCLDriverStub.dll" + $VALUE_NAME_2 = "${env:GITHUB_WORKSPACE}/build/Release/OpenCLDriverStubICD2.dll" + & $REG ADD $KEY_NAME /v $VALUE_NAME /t REG_DWORD /d 0 + if ($LASTEXITCODE -ne 0) { throw "Editing registry failed." } + & $REG ADD $KEY_NAME /v $VALUE_NAME_2 /t REG_DWORD /d 0 + if ($LASTEXITCODE -ne 0) { throw "Editing registry failed." } + foreach ($Config in 'Release','Debug') { + & cmake ` + --build "${env:GITHUB_WORKSPACE}\downstream\pkgconfig\sdk" ` + --config $Config + if ($LASTEXITCODE -ne 0) { throw "Building OpenCL-ICD-Loader in-SDK consume test in $Config failed." } + & cd ${env:GITHUB_WORKSPACE}\downstream\pkgconfig\sdk + & ctest --output-on-failure --no-tests=error -C $Config + if ($LASTEXITCODE -ne 0) { throw "Running OpenCL-ICD-Loader in-SDK consume test in $Config failed." } + } + & $REG DELETE $KEY_NAME /v $VALUE_NAME /f + if ($LASTEXITCODE -ne 0) { throw "Editing registry failed." } + & $REG DELETE $KEY_NAME /v $VALUE_NAME_2 /f + if ($LASTEXITCODE -ne 0) { throw "Editing registry failed." } + + - name: "Consume (Ninja-Multi-Config SDK): Configure/Build/Test" + if: matrix.GEN == 'Ninja Multi-Config' + run: | + $VER = switch ('${{matrix.VER}}') { ` + 'v142' {'14.2'} ` + 'v143' {'14.4'} } + Import-Module "${env:VS_ROOT}\Common7\Tools\Microsoft.VisualStudio.DevShell.dll" + Enter-VsDevShell -VsInstallPath ${env:VS_ROOT} -SkipAutomaticLocation -DevCmdArguments "-host_arch=x64 -arch=${{matrix.BIN}} -vcvars_ver=$VER" + & cmake ` + -G '${{matrix.GEN}}' ` + -D CMAKE_MAKE_PROGRAM="${env:NINJA_ROOT}\ninja.exe" ` + -D CMAKE_C_EXTENSIONS=${{matrix.CMAKE_C_EXTENSIONS}} ` + -D CMAKE_EXE_LINKER_FLAGS=/INCREMENTAL ` + -D CMAKE_PREFIX_PATH="${env:GITHUB_WORKSPACE}\external\OpenCL-Headers\install;${env:GITHUB_WORKSPACE}\install" ` + -D DRIVER_STUB_PATH="${env:GITHUB_WORKSPACE}\build\Release\OpenCLDriverStub.dll" ` + -S "${env:GITHUB_WORKSPACE}\test\pkgconfig\sdk" ` + -B "${env:GITHUB_WORKSPACE}\downstream\pkgconfig\sdk" + if ($LASTEXITCODE -ne 0) { throw "Configuring OpenCL-ICD-Loader in-SDK consume test failed." } + $REG = if('${{matrix.BIN}}' -eq 'x64') {"reg"} else {"${env:SystemRoot}\Syswow64\reg.exe"} + $KEY_NAME = "HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\OpenCL\Vendors" + $VALUE_NAME = "${env:GITHUB_WORKSPACE}/build/Release/OpenCLDriverStub.dll" + $VALUE_NAME_2 = "${env:GITHUB_WORKSPACE}/build/Release/OpenCLDriverStubICD2.dll" + & $REG ADD $KEY_NAME /v $VALUE_NAME /t REG_DWORD /d 0 + if ($LASTEXITCODE -ne 0) { throw "Editing registry failed." } + & $REG ADD $KEY_NAME /v $VALUE_NAME_2 /t REG_DWORD /d 0 + if ($LASTEXITCODE -ne 0) { throw "Editing registry failed." } + foreach ($Config in 'Release','Debug') { + & cmake ` + --build "${env:GITHUB_WORKSPACE}\downstream\pkgconfig\sdk" ` + --config $Config + if ($LASTEXITCODE -ne 0) { throw "Building OpenCL-ICD-Loader in-SDK consume test in $Config failed." } + & cd ${env:GITHUB_WORKSPACE}\downstream\pkgconfig\sdk + & ctest --output-on-failure --no-tests=error -C $Config + if ($LASTEXITCODE -ne 0) { throw "Running OpenCL-ICD-Loader in-SDK consume test in $Config failed." } + } + & $REG DELETE $KEY_NAME /v $VALUE_NAME /f + if ($LASTEXITCODE -ne 0) { throw "Editing registry failed." } + & $REG DELETE $KEY_NAME /v $VALUE_NAME_2 /f + if ($LASTEXITCODE -ne 0) { throw "Editing registry failed." } + + macos: + runs-on: macos-latest + defaults: + run: + shell: bash + strategy: + matrix: + C_COMPILER: + - /usr/bin/clang + # Disabled due to problems with __has_cpp_attribute + # See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114007 + # - gcc-11 + # Disabled due to problems with the __API_AVAILABLE macro + # - gcc-13 + CMAKE_C_EXTENSIONS: + - OFF + - ON + GEN: + - Xcode + - Ninja Multi-Config + exclude: + # These entries are excluded, since XCode selects its own compiler + - C_COMPILER: gcc-11 + GEN: Xcode + - C_COMPILER: gcc-13 + GEN: Xcode + env: + CFLAGS: -Wall -Wextra -pedantic -Werror + CC: ${{ matrix.C_COMPILER }} + + steps: + - name: Checkout OpenCL-ICD-Loader + uses: actions/checkout@v4 + + - name: Checkout OpenCL-Headers + uses: actions/checkout@v4 + with: + repository: KhronosGroup/OpenCL-Headers + path: external/OpenCL-Headers + + - name: Create Build Environment + run: | + # Install Ninja only if it's the selected generator and it's not available. + if [[ "${{matrix.GEN}}" == "Ninja Multi-Config" && ! `which ninja` ]]; then brew install ninja; fi && + if [[ ! `which pkg-config` ]]; then brew install pkg-config; fi && + cmake --version + + - name: Build & install OpenCL-Headers + run: cmake + -G "${{matrix.GEN}}" + -D BUILD_TESTING=OFF + -D CMAKE_C_EXTENSIONS=${{matrix.CMAKE_C_EXTENSIONS}} + -D CMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/external/OpenCL-Headers/install + -S $GITHUB_WORKSPACE/external/OpenCL-Headers + -B $GITHUB_WORKSPACE/external/OpenCL-Headers/build && + cmake + --build $GITHUB_WORKSPACE/external/OpenCL-Headers/build + --target install + --config Release + --parallel `sysctl -n hw.logicalcpu` + + - name: Configure + run: cmake + -G "${{matrix.GEN}}" + -D BUILD_TESTING=ON + -D CMAKE_C_EXTENSIONS=${{matrix.CMAKE_C_EXTENSIONS}} + -D CMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/install + -D CMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/external/OpenCL-Headers/install + -S $GITHUB_WORKSPACE + -B $GITHUB_WORKSPACE/build + + - name: Build + run: | + cmake --build $GITHUB_WORKSPACE/build --config Release --parallel `sysctl -n hw.logicalcpu` + cmake --build $GITHUB_WORKSPACE/build --config Debug --parallel `sysctl -n hw.logicalcpu` + + - name: Test + working-directory: ${{runner.workspace}}/OpenCL-ICD-Loader/build + run: | + ctest -C Release --output-on-failure --no-tests=error --parallel `sysctl -n hw.logicalcpu` + ctest -C Debug --output-on-failure --no-tests=error --parallel `sysctl -n hw.logicalcpu` + + - name: Test install + run: | + cmake --build $GITHUB_WORKSPACE/build --config Release --target install + + - name: Consume (install) + run: cmake + -G "${{matrix.GEN}}" + -D CMAKE_C_EXTENSIONS=${{matrix.CMAKE_C_EXTENSIONS}} + -D CMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/external/OpenCL-Headers/install;$GITHUB_WORKSPACE/install" + -S $GITHUB_WORKSPACE/test/pkgconfig/bare + -B $GITHUB_WORKSPACE/build_install && + cmake --build $GITHUB_WORKSPACE/build_install --config Release --parallel `sysctl -n hw.logicalcpu` && + cmake --build $GITHUB_WORKSPACE/build_install --config Debug --parallel `sysctl -n hw.logicalcpu` + + - name: Test pkg-config + run: | + export PKG_CONFIG_PATH=$GITHUB_WORKSPACE/install/lib/pkgconfig:$GITHUB_WORKSPACE/external/OpenCL-Headers/install/share/pkgconfig && + pkg-config OpenCL --cflags | grep -q "\-I$GITHUB_WORKSPACE/external/OpenCL-Headers/install/include" && + pkg-config OpenCL --libs | grep -q "\-L$GITHUB_WORKSPACE/install/lib -lOpenCL" + + - name: Consume pkg-config + run: export PKG_CONFIG_PATH=$GITHUB_WORKSPACE/install/lib/pkgconfig:$GITHUB_WORKSPACE/external/OpenCL-Headers/install/share/pkgconfig && + cmake + -G "${{matrix.GEN}}" + -D CMAKE_C_EXTENSIONS=${{matrix.CMAKE_C_EXTENSIONS}} + -D CMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/external/OpenCL-Headers/install" + -D DRIVER_STUB_PATH=$GITHUB_WORKSPACE/build/Release/libOpenCLDriverStub.dylib + -B $GITHUB_WORKSPACE/build/downstream/pkgconfig + -S $GITHUB_WORKSPACE/test/pkgconfig/pkgconfig && + cmake --build $GITHUB_WORKSPACE/build/downstream/pkgconfig --config Release --parallel `sysctl -n hw.logicalcpu` && + cmake --build $GITHUB_WORKSPACE/build/downstream/pkgconfig --config Debug --parallel `sysctl -n hw.logicalcpu` && + cd $GITHUB_WORKSPACE/build/downstream/pkgconfig && + ctest -C Release --output-on-failure --no-tests=error --parallel `sysctl -n hw.logicalcpu` && + ctest -C Debug --output-on-failure --no-tests=error --parallel `sysctl -n hw.logicalcpu` + + android: + runs-on: ubuntu-latest + defaults: + run: + shell: bash + strategy: + matrix: + ABI: + - arm64-v8a + - x86_64 + API_LEVEL: + - android-19 + - android-33 + CONFIG: + - Debug + - Release + env: + CFLAGS: -Wall -Wextra -pedantic -Werror + steps: + - name: Checkout OpenCL-ICD-Loader + uses: actions/checkout@v4 + + - name: Checkout OpenCL-Headers + uses: actions/checkout@v4 + with: + repository: KhronosGroup/OpenCL-Headers + path: external/OpenCL-Headers + + - name: Configure & install OpenCL-Headers + run: cmake + -G "Unix Makefiles" + -D CMAKE_BUILD_TYPE=${{matrix.CONFIG}} + -D CMAKE_C_EXTENSIONS=${{matrix.CMAKE_C_EXTENSIONS}} + -D CMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/external/OpenCL-Headers/install + -D BUILD_TESTING=OFF + -S $GITHUB_WORKSPACE/external/OpenCL-Headers + -B $GITHUB_WORKSPACE/external/OpenCL-Headers/build && + cmake + --build $GITHUB_WORKSPACE/external/OpenCL-Headers/build + --target install + -- + -j`nproc` + + - name: Configure + run: cmake + -G "Unix Makefiles" + -D BUILD_TESTING=ON + -D CMAKE_C_EXTENSIONS=${{matrix.CMAKE_C_EXTENSIONS}} + -D CMAKE_BUILD_TYPE=${{matrix.CONFIG}} + -D CMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake + -D ANDROID_ABI=${{matrix.ABI}} + -D ANDROID_PLATFORM=${{matrix.API_LEVEL}} + -D CMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY + -D CMAKE_FIND_ROOT_PATH=$GITHUB_WORKSPACE/external/OpenCL-Headers/install + -S $GITHUB_WORKSPACE + -B $GITHUB_WORKSPACE/build + + - name: Build + run: cmake --build $GITHUB_WORKSPACE/build --parallel `nproc` diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..06a8c283 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,74 @@ +name: Release + +on: + push: + tags: + - "v*" +env: + distroseries: jammy + +jobs: + release: + if: false + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - name: Add PPA + run: sudo add-apt-repository -y ppa:${{ vars.PPA }} + + - name: Install prerequisites + run: sudo apt-get update -qq && sudo apt-get install -y cmake devscripts debhelper-compat=13 opencl-c-headers + + - name: Import GPG signing key + run: echo "${{ secrets.DEB_SIGNING_KEY }}" | gpg --import + + - name: Download and extract source code + run: | + wget -O $GITHUB_WORKSPACE/source.orig.tar.gz https://github.com/$GITHUB_REPOSITORY/archive/refs/tags/$GITHUB_REF_NAME.tar.gz + tar -xvf $GITHUB_WORKSPACE/source.orig.tar.gz + + - name: Configure project out-of-tree + run: cmake + -S $GITHUB_WORKSPACE/OpenCL-ICD-Loader* + -B $GITHUB_WORKSPACE/../build + -D CMAKE_BUILD_TYPE=Release + -D CMAKE_INSTALL_PREFIX=/usr + -D BUILD_TESTING=OFF + -D LATEST_RELEASE_VERSION=$GITHUB_REF_NAME + -D CPACK_DEBIAN_PACKAGE_MAINTAINER="${{ vars.DEB_MAINTAINER }}" + -D DEBIAN_VERSION_SUFFIX=${{ vars.DEB_VERSION_SUFFIX }} + + - name: Generate packaging scripts + run: cmake + -D CMAKE_CACHE_PATH=$GITHUB_WORKSPACE/../build/CMakeCache.txt + -D ORIG_ARCHIVE=$GITHUB_WORKSPACE/source.orig.tar.gz + -D LATEST_RELEASE_VERSION=$GITHUB_REF_NAME + -D DEBIAN_DISTROSERIES=${{ env.distroseries }} + -D DEBIAN_PACKAGE_MAINTAINER="${{ vars.DEB_MAINTAINER }}" + -D DEBIAN_VERSION_SUFFIX=${{ vars.DEB_VERSION_SUFFIX }} + -P $GITHUB_WORKSPACE/OpenCL-ICD-Loader*/cmake/DebSourcePkg.cmake + + - name: Build source package + run: | + cd $GITHUB_WORKSPACE/OpenCL-ICD-Loader*/ + debuild -S -sa + + - name: Build binary package + run: cpack + -G DEB + -C Release + -B $GITHUB_WORKSPACE/../build + --config $GITHUB_WORKSPACE/../build/CPackConfig.cmake + + # The following step does not depend on the previous step "Build binary package", + # but if the binary package build is unsuccessful, it is better not to push the + # source packages to the PPA + - name: Push source package to the PPA + run: dput ppa:${{ vars.PPA }} $GITHUB_WORKSPACE/*source.changes + + - name: Create GitHub release + uses: softprops/action-gh-release@v1 + with: + files: ${{ github.workspace }}/../build/*.deb diff --git a/.gitignore b/.gitignore index 9bb7c139..8a9dc701 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,22 @@ +# Build dir +[Bb]uild/ + +# Install dir +[Ii]nstall/ + +# External dir +[Ee]xternal/ + +# Package dir +[Pp]ackage[-_\s\d]*/ + +# Tackage dir +[T]esting/ + +# inc subdirs inc/CL/ inc/EGL/ inc/KHR/ -build/ + +# Visual Studio Code +.vscode diff --git a/CMakeLists.txt b/CMakeLists.txt index 691d1370..1ce37cff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,18 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 3.16) -project (OPENCL_ICD_LOADER) +# Include guard for including this project multiple times +if(TARGET OpenCL) + return() +endif() +project (OpenCL-ICD-Loader + VERSION 3.0 + LANGUAGES C) + +find_package (Threads REQUIRED) + +set(CMAKE_C_STANDARD 99) +set(CMAKE_C_STANDARD_REQUIRED ON) # The option below allows building the ICD Loader library as a shared library # (ON, default) or a static library (OFF). # @@ -30,42 +41,259 @@ project (OPENCL_ICD_LOADER) # may be useful to simplify the build and distribution of the application. E.g. # in test farms, or in cases where the end-user system configs are known in # advance. Use it with discretion. -option (BUILD_SHARED_LIBS "Build shared libs" ON) +if(DEFINED BUILD_SHARED_LIBS) + set(OPENCL_ICD_LOADER_BUILD_SHARED_LIBS_DEFAULT ${BUILD_SHARED_LIBS}) +else() + set(OPENCL_ICD_LOADER_BUILD_SHARED_LIBS_DEFAULT ON) +endif() +option(OPENCL_ICD_LOADER_BUILD_SHARED_LIBS "Build OpenCL ICD Loader as shared library" ${OPENCL_ICD_LOADER_BUILD_SHARED_LIBS_DEFAULT}) + +# This option enables/disables support for OpenCL layers in the ICD loader. +# It is currently needed default while the specification is being formalized, +# and to study the performance impact. +option (ENABLE_OPENCL_LAYERS "Enable OpenCL Layers" ON) +option (ENABLE_OPENCL_LOADER_MANAGED_DISPATCH "Enable OpenCL Loader managed dispatch" ON) +include(CMakeDependentOption) +cmake_dependent_option(ENABLE_OPENCL_LAYERINFO "Enable building cllayerinfo tool" ON ENABLE_OPENCL_LAYERS OFF) + +include(GNUInstallDirs) -set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +include(CheckFunctionExists) +include(JoinPaths) +include(Package) -set (OPENCL_ICD_LOADER_SOURCES icd.c icd_dispatch.c) +check_function_exists(secure_getenv HAVE_SECURE_GETENV) +check_function_exists(__secure_getenv HAVE___SECURE_GETENV) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/loader/icd_cmake_config.h.in + ${CMAKE_CURRENT_BINARY_DIR}/icd_cmake_config.h) + +set (OPENCL_ICD_LOADER_SOURCES + loader/icd.c + loader/icd.h + loader/icd_version.h + loader/icd_dispatch.c + loader/icd_dispatch.h + loader/icd_dispatch_generated.c + loader/icd_envvars.h + loader/icd_platform.h) +include_directories (include) if (WIN32) - list (APPEND OPENCL_ICD_LOADER_SOURCES icd_windows.c icd_windows_hkr.c OpenCL.def OpenCL.rc) - include_directories ($ENV{DXSDK_DIR}/Include) + list (APPEND OPENCL_ICD_LOADER_SOURCES + loader/windows/adapter.h + loader/windows/icd_windows.c + loader/windows/icd_windows.h + loader/windows/icd_windows_dxgk.c + loader/windows/icd_windows_dxgk.h + loader/windows/icd_windows_envvars.c + loader/windows/icd_windows_hkr.c + loader/windows/icd_windows_hkr.h + loader/windows/icd_windows_apppackage.c + loader/windows/icd_windows_apppackage.h + loader/windows/OpenCL.rc) + # Only add the DXSDK include directory if the environment variable is + # defined. Since the DXSDK has merged into the Windows SDK, this is + # only required in rare cases. + if (DEFINED ENV{DXSDK_DIR} AND NOT (MINGW OR MSYS OR CYGWIN)) + include_directories ($ENV{DXSDK_DIR}/Include) + endif () + + # For mingw-i686 builds only we need a special .def file with stdcall + # exports. In all other cases we can use a standard .def file. + if ((CMAKE_SIZEOF_VOID_P EQUAL 4) AND (MINGW OR MSYS OR CYGWIN)) + list (APPEND OPENCL_ICD_LOADER_SOURCES loader/windows/OpenCL-mingw-i686.def) + else () + list (APPEND OPENCL_ICD_LOADER_SOURCES loader/windows/OpenCL.def) + endif () else () - list (APPEND OPENCL_ICD_LOADER_SOURCES icd_linux.c icd_exports.map) + list (APPEND OPENCL_ICD_LOADER_SOURCES + loader/linux/icd_linux.c + loader/linux/icd_linux_envvars.c + loader/linux/icd_exports.map) endif () -# Change this to point to a directory containing OpenCL header directory "CL" -# OR copy OpenCL headers to ./inc/CL/ -if (NOT DEFINED OPENCL_INCLUDE_DIRS) - set (OPENCL_INCLUDE_DIRS ./inc) -endif () +set (OPENCL_ICD_LOADER_HEADERS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/inc" CACHE PATH "Path to OpenCL Headers") + +if (${OPENCL_ICD_LOADER_BUILD_SHARED_LIBS}) + add_library (OpenCL SHARED ${OPENCL_ICD_LOADER_SOURCES}) +else() + add_library (OpenCL STATIC ${OPENCL_ICD_LOADER_SOURCES}) +endif() -include_directories (${OPENCL_INCLUDE_DIRS}) +add_library (OpenCL::OpenCL ALIAS OpenCL) -add_library (OpenCL SHARED ${OPENCL_ICD_LOADER_SOURCES}) -set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1") +set_target_properties (OpenCL PROPERTIES VERSION 1\.0\.0 SOVERSION "1") if (WIN32) - target_link_libraries (OpenCL cfgmgr32.lib) + target_link_libraries (OpenCL PRIVATE cfgmgr32.lib runtimeobject.lib) + + # Generate a DLL without a "lib" prefix for mingw. + if (MINGW OR MSYS OR CYGWIN) + set_target_properties(OpenCL PROPERTIES PREFIX "") + set_target_properties(OpenCL PROPERTIES LINK_FLAGS "-Wl,-disable-stdcall-fixup") + endif() else() - if (APPLE) - set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-pthread") - else () - set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-pthread -Wl,--version-script -Wl,${PROJECT_SOURCE_DIR}/icd_exports.map") + target_link_libraries (OpenCL PRIVATE ${CMAKE_THREAD_LIBS_INIT}) + if (NOT APPLE) + set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map") + if (OPENCL_ICD_LOADER_PIC) + set_target_properties(OpenCL PROPERTIES POSITION_INDEPENDENT_CODE ON) + endif () endif () endif () -target_link_libraries (OpenCL ${CMAKE_DL_LIBS}) +if (EXISTS ${OPENCL_ICD_LOADER_HEADERS_DIR}/CL/cl.h) + message (STATUS "Defining OpenCL::Headers through OPENCL_ICD_LOADER_HEADERS_DIR") + add_library (OpenCLHeaders INTERFACE) + add_library (OpenCL::Headers ALIAS OpenCLHeaders) + target_include_directories (OpenCLHeaders INTERFACE ${OPENCL_ICD_LOADER_HEADERS_DIR}) + target_include_directories (OpenCL PUBLIC $) +else () + if (NOT TARGET OpenCL::Headers) + find_package (OpenCLHeaders REQUIRED) + endif () + target_link_libraries (OpenCL PUBLIC OpenCL::Headers) +endif () + +set (OPENCL_COMPILE_DEFINITIONS + CL_TARGET_OPENCL_VERSION=300 + CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES + OPENCL_ICD_LOADER_VERSION_MAJOR=3 + OPENCL_ICD_LOADER_VERSION_MINOR=0 + OPENCL_ICD_LOADER_VERSION_REV=7 + $<$:CL_ENABLE_LAYERS> + $<$:CL_ENABLE_LOADER_MANAGED_DISPATCH> +) + +target_compile_definitions (OpenCL + PRIVATE + ${OPENCL_COMPILE_DEFINITIONS} +) + +target_include_directories (OpenCL + PRIVATE + ${CMAKE_CURRENT_BINARY_DIR} + loader +) +target_link_libraries (OpenCL PUBLIC ${CMAKE_DL_LIBS}) + +if (ENABLE_OPENCL_LAYERINFO) + + set (OPENCL_LAYER_INFO_SOURCES + loader/cllayerinfo.c + ${OPENCL_ICD_LOADER_SOURCES} + ) + + add_executable(cllayerinfo ${OPENCL_LAYER_INFO_SOURCES}) + + add_executable(OpenCL::cllayerinfo ALIAS cllayerinfo) + + target_compile_definitions (cllayerinfo + PRIVATE + CL_LAYER_INFO + ${OPENCL_COMPILE_DEFINITIONS} + ) + + if (EXISTS ${OPENCL_ICD_LOADER_HEADERS_DIR}/CL/cl.h) + target_include_directories (cllayerinfo PUBLIC $) + else () + target_link_libraries (cllayerinfo PUBLIC OpenCL::Headers) + endif () + + if (WIN32) + target_link_libraries (cllayerinfo PRIVATE cfgmgr32.lib runtimeobject.lib) + else () + target_link_libraries (cllayerinfo PRIVATE ${CMAKE_THREAD_LIBS_INIT}) + endif () + + target_link_libraries (cllayerinfo PUBLIC ${CMAKE_DL_LIBS}) + + target_include_directories (cllayerinfo + PRIVATE + ${CMAKE_CURRENT_BINARY_DIR} + loader + ) +endif () + +option (OPENCL_ICD_LOADER_BUILD_TESTING "Enable support for OpenCL ICD Loader testing." OFF) + +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME OR OPENCL_ICD_LOADER_BUILD_TESTING) + include(CTest) +endif() +if((CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME OR OPENCL_ICD_LOADER_BUILD_TESTING) AND BUILD_TESTING) + add_subdirectory (test) +endif() + +install( + TARGETS OpenCL + EXPORT OpenCLICDLoaderTargets + LIBRARY + DESTINATION ${CMAKE_INSTALL_LIBDIR} # obtained from GNUInstallDirs +) +install( +# FILES $ is cleanest, but is MSVC link.exe specific. LLVM's lld.exe and lld-link.exe don't support it (configure-time error) +# FILES $/OpenCL.pdb looks OK, but even though there's a PDB, this prop is empty on non-MSVC toolchains + FILES $/OpenCL.pdb # is the most implicit (expect PDB be next to the library), yet the only one that universally works + DESTINATION ${CMAKE_INSTALL_BINDIR} + OPTIONAL +) + +if (ENABLE_OPENCL_LAYERINFO) + install( + TARGETS cllayerinfo + RUNTIME + DESTINATION ${CMAKE_INSTALL_BINDIR} + COMPONENT cllayerinfo + ) +endif() + +export( + EXPORT OpenCLICDLoaderTargets + FILE ${PROJECT_BINARY_DIR}/OpenCLICDLoader/OpenCLICDLoaderTargets.cmake + NAMESPACE OpenCL:: +) +file( + WRITE ${PROJECT_BINARY_DIR}/OpenCLICDLoader/OpenCLICDLoaderConfig.cmake + "include(\"\${CMAKE_CURRENT_LIST_DIR}/OpenCLICDLoaderTargets.cmake\")" +) + +set(config_package_location ${CMAKE_INSTALL_DATADIR}/cmake/OpenCLICDLoader) +install( + EXPORT OpenCLICDLoaderTargets + FILE OpenCLICDLoaderTargets.cmake + NAMESPACE OpenCL:: + DESTINATION ${config_package_location} + COMPONENT dev +) +install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/OpenCLICDLoader/OpenCLICDLoaderConfig.cmake + DESTINATION ${config_package_location} + COMPONENT dev +) + +unset(CMAKE_SIZEOF_VOID_P) +include(CMakePackageConfigHelpers) +write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/OpenCLICDLoader/OpenCLICDLoaderConfigVersion.cmake + VERSION ${PROJECT_VERSION} + COMPATIBILITY AnyNewerVersion +) +install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/OpenCLICDLoader/OpenCLICDLoaderConfigVersion.cmake + DESTINATION ${config_package_location} + COMPONENT dev +) + +# Separate namelink from shared library and symlink for DEB packaging +install (TARGETS OpenCL + LIBRARY + DESTINATION ${CMAKE_INSTALL_LIBDIR} + COMPONENT runtime + NAMELINK_SKIP) -enable_testing() -add_subdirectory (test) +install (TARGETS OpenCL + LIBRARY + DESTINATION ${CMAKE_INSTALL_LIBDIR} + COMPONENT dev + NAMELINK_ONLY) diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..261eeb9e --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index 7afedf6c..00000000 --- a/LICENSE.txt +++ /dev/null @@ -1,35 +0,0 @@ -Copyright (c) 2016 The Khronos Group Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software source and associated documentation files (the "Materials"), -to deal in the Materials without restriction, including without limitation -the rights to use, copy, modify, compile, merge, publish, distribute, -sublicense, and/or sell copies of the Materials, and to permit persons to -whom the Materials are furnished to do so, subject the following terms and -conditions: - -All modifications to the Materials used to create a binary that is -distributed to third parties shall be provided to Khronos with an -unrestricted license to use for the purposes of implementing bug fixes and -enhancements to the Materials; - -If the binary is used as part of an OpenCL(TM) implementation, whether binary -is distributed together with or separately to that implementation, then -recipient must become an OpenCL Adopter and follow the published OpenCL -conformance process for that implementation, details at: -http://www.khronos.org/conformance/; - -The above copyright notice, the OpenCL trademark license, and this permission -notice shall be included in all copies or substantial portions of the -Materials. - -THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN -THE MATERIALS. - -OpenCL is a trademark of Apple Inc. used under license by Khronos. - diff --git a/Makefile b/Makefile deleted file mode 100644 index d804cb29..00000000 --- a/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -.PHONY: default do_cmake do_build test package -.PHONY: clean clobber - -BUILD_DIR:=build - -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 .git .gitignore icd - @echo "Package created at ${PACKAGE_PATH}" - -clean: - ${MAKE} -C ${BUILD_DIR} clean - -clobber: - rm -rf ${BUILD_DIR} diff --git a/OpenCL.pc.in b/OpenCL.pc.in new file mode 100644 index 00000000..ef353336 --- /dev/null +++ b/OpenCL.pc.in @@ -0,0 +1,9 @@ +prefix=@PKGCONFIG_PREFIX@ +exec_prefix=${prefix} +libdir=@OPENCL_LIBDIR_PC@ + +Name: OpenCL +Description: Khronos OpenCL ICD Loader +Requires: OpenCL-Headers +Version: 3.0 +Libs: -L${libdir} -lOpenCL diff --git a/OpenCL.rc b/OpenCL.rc deleted file mode 100644 index 16914f4f..00000000 --- a/OpenCL.rc +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2016 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software source and associated documentation files (the "Materials"), - * to deal in the Materials without restriction, including without limitation - * the rights to use, copy, modify, compile, merge, publish, distribute, - * sublicense, and/or sell copies of the Materials, and to permit persons to - * whom the Materials are furnished to do so, subject the following terms and - * conditions: - * - * All modifications to the Materials used to create a binary that is - * distributed to third parties shall be provided to Khronos with an - * unrestricted license to use for the purposes of implementing bug fixes and - * enhancements to the Materials; - * - * If the binary is used as part of an OpenCL(TM) implementation, whether binary - * is distributed together with or separately to that implementation, then - * recipient must become an OpenCL Adopter and follow the published OpenCL - * conformance process for that implementation, details at: - * http://www.khronos.org/conformance/; - * - * The above copyright notice, the OpenCL trademark license, and this permission - * notice shall be included in all copies or substantial portions of the - * Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN - * THE MATERIALS. - * - * OpenCL is a trademark of Apple Inc. used under license by Khronos. - */ - -#include - -#ifdef RC_INVOKED - -VS_VERSION_INFO VERSIONINFO -FILEVERSION 2,2,1,0 -PRODUCTVERSION 2,2,1,0 -FILETYPE VFT_DLL - -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904E4" - BEGIN - VALUE "FileDescription" ,"OpenCL Client DLL" - VALUE "ProductName" ,"Khronos OpenCL ICD" - VALUE "LegalCopyright" ,"Copyright \251 The Khronos Group Inc 2016" - VALUE "FileVersion" ,"2.2.1.0" - VALUE "CompanyName" ,"Khronos Group" - VALUE "InternalName" ,"OpenCL" - VALUE "OriginalFilename","OpenCL.dll" - END - END - - BLOCK "VarFileInfo" - BEGIN - // extend this line for localized versions - VALUE "Translation", 0x0409, 0x04E4 - END -END - -#endif - diff --git a/README.md b/README.md new file mode 100644 index 00000000..a7aa8652 --- /dev/null +++ b/README.md @@ -0,0 +1,149 @@ +# OpenCLTM ICD Loader + +This repo contains the source code and tests for the Khronos official OpenCL ICD Loader. + +## CI Build Status + +[![Windows Build Status](https://github.com/KhronosGroup/OpenCL-ICD-Loader/workflows/Windows/badge.svg)](https://github.com/KhronosGroup/OpenCL-ICD-Loader/actions?query=workflow%3AWindows) +[![Linux Build Status](https://github.com/KhronosGroup/OpenCL-ICD-Loader/workflows/Linux/badge.svg)](https://github.com/KhronosGroup/OpenCL-ICD-Loader/actions?query=workflow%3ALinux) +[![MacOS Build Status](https://github.com/KhronosGroup/OpenCL-ICD-Loader/workflows/MacOS/badge.svg)](https://github.com/KhronosGroup/OpenCL-ICD-Loader/actions?query=workflow%3AMacOS) + +## Introduction + +OpenCL defines an *Installable Client Driver* (ICD) mechanism to allow developers to build applications against an *Installable Client Driver* loader (ICD loader) rather than linking their applications against a specific OpenCL implementation. +The ICD Loader is responsible for: + +* Exporting OpenCL API entry points +* Enumerating OpenCL implementations +* Forwarding OpenCL API calls to the correct implementation + +This repo contains the source code and tests for the Khronos official OpenCL ICD Loader. + +Note that this repo does not contain an OpenCL implementation (ICD). +You will need to obtain and install an OpenCL implementation for your OpenCL device that supports the OpenCL ICD extension `cl_khr_icd` to run an application using the OpenCL ICD Loader. + +The OpenCL *Installable Client Driver* extension (`cl_khr_icd`) is described in the OpenCL extensions specification, which may be found on the [Khronos OpenCL Registry](https://www.khronos.org/registry/OpenCL/). + +## Build Instructions + +> While the ICD Loader can be built and installed in isolation, it is part of the [OpenCL SDK](https://github.com/KhronosGroup/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](https://github.com/KhronosGroup/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](https://cmake.org). + +### 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 + +1. 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 + +1. 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 + +```bash +cmake -D CMAKE_PREFIX_PATH="/chosen/install/prefix/of/headers;/chosen/install/prefix/of/loader" /path/to/opencl/app +``` + +and sample `CMakeLists.txt` + +```cmake +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: + +```bash +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.` | diff --git a/README.txt b/README.txt deleted file mode 100644 index 3b51170e..00000000 --- a/README.txt +++ /dev/null @@ -1,50 +0,0 @@ -== Building ICD and ICD Test == - -The build system will build ICD Loader library (OpenCL.dll or libOpenCL.so) and -ICD Loader Test binary (icd_loader_test) and some helper libraries for the test. - -=== Linux === - -Run "make" - -=== Windows === - -Run "build_using_cmake.bat" - -== Running ICD Test == - -ICD Test can be run using ctest, which is a companion to cmake. It can also be -run directly by executing icd_loader_test(.exe) executable from the bin folder. - -=== Linux === - -1. Add driver stub as an ICD - echo full/path/to/libOpenCLDriverStub.so > /etc/OpenCL/vendors/test.icd - -2. Run test using ctest - make test - -=== Windows === - -1. Add driver stub as an ICD by adding appropriate registry value - Key for 32-bit apps: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Khronos\OpenCL\Vendors - Key for 64-bit apps: HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\OpenCL\Vendors - - Add a REG_DWORD value: - Name: c:/full/path/to/OpenCLDriverStub.dll - Data: 0 - - Note: The build_using_cmake.bat builds ICD test as a 32-bit binary. - -2. Run test using ctest.exe - cd build - ctest.exe - -== Cleanup == - -Manually remove the registry key or .icd files added for running the ICD test. - -The "build" and "bin" folders are autogenerated by the build so those may be -safely deleted without losing any source code (on Linux "make clobber" will -delete them). - diff --git a/build_using_cmake.bat b/build_using_cmake.bat deleted file mode 100644 index f0044db7..00000000 --- a/build_using_cmake.bat +++ /dev/null @@ -1,11 +0,0 @@ -call "%VS90COMNTOOLS%/vsvars32.bat" - -set BUILD_DIR=build -set BIN_DIR=bin - -mkdir %BUILD_DIR% -cd %BUILD_DIR% -cmake -G "NMake Makefiles" ../ -nmake -cd .. - diff --git a/cmake/DebSourcePkg.cmake b/cmake/DebSourcePkg.cmake new file mode 100644 index 00000000..eb10e6a0 --- /dev/null +++ b/cmake/DebSourcePkg.cmake @@ -0,0 +1,160 @@ +# This script produces the changelog, control and rules file in the debian +# directory. These files are needed to build a Debian source package from the repository. +# Run this in CMake script mode, e.g. +# $ cd OpenCL-ICD-Loader +# $ cmake -S . -B ../build -D BUILD_TESTING=OFF +# $ cmake +# -DCMAKE_CACHE_PATH=../build/CMakeCache.txt +# -DCPACK_DEBIAN_PACKAGE_MAINTAINER="Example Name " +# -DDEBIAN_DISTROSERIES=jammy +# -DORIG_ARCHIVE=../OpenCL-ICD-Loader.tar.gz +# -DLATEST_RELEASE_VERSION=v2023.08.29 +# -P cmake/DebSourcePkg.cmake +# $ debuild -S -sa + +cmake_minimum_required(VERSION 3.21) # file(COPY_FILE) is added in CMake 3.21 + +if(NOT EXISTS "${CMAKE_CACHE_PATH}") + message(FATAL_ERROR "CMAKE_CACHE_PATH is not set or does not exist") +endif() +if(NOT DEFINED DEBIAN_PACKAGE_MAINTAINER) + message(FATAL_ERROR "DEBIAN_PACKAGE_MAINTAINER is not set") +endif() +if(NOT DEFINED DEBIAN_DISTROSERIES) + message(FATAL_ERROR "DEBIAN_DISTROSERIES is not set") +endif() +if(NOT DEFINED ORIG_ARCHIVE) + message(WARNING "ORIG_ARCHIVE is not set") +elseif(NOT EXISTS "${ORIG_ARCHIVE}") + message(FATAL_ERROR "ORIG_ARCHIVE is defined, but the file does not exist at \"${ORIG_ARCHIVE}\"") +endif() +if(NOT DEFINED LATEST_RELEASE_VERSION) + message(WARNING "LATEST_RELEASE_VERSION is not set") +endif() +if(NOT DEFINED DEBIAN_VERSION_SUFFIX) + message(WARNING "DEBIAN_VERSION_SUFFIX is not set") +endif() + +# Extracting the project version from the main CMakeLists.txt via regex +file(READ "${CMAKE_CACHE_PATH}" CMAKE_CACHE) +string(REGEX MATCH "CMAKE_PROJECT_VERSION[^=]*=([^\n]*)" REGEX_MATCH "${CMAKE_CACHE}") +if(NOT REGEX_MATCH) + message(FATAL_ERROR "Could not extract project version from CMakeLists.txt") +endif() +set(PROJECT_VERSION "${CMAKE_MATCH_1}") + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") +# Package.cmake contains all details for packaging +include(PackageSetup) + +# Append a space after every newline in the description. This format is required +# in the control file. +string(REPLACE "\n" "\n " CPACK_DEBIAN_DEV_DESCRIPTION "${CPACK_DEBIAN_DEV_DESCRIPTION}") +string(REPLACE "\n" "\n " CPACK_DEBIAN_RUNTIME_DESCRIPTION "${CPACK_DEBIAN_RUNTIME_DESCRIPTION}") +string(REPLACE "\n" "\n " CPACK_DEBIAN_CLLAYERINFO_DESCRIPTION "${CPACK_DEBIAN_CLLAYERINFO_DESCRIPTION}") + +set(DEB_SOURCE_PKG_DIR "${CMAKE_CURRENT_LIST_DIR}/../debian") +# Write debian/control +file(WRITE "${DEB_SOURCE_PKG_DIR}/control" +"Source: ${PACKAGE_NAME_PREFIX} +Section: ${CPACK_DEBIAN_DEV_PACKAGE_SECTION} +Priority: optional +Maintainer: ${DEBIAN_PACKAGE_MAINTAINER} +Build-Depends: cmake, debhelper-compat (=13), opencl-c-headers +Rules-Requires-Root: no +Homepage: ${CPACK_DEBIAN_PACKAGE_HOMEPAGE} +Standards-Version: 4.6.2 + +Package: ${CPACK_DEBIAN_DEV_PACKAGE_NAME} +Architecture: any +Multi-Arch: same +Depends: ${CPACK_DEBIAN_DEV_PACKAGE_DEPENDS}, ${CPACK_DEBIAN_RUNTIME_PACKAGE_NAME} (=${PACKAGE_VERSION_REVISION}) +Recommends: ${CPACK_DEBIAN_DEV_PACKAGE_RECOMMENDS} +Conflicts: ${CPACK_DEBIAN_DEV_PACKAGE_CONFLICTS} +Breaks: ${CPACK_DEBIAN_DEV_PACKAGE_BREAKS} +Replaces: ${CPACK_DEBIAN_DEV_PACKAGE_REPLACES} +Provides: ${CPACK_DEBIAN_DEV_PACKAGE_PROVIDES} +Description: ${CPACK_DEBIAN_DEV_DESCRIPTION} + +Package: ${CPACK_DEBIAN_RUNTIME_PACKAGE_NAME} +Section: ${CPACK_DEBIAN_RUNTIME_PACKAGE_SECTION} +Architecture: any +Multi-Arch: same +Depends: ${CPACK_DEBIAN_RUNTIME_PACKAGE_DEPENDS} +# Conflicts and replaces deliberately not added +# The runtime package provides libOpenCL.so.1.0.0 and libOpenCL.so.1 via update-alternatives +# Conflicts: ${CPACK_DEBIAN_RUNTIME_PACKAGE_CONFLICTS} +# Replaces: ${CPACK_DEBIAN_RUNTIME_PACKAGE_REPLACES} +Provides: ${CPACK_DEBIAN_RUNTIME_PACKAGE_PROVIDES} +Description: ${CPACK_DEBIAN_RUNTIME_DESCRIPTION} + +Package: ${CPACK_DEBIAN_CLLAYERINFO_PACKAGE_NAME} +Section: ${CPACK_DEBIAN_CLLAYERINFO_PACKAGE_SECTION} +Architecture: any +Depends: ${CPACK_DEBIAN_CLLAYERINFO_PACKAGE_DEPENDS}, ${CPACK_DEBIAN_RUNTIME_PACKAGE_NAME} (=${PACKAGE_VERSION_REVISION}) +Conflicts: ${CPACK_DEBIAN_CLLAYERINFO_PACKAGE_CONFLICTS} +Replaces: ${CPACK_DEBIAN_CLLAYERINFO_PACKAGE_REPLACES} +Provides: ${CPACK_DEBIAN_CLLAYERINFO_PACKAGE_PROVIDES} +Description: ${CPACK_DEBIAN_CLLAYERINFO_DESCRIPTION} +" +) +# Write debian/changelog +string(TIMESTAMP CURRENT_TIMESTAMP "%a, %d %b %Y %H:%M:%S +0000" UTC) +file(WRITE "${DEB_SOURCE_PKG_DIR}/changelog" +"${PACKAGE_NAME_PREFIX} (${PACKAGE_VERSION_REVISION}) ${DEBIAN_DISTROSERIES}; urgency=medium + + * Released version ${PACKAGE_VERSION_REVISION} + + -- ${DEBIAN_PACKAGE_MAINTAINER} ${CURRENT_TIMESTAMP} +") +# Write debian/rules +file(WRITE "${DEB_SOURCE_PKG_DIR}/rules" +"#!/usr/bin/make -f +%: +\tdh $@ + +override_dh_auto_configure: +\tdh_auto_configure -- -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF + +GENERATED_MAINTAINER_SCRIPTS := $(patsubst %.in,%,$(wildcard debian/*.alternatives.in)) + +$(GENERATED_MAINTAINER_SCRIPTS): %: %.in +\tsed \"s%@DEB_HOST_MULTIARCH@%$(DEB_HOST_MULTIARCH)%g\" < $< > $@ + +execute_before_dh_install: $(GENERATED_MAINTAINER_SCRIPTS) +\ttrue # An empty rule would confuse dh +") +file(WRITE "${DEB_SOURCE_PKG_DIR}/${CPACK_DEBIAN_DEV_PACKAGE_NAME}.install" +"usr/lib/*/pkgconfig +usr/lib/*/lib*.so +usr/share +") +# The .so files are installed to a different directory, and then linked back +# the the original location via update-alternatives. +file(WRITE "${DEB_SOURCE_PKG_DIR}/${CPACK_DEBIAN_RUNTIME_PACKAGE_NAME}.install" +"usr/lib/*/lib*.so.* usr/lib/\${DEB_HOST_MULTIARCH}/KhronosOpenCLICDLoader +") +file(WRITE "${DEB_SOURCE_PKG_DIR}/${CPACK_DEBIAN_RUNTIME_PACKAGE_NAME}.alternatives.in" +"Name: libOpenCL.so.1.0.0-@DEB_HOST_MULTIARCH@ +Link: /usr/lib/@DEB_HOST_MULTIARCH@/libOpenCL.so.1.0.0 +Alternative: /usr/lib/@DEB_HOST_MULTIARCH@/KhronosOpenCLICDLoader/libOpenCL.so.1.0.0 +Dependents: + /usr/lib/@DEB_HOST_MULTIARCH@/libOpenCL.so.1 libOpenCL.so.1-@DEB_HOST_MULTIARCH@ /usr/lib/@DEB_HOST_MULTIARCH@/KhronosOpenCLICDLoader/libOpenCL.so.1 +Priority: 100 +") +file(WRITE "${DEB_SOURCE_PKG_DIR}/${CPACK_DEBIAN_CLLAYERINFO_PACKAGE_NAME}.install" +"usr/bin +") + +if(DEFINED ORIG_ARCHIVE) + # Copy the passed orig.tar.gz file. The target filename is deduced from the version number, as expected by debuild + cmake_path(IS_ABSOLUTE ORIG_ARCHIVE IS_ORIG_ARCHIVE_ABSOLUTE) + if (NOT IS_ORIG_ARCHIVE_ABSOLUTE) + message(FATAL_ERROR "ORIG_ARCHIVE must be an absolute path (passed: \"${ORIG_ARCHIVE}\")") + endif() + cmake_path(GET ORIG_ARCHIVE EXTENSION ORIG_ARCHIVE_EXT) + cmake_path(GET ORIG_ARCHIVE PARENT_PATH ORIG_ARCHIVE_PARENT) + set(TARGET_PATH "${ORIG_ARCHIVE_PARENT}/${PACKAGE_NAME_PREFIX}_${CPACK_DEBIAN_PACKAGE_VERSION}${ORIG_ARCHIVE_EXT}") + message(STATUS "Copying \"${ORIG_ARCHIVE}\" to \"${TARGET_PATH}\"") + file(COPY_FILE "${ORIG_ARCHIVE}" "${TARGET_PATH}") +endif() diff --git a/cmake/JoinPaths.cmake b/cmake/JoinPaths.cmake new file mode 100644 index 00000000..32d6d668 --- /dev/null +++ b/cmake/JoinPaths.cmake @@ -0,0 +1,26 @@ +# This module provides function for joining paths +# known from from most languages +# +# Original license: +# SPDX-License-Identifier: (MIT OR CC0-1.0) +# Explicit permission given to distribute this module under +# the terms of the project as described in /LICENSE.rst. +# Copyright 2020 Jan Tojnar +# https://github.com/jtojnar/cmake-snips +# +# Modelled after Python’s os.path.join +# https://docs.python.org/3.7/library/os.path.html#os.path.join +# Windows not supported +function(join_paths joined_path first_path_segment) + set(temp_path "${first_path_segment}") + foreach(current_segment IN LISTS ARGN) + if(NOT ("${current_segment}" STREQUAL "")) + if(IS_ABSOLUTE "${current_segment}") + set(temp_path "${current_segment}") + else() + set(temp_path "${temp_path}/${current_segment}") + endif() + endif() + endforeach() + set(${joined_path} "${temp_path}" PARENT_SCOPE) +endfunction() diff --git a/cmake/Package.cmake b/cmake/Package.cmake new file mode 100644 index 00000000..adfa5056 --- /dev/null +++ b/cmake/Package.cmake @@ -0,0 +1,40 @@ +include("${CMAKE_CURRENT_LIST_DIR}/PackageSetup.cmake") + +# Configuring pkgconfig + +# We need two different instances of OpenCL.pc +# One for installing (cmake --install), which contains CMAKE_INSTALL_PREFIX as prefix +# And another for the Debian development package, which contains CPACK_PACKAGING_INSTALL_PREFIX as prefix + +join_paths(OPENCL_INCLUDEDIR_PC "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}") +join_paths(OPENCL_LIBDIR_PC "\${exec_prefix}" "${CMAKE_INSTALL_LIBDIR}") + +set(pkg_config_location ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +set(PKGCONFIG_PREFIX "${CMAKE_INSTALL_PREFIX}") + +# Configure and install OpenCL.pc for installing the project +configure_file( + OpenCL.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/pkgconfig_install/OpenCL.pc + @ONLY) +install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgconfig_install/OpenCL.pc + DESTINATION ${pkg_config_location} + COMPONENT pkgconfig_install) + +# Configure and install OpenCL.pc for the Debian package +set(PKGCONFIG_PREFIX "${CPACK_PACKAGING_INSTALL_PREFIX}") +configure_file( + OpenCL.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/pkgconfig_package/OpenCL.pc + @ONLY) + +install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgconfig_package/OpenCL.pc + DESTINATION ${pkg_config_location} + COMPONENT dev + EXCLUDE_FROM_ALL) + +set(CPACK_DEBIAN_PACKAGE_DEBUG ON) + +include(CPack) diff --git a/cmake/PackageSetup.cmake b/cmake/PackageSetup.cmake new file mode 100644 index 00000000..b4aade8a --- /dev/null +++ b/cmake/PackageSetup.cmake @@ -0,0 +1,112 @@ +set(CPACK_PACKAGE_VENDOR "khronos") + +set(CPACK_DEBIAN_RUNTIME_DESCRIPTION "Generic OpenCL ICD Loader +OpenCL (Open Computing Language) is a multivendor open standard for +general-purpose parallel programming of heterogeneous systems that include +CPUs, GPUs and other processors. +. +This package contains an installable client driver loader (ICD Loader) +library that can be used to load any (free or non-free) installable client +driver (ICD) for OpenCL. It acts as a demultiplexer so several ICD can +be installed and used together.") + +set(CPACK_DEBIAN_DEV_DESCRIPTION "OpenCL development files +OpenCL (Open Computing Language) is a multivendor open standard for +general-purpose parallel programming of heterogeneous systems that include +CPUs, GPUs and other processors. +. +This package provides the development files: headers and libraries. +. +It also ensures that the ocl-icd ICD loader is installed so its additional +features (compared to the OpenCL norm) can be used: .pc file, ability to +select an ICD without root privilege, etc.") + +set(CPACK_DEBIAN_CLLAYERINFO_DESCRIPTION "Query OpenCL Layer system information +OpenCL (Open Computing Language) is a multivendor open standard for +general-purpose parallel programming of heterogeneous systems that include +CPUs, GPUs and other processors. It supports system and user configured layers +to intercept OpenCL API calls. +. +This package contains a tool that lists the layers loaded by the the ocl-icd +OpenCL ICD Loader.") + +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") + +set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md") + +if(NOT CPACK_PACKAGING_INSTALL_PREFIX) + set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") +endif() + +# DEB packaging configuration +set(CPACK_DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_VENDOR}) + +set(CPACK_DEBIAN_PACKAGE_HOMEPAGE + "https://github.com/KhronosGroup/OpenCL-ICD-Loader") + +# Version number [epoch:]upstream_version[-debian_revision] +set(CPACK_DEBIAN_PACKAGE_VERSION "${PROJECT_VERSION}") # upstream_version +if(DEFINED LATEST_RELEASE_VERSION) + # Remove leading "v", if exists + string(LENGTH "${LATEST_RELEASE_VERSION}" LATEST_RELEASE_VERSION_LENGTH) + string(SUBSTRING "${LATEST_RELEASE_VERSION}" 0 1 LATEST_RELEASE_VERSION_FRONT) + if(LATEST_RELEASE_VERSION_FRONT STREQUAL "v") + string(SUBSTRING "${LATEST_RELEASE_VERSION}" 1 ${LATEST_RELEASE_VERSION_LENGTH} LATEST_RELEASE_VERSION) + endif() + + string(APPEND CPACK_DEBIAN_PACKAGE_VERSION "~${LATEST_RELEASE_VERSION}") +endif() +set(CPACK_DEBIAN_PACKAGE_RELEASE "1") # debian_revision (because this is a + # non-native pkg) +set(PACKAGE_VERSION_REVISION "${CPACK_DEBIAN_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}${DEBIAN_VERSION_SUFFIX}") + +# Get architecture +execute_process(COMMAND dpkg "--print-architecture" OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE) +string(STRIP "${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}" CPACK_DEBIAN_PACKAGE_ARCHITECTURE) + +########################################################## +# Components # +########################################################## + +set(CPACK_DEB_COMPONENT_INSTALL ON) +set(CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS OFF) # Component dependencies are NOT reflected in package relationships +set(CPACK_COMPONENTS_ALL runtime dev cllayerinfo) + +set(PACKAGE_NAME_PREFIX "khronos-opencl-loader") + +## Package runtime component +set(CPACK_DEBIAN_RUNTIME_PACKAGE_NAME "${PACKAGE_NAME_PREFIX}-libopencl1") + +# Package file name in deb format: +# _-_.deb +set(CPACK_DEBIAN_RUNTIME_FILE_NAME "${CPACK_DEBIAN_RUNTIME_PACKAGE_NAME}_${PACKAGE_VERSION_REVISION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb") +set(CPACK_DEBIAN_RUNTIME_PACKAGE_SECTION "libs") +# Dependencies +set(CPACK_DEBIAN_RUNTIME_PACKAGE_DEPENDS "libc6") +set(CPACK_DEBIAN_RUNTIME_PACKAGE_SUGGESTS "opencl-icd") +set(CPACK_DEBIAN_RUNTIME_PACKAGE_CONFLICTS "amd-app, libopencl1, nvidia-libopencl1-dev") +set(CPACK_DEBIAN_RUNTIME_PACKAGE_REPLACES "amd-app, libopencl1, nvidia-libopencl1-dev") +set(CPACK_DEBIAN_RUNTIME_PACKAGE_PROVIDES "libopencl-1.1-1, libopencl-1.2-1, libopencl-2.0-1, libopencl-2.1-1, libopencl-2.2-1, libopencl-3.0-1, libopencl1") + +## Package dev component +set(CPACK_DEBIAN_DEV_PACKAGE_NAME "${PACKAGE_NAME_PREFIX}-opencl-dev") + +# Package file name in deb format: +# _-_.deb +set(CPACK_DEBIAN_DEV_FILE_NAME "${CPACK_DEBIAN_DEV_PACKAGE_NAME}_${PACKAGE_VERSION_REVISION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb") +set(CPACK_DEBIAN_DEV_PACKAGE_SECTION "libdevel") + +# Dependencies +set(CPACK_DEBIAN_DEV_PACKAGE_DEPENDS "opencl-c-headers (>= ${CPACK_DEBIAN_PACKAGE_VERSION}) | opencl-headers (>= ${CPACK_DEBIAN_PACKAGE_VERSION}), ${CPACK_DEBIAN_RUNTIME_PACKAGE_NAME} (>= ${CPACK_DEBIAN_PACKAGE_VERSION}) | libopencl1") +set(CPACK_DEBIAN_DEV_PACKAGE_RECOMMENDS "libgl1-mesa-dev | libgl-dev") +set(CPACK_DEBIAN_DEV_PACKAGE_CONFLICTS "opencl-dev") +set(CPACK_DEBIAN_DEV_PACKAGE_BREAKS "amd-libopencl1, nvidia-libopencl1") +set(CPACK_DEBIAN_DEV_PACKAGE_REPLACES "amd-libopencl1, nvidia-libopencl1, opencl-dev") +set(CPACK_DEBIAN_DEV_PACKAGE_PROVIDES "opencl-dev") + +## Package cllayerinfo component +set(CPACK_DEBIAN_CLLAYERINFO_PACKAGE_NAME "${PACKAGE_NAME_PREFIX}-cllayerinfo") +set(CPACK_DEBIAN_CLLAYERINFO_FILE_NAME "${CPACK_DEBIAN_CLLAYERINFO_PACKAGE_NAME}_${PACKAGE_VERSION_REVISION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb") +# Dependencies +set(CPACK_DEBIAN_CLLAYERINFO_PACKAGE_DEPENDS "libc6") +set(CPACK_DEBIAN_CLLAYERINFO_PACKAGE_SECTION "admin") diff --git a/icd.c b/icd.c deleted file mode 100644 index fdeff798..00000000 --- a/icd.c +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Copyright (c) 2016 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software source and associated documentation files (the "Materials"), - * to deal in the Materials without restriction, including without limitation - * the rights to use, copy, modify, compile, merge, publish, distribute, - * sublicense, and/or sell copies of the Materials, and to permit persons to - * whom the Materials are furnished to do so, subject the following terms and - * conditions: - * - * All modifications to the Materials used to create a binary that is - * distributed to third parties shall be provided to Khronos with an - * unrestricted license to use for the purposes of implementing bug fixes and - * enhancements to the Materials; - * - * If the binary is used as part of an OpenCL(TM) implementation, whether binary - * is distributed together with or separately to that implementation, then - * recipient must become an OpenCL Adopter and follow the published OpenCL - * conformance process for that implementation, details at: - * http://www.khronos.org/conformance/; - * - * The above copyright notice, the OpenCL trademark license, and this permission - * notice shall be included in all copies or substantial portions of the - * Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN - * THE MATERIALS. - * - * OpenCL is a trademark of Apple Inc. used under license by Khronos. - */ - -#include "icd.h" -#include "icd_dispatch.h" -#include -#include - -KHRicdVendor *khrIcdVendors = NULL; - -// entrypoint to initialize the ICD and add all vendors -void khrIcdInitialize(void) -{ - // enumerate vendors present on the system - khrIcdOsVendorsEnumerateOnce(); -} - -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; - KHRicdVendor *vendorIterator = 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; - } - - // ensure that we haven't already loaded this vendor - for (vendorIterator = khrIcdVendors; vendorIterator; vendorIterator = vendorIterator->next) - { - if (vendorIterator->library == library) - { - KHR_ICD_TRACE("already loaded vendor %s, nothing to do here\n", libraryName); - goto Done; - } - } - - // get the library's clGetExtensionFunctionAddress pointer - p_clGetExtensionFunctionAddress = (pfn_clGetExtensionFunctionAddress)(size_t)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 = (pfn_clIcdGetPlatformIDs)(size_t)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 = &khrIcdVendors; *prevNextPointer; prevNextPointer = &( (*prevNextPointer)->next) ); - *prevNextPointer = vendor; - } - - KHR_ICD_TRACE("successfully added vendor %s with suffix %s\n", libraryName, suffix); - - } - -Done: - - if (library) - { - khrIcdOsLibraryUnload(library); - } - if (platforms) - { - free(platforms); - } -} - -void khrIcdContextPropertiesGetPlatform(const cl_context_properties *properties, cl_platform_id *outPlatform) -{ - if (properties == NULL && khrIcdVendors != NULL) - { - *outPlatform = khrIcdVendors[0].platform; - return; - } - - const cl_context_properties *property = (cl_context_properties *)NULL; - *outPlatform = NULL; - for (property = properties; property && property[0]; property += 2) - { - if ((cl_context_properties)CL_CONTEXT_PLATFORM == property[0]) - { - *outPlatform = (cl_platform_id)property[1]; - } - } -} - diff --git a/icd.h b/icd.h deleted file mode 100644 index 9221be47..00000000 --- a/icd.h +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (c) 2016 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software source and associated documentation files (the "Materials"), - * to deal in the Materials without restriction, including without limitation - * the rights to use, copy, modify, compile, merge, publish, distribute, - * sublicense, and/or sell copies of the Materials, and to permit persons to - * whom the Materials are furnished to do so, subject the following terms and - * conditions: - * - * All modifications to the Materials used to create a binary that is - * distributed to third parties shall be provided to Khronos with an - * unrestricted license to use for the purposes of implementing bug fixes and - * enhancements to the Materials; - * - * If the binary is used as part of an OpenCL(TM) implementation, whether binary - * is distributed together with or separately to that implementation, then - * recipient must become an OpenCL Adopter and follow the published OpenCL - * conformance process for that implementation, details at: - * http://www.khronos.org/conformance/; - * - * The above copyright notice, the OpenCL trademark license, and this permission - * notice shall be included in all copies or substantial portions of the - * Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN - * THE MATERIALS. - * - * OpenCL is a trademark of Apple Inc. used under license by Khronos. - */ - -#ifndef _ICD_H_ -#define _ICD_H_ - -#ifndef CL_USE_DEPRECATED_OPENCL_1_0_APIS -#define CL_USE_DEPRECATED_OPENCL_1_0_APIS -#endif - -#ifndef CL_USE_DEPRECATED_OPENCL_1_1_APIS -#define CL_USE_DEPRECATED_OPENCL_1_1_APIS -#endif - -#ifndef CL_USE_DEPRECATED_OPENCL_1_2_APIS -#define CL_USE_DEPRECATED_OPENCL_1_2_APIS -#endif - -#include -#include - -#ifdef _WIN32 -#include -#endif - -/* - * 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; - -/* - * 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; -}; - -// the global state -extern KHRicdVendor * khrIcdVendors; - -/* - * 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 khrIcdOsVendorsEnumerateOnce(void); - -// add a vendor's implementation to the list of libraries -void khrIcdVendorAdd(const char *libraryName); - -// dynamically load a library. returns NULL on failure -// n.b, this call is OS-specific -void *khrIcdOsLibraryLoad(const char *libraryName); - -// get a function pointer from a loaded library. returns NULL on failure. -// n.b, this call is OS-specific -void *khrIcdOsLibraryGetFunctionAddress(void *library, const char *functionName); - -// unload a library. -// n.b, this call is OS-specific -void khrIcdOsLibraryUnload(void *library); - -// parse properties and determine the platform to use from them -void khrIcdContextPropertiesGetPlatform( - const cl_context_properties *properties, - cl_platform_id *outPlatform); - -// internal tracing macros -#if 0 - #include - #define KHR_ICD_TRACE(...) \ - do \ - { \ - fprintf(stderr, "KHR ICD trace at %s:%d: ", __FILE__, __LINE__); \ - fprintf(stderr, __VA_ARGS__); \ - } while (0) -#ifdef _WIN32 -#define KHR_ICD_WIDE_TRACE(...) \ - do \ - { \ - fwprintf(stderr, L"KHR ICD trace at %hs:%d: ", __FILE__, __LINE__); \ - fwprintf(stderr, __VA_ARGS__); \ - } while (0) -#else -#define KHR_ICD_WIDE_TRACE(...) -#endif - #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_WIDE_TRACE(...) - #define KHR_ICD_ASSERT(x) -#endif - -// if handle is NULL then return invalid_handle_error_code -#define KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(handle,invalid_handle_error_code) \ - do \ - { \ - if (!handle) \ - { \ - return invalid_handle_error_code; \ - } \ - } while (0) - -// if handle is NULL then set errcode_ret to invalid_handle_error and return NULL -// (NULL being an invalid handle) -#define KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(handle,invalid_handle_error) \ - do \ - { \ - if (!handle) \ - { \ - if (errcode_ret) \ - { \ - *errcode_ret = invalid_handle_error; \ - } \ - return NULL; \ - } \ - } while (0) - - -#endif - diff --git a/icd_dispatch.c b/icd_dispatch.c deleted file mode 100644 index efab2cab..00000000 --- a/icd_dispatch.c +++ /dev/null @@ -1,2684 +0,0 @@ -/* - * Copyright (c) 2012-2018 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software source and associated documentation files (the "Materials"), - * to deal in the Materials without restriction, including without limitation - * the rights to use, copy, modify, compile, merge, publish, distribute, - * sublicense, and/or sell copies of the Materials, and to permit persons to - * whom the Materials are furnished to do so, subject the following terms and - * conditions: - * - * All modifications to the Materials used to create a binary that is - * distributed to third parties shall be provided to Khronos with an - * unrestricted license to use for the purposes of implementing bug fixes and - * enhancements to the Materials; - * - * If the binary is used as part of an OpenCL(TM) implementation, whether binary - * is distributed together with or separately to that implementation, then - * recipient must become an OpenCL Adopter and follow the published OpenCL - * conformance process for that implementation, details at: - * http://www.khronos.org/conformance/; - * - * The above copyright notice, the OpenCL trademark license, and this permission - * notice shall be included in all copies or substantial portions of the - * Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN - * THE MATERIALS. - * - * OpenCL is a trademark of Apple Inc. used under license by Khronos. - */ - -#include "icd_dispatch.h" -#include "icd.h" -#include -#include - -// Platform APIs -CL_API_ENTRY cl_int CL_API_CALL -clGetPlatformIDs(cl_uint num_entries, - cl_platform_id * platforms, - cl_uint * num_platforms) CL_API_SUFFIX__VERSION_1_0 -{ - KHRicdVendor* vendor = NULL; - cl_uint i; - - // initialize the platforms (in case they have not been already) - khrIcdInitialize(); - - if (!num_entries && platforms) - { - return CL_INVALID_VALUE; - } - if (!platforms && !num_platforms) - { - return CL_INVALID_VALUE; - } - // set num_platforms to 0 and set all platform pointers to NULL - if (num_platforms) - { - *num_platforms = 0; - } - for (i = 0; i < num_entries && platforms; ++i) - { - platforms[i] = NULL; - } - // return error if we have no platforms - if (!khrIcdVendors) - { - return CL_PLATFORM_NOT_FOUND_KHR; - } - // otherwise enumerate all platforms - for (vendor = khrIcdVendors; vendor; vendor = vendor->next) - { - if (num_entries && platforms) - { - *(platforms++) = vendor->platform; - --num_entries; - } - if (num_platforms) - { - ++(*num_platforms); - } - } - return CL_SUCCESS; -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetPlatformInfo(cl_platform_id platform, - cl_platform_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - // initialize the platforms (in case they have not been already) - khrIcdInitialize(); - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); - return platform->dispatch->clGetPlatformInfo( - platform, - param_name, - param_value_size, - param_value, - param_value_size_ret); -} - -// Device APIs -CL_API_ENTRY cl_int CL_API_CALL -clGetDeviceIDs(cl_platform_id platform, - cl_device_type device_type, - cl_uint num_entries, - cl_device_id * devices, - cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_0 -{ - // initialize the platforms (in case they have not been already) - khrIcdInitialize(); - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); - return platform->dispatch->clGetDeviceIDs( - platform, - device_type, - num_entries, - devices, - num_devices); -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetDeviceInfo( - cl_device_id device, - cl_device_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); - return device->dispatch->clGetDeviceInfo( - device, - param_name, - param_value_size, - param_value, - param_value_size_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clCreateSubDevices(cl_device_id in_device, - const cl_device_partition_property * properties, - cl_uint num_entries, - cl_device_id * out_devices, - cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_2 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(in_device, CL_INVALID_DEVICE); - return in_device->dispatch->clCreateSubDevices( - in_device, - properties, - num_entries, - out_devices, - num_devices); -} - -CL_API_ENTRY cl_int CL_API_CALL -clRetainDevice(cl_device_id device) CL_API_SUFFIX__VERSION_1_2 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); - return device->dispatch->clRetainDevice(device); -} - -CL_API_ENTRY cl_int CL_API_CALL -clReleaseDevice(cl_device_id device) CL_API_SUFFIX__VERSION_1_2 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); - return device->dispatch->clReleaseDevice(device); -} - -// Context APIs -CL_API_ENTRY cl_context CL_API_CALL -clCreateContext(const cl_context_properties * properties, - cl_uint num_devices, - const cl_device_id * devices, - void (CL_CALLBACK *pfn_notify)(const char *, const void *, size_t, void *), - void * user_data, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - // initialize the platforms (in case they have not been already) - khrIcdInitialize(); - if (!num_devices || !devices) - { - if (errcode_ret) - { - *errcode_ret = CL_INVALID_VALUE; - } - return NULL; - } - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(devices[0], CL_INVALID_DEVICE); - return devices[0]->dispatch->clCreateContext( - properties, - num_devices, - devices, - pfn_notify, - user_data, - errcode_ret); -} - -CL_API_ENTRY cl_context CL_API_CALL -clCreateContextFromType(const cl_context_properties * properties, - cl_device_type device_type, - void (CL_CALLBACK *pfn_notify)(const char *, const void *, size_t, void *), - void * user_data, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - cl_platform_id platform = NULL; - - // initialize the platforms (in case they have not been already) - khrIcdInitialize(); - - // determine the platform to use from the properties specified - khrIcdContextPropertiesGetPlatform(properties, &platform); - - // validate the platform handle and dispatch - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(platform, CL_INVALID_PLATFORM); - return platform->dispatch->clCreateContextFromType( - properties, - device_type, - pfn_notify, - user_data, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clRetainContext(cl_context context) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(context, CL_INVALID_CONTEXT); - return context->dispatch->clRetainContext(context); -} - -CL_API_ENTRY cl_int CL_API_CALL -clReleaseContext(cl_context context) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(context, CL_INVALID_CONTEXT); - return context->dispatch->clReleaseContext(context); -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetContextInfo(cl_context context, - cl_context_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(context, CL_INVALID_CONTEXT); - return context->dispatch->clGetContextInfo( - context, - param_name, - param_value_size, - param_value, - param_value_size_ret); -} - -// Command Queue APIs -CL_API_ENTRY cl_command_queue CL_API_CALL -clCreateCommandQueue(cl_context context, - cl_device_id device, - cl_command_queue_properties properties, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateCommandQueue( - context, - device, - properties, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clRetainCommandQueue(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clRetainCommandQueue(command_queue); -} - -CL_API_ENTRY cl_int CL_API_CALL -clReleaseCommandQueue(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clReleaseCommandQueue(command_queue); -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetCommandQueueInfo(cl_command_queue command_queue, - cl_command_queue_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clGetCommandQueueInfo( - command_queue, - param_name, - param_value_size, - param_value, - param_value_size_ret); -} - -// Memory Object APIs -CL_API_ENTRY cl_mem CL_API_CALL -clCreateBuffer(cl_context context, - cl_mem_flags flags, - size_t size, - void * host_ptr, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateBuffer( - context, - flags, - size, - host_ptr, - errcode_ret); -} - -CL_API_ENTRY cl_mem CL_API_CALL -clCreateImage(cl_context context, - cl_mem_flags flags, - const cl_image_format * image_format, - const cl_image_desc * image_desc, - void * host_ptr, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateImage( - context, - flags, - image_format, - image_desc, - host_ptr, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clRetainMemObject(cl_mem memobj) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); - return memobj->dispatch->clRetainMemObject(memobj); -} - - -CL_API_ENTRY cl_int CL_API_CALL -clReleaseMemObject(cl_mem memobj) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); - return memobj->dispatch->clReleaseMemObject(memobj); -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetSupportedImageFormats(cl_context context, - cl_mem_flags flags, - cl_mem_object_type image_type, - cl_uint num_entries, - cl_image_format * image_formats, - cl_uint * num_image_formats) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(context, CL_INVALID_CONTEXT); - return context->dispatch->clGetSupportedImageFormats( - context, - flags, - image_type, - num_entries, - image_formats, - num_image_formats); -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetMemObjectInfo(cl_mem memobj, - cl_mem_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); - return memobj->dispatch->clGetMemObjectInfo( - memobj, - param_name, - param_value_size, - param_value, - param_value_size_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetImageInfo(cl_mem image, - cl_image_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(image, CL_INVALID_MEM_OBJECT); - return image->dispatch->clGetImageInfo( - image, - param_name, - param_value_size, - param_value, - param_value_size_ret); -} - -// Sampler APIs -CL_API_ENTRY cl_sampler CL_API_CALL -clCreateSampler(cl_context context, - cl_bool normalized_coords, - cl_addressing_mode addressing_mode, - cl_filter_mode filter_mode, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateSampler( - context, - normalized_coords, - addressing_mode, - filter_mode, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clRetainSampler(cl_sampler sampler) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(sampler, CL_INVALID_SAMPLER); - return sampler->dispatch->clRetainSampler(sampler); -} - -CL_API_ENTRY cl_int CL_API_CALL -clReleaseSampler(cl_sampler sampler) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(sampler, CL_INVALID_SAMPLER); - return sampler->dispatch->clReleaseSampler(sampler); -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetSamplerInfo(cl_sampler sampler, - cl_sampler_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(sampler, CL_INVALID_SAMPLER); - return sampler->dispatch->clGetSamplerInfo( - sampler, - param_name, - param_value_size, - param_value, - param_value_size_ret); -} - -// Program Object APIs -CL_API_ENTRY cl_program CL_API_CALL -clCreateProgramWithSource(cl_context context, - cl_uint count, - const char ** strings, - const size_t * lengths, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateProgramWithSource( - context, - count, - strings, - lengths, - errcode_ret); -} - -CL_API_ENTRY cl_program CL_API_CALL -clCreateProgramWithBinary(cl_context context, - cl_uint num_devices, - const cl_device_id * device_list, - const size_t * lengths, - const unsigned char ** binaries, - cl_int * binary_status, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateProgramWithBinary( - context, - num_devices, - device_list, - lengths, - binaries, - binary_status, - errcode_ret); -} - -CL_API_ENTRY cl_program CL_API_CALL -clCreateProgramWithBuiltInKernels(cl_context context, - cl_uint num_devices, - const cl_device_id * device_list, - const char * kernel_names, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateProgramWithBuiltInKernels( - context, - num_devices, - device_list, - kernel_names, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clRetainProgram(cl_program program) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); - return program->dispatch->clRetainProgram(program); -} - -CL_API_ENTRY cl_int CL_API_CALL -clReleaseProgram(cl_program program) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); - return program->dispatch->clReleaseProgram(program); -} - -CL_API_ENTRY cl_int CL_API_CALL -clBuildProgram(cl_program program, - cl_uint num_devices, - const cl_device_id * device_list, - const char * options, - void (CL_CALLBACK *pfn_notify)(cl_program program, void * user_data), - void * user_data) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); - return program->dispatch->clBuildProgram( - program, - num_devices, - device_list, - options, - pfn_notify, - user_data); -} - -CL_API_ENTRY cl_int CL_API_CALL -clCompileProgram(cl_program program, - cl_uint num_devices, - const cl_device_id * device_list, - const char * options, - cl_uint num_input_headers, - const cl_program * input_headers, - const char ** header_include_names, - void (CL_CALLBACK * pfn_notify)(cl_program program, void * user_data), - void * user_data) CL_API_SUFFIX__VERSION_1_2 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); - return program->dispatch->clCompileProgram( - program, - num_devices, - device_list, - options, - num_input_headers, - input_headers, - header_include_names, - pfn_notify, - user_data); -} - -CL_API_ENTRY cl_program CL_API_CALL -clLinkProgram(cl_context context, - cl_uint num_devices, - const cl_device_id * device_list, - const char * options, - cl_uint num_input_programs, - const cl_program * input_programs, - void (CL_CALLBACK * pfn_notify)(cl_program program, void * user_data), - void * user_data, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clLinkProgram( - context, - num_devices, - device_list, - options, - num_input_programs, - input_programs, - pfn_notify, - user_data, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clSetProgramSpecializationConstant(cl_program program, - cl_uint spec_id, - size_t spec_size, - const void* spec_value) CL_API_SUFFIX__VERSION_2_2 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); - return program->dispatch->clSetProgramSpecializationConstant( - program, - spec_id, - spec_size, - spec_value); -} - -CL_API_ENTRY cl_int CL_API_CALL -clSetProgramReleaseCallback(cl_program program, - void (CL_CALLBACK * pfn_notify)(cl_program program, void * user_data), - void * user_data) CL_API_SUFFIX__VERSION_2_2 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); - return program->dispatch->clSetProgramReleaseCallback( - program, - pfn_notify, - user_data); -} - -CL_API_ENTRY cl_int CL_API_CALL -clUnloadPlatformCompiler(cl_platform_id platform) CL_API_SUFFIX__VERSION_1_2 -{ - // initialize the platforms (in case they have not been already) - khrIcdInitialize(); - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); - return platform->dispatch->clUnloadPlatformCompiler(platform); -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetProgramInfo(cl_program program, - cl_program_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); - return program->dispatch->clGetProgramInfo( - program, - param_name, - param_value_size, - param_value, - param_value_size_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetProgramBuildInfo(cl_program program, - cl_device_id device, - cl_program_build_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); - return program->dispatch->clGetProgramBuildInfo( - program, - device, - param_name, - param_value_size, - param_value, - param_value_size_ret); -} - -// Kernel Object APIs -CL_API_ENTRY cl_kernel CL_API_CALL -clCreateKernel(cl_program program, - const char * kernel_name, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(program, CL_INVALID_PROGRAM); - return program->dispatch->clCreateKernel( - program, - kernel_name, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clCreateKernelsInProgram(cl_program program, - cl_uint num_kernels, - cl_kernel * kernels, - cl_uint * num_kernels_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); - return program->dispatch->clCreateKernelsInProgram( - program, - num_kernels, - kernels, - num_kernels_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clRetainKernel(cl_kernel kernel) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); - return kernel->dispatch->clRetainKernel(kernel); -} - -CL_API_ENTRY cl_int CL_API_CALL -clReleaseKernel(cl_kernel kernel) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); - return kernel->dispatch->clReleaseKernel(kernel); -} - -CL_API_ENTRY cl_int CL_API_CALL -clSetKernelArg(cl_kernel kernel, - cl_uint arg_index, - size_t arg_size, - const void * arg_value) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); - return kernel->dispatch->clSetKernelArg( - kernel, - arg_index, - arg_size, - arg_value); -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetKernelInfo(cl_kernel kernel, - cl_kernel_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); - return kernel->dispatch->clGetKernelInfo( - kernel, - param_name, - param_value_size, - param_value, - param_value_size_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetKernelArgInfo(cl_kernel kernel, - cl_uint arg_indx, - cl_kernel_arg_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_2 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); - return kernel->dispatch->clGetKernelArgInfo( - kernel, - arg_indx, - param_name, - param_value_size, - param_value, - param_value_size_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetKernelWorkGroupInfo(cl_kernel kernel, - cl_device_id device, - cl_kernel_work_group_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); - return kernel->dispatch->clGetKernelWorkGroupInfo( - kernel, - device, - param_name, - param_value_size, - param_value, - param_value_size_ret); -} - -// Event Object APIs -CL_API_ENTRY cl_int CL_API_CALL -clWaitForEvents(cl_uint num_events, - const cl_event * event_list) CL_API_SUFFIX__VERSION_1_0 -{ - if (!num_events || !event_list) - { - return CL_INVALID_VALUE; - } - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event_list[0], CL_INVALID_EVENT); - return event_list[0]->dispatch->clWaitForEvents( - num_events, - event_list); -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetEventInfo(cl_event event, - cl_event_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); - return event->dispatch->clGetEventInfo( - event, - param_name, - param_value_size, - param_value, - param_value_size_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clRetainEvent(cl_event event) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); - return event->dispatch->clRetainEvent(event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clReleaseEvent(cl_event event) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); - return event->dispatch->clReleaseEvent(event); -} - -// Profiling APIs -CL_API_ENTRY cl_int CL_API_CALL -clGetEventProfilingInfo(cl_event event, - cl_profiling_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); - return event->dispatch->clGetEventProfilingInfo( - event, - param_name, - param_value_size, - param_value, - param_value_size_ret); -} - -// Flush and Finish APIs -CL_API_ENTRY cl_int CL_API_CALL -clFlush(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clFlush(command_queue); -} - -CL_API_ENTRY cl_int CL_API_CALL -clFinish(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clFinish(command_queue); -} - -// Enqueued Commands APIs -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueReadBuffer(cl_command_queue command_queue, - cl_mem buffer, - cl_bool blocking_read, - size_t offset, - size_t cb, - void * ptr, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueReadBuffer( - command_queue, - buffer, - blocking_read, - offset, - cb, - ptr, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueReadBufferRect( - cl_command_queue command_queue, - cl_mem buffer, - cl_bool blocking_read, - const size_t * buffer_origin, - const size_t * host_origin, - const size_t * region, - size_t buffer_row_pitch, - size_t buffer_slice_pitch, - size_t host_row_pitch, - size_t host_slice_pitch, - void * ptr, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_1 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueReadBufferRect( - command_queue, - buffer, - blocking_read, - buffer_origin, - host_origin, - region, - buffer_row_pitch, - buffer_slice_pitch, - host_row_pitch, - host_slice_pitch, - ptr, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueWriteBuffer(cl_command_queue command_queue, - cl_mem buffer, - cl_bool blocking_write, - size_t offset, - size_t cb, - const void * ptr, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueWriteBuffer( - command_queue, - buffer, - blocking_write, - offset, - cb, - ptr, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueWriteBufferRect( - cl_command_queue command_queue, - cl_mem buffer, - cl_bool blocking_read, - const size_t * buffer_origin, - const size_t * host_origin, - const size_t * region, - size_t buffer_row_pitch, - size_t buffer_slice_pitch, - size_t host_row_pitch, - size_t host_slice_pitch, - const void * ptr, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_1 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueWriteBufferRect( - command_queue, - buffer, - blocking_read, - buffer_origin, - host_origin, - region, - buffer_row_pitch, - buffer_slice_pitch, - host_row_pitch, - host_slice_pitch, - ptr, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueFillBuffer(cl_command_queue command_queue, - cl_mem buffer, - const void * pattern, - size_t pattern_size, - size_t offset, - size_t cb, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_2 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueFillBuffer( - command_queue, - buffer, - pattern, - pattern_size, - offset, - cb, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueCopyBuffer(cl_command_queue command_queue, - cl_mem src_buffer, - cl_mem dst_buffer, - size_t src_offset, - size_t dst_offset, - size_t cb, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueCopyBuffer( - command_queue, - src_buffer, - dst_buffer, - src_offset, - dst_offset, - cb, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueCopyBufferRect( - cl_command_queue command_queue, - cl_mem src_buffer, - cl_mem dst_buffer, - const size_t * src_origin, - const size_t * dst_origin, - const size_t * region, - size_t src_row_pitch, - size_t src_slice_pitch, - size_t dst_row_pitch, - size_t dst_slice_pitch, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_1 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueCopyBufferRect( - command_queue, - src_buffer, - dst_buffer, - src_origin, - dst_origin, - region, - src_row_pitch, - src_slice_pitch, - dst_row_pitch, - dst_slice_pitch, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueReadImage(cl_command_queue command_queue, - cl_mem image, - cl_bool blocking_read, - const size_t * origin, - const size_t * region, - size_t row_pitch, - size_t slice_pitch, - void * ptr, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueReadImage( - command_queue, - image, - blocking_read, - origin, - region, - row_pitch, - slice_pitch, - ptr, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueWriteImage(cl_command_queue command_queue, - cl_mem image, - cl_bool blocking_write, - const size_t * origin, - const size_t * region, - size_t input_row_pitch, - size_t input_slice_pitch, - const void * ptr, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueWriteImage( - command_queue, - image, - blocking_write, - origin, - region, - input_row_pitch, - input_slice_pitch, - ptr, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueFillImage(cl_command_queue command_queue, - cl_mem image, - const void * fill_color, - const size_t origin[3], - const size_t region[3], - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_2 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueFillImage( - command_queue, - image, - fill_color, - origin, - region, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueCopyImage(cl_command_queue command_queue, - cl_mem src_image, - cl_mem dst_image, - const size_t * src_origin, - const size_t * dst_origin, - const size_t * region, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueCopyImage( - command_queue, - src_image, - dst_image, - src_origin, - dst_origin, - region, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueCopyImageToBuffer(cl_command_queue command_queue, - cl_mem src_image, - cl_mem dst_buffer, - const size_t * src_origin, - const size_t * region, - size_t dst_offset, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueCopyImageToBuffer( - command_queue, - src_image, - dst_buffer, - src_origin, - region, - dst_offset, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueCopyBufferToImage(cl_command_queue command_queue, - cl_mem src_buffer, - cl_mem dst_image, - size_t src_offset, - const size_t * dst_origin, - const size_t * region, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueCopyBufferToImage( - command_queue, - src_buffer, - dst_image, - src_offset, - dst_origin, - region, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY void * CL_API_CALL -clEnqueueMapBuffer(cl_command_queue command_queue, - cl_mem buffer, - cl_bool blocking_map, - cl_map_flags map_flags, - size_t offset, - size_t cb, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueMapBuffer( - command_queue, - buffer, - blocking_map, - map_flags, - offset, - cb, - num_events_in_wait_list, - event_wait_list, - event, - errcode_ret); -} - -CL_API_ENTRY void * CL_API_CALL -clEnqueueMapImage(cl_command_queue command_queue, - cl_mem image, - cl_bool blocking_map, - cl_map_flags map_flags, - const size_t * origin, - const size_t * region, - size_t * image_row_pitch, - size_t * image_slice_pitch, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueMapImage( - command_queue, - image, - blocking_map, - map_flags, - origin, - region, - image_row_pitch, - image_slice_pitch, - num_events_in_wait_list, - event_wait_list, - event, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueUnmapMemObject(cl_command_queue command_queue, - cl_mem memobj, - void * mapped_ptr, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueUnmapMemObject( - command_queue, - memobj, - mapped_ptr, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueMigrateMemObjects(cl_command_queue command_queue, - cl_uint num_mem_objects, - const cl_mem * mem_objects, - cl_mem_migration_flags flags, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_2 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueMigrateMemObjects( - command_queue, - num_mem_objects, - mem_objects, - flags, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueNDRangeKernel(cl_command_queue command_queue, - cl_kernel kernel, - cl_uint work_dim, - const size_t * global_work_offset, - const size_t * global_work_size, - const size_t * local_work_size, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueNDRangeKernel( - command_queue, - kernel, - work_dim, - global_work_offset, - global_work_size, - local_work_size, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueTask(cl_command_queue command_queue, - cl_kernel kernel, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueTask( - command_queue, - kernel, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueNativeKernel(cl_command_queue command_queue, - void (CL_CALLBACK * user_func)(void *), - void * args, - size_t cb_args, - cl_uint num_mem_objects, - const cl_mem * mem_list, - const void ** args_mem_loc, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueNativeKernel( - command_queue, - user_func, - args, - cb_args, - num_mem_objects, - mem_list, - args_mem_loc, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueMarkerWithWaitList(cl_command_queue command_queue, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_2 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueMarkerWithWaitList( - command_queue, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueBarrierWithWaitList(cl_command_queue command_queue, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_2 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueBarrierWithWaitList( - command_queue, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY void * CL_API_CALL -clGetExtensionFunctionAddressForPlatform(cl_platform_id platform, - const char * function_name) CL_API_SUFFIX__VERSION_1_2 -{ - // make sure the ICD is initialized - khrIcdInitialize(); - - // return any ICD-aware extensions - - // Most extensions, including multi-vendor KHR and EXT extensions, - // do not need to be ICD-aware and do not require any ICD loader - // modifications. The KHR and EXT extensions below were added for - // backwards compatibility only. - #define CL_COMMON_EXTENSION_ENTRYPOINT_ADD(name) if (!strcmp(function_name, #name) ) return (void *)(size_t)&name - - // Functions supporting the creation of OpenCL Memory Objects - // from OpenGL Objects (cl_apple_gl_sharing, cl_khr_gl_sharing) - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLBuffer); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLTexture); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLTexture2D); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLTexture3D); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLRenderbuffer); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetGLObjectInfo); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetGLTextureInfo); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueAcquireGLObjects); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueReleaseGLObjects); - - // cl_khr_gl_sharing - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetGLContextInfoKHR); - - // cl_khr_gl_event - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateEventFromGLsyncKHR); - -#if defined(_WIN32) - // cl_khr_d3d10_sharing - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetDeviceIDsFromD3D10KHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D10BufferKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D10Texture2DKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D10Texture3DKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueAcquireD3D10ObjectsKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueReleaseD3D10ObjectsKHR); - // cl_khr_d3d11_sharing - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetDeviceIDsFromD3D11KHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D11BufferKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D11Texture2DKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D11Texture3DKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueAcquireD3D11ObjectsKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueReleaseD3D11ObjectsKHR); - // cl_khr_dx9_media_sharing - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetDeviceIDsFromDX9MediaAdapterKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromDX9MediaSurfaceKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueAcquireDX9MediaSurfacesKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueReleaseDX9MediaSurfacesKHR); -#endif - - // cl_ext_device_fission - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateSubDevicesEXT); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clRetainDeviceEXT); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clReleaseDeviceEXT); - - /* cl_khr_egl_image */ - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromEGLImageKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueAcquireEGLObjectsKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueReleaseEGLObjectsKHR); - - /* cl_khr_egl_event */ - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateEventFromEGLSyncKHR); - - /* cl_khr_sub_groups */ - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetKernelSubGroupInfoKHR); - - // This is not an ICD-aware extension, so call into the implementation - // to get the extension function address. - - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, NULL); - return platform->dispatch->clGetExtensionFunctionAddressForPlatform( - platform, - function_name); -} - -// Deprecated APIs -CL_API_ENTRY cl_int CL_API_CALL -clSetCommandQueueProperty(cl_command_queue command_queue, - cl_command_queue_properties properties, - cl_bool enable, - cl_command_queue_properties * old_properties) CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clSetCommandQueueProperty( - command_queue, - properties, - enable, - old_properties); -} - -CL_API_ENTRY cl_int CL_API_CALL -clCreateSubDevicesEXT( - cl_device_id in_device, - const cl_device_partition_property_ext * partition_properties, - cl_uint num_entries, - cl_device_id * out_devices, - cl_uint * num_devices) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(in_device, CL_INVALID_DEVICE); - return in_device->dispatch->clCreateSubDevicesEXT( - in_device, - partition_properties, - num_entries, - out_devices, - num_devices); -} - -CL_API_ENTRY cl_int CL_API_CALL -clRetainDeviceEXT(cl_device_id device) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); - return device->dispatch->clRetainDeviceEXT(device); -} - -CL_API_ENTRY cl_int CL_API_CALL -clReleaseDeviceEXT(cl_device_id device) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); - return device->dispatch->clReleaseDeviceEXT(device); -} - -CL_API_ENTRY cl_mem CL_API_CALL -clCreateImage2D(cl_context context, - cl_mem_flags flags, - const cl_image_format * image_format, - size_t image_width, - size_t image_height, - size_t image_row_pitch, - void * host_ptr, - cl_int * errcode_ret) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateImage2D( - context, - flags, - image_format, - image_width, - image_height, - image_row_pitch, - host_ptr, - errcode_ret); -} - -CL_API_ENTRY cl_mem CL_API_CALL -clCreateImage3D(cl_context context, - cl_mem_flags flags, - const cl_image_format * image_format, - size_t image_width, - size_t image_height, - size_t image_depth, - size_t image_row_pitch, - size_t image_slice_pitch, - void * host_ptr, - cl_int * errcode_ret) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateImage3D( - context, - flags, - image_format, - image_width, - image_height, - image_depth, - image_row_pitch, - image_slice_pitch, - host_ptr, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clUnloadCompiler(void) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED -{ - return CL_SUCCESS; -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueMarker(cl_command_queue command_queue, - cl_event * event) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueMarker( - command_queue, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueWaitForEvents(cl_command_queue command_queue, - cl_uint num_events, - const cl_event * event_list) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueWaitForEvents( - command_queue, - num_events, - event_list); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueBarrier(cl_command_queue command_queue) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueBarrier(command_queue); -} - -CL_API_ENTRY void * CL_API_CALL -clGetExtensionFunctionAddress(const char *function_name) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED -{ - size_t function_name_length = strlen(function_name); - KHRicdVendor* vendor = NULL; - - // make sure the ICD is initialized - khrIcdInitialize(); - - // return any ICD-aware extensions - - // Most extensions, including multi-vendor KHR and EXT extensions, - // do not need to be ICD-aware and do not require any ICD loader - // modifications. The KHR and EXT extensions below were added for - // backwards compatibility only. - #define CL_COMMON_EXTENSION_ENTRYPOINT_ADD(name) if (!strcmp(function_name, #name) ) return (void *)(size_t)&name - - // Functions supporting the creation of OpenCL Memory Objects - // from OpenGL Objects (cl_apple_gl_sharing, cl_khr_gl_sharing) - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLBuffer); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLTexture); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLTexture2D); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLTexture3D); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromGLRenderbuffer); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetGLObjectInfo); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetGLTextureInfo); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueAcquireGLObjects); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueReleaseGLObjects); - - // cl_khr_gl_sharing - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetGLContextInfoKHR); - - // cl_khr_gl_event - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateEventFromGLsyncKHR); - -#if defined(_WIN32) - // cl_khr_d3d10_sharing - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetDeviceIDsFromD3D10KHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D10BufferKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D10Texture2DKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D10Texture3DKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueAcquireD3D10ObjectsKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueReleaseD3D10ObjectsKHR); - // cl_khr_d3d11_sharing - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetDeviceIDsFromD3D11KHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D11BufferKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D11Texture2DKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromD3D11Texture3DKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueAcquireD3D11ObjectsKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueReleaseD3D11ObjectsKHR); - // cl_khr_dx9_media_sharing - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetDeviceIDsFromDX9MediaAdapterKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromDX9MediaSurfaceKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueAcquireDX9MediaSurfacesKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueReleaseDX9MediaSurfacesKHR); -#endif - - // cl_ext_device_fission - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateSubDevicesEXT); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clRetainDeviceEXT); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clReleaseDeviceEXT); - - /* cl_khr_egl_image */ - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateFromEGLImageKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueAcquireEGLObjectsKHR); - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clEnqueueReleaseEGLObjectsKHR); - - /* cl_khr_egl_event */ - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clCreateEventFromEGLSyncKHR); - - /* cl_khr_sub_groups */ - CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetKernelSubGroupInfoKHR); - - // fall back to vendor extension detection - for (vendor = khrIcdVendors; vendor; vendor = vendor->next) - { - size_t vendor_suffix_length = strlen(vendor->suffix); - if (vendor_suffix_length <= function_name_length && vendor_suffix_length > 0) - { - const char *function_suffix = function_name+function_name_length-vendor_suffix_length; - if (!strcmp(function_suffix, vendor->suffix) ) - { - return vendor->clGetExtensionFunctionAddress(function_name); - } - } - } - return NULL; -} - -// GL and other APIs -CL_API_ENTRY cl_mem CL_API_CALL clCreateFromGLBuffer( - cl_context context, - cl_mem_flags flags, - cl_GLuint bufobj, - int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateFromGLBuffer( - context, - flags, - bufobj, - errcode_ret); -} - -CL_API_ENTRY cl_mem CL_API_CALL clCreateFromGLTexture( - cl_context context, - cl_mem_flags flags, - cl_GLenum target, - cl_GLint miplevel, - cl_GLuint texture, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateFromGLTexture( - context, - flags, - target, - miplevel, - texture, - errcode_ret); -} - -CL_API_ENTRY cl_mem CL_API_CALL clCreateFromGLTexture2D( - cl_context context, - cl_mem_flags flags, - cl_GLenum target, - cl_GLint miplevel, - cl_GLuint texture, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateFromGLTexture2D( - context, - flags, - target, - miplevel, - texture, - errcode_ret); -} - -CL_API_ENTRY cl_mem CL_API_CALL clCreateFromGLTexture3D( - cl_context context, - cl_mem_flags flags, - cl_GLenum target, - cl_GLint miplevel, - cl_GLuint texture, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateFromGLTexture3D( - context, - flags, - target, - miplevel, - texture, - errcode_ret); -} - -CL_API_ENTRY cl_mem CL_API_CALL clCreateFromGLRenderbuffer( - cl_context context, - cl_mem_flags flags, - cl_GLuint renderbuffer, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateFromGLRenderbuffer( - context, - flags, - renderbuffer, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL clGetGLObjectInfo( - cl_mem memobj, - cl_gl_object_type * gl_object_type, - cl_GLuint * gl_object_name) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); - return memobj->dispatch->clGetGLObjectInfo( - memobj, - gl_object_type, - gl_object_name); -} - -CL_API_ENTRY cl_int CL_API_CALL clGetGLTextureInfo( - cl_mem memobj, - cl_gl_texture_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); - return memobj->dispatch->clGetGLTextureInfo( - memobj, - param_name, - param_value_size, - param_value, - param_value_size_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL clEnqueueAcquireGLObjects( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueAcquireGLObjects( - command_queue, - num_objects, - mem_objects, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL clEnqueueReleaseGLObjects( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueReleaseGLObjects( - command_queue, - num_objects, - mem_objects, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL clGetGLContextInfoKHR( - const cl_context_properties *properties, - cl_gl_context_info param_name, - size_t param_value_size, - void *param_value, - size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 -{ - cl_platform_id platform = NULL; - - // initialize the platforms (in case they have not been already) - khrIcdInitialize(); - - // determine the platform to use from the properties specified - khrIcdContextPropertiesGetPlatform(properties, &platform); - - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); - return platform->dispatch->clGetGLContextInfoKHR( - properties, - param_name, - param_value_size, - param_value, - param_value_size_ret); -} - -CL_API_ENTRY cl_event CL_API_CALL clCreateEventFromGLsyncKHR( - cl_context context, - cl_GLsync sync, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_1 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateEventFromGLsyncKHR( - context, - sync, - errcode_ret); -} - -#if defined(_WIN32) -/* - * - * cl_d3d10_sharing_khr - * - */ - -CL_API_ENTRY cl_int CL_API_CALL -clGetDeviceIDsFromD3D10KHR( - cl_platform_id platform, - cl_d3d10_device_source_khr d3d_device_source, - void *d3d_object, - cl_d3d10_device_set_khr d3d_device_set, - cl_uint num_entries, - cl_device_id *devices, - cl_uint *num_devices) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); - return platform->dispatch->clGetDeviceIDsFromD3D10KHR( - platform, - d3d_device_source, - d3d_object, - d3d_device_set, - num_entries, - devices, - num_devices); -} - -CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromD3D10BufferKHR( - cl_context context, - cl_mem_flags flags, - ID3D10Buffer *resource, - cl_int *errcode_ret) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateFromD3D10BufferKHR( - context, - flags, - resource, - errcode_ret); -} - -CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromD3D10Texture2DKHR( - cl_context context, - cl_mem_flags flags, - ID3D10Texture2D * resource, - UINT subresource, - cl_int * errcode_ret) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateFromD3D10Texture2DKHR( - context, - flags, - resource, - subresource, - errcode_ret); -} - -CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromD3D10Texture3DKHR( - cl_context context, - cl_mem_flags flags, - ID3D10Texture3D *resource, - UINT subresource, - cl_int *errcode_ret) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateFromD3D10Texture3DKHR( - context, - flags, - resource, - subresource, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueAcquireD3D10ObjectsKHR( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem *mem_objects, - cl_uint num_events_in_wait_list, - const cl_event *event_wait_list, - cl_event *event) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueAcquireD3D10ObjectsKHR( - command_queue, - num_objects, - mem_objects, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueReleaseD3D10ObjectsKHR( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem *mem_objects, - cl_uint num_events_in_wait_list, - const cl_event *event_wait_list, - cl_event *event) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueReleaseD3D10ObjectsKHR( - command_queue, - num_objects, - mem_objects, - num_events_in_wait_list, - event_wait_list, - event); -} - -/* - * - * cl_d3d11_sharing_khr - * - */ - -CL_API_ENTRY cl_int CL_API_CALL -clGetDeviceIDsFromD3D11KHR( - cl_platform_id platform, - cl_d3d11_device_source_khr d3d_device_source, - void * d3d_object, - cl_d3d11_device_set_khr d3d_device_set, - cl_uint num_entries, - cl_device_id * devices, - cl_uint * num_devices) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); - return platform->dispatch->clGetDeviceIDsFromD3D11KHR( - platform, - d3d_device_source, - d3d_object, - d3d_device_set, - num_entries, - devices, - num_devices); -} - -CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromD3D11BufferKHR( - cl_context context, - cl_mem_flags flags, - ID3D11Buffer * resource, - cl_int * errcode_ret) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateFromD3D11BufferKHR( - context, - flags, - resource, - errcode_ret); -} - -CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromD3D11Texture2DKHR( - cl_context context, - cl_mem_flags flags, - ID3D11Texture2D * resource, - UINT subresource, - cl_int * errcode_ret) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateFromD3D11Texture2DKHR( - context, - flags, - resource, - subresource, - errcode_ret); -} - -CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromD3D11Texture3DKHR( - cl_context context, - cl_mem_flags flags, - ID3D11Texture3D * resource, - UINT subresource, - cl_int * errcode_ret) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateFromD3D11Texture3DKHR( - context, - flags, - resource, - subresource, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueAcquireD3D11ObjectsKHR( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueAcquireD3D11ObjectsKHR( - command_queue, - num_objects, - mem_objects, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueReleaseD3D11ObjectsKHR( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueReleaseD3D11ObjectsKHR( - command_queue, - num_objects, - mem_objects, - num_events_in_wait_list, - event_wait_list, - event); -} - -/* - * - * cl_khr_dx9_media_sharing - * - */ - -CL_API_ENTRY cl_int CL_API_CALL -clGetDeviceIDsFromDX9MediaAdapterKHR( - cl_platform_id platform, - cl_uint num_media_adapters, - cl_dx9_media_adapter_type_khr * media_adapters_type, - void * media_adapters, - cl_dx9_media_adapter_set_khr media_adapter_set, - cl_uint num_entries, - cl_device_id * devices, - cl_uint * num_devices) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); - return platform->dispatch->clGetDeviceIDsFromDX9MediaAdapterKHR( - platform, - num_media_adapters, - media_adapters_type, - media_adapters, - media_adapter_set, - num_entries, - devices, - num_devices); -} - -CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromDX9MediaSurfaceKHR( - cl_context context, - cl_mem_flags flags, - cl_dx9_media_adapter_type_khr adapter_type, - void * surface_info, - cl_uint plane, - cl_int * errcode_ret) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateFromDX9MediaSurfaceKHR( - context, - flags, - adapter_type, - surface_info, - plane, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueAcquireDX9MediaSurfacesKHR( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueAcquireDX9MediaSurfacesKHR( - command_queue, - num_objects, - mem_objects, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueReleaseDX9MediaSurfacesKHR( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueReleaseDX9MediaSurfacesKHR( - command_queue, - num_objects, - mem_objects, - num_events_in_wait_list, - event_wait_list, - event); -} - -#endif - -CL_API_ENTRY cl_int CL_API_CALL -clSetEventCallback( - cl_event event, - cl_int command_exec_callback_type, - void (CL_CALLBACK *pfn_notify)(cl_event, cl_int, void *), - void *user_data) CL_API_SUFFIX__VERSION_1_1 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); - return event->dispatch->clSetEventCallback( - event, - command_exec_callback_type, - pfn_notify, - user_data); -} - -CL_API_ENTRY cl_mem CL_API_CALL -clCreateSubBuffer( - cl_mem buffer, - cl_mem_flags flags, - cl_buffer_create_type buffer_create_type, - const void * buffer_create_info, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_1 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(buffer, CL_INVALID_MEM_OBJECT); - return buffer->dispatch->clCreateSubBuffer( - buffer, - flags, - buffer_create_type, - buffer_create_info, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clSetMemObjectDestructorCallback( - cl_mem memobj, - void (CL_CALLBACK * pfn_notify)( cl_mem, void*), - void * user_data ) CL_API_SUFFIX__VERSION_1_1 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); - return memobj->dispatch->clSetMemObjectDestructorCallback( - memobj, - pfn_notify, - user_data); -} - -CL_API_ENTRY cl_event CL_API_CALL -clCreateUserEvent( - cl_context context, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_1 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateUserEvent( - context, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clSetUserEventStatus( - cl_event event, - cl_int execution_status) CL_API_SUFFIX__VERSION_1_1 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); - return event->dispatch->clSetUserEventStatus( - event, - execution_status); -} - -CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromEGLImageKHR( - cl_context context, - CLeglDisplayKHR display, - CLeglImageKHR image, - cl_mem_flags flags, - const cl_egl_image_properties_khr *properties, - cl_int *errcode_ret) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateFromEGLImageKHR( - context, - display, - image, - flags, - properties, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueAcquireEGLObjectsKHR( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem *mem_objects, - cl_uint num_events_in_wait_list, - const cl_event *event_wait_list, - cl_event *event) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueAcquireEGLObjectsKHR( - command_queue, - num_objects, - mem_objects, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueReleaseEGLObjectsKHR( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem *mem_objects, - cl_uint num_events_in_wait_list, - const cl_event *event_wait_list, - cl_event *event) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueReleaseEGLObjectsKHR( - command_queue, - num_objects, - mem_objects, - num_events_in_wait_list, - event_wait_list, - event); -} - -/* cl_khr_egl_event */ -CL_API_ENTRY cl_event CL_API_CALL -clCreateEventFromEGLSyncKHR( - cl_context context, - CLeglSyncKHR sync, - CLeglDisplayKHR display, - cl_int *errcode_ret) -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateEventFromEGLSyncKHR( - context, - sync, - display, - errcode_ret); -} - -CL_API_ENTRY cl_command_queue CL_API_CALL -clCreateCommandQueueWithProperties( - cl_context context, - cl_device_id device, - const cl_queue_properties * properties, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_2_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateCommandQueueWithProperties( - context, - device, - properties, - errcode_ret); -} - -CL_API_ENTRY cl_mem CL_API_CALL -clCreatePipe( - cl_context context, - cl_mem_flags flags, - cl_uint pipe_packet_size, - cl_uint pipe_max_packets, - const cl_pipe_properties * properties, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_2_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreatePipe( - context, - flags, - pipe_packet_size, - pipe_max_packets, - properties, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetPipeInfo( - cl_mem pipe, - cl_pipe_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_2_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(pipe, CL_INVALID_MEM_OBJECT); - return pipe->dispatch->clGetPipeInfo( - pipe, - param_name, - param_value_size, - param_value, - param_value_size_ret); -} - -CL_API_ENTRY void * CL_API_CALL -clSVMAlloc( - cl_context context, - cl_svm_mem_flags flags, - size_t size, - cl_uint alignment) CL_API_SUFFIX__VERSION_2_0 -{ - if (!context) { - return NULL; - } - return context->dispatch->clSVMAlloc( - context, - flags, - size, - alignment); -} - -CL_API_ENTRY void CL_API_CALL -clSVMFree( - cl_context context, - void * svm_pointer) CL_API_SUFFIX__VERSION_2_0 -{ - if (!context || !svm_pointer) { - return; - } - context->dispatch->clSVMFree( - context, - svm_pointer); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueSVMFree( - cl_command_queue command_queue, - cl_uint num_svm_pointers, - void* svm_pointers[], - void (CL_CALLBACK* pfn_free_func)( - cl_command_queue queue, - cl_uint num_svm_pointers, - void* svm_pointers[], - void* user_data), - void* user_data, - cl_uint num_events_in_wait_list, - const cl_event* event_wait_list, - cl_event* event) CL_API_SUFFIX__VERSION_2_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueSVMFree( - command_queue, - num_svm_pointers, - svm_pointers, - pfn_free_func, - user_data, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueSVMMemcpy( - cl_command_queue command_queue, - cl_bool blocking_copy, - void * dst_ptr, - const void * src_ptr, - size_t size, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_2_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueSVMMemcpy( - command_queue, - blocking_copy, - dst_ptr, - src_ptr, - size, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueSVMMemFill( - cl_command_queue command_queue, - void * svm_ptr, - const void * pattern, - size_t pattern_size, - size_t size, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_2_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueSVMMemFill( - command_queue, - svm_ptr, - pattern, - pattern_size, - size, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueSVMMap( - cl_command_queue command_queue, - cl_bool blocking_map, - cl_map_flags flags, - void * svm_ptr, - size_t size, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_2_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueSVMMap( - command_queue, - blocking_map, - flags, - svm_ptr, - size, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueSVMUnmap( - cl_command_queue command_queue, - void * svm_ptr, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_2_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueSVMUnmap( - command_queue, - svm_ptr, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_sampler CL_API_CALL -clCreateSamplerWithProperties( - cl_context context, - const cl_sampler_properties * sampler_properties, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_2_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateSamplerWithProperties( - context, - sampler_properties, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clSetKernelArgSVMPointer( - cl_kernel kernel, - cl_uint arg_index, - const void * arg_value) CL_API_SUFFIX__VERSION_2_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); - return kernel->dispatch->clSetKernelArgSVMPointer( - kernel, - arg_index, - arg_value); -} - -CL_API_ENTRY cl_int CL_API_CALL -clSetKernelExecInfo( - cl_kernel kernel, - cl_kernel_exec_info param_name, - size_t param_value_size, - const void * param_value) CL_API_SUFFIX__VERSION_2_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); - return kernel->dispatch->clSetKernelExecInfo( - kernel, - param_name, - param_value_size, - param_value); -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetKernelSubGroupInfoKHR( - cl_kernel in_kernel, - cl_device_id in_device, - cl_kernel_sub_group_info param_name, - size_t input_value_size, - const void * input_value, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_EXT_SUFFIX__VERSION_2_0 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(in_kernel, CL_INVALID_KERNEL); - return in_kernel->dispatch->clGetKernelSubGroupInfoKHR( - in_kernel, - in_device, - param_name, - input_value_size, - input_value, - param_value_size, - param_value, - param_value_size_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clSetDefaultDeviceCommandQueue( - cl_context context, - cl_device_id device, - cl_command_queue command_queue) CL_API_SUFFIX__VERSION_2_1 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(context, CL_INVALID_CONTEXT); - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); - return context->dispatch->clSetDefaultDeviceCommandQueue( - context, - device, - command_queue); -} - -CL_API_ENTRY cl_program CL_API_CALL -clCreateProgramWithIL( - cl_context context, - const void * il, - size_t length, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_2_1 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); - return context->dispatch->clCreateProgramWithIL( - context, - il, - length, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetKernelSubGroupInfo( - cl_kernel kernel, - cl_device_id device, - cl_kernel_sub_group_info param_name, - size_t input_value_size, - const void * input_value, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_2_1 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); - return kernel->dispatch->clGetKernelSubGroupInfo( - kernel, - device, - param_name, - input_value_size, - input_value, - param_value_size, - param_value, - param_value_size_ret); -} - -CL_API_ENTRY cl_kernel CL_API_CALL -clCloneKernel( - cl_kernel source_kernel, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_2_1 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(source_kernel, CL_INVALID_KERNEL); - return source_kernel->dispatch->clCloneKernel( - source_kernel, - errcode_ret); -} - -CL_API_ENTRY cl_int CL_API_CALL -clEnqueueSVMMigrateMem( - cl_command_queue command_queue, - cl_uint num_svm_pointers, - const void ** svm_pointers, - const size_t * sizes, - cl_mem_migration_flags flags, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_2_1 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); - return command_queue->dispatch->clEnqueueSVMMigrateMem( - command_queue, - num_svm_pointers, - svm_pointers, - sizes, - flags, - num_events_in_wait_list, - event_wait_list, - event); -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetDeviceAndHostTimer( - cl_device_id device, - cl_ulong * device_timestamp, - cl_ulong * host_timestamp) CL_API_SUFFIX__VERSION_2_1 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); - return device->dispatch->clGetDeviceAndHostTimer( - device, - device_timestamp, - host_timestamp); -} - -CL_API_ENTRY cl_int CL_API_CALL -clGetHostTimer( - cl_device_id device, - cl_ulong * host_timestamp) CL_API_SUFFIX__VERSION_2_1 -{ - KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); - return device->dispatch->clGetHostTimer( - device, - host_timestamp); -} - - diff --git a/icd_dispatch.h b/icd_dispatch.h deleted file mode 100644 index da7a6008..00000000 --- a/icd_dispatch.h +++ /dev/null @@ -1,1530 +0,0 @@ -/* - * Copyright (c) 2016 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software source and associated documentation files (the "Materials"), - * to deal in the Materials without restriction, including without limitation - * the rights to use, copy, modify, compile, merge, publish, distribute, - * sublicense, and/or sell copies of the Materials, and to permit persons to - * whom the Materials are furnished to do so, subject the following terms and - * conditions: - * - * All modifications to the Materials used to create a binary that is - * distributed to third parties shall be provided to Khronos with an - * unrestricted license to use for the purposes of implementing bug fixes and - * enhancements to the Materials; - * - * If the binary is used as part of an OpenCL(TM) implementation, whether binary - * is distributed together with or separately to that implementation, then - * recipient must become an OpenCL Adopter and follow the published OpenCL - * conformance process for that implementation, details at: - * http://www.khronos.org/conformance/; - * - * The above copyright notice, the OpenCL trademark license, and this permission - * notice shall be included in all copies or substantial portions of the - * Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN - * THE MATERIALS. - * - * OpenCL is a trademark of Apple Inc. used under license by Khronos. - */ - -#ifndef _ICD_DISPATCH_H_ -#define _ICD_DISPATCH_H_ - -#ifndef CL_USE_DEPRECATED_OPENCL_1_0_APIS -#define CL_USE_DEPRECATED_OPENCL_1_0_APIS -#endif - -#ifndef CL_USE_DEPRECATED_OPENCL_1_1_APIS -#define CL_USE_DEPRECATED_OPENCL_1_1_APIS -#endif - -#ifndef CL_USE_DEPRECATED_OPENCL_1_2_APIS -#define CL_USE_DEPRECATED_OPENCL_1_2_APIS -#endif - -#ifndef CL_USE_DEPRECATED_OPENCL_2_0_APIS -#define CL_USE_DEPRECATED_OPENCL_2_0_APIS -#endif - -// cl.h -#include - -// cl_gl.h and required files -#ifdef _WIN32 -#include -#include -#include -#include -#include -#include -#endif -#include -#include -#include -#include - -/* - * - * function pointer typedefs - * - */ - -// Platform APIs -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetPlatformIDs)( - cl_uint num_entries, - cl_platform_id * platforms, - cl_uint * num_platforms) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetPlatformInfo)( - cl_platform_id platform, - cl_platform_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; - -// Device APIs -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetDeviceIDs)( - cl_platform_id platform, - cl_device_type device_type, - cl_uint num_entries, - cl_device_id * devices, - cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetDeviceInfo)( - cl_device_id device, - cl_device_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clCreateSubDevices)( - cl_device_id in_device, - const cl_device_partition_property * partition_properties, - cl_uint num_entries, - cl_device_id * out_devices, - cl_uint * num_devices); - -typedef CL_API_ENTRY cl_int (CL_API_CALL * KHRpfn_clRetainDevice)( - cl_device_id device) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL * KHRpfn_clReleaseDevice)( - cl_device_id device) CL_API_SUFFIX__VERSION_1_2; - -// Context APIs -typedef CL_API_ENTRY cl_context (CL_API_CALL *KHRpfn_clCreateContext)( - const cl_context_properties * properties, - cl_uint num_devices, - const cl_device_id * devices, - void (CL_CALLBACK *pfn_notify)(const char *, const void *, size_t, void *), - void * user_data, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_context (CL_API_CALL *KHRpfn_clCreateContextFromType)( - const cl_context_properties * properties, - cl_device_type device_type, - void (CL_CALLBACK *pfn_notify)(const char *, const void *, size_t, void *), - void * user_data, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clRetainContext)( - cl_context context) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clReleaseContext)( - cl_context context) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetContextInfo)( - cl_context context, - cl_context_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; - -// Command Queue APIs -typedef CL_API_ENTRY cl_command_queue (CL_API_CALL *KHRpfn_clCreateCommandQueue)( - cl_context context, - cl_device_id device, - cl_command_queue_properties properties, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_command_queue (CL_API_CALL *KHRpfn_clCreateCommandQueueWithProperties)( - cl_context /* context */, - cl_device_id /* device */, - const cl_queue_properties * /* properties */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_2_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clRetainCommandQueue)( - cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clReleaseCommandQueue)( - cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetCommandQueueInfo)( - cl_command_queue command_queue, - cl_command_queue_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; - -// Memory Object APIs -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateBuffer)( - cl_context context, - cl_mem_flags flags, - size_t size, - void * host_ptr, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateImage)( - cl_context context, - cl_mem_flags flags, - const cl_image_format * image_format, - const cl_image_desc * image_desc, - void * host_ptr, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clRetainMemObject)(cl_mem memobj) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clReleaseMemObject)(cl_mem memobj) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetSupportedImageFormats)( - cl_context context, - cl_mem_flags flags, - cl_mem_object_type image_type, - cl_uint num_entries, - cl_image_format * image_formats, - cl_uint * num_image_formats) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetMemObjectInfo)( - cl_mem memobj, - cl_mem_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetImageInfo)( - cl_mem image, - cl_image_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreatePipe)( - cl_context /* context */, - cl_mem_flags /* flags */, - cl_uint /* pipe_packet_size */, - cl_uint /* pipe_max_packets */, - const cl_pipe_properties * /* properties */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_2_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetPipeInfo)( - cl_mem /* pipe */, - cl_pipe_info /* param_name */, - size_t /* param_value_size */, - void * /* param_value */, - size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_2_0; - -typedef CL_API_ENTRY void * (CL_API_CALL *KHRpfn_clSVMAlloc)( - cl_context /* context */, - cl_svm_mem_flags /* flags */, - size_t /* size */, - unsigned int /* alignment */) CL_API_SUFFIX__VERSION_2_0; - -typedef CL_API_ENTRY void (CL_API_CALL *KHRpfn_clSVMFree)( - cl_context /* context */, - void * /* svm_pointer */) CL_API_SUFFIX__VERSION_2_0; - -// Sampler APIs -typedef CL_API_ENTRY cl_sampler (CL_API_CALL *KHRpfn_clCreateSampler)( - cl_context context, - cl_bool normalized_coords, - cl_addressing_mode addressing_mode, - cl_filter_mode filter_mode, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clRetainSampler)(cl_sampler sampler) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clReleaseSampler)(cl_sampler sampler) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetSamplerInfo)( - cl_sampler sampler, - cl_sampler_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_sampler (CL_API_CALL *KHRpfn_clCreateSamplerWithProperties)( - cl_context /* context */, - const cl_sampler_properties * /* sampler_properties */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_2_0; - -// Program Object APIs -typedef CL_API_ENTRY cl_program (CL_API_CALL *KHRpfn_clCreateProgramWithSource)( - cl_context context, - cl_uint count, - const char ** strings, - const size_t * lengths, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_program (CL_API_CALL *KHRpfn_clCreateProgramWithBinary)( - cl_context context, - cl_uint num_devices, - const cl_device_id * device_list, - const size_t * lengths, - const unsigned char ** binaries, - cl_int * binary_status, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_program (CL_API_CALL *KHRpfn_clCreateProgramWithBuiltInKernels)( - cl_context context, - cl_uint num_devices, - const cl_device_id * device_list, - const char * kernel_names, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clRetainProgram)(cl_program program) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clReleaseProgram)(cl_program program) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clBuildProgram)( - cl_program program, - cl_uint num_devices, - const cl_device_id * device_list, - const char * options, - void (CL_CALLBACK *pfn_notify)(cl_program program, void * user_data), - void * user_data) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clCompileProgram)( - cl_program program, - cl_uint num_devices, - const cl_device_id * device_list, - const char * options, - cl_uint num_input_headers, - const cl_program * input_headers, - const char ** header_include_names, - void (CL_CALLBACK * pfn_notify)(cl_program program, void * user_data), - void * user_data) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_program (CL_API_CALL *KHRpfn_clLinkProgram)( - cl_context context, - cl_uint num_devices, - const cl_device_id * device_list, - const char * options, - cl_uint num_input_programs, - const cl_program * input_programs, - void (CL_CALLBACK * pfn_notify)(cl_program program, void * user_data), - void * user_data, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clSetProgramSpecializationConstant)( - cl_program program, - cl_uint spec_id, - size_t spec_size, - const void* spec_value) CL_API_SUFFIX__VERSION_2_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clSetProgramReleaseCallback)( - cl_program program, - void (CL_CALLBACK * pfn_notify)(cl_program program, void * user_data), - void * user_data) CL_API_SUFFIX__VERSION_2_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clUnloadPlatformCompiler)( - cl_platform_id platform) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetProgramInfo)( - cl_program program, - cl_program_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetProgramBuildInfo)( - cl_program program, - cl_device_id device, - cl_program_build_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; - -// Kernel Object APIs -typedef CL_API_ENTRY cl_kernel (CL_API_CALL *KHRpfn_clCreateKernel)( - cl_program program, - const char * kernel_name, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clCreateKernelsInProgram)( - cl_program program, - cl_uint num_kernels, - cl_kernel * kernels, - cl_uint * num_kernels_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clRetainKernel)(cl_kernel kernel) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clReleaseKernel)(cl_kernel kernel) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clSetKernelArg)( - cl_kernel kernel, - cl_uint arg_index, - size_t arg_size, - const void * arg_value) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetKernelInfo)( - cl_kernel kernel, - cl_kernel_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetKernelArgInfo)( - cl_kernel kernel, - cl_uint arg_indx, - cl_kernel_arg_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetKernelWorkGroupInfo)( - cl_kernel kernel, - cl_device_id device, - cl_kernel_work_group_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clSetKernelArgSVMPointer)( - cl_kernel /* kernel */, - cl_uint /* arg_index */, - const void * /* arg_value */) CL_API_SUFFIX__VERSION_2_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clSetKernelExecInfo)( - cl_kernel /* kernel */, - cl_kernel_exec_info /* param_name */, - size_t /* param_value_size */, - const void * /* param_value */) CL_API_SUFFIX__VERSION_2_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetKernelSubGroupInfoKHR)( - cl_kernel /* in_kernel */, - cl_device_id /*in_device*/, - cl_kernel_sub_group_info /* param_name */, - size_t /*input_value_size*/, - const void * /*input_value*/, - size_t /*param_value_size*/, - void* /*param_value*/, - size_t* /*param_value_size_ret*/) CL_EXT_SUFFIX__VERSION_2_0; - -// Event Object APIs -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clWaitForEvents)( - cl_uint num_events, - const cl_event * event_list) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetEventInfo)( - cl_event event, - cl_event_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clRetainEvent)(cl_event event) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clReleaseEvent)(cl_event event) CL_API_SUFFIX__VERSION_1_0; - -// Profiling APIs -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetEventProfilingInfo)( - cl_event event, - cl_profiling_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; - -// Flush and Finish APIs -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clFlush)(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clFinish)(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0; - -// Enqueued Commands APIs -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueReadBuffer)( - cl_command_queue command_queue, - cl_mem buffer, - cl_bool blocking_read, - size_t offset, - size_t cb, - void * ptr, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueReadBufferRect)( - cl_command_queue command_queue, - cl_mem buffer, - cl_bool blocking_read, - const size_t * buffer_origin, - const size_t * host_origin, - const size_t * region, - size_t buffer_row_pitch, - size_t buffer_slice_pitch, - size_t host_row_pitch, - size_t host_slice_pitch, - void * ptr, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_1; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueWriteBuffer)( - cl_command_queue command_queue, - cl_mem buffer, - cl_bool blocking_write, - size_t offset, - size_t cb, - const void * ptr, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueWriteBufferRect)( - cl_command_queue command_queue, - cl_mem buffer, - cl_bool blocking_read, - const size_t * buffer_origin, - const size_t * host_origin, - const size_t * region, - size_t buffer_row_pitch, - size_t buffer_slice_pitch, - size_t host_row_pitch, - size_t host_slice_pitch, - const void * ptr, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_1; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueFillBuffer)( - cl_command_queue command_queue, - cl_mem buffer, - const void * pattern, - size_t pattern_size, - size_t offset, - size_t cb, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueCopyBuffer)( - cl_command_queue command_queue, - cl_mem src_buffer, - cl_mem dst_buffer, - size_t src_offset, - size_t dst_offset, - size_t cb, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueCopyBufferRect)( - cl_command_queue command_queue, - cl_mem src_buffer, - cl_mem dst_buffer, - const size_t * src_origin, - const size_t * dst_origin, - const size_t * region, - size_t src_row_pitch, - size_t src_slice_pitch, - size_t dst_row_pitch, - size_t dst_slice_pitch, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_1; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueReadImage)( - cl_command_queue command_queue, - cl_mem image, - cl_bool blocking_read, - const size_t * origin, - const size_t * region, - size_t row_pitch, - size_t slice_pitch, - void * ptr, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueWriteImage)( - cl_command_queue command_queue, - cl_mem image, - cl_bool blocking_write, - const size_t * origin, - const size_t * region, - size_t input_row_pitch, - size_t input_slice_pitch, - const void * ptr, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueFillImage)( - cl_command_queue command_queue, - cl_mem image, - const void * fill_color, - const size_t origin[3], - const size_t region[3], - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueCopyImage)( - cl_command_queue command_queue, - cl_mem src_image, - cl_mem dst_image, - const size_t * src_origin, - const size_t * dst_origin, - const size_t * region, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueCopyImageToBuffer)( - cl_command_queue command_queue, - cl_mem src_image, - cl_mem dst_buffer, - const size_t * src_origin, - const size_t * region, - size_t dst_offset, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueCopyBufferToImage)( - cl_command_queue command_queue, - cl_mem src_buffer, - cl_mem dst_image, - size_t src_offset, - const size_t * dst_origin, - const size_t * region, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY void * (CL_API_CALL *KHRpfn_clEnqueueMapBuffer)( - cl_command_queue command_queue, - cl_mem buffer, - cl_bool blocking_map, - cl_map_flags map_flags, - size_t offset, - size_t cb, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY void * (CL_API_CALL *KHRpfn_clEnqueueMapImage)( - cl_command_queue command_queue, - cl_mem image, - cl_bool blocking_map, - cl_map_flags map_flags, - const size_t * origin, - const size_t * region, - size_t * image_row_pitch, - size_t * image_slice_pitch, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueUnmapMemObject)( - cl_command_queue command_queue, - cl_mem memobj, - void * mapped_ptr, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueMigrateMemObjects)( - cl_command_queue command_queue, - cl_uint num_mem_objects, - const cl_mem * mem_objects, - cl_mem_migration_flags flags, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueNDRangeKernel)( - cl_command_queue command_queue, - cl_kernel kernel, - cl_uint work_dim, - const size_t * global_work_offset, - const size_t * global_work_size, - const size_t * local_work_size, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueTask)( - cl_command_queue command_queue, - cl_kernel kernel, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueNativeKernel)( - cl_command_queue command_queue, - void (CL_CALLBACK * user_func)(void *), - void * args, - size_t cb_args, - cl_uint num_mem_objects, - const cl_mem * mem_list, - const void ** args_mem_loc, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueMarkerWithWaitList)( - cl_command_queue command_queue, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueBarrierWithWaitList)( - cl_command_queue command_queue, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY void * (CL_API_CALL *KHRpfn_clGetExtensionFunctionAddressForPlatform)( - cl_platform_id platform, - const char * function_name) CL_API_SUFFIX__VERSION_1_2; - -// Shared Virtual Memory APIs -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueSVMFree)( - cl_command_queue /* command_queue */, - cl_uint /* num_svm_pointers */, - void ** /* svm_pointers */, - void (CL_CALLBACK *pfn_free_func)( - cl_command_queue /* queue */, - cl_uint /* num_svm_pointers */, - void ** /* svm_pointers[] */, - void * /* user_data */), - void * /* user_data */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_2_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueSVMMemcpy)( - cl_command_queue /* command_queue */, - cl_bool /* blocking_copy */, - void * /* dst_ptr */, - const void * /* src_ptr */, - size_t /* size */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_2_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueSVMMemFill)( - cl_command_queue /* command_queue */, - void * /* svm_ptr */, - const void * /* pattern */, - size_t /* pattern_size */, - size_t /* size */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_2_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueSVMMap)( - cl_command_queue /* command_queue */, - cl_bool /* blocking_map */, - cl_map_flags /* map_flags */, - void * /* svm_ptr */, - size_t /* size */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_2_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueSVMUnmap)( - cl_command_queue /* command_queue */, - void * /* svm_ptr */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_2_0; - -// Deprecated APIs -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clSetCommandQueueProperty)( - cl_command_queue command_queue, - cl_command_queue_properties properties, - cl_bool enable, - cl_command_queue_properties * old_properties) CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateImage2D)( - cl_context context, - cl_mem_flags flags, - const cl_image_format * image_format, - size_t image_width, - size_t image_height, - size_t image_row_pitch, - void * host_ptr, - cl_int * errcode_ret) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateImage3D)( - cl_context context, - cl_mem_flags flags, - const cl_image_format * image_format, - size_t image_width, - size_t image_height, - size_t image_depth, - size_t image_row_pitch, - size_t image_slice_pitch, - void * host_ptr, - cl_int * errcode_ret) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clUnloadCompiler)(void) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueMarker)( - cl_command_queue command_queue, - cl_event * event) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueWaitForEvents)( - cl_command_queue command_queue, - cl_uint num_events, - const cl_event * event_list) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueBarrier)(cl_command_queue command_queue) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; - -typedef CL_API_ENTRY void * (CL_API_CALL *KHRpfn_clGetExtensionFunctionAddress)(const char *function_name) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; - -// GL and other APIs -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromGLBuffer)( - cl_context context, - cl_mem_flags flags, - cl_GLuint bufobj, - int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromGLTexture)( - cl_context context, - cl_mem_flags flags, - cl_GLenum target, - cl_GLint miplevel, - cl_GLuint texture, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromGLTexture2D)( - cl_context context, - cl_mem_flags flags, - cl_GLenum target, - cl_GLint miplevel, - cl_GLuint texture, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromGLTexture3D)( - cl_context context, - cl_mem_flags flags, - cl_GLenum target, - cl_GLint miplevel, - cl_GLuint texture, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromGLRenderbuffer)( - cl_context context, - cl_mem_flags flags, - cl_GLuint renderbuffer, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetGLObjectInfo)( - cl_mem memobj, - cl_gl_object_type * gl_object_type, - cl_GLuint * gl_object_name) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetGLTextureInfo)( - cl_mem memobj, - cl_gl_texture_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueAcquireGLObjects)( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueReleaseGLObjects)( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - -/* cl_khr_gl_sharing */ -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetGLContextInfoKHR)( - const cl_context_properties *properties, - cl_gl_context_info param_name, - size_t param_value_size, - void *param_value, - size_t *param_value_size_ret); - -/* cl_khr_gl_event */ -typedef CL_API_ENTRY cl_event (CL_API_CALL *KHRpfn_clCreateEventFromGLsyncKHR)( - cl_context context, - cl_GLsync sync, - cl_int *errcode_ret); - - -#if defined(_WIN32) - -/* cl_khr_d3d10_sharing */ - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetDeviceIDsFromD3D10KHR)( - cl_platform_id platform, - cl_d3d10_device_source_khr d3d_device_source, - void * d3d_object, - cl_d3d10_device_set_khr d3d_device_set, - cl_uint num_entries, - cl_device_id * devices, - cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromD3D10BufferKHR)( - cl_context context, - cl_mem_flags flags, - ID3D10Buffer * resource, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromD3D10Texture2DKHR)( - cl_context context, - cl_mem_flags flags, - ID3D10Texture2D * resource, - UINT subresource, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromD3D10Texture3DKHR)( - cl_context context, - cl_mem_flags flags, - ID3D10Texture3D * resource, - UINT subresource, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueAcquireD3D10ObjectsKHR)( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueReleaseD3D10ObjectsKHR)( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetDeviceIDsFromD3D10KHR( - cl_platform_id platform, - cl_d3d10_device_source_khr d3d_device_source, - void *d3d_object, - cl_d3d10_device_set_khr d3d_device_set, - cl_uint num_entries, - cl_device_id *devices, - cl_uint *num_devices); - -extern CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromD3D10BufferKHR( - cl_context context, - cl_mem_flags flags, - ID3D10Buffer *resource, - cl_int *errcode_ret); - -extern CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromD3D10Texture2DKHR( - cl_context context, - cl_mem_flags flags, - ID3D10Texture2D * resource, - UINT subresource, - cl_int * errcode_ret); - -extern CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromD3D10Texture3DKHR( - cl_context context, - cl_mem_flags flags, - ID3D10Texture3D *resource, - UINT subresource, - cl_int *errcode_ret); - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueAcquireD3D10ObjectsKHR( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem *mem_objects, - cl_uint num_events_in_wait_list, - const cl_event *event_wait_list, - cl_event *event); - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueReleaseD3D10ObjectsKHR( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem *mem_objects, - cl_uint num_events_in_wait_list, - const cl_event *event_wait_list, - cl_event *event); - -/* cl_khr_d3d11_sharing */ -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetDeviceIDsFromD3D11KHR)( - cl_platform_id platform, - cl_d3d11_device_source_khr d3d_device_source, - void * d3d_object, - cl_d3d11_device_set_khr d3d_device_set, - cl_uint num_entries, - cl_device_id * devices, - cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromD3D11BufferKHR)( - cl_context context, - cl_mem_flags flags, - ID3D11Buffer * resource, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromD3D11Texture2DKHR)( - cl_context context, - cl_mem_flags flags, - ID3D11Texture2D * resource, - UINT subresource, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromD3D11Texture3DKHR)( - cl_context context, - cl_mem_flags flags, - ID3D11Texture3D * resource, - UINT subresource, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueAcquireD3D11ObjectsKHR)( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueReleaseD3D11ObjectsKHR)( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_2; - -/* cl_khr_dx9_media_sharing */ -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetDeviceIDsFromDX9MediaAdapterKHR)( - cl_platform_id platform, - cl_uint num_media_adapters, - cl_dx9_media_adapter_type_khr * media_adapters_type, - void * media_adapters, - cl_dx9_media_adapter_set_khr media_adapter_set, - cl_uint num_entries, - cl_device_id * devices, - cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromDX9MediaSurfaceKHR)( - cl_context context, - cl_mem_flags flags, - cl_dx9_media_adapter_type_khr adapter_type, - void * surface_info, - cl_uint plane, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueAcquireDX9MediaSurfacesKHR)( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueReleaseDX9MediaSurfacesKHR)( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_2; - -/* cl_khr_d3d11_sharing */ -extern CL_API_ENTRY cl_int CL_API_CALL -clGetDeviceIDsFromD3D11KHR( - cl_platform_id platform, - cl_d3d11_device_source_khr d3d_device_source, - void * d3d_object, - cl_d3d11_device_set_khr d3d_device_set, - cl_uint num_entries, - cl_device_id * devices, - cl_uint * num_devices); - -extern CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromD3D11BufferKHR( - cl_context context, - cl_mem_flags flags, - ID3D11Buffer * resource, - cl_int * errcode_ret); - -extern CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromD3D11Texture2DKHR( - cl_context context, - cl_mem_flags flags, - ID3D11Texture2D * resource, - UINT subresource, - cl_int * errcode_ret); - -extern CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromD3D11Texture3DKHR( - cl_context context, - cl_mem_flags flags, - ID3D11Texture3D * resource, - UINT subresource, - cl_int * errcode_ret); - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueAcquireD3D11ObjectsKHR( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event); - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueReleaseD3D11ObjectsKHR( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event); - -/* cl_khr_dx9_media_sharing */ -extern CL_API_ENTRY cl_int CL_API_CALL -clGetDeviceIDsFromDX9MediaAdapterKHR( - cl_platform_id platform, - cl_uint num_media_adapters, - cl_dx9_media_adapter_type_khr * media_adapter_type, - void * media_adapters, - cl_dx9_media_adapter_set_khr media_adapter_set, - cl_uint num_entries, - cl_device_id * devices, - cl_uint * num_devices); - -extern CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromDX9MediaSurfaceKHR( - cl_context context, - cl_mem_flags flags, - cl_dx9_media_adapter_type_khr adapter_type, - void * surface_info, - cl_uint plane, - cl_int * errcode_ret); - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueAcquireDX9MediaSurfacesKHR( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event); - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueReleaseDX9MediaSurfacesKHR( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event); - -#else - -/* cl_khr_d3d10_sharing */ -typedef void *KHRpfn_clGetDeviceIDsFromD3D10KHR; -typedef void *KHRpfn_clCreateFromD3D10BufferKHR; -typedef void *KHRpfn_clCreateFromD3D10Texture2DKHR; -typedef void *KHRpfn_clCreateFromD3D10Texture3DKHR; -typedef void *KHRpfn_clEnqueueAcquireD3D10ObjectsKHR; -typedef void *KHRpfn_clEnqueueReleaseD3D10ObjectsKHR; - -/* cl_khr_d3d11_sharing */ -typedef void *KHRpfn_clGetDeviceIDsFromD3D11KHR; -typedef void *KHRpfn_clCreateFromD3D11BufferKHR; -typedef void *KHRpfn_clCreateFromD3D11Texture2DKHR; -typedef void *KHRpfn_clCreateFromD3D11Texture3DKHR; -typedef void *KHRpfn_clEnqueueAcquireD3D11ObjectsKHR; -typedef void *KHRpfn_clEnqueueReleaseD3D11ObjectsKHR; - -/* cl_khr_dx9_media_sharing */ -typedef void *KHRpfn_clCreateFromDX9MediaSurfaceKHR; -typedef void *KHRpfn_clEnqueueAcquireDX9MediaSurfacesKHR; -typedef void *KHRpfn_clEnqueueReleaseDX9MediaSurfacesKHR; -typedef void *KHRpfn_clGetDeviceIDsFromDX9MediaAdapterKHR; - -#endif - -/* OpenCL 1.1 */ - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clSetEventCallback)( - cl_event /* event */, - cl_int /* command_exec_callback_type */, - void (CL_CALLBACK * /* pfn_notify */)(cl_event, cl_int, void *), - void * /* user_data */) CL_API_SUFFIX__VERSION_1_1; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateSubBuffer)( - cl_mem /* buffer */, - cl_mem_flags /* flags */, - cl_buffer_create_type /* buffer_create_type */, - const void * /* buffer_create_info */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_1; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clSetMemObjectDestructorCallback)( - cl_mem /* memobj */, - void (CL_CALLBACK * /*pfn_notify*/)( cl_mem /* memobj */, void* /*user_data*/), - void * /*user_data */ ) CL_API_SUFFIX__VERSION_1_1; - -typedef CL_API_ENTRY cl_event (CL_API_CALL *KHRpfn_clCreateUserEvent)( - cl_context /* context */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_1; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clSetUserEventStatus)( - cl_event /* event */, - cl_int /* execution_status */) CL_API_SUFFIX__VERSION_1_1; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clCreateSubDevicesEXT)( - cl_device_id in_device, - const cl_device_partition_property_ext * partition_properties, - cl_uint num_entries, - cl_device_id * out_devices, - cl_uint * num_devices); - -typedef CL_API_ENTRY cl_int (CL_API_CALL * KHRpfn_clRetainDeviceEXT)( - cl_device_id device) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL * KHRpfn_clReleaseDeviceEXT)( - cl_device_id device) CL_API_SUFFIX__VERSION_1_0; - -/* cl_khr_egl_image */ -typedef CL_API_ENTRY cl_mem (CL_API_CALL *KHRpfn_clCreateFromEGLImageKHR)( - cl_context context, - CLeglDisplayKHR display, - CLeglImageKHR image, - cl_mem_flags flags, - const cl_egl_image_properties_khr *properties, - cl_int *errcode_ret); - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueAcquireEGLObjectsKHR)( - 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); - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueReleaseEGLObjectsKHR)( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem *mem_objects, - cl_uint num_events_in_wait_list, - const cl_event *event_wait_list, - cl_event *event); - -/* cl_khr_egl_event */ -typedef CL_API_ENTRY cl_event (CL_API_CALL *KHRpfn_clCreateEventFromEGLSyncKHR)( - cl_context context, - CLeglSyncKHR sync, - CLeglDisplayKHR display, - cl_int *errcode_ret); - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clSetDefaultDeviceCommandQueue)( - cl_context context, - cl_device_id device, - cl_command_queue command_queue) CL_API_SUFFIX__VERSION_2_1; - -typedef CL_API_ENTRY cl_program (CL_API_CALL *KHRpfn_clCreateProgramWithIL)( - cl_context context, - const void * il, - size_t length, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_2_1; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetKernelSubGroupInfo )( - cl_kernel kernel, - cl_device_id device, - cl_kernel_sub_group_info param_name, - size_t input_value_size, - const void * input_value, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_2_1; - -typedef CL_API_ENTRY cl_kernel (CL_API_CALL *KHRpfn_clCloneKernel)( - cl_kernel source_kernel, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_2_1; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clEnqueueSVMMigrateMem)( - cl_command_queue command_queue, - cl_uint num_svm_pointers, - const void ** svm_pointers, - const size_t * sizes, - cl_mem_migration_flags flags, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_2_1; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetDeviceAndHostTimer)( - cl_device_id device, - cl_ulong * device_timestamp, - cl_ulong * host_timestamp) CL_API_SUFFIX__VERSION_2_1; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *KHRpfn_clGetHostTimer)( - cl_device_id device, - cl_ulong * host_timestamp) CL_API_SUFFIX__VERSION_2_1; - -/* - * - * vendor dispatch table structure - * - * note that the types in the structure KHRicdVendorDispatch mirror the function - * names listed in the string table khrIcdVendorDispatchFunctionNames - * - */ - -typedef struct KHRicdVendorDispatchRec KHRicdVendorDispatch; - -struct KHRicdVendorDispatchRec -{ - /* OpenCL 1.0 */ - KHRpfn_clGetPlatformIDs clGetPlatformIDs; - KHRpfn_clGetPlatformInfo clGetPlatformInfo; - KHRpfn_clGetDeviceIDs clGetDeviceIDs; - KHRpfn_clGetDeviceInfo clGetDeviceInfo; - KHRpfn_clCreateContext clCreateContext; - KHRpfn_clCreateContextFromType clCreateContextFromType; - KHRpfn_clRetainContext clRetainContext; - KHRpfn_clReleaseContext clReleaseContext; - KHRpfn_clGetContextInfo clGetContextInfo; - KHRpfn_clCreateCommandQueue clCreateCommandQueue; - KHRpfn_clRetainCommandQueue clRetainCommandQueue; - KHRpfn_clReleaseCommandQueue clReleaseCommandQueue; - KHRpfn_clGetCommandQueueInfo clGetCommandQueueInfo; - KHRpfn_clSetCommandQueueProperty clSetCommandQueueProperty; - KHRpfn_clCreateBuffer clCreateBuffer; - KHRpfn_clCreateImage2D clCreateImage2D; - KHRpfn_clCreateImage3D clCreateImage3D; - KHRpfn_clRetainMemObject clRetainMemObject; - KHRpfn_clReleaseMemObject clReleaseMemObject; - KHRpfn_clGetSupportedImageFormats clGetSupportedImageFormats; - KHRpfn_clGetMemObjectInfo clGetMemObjectInfo; - KHRpfn_clGetImageInfo clGetImageInfo; - KHRpfn_clCreateSampler clCreateSampler; - KHRpfn_clRetainSampler clRetainSampler; - KHRpfn_clReleaseSampler clReleaseSampler; - KHRpfn_clGetSamplerInfo clGetSamplerInfo; - KHRpfn_clCreateProgramWithSource clCreateProgramWithSource; - KHRpfn_clCreateProgramWithBinary clCreateProgramWithBinary; - KHRpfn_clRetainProgram clRetainProgram; - KHRpfn_clReleaseProgram clReleaseProgram; - KHRpfn_clBuildProgram clBuildProgram; - KHRpfn_clUnloadCompiler clUnloadCompiler; - KHRpfn_clGetProgramInfo clGetProgramInfo; - KHRpfn_clGetProgramBuildInfo clGetProgramBuildInfo; - KHRpfn_clCreateKernel clCreateKernel; - KHRpfn_clCreateKernelsInProgram clCreateKernelsInProgram; - KHRpfn_clRetainKernel clRetainKernel; - KHRpfn_clReleaseKernel clReleaseKernel; - KHRpfn_clSetKernelArg clSetKernelArg; - KHRpfn_clGetKernelInfo clGetKernelInfo; - KHRpfn_clGetKernelWorkGroupInfo clGetKernelWorkGroupInfo; - KHRpfn_clWaitForEvents clWaitForEvents; - KHRpfn_clGetEventInfo clGetEventInfo; - KHRpfn_clRetainEvent clRetainEvent; - KHRpfn_clReleaseEvent clReleaseEvent; - KHRpfn_clGetEventProfilingInfo clGetEventProfilingInfo; - KHRpfn_clFlush clFlush; - KHRpfn_clFinish clFinish; - KHRpfn_clEnqueueReadBuffer clEnqueueReadBuffer; - KHRpfn_clEnqueueWriteBuffer clEnqueueWriteBuffer; - KHRpfn_clEnqueueCopyBuffer clEnqueueCopyBuffer; - KHRpfn_clEnqueueReadImage clEnqueueReadImage; - KHRpfn_clEnqueueWriteImage clEnqueueWriteImage; - KHRpfn_clEnqueueCopyImage clEnqueueCopyImage; - KHRpfn_clEnqueueCopyImageToBuffer clEnqueueCopyImageToBuffer; - KHRpfn_clEnqueueCopyBufferToImage clEnqueueCopyBufferToImage; - KHRpfn_clEnqueueMapBuffer clEnqueueMapBuffer; - KHRpfn_clEnqueueMapImage clEnqueueMapImage; - KHRpfn_clEnqueueUnmapMemObject clEnqueueUnmapMemObject; - KHRpfn_clEnqueueNDRangeKernel clEnqueueNDRangeKernel; - KHRpfn_clEnqueueTask clEnqueueTask; - KHRpfn_clEnqueueNativeKernel clEnqueueNativeKernel; - KHRpfn_clEnqueueMarker clEnqueueMarker; - KHRpfn_clEnqueueWaitForEvents clEnqueueWaitForEvents; - KHRpfn_clEnqueueBarrier clEnqueueBarrier; - KHRpfn_clGetExtensionFunctionAddress clGetExtensionFunctionAddress; - KHRpfn_clCreateFromGLBuffer clCreateFromGLBuffer; - KHRpfn_clCreateFromGLTexture2D clCreateFromGLTexture2D; - KHRpfn_clCreateFromGLTexture3D clCreateFromGLTexture3D; - KHRpfn_clCreateFromGLRenderbuffer clCreateFromGLRenderbuffer; - KHRpfn_clGetGLObjectInfo clGetGLObjectInfo; - KHRpfn_clGetGLTextureInfo clGetGLTextureInfo; - KHRpfn_clEnqueueAcquireGLObjects clEnqueueAcquireGLObjects; - KHRpfn_clEnqueueReleaseGLObjects clEnqueueReleaseGLObjects; - KHRpfn_clGetGLContextInfoKHR clGetGLContextInfoKHR; - - /* cl_khr_d3d10_sharing */ - KHRpfn_clGetDeviceIDsFromD3D10KHR clGetDeviceIDsFromD3D10KHR; - KHRpfn_clCreateFromD3D10BufferKHR clCreateFromD3D10BufferKHR; - KHRpfn_clCreateFromD3D10Texture2DKHR clCreateFromD3D10Texture2DKHR; - KHRpfn_clCreateFromD3D10Texture3DKHR clCreateFromD3D10Texture3DKHR; - KHRpfn_clEnqueueAcquireD3D10ObjectsKHR clEnqueueAcquireD3D10ObjectsKHR; - KHRpfn_clEnqueueReleaseD3D10ObjectsKHR clEnqueueReleaseD3D10ObjectsKHR; - - /* OpenCL 1.1 */ - KHRpfn_clSetEventCallback clSetEventCallback; - KHRpfn_clCreateSubBuffer clCreateSubBuffer; - KHRpfn_clSetMemObjectDestructorCallback clSetMemObjectDestructorCallback; - KHRpfn_clCreateUserEvent clCreateUserEvent; - KHRpfn_clSetUserEventStatus clSetUserEventStatus; - KHRpfn_clEnqueueReadBufferRect clEnqueueReadBufferRect; - KHRpfn_clEnqueueWriteBufferRect clEnqueueWriteBufferRect; - KHRpfn_clEnqueueCopyBufferRect clEnqueueCopyBufferRect; - - /* cl_ext_device_fission */ - KHRpfn_clCreateSubDevicesEXT clCreateSubDevicesEXT; - KHRpfn_clRetainDeviceEXT clRetainDeviceEXT; - KHRpfn_clReleaseDeviceEXT clReleaseDeviceEXT; - - /* cl_khr_gl_event */ - KHRpfn_clCreateEventFromGLsyncKHR clCreateEventFromGLsyncKHR; - - /* OpenCL 1.2 */ - KHRpfn_clCreateSubDevices clCreateSubDevices; - KHRpfn_clRetainDevice clRetainDevice; - KHRpfn_clReleaseDevice clReleaseDevice; - KHRpfn_clCreateImage clCreateImage; - KHRpfn_clCreateProgramWithBuiltInKernels clCreateProgramWithBuiltInKernels; - KHRpfn_clCompileProgram clCompileProgram; - KHRpfn_clLinkProgram clLinkProgram; - KHRpfn_clUnloadPlatformCompiler clUnloadPlatformCompiler; - KHRpfn_clGetKernelArgInfo clGetKernelArgInfo; - KHRpfn_clEnqueueFillBuffer clEnqueueFillBuffer; - KHRpfn_clEnqueueFillImage clEnqueueFillImage; - KHRpfn_clEnqueueMigrateMemObjects clEnqueueMigrateMemObjects; - KHRpfn_clEnqueueMarkerWithWaitList clEnqueueMarkerWithWaitList; - KHRpfn_clEnqueueBarrierWithWaitList clEnqueueBarrierWithWaitList; - KHRpfn_clGetExtensionFunctionAddressForPlatform clGetExtensionFunctionAddressForPlatform; - KHRpfn_clCreateFromGLTexture clCreateFromGLTexture; - - /* cl_khr_d3d11_sharing */ - KHRpfn_clGetDeviceIDsFromD3D11KHR clGetDeviceIDsFromD3D11KHR; - KHRpfn_clCreateFromD3D11BufferKHR clCreateFromD3D11BufferKHR; - KHRpfn_clCreateFromD3D11Texture2DKHR clCreateFromD3D11Texture2DKHR; - KHRpfn_clCreateFromD3D11Texture3DKHR clCreateFromD3D11Texture3DKHR; - KHRpfn_clCreateFromDX9MediaSurfaceKHR clCreateFromDX9MediaSurfaceKHR; - KHRpfn_clEnqueueAcquireD3D11ObjectsKHR clEnqueueAcquireD3D11ObjectsKHR; - KHRpfn_clEnqueueReleaseD3D11ObjectsKHR clEnqueueReleaseD3D11ObjectsKHR; - - /* cl_khr_dx9_media_sharing */ - KHRpfn_clGetDeviceIDsFromDX9MediaAdapterKHR clGetDeviceIDsFromDX9MediaAdapterKHR; - KHRpfn_clEnqueueAcquireDX9MediaSurfacesKHR clEnqueueAcquireDX9MediaSurfacesKHR; - KHRpfn_clEnqueueReleaseDX9MediaSurfacesKHR clEnqueueReleaseDX9MediaSurfacesKHR; - - /* cl_khr_egl_image */ - KHRpfn_clCreateFromEGLImageKHR clCreateFromEGLImageKHR; - KHRpfn_clEnqueueAcquireEGLObjectsKHR clEnqueueAcquireEGLObjectsKHR; - KHRpfn_clEnqueueReleaseEGLObjectsKHR clEnqueueReleaseEGLObjectsKHR; - - /* cl_khr_egl_event */ - KHRpfn_clCreateEventFromEGLSyncKHR clCreateEventFromEGLSyncKHR; - - /* OpenCL 2.0 */ - KHRpfn_clCreateCommandQueueWithProperties clCreateCommandQueueWithProperties; - KHRpfn_clCreatePipe clCreatePipe; - KHRpfn_clGetPipeInfo clGetPipeInfo; - KHRpfn_clSVMAlloc clSVMAlloc; - KHRpfn_clSVMFree clSVMFree; - KHRpfn_clEnqueueSVMFree clEnqueueSVMFree; - KHRpfn_clEnqueueSVMMemcpy clEnqueueSVMMemcpy; - KHRpfn_clEnqueueSVMMemFill clEnqueueSVMMemFill; - KHRpfn_clEnqueueSVMMap clEnqueueSVMMap; - KHRpfn_clEnqueueSVMUnmap clEnqueueSVMUnmap; - KHRpfn_clCreateSamplerWithProperties clCreateSamplerWithProperties; - KHRpfn_clSetKernelArgSVMPointer clSetKernelArgSVMPointer; - KHRpfn_clSetKernelExecInfo clSetKernelExecInfo; - - /* cl_khr_sub_groups */ - KHRpfn_clGetKernelSubGroupInfoKHR clGetKernelSubGroupInfoKHR; - - /* OpenCL 2.1 */ - KHRpfn_clCloneKernel clCloneKernel; - KHRpfn_clCreateProgramWithIL clCreateProgramWithIL; - KHRpfn_clEnqueueSVMMigrateMem clEnqueueSVMMigrateMem; - KHRpfn_clGetDeviceAndHostTimer clGetDeviceAndHostTimer; - KHRpfn_clGetHostTimer clGetHostTimer; - KHRpfn_clGetKernelSubGroupInfo clGetKernelSubGroupInfo; - KHRpfn_clSetDefaultDeviceCommandQueue clSetDefaultDeviceCommandQueue; - - /* OpenCL 2.2 */ - KHRpfn_clSetProgramReleaseCallback clSetProgramReleaseCallback; - KHRpfn_clSetProgramSpecializationConstant clSetProgramSpecializationConstant; -}; - -/* - * - * vendor dispatch table structure - * - */ - -struct _cl_platform_id -{ - KHRicdVendorDispatch *dispatch; -}; - -struct _cl_device_id -{ - KHRicdVendorDispatch *dispatch; -}; - -struct _cl_context -{ - KHRicdVendorDispatch *dispatch; -}; - -struct _cl_command_queue -{ - KHRicdVendorDispatch *dispatch; -}; - -struct _cl_mem -{ - KHRicdVendorDispatch *dispatch; -}; - -struct _cl_program -{ - KHRicdVendorDispatch *dispatch; -}; - -struct _cl_kernel -{ - KHRicdVendorDispatch *dispatch; -}; - -struct _cl_event -{ - KHRicdVendorDispatch *dispatch; -}; - -struct _cl_sampler -{ - KHRicdVendorDispatch *dispatch; -}; - -#endif // _ICD_DISPATCH_H_ - diff --git a/icd_linux.c b/icd_linux.c deleted file mode 100644 index ddf5bfe0..00000000 --- a/icd_linux.c +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (c) 2016 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software source and associated documentation files (the "Materials"), - * to deal in the Materials without restriction, including without limitation - * the rights to use, copy, modify, compile, merge, publish, distribute, - * sublicense, and/or sell copies of the Materials, and to permit persons to - * whom the Materials are furnished to do so, subject the following terms and - * conditions: - * - * All modifications to the Materials used to create a binary that is - * distributed to third parties shall be provided to Khronos with an - * unrestricted license to use for the purposes of implementing bug fixes and - * enhancements to the Materials; - * - * If the binary is used as part of an OpenCL(TM) implementation, whether binary - * is distributed together with or separately to that implementation, then - * recipient must become an OpenCL Adopter and follow the published OpenCL - * conformance process for that implementation, details at: - * http://www.khronos.org/conformance/; - * - * The above copyright notice, the OpenCL trademark license, and this permission - * notice shall be included in all copies or substantial portions of the - * Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN - * THE MATERIALS. - * - * OpenCL is a trademark of Apple Inc. used under license by Khronos. - */ - -#include "icd.h" -#include -#include -#include -#include -#include -#include -#include - -static pthread_once_t initialized = PTHREAD_ONCE_INIT; - -/* - * - * Vendor enumeration functions - * - */ - -// go through the list of vendors in the two configuration files -void khrIcdOsVendorsEnumerate(void) -{ - DIR *dir = NULL; - struct dirent *dirEntry = NULL; -#ifdef __ANDROID__ - char *vendorPath = "/system/vendor/Khronos/OpenCL/vendors/"; -#else - char *vendorPath = "/etc/OpenCL/vendors/"; -#endif // ANDROID - - // open the directory - dir = opendir(vendorPath); - if (NULL == dir) - { - KHR_ICD_TRACE("Failed to open path %s\n", vendorPath); - goto Cleanup; - } - - // attempt to load all files in the directory - for (dirEntry = readdir(dir); dirEntry; dirEntry = readdir(dir) ) - { - switch(dirEntry->d_type) - { - case DT_UNKNOWN: - case DT_REG: - case DT_LNK: - { - const char* extension = ".icd"; - FILE *fin = NULL; - char* fileName = NULL; - char* buffer = NULL; - long bufferSize = 0; - - // make sure the file name ends in .icd - if (strlen(extension) > strlen(dirEntry->d_name) ) - { - break; - } - if (strcmp(dirEntry->d_name + strlen(dirEntry->d_name) - strlen(extension), extension) ) - { - break; - } - - // allocate space for the full path of the vendor library name - fileName = malloc(strlen(dirEntry->d_name) + 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); - } -} - -// go through the list of vendors only once -void khrIcdOsVendorsEnumerateOnce(void) -{ - pthread_once(&initialized, khrIcdOsVendorsEnumerate); -} - -/* - * - * Dynamic library loading functions - * - */ - -// dynamically load a library. returns NULL on failure -void *khrIcdOsLibraryLoad(const char *libraryName) -{ - return dlopen (libraryName, RTLD_NOW); -} - -// get a function pointer from a loaded library. returns NULL on failure. -void *khrIcdOsLibraryGetFunctionAddress(void *library, const char *functionName) -{ - return dlsym(library, functionName); -} - -// unload a library -void khrIcdOsLibraryUnload(void *library) -{ - dlclose(library); -} - diff --git a/icd_windows.c b/icd_windows.c deleted file mode 100644 index 13e3e5f9..00000000 --- a/icd_windows.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (c) 2016 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software source and associated documentation files (the "Materials"), - * to deal in the Materials without restriction, including without limitation - * the rights to use, copy, modify, compile, merge, publish, distribute, - * sublicense, and/or sell copies of the Materials, and to permit persons to - * whom the Materials are furnished to do so, subject the following terms and - * conditions: - * - * All modifications to the Materials used to create a binary that is - * distributed to third parties shall be provided to Khronos with an - * unrestricted license to use for the purposes of implementing bug fixes and - * enhancements to the Materials; - * - * If the binary is used as part of an OpenCL(TM) implementation, whether binary - * is distributed together with or separately to that implementation, then - * recipient must become an OpenCL Adopter and follow the published OpenCL - * conformance process for that implementation, details at: - * http://www.khronos.org/conformance/; - * - * The above copyright notice, the OpenCL trademark license, and this permission - * notice shall be included in all copies or substantial portions of the - * Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN - * THE MATERIALS. - * - * OpenCL is a trademark of Apple Inc. used under license by Khronos. - */ - -#include "icd.h" -#include "icd_windows_hkr.h" -#include -#include -#include - -static INIT_ONCE initialized = INIT_ONCE_STATIC_INIT; - -/* - * - * Vendor enumeration functions - * - */ - -// go through the list of vendors in the registry and call khrIcdVendorAdd -// for each vendor encountered -BOOL CALLBACK khrIcdOsVendorsEnumerate(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *lpContext) -{ - LONG result; - const char* platformsName = "SOFTWARE\\Khronos\\OpenCL\\Vendors"; - HKEY platformsKey = NULL; - DWORD dwIndex; - - if (!khrIcdOsVendorsEnumerateHKR()) - { - KHR_ICD_TRACE("Failed to enumerate HKR entries, continuing\n"); - } - - KHR_ICD_TRACE("Opening key HKLM\\%s...\n", platformsName); - result = RegOpenKeyExA( - HKEY_LOCAL_MACHINE, - platformsName, - 0, - KEY_READ, - &platformsKey); - if (ERROR_SUCCESS != result) - { - KHR_ICD_TRACE("Failed to open platforms key %s, continuing\n", platformsName); - return FALSE; - } - - // for each value - for (dwIndex = 0;; ++dwIndex) - { - char cszLibraryName[1024] = {0}; - DWORD dwLibraryNameSize = sizeof(cszLibraryName); - DWORD dwLibraryNameType = 0; - DWORD dwValue = 0; - DWORD dwValueSize = sizeof(dwValue); - - // read the value name - KHR_ICD_TRACE("Reading value %d...\n", dwIndex); - result = RegEnumValueA( - platformsKey, - dwIndex, - cszLibraryName, - &dwLibraryNameSize, - NULL, - &dwLibraryNameType, - (LPBYTE)&dwValue, - &dwValueSize); - // if RegEnumKeyEx fails, we are done with the enumeration - if (ERROR_SUCCESS != result) - { - KHR_ICD_TRACE("Failed to read value %d, done reading key.\n", dwIndex); - break; - } - KHR_ICD_TRACE("Value %s found...\n", cszLibraryName); - - // Require that the value be a DWORD and equal zero - if (REG_DWORD != dwLibraryNameType) - { - KHR_ICD_TRACE("Value not a DWORD, skipping\n"); - continue; - } - if (dwValue) - { - KHR_ICD_TRACE("Value not zero, skipping\n"); - continue; - } - - // add the library - khrIcdVendorAdd(cszLibraryName); - } - - result = RegCloseKey(platformsKey); - if (ERROR_SUCCESS != result) - { - KHR_ICD_TRACE("Failed to close platforms key %s, ignoring\n", platformsName); - } - - return TRUE; -} - -// go through the list of vendors only once -void khrIcdOsVendorsEnumerateOnce() -{ - InitOnceExecuteOnce(&initialized, khrIcdOsVendorsEnumerate, NULL, NULL); -} - -/* - * - * Dynamic library loading functions - * - */ - -// dynamically load a library. returns NULL on failure -void *khrIcdOsLibraryLoad(const char *libraryName) -{ - return (void *)LoadLibraryA(libraryName); -} - -// get a function pointer from a loaded library. returns NULL on failure. -void *khrIcdOsLibraryGetFunctionAddress(void *library, const char *functionName) -{ - if (!library || !functionName) - { - return NULL; - } - return GetProcAddress( (HMODULE)library, functionName); -} - -// unload a library. -void khrIcdOsLibraryUnload(void *library) -{ - FreeLibrary( (HMODULE)library); -} - diff --git a/icd_windows_hkr.h b/icd_windows_hkr.h deleted file mode 100644 index b10d15a5..00000000 --- a/icd_windows_hkr.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2017 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software source and associated documentation files (the "Materials"), - * to deal in the Materials without restriction, including without limitation - * the rights to use, copy, modify, compile, merge, publish, distribute, - * sublicense, and/or sell copies of the Materials, and to permit persons to - * whom the Materials are furnished to do so, subject the following terms and - * conditions: - * - * All modifications to the Materials used to create a binary that is - * distributed to third parties shall be provided to Khronos with an - * unrestricted license to use for the purposes of implementing bug fixes and - * enhancements to the Materials; - * - * If the binary is used as part of an OpenCL(TM) implementation, whether binary - * is distributed together with or separately to that implementation, then - * recipient must become an OpenCL Adopter and follow the published OpenCL - * conformance process for that implementation, details at: - * http://www.khronos.org/conformance/; - * - * The above copyright notice, the OpenCL trademark license, and this permission - * notice shall be included in all copies or substantial portions of the - * Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN - * THE MATERIALS. - * - * OpenCL is a trademark of Apple Inc. used under license by Khronos. - */ - -#include - -bool khrIcdOsVendorsEnumerateHKR(void); diff --git a/inc/README.txt b/inc/README.txt index 9209d44d..a52b2114 100644 --- a/inc/README.txt +++ b/inc/README.txt @@ -6,7 +6,6 @@ inc/CL/cl_d3d11.h inc/CL/cl_dx9_media_sharing.h inc/CL/cl_egl.h inc/CL/cl_ext.h -inc/CL/cl_gl_ext.h inc/CL/cl_gl.h inc/CL/cl.h inc/CL/cl.hpp diff --git a/include/cl_khr_icd2.h b/include/cl_khr_icd2.h new file mode 100644 index 00000000..3672401a --- /dev/null +++ b/include/cl_khr_icd2.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2016-2025 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#include + +#if !defined(CL_ICD2_TAG_KHR) +#if INTPTR_MAX == INT32_MAX +#define CL_ICD2_TAG_KHR ((intptr_t)0x434C3331) +#else +#define CL_ICD2_TAG_KHR ((intptr_t)0x4F50454E434C3331) +#endif + +typedef void * CL_API_CALL +clIcdGetFunctionAddressForPlatformKHR_t( + cl_platform_id platform, + const char* func_name); + +typedef clIcdGetFunctionAddressForPlatformKHR_t * +clIcdGetFunctionAddressForPlatformKHR_fn; + +typedef cl_int CL_API_CALL +clIcdSetPlatformDispatchDataKHR_t( + cl_platform_id platform, + void *disp_data); + +typedef clIcdSetPlatformDispatchDataKHR_t * +clIcdSetPlatformDispatchDataKHR_fn; +#endif // !defined(CL_ICD2_TAG_KHR) diff --git a/loader/cllayerinfo.c b/loader/cllayerinfo.c new file mode 100644 index 00000000..5a85ba82 --- /dev/null +++ b/loader/cllayerinfo.c @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2022 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#include "icd.h" +#include +#include +#include +#if defined(_WIN32) +#include +#include +#include +#else +#include +#endif +#include + +int stdout_bak, stderr_bak; + +// Temporarily deactivate stdout: +// https://stackoverflow.com/a/4832902 + +#if defined(_WIN32) +#define SECURE 1 +#define OPEN _open +#define OPEN_FLAGS _O_WRONLY +#define CLOSE _close +#define DUP _dup +#define DUP2 _dup2 +#define NULL_STREAM "nul" +#else +#define OPEN open +#define OPEN_FLAGS O_WRONLY +#define CLOSE close +#define DUP dup +#define DUP2 dup2 +#define NULL_STREAM "/dev/null" +#endif + +static inline int +silence_stream(FILE *file, int fd) +{ + int new_fd, fd_bak; + fflush(file); + fd_bak = DUP(fd); +#if defined(_WIN32) && SECURE + _sopen_s(&new_fd, NULL_STREAM, OPEN_FLAGS, _SH_DENYNO, _S_IWRITE); +#else + new_fd = OPEN(NULL_STREAM, OPEN_FLAGS); +#endif + DUP2(new_fd, fd); + CLOSE(new_fd); + return fd_bak; +} + +static void silence_layers(void) +{ + stdout_bak = silence_stream(stdout, 1); + stderr_bak = silence_stream(stderr, 2); +} + +static inline void +restore_stream(FILE *file, int fd, int fd_bak) +{ + fflush(file); + DUP2(fd_bak, fd); + CLOSE(fd_bak); +} + +static void restore_outputs(void) +{ + restore_stream(stdout, 1, stdout_bak); + restore_stream(stderr, 2, stderr_bak); +} + +void printLayerInfo(const struct KHRLayer *layer) +{ + cl_layer_api_version api_version = 0; + pfn_clGetLayerInfo p_clGetLayerInfo = (pfn_clGetLayerInfo)(size_t)layer->p_clGetLayerInfo; + cl_int result = CL_SUCCESS; + size_t sz; + + printf("%s:\n", layer->libraryName); + result = p_clGetLayerInfo(CL_LAYER_API_VERSION, sizeof(api_version), &api_version, NULL); + if (CL_SUCCESS == result) + printf("\tCL_LAYER_API_VERSION: %d\n", (int)api_version); + + result = p_clGetLayerInfo(CL_LAYER_NAME, 0, NULL, &sz); + if (CL_SUCCESS == result) + { + char *name = (char *)malloc(sz); + if (name) + { + result = p_clGetLayerInfo(CL_LAYER_NAME, sz, name, NULL); + if (CL_SUCCESS == result) + printf("\tCL_LAYER_NAME: %s\n", name); + free(name); + } + } +} + +int main (int argc, char *argv[]) +{ + (void)argc; + (void)argv; + silence_layers(); + atexit(restore_outputs); + khrIcdInitialize(); + restore_outputs(); + atexit(silence_layers); + const struct KHRLayer *layer = khrFirstLayer; + while (layer) + { + printLayerInfo(layer); + layer = layer->next; + } + return 0; +} diff --git a/loader/icd.c b/loader/icd.c new file mode 100644 index 00000000..7be82672 --- /dev/null +++ b/loader/icd.c @@ -0,0 +1,474 @@ +/* + * Copyright (c) 2016-2020 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#include "icd.h" +#include "icd_dispatch.h" +#include "icd_envvars.h" +#if defined(CL_ENABLE_LAYERS) +#include +#endif // defined(CL_ENABLE_LAYERS) +#include +#include + +KHRicdVendor *khrIcdVendors = NULL; +int khrEnableTrace = 0; + +#if defined(CL_ENABLE_LAYERS) +struct KHRLayer *khrFirstLayer = NULL; +#endif // defined(CL_ENABLE_LAYERS) + +// entrypoint to check and initialize trace. +void khrIcdInitializeTrace(void) +{ + char *enableTrace = khrIcd_getenv("OCL_ICD_ENABLE_TRACE"); + if (enableTrace && (strcmp(enableTrace, "True") == 0 || + strcmp(enableTrace, "true") == 0 || + strcmp(enableTrace, "T") == 0 || + strcmp(enableTrace, "1") == 0)) + { + khrEnableTrace = 1; + } +} + +// entrypoint to initialize the ICD and add all vendors +void khrIcdInitialize(void) +{ + // enumerate vendors present on the system + khrIcdOsVendorsEnumerateOnce(); +} + +void khrIcdVendorAdd(const char *libraryName) +{ + void *library = NULL; + cl_int result = CL_SUCCESS; + pfn_clGetExtensionFunctionAddress p_clGetExtensionFunctionAddress = NULL; + pfn_clIcdGetPlatformIDs p_clIcdGetPlatformIDs = NULL; +#if defined(CL_ENABLE_LOADER_MANAGED_DISPATCH) + clIcdGetFunctionAddressForPlatformKHR_fn p_clIcdGetFunctionAddressForPlatform = NULL; + clIcdSetPlatformDispatchDataKHR_fn p_clIcdSetPlatformDispatchData = NULL; +#endif + cl_uint i = 0; + cl_uint platformCount = 0; + cl_platform_id *platforms = NULL; + KHRicdVendor *vendorIterator = 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; + } + + // ensure that we haven't already loaded this vendor + for (vendorIterator = khrIcdVendors; vendorIterator; vendorIterator = vendorIterator->next) + { + if (vendorIterator->library == library) + { + KHR_ICD_TRACE("already loaded vendor %s, nothing to do here\n", libraryName); + goto Done; + } + } + + // get the library's clGetExtensionFunctionAddress pointer + p_clGetExtensionFunctionAddress = (pfn_clGetExtensionFunctionAddress)(size_t)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 = (pfn_clIcdGetPlatformIDs)(size_t)p_clGetExtensionFunctionAddress("clIcdGetPlatformIDsKHR"); + if (!p_clIcdGetPlatformIDs) + { + KHR_ICD_TRACE("failed to get extension function address clIcdGetPlatformIDsKHR\n"); + goto Done; + } + +#if defined(CL_ENABLE_LOADER_MANAGED_DISPATCH) + // try to get clIcdGetFunctionAddressForPlatformKHR and clIcdSetPlatformDispatchDataKHR to detect cl_khr_icd2 support + p_clIcdGetFunctionAddressForPlatform = (clIcdGetFunctionAddressForPlatformKHR_fn)(size_t)p_clGetExtensionFunctionAddress("clIcdGetFunctionAddressForPlatformKHR"); + p_clIcdSetPlatformDispatchData = (clIcdSetPlatformDispatchDataKHR_fn)(size_t)p_clGetExtensionFunctionAddress("clIcdSetPlatformDispatchDataKHR"); +#endif + + // 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; + + // skip NULL platforms and non dispatchable platforms + if (!platforms[i] || !platforms[i]->dispatch) + { + continue; + } + +#if defined(CL_ENABLE_LOADER_MANAGED_DISPATCH) + if (KHR_ICD2_HAS_TAG(platforms[i]) && !p_clIcdGetFunctionAddressForPlatform) + { + KHR_ICD_TRACE("found icd 2 object, but platform is missing clIcdGetFunctionAddressForPlatformKHR\n"); + continue; + } + if (KHR_ICD2_HAS_TAG(platforms[i]) && !p_clIcdSetPlatformDispatchData) + { + KHR_ICD_TRACE("found icd 2 object, but platform is missing clIcdSetPlatformDispatchDataKHR\n"); + continue; + } + if (KHR_ICD2_HAS_TAG(platforms[i]) && !((intptr_t)((platforms[i])->dispatch->clUnloadCompiler) == CL_ICD2_TAG_KHR)) + { + KHR_ICD_TRACE("found icd 2 object, but platform is missing tag in clUnloadCompiler\n"); + continue; + } +#endif + + // allocate a structure for the vendor + vendor = (KHRicdVendor*)malloc(sizeof(*vendor) ); + if (!vendor) + { + KHR_ICD_TRACE("failed to allocate memory\n"); + continue; + } + memset(vendor, 0, sizeof(*vendor)); + +#if defined(CL_ENABLE_LOADER_MANAGED_DISPATCH) + // populate cl_khr_icd2 platform's loader managed dispatch tables + if (KHR_ICD2_HAS_TAG(platforms[i])) + { + khrIcd2PopulateDispatchTable(platforms[i], p_clIcdGetFunctionAddressForPlatform, &vendor->dispData.dispatch); + p_clIcdSetPlatformDispatchData(platforms[i], &vendor->dispData); + KHR_ICD_TRACE("found icd 2 platform, using loader managed dispatch\n"); + } +#endif + + // call clGetPlatformInfo on the returned platform to get the suffix + result = KHR_ICD2_DISPATCH(platforms[i])->clGetPlatformInfo( + platforms[i], + CL_PLATFORM_ICD_SUFFIX_KHR, + 0, + NULL, + &suffixSize); + if (CL_SUCCESS != result) + { + free(vendor); + continue; + } + suffix = (char *)malloc(suffixSize); + if (!suffix) + { + free(vendor); + continue; + } + result = KHR_ICD2_DISPATCH(platforms[i])->clGetPlatformInfo( + platforms[i], + CL_PLATFORM_ICD_SUFFIX_KHR, + suffixSize, + suffix, + NULL); + if (CL_SUCCESS != result) + { + free(suffix); + free(vendor); + continue; + } + + // 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 = &khrIcdVendors; *prevNextPointer; prevNextPointer = &( (*prevNextPointer)->next) ); + *prevNextPointer = vendor; + } + + KHR_ICD_TRACE("successfully added vendor %s with suffix %s\n", libraryName, suffix); + + } + +Done: + + if (library) + { + khrIcdOsLibraryUnload(library); + } + if (platforms) + { + free(platforms); + } +} + +#if defined(CL_ENABLE_LAYERS) +void khrIcdLayerAdd(const char *libraryName) +{ + void *library = NULL; + cl_int result = CL_SUCCESS; + pfn_clGetLayerInfo p_clGetLayerInfo = NULL; + pfn_clInitLayer p_clInitLayer = NULL; + struct KHRLayer *layerIterator = NULL; + struct KHRLayer *layer = NULL; + cl_layer_api_version api_version = 0; + const struct _cl_icd_dispatch *targetDispatch = NULL; + const struct _cl_icd_dispatch *layerDispatch = NULL; + cl_uint layerDispatchNumEntries = 0; + cl_uint loaderDispatchNumEntries = 0; + + // require that the library name be valid + if (!libraryName) + { + goto Done; + } + KHR_ICD_TRACE("attempting to add layer %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; + } + + // ensure that we haven't already loaded this layer + for (layerIterator = khrFirstLayer; layerIterator; layerIterator = layerIterator->next) + { + if (layerIterator->library == library) + { + KHR_ICD_TRACE("already loaded layer %s, nothing to do here\n", libraryName); + goto Done; + } + } + + // get the library's clGetLayerInfo pointer + p_clGetLayerInfo = (pfn_clGetLayerInfo)(size_t)khrIcdOsLibraryGetFunctionAddress(library, "clGetLayerInfo"); + if (!p_clGetLayerInfo) + { + KHR_ICD_TRACE("failed to get function address clGetLayerInfo\n"); + goto Done; + } + + // use that function to get the clInitLayer function pointer + p_clInitLayer = (pfn_clInitLayer)(size_t)khrIcdOsLibraryGetFunctionAddress(library, "clInitLayer"); + if (!p_clInitLayer) + { + KHR_ICD_TRACE("failed to get function address clInitLayer\n"); + goto Done; + } + + result = p_clGetLayerInfo(CL_LAYER_API_VERSION, sizeof(api_version), &api_version, NULL); + if (CL_SUCCESS != result) + { + KHR_ICD_TRACE("failed to query layer version\n"); + goto Done; + } + + if (CL_LAYER_API_VERSION_100 != api_version) + { + KHR_ICD_TRACE("unsupported api version\n"); + goto Done; + } + + layer = (struct KHRLayer*)calloc(sizeof(struct KHRLayer), 1); + if (!layer) + { + KHR_ICD_TRACE("failed to allocate memory\n"); + goto Done; + } +#ifdef CL_LAYER_INFO + { + // Not using strdup as it is not standard c + size_t sz_name = strlen(libraryName) + 1; + layer->libraryName = malloc(sz_name); + if (!layer->libraryName) + { + KHR_ICD_TRACE("failed to allocate memory\n"); + goto Done; + } + memcpy(layer->libraryName, libraryName, sz_name); + layer->p_clGetLayerInfo = (void *)(size_t)p_clGetLayerInfo; + } +#endif + + if (khrFirstLayer) { + targetDispatch = &(khrFirstLayer->dispatch); + } else { + targetDispatch = &khrMasterDispatch; + } + + loaderDispatchNumEntries = sizeof(khrMasterDispatch)/sizeof(void*); + result = p_clInitLayer( + loaderDispatchNumEntries, + targetDispatch, + &layerDispatchNumEntries, + &layerDispatch); + if (CL_SUCCESS != result) + { + KHR_ICD_TRACE("failed to initialize layer\n"); + goto Done; + } + + layer->next = khrFirstLayer; + khrFirstLayer = layer; + layer->library = library; + + cl_uint limit = layerDispatchNumEntries < loaderDispatchNumEntries ? layerDispatchNumEntries : loaderDispatchNumEntries; + + for (cl_uint i = 0; i < limit; i++) { + ((void **)&(layer->dispatch))[i] = + ((void *const*)layerDispatch)[i] ? + ((void *const*)layerDispatch)[i] : ((void *const*)targetDispatch)[i]; + } + for (cl_uint i = limit; i < loaderDispatchNumEntries; i++) { + ((void **)&(layer->dispatch))[i] = ((void *const*)targetDispatch)[i]; + } + + KHR_ICD_TRACE("successfully added layer %s\n", libraryName); + return; +Done: + if (library) + { + khrIcdOsLibraryUnload(library); + } + if (layer) + { + free(layer); + } +} +#endif // defined(CL_ENABLE_LAYERS) + +// Get next file or dirname given a string list or registry key path. +// Note: the input string may be modified! +static char *loader_get_next_path(char *path) { + size_t len; + char *next; + + if (path == NULL) return NULL; + next = strchr(path, PATH_SEPARATOR); + if (next == NULL) { + len = strlen(path); + next = path + len; + } else { + *next = '\0'; + next++; + } + + return next; +} + +void khrIcdVendorsEnumerateEnv(void) +{ + char* icdFilenames = khrIcd_secure_getenv("OCL_ICD_FILENAMES"); + char* cur_file = NULL; + char* next_file = NULL; + if (icdFilenames) + { + KHR_ICD_TRACE("Found OCL_ICD_FILENAMES environment variable.\n"); + + next_file = icdFilenames; + while (NULL != next_file && *next_file != '\0') { + cur_file = next_file; + next_file = loader_get_next_path(cur_file); + + khrIcdVendorAdd(cur_file); + } + + khrIcd_free_getenv(icdFilenames); + } +} + +#if defined(CL_ENABLE_LAYERS) +void khrIcdLayersEnumerateEnv(void) +{ + char* layerFilenames = khrIcd_secure_getenv("OPENCL_LAYERS"); + char* cur_file = NULL; + char* next_file = NULL; + if (layerFilenames) + { + KHR_ICD_TRACE("Found OPENCL_LAYERS environment variable.\n"); + + next_file = layerFilenames; + while (NULL != next_file && *next_file != '\0') { + cur_file = next_file; + next_file = loader_get_next_path(cur_file); + + khrIcdLayerAdd(cur_file); + } + + khrIcd_free_getenv(layerFilenames); + } +} +#endif // defined(CL_ENABLE_LAYERS) + +void khrIcdContextPropertiesGetPlatform(const cl_context_properties *properties, cl_platform_id *outPlatform) +{ + if (properties == NULL && khrIcdVendors != NULL) + { + *outPlatform = khrIcdVendors[0].platform; + } + else + { + const cl_context_properties *property = (cl_context_properties *)NULL; + *outPlatform = NULL; + for (property = properties; property && property[0]; property += 2) + { + if ((cl_context_properties)CL_CONTEXT_PLATFORM == property[0]) + { + *outPlatform = (cl_platform_id)property[1]; + } + } + } +} + diff --git a/loader/icd.h b/loader/icd.h new file mode 100644 index 00000000..357a8267 --- /dev/null +++ b/loader/icd.h @@ -0,0 +1,266 @@ +/* + * Copyright (c) 2016-2020 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#ifndef _ICD_H_ +#define _ICD_H_ + +#include "icd_platform.h" +#include "icd_dispatch.h" + +#ifndef CL_USE_DEPRECATED_OPENCL_1_0_APIS +#define CL_USE_DEPRECATED_OPENCL_1_0_APIS +#endif + +#ifndef CL_USE_DEPRECATED_OPENCL_1_1_APIS +#define CL_USE_DEPRECATED_OPENCL_1_1_APIS +#endif + +#ifndef CL_USE_DEPRECATED_OPENCL_1_2_APIS +#define CL_USE_DEPRECATED_OPENCL_1_2_APIS +#endif + +#ifndef CL_USE_DEPRECATED_OPENCL_2_0_APIS +#define CL_USE_DEPRECATED_OPENCL_2_0_APIS +#endif + +#ifndef CL_USE_DEPRECATED_OPENCL_2_1_APIS +#define CL_USE_DEPRECATED_OPENCL_2_1_APIS +#endif + +#ifndef CL_USE_DEPRECATED_OPENCL_2_2_APIS +#define CL_USE_DEPRECATED_OPENCL_2_2_APIS +#endif + +#include +#include +#include +#include + +/* + * type definitions + */ + +typedef 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_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 void *(CL_API_CALL *pfn_clGetExtensionFunctionAddress)( + const char *function_name) CL_API_SUFFIX__VERSION_1_0; + +typedef struct KHRicdVendorRec KHRicdVendor; + +/* + * 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; + +#if defined(CL_ENABLE_LOADER_MANAGED_DISPATCH) + // the loader populated dispatch table for cl_khr_icd2 compliant platforms + struct KHRDisp dispData; +#endif + + // next vendor in the list vendors + KHRicdVendor *next; +}; + +// the global state +extern KHRicdVendor * khrIcdVendors; + +extern int khrEnableTrace; + +#if defined(CL_ENABLE_LAYERS) +/* + * KHRLayer + * + * Data for a single Layer + */ +struct KHRLayer; +struct KHRLayer +{ + // the loaded library object (true type varies on Linux versus Windows) + void *library; + // the dispatch table of the layer + struct _cl_icd_dispatch dispatch; + // The next layer in the chain + struct KHRLayer *next; +#ifdef CL_LAYER_INFO + // The layer library name + char *libraryName; + // the pointer to the clGetLayerInfo funciton + void *p_clGetLayerInfo; +#endif +}; + +// the global layer state +extern struct KHRLayer * khrFirstLayer; +extern struct _cl_icd_dispatch khrMasterDispatch; +#endif // defined(CL_ENABLE_LAYERS) + +/* + * 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); + +// entrypoint to check and initialize trace. +void khrIcdInitializeTrace(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 khrIcdOsVendorsEnumerateOnce(void); + +// read vendors from environment variables +void khrIcdVendorsEnumerateEnv(void); + +// add a vendor's implementation to the list of libraries +void khrIcdVendorAdd(const char *libraryName); + +// read layers from environment variables +void khrIcdLayersEnumerateEnv(void); + +// add a layer to the layer chain +void khrIcdLayerAdd(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); + +// condition anonyous union initialization to usage +#if __CL_HAS_ANON_STRUCT__ +#define ICD_ANON_UNION_INIT_MEMBER(a) {a} +#else +#define ICD_ANON_UNION_INIT_MEMBER(a) a +#endif + +// internal tracing macros +#define KHR_ICD_TRACE(...) \ +do \ +{ \ + if (khrEnableTrace) \ + { \ + fprintf(stderr, "KHR ICD trace at %s:%d: ", __FILE__, __LINE__); \ + fprintf(stderr, __VA_ARGS__); \ + } \ +} while (0) + +#ifdef _WIN32 +#define KHR_ICD_WIDE_TRACE(...) \ +do \ +{ \ + if (khrEnableTrace) \ + { \ + fwprintf(stderr, L"KHR ICD trace at %hs:%d: ", __FILE__, __LINE__); \ + fwprintf(stderr, __VA_ARGS__); \ + } \ +} while (0) + +#else +#define KHR_ICD_WIDE_TRACE(...) +#endif + +#define KHR_ICD_ERROR_RETURN_ERROR(_error) \ +do { \ + return _error; \ +} while(0) + +#define KHR_ICD_ERROR_RETURN_HANDLE(_error) \ +do { \ + if (errcode_ret) { \ + *errcode_ret = _error; \ + } \ + return NULL; \ +} while(0) + +// Check if the passed-in handle is NULL, and if it is, return the error. +#define KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(_handle, _error) \ +do { \ + if (!_handle) { \ + KHR_ICD_ERROR_RETURN_ERROR(_error); \ + } \ +} while (0) + +// Check if the passed-in handle is NULL, and if it is, first check and set +// errcode_ret to the error, then return NULL (NULL being an invalid handle). +#define KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(_handle, _error) \ +do { \ + if (!_handle) { \ + KHR_ICD_ERROR_RETURN_HANDLE(_error); \ + } \ +} while (0) + +// Check if the passed-in function pointer is NULL, and if it is, return +// CL_INVALID_OPERATION. +#define KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(_pointer) \ +do { \ + if (!_pointer) { \ + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); \ + } \ +} while (0) + +// Check if the passed-in function pointer is NULL, and if it is, first +// check and set errcode_ret to CL_INVALID_OPERATION, then return NULL +// (NULL being an invalid handle). +#define KHR_ICD_VALIDATE_POINTER_RETURN_HANDLE(_pointer) \ +do { \ + if (!_pointer) { \ + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); \ + } \ +} while (0) + +#endif diff --git a/loader/icd_cmake_config.h.in b/loader/icd_cmake_config.h.in new file mode 100644 index 00000000..3bbc4612 --- /dev/null +++ b/loader/icd_cmake_config.h.in @@ -0,0 +1,2 @@ +#cmakedefine HAVE_SECURE_GETENV +#cmakedefine HAVE___SECURE_GETENV diff --git a/loader/icd_dispatch.c b/loader/icd_dispatch.c new file mode 100644 index 00000000..de9ef6ef --- /dev/null +++ b/loader/icd_dispatch.c @@ -0,0 +1,339 @@ +/* + * Copyright (c) 2012-2020 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#include "icd.h" +#include "icd_dispatch.h" +#include "icd_version.h" + +#include +#include + +static clGetICDLoaderInfoOCLICD_t clGetICDLoaderInfoOCLICD; +cl_int CL_API_CALL +clGetICDLoaderInfoOCLICD( + cl_icdl_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) +{ + static const char cl_icdl_OCL_VERSION[] = OPENCL_ICD_LOADER_OCL_VERSION_STRING; + static const char cl_icdl_VERSION[] = OPENCL_ICD_LOADER_VERSION_STRING; + static const char cl_icdl_NAME[] = OPENCL_ICD_LOADER_NAME_STRING; + static const char cl_icdl_VENDOR[] = OPENCL_ICD_LOADER_VENDOR_STRING; + size_t pvs; + const void * pv = NULL; + +#define KHR_ICD_CASE_STRING_PARAM_NAME(name) \ + case CL_ICDL_ ## name: \ + pvs = strlen(cl_icdl_ ## name) + 1; \ + pv = (const void *)cl_icdl_ ## name; \ + break + + switch (param_name) { + KHR_ICD_CASE_STRING_PARAM_NAME(OCL_VERSION); + KHR_ICD_CASE_STRING_PARAM_NAME(VERSION); + KHR_ICD_CASE_STRING_PARAM_NAME(NAME); + KHR_ICD_CASE_STRING_PARAM_NAME(VENDOR); + default: + return CL_INVALID_VALUE; + } + +#undef KHR_ICD_CASE_PARAM_NAME + + if (param_value) { + if (param_value_size < pvs) + return CL_INVALID_VALUE; + memcpy(param_value, pv, pvs); + } + if (param_value_size_ret != NULL) + *param_value_size_ret = pvs; + return CL_SUCCESS; +} + +static void* khrIcdGetExtensionFunctionAddress(const char* function_name) +{ +// Most extensions, including multi-vendor KHR and EXT extensions, +// do not need to be ICD-aware and do not require any ICD loader +// modifications. The KHR and EXT extensions below were added for +// backwards compatibility only. +#define KHR_ICD_CHECK_EXTENSION_FUNCTION(name) \ + do \ + { \ + if (!strcmp(function_name, #name)) \ + { \ + return (void*)(size_t)&name; \ + } \ + } while (0) + + // Functions supporting the creation of OpenCL Memory Objects + // from OpenGL Objects (cl_apple_gl_sharing, cl_khr_gl_sharing) + KHR_ICD_CHECK_EXTENSION_FUNCTION(clCreateFromGLBuffer); + KHR_ICD_CHECK_EXTENSION_FUNCTION(clCreateFromGLTexture); + KHR_ICD_CHECK_EXTENSION_FUNCTION(clCreateFromGLTexture2D); + KHR_ICD_CHECK_EXTENSION_FUNCTION(clCreateFromGLTexture3D); + KHR_ICD_CHECK_EXTENSION_FUNCTION(clCreateFromGLRenderbuffer); + KHR_ICD_CHECK_EXTENSION_FUNCTION(clGetGLObjectInfo); + KHR_ICD_CHECK_EXTENSION_FUNCTION(clGetGLTextureInfo); + KHR_ICD_CHECK_EXTENSION_FUNCTION(clEnqueueAcquireGLObjects); + KHR_ICD_CHECK_EXTENSION_FUNCTION(clEnqueueReleaseGLObjects); + + // cl_khr_gl_sharing + KHR_ICD_CHECK_EXTENSION_FUNCTION(clGetGLContextInfoKHR); + + // cl_khr_gl_event + KHR_ICD_CHECK_EXTENSION_FUNCTION(clCreateEventFromGLsyncKHR); + +#if defined(_WIN32) + // cl_khr_d3d10_sharing + KHR_ICD_CHECK_EXTENSION_FUNCTION(clGetDeviceIDsFromD3D10KHR); + KHR_ICD_CHECK_EXTENSION_FUNCTION(clCreateFromD3D10BufferKHR); + KHR_ICD_CHECK_EXTENSION_FUNCTION(clCreateFromD3D10Texture2DKHR); + KHR_ICD_CHECK_EXTENSION_FUNCTION(clCreateFromD3D10Texture3DKHR); + KHR_ICD_CHECK_EXTENSION_FUNCTION(clEnqueueAcquireD3D10ObjectsKHR); + KHR_ICD_CHECK_EXTENSION_FUNCTION(clEnqueueReleaseD3D10ObjectsKHR); + // cl_khr_d3d11_sharing + KHR_ICD_CHECK_EXTENSION_FUNCTION(clGetDeviceIDsFromD3D11KHR); + KHR_ICD_CHECK_EXTENSION_FUNCTION(clCreateFromD3D11BufferKHR); + KHR_ICD_CHECK_EXTENSION_FUNCTION(clCreateFromD3D11Texture2DKHR); + KHR_ICD_CHECK_EXTENSION_FUNCTION(clCreateFromD3D11Texture3DKHR); + KHR_ICD_CHECK_EXTENSION_FUNCTION(clEnqueueAcquireD3D11ObjectsKHR); + KHR_ICD_CHECK_EXTENSION_FUNCTION(clEnqueueReleaseD3D11ObjectsKHR); + // cl_khr_dx9_media_sharing + KHR_ICD_CHECK_EXTENSION_FUNCTION(clGetDeviceIDsFromDX9MediaAdapterKHR); + KHR_ICD_CHECK_EXTENSION_FUNCTION(clCreateFromDX9MediaSurfaceKHR); + KHR_ICD_CHECK_EXTENSION_FUNCTION(clEnqueueAcquireDX9MediaSurfacesKHR); + KHR_ICD_CHECK_EXTENSION_FUNCTION(clEnqueueReleaseDX9MediaSurfacesKHR); +#endif + + // cl_ext_device_fission + KHR_ICD_CHECK_EXTENSION_FUNCTION(clCreateSubDevicesEXT); + KHR_ICD_CHECK_EXTENSION_FUNCTION(clRetainDeviceEXT); + KHR_ICD_CHECK_EXTENSION_FUNCTION(clReleaseDeviceEXT); + + // cl_khr_egl_image + KHR_ICD_CHECK_EXTENSION_FUNCTION(clCreateFromEGLImageKHR); + KHR_ICD_CHECK_EXTENSION_FUNCTION(clEnqueueAcquireEGLObjectsKHR); + KHR_ICD_CHECK_EXTENSION_FUNCTION(clEnqueueReleaseEGLObjectsKHR); + + // cl_khr_egl_event + KHR_ICD_CHECK_EXTENSION_FUNCTION(clCreateEventFromEGLSyncKHR); + + // cl_khr_sub_groups + KHR_ICD_CHECK_EXTENSION_FUNCTION(clGetKernelSubGroupInfoKHR); + + // cl_icdl + KHR_ICD_CHECK_EXTENSION_FUNCTION(clGetICDLoaderInfoOCLICD); + +#undef KHR_ICD_CHECK_EXTENSION_FUNCTION + + return NULL; +} + +#ifdef __cplusplus +extern "C" { +#endif + +static inline cl_int clGetPlatformIDs_body( + cl_uint num_entries, + cl_platform_id* platforms, + cl_uint* num_platforms) +{ + KHRicdVendor* vendor = NULL; + cl_uint i; + + if (!num_entries && platforms) + { + return CL_INVALID_VALUE; + } + if (!platforms && !num_platforms) + { + return CL_INVALID_VALUE; + } + // set num_platforms to 0 and set all platform pointers to NULL + if (num_platforms) + { + *num_platforms = 0; + } + for (i = 0; i < num_entries && platforms; ++i) + { + platforms[i] = NULL; + } + // return error if we have no platforms + if (!khrIcdVendors) + { + return CL_PLATFORM_NOT_FOUND_KHR; + } + // otherwise enumerate all platforms + for (vendor = khrIcdVendors; vendor; vendor = vendor->next) + { + if (num_entries && platforms) + { + *(platforms++) = vendor->platform; + --num_entries; + } + if (num_platforms) + { + ++(*num_platforms); + } + } + return CL_SUCCESS; +} + +cl_int CL_API_CALL clGetPlatformIDs_disp( + cl_uint num_entries, + cl_platform_id* platforms, + cl_uint* num_platforms) +{ + return clGetPlatformIDs_body( + num_entries, + platforms, + num_platforms); +} + +CL_API_ENTRY cl_int CL_API_CALL clGetPlatformIDs( + cl_uint num_entries, + cl_platform_id* platforms, + cl_uint* num_platforms) +{ + // initialize the platforms (in case they have not been already) + khrIcdInitialize(); + +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clGetPlatformIDs( + num_entries, + platforms, + num_platforms); +#endif // defined(CL_ENABLE_LAYERS) + return clGetPlatformIDs_body( + num_entries, + platforms, + num_platforms); +} + +static inline void* clGetExtensionFunctionAddress_body( + const char* function_name) +{ + void* function_address = NULL; + size_t function_name_length = 0; + KHRicdVendor* vendor = NULL; + + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(function_name, NULL); + + // check if this is an ICD-aware extension + function_address = khrIcdGetExtensionFunctionAddress(function_name); + if (function_address) + { + return function_address; + } + + // fall back to vendor extension detection + function_name_length = strlen(function_name); + for (vendor = khrIcdVendors; vendor; vendor = vendor->next) + { + size_t vendor_suffix_length = strlen(vendor->suffix); + if (vendor_suffix_length <= function_name_length && + vendor_suffix_length > 0) + { + const char* function_suffix = + function_name + function_name_length - vendor_suffix_length; + if (!strcmp(function_suffix, vendor->suffix)) + { + return vendor->clGetExtensionFunctionAddress(function_name); + } + } + } + + return NULL; +} + +void* CL_API_CALL clGetExtensionFunctionAddress_disp( + const char* function_name) +{ + return clGetExtensionFunctionAddress_body( + function_name); +} + +CL_API_ENTRY void* CL_API_CALL clGetExtensionFunctionAddress( + const char* function_name) +{ + // make sure the ICD is initialized + khrIcdInitialize(); + +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clGetExtensionFunctionAddress( + function_name); +#endif // defined(CL_ENABLE_LAYERS) + return clGetExtensionFunctionAddress_body( + function_name); +} + +static inline void* clGetExtensionFunctionAddressForPlatform_body( + cl_platform_id platform, + const char* function_name) +{ + void* function_address = NULL; + + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(function_name, NULL); + + // check if this is an ICD-aware extension + function_address = khrIcdGetExtensionFunctionAddress(function_name); + if (function_address) + { + return function_address; + } + + // This is not an ICD-aware extension, so call into the implementation + // to get the extension function address. + + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, NULL); + return KHR_ICD2_DISPATCH(platform)->clGetExtensionFunctionAddressForPlatform( + platform, + function_name); +} + +void* CL_API_CALL clGetExtensionFunctionAddressForPlatform_disp( + cl_platform_id platform, + const char* function_name) +{ + return clGetExtensionFunctionAddressForPlatform_body( + platform, + function_name); +} + +CL_API_ENTRY void* CL_API_CALL clGetExtensionFunctionAddressForPlatform( + cl_platform_id platform, + const char* function_name) +{ + // make sure the ICD is initialized + khrIcdInitialize(); +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clGetExtensionFunctionAddressForPlatform( + platform, + function_name); +#endif // defined(CL_ENABLE_LAYERS) + return clGetExtensionFunctionAddressForPlatform_body( + platform, + function_name); +} + +#ifdef __cplusplus +} +#endif diff --git a/loader/icd_dispatch.h b/loader/icd_dispatch.h new file mode 100644 index 00000000..95d47bc6 --- /dev/null +++ b/loader/icd_dispatch.h @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2016-2019 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#ifndef _ICD_DISPATCH_H_ +#define _ICD_DISPATCH_H_ + +#ifndef CL_USE_DEPRECATED_OPENCL_1_0_APIS +#define CL_USE_DEPRECATED_OPENCL_1_0_APIS +#endif + +#ifndef CL_USE_DEPRECATED_OPENCL_1_1_APIS +#define CL_USE_DEPRECATED_OPENCL_1_1_APIS +#endif + +#ifndef CL_USE_DEPRECATED_OPENCL_1_2_APIS +#define CL_USE_DEPRECATED_OPENCL_1_2_APIS +#endif + +#ifndef CL_USE_DEPRECATED_OPENCL_2_0_APIS +#define CL_USE_DEPRECATED_OPENCL_2_0_APIS +#endif + +#ifndef CL_USE_DEPRECATED_OPENCL_2_1_APIS +#define CL_USE_DEPRECATED_OPENCL_2_1_APIS +#endif + +#ifndef CL_USE_DEPRECATED_OPENCL_2_2_APIS +#define CL_USE_DEPRECATED_OPENCL_2_2_APIS +#endif + +// cl.h +#include + +// cl_gl.h and required files +#ifdef _WIN32 +#include +#include +#include +#include +#include +#include +#endif +#include +#include +#include +#include +#include "cl_khr_icd2.h" + +#if defined(CL_ENABLE_LOADER_MANAGED_DISPATCH) + +extern void khrIcd2PopulateDispatchTable( + cl_platform_id platform, + clIcdGetFunctionAddressForPlatformKHR_fn p_clIcdGetFunctionAddressForPlatform, + struct _cl_icd_dispatch* dispatch); + +struct KHRDisp +{ + struct _cl_icd_dispatch dispatch; +}; + +#define KHR_ICD2_HAS_TAG(object) \ +(((intptr_t)((object)->dispatch->clGetPlatformIDs)) == CL_ICD2_TAG_KHR) + +#define KHR_ICD2_DISPATCH(object) \ +(KHR_ICD2_HAS_TAG(object) ? \ + &(object)->dispData->dispatch : \ + (object)->dispatch) + +#define KHR_ICD_OBJECT_BODY { \ + cl_icd_dispatch *dispatch; \ + struct KHRDisp *dispData; \ +} + +#else // ! defined(CL_ENABLE_LOADER_MANAGED_DISPATCH) + +#define KHR_ICD2_DISPATCH(object) ((object)->dispatch) + +#define KHR_ICD_OBJECT_BODY { \ + cl_icd_dispatch *dispatch; \ +} + +#endif // defined(CL_ENABLE_LOADER_MANAGED_DISPATCH) + +/* + * + * vendor dispatch table structure + * + */ + +struct _cl_platform_id +KHR_ICD_OBJECT_BODY; + +struct _cl_device_id +KHR_ICD_OBJECT_BODY; + +struct _cl_context +KHR_ICD_OBJECT_BODY; + +struct _cl_command_queue +KHR_ICD_OBJECT_BODY; + +struct _cl_mem +KHR_ICD_OBJECT_BODY; + +struct _cl_program +KHR_ICD_OBJECT_BODY; + +struct _cl_kernel +KHR_ICD_OBJECT_BODY; + +struct _cl_event +KHR_ICD_OBJECT_BODY; + +struct _cl_sampler +KHR_ICD_OBJECT_BODY; + +#endif // _ICD_DISPATCH_H_ + diff --git a/loader/icd_dispatch_generated.c b/loader/icd_dispatch_generated.c new file mode 100644 index 00000000..37c291c9 --- /dev/null +++ b/loader/icd_dispatch_generated.c @@ -0,0 +1,9671 @@ +/* + * Copyright (c) 2012-2023 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#include "icd.h" +#include "icd_dispatch.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////// +// Core APIs: +#if defined(CL_ENABLE_LAYERS) +extern cl_int CL_API_CALL clGetPlatformIDs_disp( + cl_uint num_entries, + cl_platform_id* platforms, + cl_uint* num_platforms) CL_API_SUFFIX__VERSION_1_0; +#endif // defined(CL_ENABLE_LAYERS) + +CL_API_ENTRY cl_int CL_API_CALL clGetPlatformInfo( + cl_platform_id platform, + cl_platform_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clGetPlatformInfo( + platform, + param_name, + param_value_size, + param_value, + param_value_size_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); + return KHR_ICD2_DISPATCH(platform)->clGetPlatformInfo( + platform, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clGetPlatformInfo_disp( + cl_platform_id platform, + cl_platform_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); + return KHR_ICD2_DISPATCH(platform)->clGetPlatformInfo( + platform, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clGetDeviceIDs( + cl_platform_id platform, + cl_device_type device_type, + cl_uint num_entries, + cl_device_id* devices, + cl_uint* num_devices) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clGetDeviceIDs( + platform, + device_type, + num_entries, + devices, + num_devices); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); + return KHR_ICD2_DISPATCH(platform)->clGetDeviceIDs( + platform, + device_type, + num_entries, + devices, + num_devices); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clGetDeviceIDs_disp( + cl_platform_id platform, + cl_device_type device_type, + cl_uint num_entries, + cl_device_id* devices, + cl_uint* num_devices) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); + return KHR_ICD2_DISPATCH(platform)->clGetDeviceIDs( + platform, + device_type, + num_entries, + devices, + num_devices); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clGetDeviceInfo( + cl_device_id device, + cl_device_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clGetDeviceInfo( + device, + param_name, + param_value_size, + param_value, + param_value_size_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); + return KHR_ICD2_DISPATCH(device)->clGetDeviceInfo( + device, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clGetDeviceInfo_disp( + cl_device_id device, + cl_device_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); + return KHR_ICD2_DISPATCH(device)->clGetDeviceInfo( + device, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_context CL_API_CALL clCreateContext( + const cl_context_properties* properties, + cl_uint num_devices, + const cl_device_id* devices, + void (CL_CALLBACK* pfn_notify)(const char* errinfo, const void* private_info, size_t cb, void* user_data), + void* user_data, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateContext( + properties, + num_devices, + devices, + pfn_notify, + user_data, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + if (num_devices == 0 || devices == NULL) { + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(NULL, CL_INVALID_VALUE); + } + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(devices[0], CL_INVALID_DEVICE); + return KHR_ICD2_DISPATCH(devices[0])->clCreateContext( + properties, + num_devices, + devices, + pfn_notify, + user_data, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_context CL_API_CALL clCreateContext_disp( + const cl_context_properties* properties, + cl_uint num_devices, + const cl_device_id* devices, + void (CL_CALLBACK* pfn_notify)(const char* errinfo, const void* private_info, size_t cb, void* user_data), + void* user_data, + cl_int* errcode_ret) +{ + if (num_devices == 0 || devices == NULL) { + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(NULL, CL_INVALID_VALUE); + } + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(devices[0], CL_INVALID_DEVICE); + return KHR_ICD2_DISPATCH(devices[0])->clCreateContext( + properties, + num_devices, + devices, + pfn_notify, + user_data, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_context CL_API_CALL clCreateContextFromType( + const cl_context_properties* properties, + cl_device_type device_type, + void (CL_CALLBACK* pfn_notify)(const char* errinfo, const void* private_info, size_t cb, void* user_data), + void* user_data, + cl_int* errcode_ret) +{ + khrIcdInitialize(); +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateContextFromType( + properties, + device_type, + pfn_notify, + user_data, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + cl_platform_id platform = NULL; + khrIcdContextPropertiesGetPlatform(properties, &platform); + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(platform, CL_INVALID_PLATFORM); + return KHR_ICD2_DISPATCH(platform)->clCreateContextFromType( + properties, + device_type, + pfn_notify, + user_data, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_context CL_API_CALL clCreateContextFromType_disp( + const cl_context_properties* properties, + cl_device_type device_type, + void (CL_CALLBACK* pfn_notify)(const char* errinfo, const void* private_info, size_t cb, void* user_data), + void* user_data, + cl_int* errcode_ret) +{ + khrIcdInitialize(); + cl_platform_id platform = NULL; + khrIcdContextPropertiesGetPlatform(properties, &platform); + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(platform, CL_INVALID_PLATFORM); + return KHR_ICD2_DISPATCH(platform)->clCreateContextFromType( + properties, + device_type, + pfn_notify, + user_data, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clRetainContext( + cl_context context) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clRetainContext( + context); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clRetainContext( + context); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clRetainContext_disp( + cl_context context) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clRetainContext( + context); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clReleaseContext( + cl_context context) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clReleaseContext( + context); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clReleaseContext( + context); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clReleaseContext_disp( + cl_context context) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clReleaseContext( + context); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clGetContextInfo( + cl_context context, + cl_context_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clGetContextInfo( + context, + param_name, + param_value_size, + param_value, + param_value_size_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clGetContextInfo( + context, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clGetContextInfo_disp( + cl_context context, + cl_context_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clGetContextInfo( + context, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clRetainCommandQueue( + cl_command_queue command_queue) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clRetainCommandQueue( + command_queue); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clRetainCommandQueue( + command_queue); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clRetainCommandQueue_disp( + cl_command_queue command_queue) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clRetainCommandQueue( + command_queue); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clReleaseCommandQueue( + cl_command_queue command_queue) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clReleaseCommandQueue( + command_queue); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clReleaseCommandQueue( + command_queue); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clReleaseCommandQueue_disp( + cl_command_queue command_queue) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clReleaseCommandQueue( + command_queue); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clGetCommandQueueInfo( + cl_command_queue command_queue, + cl_command_queue_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clGetCommandQueueInfo( + command_queue, + param_name, + param_value_size, + param_value, + param_value_size_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clGetCommandQueueInfo( + command_queue, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clGetCommandQueueInfo_disp( + cl_command_queue command_queue, + cl_command_queue_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clGetCommandQueueInfo( + command_queue, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_mem CL_API_CALL clCreateBuffer( + cl_context context, + cl_mem_flags flags, + size_t size, + void* host_ptr, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateBuffer( + context, + flags, + size, + host_ptr, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clCreateBuffer( + context, + flags, + size, + host_ptr, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_mem CL_API_CALL clCreateBuffer_disp( + cl_context context, + cl_mem_flags flags, + size_t size, + void* host_ptr, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clCreateBuffer( + context, + flags, + size, + host_ptr, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clRetainMemObject( + cl_mem memobj) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clRetainMemObject( + memobj); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); + return KHR_ICD2_DISPATCH(memobj)->clRetainMemObject( + memobj); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clRetainMemObject_disp( + cl_mem memobj) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); + return KHR_ICD2_DISPATCH(memobj)->clRetainMemObject( + memobj); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clReleaseMemObject( + cl_mem memobj) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clReleaseMemObject( + memobj); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); + return KHR_ICD2_DISPATCH(memobj)->clReleaseMemObject( + memobj); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clReleaseMemObject_disp( + cl_mem memobj) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); + return KHR_ICD2_DISPATCH(memobj)->clReleaseMemObject( + memobj); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clGetSupportedImageFormats( + cl_context context, + cl_mem_flags flags, + cl_mem_object_type image_type, + cl_uint num_entries, + cl_image_format* image_formats, + cl_uint* num_image_formats) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clGetSupportedImageFormats( + context, + flags, + image_type, + num_entries, + image_formats, + num_image_formats); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clGetSupportedImageFormats( + context, + flags, + image_type, + num_entries, + image_formats, + num_image_formats); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clGetSupportedImageFormats_disp( + cl_context context, + cl_mem_flags flags, + cl_mem_object_type image_type, + cl_uint num_entries, + cl_image_format* image_formats, + cl_uint* num_image_formats) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clGetSupportedImageFormats( + context, + flags, + image_type, + num_entries, + image_formats, + num_image_formats); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clGetMemObjectInfo( + cl_mem memobj, + cl_mem_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clGetMemObjectInfo( + memobj, + param_name, + param_value_size, + param_value, + param_value_size_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); + return KHR_ICD2_DISPATCH(memobj)->clGetMemObjectInfo( + memobj, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clGetMemObjectInfo_disp( + cl_mem memobj, + cl_mem_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); + return KHR_ICD2_DISPATCH(memobj)->clGetMemObjectInfo( + memobj, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clGetImageInfo( + cl_mem image, + cl_image_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clGetImageInfo( + image, + param_name, + param_value_size, + param_value, + param_value_size_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(image, CL_INVALID_MEM_OBJECT); + return KHR_ICD2_DISPATCH(image)->clGetImageInfo( + image, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clGetImageInfo_disp( + cl_mem image, + cl_image_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(image, CL_INVALID_MEM_OBJECT); + return KHR_ICD2_DISPATCH(image)->clGetImageInfo( + image, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clRetainSampler( + cl_sampler sampler) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clRetainSampler( + sampler); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(sampler, CL_INVALID_SAMPLER); + return KHR_ICD2_DISPATCH(sampler)->clRetainSampler( + sampler); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clRetainSampler_disp( + cl_sampler sampler) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(sampler, CL_INVALID_SAMPLER); + return KHR_ICD2_DISPATCH(sampler)->clRetainSampler( + sampler); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clReleaseSampler( + cl_sampler sampler) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clReleaseSampler( + sampler); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(sampler, CL_INVALID_SAMPLER); + return KHR_ICD2_DISPATCH(sampler)->clReleaseSampler( + sampler); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clReleaseSampler_disp( + cl_sampler sampler) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(sampler, CL_INVALID_SAMPLER); + return KHR_ICD2_DISPATCH(sampler)->clReleaseSampler( + sampler); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clGetSamplerInfo( + cl_sampler sampler, + cl_sampler_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clGetSamplerInfo( + sampler, + param_name, + param_value_size, + param_value, + param_value_size_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(sampler, CL_INVALID_SAMPLER); + return KHR_ICD2_DISPATCH(sampler)->clGetSamplerInfo( + sampler, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clGetSamplerInfo_disp( + cl_sampler sampler, + cl_sampler_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(sampler, CL_INVALID_SAMPLER); + return KHR_ICD2_DISPATCH(sampler)->clGetSamplerInfo( + sampler, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_program CL_API_CALL clCreateProgramWithSource( + cl_context context, + cl_uint count, + const char** strings, + const size_t* lengths, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateProgramWithSource( + context, + count, + strings, + lengths, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clCreateProgramWithSource( + context, + count, + strings, + lengths, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_program CL_API_CALL clCreateProgramWithSource_disp( + cl_context context, + cl_uint count, + const char** strings, + const size_t* lengths, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clCreateProgramWithSource( + context, + count, + strings, + lengths, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_program CL_API_CALL clCreateProgramWithBinary( + cl_context context, + cl_uint num_devices, + const cl_device_id* device_list, + const size_t* lengths, + const unsigned char** binaries, + cl_int* binary_status, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateProgramWithBinary( + context, + num_devices, + device_list, + lengths, + binaries, + binary_status, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clCreateProgramWithBinary( + context, + num_devices, + device_list, + lengths, + binaries, + binary_status, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_program CL_API_CALL clCreateProgramWithBinary_disp( + cl_context context, + cl_uint num_devices, + const cl_device_id* device_list, + const size_t* lengths, + const unsigned char** binaries, + cl_int* binary_status, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clCreateProgramWithBinary( + context, + num_devices, + device_list, + lengths, + binaries, + binary_status, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clRetainProgram( + cl_program program) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clRetainProgram( + program); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); + return KHR_ICD2_DISPATCH(program)->clRetainProgram( + program); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clRetainProgram_disp( + cl_program program) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); + return KHR_ICD2_DISPATCH(program)->clRetainProgram( + program); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clReleaseProgram( + cl_program program) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clReleaseProgram( + program); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); + return KHR_ICD2_DISPATCH(program)->clReleaseProgram( + program); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clReleaseProgram_disp( + cl_program program) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); + return KHR_ICD2_DISPATCH(program)->clReleaseProgram( + program); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clBuildProgram( + cl_program program, + cl_uint num_devices, + const cl_device_id* device_list, + const char* options, + void (CL_CALLBACK* pfn_notify)(cl_program program, void* user_data), + void* user_data) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clBuildProgram( + program, + num_devices, + device_list, + options, + pfn_notify, + user_data); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); + return KHR_ICD2_DISPATCH(program)->clBuildProgram( + program, + num_devices, + device_list, + options, + pfn_notify, + user_data); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clBuildProgram_disp( + cl_program program, + cl_uint num_devices, + const cl_device_id* device_list, + const char* options, + void (CL_CALLBACK* pfn_notify)(cl_program program, void* user_data), + void* user_data) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); + return KHR_ICD2_DISPATCH(program)->clBuildProgram( + program, + num_devices, + device_list, + options, + pfn_notify, + user_data); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clGetProgramInfo( + cl_program program, + cl_program_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clGetProgramInfo( + program, + param_name, + param_value_size, + param_value, + param_value_size_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); + return KHR_ICD2_DISPATCH(program)->clGetProgramInfo( + program, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clGetProgramInfo_disp( + cl_program program, + cl_program_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); + return KHR_ICD2_DISPATCH(program)->clGetProgramInfo( + program, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clGetProgramBuildInfo( + cl_program program, + cl_device_id device, + cl_program_build_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clGetProgramBuildInfo( + program, + device, + param_name, + param_value_size, + param_value, + param_value_size_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); + return KHR_ICD2_DISPATCH(program)->clGetProgramBuildInfo( + program, + device, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clGetProgramBuildInfo_disp( + cl_program program, + cl_device_id device, + cl_program_build_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); + return KHR_ICD2_DISPATCH(program)->clGetProgramBuildInfo( + program, + device, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_kernel CL_API_CALL clCreateKernel( + cl_program program, + const char* kernel_name, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateKernel( + program, + kernel_name, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(program, CL_INVALID_PROGRAM); + return KHR_ICD2_DISPATCH(program)->clCreateKernel( + program, + kernel_name, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_kernel CL_API_CALL clCreateKernel_disp( + cl_program program, + const char* kernel_name, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(program, CL_INVALID_PROGRAM); + return KHR_ICD2_DISPATCH(program)->clCreateKernel( + program, + kernel_name, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clCreateKernelsInProgram( + cl_program program, + cl_uint num_kernels, + cl_kernel* kernels, + cl_uint* num_kernels_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateKernelsInProgram( + program, + num_kernels, + kernels, + num_kernels_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); + return KHR_ICD2_DISPATCH(program)->clCreateKernelsInProgram( + program, + num_kernels, + kernels, + num_kernels_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clCreateKernelsInProgram_disp( + cl_program program, + cl_uint num_kernels, + cl_kernel* kernels, + cl_uint* num_kernels_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); + return KHR_ICD2_DISPATCH(program)->clCreateKernelsInProgram( + program, + num_kernels, + kernels, + num_kernels_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clRetainKernel( + cl_kernel kernel) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clRetainKernel( + kernel); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); + return KHR_ICD2_DISPATCH(kernel)->clRetainKernel( + kernel); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clRetainKernel_disp( + cl_kernel kernel) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); + return KHR_ICD2_DISPATCH(kernel)->clRetainKernel( + kernel); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clReleaseKernel( + cl_kernel kernel) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clReleaseKernel( + kernel); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); + return KHR_ICD2_DISPATCH(kernel)->clReleaseKernel( + kernel); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clReleaseKernel_disp( + cl_kernel kernel) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); + return KHR_ICD2_DISPATCH(kernel)->clReleaseKernel( + kernel); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clSetKernelArg( + cl_kernel kernel, + cl_uint arg_index, + size_t arg_size, + const void* arg_value) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clSetKernelArg( + kernel, + arg_index, + arg_size, + arg_value); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); + return KHR_ICD2_DISPATCH(kernel)->clSetKernelArg( + kernel, + arg_index, + arg_size, + arg_value); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clSetKernelArg_disp( + cl_kernel kernel, + cl_uint arg_index, + size_t arg_size, + const void* arg_value) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); + return KHR_ICD2_DISPATCH(kernel)->clSetKernelArg( + kernel, + arg_index, + arg_size, + arg_value); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clGetKernelInfo( + cl_kernel kernel, + cl_kernel_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clGetKernelInfo( + kernel, + param_name, + param_value_size, + param_value, + param_value_size_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); + return KHR_ICD2_DISPATCH(kernel)->clGetKernelInfo( + kernel, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clGetKernelInfo_disp( + cl_kernel kernel, + cl_kernel_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); + return KHR_ICD2_DISPATCH(kernel)->clGetKernelInfo( + kernel, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clGetKernelWorkGroupInfo( + cl_kernel kernel, + cl_device_id device, + cl_kernel_work_group_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clGetKernelWorkGroupInfo( + kernel, + device, + param_name, + param_value_size, + param_value, + param_value_size_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); + return KHR_ICD2_DISPATCH(kernel)->clGetKernelWorkGroupInfo( + kernel, + device, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clGetKernelWorkGroupInfo_disp( + cl_kernel kernel, + cl_device_id device, + cl_kernel_work_group_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); + return KHR_ICD2_DISPATCH(kernel)->clGetKernelWorkGroupInfo( + kernel, + device, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clWaitForEvents( + cl_uint num_events, + const cl_event* event_list) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clWaitForEvents( + num_events, + event_list); +#endif // defined(CL_ENABLE_LAYERS) + if (num_events == 0 || event_list == NULL) { + return CL_INVALID_VALUE; + } + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event_list[0], CL_INVALID_EVENT); + return KHR_ICD2_DISPATCH(event_list[0])->clWaitForEvents( + num_events, + event_list); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clWaitForEvents_disp( + cl_uint num_events, + const cl_event* event_list) +{ + if (num_events == 0 || event_list == NULL) { + return CL_INVALID_VALUE; + } + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event_list[0], CL_INVALID_EVENT); + return KHR_ICD2_DISPATCH(event_list[0])->clWaitForEvents( + num_events, + event_list); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clGetEventInfo( + cl_event event, + cl_event_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clGetEventInfo( + event, + param_name, + param_value_size, + param_value, + param_value_size_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); + return KHR_ICD2_DISPATCH(event)->clGetEventInfo( + event, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clGetEventInfo_disp( + cl_event event, + cl_event_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); + return KHR_ICD2_DISPATCH(event)->clGetEventInfo( + event, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clRetainEvent( + cl_event event) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clRetainEvent( + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); + return KHR_ICD2_DISPATCH(event)->clRetainEvent( + event); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clRetainEvent_disp( + cl_event event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); + return KHR_ICD2_DISPATCH(event)->clRetainEvent( + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clReleaseEvent( + cl_event event) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clReleaseEvent( + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); + return KHR_ICD2_DISPATCH(event)->clReleaseEvent( + event); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clReleaseEvent_disp( + cl_event event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); + return KHR_ICD2_DISPATCH(event)->clReleaseEvent( + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clGetEventProfilingInfo( + cl_event event, + cl_profiling_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clGetEventProfilingInfo( + event, + param_name, + param_value_size, + param_value, + param_value_size_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); + return KHR_ICD2_DISPATCH(event)->clGetEventProfilingInfo( + event, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clGetEventProfilingInfo_disp( + cl_event event, + cl_profiling_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); + return KHR_ICD2_DISPATCH(event)->clGetEventProfilingInfo( + event, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clFlush( + cl_command_queue command_queue) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clFlush( + command_queue); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clFlush( + command_queue); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clFlush_disp( + cl_command_queue command_queue) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clFlush( + command_queue); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clFinish( + cl_command_queue command_queue) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clFinish( + command_queue); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clFinish( + command_queue); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clFinish_disp( + cl_command_queue command_queue) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clFinish( + command_queue); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueReadBuffer( + cl_command_queue command_queue, + cl_mem buffer, + cl_bool blocking_read, + size_t offset, + size_t size, + void* ptr, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueReadBuffer( + command_queue, + buffer, + blocking_read, + offset, + size, + ptr, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueReadBuffer( + command_queue, + buffer, + blocking_read, + offset, + size, + ptr, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueReadBuffer_disp( + cl_command_queue command_queue, + cl_mem buffer, + cl_bool blocking_read, + size_t offset, + size_t size, + void* ptr, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueReadBuffer( + command_queue, + buffer, + blocking_read, + offset, + size, + ptr, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueWriteBuffer( + cl_command_queue command_queue, + cl_mem buffer, + cl_bool blocking_write, + size_t offset, + size_t size, + const void* ptr, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueWriteBuffer( + command_queue, + buffer, + blocking_write, + offset, + size, + ptr, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueWriteBuffer( + command_queue, + buffer, + blocking_write, + offset, + size, + ptr, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueWriteBuffer_disp( + cl_command_queue command_queue, + cl_mem buffer, + cl_bool blocking_write, + size_t offset, + size_t size, + const void* ptr, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueWriteBuffer( + command_queue, + buffer, + blocking_write, + offset, + size, + ptr, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueCopyBuffer( + cl_command_queue command_queue, + cl_mem src_buffer, + cl_mem dst_buffer, + size_t src_offset, + size_t dst_offset, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueCopyBuffer( + command_queue, + src_buffer, + dst_buffer, + src_offset, + dst_offset, + size, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueCopyBuffer( + command_queue, + src_buffer, + dst_buffer, + src_offset, + dst_offset, + size, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueCopyBuffer_disp( + cl_command_queue command_queue, + cl_mem src_buffer, + cl_mem dst_buffer, + size_t src_offset, + size_t dst_offset, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueCopyBuffer( + command_queue, + src_buffer, + dst_buffer, + src_offset, + dst_offset, + size, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueReadImage( + cl_command_queue command_queue, + cl_mem image, + cl_bool blocking_read, + const size_t* origin, + const size_t* region, + size_t row_pitch, + size_t slice_pitch, + void* ptr, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueReadImage( + command_queue, + image, + blocking_read, + origin, + region, + row_pitch, + slice_pitch, + ptr, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueReadImage( + command_queue, + image, + blocking_read, + origin, + region, + row_pitch, + slice_pitch, + ptr, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueReadImage_disp( + cl_command_queue command_queue, + cl_mem image, + cl_bool blocking_read, + const size_t* origin, + const size_t* region, + size_t row_pitch, + size_t slice_pitch, + void* ptr, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueReadImage( + command_queue, + image, + blocking_read, + origin, + region, + row_pitch, + slice_pitch, + ptr, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueWriteImage( + cl_command_queue command_queue, + cl_mem image, + cl_bool blocking_write, + const size_t* origin, + const size_t* region, + size_t input_row_pitch, + size_t input_slice_pitch, + const void* ptr, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueWriteImage( + command_queue, + image, + blocking_write, + origin, + region, + input_row_pitch, + input_slice_pitch, + ptr, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueWriteImage( + command_queue, + image, + blocking_write, + origin, + region, + input_row_pitch, + input_slice_pitch, + ptr, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueWriteImage_disp( + cl_command_queue command_queue, + cl_mem image, + cl_bool blocking_write, + const size_t* origin, + const size_t* region, + size_t input_row_pitch, + size_t input_slice_pitch, + const void* ptr, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueWriteImage( + command_queue, + image, + blocking_write, + origin, + region, + input_row_pitch, + input_slice_pitch, + ptr, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueCopyImage( + cl_command_queue command_queue, + cl_mem src_image, + cl_mem dst_image, + const size_t* src_origin, + const size_t* dst_origin, + const size_t* region, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueCopyImage( + command_queue, + src_image, + dst_image, + src_origin, + dst_origin, + region, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueCopyImage( + command_queue, + src_image, + dst_image, + src_origin, + dst_origin, + region, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueCopyImage_disp( + cl_command_queue command_queue, + cl_mem src_image, + cl_mem dst_image, + const size_t* src_origin, + const size_t* dst_origin, + const size_t* region, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueCopyImage( + command_queue, + src_image, + dst_image, + src_origin, + dst_origin, + region, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueCopyImageToBuffer( + cl_command_queue command_queue, + cl_mem src_image, + cl_mem dst_buffer, + const size_t* src_origin, + const size_t* region, + size_t dst_offset, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueCopyImageToBuffer( + command_queue, + src_image, + dst_buffer, + src_origin, + region, + dst_offset, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueCopyImageToBuffer( + command_queue, + src_image, + dst_buffer, + src_origin, + region, + dst_offset, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueCopyImageToBuffer_disp( + cl_command_queue command_queue, + cl_mem src_image, + cl_mem dst_buffer, + const size_t* src_origin, + const size_t* region, + size_t dst_offset, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueCopyImageToBuffer( + command_queue, + src_image, + dst_buffer, + src_origin, + region, + dst_offset, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueCopyBufferToImage( + cl_command_queue command_queue, + cl_mem src_buffer, + cl_mem dst_image, + size_t src_offset, + const size_t* dst_origin, + const size_t* region, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueCopyBufferToImage( + command_queue, + src_buffer, + dst_image, + src_offset, + dst_origin, + region, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueCopyBufferToImage( + command_queue, + src_buffer, + dst_image, + src_offset, + dst_origin, + region, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueCopyBufferToImage_disp( + cl_command_queue command_queue, + cl_mem src_buffer, + cl_mem dst_image, + size_t src_offset, + const size_t* dst_origin, + const size_t* region, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueCopyBufferToImage( + command_queue, + src_buffer, + dst_image, + src_offset, + dst_origin, + region, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY void* CL_API_CALL clEnqueueMapBuffer( + cl_command_queue command_queue, + cl_mem buffer, + cl_bool blocking_map, + cl_map_flags map_flags, + size_t offset, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueMapBuffer( + command_queue, + buffer, + blocking_map, + map_flags, + offset, + size, + num_events_in_wait_list, + event_wait_list, + event, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueMapBuffer( + command_queue, + buffer, + blocking_map, + map_flags, + offset, + size, + num_events_in_wait_list, + event_wait_list, + event, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static void* CL_API_CALL clEnqueueMapBuffer_disp( + cl_command_queue command_queue, + cl_mem buffer, + cl_bool blocking_map, + cl_map_flags map_flags, + size_t offset, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueMapBuffer( + command_queue, + buffer, + blocking_map, + map_flags, + offset, + size, + num_events_in_wait_list, + event_wait_list, + event, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY void* CL_API_CALL clEnqueueMapImage( + cl_command_queue command_queue, + cl_mem image, + cl_bool blocking_map, + cl_map_flags map_flags, + const size_t* origin, + const size_t* region, + size_t* image_row_pitch, + size_t* image_slice_pitch, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueMapImage( + command_queue, + image, + blocking_map, + map_flags, + origin, + region, + image_row_pitch, + image_slice_pitch, + num_events_in_wait_list, + event_wait_list, + event, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueMapImage( + command_queue, + image, + blocking_map, + map_flags, + origin, + region, + image_row_pitch, + image_slice_pitch, + num_events_in_wait_list, + event_wait_list, + event, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static void* CL_API_CALL clEnqueueMapImage_disp( + cl_command_queue command_queue, + cl_mem image, + cl_bool blocking_map, + cl_map_flags map_flags, + const size_t* origin, + const size_t* region, + size_t* image_row_pitch, + size_t* image_slice_pitch, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueMapImage( + command_queue, + image, + blocking_map, + map_flags, + origin, + region, + image_row_pitch, + image_slice_pitch, + num_events_in_wait_list, + event_wait_list, + event, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueUnmapMemObject( + cl_command_queue command_queue, + cl_mem memobj, + void* mapped_ptr, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueUnmapMemObject( + command_queue, + memobj, + mapped_ptr, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueUnmapMemObject( + command_queue, + memobj, + mapped_ptr, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueUnmapMemObject_disp( + cl_command_queue command_queue, + cl_mem memobj, + void* mapped_ptr, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueUnmapMemObject( + command_queue, + memobj, + mapped_ptr, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueNDRangeKernel( + cl_command_queue command_queue, + cl_kernel kernel, + cl_uint work_dim, + const size_t* global_work_offset, + const size_t* global_work_size, + const size_t* local_work_size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueNDRangeKernel( + command_queue, + kernel, + work_dim, + global_work_offset, + global_work_size, + local_work_size, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueNDRangeKernel( + command_queue, + kernel, + work_dim, + global_work_offset, + global_work_size, + local_work_size, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueNDRangeKernel_disp( + cl_command_queue command_queue, + cl_kernel kernel, + cl_uint work_dim, + const size_t* global_work_offset, + const size_t* global_work_size, + const size_t* local_work_size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueNDRangeKernel( + command_queue, + kernel, + work_dim, + global_work_offset, + global_work_size, + local_work_size, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueNativeKernel( + cl_command_queue command_queue, + void (CL_CALLBACK* user_func)(void*), + void* args, + size_t cb_args, + cl_uint num_mem_objects, + const cl_mem* mem_list, + const void** args_mem_loc, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueNativeKernel( + command_queue, + user_func, + args, + cb_args, + num_mem_objects, + mem_list, + args_mem_loc, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueNativeKernel( + command_queue, + user_func, + args, + cb_args, + num_mem_objects, + mem_list, + args_mem_loc, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueNativeKernel_disp( + cl_command_queue command_queue, + void (CL_CALLBACK* user_func)(void*), + void* args, + size_t cb_args, + cl_uint num_mem_objects, + const cl_mem* mem_list, + const void** args_mem_loc, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueNativeKernel( + command_queue, + user_func, + args, + cb_args, + num_mem_objects, + mem_list, + args_mem_loc, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +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) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clSetCommandQueueProperty( + command_queue, + properties, + enable, + old_properties); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clSetCommandQueueProperty( + command_queue, + properties, + enable, + old_properties); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clSetCommandQueueProperty_disp( + cl_command_queue command_queue, + cl_command_queue_properties properties, + cl_bool enable, + cl_command_queue_properties* old_properties) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clSetCommandQueueProperty( + command_queue, + properties, + enable, + old_properties); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_mem CL_API_CALL clCreateImage2D( + cl_context context, + cl_mem_flags flags, + const cl_image_format* image_format, + size_t image_width, + size_t image_height, + size_t image_row_pitch, + void* host_ptr, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateImage2D( + context, + flags, + image_format, + image_width, + image_height, + image_row_pitch, + host_ptr, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clCreateImage2D( + context, + flags, + image_format, + image_width, + image_height, + image_row_pitch, + host_ptr, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_mem CL_API_CALL clCreateImage2D_disp( + cl_context context, + cl_mem_flags flags, + const cl_image_format* image_format, + size_t image_width, + size_t image_height, + size_t image_row_pitch, + void* host_ptr, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clCreateImage2D( + context, + flags, + image_format, + image_width, + image_height, + image_row_pitch, + host_ptr, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_mem CL_API_CALL clCreateImage3D( + cl_context context, + cl_mem_flags flags, + const cl_image_format* image_format, + size_t image_width, + size_t image_height, + size_t image_depth, + size_t image_row_pitch, + size_t image_slice_pitch, + void* host_ptr, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateImage3D( + context, + flags, + image_format, + image_width, + image_height, + image_depth, + image_row_pitch, + image_slice_pitch, + host_ptr, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clCreateImage3D( + context, + flags, + image_format, + image_width, + image_height, + image_depth, + image_row_pitch, + image_slice_pitch, + host_ptr, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_mem CL_API_CALL clCreateImage3D_disp( + cl_context context, + cl_mem_flags flags, + const cl_image_format* image_format, + size_t image_width, + size_t image_height, + size_t image_depth, + size_t image_row_pitch, + size_t image_slice_pitch, + void* host_ptr, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clCreateImage3D( + context, + flags, + image_format, + image_width, + image_height, + image_depth, + image_row_pitch, + image_slice_pitch, + host_ptr, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueMarker( + cl_command_queue command_queue, + cl_event* event) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueMarker( + command_queue, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueMarker( + command_queue, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueMarker_disp( + cl_command_queue command_queue, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueMarker( + command_queue, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueWaitForEvents( + cl_command_queue command_queue, + cl_uint num_events, + const cl_event* event_list) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueWaitForEvents( + command_queue, + num_events, + event_list); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueWaitForEvents( + command_queue, + num_events, + event_list); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueWaitForEvents_disp( + cl_command_queue command_queue, + cl_uint num_events, + const cl_event* event_list) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueWaitForEvents( + command_queue, + num_events, + event_list); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueBarrier( + cl_command_queue command_queue) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueBarrier( + command_queue); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueBarrier( + command_queue); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueBarrier_disp( + cl_command_queue command_queue) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueBarrier( + command_queue); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clUnloadCompiler( + void ) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clUnloadCompiler( + ); +#endif // defined(CL_ENABLE_LAYERS) + // Nothing! + return CL_SUCCESS; +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clUnloadCompiler_disp( + void ) +{ + // Nothing! + return CL_SUCCESS; +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +extern void* CL_API_CALL clGetExtensionFunctionAddress_disp( + const char* func_name) CL_API_SUFFIX__VERSION_1_1_DEPRECATED; +#endif // defined(CL_ENABLE_LAYERS) + +CL_API_ENTRY cl_command_queue CL_API_CALL clCreateCommandQueue( + cl_context context, + cl_device_id device, + cl_command_queue_properties properties, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateCommandQueue( + context, + device, + properties, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clCreateCommandQueue( + context, + device, + properties, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_command_queue CL_API_CALL clCreateCommandQueue_disp( + cl_context context, + cl_device_id device, + cl_command_queue_properties properties, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clCreateCommandQueue( + context, + device, + properties, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_sampler CL_API_CALL clCreateSampler( + cl_context context, + cl_bool normalized_coords, + cl_addressing_mode addressing_mode, + cl_filter_mode filter_mode, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateSampler( + context, + normalized_coords, + addressing_mode, + filter_mode, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clCreateSampler( + context, + normalized_coords, + addressing_mode, + filter_mode, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_sampler CL_API_CALL clCreateSampler_disp( + cl_context context, + cl_bool normalized_coords, + cl_addressing_mode addressing_mode, + cl_filter_mode filter_mode, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clCreateSampler( + context, + normalized_coords, + addressing_mode, + filter_mode, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueTask( + cl_command_queue command_queue, + cl_kernel kernel, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueTask( + command_queue, + kernel, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueTask( + command_queue, + kernel, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueTask_disp( + cl_command_queue command_queue, + cl_kernel kernel, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueTask( + command_queue, + kernel, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_mem CL_API_CALL clCreateSubBuffer( + cl_mem buffer, + cl_mem_flags flags, + cl_buffer_create_type buffer_create_type, + const void* buffer_create_info, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateSubBuffer( + buffer, + flags, + buffer_create_type, + buffer_create_info, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(buffer, CL_INVALID_MEM_OBJECT); + return KHR_ICD2_DISPATCH(buffer)->clCreateSubBuffer( + buffer, + flags, + buffer_create_type, + buffer_create_info, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_mem CL_API_CALL clCreateSubBuffer_disp( + cl_mem buffer, + cl_mem_flags flags, + cl_buffer_create_type buffer_create_type, + const void* buffer_create_info, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(buffer, CL_INVALID_MEM_OBJECT); + return KHR_ICD2_DISPATCH(buffer)->clCreateSubBuffer( + buffer, + flags, + buffer_create_type, + buffer_create_info, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clSetMemObjectDestructorCallback( + cl_mem memobj, + void (CL_CALLBACK* pfn_notify)(cl_mem memobj, void* user_data), + void* user_data) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clSetMemObjectDestructorCallback( + memobj, + pfn_notify, + user_data); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); + return KHR_ICD2_DISPATCH(memobj)->clSetMemObjectDestructorCallback( + memobj, + pfn_notify, + user_data); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clSetMemObjectDestructorCallback_disp( + cl_mem memobj, + void (CL_CALLBACK* pfn_notify)(cl_mem memobj, void* user_data), + void* user_data) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); + return KHR_ICD2_DISPATCH(memobj)->clSetMemObjectDestructorCallback( + memobj, + pfn_notify, + user_data); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_event CL_API_CALL clCreateUserEvent( + cl_context context, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateUserEvent( + context, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clCreateUserEvent( + context, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_event CL_API_CALL clCreateUserEvent_disp( + cl_context context, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clCreateUserEvent( + context, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clSetUserEventStatus( + cl_event event, + cl_int execution_status) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clSetUserEventStatus( + event, + execution_status); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); + return KHR_ICD2_DISPATCH(event)->clSetUserEventStatus( + event, + execution_status); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clSetUserEventStatus_disp( + cl_event event, + cl_int execution_status) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); + return KHR_ICD2_DISPATCH(event)->clSetUserEventStatus( + event, + execution_status); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clSetEventCallback( + cl_event event, + cl_int command_exec_callback_type, + void (CL_CALLBACK* pfn_notify)(cl_event event, cl_int event_command_status, void *user_data), + void* user_data) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clSetEventCallback( + event, + command_exec_callback_type, + pfn_notify, + user_data); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); + return KHR_ICD2_DISPATCH(event)->clSetEventCallback( + event, + command_exec_callback_type, + pfn_notify, + user_data); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clSetEventCallback_disp( + cl_event event, + cl_int command_exec_callback_type, + void (CL_CALLBACK* pfn_notify)(cl_event event, cl_int event_command_status, void *user_data), + void* user_data) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(event, CL_INVALID_EVENT); + return KHR_ICD2_DISPATCH(event)->clSetEventCallback( + event, + command_exec_callback_type, + pfn_notify, + user_data); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueReadBufferRect( + cl_command_queue command_queue, + cl_mem buffer, + cl_bool blocking_read, + const size_t* buffer_origin, + const size_t* host_origin, + const size_t* region, + size_t buffer_row_pitch, + size_t buffer_slice_pitch, + size_t host_row_pitch, + size_t host_slice_pitch, + void* ptr, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueReadBufferRect( + command_queue, + buffer, + blocking_read, + buffer_origin, + host_origin, + region, + buffer_row_pitch, + buffer_slice_pitch, + host_row_pitch, + host_slice_pitch, + ptr, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueReadBufferRect( + command_queue, + buffer, + blocking_read, + buffer_origin, + host_origin, + region, + buffer_row_pitch, + buffer_slice_pitch, + host_row_pitch, + host_slice_pitch, + ptr, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueReadBufferRect_disp( + cl_command_queue command_queue, + cl_mem buffer, + cl_bool blocking_read, + const size_t* buffer_origin, + const size_t* host_origin, + const size_t* region, + size_t buffer_row_pitch, + size_t buffer_slice_pitch, + size_t host_row_pitch, + size_t host_slice_pitch, + void* ptr, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueReadBufferRect( + command_queue, + buffer, + blocking_read, + buffer_origin, + host_origin, + region, + buffer_row_pitch, + buffer_slice_pitch, + host_row_pitch, + host_slice_pitch, + ptr, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueWriteBufferRect( + cl_command_queue command_queue, + cl_mem buffer, + cl_bool blocking_write, + const size_t* buffer_origin, + const size_t* host_origin, + const size_t* region, + size_t buffer_row_pitch, + size_t buffer_slice_pitch, + size_t host_row_pitch, + size_t host_slice_pitch, + const void* ptr, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueWriteBufferRect( + command_queue, + buffer, + blocking_write, + buffer_origin, + host_origin, + region, + buffer_row_pitch, + buffer_slice_pitch, + host_row_pitch, + host_slice_pitch, + ptr, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueWriteBufferRect( + command_queue, + buffer, + blocking_write, + buffer_origin, + host_origin, + region, + buffer_row_pitch, + buffer_slice_pitch, + host_row_pitch, + host_slice_pitch, + ptr, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueWriteBufferRect_disp( + cl_command_queue command_queue, + cl_mem buffer, + cl_bool blocking_write, + const size_t* buffer_origin, + const size_t* host_origin, + const size_t* region, + size_t buffer_row_pitch, + size_t buffer_slice_pitch, + size_t host_row_pitch, + size_t host_slice_pitch, + const void* ptr, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueWriteBufferRect( + command_queue, + buffer, + blocking_write, + buffer_origin, + host_origin, + region, + buffer_row_pitch, + buffer_slice_pitch, + host_row_pitch, + host_slice_pitch, + ptr, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueCopyBufferRect( + cl_command_queue command_queue, + cl_mem src_buffer, + cl_mem dst_buffer, + const size_t* src_origin, + const size_t* dst_origin, + const size_t* region, + size_t src_row_pitch, + size_t src_slice_pitch, + size_t dst_row_pitch, + size_t dst_slice_pitch, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueCopyBufferRect( + command_queue, + src_buffer, + dst_buffer, + src_origin, + dst_origin, + region, + src_row_pitch, + src_slice_pitch, + dst_row_pitch, + dst_slice_pitch, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueCopyBufferRect( + command_queue, + src_buffer, + dst_buffer, + src_origin, + dst_origin, + region, + src_row_pitch, + src_slice_pitch, + dst_row_pitch, + dst_slice_pitch, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueCopyBufferRect_disp( + cl_command_queue command_queue, + cl_mem src_buffer, + cl_mem dst_buffer, + const size_t* src_origin, + const size_t* dst_origin, + const size_t* region, + size_t src_row_pitch, + size_t src_slice_pitch, + size_t dst_row_pitch, + size_t dst_slice_pitch, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueCopyBufferRect( + command_queue, + src_buffer, + dst_buffer, + src_origin, + dst_origin, + region, + src_row_pitch, + src_slice_pitch, + dst_row_pitch, + dst_slice_pitch, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clCreateSubDevices( + cl_device_id in_device, + const cl_device_partition_property* properties, + cl_uint num_devices, + cl_device_id* out_devices, + cl_uint* num_devices_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateSubDevices( + in_device, + properties, + num_devices, + out_devices, + num_devices_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(in_device, CL_INVALID_DEVICE); + return KHR_ICD2_DISPATCH(in_device)->clCreateSubDevices( + in_device, + properties, + num_devices, + out_devices, + num_devices_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clCreateSubDevices_disp( + cl_device_id in_device, + const cl_device_partition_property* properties, + cl_uint num_devices, + cl_device_id* out_devices, + cl_uint* num_devices_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(in_device, CL_INVALID_DEVICE); + return KHR_ICD2_DISPATCH(in_device)->clCreateSubDevices( + in_device, + properties, + num_devices, + out_devices, + num_devices_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clRetainDevice( + cl_device_id device) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clRetainDevice( + device); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); + return KHR_ICD2_DISPATCH(device)->clRetainDevice( + device); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clRetainDevice_disp( + cl_device_id device) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); + return KHR_ICD2_DISPATCH(device)->clRetainDevice( + device); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clReleaseDevice( + cl_device_id device) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clReleaseDevice( + device); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); + return KHR_ICD2_DISPATCH(device)->clReleaseDevice( + device); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clReleaseDevice_disp( + cl_device_id device) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); + return KHR_ICD2_DISPATCH(device)->clReleaseDevice( + device); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_mem CL_API_CALL clCreateImage( + cl_context context, + cl_mem_flags flags, + const cl_image_format* image_format, + const cl_image_desc* image_desc, + void* host_ptr, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateImage( + context, + flags, + image_format, + image_desc, + host_ptr, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clCreateImage( + context, + flags, + image_format, + image_desc, + host_ptr, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_mem CL_API_CALL clCreateImage_disp( + cl_context context, + cl_mem_flags flags, + const cl_image_format* image_format, + const cl_image_desc* image_desc, + void* host_ptr, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clCreateImage( + context, + flags, + image_format, + image_desc, + host_ptr, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_program CL_API_CALL clCreateProgramWithBuiltInKernels( + cl_context context, + cl_uint num_devices, + const cl_device_id* device_list, + const char* kernel_names, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateProgramWithBuiltInKernels( + context, + num_devices, + device_list, + kernel_names, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clCreateProgramWithBuiltInKernels( + context, + num_devices, + device_list, + kernel_names, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_program CL_API_CALL clCreateProgramWithBuiltInKernels_disp( + cl_context context, + cl_uint num_devices, + const cl_device_id* device_list, + const char* kernel_names, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clCreateProgramWithBuiltInKernels( + context, + num_devices, + device_list, + kernel_names, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clCompileProgram( + cl_program program, + cl_uint num_devices, + const cl_device_id* device_list, + const char* options, + cl_uint num_input_headers, + const cl_program* input_headers, + const char** header_include_names, + void (CL_CALLBACK* pfn_notify)(cl_program program, void* user_data), + void* user_data) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCompileProgram( + program, + num_devices, + device_list, + options, + num_input_headers, + input_headers, + header_include_names, + pfn_notify, + user_data); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); + return KHR_ICD2_DISPATCH(program)->clCompileProgram( + program, + num_devices, + device_list, + options, + num_input_headers, + input_headers, + header_include_names, + pfn_notify, + user_data); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clCompileProgram_disp( + cl_program program, + cl_uint num_devices, + const cl_device_id* device_list, + const char* options, + cl_uint num_input_headers, + const cl_program* input_headers, + const char** header_include_names, + void (CL_CALLBACK* pfn_notify)(cl_program program, void* user_data), + void* user_data) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); + return KHR_ICD2_DISPATCH(program)->clCompileProgram( + program, + num_devices, + device_list, + options, + num_input_headers, + input_headers, + header_include_names, + pfn_notify, + user_data); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_program CL_API_CALL clLinkProgram( + cl_context context, + cl_uint num_devices, + const cl_device_id* device_list, + const char* options, + cl_uint num_input_programs, + const cl_program* input_programs, + void (CL_CALLBACK* pfn_notify)(cl_program program, void* user_data), + void* user_data, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clLinkProgram( + context, + num_devices, + device_list, + options, + num_input_programs, + input_programs, + pfn_notify, + user_data, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clLinkProgram( + context, + num_devices, + device_list, + options, + num_input_programs, + input_programs, + pfn_notify, + user_data, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_program CL_API_CALL clLinkProgram_disp( + cl_context context, + cl_uint num_devices, + const cl_device_id* device_list, + const char* options, + cl_uint num_input_programs, + const cl_program* input_programs, + void (CL_CALLBACK* pfn_notify)(cl_program program, void* user_data), + void* user_data, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clLinkProgram( + context, + num_devices, + device_list, + options, + num_input_programs, + input_programs, + pfn_notify, + user_data, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clUnloadPlatformCompiler( + cl_platform_id platform) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clUnloadPlatformCompiler( + platform); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); + return KHR_ICD2_DISPATCH(platform)->clUnloadPlatformCompiler( + platform); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clUnloadPlatformCompiler_disp( + cl_platform_id platform) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); + return KHR_ICD2_DISPATCH(platform)->clUnloadPlatformCompiler( + platform); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clGetKernelArgInfo( + cl_kernel kernel, + cl_uint arg_index, + cl_kernel_arg_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clGetKernelArgInfo( + kernel, + arg_index, + param_name, + param_value_size, + param_value, + param_value_size_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); + return KHR_ICD2_DISPATCH(kernel)->clGetKernelArgInfo( + kernel, + arg_index, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clGetKernelArgInfo_disp( + cl_kernel kernel, + cl_uint arg_index, + cl_kernel_arg_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); + return KHR_ICD2_DISPATCH(kernel)->clGetKernelArgInfo( + kernel, + arg_index, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueFillBuffer( + cl_command_queue command_queue, + cl_mem buffer, + const void* pattern, + size_t pattern_size, + size_t offset, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueFillBuffer( + command_queue, + buffer, + pattern, + pattern_size, + offset, + size, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueFillBuffer( + command_queue, + buffer, + pattern, + pattern_size, + offset, + size, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueFillBuffer_disp( + cl_command_queue command_queue, + cl_mem buffer, + const void* pattern, + size_t pattern_size, + size_t offset, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueFillBuffer( + command_queue, + buffer, + pattern, + pattern_size, + offset, + size, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueFillImage( + cl_command_queue command_queue, + cl_mem image, + const void* fill_color, + const size_t* origin, + const size_t* region, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueFillImage( + command_queue, + image, + fill_color, + origin, + region, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueFillImage( + command_queue, + image, + fill_color, + origin, + region, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueFillImage_disp( + cl_command_queue command_queue, + cl_mem image, + const void* fill_color, + const size_t* origin, + const size_t* region, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueFillImage( + command_queue, + image, + fill_color, + origin, + region, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueMigrateMemObjects( + cl_command_queue command_queue, + cl_uint num_mem_objects, + const cl_mem* mem_objects, + cl_mem_migration_flags flags, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueMigrateMemObjects( + command_queue, + num_mem_objects, + mem_objects, + flags, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueMigrateMemObjects( + command_queue, + num_mem_objects, + mem_objects, + flags, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueMigrateMemObjects_disp( + cl_command_queue command_queue, + cl_uint num_mem_objects, + const cl_mem* mem_objects, + cl_mem_migration_flags flags, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueMigrateMemObjects( + command_queue, + num_mem_objects, + mem_objects, + flags, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueMarkerWithWaitList( + cl_command_queue command_queue, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueMarkerWithWaitList( + command_queue, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueMarkerWithWaitList( + command_queue, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueMarkerWithWaitList_disp( + cl_command_queue command_queue, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueMarkerWithWaitList( + command_queue, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueBarrierWithWaitList( + cl_command_queue command_queue, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueBarrierWithWaitList( + command_queue, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueBarrierWithWaitList( + command_queue, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueBarrierWithWaitList_disp( + cl_command_queue command_queue, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueBarrierWithWaitList( + command_queue, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +extern void* CL_API_CALL clGetExtensionFunctionAddressForPlatform_disp( + cl_platform_id platform, + const char* func_name) CL_API_SUFFIX__VERSION_1_2; +#endif // defined(CL_ENABLE_LAYERS) + +CL_API_ENTRY cl_command_queue CL_API_CALL clCreateCommandQueueWithProperties( + cl_context context, + cl_device_id device, + const cl_queue_properties* properties, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateCommandQueueWithProperties( + context, + device, + properties, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clCreateCommandQueueWithProperties( + context, + device, + properties, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_command_queue CL_API_CALL clCreateCommandQueueWithProperties_disp( + cl_context context, + cl_device_id device, + const cl_queue_properties* properties, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clCreateCommandQueueWithProperties( + context, + device, + properties, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_mem CL_API_CALL clCreatePipe( + cl_context context, + cl_mem_flags flags, + cl_uint pipe_packet_size, + cl_uint pipe_max_packets, + const cl_pipe_properties* properties, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreatePipe( + context, + flags, + pipe_packet_size, + pipe_max_packets, + properties, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clCreatePipe( + context, + flags, + pipe_packet_size, + pipe_max_packets, + properties, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_mem CL_API_CALL clCreatePipe_disp( + cl_context context, + cl_mem_flags flags, + cl_uint pipe_packet_size, + cl_uint pipe_max_packets, + const cl_pipe_properties* properties, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clCreatePipe( + context, + flags, + pipe_packet_size, + pipe_max_packets, + properties, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clGetPipeInfo( + cl_mem pipe, + cl_pipe_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clGetPipeInfo( + pipe, + param_name, + param_value_size, + param_value, + param_value_size_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(pipe, CL_INVALID_MEM_OBJECT); + return KHR_ICD2_DISPATCH(pipe)->clGetPipeInfo( + pipe, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clGetPipeInfo_disp( + cl_mem pipe, + cl_pipe_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(pipe, CL_INVALID_MEM_OBJECT); + return KHR_ICD2_DISPATCH(pipe)->clGetPipeInfo( + pipe, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY void* CL_API_CALL clSVMAlloc( + cl_context context, + cl_svm_mem_flags flags, + size_t size, + cl_uint alignment) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clSVMAlloc( + context, + flags, + size, + alignment); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(context, NULL); + return KHR_ICD2_DISPATCH(context)->clSVMAlloc( + context, + flags, + size, + alignment); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static void* CL_API_CALL clSVMAlloc_disp( + cl_context context, + cl_svm_mem_flags flags, + size_t size, + cl_uint alignment) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(context, NULL); + return KHR_ICD2_DISPATCH(context)->clSVMAlloc( + context, + flags, + size, + alignment); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY void CL_API_CALL clSVMFree( + cl_context context, + void* svm_pointer) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + { + khrFirstLayer->dispatch.clSVMFree( + context, + svm_pointer); + } + else +#endif // defined(CL_ENABLE_LAYERS) + if (context != NULL) + KHR_ICD2_DISPATCH(context)->clSVMFree( + context, + svm_pointer); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static void CL_API_CALL clSVMFree_disp( + cl_context context, + void* svm_pointer) +{ + if (context != NULL) + KHR_ICD2_DISPATCH(context)->clSVMFree( + context, + svm_pointer); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_sampler CL_API_CALL clCreateSamplerWithProperties( + cl_context context, + const cl_sampler_properties* sampler_properties, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateSamplerWithProperties( + context, + sampler_properties, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clCreateSamplerWithProperties( + context, + sampler_properties, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_sampler CL_API_CALL clCreateSamplerWithProperties_disp( + cl_context context, + const cl_sampler_properties* sampler_properties, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clCreateSamplerWithProperties( + context, + sampler_properties, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clSetKernelArgSVMPointer( + cl_kernel kernel, + cl_uint arg_index, + const void* arg_value) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clSetKernelArgSVMPointer( + kernel, + arg_index, + arg_value); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); + return KHR_ICD2_DISPATCH(kernel)->clSetKernelArgSVMPointer( + kernel, + arg_index, + arg_value); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clSetKernelArgSVMPointer_disp( + cl_kernel kernel, + cl_uint arg_index, + const void* arg_value) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); + return KHR_ICD2_DISPATCH(kernel)->clSetKernelArgSVMPointer( + kernel, + arg_index, + arg_value); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clSetKernelExecInfo( + cl_kernel kernel, + cl_kernel_exec_info param_name, + size_t param_value_size, + const void* param_value) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clSetKernelExecInfo( + kernel, + param_name, + param_value_size, + param_value); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); + return KHR_ICD2_DISPATCH(kernel)->clSetKernelExecInfo( + kernel, + param_name, + param_value_size, + param_value); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clSetKernelExecInfo_disp( + cl_kernel kernel, + cl_kernel_exec_info param_name, + size_t param_value_size, + const void* param_value) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); + return KHR_ICD2_DISPATCH(kernel)->clSetKernelExecInfo( + kernel, + param_name, + param_value_size, + param_value); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueSVMFree( + cl_command_queue command_queue, + cl_uint num_svm_pointers, + void* svm_pointers[], + void (CL_CALLBACK* pfn_free_func)(cl_command_queue queue, cl_uint num_svm_pointers, void* svm_pointers[], void* user_data), + void* user_data, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueSVMFree( + command_queue, + num_svm_pointers, + svm_pointers, + pfn_free_func, + user_data, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueSVMFree( + command_queue, + num_svm_pointers, + svm_pointers, + pfn_free_func, + user_data, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueSVMFree_disp( + cl_command_queue command_queue, + cl_uint num_svm_pointers, + void* svm_pointers[], + void (CL_CALLBACK* pfn_free_func)(cl_command_queue queue, cl_uint num_svm_pointers, void* svm_pointers[], void* user_data), + void* user_data, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueSVMFree( + command_queue, + num_svm_pointers, + svm_pointers, + pfn_free_func, + user_data, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueSVMMemcpy( + cl_command_queue command_queue, + cl_bool blocking_copy, + void* dst_ptr, + const void* src_ptr, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueSVMMemcpy( + command_queue, + blocking_copy, + dst_ptr, + src_ptr, + size, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueSVMMemcpy( + command_queue, + blocking_copy, + dst_ptr, + src_ptr, + size, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueSVMMemcpy_disp( + cl_command_queue command_queue, + cl_bool blocking_copy, + void* dst_ptr, + const void* src_ptr, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueSVMMemcpy( + command_queue, + blocking_copy, + dst_ptr, + src_ptr, + size, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueSVMMemFill( + cl_command_queue command_queue, + void* svm_ptr, + const void* pattern, + size_t pattern_size, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueSVMMemFill( + command_queue, + svm_ptr, + pattern, + pattern_size, + size, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueSVMMemFill( + command_queue, + svm_ptr, + pattern, + pattern_size, + size, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueSVMMemFill_disp( + cl_command_queue command_queue, + void* svm_ptr, + const void* pattern, + size_t pattern_size, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueSVMMemFill( + command_queue, + svm_ptr, + pattern, + pattern_size, + size, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueSVMMap( + cl_command_queue command_queue, + cl_bool blocking_map, + cl_map_flags flags, + void* svm_ptr, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueSVMMap( + command_queue, + blocking_map, + flags, + svm_ptr, + size, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueSVMMap( + command_queue, + blocking_map, + flags, + svm_ptr, + size, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueSVMMap_disp( + cl_command_queue command_queue, + cl_bool blocking_map, + cl_map_flags flags, + void* svm_ptr, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueSVMMap( + command_queue, + blocking_map, + flags, + svm_ptr, + size, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueSVMUnmap( + cl_command_queue command_queue, + void* svm_ptr, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueSVMUnmap( + command_queue, + svm_ptr, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueSVMUnmap( + command_queue, + svm_ptr, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueSVMUnmap_disp( + cl_command_queue command_queue, + void* svm_ptr, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueSVMUnmap( + command_queue, + svm_ptr, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clSetDefaultDeviceCommandQueue( + cl_context context, + cl_device_id device, + cl_command_queue command_queue) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clSetDefaultDeviceCommandQueue( + context, + device, + command_queue); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clSetDefaultDeviceCommandQueue( + context, + device, + command_queue); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clSetDefaultDeviceCommandQueue_disp( + cl_context context, + cl_device_id device, + cl_command_queue command_queue) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clSetDefaultDeviceCommandQueue( + context, + device, + command_queue); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clGetDeviceAndHostTimer( + cl_device_id device, + cl_ulong* device_timestamp, + cl_ulong* host_timestamp) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clGetDeviceAndHostTimer( + device, + device_timestamp, + host_timestamp); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); + return KHR_ICD2_DISPATCH(device)->clGetDeviceAndHostTimer( + device, + device_timestamp, + host_timestamp); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clGetDeviceAndHostTimer_disp( + cl_device_id device, + cl_ulong* device_timestamp, + cl_ulong* host_timestamp) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); + return KHR_ICD2_DISPATCH(device)->clGetDeviceAndHostTimer( + device, + device_timestamp, + host_timestamp); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clGetHostTimer( + cl_device_id device, + cl_ulong* host_timestamp) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clGetHostTimer( + device, + host_timestamp); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); + return KHR_ICD2_DISPATCH(device)->clGetHostTimer( + device, + host_timestamp); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clGetHostTimer_disp( + cl_device_id device, + cl_ulong* host_timestamp) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); + return KHR_ICD2_DISPATCH(device)->clGetHostTimer( + device, + host_timestamp); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_program CL_API_CALL clCreateProgramWithIL( + cl_context context, + const void* il, + size_t length, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateProgramWithIL( + context, + il, + length, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clCreateProgramWithIL( + context, + il, + length, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_program CL_API_CALL clCreateProgramWithIL_disp( + cl_context context, + const void* il, + size_t length, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clCreateProgramWithIL( + context, + il, + length, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_kernel CL_API_CALL clCloneKernel( + cl_kernel source_kernel, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCloneKernel( + source_kernel, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(source_kernel, CL_INVALID_KERNEL); + return KHR_ICD2_DISPATCH(source_kernel)->clCloneKernel( + source_kernel, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_kernel CL_API_CALL clCloneKernel_disp( + cl_kernel source_kernel, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(source_kernel, CL_INVALID_KERNEL); + return KHR_ICD2_DISPATCH(source_kernel)->clCloneKernel( + source_kernel, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clGetKernelSubGroupInfo( + cl_kernel kernel, + cl_device_id device, + cl_kernel_sub_group_info param_name, + size_t input_value_size, + const void* input_value, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clGetKernelSubGroupInfo( + kernel, + device, + param_name, + input_value_size, + input_value, + param_value_size, + param_value, + param_value_size_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); + return KHR_ICD2_DISPATCH(kernel)->clGetKernelSubGroupInfo( + kernel, + device, + param_name, + input_value_size, + input_value, + param_value_size, + param_value, + param_value_size_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clGetKernelSubGroupInfo_disp( + cl_kernel kernel, + cl_device_id device, + cl_kernel_sub_group_info param_name, + size_t input_value_size, + const void* input_value, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(kernel, CL_INVALID_KERNEL); + return KHR_ICD2_DISPATCH(kernel)->clGetKernelSubGroupInfo( + kernel, + device, + param_name, + input_value_size, + input_value, + param_value_size, + param_value, + param_value_size_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueSVMMigrateMem( + cl_command_queue command_queue, + cl_uint num_svm_pointers, + const void** svm_pointers, + const size_t* sizes, + cl_mem_migration_flags flags, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueSVMMigrateMem( + command_queue, + num_svm_pointers, + svm_pointers, + sizes, + flags, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueSVMMigrateMem( + command_queue, + num_svm_pointers, + svm_pointers, + sizes, + flags, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueSVMMigrateMem_disp( + cl_command_queue command_queue, + cl_uint num_svm_pointers, + const void** svm_pointers, + const size_t* sizes, + cl_mem_migration_flags flags, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueSVMMigrateMem( + command_queue, + num_svm_pointers, + svm_pointers, + sizes, + flags, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clSetProgramSpecializationConstant( + cl_program program, + cl_uint spec_id, + size_t spec_size, + const void* spec_value) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clSetProgramSpecializationConstant( + program, + spec_id, + spec_size, + spec_value); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); + return KHR_ICD2_DISPATCH(program)->clSetProgramSpecializationConstant( + program, + spec_id, + spec_size, + spec_value); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clSetProgramSpecializationConstant_disp( + cl_program program, + cl_uint spec_id, + size_t spec_size, + const void* spec_value) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); + return KHR_ICD2_DISPATCH(program)->clSetProgramSpecializationConstant( + program, + spec_id, + spec_size, + spec_value); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clSetProgramReleaseCallback( + cl_program program, + void (CL_CALLBACK* pfn_notify)(cl_program program, void* user_data), + void* user_data) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clSetProgramReleaseCallback( + program, + pfn_notify, + user_data); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); + return KHR_ICD2_DISPATCH(program)->clSetProgramReleaseCallback( + program, + pfn_notify, + user_data); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clSetProgramReleaseCallback_disp( + cl_program program, + void (CL_CALLBACK* pfn_notify)(cl_program program, void* user_data), + void* user_data) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(program, CL_INVALID_PROGRAM); + return KHR_ICD2_DISPATCH(program)->clSetProgramReleaseCallback( + program, + pfn_notify, + user_data); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_int CL_API_CALL clSetContextDestructorCallback( + cl_context context, + void (CL_CALLBACK* pfn_notify)(cl_context context, void* user_data), + void* user_data) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clSetContextDestructorCallback( + context, + pfn_notify, + user_data); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clSetContextDestructorCallback( + context, + pfn_notify, + user_data); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clSetContextDestructorCallback_disp( + cl_context context, + void (CL_CALLBACK* pfn_notify)(cl_context context, void* user_data), + void* user_data) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clSetContextDestructorCallback( + context, + pfn_notify, + user_data); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_mem CL_API_CALL clCreateBufferWithProperties( + cl_context context, + const cl_mem_properties* properties, + cl_mem_flags flags, + size_t size, + void* host_ptr, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateBufferWithProperties( + context, + properties, + flags, + size, + host_ptr, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clCreateBufferWithProperties( + context, + properties, + flags, + size, + host_ptr, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_mem CL_API_CALL clCreateBufferWithProperties_disp( + cl_context context, + const cl_mem_properties* properties, + cl_mem_flags flags, + size_t size, + void* host_ptr, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clCreateBufferWithProperties( + context, + properties, + flags, + size, + host_ptr, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +CL_API_ENTRY cl_mem CL_API_CALL clCreateImageWithProperties( + cl_context context, + const cl_mem_properties* properties, + cl_mem_flags flags, + const cl_image_format* image_format, + const cl_image_desc* image_desc, + void* host_ptr, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateImageWithProperties( + context, + properties, + flags, + image_format, + image_desc, + host_ptr, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clCreateImageWithProperties( + context, + properties, + flags, + image_format, + image_desc, + host_ptr, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +#if defined(CL_ENABLE_LAYERS) +static cl_mem CL_API_CALL clCreateImageWithProperties_disp( + cl_context context, + const cl_mem_properties* properties, + cl_mem_flags flags, + const cl_image_format* image_format, + const cl_image_desc* image_desc, + void* host_ptr, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + return KHR_ICD2_DISPATCH(context)->clCreateImageWithProperties( + context, + properties, + flags, + image_format, + image_desc, + host_ptr, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +// cl_ext_device_fission + +CL_API_ENTRY cl_int CL_API_CALL clReleaseDeviceEXT( + cl_device_id device) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clReleaseDeviceEXT( + device); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(device)->clReleaseDeviceEXT); + return KHR_ICD2_DISPATCH(device)->clReleaseDeviceEXT( + device); +} +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clReleaseDeviceEXT_disp( + cl_device_id device) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(device)->clReleaseDeviceEXT); + return KHR_ICD2_DISPATCH(device)->clReleaseDeviceEXT( + device); +} +#endif // defined(CL_ENABLE_LAYERS) + +CL_API_ENTRY cl_int CL_API_CALL clRetainDeviceEXT( + cl_device_id device) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clRetainDeviceEXT( + device); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(device)->clRetainDeviceEXT); + return KHR_ICD2_DISPATCH(device)->clRetainDeviceEXT( + device); +} +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clRetainDeviceEXT_disp( + cl_device_id device) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(device, CL_INVALID_DEVICE); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(device)->clRetainDeviceEXT); + return KHR_ICD2_DISPATCH(device)->clRetainDeviceEXT( + device); +} +#endif // defined(CL_ENABLE_LAYERS) + +CL_API_ENTRY cl_int CL_API_CALL clCreateSubDevicesEXT( + cl_device_id in_device, + const cl_device_partition_property_ext* properties, + cl_uint num_entries, + cl_device_id* out_devices, + cl_uint* num_devices) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateSubDevicesEXT( + in_device, + properties, + num_entries, + out_devices, + num_devices); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(in_device, CL_INVALID_DEVICE); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(in_device)->clCreateSubDevicesEXT); + return KHR_ICD2_DISPATCH(in_device)->clCreateSubDevicesEXT( + in_device, + properties, + num_entries, + out_devices, + num_devices); +} +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clCreateSubDevicesEXT_disp( + cl_device_id in_device, + const cl_device_partition_property_ext* properties, + cl_uint num_entries, + cl_device_id* out_devices, + cl_uint* num_devices) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(in_device, CL_INVALID_DEVICE); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(in_device)->clCreateSubDevicesEXT); + return KHR_ICD2_DISPATCH(in_device)->clCreateSubDevicesEXT( + in_device, + properties, + num_entries, + out_devices, + num_devices); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +// cl_khr_d3d10_sharing + +#if defined(_WIN32) + +CL_API_ENTRY cl_int CL_API_CALL clGetDeviceIDsFromD3D10KHR( + cl_platform_id platform, + cl_d3d10_device_source_khr d3d_device_source, + void* d3d_object, + cl_d3d10_device_set_khr d3d_device_set, + cl_uint num_entries, + cl_device_id* devices, + cl_uint* num_devices) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clGetDeviceIDsFromD3D10KHR( + platform, + d3d_device_source, + d3d_object, + d3d_device_set, + num_entries, + devices, + num_devices); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(platform)->clGetDeviceIDsFromD3D10KHR); + return KHR_ICD2_DISPATCH(platform)->clGetDeviceIDsFromD3D10KHR( + platform, + d3d_device_source, + d3d_object, + d3d_device_set, + num_entries, + devices, + num_devices); +} +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clGetDeviceIDsFromD3D10KHR_disp( + cl_platform_id platform, + cl_d3d10_device_source_khr d3d_device_source, + void* d3d_object, + cl_d3d10_device_set_khr d3d_device_set, + cl_uint num_entries, + cl_device_id* devices, + cl_uint* num_devices) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(platform)->clGetDeviceIDsFromD3D10KHR); + return KHR_ICD2_DISPATCH(platform)->clGetDeviceIDsFromD3D10KHR( + platform, + d3d_device_source, + d3d_object, + d3d_device_set, + num_entries, + devices, + num_devices); +} +#endif // defined(CL_ENABLE_LAYERS) + +CL_API_ENTRY cl_mem CL_API_CALL clCreateFromD3D10BufferKHR( + cl_context context, + cl_mem_flags flags, + ID3D10Buffer* resource, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateFromD3D10BufferKHR( + context, + flags, + resource, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + KHR_ICD_VALIDATE_POINTER_RETURN_HANDLE(KHR_ICD2_DISPATCH(context)->clCreateFromD3D10BufferKHR); + return KHR_ICD2_DISPATCH(context)->clCreateFromD3D10BufferKHR( + context, + flags, + resource, + errcode_ret); +} +#if defined(CL_ENABLE_LAYERS) +static cl_mem CL_API_CALL clCreateFromD3D10BufferKHR_disp( + cl_context context, + cl_mem_flags flags, + ID3D10Buffer* resource, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + KHR_ICD_VALIDATE_POINTER_RETURN_HANDLE(KHR_ICD2_DISPATCH(context)->clCreateFromD3D10BufferKHR); + return KHR_ICD2_DISPATCH(context)->clCreateFromD3D10BufferKHR( + context, + flags, + resource, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +CL_API_ENTRY cl_mem CL_API_CALL clCreateFromD3D10Texture2DKHR( + cl_context context, + cl_mem_flags flags, + ID3D10Texture2D* resource, + UINT subresource, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateFromD3D10Texture2DKHR( + context, + flags, + resource, + subresource, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + KHR_ICD_VALIDATE_POINTER_RETURN_HANDLE(KHR_ICD2_DISPATCH(context)->clCreateFromD3D10Texture2DKHR); + return KHR_ICD2_DISPATCH(context)->clCreateFromD3D10Texture2DKHR( + context, + flags, + resource, + subresource, + errcode_ret); +} +#if defined(CL_ENABLE_LAYERS) +static cl_mem CL_API_CALL clCreateFromD3D10Texture2DKHR_disp( + cl_context context, + cl_mem_flags flags, + ID3D10Texture2D* resource, + UINT subresource, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + KHR_ICD_VALIDATE_POINTER_RETURN_HANDLE(KHR_ICD2_DISPATCH(context)->clCreateFromD3D10Texture2DKHR); + return KHR_ICD2_DISPATCH(context)->clCreateFromD3D10Texture2DKHR( + context, + flags, + resource, + subresource, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +CL_API_ENTRY cl_mem CL_API_CALL clCreateFromD3D10Texture3DKHR( + cl_context context, + cl_mem_flags flags, + ID3D10Texture3D* resource, + UINT subresource, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateFromD3D10Texture3DKHR( + context, + flags, + resource, + subresource, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + KHR_ICD_VALIDATE_POINTER_RETURN_HANDLE(KHR_ICD2_DISPATCH(context)->clCreateFromD3D10Texture3DKHR); + return KHR_ICD2_DISPATCH(context)->clCreateFromD3D10Texture3DKHR( + context, + flags, + resource, + subresource, + errcode_ret); +} +#if defined(CL_ENABLE_LAYERS) +static cl_mem CL_API_CALL clCreateFromD3D10Texture3DKHR_disp( + cl_context context, + cl_mem_flags flags, + ID3D10Texture3D* resource, + UINT subresource, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + KHR_ICD_VALIDATE_POINTER_RETURN_HANDLE(KHR_ICD2_DISPATCH(context)->clCreateFromD3D10Texture3DKHR); + return KHR_ICD2_DISPATCH(context)->clCreateFromD3D10Texture3DKHR( + context, + flags, + resource, + subresource, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueAcquireD3D10ObjectsKHR( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueAcquireD3D10ObjectsKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(command_queue)->clEnqueueAcquireD3D10ObjectsKHR); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueAcquireD3D10ObjectsKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueAcquireD3D10ObjectsKHR_disp( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(command_queue)->clEnqueueAcquireD3D10ObjectsKHR); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueAcquireD3D10ObjectsKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueReleaseD3D10ObjectsKHR( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueReleaseD3D10ObjectsKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(command_queue)->clEnqueueReleaseD3D10ObjectsKHR); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueReleaseD3D10ObjectsKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueReleaseD3D10ObjectsKHR_disp( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(command_queue)->clEnqueueReleaseD3D10ObjectsKHR); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueReleaseD3D10ObjectsKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +#endif // defined(_WIN32) + +/////////////////////////////////////////////////////////////////////////////// + +// cl_khr_d3d11_sharing + +#if defined(_WIN32) + +CL_API_ENTRY cl_int CL_API_CALL clGetDeviceIDsFromD3D11KHR( + cl_platform_id platform, + cl_d3d11_device_source_khr d3d_device_source, + void* d3d_object, + cl_d3d11_device_set_khr d3d_device_set, + cl_uint num_entries, + cl_device_id* devices, + cl_uint* num_devices) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clGetDeviceIDsFromD3D11KHR( + platform, + d3d_device_source, + d3d_object, + d3d_device_set, + num_entries, + devices, + num_devices); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(platform)->clGetDeviceIDsFromD3D11KHR); + return KHR_ICD2_DISPATCH(platform)->clGetDeviceIDsFromD3D11KHR( + platform, + d3d_device_source, + d3d_object, + d3d_device_set, + num_entries, + devices, + num_devices); +} +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clGetDeviceIDsFromD3D11KHR_disp( + cl_platform_id platform, + cl_d3d11_device_source_khr d3d_device_source, + void* d3d_object, + cl_d3d11_device_set_khr d3d_device_set, + cl_uint num_entries, + cl_device_id* devices, + cl_uint* num_devices) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(platform)->clGetDeviceIDsFromD3D11KHR); + return KHR_ICD2_DISPATCH(platform)->clGetDeviceIDsFromD3D11KHR( + platform, + d3d_device_source, + d3d_object, + d3d_device_set, + num_entries, + devices, + num_devices); +} +#endif // defined(CL_ENABLE_LAYERS) + +CL_API_ENTRY cl_mem CL_API_CALL clCreateFromD3D11BufferKHR( + cl_context context, + cl_mem_flags flags, + ID3D11Buffer* resource, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateFromD3D11BufferKHR( + context, + flags, + resource, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + KHR_ICD_VALIDATE_POINTER_RETURN_HANDLE(KHR_ICD2_DISPATCH(context)->clCreateFromD3D11BufferKHR); + return KHR_ICD2_DISPATCH(context)->clCreateFromD3D11BufferKHR( + context, + flags, + resource, + errcode_ret); +} +#if defined(CL_ENABLE_LAYERS) +static cl_mem CL_API_CALL clCreateFromD3D11BufferKHR_disp( + cl_context context, + cl_mem_flags flags, + ID3D11Buffer* resource, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + KHR_ICD_VALIDATE_POINTER_RETURN_HANDLE(KHR_ICD2_DISPATCH(context)->clCreateFromD3D11BufferKHR); + return KHR_ICD2_DISPATCH(context)->clCreateFromD3D11BufferKHR( + context, + flags, + resource, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +CL_API_ENTRY cl_mem CL_API_CALL clCreateFromD3D11Texture2DKHR( + cl_context context, + cl_mem_flags flags, + ID3D11Texture2D* resource, + UINT subresource, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateFromD3D11Texture2DKHR( + context, + flags, + resource, + subresource, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + KHR_ICD_VALIDATE_POINTER_RETURN_HANDLE(KHR_ICD2_DISPATCH(context)->clCreateFromD3D11Texture2DKHR); + return KHR_ICD2_DISPATCH(context)->clCreateFromD3D11Texture2DKHR( + context, + flags, + resource, + subresource, + errcode_ret); +} +#if defined(CL_ENABLE_LAYERS) +static cl_mem CL_API_CALL clCreateFromD3D11Texture2DKHR_disp( + cl_context context, + cl_mem_flags flags, + ID3D11Texture2D* resource, + UINT subresource, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + KHR_ICD_VALIDATE_POINTER_RETURN_HANDLE(KHR_ICD2_DISPATCH(context)->clCreateFromD3D11Texture2DKHR); + return KHR_ICD2_DISPATCH(context)->clCreateFromD3D11Texture2DKHR( + context, + flags, + resource, + subresource, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +CL_API_ENTRY cl_mem CL_API_CALL clCreateFromD3D11Texture3DKHR( + cl_context context, + cl_mem_flags flags, + ID3D11Texture3D* resource, + UINT subresource, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateFromD3D11Texture3DKHR( + context, + flags, + resource, + subresource, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + KHR_ICD_VALIDATE_POINTER_RETURN_HANDLE(KHR_ICD2_DISPATCH(context)->clCreateFromD3D11Texture3DKHR); + return KHR_ICD2_DISPATCH(context)->clCreateFromD3D11Texture3DKHR( + context, + flags, + resource, + subresource, + errcode_ret); +} +#if defined(CL_ENABLE_LAYERS) +static cl_mem CL_API_CALL clCreateFromD3D11Texture3DKHR_disp( + cl_context context, + cl_mem_flags flags, + ID3D11Texture3D* resource, + UINT subresource, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + KHR_ICD_VALIDATE_POINTER_RETURN_HANDLE(KHR_ICD2_DISPATCH(context)->clCreateFromD3D11Texture3DKHR); + return KHR_ICD2_DISPATCH(context)->clCreateFromD3D11Texture3DKHR( + context, + flags, + resource, + subresource, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueAcquireD3D11ObjectsKHR( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueAcquireD3D11ObjectsKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(command_queue)->clEnqueueAcquireD3D11ObjectsKHR); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueAcquireD3D11ObjectsKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueAcquireD3D11ObjectsKHR_disp( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(command_queue)->clEnqueueAcquireD3D11ObjectsKHR); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueAcquireD3D11ObjectsKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueReleaseD3D11ObjectsKHR( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueReleaseD3D11ObjectsKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(command_queue)->clEnqueueReleaseD3D11ObjectsKHR); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueReleaseD3D11ObjectsKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueReleaseD3D11ObjectsKHR_disp( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(command_queue)->clEnqueueReleaseD3D11ObjectsKHR); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueReleaseD3D11ObjectsKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +#endif // defined(_WIN32) + +/////////////////////////////////////////////////////////////////////////////// + +// cl_khr_dx9_media_sharing + +#if defined(_WIN32) + +CL_API_ENTRY cl_int CL_API_CALL clGetDeviceIDsFromDX9MediaAdapterKHR( + cl_platform_id platform, + cl_uint num_media_adapters, + cl_dx9_media_adapter_type_khr* media_adapter_type, + void* media_adapters, + cl_dx9_media_adapter_set_khr media_adapter_set, + cl_uint num_entries, + cl_device_id* devices, + cl_uint* num_devices) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clGetDeviceIDsFromDX9MediaAdapterKHR( + platform, + num_media_adapters, + media_adapter_type, + media_adapters, + media_adapter_set, + num_entries, + devices, + num_devices); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(platform)->clGetDeviceIDsFromDX9MediaAdapterKHR); + return KHR_ICD2_DISPATCH(platform)->clGetDeviceIDsFromDX9MediaAdapterKHR( + platform, + num_media_adapters, + media_adapter_type, + media_adapters, + media_adapter_set, + num_entries, + devices, + num_devices); +} +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clGetDeviceIDsFromDX9MediaAdapterKHR_disp( + cl_platform_id platform, + cl_uint num_media_adapters, + cl_dx9_media_adapter_type_khr* media_adapter_type, + void* media_adapters, + cl_dx9_media_adapter_set_khr media_adapter_set, + cl_uint num_entries, + cl_device_id* devices, + cl_uint* num_devices) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(platform)->clGetDeviceIDsFromDX9MediaAdapterKHR); + return KHR_ICD2_DISPATCH(platform)->clGetDeviceIDsFromDX9MediaAdapterKHR( + platform, + num_media_adapters, + media_adapter_type, + media_adapters, + media_adapter_set, + num_entries, + devices, + num_devices); +} +#endif // defined(CL_ENABLE_LAYERS) + +CL_API_ENTRY cl_mem CL_API_CALL clCreateFromDX9MediaSurfaceKHR( + cl_context context, + cl_mem_flags flags, + cl_dx9_media_adapter_type_khr adapter_type, + void* surface_info, + cl_uint plane, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateFromDX9MediaSurfaceKHR( + context, + flags, + adapter_type, + surface_info, + plane, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + KHR_ICD_VALIDATE_POINTER_RETURN_HANDLE(KHR_ICD2_DISPATCH(context)->clCreateFromDX9MediaSurfaceKHR); + return KHR_ICD2_DISPATCH(context)->clCreateFromDX9MediaSurfaceKHR( + context, + flags, + adapter_type, + surface_info, + plane, + errcode_ret); +} +#if defined(CL_ENABLE_LAYERS) +static cl_mem CL_API_CALL clCreateFromDX9MediaSurfaceKHR_disp( + cl_context context, + cl_mem_flags flags, + cl_dx9_media_adapter_type_khr adapter_type, + void* surface_info, + cl_uint plane, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + KHR_ICD_VALIDATE_POINTER_RETURN_HANDLE(KHR_ICD2_DISPATCH(context)->clCreateFromDX9MediaSurfaceKHR); + return KHR_ICD2_DISPATCH(context)->clCreateFromDX9MediaSurfaceKHR( + context, + flags, + adapter_type, + surface_info, + plane, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueAcquireDX9MediaSurfacesKHR( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueAcquireDX9MediaSurfacesKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(command_queue)->clEnqueueAcquireDX9MediaSurfacesKHR); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueAcquireDX9MediaSurfacesKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueAcquireDX9MediaSurfacesKHR_disp( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(command_queue)->clEnqueueAcquireDX9MediaSurfacesKHR); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueAcquireDX9MediaSurfacesKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueReleaseDX9MediaSurfacesKHR( + 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) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueReleaseDX9MediaSurfacesKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(command_queue)->clEnqueueReleaseDX9MediaSurfacesKHR); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueReleaseDX9MediaSurfacesKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueReleaseDX9MediaSurfacesKHR_disp( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(command_queue)->clEnqueueReleaseDX9MediaSurfacesKHR); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueReleaseDX9MediaSurfacesKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +#endif // defined(_WIN32) + +/////////////////////////////////////////////////////////////////////////////// + +// cl_khr_egl_event + +CL_API_ENTRY cl_event CL_API_CALL clCreateEventFromEGLSyncKHR( + cl_context context, + CLeglSyncKHR sync, + CLeglDisplayKHR display, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateEventFromEGLSyncKHR( + context, + sync, + display, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + KHR_ICD_VALIDATE_POINTER_RETURN_HANDLE(KHR_ICD2_DISPATCH(context)->clCreateEventFromEGLSyncKHR); + return KHR_ICD2_DISPATCH(context)->clCreateEventFromEGLSyncKHR( + context, + sync, + display, + errcode_ret); +} +#if defined(CL_ENABLE_LAYERS) +static cl_event CL_API_CALL clCreateEventFromEGLSyncKHR_disp( + cl_context context, + CLeglSyncKHR sync, + CLeglDisplayKHR display, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + KHR_ICD_VALIDATE_POINTER_RETURN_HANDLE(KHR_ICD2_DISPATCH(context)->clCreateEventFromEGLSyncKHR); + return KHR_ICD2_DISPATCH(context)->clCreateEventFromEGLSyncKHR( + context, + sync, + display, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +// cl_khr_egl_image + +CL_API_ENTRY cl_mem CL_API_CALL clCreateFromEGLImageKHR( + cl_context context, + CLeglDisplayKHR egldisplay, + CLeglImageKHR eglimage, + cl_mem_flags flags, + const cl_egl_image_properties_khr* properties, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateFromEGLImageKHR( + context, + egldisplay, + eglimage, + flags, + properties, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + KHR_ICD_VALIDATE_POINTER_RETURN_HANDLE(KHR_ICD2_DISPATCH(context)->clCreateFromEGLImageKHR); + return KHR_ICD2_DISPATCH(context)->clCreateFromEGLImageKHR( + context, + egldisplay, + eglimage, + flags, + properties, + errcode_ret); +} +#if defined(CL_ENABLE_LAYERS) +static cl_mem CL_API_CALL clCreateFromEGLImageKHR_disp( + cl_context context, + CLeglDisplayKHR egldisplay, + CLeglImageKHR eglimage, + cl_mem_flags flags, + const cl_egl_image_properties_khr* properties, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + KHR_ICD_VALIDATE_POINTER_RETURN_HANDLE(KHR_ICD2_DISPATCH(context)->clCreateFromEGLImageKHR); + return KHR_ICD2_DISPATCH(context)->clCreateFromEGLImageKHR( + context, + egldisplay, + eglimage, + flags, + properties, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueAcquireEGLObjectsKHR( + 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) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueAcquireEGLObjectsKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(command_queue)->clEnqueueAcquireEGLObjectsKHR); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueAcquireEGLObjectsKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueAcquireEGLObjectsKHR_disp( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(command_queue)->clEnqueueAcquireEGLObjectsKHR); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueAcquireEGLObjectsKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +CL_API_ENTRY cl_int CL_API_CALL clEnqueueReleaseEGLObjectsKHR( + 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) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueReleaseEGLObjectsKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(command_queue)->clEnqueueReleaseEGLObjectsKHR); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueReleaseEGLObjectsKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueReleaseEGLObjectsKHR_disp( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(command_queue)->clEnqueueReleaseEGLObjectsKHR); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueReleaseEGLObjectsKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +// cl_khr_gl_event + +CL_API_ENTRY cl_event CL_API_CALL clCreateEventFromGLsyncKHR( + cl_context context, + cl_GLsync sync, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateEventFromGLsyncKHR( + context, + sync, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + KHR_ICD_VALIDATE_POINTER_RETURN_HANDLE(KHR_ICD2_DISPATCH(context)->clCreateEventFromGLsyncKHR); + return KHR_ICD2_DISPATCH(context)->clCreateEventFromGLsyncKHR( + context, + sync, + errcode_ret); +} +#if defined(CL_ENABLE_LAYERS) +static cl_event CL_API_CALL clCreateEventFromGLsyncKHR_disp( + cl_context context, + cl_GLsync sync, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + KHR_ICD_VALIDATE_POINTER_RETURN_HANDLE(KHR_ICD2_DISPATCH(context)->clCreateEventFromGLsyncKHR); + return KHR_ICD2_DISPATCH(context)->clCreateEventFromGLsyncKHR( + context, + sync, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +// cl_khr_gl_sharing + +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) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clGetGLContextInfoKHR( + properties, + param_name, + param_value_size, + param_value, + param_value_size_ret); +#endif // defined(CL_ENABLE_LAYERS) + cl_platform_id platform = NULL; + khrIcdContextPropertiesGetPlatform(properties, &platform); + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(platform)->clGetGLContextInfoKHR); + return KHR_ICD2_DISPATCH(platform)->clGetGLContextInfoKHR( + properties, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clGetGLContextInfoKHR_disp( + 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_platform_id platform = NULL; + khrIcdContextPropertiesGetPlatform(properties, &platform); + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(platform)->clGetGLContextInfoKHR); + return KHR_ICD2_DISPATCH(platform)->clGetGLContextInfoKHR( + properties, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +CL_API_ENTRY cl_mem CL_API_CALL clCreateFromGLBuffer( + cl_context context, + cl_mem_flags flags, + cl_GLuint bufobj, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateFromGLBuffer( + context, + flags, + bufobj, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + KHR_ICD_VALIDATE_POINTER_RETURN_HANDLE(KHR_ICD2_DISPATCH(context)->clCreateFromGLBuffer); + return KHR_ICD2_DISPATCH(context)->clCreateFromGLBuffer( + context, + flags, + bufobj, + errcode_ret); +} +#if defined(CL_ENABLE_LAYERS) +static cl_mem CL_API_CALL clCreateFromGLBuffer_disp( + cl_context context, + cl_mem_flags flags, + cl_GLuint bufobj, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + KHR_ICD_VALIDATE_POINTER_RETURN_HANDLE(KHR_ICD2_DISPATCH(context)->clCreateFromGLBuffer); + return KHR_ICD2_DISPATCH(context)->clCreateFromGLBuffer( + context, + flags, + bufobj, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +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) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateFromGLTexture( + context, + flags, + target, + miplevel, + texture, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + KHR_ICD_VALIDATE_POINTER_RETURN_HANDLE(KHR_ICD2_DISPATCH(context)->clCreateFromGLTexture); + return KHR_ICD2_DISPATCH(context)->clCreateFromGLTexture( + context, + flags, + target, + miplevel, + texture, + errcode_ret); +} +#if defined(CL_ENABLE_LAYERS) +static cl_mem CL_API_CALL clCreateFromGLTexture_disp( + cl_context context, + cl_mem_flags flags, + cl_GLenum target, + cl_GLint miplevel, + cl_GLuint texture, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + KHR_ICD_VALIDATE_POINTER_RETURN_HANDLE(KHR_ICD2_DISPATCH(context)->clCreateFromGLTexture); + return KHR_ICD2_DISPATCH(context)->clCreateFromGLTexture( + context, + flags, + target, + miplevel, + texture, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +CL_API_ENTRY cl_mem CL_API_CALL clCreateFromGLRenderbuffer( + cl_context context, + cl_mem_flags flags, + cl_GLuint renderbuffer, + cl_int* errcode_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateFromGLRenderbuffer( + context, + flags, + renderbuffer, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + KHR_ICD_VALIDATE_POINTER_RETURN_HANDLE(KHR_ICD2_DISPATCH(context)->clCreateFromGLRenderbuffer); + return KHR_ICD2_DISPATCH(context)->clCreateFromGLRenderbuffer( + context, + flags, + renderbuffer, + errcode_ret); +} +#if defined(CL_ENABLE_LAYERS) +static cl_mem CL_API_CALL clCreateFromGLRenderbuffer_disp( + cl_context context, + cl_mem_flags flags, + cl_GLuint renderbuffer, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + KHR_ICD_VALIDATE_POINTER_RETURN_HANDLE(KHR_ICD2_DISPATCH(context)->clCreateFromGLRenderbuffer); + return KHR_ICD2_DISPATCH(context)->clCreateFromGLRenderbuffer( + context, + flags, + renderbuffer, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +CL_API_ENTRY cl_int CL_API_CALL clGetGLObjectInfo( + cl_mem memobj, + cl_gl_object_type* gl_object_type, + cl_GLuint* gl_object_name) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clGetGLObjectInfo( + memobj, + gl_object_type, + gl_object_name); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(memobj)->clGetGLObjectInfo); + return KHR_ICD2_DISPATCH(memobj)->clGetGLObjectInfo( + memobj, + gl_object_type, + gl_object_name); +} +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clGetGLObjectInfo_disp( + cl_mem memobj, + cl_gl_object_type* gl_object_type, + cl_GLuint* gl_object_name) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(memobj)->clGetGLObjectInfo); + return KHR_ICD2_DISPATCH(memobj)->clGetGLObjectInfo( + memobj, + gl_object_type, + gl_object_name); +} +#endif // defined(CL_ENABLE_LAYERS) + +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) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clGetGLTextureInfo( + memobj, + param_name, + param_value_size, + param_value, + param_value_size_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(memobj)->clGetGLTextureInfo); + return KHR_ICD2_DISPATCH(memobj)->clGetGLTextureInfo( + memobj, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clGetGLTextureInfo_disp( + cl_mem memobj, + cl_gl_texture_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(memobj, CL_INVALID_MEM_OBJECT); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(memobj)->clGetGLTextureInfo); + return KHR_ICD2_DISPATCH(memobj)->clGetGLTextureInfo( + memobj, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +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) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueAcquireGLObjects( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(command_queue)->clEnqueueAcquireGLObjects); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueAcquireGLObjects( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueAcquireGLObjects_disp( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(command_queue)->clEnqueueAcquireGLObjects); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueAcquireGLObjects( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +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) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clEnqueueReleaseGLObjects( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(command_queue)->clEnqueueReleaseGLObjects); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueReleaseGLObjects( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clEnqueueReleaseGLObjects_disp( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(command_queue)->clEnqueueReleaseGLObjects); + return KHR_ICD2_DISPATCH(command_queue)->clEnqueueReleaseGLObjects( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} +#endif // defined(CL_ENABLE_LAYERS) + +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) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateFromGLTexture2D( + context, + flags, + target, + miplevel, + texture, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + KHR_ICD_VALIDATE_POINTER_RETURN_HANDLE(KHR_ICD2_DISPATCH(context)->clCreateFromGLTexture2D); + return KHR_ICD2_DISPATCH(context)->clCreateFromGLTexture2D( + context, + flags, + target, + miplevel, + texture, + errcode_ret); +} +#if defined(CL_ENABLE_LAYERS) +static cl_mem CL_API_CALL clCreateFromGLTexture2D_disp( + cl_context context, + cl_mem_flags flags, + cl_GLenum target, + cl_GLint miplevel, + cl_GLuint texture, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + KHR_ICD_VALIDATE_POINTER_RETURN_HANDLE(KHR_ICD2_DISPATCH(context)->clCreateFromGLTexture2D); + return KHR_ICD2_DISPATCH(context)->clCreateFromGLTexture2D( + context, + flags, + target, + miplevel, + texture, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +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) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clCreateFromGLTexture3D( + context, + flags, + target, + miplevel, + texture, + errcode_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + KHR_ICD_VALIDATE_POINTER_RETURN_HANDLE(KHR_ICD2_DISPATCH(context)->clCreateFromGLTexture3D); + return KHR_ICD2_DISPATCH(context)->clCreateFromGLTexture3D( + context, + flags, + target, + miplevel, + texture, + errcode_ret); +} +#if defined(CL_ENABLE_LAYERS) +static cl_mem CL_API_CALL clCreateFromGLTexture3D_disp( + cl_context context, + cl_mem_flags flags, + cl_GLenum target, + cl_GLint miplevel, + cl_GLuint texture, + cl_int* errcode_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(context, CL_INVALID_CONTEXT); + KHR_ICD_VALIDATE_POINTER_RETURN_HANDLE(KHR_ICD2_DISPATCH(context)->clCreateFromGLTexture3D); + return KHR_ICD2_DISPATCH(context)->clCreateFromGLTexture3D( + context, + flags, + target, + miplevel, + texture, + errcode_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +// cl_khr_subgroups + +CL_API_ENTRY cl_int CL_API_CALL clGetKernelSubGroupInfoKHR( + cl_kernel in_kernel, + cl_device_id in_device, + cl_kernel_sub_group_info param_name, + size_t input_value_size, + const void* input_value, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.clGetKernelSubGroupInfoKHR( + in_kernel, + in_device, + param_name, + input_value_size, + input_value, + param_value_size, + param_value, + param_value_size_ret); +#endif // defined(CL_ENABLE_LAYERS) + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(in_kernel, CL_INVALID_KERNEL); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(in_kernel)->clGetKernelSubGroupInfoKHR); + return KHR_ICD2_DISPATCH(in_kernel)->clGetKernelSubGroupInfoKHR( + in_kernel, + in_device, + param_name, + input_value_size, + input_value, + param_value_size, + param_value, + param_value_size_ret); +} +#if defined(CL_ENABLE_LAYERS) +static cl_int CL_API_CALL clGetKernelSubGroupInfoKHR_disp( + cl_kernel in_kernel, + cl_device_id in_device, + cl_kernel_sub_group_info param_name, + size_t input_value_size, + const void* input_value, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(in_kernel, CL_INVALID_KERNEL); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(in_kernel)->clGetKernelSubGroupInfoKHR); + return KHR_ICD2_DISPATCH(in_kernel)->clGetKernelSubGroupInfoKHR( + in_kernel, + in_device, + param_name, + input_value_size, + input_value, + param_value_size, + param_value, + param_value_size_ret); +} +#endif // defined(CL_ENABLE_LAYERS) + +/////////////////////////////////////////////////////////////////////////////// + +#if defined(CL_ENABLE_LAYERS) +struct _cl_icd_dispatch khrMasterDispatch = { + ICD_ANON_UNION_INIT_MEMBER(&clGetPlatformIDs_disp), + &clGetPlatformInfo_disp, + &clGetDeviceIDs_disp, + &clGetDeviceInfo_disp, + &clCreateContext_disp, + &clCreateContextFromType_disp, + &clRetainContext_disp, + &clReleaseContext_disp, + &clGetContextInfo_disp, + &clCreateCommandQueue_disp, + &clRetainCommandQueue_disp, + &clReleaseCommandQueue_disp, + &clGetCommandQueueInfo_disp, + &clSetCommandQueueProperty_disp, + &clCreateBuffer_disp, + &clCreateImage2D_disp, + &clCreateImage3D_disp, + &clRetainMemObject_disp, + &clReleaseMemObject_disp, + &clGetSupportedImageFormats_disp, + &clGetMemObjectInfo_disp, + &clGetImageInfo_disp, + &clCreateSampler_disp, + &clRetainSampler_disp, + &clReleaseSampler_disp, + &clGetSamplerInfo_disp, + &clCreateProgramWithSource_disp, + &clCreateProgramWithBinary_disp, + &clRetainProgram_disp, + &clReleaseProgram_disp, + &clBuildProgram_disp, + ICD_ANON_UNION_INIT_MEMBER(&clUnloadCompiler_disp), + &clGetProgramInfo_disp, + &clGetProgramBuildInfo_disp, + &clCreateKernel_disp, + &clCreateKernelsInProgram_disp, + &clRetainKernel_disp, + &clReleaseKernel_disp, + &clSetKernelArg_disp, + &clGetKernelInfo_disp, + &clGetKernelWorkGroupInfo_disp, + &clWaitForEvents_disp, + &clGetEventInfo_disp, + &clRetainEvent_disp, + &clReleaseEvent_disp, + &clGetEventProfilingInfo_disp, + &clFlush_disp, + &clFinish_disp, + &clEnqueueReadBuffer_disp, + &clEnqueueWriteBuffer_disp, + &clEnqueueCopyBuffer_disp, + &clEnqueueReadImage_disp, + &clEnqueueWriteImage_disp, + &clEnqueueCopyImage_disp, + &clEnqueueCopyImageToBuffer_disp, + &clEnqueueCopyBufferToImage_disp, + &clEnqueueMapBuffer_disp, + &clEnqueueMapImage_disp, + &clEnqueueUnmapMemObject_disp, + &clEnqueueNDRangeKernel_disp, + &clEnqueueTask_disp, + &clEnqueueNativeKernel_disp, + &clEnqueueMarker_disp, + &clEnqueueWaitForEvents_disp, + &clEnqueueBarrier_disp, + &clGetExtensionFunctionAddress_disp, + &clCreateFromGLBuffer_disp, + &clCreateFromGLTexture2D_disp, + &clCreateFromGLTexture3D_disp, + &clCreateFromGLRenderbuffer_disp, + &clGetGLObjectInfo_disp, + &clGetGLTextureInfo_disp, + &clEnqueueAcquireGLObjects_disp, + &clEnqueueReleaseGLObjects_disp, + &clGetGLContextInfoKHR_disp, + + /* cl_khr_d3d10_sharing */ +#if defined(_WIN32) + &clGetDeviceIDsFromD3D10KHR_disp, + &clCreateFromD3D10BufferKHR_disp, + &clCreateFromD3D10Texture2DKHR_disp, + &clCreateFromD3D10Texture3DKHR_disp, + &clEnqueueAcquireD3D10ObjectsKHR_disp, + &clEnqueueReleaseD3D10ObjectsKHR_disp, +#else + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, +#endif + + /* OpenCL 1.1 */ + &clSetEventCallback_disp, + &clCreateSubBuffer_disp, + &clSetMemObjectDestructorCallback_disp, + &clCreateUserEvent_disp, + &clSetUserEventStatus_disp, + &clEnqueueReadBufferRect_disp, + &clEnqueueWriteBufferRect_disp, + &clEnqueueCopyBufferRect_disp, + + /* cl_ext_device_fission */ + &clCreateSubDevicesEXT_disp, + &clRetainDeviceEXT_disp, + &clReleaseDeviceEXT_disp, + + /* cl_khr_gl_event */ + &clCreateEventFromGLsyncKHR_disp, + + /* OpenCL 1.2 */ + &clCreateSubDevices_disp, + &clRetainDevice_disp, + &clReleaseDevice_disp, + &clCreateImage_disp, + &clCreateProgramWithBuiltInKernels_disp, + &clCompileProgram_disp, + &clLinkProgram_disp, + &clUnloadPlatformCompiler_disp, + &clGetKernelArgInfo_disp, + &clEnqueueFillBuffer_disp, + &clEnqueueFillImage_disp, + &clEnqueueMigrateMemObjects_disp, + &clEnqueueMarkerWithWaitList_disp, + &clEnqueueBarrierWithWaitList_disp, + &clGetExtensionFunctionAddressForPlatform_disp, + &clCreateFromGLTexture_disp, + + /* cl_khr_d3d11_sharing */ +#if defined(_WIN32) + &clGetDeviceIDsFromD3D11KHR_disp, + &clCreateFromD3D11BufferKHR_disp, + &clCreateFromD3D11Texture2DKHR_disp, + &clCreateFromD3D11Texture3DKHR_disp, + &clCreateFromDX9MediaSurfaceKHR_disp, + &clEnqueueAcquireD3D11ObjectsKHR_disp, + &clEnqueueReleaseD3D11ObjectsKHR_disp, +#else + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, +#endif + + /* cl_khr_dx9_media_sharing */ +#if defined(_WIN32) + &clGetDeviceIDsFromDX9MediaAdapterKHR_disp, + &clEnqueueAcquireDX9MediaSurfacesKHR_disp, + &clEnqueueReleaseDX9MediaSurfacesKHR_disp, +#else + NULL, + NULL, + NULL, +#endif + + /* cl_khr_egl_image */ + &clCreateFromEGLImageKHR_disp, + &clEnqueueAcquireEGLObjectsKHR_disp, + &clEnqueueReleaseEGLObjectsKHR_disp, + + /* cl_khr_egl_event */ + &clCreateEventFromEGLSyncKHR_disp, + + /* OpenCL 2.0 */ + &clCreateCommandQueueWithProperties_disp, + &clCreatePipe_disp, + &clGetPipeInfo_disp, + &clSVMAlloc_disp, + &clSVMFree_disp, + &clEnqueueSVMFree_disp, + &clEnqueueSVMMemcpy_disp, + &clEnqueueSVMMemFill_disp, + &clEnqueueSVMMap_disp, + &clEnqueueSVMUnmap_disp, + &clCreateSamplerWithProperties_disp, + &clSetKernelArgSVMPointer_disp, + &clSetKernelExecInfo_disp, + + /* cl_khr_sub_groups */ + &clGetKernelSubGroupInfoKHR_disp, + + /* OpenCL 2.1 */ + &clCloneKernel_disp, + &clCreateProgramWithIL_disp, + &clEnqueueSVMMigrateMem_disp, + &clGetDeviceAndHostTimer_disp, + &clGetHostTimer_disp, + &clGetKernelSubGroupInfo_disp, + &clSetDefaultDeviceCommandQueue_disp, + + /* OpenCL 2.2 */ + &clSetProgramReleaseCallback_disp, + &clSetProgramSpecializationConstant_disp, + + /* OpenCL 3.0 */ + &clCreateBufferWithProperties_disp, + &clCreateImageWithProperties_disp, + &clSetContextDestructorCallback_disp +}; +#endif // defined(CL_ENABLE_LAYERS) + +#if defined(CL_ENABLE_LOADER_MANAGED_DISPATCH) +/////////////////////////////////////////////////////////////////////////////// +// Core APIs: +static cl_int CL_API_CALL clGetPlatformIDs_unsupp( + cl_uint num_entries, + cl_platform_id* platforms, + cl_uint* num_platforms) +{ + (void)num_entries; + (void)platforms; + (void)num_platforms; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clGetPlatformInfo_unsupp( + cl_platform_id platform, + cl_platform_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + (void)platform; + (void)param_name; + (void)param_value_size; + (void)param_value; + (void)param_value_size_ret; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clGetDeviceIDs_unsupp( + cl_platform_id platform, + cl_device_type device_type, + cl_uint num_entries, + cl_device_id* devices, + cl_uint* num_devices) +{ + (void)platform; + (void)device_type; + (void)num_entries; + (void)devices; + (void)num_devices; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clGetDeviceInfo_unsupp( + cl_device_id device, + cl_device_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + (void)device; + (void)param_name; + (void)param_value_size; + (void)param_value; + (void)param_value_size_ret; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_context CL_API_CALL clCreateContext_unsupp( + const cl_context_properties* properties, + cl_uint num_devices, + const cl_device_id* devices, + void (CL_CALLBACK* pfn_notify)(const char* errinfo, const void* private_info, size_t cb, void* user_data), + void* user_data, + cl_int* errcode_ret) +{ + (void)properties; + (void)num_devices; + (void)devices; + (void)pfn_notify; + (void)user_data; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static cl_context CL_API_CALL clCreateContextFromType_unsupp( + const cl_context_properties* properties, + cl_device_type device_type, + void (CL_CALLBACK* pfn_notify)(const char* errinfo, const void* private_info, size_t cb, void* user_data), + void* user_data, + cl_int* errcode_ret) +{ + (void)properties; + (void)device_type; + (void)pfn_notify; + (void)user_data; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clRetainContext_unsupp( + cl_context context) +{ + (void)context; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clReleaseContext_unsupp( + cl_context context) +{ + (void)context; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clGetContextInfo_unsupp( + cl_context context, + cl_context_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + (void)context; + (void)param_name; + (void)param_value_size; + (void)param_value; + (void)param_value_size_ret; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clRetainCommandQueue_unsupp( + cl_command_queue command_queue) +{ + (void)command_queue; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clReleaseCommandQueue_unsupp( + cl_command_queue command_queue) +{ + (void)command_queue; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clGetCommandQueueInfo_unsupp( + cl_command_queue command_queue, + cl_command_queue_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + (void)command_queue; + (void)param_name; + (void)param_value_size; + (void)param_value; + (void)param_value_size_ret; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_mem CL_API_CALL clCreateBuffer_unsupp( + cl_context context, + cl_mem_flags flags, + size_t size, + void* host_ptr, + cl_int* errcode_ret) +{ + (void)context; + (void)flags; + (void)size; + (void)host_ptr; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clRetainMemObject_unsupp( + cl_mem memobj) +{ + (void)memobj; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clReleaseMemObject_unsupp( + cl_mem memobj) +{ + (void)memobj; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clGetSupportedImageFormats_unsupp( + cl_context context, + cl_mem_flags flags, + cl_mem_object_type image_type, + cl_uint num_entries, + cl_image_format* image_formats, + cl_uint* num_image_formats) +{ + (void)context; + (void)flags; + (void)image_type; + (void)num_entries; + (void)image_formats; + (void)num_image_formats; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clGetMemObjectInfo_unsupp( + cl_mem memobj, + cl_mem_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + (void)memobj; + (void)param_name; + (void)param_value_size; + (void)param_value; + (void)param_value_size_ret; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clGetImageInfo_unsupp( + cl_mem image, + cl_image_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + (void)image; + (void)param_name; + (void)param_value_size; + (void)param_value; + (void)param_value_size_ret; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clRetainSampler_unsupp( + cl_sampler sampler) +{ + (void)sampler; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clReleaseSampler_unsupp( + cl_sampler sampler) +{ + (void)sampler; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clGetSamplerInfo_unsupp( + cl_sampler sampler, + cl_sampler_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + (void)sampler; + (void)param_name; + (void)param_value_size; + (void)param_value; + (void)param_value_size_ret; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_program CL_API_CALL clCreateProgramWithSource_unsupp( + cl_context context, + cl_uint count, + const char** strings, + const size_t* lengths, + cl_int* errcode_ret) +{ + (void)context; + (void)count; + (void)strings; + (void)lengths; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static cl_program CL_API_CALL clCreateProgramWithBinary_unsupp( + cl_context context, + cl_uint num_devices, + const cl_device_id* device_list, + const size_t* lengths, + const unsigned char** binaries, + cl_int* binary_status, + cl_int* errcode_ret) +{ + (void)context; + (void)num_devices; + (void)device_list; + (void)lengths; + (void)binaries; + (void)binary_status; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clRetainProgram_unsupp( + cl_program program) +{ + (void)program; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clReleaseProgram_unsupp( + cl_program program) +{ + (void)program; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clBuildProgram_unsupp( + cl_program program, + cl_uint num_devices, + const cl_device_id* device_list, + const char* options, + void (CL_CALLBACK* pfn_notify)(cl_program program, void* user_data), + void* user_data) +{ + (void)program; + (void)num_devices; + (void)device_list; + (void)options; + (void)pfn_notify; + (void)user_data; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clGetProgramInfo_unsupp( + cl_program program, + cl_program_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + (void)program; + (void)param_name; + (void)param_value_size; + (void)param_value; + (void)param_value_size_ret; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clGetProgramBuildInfo_unsupp( + cl_program program, + cl_device_id device, + cl_program_build_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + (void)program; + (void)device; + (void)param_name; + (void)param_value_size; + (void)param_value; + (void)param_value_size_ret; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_kernel CL_API_CALL clCreateKernel_unsupp( + cl_program program, + const char* kernel_name, + cl_int* errcode_ret) +{ + (void)program; + (void)kernel_name; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clCreateKernelsInProgram_unsupp( + cl_program program, + cl_uint num_kernels, + cl_kernel* kernels, + cl_uint* num_kernels_ret) +{ + (void)program; + (void)num_kernels; + (void)kernels; + (void)num_kernels_ret; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clRetainKernel_unsupp( + cl_kernel kernel) +{ + (void)kernel; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clReleaseKernel_unsupp( + cl_kernel kernel) +{ + (void)kernel; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clSetKernelArg_unsupp( + cl_kernel kernel, + cl_uint arg_index, + size_t arg_size, + const void* arg_value) +{ + (void)kernel; + (void)arg_index; + (void)arg_size; + (void)arg_value; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clGetKernelInfo_unsupp( + cl_kernel kernel, + cl_kernel_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + (void)kernel; + (void)param_name; + (void)param_value_size; + (void)param_value; + (void)param_value_size_ret; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clGetKernelWorkGroupInfo_unsupp( + cl_kernel kernel, + cl_device_id device, + cl_kernel_work_group_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + (void)kernel; + (void)device; + (void)param_name; + (void)param_value_size; + (void)param_value; + (void)param_value_size_ret; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clWaitForEvents_unsupp( + cl_uint num_events, + const cl_event* event_list) +{ + (void)num_events; + (void)event_list; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clGetEventInfo_unsupp( + cl_event event, + cl_event_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + (void)event; + (void)param_name; + (void)param_value_size; + (void)param_value; + (void)param_value_size_ret; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clRetainEvent_unsupp( + cl_event event) +{ + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clReleaseEvent_unsupp( + cl_event event) +{ + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clGetEventProfilingInfo_unsupp( + cl_event event, + cl_profiling_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + (void)event; + (void)param_name; + (void)param_value_size; + (void)param_value; + (void)param_value_size_ret; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clFlush_unsupp( + cl_command_queue command_queue) +{ + (void)command_queue; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clFinish_unsupp( + cl_command_queue command_queue) +{ + (void)command_queue; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueReadBuffer_unsupp( + cl_command_queue command_queue, + cl_mem buffer, + cl_bool blocking_read, + size_t offset, + size_t size, + void* ptr, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + (void)command_queue; + (void)buffer; + (void)blocking_read; + (void)offset; + (void)size; + (void)ptr; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueWriteBuffer_unsupp( + cl_command_queue command_queue, + cl_mem buffer, + cl_bool blocking_write, + size_t offset, + size_t size, + const void* ptr, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + (void)command_queue; + (void)buffer; + (void)blocking_write; + (void)offset; + (void)size; + (void)ptr; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueCopyBuffer_unsupp( + cl_command_queue command_queue, + cl_mem src_buffer, + cl_mem dst_buffer, + size_t src_offset, + size_t dst_offset, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + (void)command_queue; + (void)src_buffer; + (void)dst_buffer; + (void)src_offset; + (void)dst_offset; + (void)size; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueReadImage_unsupp( + cl_command_queue command_queue, + cl_mem image, + cl_bool blocking_read, + const size_t* origin, + const size_t* region, + size_t row_pitch, + size_t slice_pitch, + void* ptr, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + (void)command_queue; + (void)image; + (void)blocking_read; + (void)origin; + (void)region; + (void)row_pitch; + (void)slice_pitch; + (void)ptr; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueWriteImage_unsupp( + cl_command_queue command_queue, + cl_mem image, + cl_bool blocking_write, + const size_t* origin, + const size_t* region, + size_t input_row_pitch, + size_t input_slice_pitch, + const void* ptr, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + (void)command_queue; + (void)image; + (void)blocking_write; + (void)origin; + (void)region; + (void)input_row_pitch; + (void)input_slice_pitch; + (void)ptr; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueCopyImage_unsupp( + cl_command_queue command_queue, + cl_mem src_image, + cl_mem dst_image, + const size_t* src_origin, + const size_t* dst_origin, + const size_t* region, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + (void)command_queue; + (void)src_image; + (void)dst_image; + (void)src_origin; + (void)dst_origin; + (void)region; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueCopyImageToBuffer_unsupp( + cl_command_queue command_queue, + cl_mem src_image, + cl_mem dst_buffer, + const size_t* src_origin, + const size_t* region, + size_t dst_offset, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + (void)command_queue; + (void)src_image; + (void)dst_buffer; + (void)src_origin; + (void)region; + (void)dst_offset; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueCopyBufferToImage_unsupp( + cl_command_queue command_queue, + cl_mem src_buffer, + cl_mem dst_image, + size_t src_offset, + const size_t* dst_origin, + const size_t* region, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + (void)command_queue; + (void)src_buffer; + (void)dst_image; + (void)src_offset; + (void)dst_origin; + (void)region; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static void* CL_API_CALL clEnqueueMapBuffer_unsupp( + cl_command_queue command_queue, + cl_mem buffer, + cl_bool blocking_map, + cl_map_flags map_flags, + size_t offset, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event, + cl_int* errcode_ret) +{ + (void)command_queue; + (void)buffer; + (void)blocking_map; + (void)map_flags; + (void)offset; + (void)size; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static void* CL_API_CALL clEnqueueMapImage_unsupp( + cl_command_queue command_queue, + cl_mem image, + cl_bool blocking_map, + cl_map_flags map_flags, + const size_t* origin, + const size_t* region, + size_t* image_row_pitch, + size_t* image_slice_pitch, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event, + cl_int* errcode_ret) +{ + (void)command_queue; + (void)image; + (void)blocking_map; + (void)map_flags; + (void)origin; + (void)region; + (void)image_row_pitch; + (void)image_slice_pitch; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueUnmapMemObject_unsupp( + cl_command_queue command_queue, + cl_mem memobj, + void* mapped_ptr, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + (void)command_queue; + (void)memobj; + (void)mapped_ptr; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueNDRangeKernel_unsupp( + cl_command_queue command_queue, + cl_kernel kernel, + cl_uint work_dim, + const size_t* global_work_offset, + const size_t* global_work_size, + const size_t* local_work_size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + (void)command_queue; + (void)kernel; + (void)work_dim; + (void)global_work_offset; + (void)global_work_size; + (void)local_work_size; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueNativeKernel_unsupp( + cl_command_queue command_queue, + void (CL_CALLBACK* user_func)(void*), + void* args, + size_t cb_args, + cl_uint num_mem_objects, + const cl_mem* mem_list, + const void** args_mem_loc, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + (void)command_queue; + (void)user_func; + (void)args; + (void)cb_args; + (void)num_mem_objects; + (void)mem_list; + (void)args_mem_loc; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clSetCommandQueueProperty_unsupp( + cl_command_queue command_queue, + cl_command_queue_properties properties, + cl_bool enable, + cl_command_queue_properties* old_properties) +{ + (void)command_queue; + (void)properties; + (void)enable; + (void)old_properties; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_mem CL_API_CALL clCreateImage2D_unsupp( + cl_context context, + cl_mem_flags flags, + const cl_image_format* image_format, + size_t image_width, + size_t image_height, + size_t image_row_pitch, + void* host_ptr, + cl_int* errcode_ret) +{ + (void)context; + (void)flags; + (void)image_format; + (void)image_width; + (void)image_height; + (void)image_row_pitch; + (void)host_ptr; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static cl_mem CL_API_CALL clCreateImage3D_unsupp( + cl_context context, + cl_mem_flags flags, + const cl_image_format* image_format, + size_t image_width, + size_t image_height, + size_t image_depth, + size_t image_row_pitch, + size_t image_slice_pitch, + void* host_ptr, + cl_int* errcode_ret) +{ + (void)context; + (void)flags; + (void)image_format; + (void)image_width; + (void)image_height; + (void)image_depth; + (void)image_row_pitch; + (void)image_slice_pitch; + (void)host_ptr; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueMarker_unsupp( + cl_command_queue command_queue, + cl_event* event) +{ + (void)command_queue; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueWaitForEvents_unsupp( + cl_command_queue command_queue, + cl_uint num_events, + const cl_event* event_list) +{ + (void)command_queue; + (void)num_events; + (void)event_list; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueBarrier_unsupp( + cl_command_queue command_queue) +{ + (void)command_queue; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clUnloadCompiler_unsupp( + void ) +{ + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static void* CL_API_CALL clGetExtensionFunctionAddress_unsupp( + const char* func_name) +{ + (void)func_name; + KHR_ICD_ERROR_RETURN_ERROR(NULL); +} +static cl_command_queue CL_API_CALL clCreateCommandQueue_unsupp( + cl_context context, + cl_device_id device, + cl_command_queue_properties properties, + cl_int* errcode_ret) +{ + (void)context; + (void)device; + (void)properties; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static cl_sampler CL_API_CALL clCreateSampler_unsupp( + cl_context context, + cl_bool normalized_coords, + cl_addressing_mode addressing_mode, + cl_filter_mode filter_mode, + cl_int* errcode_ret) +{ + (void)context; + (void)normalized_coords; + (void)addressing_mode; + (void)filter_mode; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueTask_unsupp( + cl_command_queue command_queue, + cl_kernel kernel, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + (void)command_queue; + (void)kernel; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_mem CL_API_CALL clCreateSubBuffer_unsupp( + cl_mem buffer, + cl_mem_flags flags, + cl_buffer_create_type buffer_create_type, + const void* buffer_create_info, + cl_int* errcode_ret) +{ + (void)buffer; + (void)flags; + (void)buffer_create_type; + (void)buffer_create_info; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clSetMemObjectDestructorCallback_unsupp( + cl_mem memobj, + void (CL_CALLBACK* pfn_notify)(cl_mem memobj, void* user_data), + void* user_data) +{ + (void)memobj; + (void)pfn_notify; + (void)user_data; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_event CL_API_CALL clCreateUserEvent_unsupp( + cl_context context, + cl_int* errcode_ret) +{ + (void)context; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clSetUserEventStatus_unsupp( + cl_event event, + cl_int execution_status) +{ + (void)event; + (void)execution_status; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clSetEventCallback_unsupp( + cl_event event, + cl_int command_exec_callback_type, + void (CL_CALLBACK* pfn_notify)(cl_event event, cl_int event_command_status, void *user_data), + void* user_data) +{ + (void)event; + (void)command_exec_callback_type; + (void)pfn_notify; + (void)user_data; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueReadBufferRect_unsupp( + cl_command_queue command_queue, + cl_mem buffer, + cl_bool blocking_read, + const size_t* buffer_origin, + const size_t* host_origin, + const size_t* region, + size_t buffer_row_pitch, + size_t buffer_slice_pitch, + size_t host_row_pitch, + size_t host_slice_pitch, + void* ptr, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + (void)command_queue; + (void)buffer; + (void)blocking_read; + (void)buffer_origin; + (void)host_origin; + (void)region; + (void)buffer_row_pitch; + (void)buffer_slice_pitch; + (void)host_row_pitch; + (void)host_slice_pitch; + (void)ptr; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueWriteBufferRect_unsupp( + cl_command_queue command_queue, + cl_mem buffer, + cl_bool blocking_write, + const size_t* buffer_origin, + const size_t* host_origin, + const size_t* region, + size_t buffer_row_pitch, + size_t buffer_slice_pitch, + size_t host_row_pitch, + size_t host_slice_pitch, + const void* ptr, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + (void)command_queue; + (void)buffer; + (void)blocking_write; + (void)buffer_origin; + (void)host_origin; + (void)region; + (void)buffer_row_pitch; + (void)buffer_slice_pitch; + (void)host_row_pitch; + (void)host_slice_pitch; + (void)ptr; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueCopyBufferRect_unsupp( + cl_command_queue command_queue, + cl_mem src_buffer, + cl_mem dst_buffer, + const size_t* src_origin, + const size_t* dst_origin, + const size_t* region, + size_t src_row_pitch, + size_t src_slice_pitch, + size_t dst_row_pitch, + size_t dst_slice_pitch, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + (void)command_queue; + (void)src_buffer; + (void)dst_buffer; + (void)src_origin; + (void)dst_origin; + (void)region; + (void)src_row_pitch; + (void)src_slice_pitch; + (void)dst_row_pitch; + (void)dst_slice_pitch; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clCreateSubDevices_unsupp( + cl_device_id in_device, + const cl_device_partition_property* properties, + cl_uint num_devices, + cl_device_id* out_devices, + cl_uint* num_devices_ret) +{ + (void)in_device; + (void)properties; + (void)num_devices; + (void)out_devices; + (void)num_devices_ret; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clRetainDevice_unsupp( + cl_device_id device) +{ + (void)device; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clReleaseDevice_unsupp( + cl_device_id device) +{ + (void)device; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_mem CL_API_CALL clCreateImage_unsupp( + cl_context context, + cl_mem_flags flags, + const cl_image_format* image_format, + const cl_image_desc* image_desc, + void* host_ptr, + cl_int* errcode_ret) +{ + (void)context; + (void)flags; + (void)image_format; + (void)image_desc; + (void)host_ptr; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static cl_program CL_API_CALL clCreateProgramWithBuiltInKernels_unsupp( + cl_context context, + cl_uint num_devices, + const cl_device_id* device_list, + const char* kernel_names, + cl_int* errcode_ret) +{ + (void)context; + (void)num_devices; + (void)device_list; + (void)kernel_names; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clCompileProgram_unsupp( + cl_program program, + cl_uint num_devices, + const cl_device_id* device_list, + const char* options, + cl_uint num_input_headers, + const cl_program* input_headers, + const char** header_include_names, + void (CL_CALLBACK* pfn_notify)(cl_program program, void* user_data), + void* user_data) +{ + (void)program; + (void)num_devices; + (void)device_list; + (void)options; + (void)num_input_headers; + (void)input_headers; + (void)header_include_names; + (void)pfn_notify; + (void)user_data; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_program CL_API_CALL clLinkProgram_unsupp( + cl_context context, + cl_uint num_devices, + const cl_device_id* device_list, + const char* options, + cl_uint num_input_programs, + const cl_program* input_programs, + void (CL_CALLBACK* pfn_notify)(cl_program program, void* user_data), + void* user_data, + cl_int* errcode_ret) +{ + (void)context; + (void)num_devices; + (void)device_list; + (void)options; + (void)num_input_programs; + (void)input_programs; + (void)pfn_notify; + (void)user_data; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clUnloadPlatformCompiler_unsupp( + cl_platform_id platform) +{ + (void)platform; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clGetKernelArgInfo_unsupp( + cl_kernel kernel, + cl_uint arg_index, + cl_kernel_arg_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + (void)kernel; + (void)arg_index; + (void)param_name; + (void)param_value_size; + (void)param_value; + (void)param_value_size_ret; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueFillBuffer_unsupp( + cl_command_queue command_queue, + cl_mem buffer, + const void* pattern, + size_t pattern_size, + size_t offset, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + (void)command_queue; + (void)buffer; + (void)pattern; + (void)pattern_size; + (void)offset; + (void)size; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueFillImage_unsupp( + cl_command_queue command_queue, + cl_mem image, + const void* fill_color, + const size_t* origin, + const size_t* region, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + (void)command_queue; + (void)image; + (void)fill_color; + (void)origin; + (void)region; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueMigrateMemObjects_unsupp( + cl_command_queue command_queue, + cl_uint num_mem_objects, + const cl_mem* mem_objects, + cl_mem_migration_flags flags, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + (void)command_queue; + (void)num_mem_objects; + (void)mem_objects; + (void)flags; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueMarkerWithWaitList_unsupp( + cl_command_queue command_queue, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + (void)command_queue; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueBarrierWithWaitList_unsupp( + cl_command_queue command_queue, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + (void)command_queue; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static void* CL_API_CALL clGetExtensionFunctionAddressForPlatform_unsupp( + cl_platform_id platform, + const char* func_name) +{ + (void)platform; + (void)func_name; + KHR_ICD_ERROR_RETURN_ERROR(NULL); +} +static cl_command_queue CL_API_CALL clCreateCommandQueueWithProperties_unsupp( + cl_context context, + cl_device_id device, + const cl_queue_properties* properties, + cl_int* errcode_ret) +{ + (void)context; + (void)device; + (void)properties; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static cl_mem CL_API_CALL clCreatePipe_unsupp( + cl_context context, + cl_mem_flags flags, + cl_uint pipe_packet_size, + cl_uint pipe_max_packets, + const cl_pipe_properties* properties, + cl_int* errcode_ret) +{ + (void)context; + (void)flags; + (void)pipe_packet_size; + (void)pipe_max_packets; + (void)properties; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clGetPipeInfo_unsupp( + cl_mem pipe, + cl_pipe_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + (void)pipe; + (void)param_name; + (void)param_value_size; + (void)param_value; + (void)param_value_size_ret; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static void* CL_API_CALL clSVMAlloc_unsupp( + cl_context context, + cl_svm_mem_flags flags, + size_t size, + cl_uint alignment) +{ + (void)context; + (void)flags; + (void)size; + (void)alignment; + KHR_ICD_ERROR_RETURN_ERROR(NULL); +} +static void CL_API_CALL clSVMFree_unsupp( + cl_context context, + void* svm_pointer) +{ + (void)context; + (void)svm_pointer; + return; +} +static cl_sampler CL_API_CALL clCreateSamplerWithProperties_unsupp( + cl_context context, + const cl_sampler_properties* sampler_properties, + cl_int* errcode_ret) +{ + (void)context; + (void)sampler_properties; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clSetKernelArgSVMPointer_unsupp( + cl_kernel kernel, + cl_uint arg_index, + const void* arg_value) +{ + (void)kernel; + (void)arg_index; + (void)arg_value; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clSetKernelExecInfo_unsupp( + cl_kernel kernel, + cl_kernel_exec_info param_name, + size_t param_value_size, + const void* param_value) +{ + (void)kernel; + (void)param_name; + (void)param_value_size; + (void)param_value; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueSVMFree_unsupp( + cl_command_queue command_queue, + cl_uint num_svm_pointers, + void* svm_pointers[], + void (CL_CALLBACK* pfn_free_func)(cl_command_queue queue, cl_uint num_svm_pointers, void* svm_pointers[], void* user_data), + void* user_data, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + (void)command_queue; + (void)num_svm_pointers; + (void)svm_pointers; + (void)pfn_free_func; + (void)user_data; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueSVMMemcpy_unsupp( + cl_command_queue command_queue, + cl_bool blocking_copy, + void* dst_ptr, + const void* src_ptr, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + (void)command_queue; + (void)blocking_copy; + (void)dst_ptr; + (void)src_ptr; + (void)size; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueSVMMemFill_unsupp( + cl_command_queue command_queue, + void* svm_ptr, + const void* pattern, + size_t pattern_size, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + (void)command_queue; + (void)svm_ptr; + (void)pattern; + (void)pattern_size; + (void)size; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueSVMMap_unsupp( + cl_command_queue command_queue, + cl_bool blocking_map, + cl_map_flags flags, + void* svm_ptr, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + (void)command_queue; + (void)blocking_map; + (void)flags; + (void)svm_ptr; + (void)size; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueSVMUnmap_unsupp( + cl_command_queue command_queue, + void* svm_ptr, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + (void)command_queue; + (void)svm_ptr; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clSetDefaultDeviceCommandQueue_unsupp( + cl_context context, + cl_device_id device, + cl_command_queue command_queue) +{ + (void)context; + (void)device; + (void)command_queue; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clGetDeviceAndHostTimer_unsupp( + cl_device_id device, + cl_ulong* device_timestamp, + cl_ulong* host_timestamp) +{ + (void)device; + (void)device_timestamp; + (void)host_timestamp; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clGetHostTimer_unsupp( + cl_device_id device, + cl_ulong* host_timestamp) +{ + (void)device; + (void)host_timestamp; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_program CL_API_CALL clCreateProgramWithIL_unsupp( + cl_context context, + const void* il, + size_t length, + cl_int* errcode_ret) +{ + (void)context; + (void)il; + (void)length; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static cl_kernel CL_API_CALL clCloneKernel_unsupp( + cl_kernel source_kernel, + cl_int* errcode_ret) +{ + (void)source_kernel; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clGetKernelSubGroupInfo_unsupp( + cl_kernel kernel, + cl_device_id device, + cl_kernel_sub_group_info param_name, + size_t input_value_size, + const void* input_value, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + (void)kernel; + (void)device; + (void)param_name; + (void)input_value_size; + (void)input_value; + (void)param_value_size; + (void)param_value; + (void)param_value_size_ret; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueSVMMigrateMem_unsupp( + cl_command_queue command_queue, + cl_uint num_svm_pointers, + const void** svm_pointers, + const size_t* sizes, + cl_mem_migration_flags flags, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) +{ + (void)command_queue; + (void)num_svm_pointers; + (void)svm_pointers; + (void)sizes; + (void)flags; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clSetProgramSpecializationConstant_unsupp( + cl_program program, + cl_uint spec_id, + size_t spec_size, + const void* spec_value) +{ + (void)program; + (void)spec_id; + (void)spec_size; + (void)spec_value; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clSetProgramReleaseCallback_unsupp( + cl_program program, + void (CL_CALLBACK* pfn_notify)(cl_program program, void* user_data), + void* user_data) +{ + (void)program; + (void)pfn_notify; + (void)user_data; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clSetContextDestructorCallback_unsupp( + cl_context context, + void (CL_CALLBACK* pfn_notify)(cl_context context, void* user_data), + void* user_data) +{ + (void)context; + (void)pfn_notify; + (void)user_data; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_mem CL_API_CALL clCreateBufferWithProperties_unsupp( + cl_context context, + const cl_mem_properties* properties, + cl_mem_flags flags, + size_t size, + void* host_ptr, + cl_int* errcode_ret) +{ + (void)context; + (void)properties; + (void)flags; + (void)size; + (void)host_ptr; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static cl_mem CL_API_CALL clCreateImageWithProperties_unsupp( + cl_context context, + const cl_mem_properties* properties, + cl_mem_flags flags, + const cl_image_format* image_format, + const cl_image_desc* image_desc, + void* host_ptr, + cl_int* errcode_ret) +{ + (void)context; + (void)properties; + (void)flags; + (void)image_format; + (void)image_desc; + (void)host_ptr; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} + +/////////////////////////////////////////////////////////////////////////////// +// cl_ext_device_fission +static cl_int CL_API_CALL clReleaseDeviceEXT_unsupp( + cl_device_id device) +{ + (void)device; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clRetainDeviceEXT_unsupp( + cl_device_id device) +{ + (void)device; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clCreateSubDevicesEXT_unsupp( + cl_device_id in_device, + const cl_device_partition_property_ext* properties, + cl_uint num_entries, + cl_device_id* out_devices, + cl_uint* num_devices) +{ + (void)in_device; + (void)properties; + (void)num_entries; + (void)out_devices; + (void)num_devices; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +/////////////////////////////////////////////////////////////////////////////// + +// cl_khr_d3d10_sharing + +#if defined(_WIN32) +static cl_int CL_API_CALL clGetDeviceIDsFromD3D10KHR_unsupp( + cl_platform_id platform, + cl_d3d10_device_source_khr d3d_device_source, + void* d3d_object, + cl_d3d10_device_set_khr d3d_device_set, + cl_uint num_entries, + cl_device_id* devices, + cl_uint* num_devices) +{ + (void)platform; + (void)d3d_device_source; + (void)d3d_object; + (void)d3d_device_set; + (void)num_entries; + (void)devices; + (void)num_devices; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_mem CL_API_CALL clCreateFromD3D10BufferKHR_unsupp( + cl_context context, + cl_mem_flags flags, + ID3D10Buffer* resource, + cl_int* errcode_ret) +{ + (void)context; + (void)flags; + (void)resource; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static cl_mem CL_API_CALL clCreateFromD3D10Texture2DKHR_unsupp( + cl_context context, + cl_mem_flags flags, + ID3D10Texture2D* resource, + UINT subresource, + cl_int* errcode_ret) +{ + (void)context; + (void)flags; + (void)resource; + (void)subresource; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static cl_mem CL_API_CALL clCreateFromD3D10Texture3DKHR_unsupp( + cl_context context, + cl_mem_flags flags, + ID3D10Texture3D* resource, + UINT subresource, + cl_int* errcode_ret) +{ + (void)context; + (void)flags; + (void)resource; + (void)subresource; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueAcquireD3D10ObjectsKHR_unsupp( + 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) +{ + (void)command_queue; + (void)num_objects; + (void)mem_objects; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueReleaseD3D10ObjectsKHR_unsupp( + 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) +{ + (void)command_queue; + (void)num_objects; + (void)mem_objects; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +#endif // defined(_WIN32) + +/////////////////////////////////////////////////////////////////////////////// + +// cl_khr_d3d11_sharing + +#if defined(_WIN32) +static cl_int CL_API_CALL clGetDeviceIDsFromD3D11KHR_unsupp( + cl_platform_id platform, + cl_d3d11_device_source_khr d3d_device_source, + void* d3d_object, + cl_d3d11_device_set_khr d3d_device_set, + cl_uint num_entries, + cl_device_id* devices, + cl_uint* num_devices) +{ + (void)platform; + (void)d3d_device_source; + (void)d3d_object; + (void)d3d_device_set; + (void)num_entries; + (void)devices; + (void)num_devices; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_mem CL_API_CALL clCreateFromD3D11BufferKHR_unsupp( + cl_context context, + cl_mem_flags flags, + ID3D11Buffer* resource, + cl_int* errcode_ret) +{ + (void)context; + (void)flags; + (void)resource; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static cl_mem CL_API_CALL clCreateFromD3D11Texture2DKHR_unsupp( + cl_context context, + cl_mem_flags flags, + ID3D11Texture2D* resource, + UINT subresource, + cl_int* errcode_ret) +{ + (void)context; + (void)flags; + (void)resource; + (void)subresource; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static cl_mem CL_API_CALL clCreateFromD3D11Texture3DKHR_unsupp( + cl_context context, + cl_mem_flags flags, + ID3D11Texture3D* resource, + UINT subresource, + cl_int* errcode_ret) +{ + (void)context; + (void)flags; + (void)resource; + (void)subresource; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueAcquireD3D11ObjectsKHR_unsupp( + 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) +{ + (void)command_queue; + (void)num_objects; + (void)mem_objects; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueReleaseD3D11ObjectsKHR_unsupp( + 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) +{ + (void)command_queue; + (void)num_objects; + (void)mem_objects; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +#endif // defined(_WIN32) + +/////////////////////////////////////////////////////////////////////////////// + +// cl_khr_dx9_media_sharing + +#if defined(_WIN32) +static cl_int CL_API_CALL clGetDeviceIDsFromDX9MediaAdapterKHR_unsupp( + cl_platform_id platform, + cl_uint num_media_adapters, + cl_dx9_media_adapter_type_khr* media_adapter_type, + void* media_adapters, + cl_dx9_media_adapter_set_khr media_adapter_set, + cl_uint num_entries, + cl_device_id* devices, + cl_uint* num_devices) +{ + (void)platform; + (void)num_media_adapters; + (void)media_adapter_type; + (void)media_adapters; + (void)media_adapter_set; + (void)num_entries; + (void)devices; + (void)num_devices; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_mem CL_API_CALL clCreateFromDX9MediaSurfaceKHR_unsupp( + cl_context context, + cl_mem_flags flags, + cl_dx9_media_adapter_type_khr adapter_type, + void* surface_info, + cl_uint plane, + cl_int* errcode_ret) +{ + (void)context; + (void)flags; + (void)adapter_type; + (void)surface_info; + (void)plane; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueAcquireDX9MediaSurfacesKHR_unsupp( + 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) +{ + (void)command_queue; + (void)num_objects; + (void)mem_objects; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueReleaseDX9MediaSurfacesKHR_unsupp( + 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) +{ + (void)command_queue; + (void)num_objects; + (void)mem_objects; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +#endif // defined(_WIN32) + +/////////////////////////////////////////////////////////////////////////////// + +// cl_khr_egl_event +static cl_event CL_API_CALL clCreateEventFromEGLSyncKHR_unsupp( + cl_context context, + CLeglSyncKHR sync, + CLeglDisplayKHR display, + cl_int* errcode_ret) +{ + (void)context; + (void)sync; + (void)display; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +/////////////////////////////////////////////////////////////////////////////// + +// cl_khr_egl_image +static cl_mem CL_API_CALL clCreateFromEGLImageKHR_unsupp( + cl_context context, + CLeglDisplayKHR egldisplay, + CLeglImageKHR eglimage, + cl_mem_flags flags, + const cl_egl_image_properties_khr* properties, + cl_int* errcode_ret) +{ + (void)context; + (void)egldisplay; + (void)eglimage; + (void)flags; + (void)properties; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueAcquireEGLObjectsKHR_unsupp( + 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) +{ + (void)command_queue; + (void)num_objects; + (void)mem_objects; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueReleaseEGLObjectsKHR_unsupp( + 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) +{ + (void)command_queue; + (void)num_objects; + (void)mem_objects; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +/////////////////////////////////////////////////////////////////////////////// + +// cl_khr_gl_event +static cl_event CL_API_CALL clCreateEventFromGLsyncKHR_unsupp( + cl_context context, + cl_GLsync sync, + cl_int* errcode_ret) +{ + (void)context; + (void)sync; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +/////////////////////////////////////////////////////////////////////////////// + +// cl_khr_gl_sharing +static cl_int CL_API_CALL clGetGLContextInfoKHR_unsupp( + 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) +{ + (void)properties; + (void)param_name; + (void)param_value_size; + (void)param_value; + (void)param_value_size_ret; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_mem CL_API_CALL clCreateFromGLBuffer_unsupp( + cl_context context, + cl_mem_flags flags, + cl_GLuint bufobj, + cl_int* errcode_ret) +{ + (void)context; + (void)flags; + (void)bufobj; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static cl_mem CL_API_CALL clCreateFromGLTexture_unsupp( + cl_context context, + cl_mem_flags flags, + cl_GLenum target, + cl_GLint miplevel, + cl_GLuint texture, + cl_int* errcode_ret) +{ + (void)context; + (void)flags; + (void)target; + (void)miplevel; + (void)texture; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static cl_mem CL_API_CALL clCreateFromGLRenderbuffer_unsupp( + cl_context context, + cl_mem_flags flags, + cl_GLuint renderbuffer, + cl_int* errcode_ret) +{ + (void)context; + (void)flags; + (void)renderbuffer; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clGetGLObjectInfo_unsupp( + cl_mem memobj, + cl_gl_object_type* gl_object_type, + cl_GLuint* gl_object_name) +{ + (void)memobj; + (void)gl_object_type; + (void)gl_object_name; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clGetGLTextureInfo_unsupp( + cl_mem memobj, + cl_gl_texture_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + (void)memobj; + (void)param_name; + (void)param_value_size; + (void)param_value; + (void)param_value_size_ret; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueAcquireGLObjects_unsupp( + 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) +{ + (void)command_queue; + (void)num_objects; + (void)mem_objects; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_int CL_API_CALL clEnqueueReleaseGLObjects_unsupp( + 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) +{ + (void)command_queue; + (void)num_objects; + (void)mem_objects; + (void)num_events_in_wait_list; + (void)event_wait_list; + (void)event; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +static cl_mem CL_API_CALL clCreateFromGLTexture2D_unsupp( + cl_context context, + cl_mem_flags flags, + cl_GLenum target, + cl_GLint miplevel, + cl_GLuint texture, + cl_int* errcode_ret) +{ + (void)context; + (void)flags; + (void)target; + (void)miplevel; + (void)texture; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +static cl_mem CL_API_CALL clCreateFromGLTexture3D_unsupp( + cl_context context, + cl_mem_flags flags, + cl_GLenum target, + cl_GLint miplevel, + cl_GLuint texture, + cl_int* errcode_ret) +{ + (void)context; + (void)flags; + (void)target; + (void)miplevel; + (void)texture; + (void)errcode_ret; + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +} +/////////////////////////////////////////////////////////////////////////////// + +// cl_khr_subgroups +static cl_int CL_API_CALL clGetKernelSubGroupInfoKHR_unsupp( + cl_kernel in_kernel, + cl_device_id in_device, + cl_kernel_sub_group_info param_name, + size_t input_value_size, + const void* input_value, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + (void)in_kernel; + (void)in_device; + (void)param_name; + (void)input_value_size; + (void)input_value; + (void)param_value_size; + (void)param_value; + (void)param_value_size_ret; + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +} +/////////////////////////////////////////////////////////////////////////////// + + +void khrIcd2PopulateDispatchTable( + cl_platform_id platform, + clIcdGetFunctionAddressForPlatformKHR_fn p_clIcdGetFunctionAddressForPlatform, + struct _cl_icd_dispatch* dispatch) +{ +/////////////////////////////////////////////////////////////////////////////// +// Core APIs: + dispatch->clGetPlatformIDs = (clGetPlatformIDs_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clGetPlatformIDs"); + if (!dispatch->clGetPlatformIDs) + dispatch->clGetPlatformIDs = &clGetPlatformIDs_unsupp; + dispatch->clGetPlatformInfo = (clGetPlatformInfo_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clGetPlatformInfo"); + if (!dispatch->clGetPlatformInfo) + dispatch->clGetPlatformInfo = &clGetPlatformInfo_unsupp; + dispatch->clGetDeviceIDs = (clGetDeviceIDs_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clGetDeviceIDs"); + if (!dispatch->clGetDeviceIDs) + dispatch->clGetDeviceIDs = &clGetDeviceIDs_unsupp; + dispatch->clGetDeviceInfo = (clGetDeviceInfo_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clGetDeviceInfo"); + if (!dispatch->clGetDeviceInfo) + dispatch->clGetDeviceInfo = &clGetDeviceInfo_unsupp; + dispatch->clCreateContext = (clCreateContext_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateContext"); + if (!dispatch->clCreateContext) + dispatch->clCreateContext = &clCreateContext_unsupp; + dispatch->clCreateContextFromType = (clCreateContextFromType_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateContextFromType"); + if (!dispatch->clCreateContextFromType) + dispatch->clCreateContextFromType = &clCreateContextFromType_unsupp; + dispatch->clRetainContext = (clRetainContext_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clRetainContext"); + if (!dispatch->clRetainContext) + dispatch->clRetainContext = &clRetainContext_unsupp; + dispatch->clReleaseContext = (clReleaseContext_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clReleaseContext"); + if (!dispatch->clReleaseContext) + dispatch->clReleaseContext = &clReleaseContext_unsupp; + dispatch->clGetContextInfo = (clGetContextInfo_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clGetContextInfo"); + if (!dispatch->clGetContextInfo) + dispatch->clGetContextInfo = &clGetContextInfo_unsupp; + dispatch->clRetainCommandQueue = (clRetainCommandQueue_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clRetainCommandQueue"); + if (!dispatch->clRetainCommandQueue) + dispatch->clRetainCommandQueue = &clRetainCommandQueue_unsupp; + dispatch->clReleaseCommandQueue = (clReleaseCommandQueue_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clReleaseCommandQueue"); + if (!dispatch->clReleaseCommandQueue) + dispatch->clReleaseCommandQueue = &clReleaseCommandQueue_unsupp; + dispatch->clGetCommandQueueInfo = (clGetCommandQueueInfo_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clGetCommandQueueInfo"); + if (!dispatch->clGetCommandQueueInfo) + dispatch->clGetCommandQueueInfo = &clGetCommandQueueInfo_unsupp; + dispatch->clCreateBuffer = (clCreateBuffer_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateBuffer"); + if (!dispatch->clCreateBuffer) + dispatch->clCreateBuffer = &clCreateBuffer_unsupp; + dispatch->clRetainMemObject = (clRetainMemObject_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clRetainMemObject"); + if (!dispatch->clRetainMemObject) + dispatch->clRetainMemObject = &clRetainMemObject_unsupp; + dispatch->clReleaseMemObject = (clReleaseMemObject_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clReleaseMemObject"); + if (!dispatch->clReleaseMemObject) + dispatch->clReleaseMemObject = &clReleaseMemObject_unsupp; + dispatch->clGetSupportedImageFormats = (clGetSupportedImageFormats_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clGetSupportedImageFormats"); + if (!dispatch->clGetSupportedImageFormats) + dispatch->clGetSupportedImageFormats = &clGetSupportedImageFormats_unsupp; + dispatch->clGetMemObjectInfo = (clGetMemObjectInfo_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clGetMemObjectInfo"); + if (!dispatch->clGetMemObjectInfo) + dispatch->clGetMemObjectInfo = &clGetMemObjectInfo_unsupp; + dispatch->clGetImageInfo = (clGetImageInfo_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clGetImageInfo"); + if (!dispatch->clGetImageInfo) + dispatch->clGetImageInfo = &clGetImageInfo_unsupp; + dispatch->clRetainSampler = (clRetainSampler_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clRetainSampler"); + if (!dispatch->clRetainSampler) + dispatch->clRetainSampler = &clRetainSampler_unsupp; + dispatch->clReleaseSampler = (clReleaseSampler_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clReleaseSampler"); + if (!dispatch->clReleaseSampler) + dispatch->clReleaseSampler = &clReleaseSampler_unsupp; + dispatch->clGetSamplerInfo = (clGetSamplerInfo_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clGetSamplerInfo"); + if (!dispatch->clGetSamplerInfo) + dispatch->clGetSamplerInfo = &clGetSamplerInfo_unsupp; + dispatch->clCreateProgramWithSource = (clCreateProgramWithSource_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateProgramWithSource"); + if (!dispatch->clCreateProgramWithSource) + dispatch->clCreateProgramWithSource = &clCreateProgramWithSource_unsupp; + dispatch->clCreateProgramWithBinary = (clCreateProgramWithBinary_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateProgramWithBinary"); + if (!dispatch->clCreateProgramWithBinary) + dispatch->clCreateProgramWithBinary = &clCreateProgramWithBinary_unsupp; + dispatch->clRetainProgram = (clRetainProgram_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clRetainProgram"); + if (!dispatch->clRetainProgram) + dispatch->clRetainProgram = &clRetainProgram_unsupp; + dispatch->clReleaseProgram = (clReleaseProgram_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clReleaseProgram"); + if (!dispatch->clReleaseProgram) + dispatch->clReleaseProgram = &clReleaseProgram_unsupp; + dispatch->clBuildProgram = (clBuildProgram_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clBuildProgram"); + if (!dispatch->clBuildProgram) + dispatch->clBuildProgram = &clBuildProgram_unsupp; + dispatch->clGetProgramInfo = (clGetProgramInfo_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clGetProgramInfo"); + if (!dispatch->clGetProgramInfo) + dispatch->clGetProgramInfo = &clGetProgramInfo_unsupp; + dispatch->clGetProgramBuildInfo = (clGetProgramBuildInfo_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clGetProgramBuildInfo"); + if (!dispatch->clGetProgramBuildInfo) + dispatch->clGetProgramBuildInfo = &clGetProgramBuildInfo_unsupp; + dispatch->clCreateKernel = (clCreateKernel_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateKernel"); + if (!dispatch->clCreateKernel) + dispatch->clCreateKernel = &clCreateKernel_unsupp; + dispatch->clCreateKernelsInProgram = (clCreateKernelsInProgram_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateKernelsInProgram"); + if (!dispatch->clCreateKernelsInProgram) + dispatch->clCreateKernelsInProgram = &clCreateKernelsInProgram_unsupp; + dispatch->clRetainKernel = (clRetainKernel_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clRetainKernel"); + if (!dispatch->clRetainKernel) + dispatch->clRetainKernel = &clRetainKernel_unsupp; + dispatch->clReleaseKernel = (clReleaseKernel_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clReleaseKernel"); + if (!dispatch->clReleaseKernel) + dispatch->clReleaseKernel = &clReleaseKernel_unsupp; + dispatch->clSetKernelArg = (clSetKernelArg_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clSetKernelArg"); + if (!dispatch->clSetKernelArg) + dispatch->clSetKernelArg = &clSetKernelArg_unsupp; + dispatch->clGetKernelInfo = (clGetKernelInfo_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clGetKernelInfo"); + if (!dispatch->clGetKernelInfo) + dispatch->clGetKernelInfo = &clGetKernelInfo_unsupp; + dispatch->clGetKernelWorkGroupInfo = (clGetKernelWorkGroupInfo_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clGetKernelWorkGroupInfo"); + if (!dispatch->clGetKernelWorkGroupInfo) + dispatch->clGetKernelWorkGroupInfo = &clGetKernelWorkGroupInfo_unsupp; + dispatch->clWaitForEvents = (clWaitForEvents_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clWaitForEvents"); + if (!dispatch->clWaitForEvents) + dispatch->clWaitForEvents = &clWaitForEvents_unsupp; + dispatch->clGetEventInfo = (clGetEventInfo_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clGetEventInfo"); + if (!dispatch->clGetEventInfo) + dispatch->clGetEventInfo = &clGetEventInfo_unsupp; + dispatch->clRetainEvent = (clRetainEvent_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clRetainEvent"); + if (!dispatch->clRetainEvent) + dispatch->clRetainEvent = &clRetainEvent_unsupp; + dispatch->clReleaseEvent = (clReleaseEvent_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clReleaseEvent"); + if (!dispatch->clReleaseEvent) + dispatch->clReleaseEvent = &clReleaseEvent_unsupp; + dispatch->clGetEventProfilingInfo = (clGetEventProfilingInfo_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clGetEventProfilingInfo"); + if (!dispatch->clGetEventProfilingInfo) + dispatch->clGetEventProfilingInfo = &clGetEventProfilingInfo_unsupp; + dispatch->clFlush = (clFlush_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clFlush"); + if (!dispatch->clFlush) + dispatch->clFlush = &clFlush_unsupp; + dispatch->clFinish = (clFinish_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clFinish"); + if (!dispatch->clFinish) + dispatch->clFinish = &clFinish_unsupp; + dispatch->clEnqueueReadBuffer = (clEnqueueReadBuffer_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueReadBuffer"); + if (!dispatch->clEnqueueReadBuffer) + dispatch->clEnqueueReadBuffer = &clEnqueueReadBuffer_unsupp; + dispatch->clEnqueueWriteBuffer = (clEnqueueWriteBuffer_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueWriteBuffer"); + if (!dispatch->clEnqueueWriteBuffer) + dispatch->clEnqueueWriteBuffer = &clEnqueueWriteBuffer_unsupp; + dispatch->clEnqueueCopyBuffer = (clEnqueueCopyBuffer_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueCopyBuffer"); + if (!dispatch->clEnqueueCopyBuffer) + dispatch->clEnqueueCopyBuffer = &clEnqueueCopyBuffer_unsupp; + dispatch->clEnqueueReadImage = (clEnqueueReadImage_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueReadImage"); + if (!dispatch->clEnqueueReadImage) + dispatch->clEnqueueReadImage = &clEnqueueReadImage_unsupp; + dispatch->clEnqueueWriteImage = (clEnqueueWriteImage_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueWriteImage"); + if (!dispatch->clEnqueueWriteImage) + dispatch->clEnqueueWriteImage = &clEnqueueWriteImage_unsupp; + dispatch->clEnqueueCopyImage = (clEnqueueCopyImage_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueCopyImage"); + if (!dispatch->clEnqueueCopyImage) + dispatch->clEnqueueCopyImage = &clEnqueueCopyImage_unsupp; + dispatch->clEnqueueCopyImageToBuffer = (clEnqueueCopyImageToBuffer_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueCopyImageToBuffer"); + if (!dispatch->clEnqueueCopyImageToBuffer) + dispatch->clEnqueueCopyImageToBuffer = &clEnqueueCopyImageToBuffer_unsupp; + dispatch->clEnqueueCopyBufferToImage = (clEnqueueCopyBufferToImage_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueCopyBufferToImage"); + if (!dispatch->clEnqueueCopyBufferToImage) + dispatch->clEnqueueCopyBufferToImage = &clEnqueueCopyBufferToImage_unsupp; + dispatch->clEnqueueMapBuffer = (clEnqueueMapBuffer_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueMapBuffer"); + if (!dispatch->clEnqueueMapBuffer) + dispatch->clEnqueueMapBuffer = &clEnqueueMapBuffer_unsupp; + dispatch->clEnqueueMapImage = (clEnqueueMapImage_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueMapImage"); + if (!dispatch->clEnqueueMapImage) + dispatch->clEnqueueMapImage = &clEnqueueMapImage_unsupp; + dispatch->clEnqueueUnmapMemObject = (clEnqueueUnmapMemObject_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueUnmapMemObject"); + if (!dispatch->clEnqueueUnmapMemObject) + dispatch->clEnqueueUnmapMemObject = &clEnqueueUnmapMemObject_unsupp; + dispatch->clEnqueueNDRangeKernel = (clEnqueueNDRangeKernel_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueNDRangeKernel"); + if (!dispatch->clEnqueueNDRangeKernel) + dispatch->clEnqueueNDRangeKernel = &clEnqueueNDRangeKernel_unsupp; + dispatch->clEnqueueNativeKernel = (clEnqueueNativeKernel_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueNativeKernel"); + if (!dispatch->clEnqueueNativeKernel) + dispatch->clEnqueueNativeKernel = &clEnqueueNativeKernel_unsupp; + dispatch->clSetCommandQueueProperty = (clSetCommandQueueProperty_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clSetCommandQueueProperty"); + if (!dispatch->clSetCommandQueueProperty) + dispatch->clSetCommandQueueProperty = &clSetCommandQueueProperty_unsupp; + dispatch->clCreateImage2D = (clCreateImage2D_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateImage2D"); + if (!dispatch->clCreateImage2D) + dispatch->clCreateImage2D = &clCreateImage2D_unsupp; + dispatch->clCreateImage3D = (clCreateImage3D_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateImage3D"); + if (!dispatch->clCreateImage3D) + dispatch->clCreateImage3D = &clCreateImage3D_unsupp; + dispatch->clEnqueueMarker = (clEnqueueMarker_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueMarker"); + if (!dispatch->clEnqueueMarker) + dispatch->clEnqueueMarker = &clEnqueueMarker_unsupp; + dispatch->clEnqueueWaitForEvents = (clEnqueueWaitForEvents_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueWaitForEvents"); + if (!dispatch->clEnqueueWaitForEvents) + dispatch->clEnqueueWaitForEvents = &clEnqueueWaitForEvents_unsupp; + dispatch->clEnqueueBarrier = (clEnqueueBarrier_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueBarrier"); + if (!dispatch->clEnqueueBarrier) + dispatch->clEnqueueBarrier = &clEnqueueBarrier_unsupp; + dispatch->clUnloadCompiler = (clUnloadCompiler_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clUnloadCompiler"); + if (!dispatch->clUnloadCompiler) + dispatch->clUnloadCompiler = &clUnloadCompiler_unsupp; + dispatch->clGetExtensionFunctionAddress = (clGetExtensionFunctionAddress_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clGetExtensionFunctionAddress"); + if (!dispatch->clGetExtensionFunctionAddress) + dispatch->clGetExtensionFunctionAddress = &clGetExtensionFunctionAddress_unsupp; + dispatch->clCreateCommandQueue = (clCreateCommandQueue_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateCommandQueue"); + if (!dispatch->clCreateCommandQueue) + dispatch->clCreateCommandQueue = &clCreateCommandQueue_unsupp; + dispatch->clCreateSampler = (clCreateSampler_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateSampler"); + if (!dispatch->clCreateSampler) + dispatch->clCreateSampler = &clCreateSampler_unsupp; + dispatch->clEnqueueTask = (clEnqueueTask_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueTask"); + if (!dispatch->clEnqueueTask) + dispatch->clEnqueueTask = &clEnqueueTask_unsupp; + dispatch->clCreateSubBuffer = (clCreateSubBuffer_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateSubBuffer"); + if (!dispatch->clCreateSubBuffer) + dispatch->clCreateSubBuffer = &clCreateSubBuffer_unsupp; + dispatch->clSetMemObjectDestructorCallback = (clSetMemObjectDestructorCallback_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clSetMemObjectDestructorCallback"); + if (!dispatch->clSetMemObjectDestructorCallback) + dispatch->clSetMemObjectDestructorCallback = &clSetMemObjectDestructorCallback_unsupp; + dispatch->clCreateUserEvent = (clCreateUserEvent_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateUserEvent"); + if (!dispatch->clCreateUserEvent) + dispatch->clCreateUserEvent = &clCreateUserEvent_unsupp; + dispatch->clSetUserEventStatus = (clSetUserEventStatus_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clSetUserEventStatus"); + if (!dispatch->clSetUserEventStatus) + dispatch->clSetUserEventStatus = &clSetUserEventStatus_unsupp; + dispatch->clSetEventCallback = (clSetEventCallback_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clSetEventCallback"); + if (!dispatch->clSetEventCallback) + dispatch->clSetEventCallback = &clSetEventCallback_unsupp; + dispatch->clEnqueueReadBufferRect = (clEnqueueReadBufferRect_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueReadBufferRect"); + if (!dispatch->clEnqueueReadBufferRect) + dispatch->clEnqueueReadBufferRect = &clEnqueueReadBufferRect_unsupp; + dispatch->clEnqueueWriteBufferRect = (clEnqueueWriteBufferRect_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueWriteBufferRect"); + if (!dispatch->clEnqueueWriteBufferRect) + dispatch->clEnqueueWriteBufferRect = &clEnqueueWriteBufferRect_unsupp; + dispatch->clEnqueueCopyBufferRect = (clEnqueueCopyBufferRect_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueCopyBufferRect"); + if (!dispatch->clEnqueueCopyBufferRect) + dispatch->clEnqueueCopyBufferRect = &clEnqueueCopyBufferRect_unsupp; + dispatch->clCreateSubDevices = (clCreateSubDevices_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateSubDevices"); + if (!dispatch->clCreateSubDevices) + dispatch->clCreateSubDevices = &clCreateSubDevices_unsupp; + dispatch->clRetainDevice = (clRetainDevice_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clRetainDevice"); + if (!dispatch->clRetainDevice) + dispatch->clRetainDevice = &clRetainDevice_unsupp; + dispatch->clReleaseDevice = (clReleaseDevice_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clReleaseDevice"); + if (!dispatch->clReleaseDevice) + dispatch->clReleaseDevice = &clReleaseDevice_unsupp; + dispatch->clCreateImage = (clCreateImage_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateImage"); + if (!dispatch->clCreateImage) + dispatch->clCreateImage = &clCreateImage_unsupp; + dispatch->clCreateProgramWithBuiltInKernels = (clCreateProgramWithBuiltInKernels_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateProgramWithBuiltInKernels"); + if (!dispatch->clCreateProgramWithBuiltInKernels) + dispatch->clCreateProgramWithBuiltInKernels = &clCreateProgramWithBuiltInKernels_unsupp; + dispatch->clCompileProgram = (clCompileProgram_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCompileProgram"); + if (!dispatch->clCompileProgram) + dispatch->clCompileProgram = &clCompileProgram_unsupp; + dispatch->clLinkProgram = (clLinkProgram_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clLinkProgram"); + if (!dispatch->clLinkProgram) + dispatch->clLinkProgram = &clLinkProgram_unsupp; + dispatch->clUnloadPlatformCompiler = (clUnloadPlatformCompiler_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clUnloadPlatformCompiler"); + if (!dispatch->clUnloadPlatformCompiler) + dispatch->clUnloadPlatformCompiler = &clUnloadPlatformCompiler_unsupp; + dispatch->clGetKernelArgInfo = (clGetKernelArgInfo_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clGetKernelArgInfo"); + if (!dispatch->clGetKernelArgInfo) + dispatch->clGetKernelArgInfo = &clGetKernelArgInfo_unsupp; + dispatch->clEnqueueFillBuffer = (clEnqueueFillBuffer_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueFillBuffer"); + if (!dispatch->clEnqueueFillBuffer) + dispatch->clEnqueueFillBuffer = &clEnqueueFillBuffer_unsupp; + dispatch->clEnqueueFillImage = (clEnqueueFillImage_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueFillImage"); + if (!dispatch->clEnqueueFillImage) + dispatch->clEnqueueFillImage = &clEnqueueFillImage_unsupp; + dispatch->clEnqueueMigrateMemObjects = (clEnqueueMigrateMemObjects_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueMigrateMemObjects"); + if (!dispatch->clEnqueueMigrateMemObjects) + dispatch->clEnqueueMigrateMemObjects = &clEnqueueMigrateMemObjects_unsupp; + dispatch->clEnqueueMarkerWithWaitList = (clEnqueueMarkerWithWaitList_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueMarkerWithWaitList"); + if (!dispatch->clEnqueueMarkerWithWaitList) + dispatch->clEnqueueMarkerWithWaitList = &clEnqueueMarkerWithWaitList_unsupp; + dispatch->clEnqueueBarrierWithWaitList = (clEnqueueBarrierWithWaitList_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueBarrierWithWaitList"); + if (!dispatch->clEnqueueBarrierWithWaitList) + dispatch->clEnqueueBarrierWithWaitList = &clEnqueueBarrierWithWaitList_unsupp; + dispatch->clGetExtensionFunctionAddressForPlatform = (clGetExtensionFunctionAddressForPlatform_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clGetExtensionFunctionAddressForPlatform"); + if (!dispatch->clGetExtensionFunctionAddressForPlatform) + dispatch->clGetExtensionFunctionAddressForPlatform = &clGetExtensionFunctionAddressForPlatform_unsupp; + dispatch->clCreateCommandQueueWithProperties = (clCreateCommandQueueWithProperties_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateCommandQueueWithProperties"); + if (!dispatch->clCreateCommandQueueWithProperties) + dispatch->clCreateCommandQueueWithProperties = &clCreateCommandQueueWithProperties_unsupp; + dispatch->clCreatePipe = (clCreatePipe_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreatePipe"); + if (!dispatch->clCreatePipe) + dispatch->clCreatePipe = &clCreatePipe_unsupp; + dispatch->clGetPipeInfo = (clGetPipeInfo_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clGetPipeInfo"); + if (!dispatch->clGetPipeInfo) + dispatch->clGetPipeInfo = &clGetPipeInfo_unsupp; + dispatch->clSVMAlloc = (clSVMAlloc_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clSVMAlloc"); + if (!dispatch->clSVMAlloc) + dispatch->clSVMAlloc = &clSVMAlloc_unsupp; + dispatch->clSVMFree = (clSVMFree_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clSVMFree"); + if (!dispatch->clSVMFree) + dispatch->clSVMFree = &clSVMFree_unsupp; + dispatch->clCreateSamplerWithProperties = (clCreateSamplerWithProperties_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateSamplerWithProperties"); + if (!dispatch->clCreateSamplerWithProperties) + dispatch->clCreateSamplerWithProperties = &clCreateSamplerWithProperties_unsupp; + dispatch->clSetKernelArgSVMPointer = (clSetKernelArgSVMPointer_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clSetKernelArgSVMPointer"); + if (!dispatch->clSetKernelArgSVMPointer) + dispatch->clSetKernelArgSVMPointer = &clSetKernelArgSVMPointer_unsupp; + dispatch->clSetKernelExecInfo = (clSetKernelExecInfo_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clSetKernelExecInfo"); + if (!dispatch->clSetKernelExecInfo) + dispatch->clSetKernelExecInfo = &clSetKernelExecInfo_unsupp; + dispatch->clEnqueueSVMFree = (clEnqueueSVMFree_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueSVMFree"); + if (!dispatch->clEnqueueSVMFree) + dispatch->clEnqueueSVMFree = &clEnqueueSVMFree_unsupp; + dispatch->clEnqueueSVMMemcpy = (clEnqueueSVMMemcpy_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueSVMMemcpy"); + if (!dispatch->clEnqueueSVMMemcpy) + dispatch->clEnqueueSVMMemcpy = &clEnqueueSVMMemcpy_unsupp; + dispatch->clEnqueueSVMMemFill = (clEnqueueSVMMemFill_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueSVMMemFill"); + if (!dispatch->clEnqueueSVMMemFill) + dispatch->clEnqueueSVMMemFill = &clEnqueueSVMMemFill_unsupp; + dispatch->clEnqueueSVMMap = (clEnqueueSVMMap_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueSVMMap"); + if (!dispatch->clEnqueueSVMMap) + dispatch->clEnqueueSVMMap = &clEnqueueSVMMap_unsupp; + dispatch->clEnqueueSVMUnmap = (clEnqueueSVMUnmap_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueSVMUnmap"); + if (!dispatch->clEnqueueSVMUnmap) + dispatch->clEnqueueSVMUnmap = &clEnqueueSVMUnmap_unsupp; + dispatch->clSetDefaultDeviceCommandQueue = (clSetDefaultDeviceCommandQueue_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clSetDefaultDeviceCommandQueue"); + if (!dispatch->clSetDefaultDeviceCommandQueue) + dispatch->clSetDefaultDeviceCommandQueue = &clSetDefaultDeviceCommandQueue_unsupp; + dispatch->clGetDeviceAndHostTimer = (clGetDeviceAndHostTimer_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clGetDeviceAndHostTimer"); + if (!dispatch->clGetDeviceAndHostTimer) + dispatch->clGetDeviceAndHostTimer = &clGetDeviceAndHostTimer_unsupp; + dispatch->clGetHostTimer = (clGetHostTimer_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clGetHostTimer"); + if (!dispatch->clGetHostTimer) + dispatch->clGetHostTimer = &clGetHostTimer_unsupp; + dispatch->clCreateProgramWithIL = (clCreateProgramWithIL_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateProgramWithIL"); + if (!dispatch->clCreateProgramWithIL) + dispatch->clCreateProgramWithIL = &clCreateProgramWithIL_unsupp; + dispatch->clCloneKernel = (clCloneKernel_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCloneKernel"); + if (!dispatch->clCloneKernel) + dispatch->clCloneKernel = &clCloneKernel_unsupp; + dispatch->clGetKernelSubGroupInfo = (clGetKernelSubGroupInfo_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clGetKernelSubGroupInfo"); + if (!dispatch->clGetKernelSubGroupInfo) + dispatch->clGetKernelSubGroupInfo = &clGetKernelSubGroupInfo_unsupp; + dispatch->clEnqueueSVMMigrateMem = (clEnqueueSVMMigrateMem_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueSVMMigrateMem"); + if (!dispatch->clEnqueueSVMMigrateMem) + dispatch->clEnqueueSVMMigrateMem = &clEnqueueSVMMigrateMem_unsupp; + dispatch->clSetProgramSpecializationConstant = (clSetProgramSpecializationConstant_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clSetProgramSpecializationConstant"); + if (!dispatch->clSetProgramSpecializationConstant) + dispatch->clSetProgramSpecializationConstant = &clSetProgramSpecializationConstant_unsupp; + dispatch->clSetProgramReleaseCallback = (clSetProgramReleaseCallback_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clSetProgramReleaseCallback"); + if (!dispatch->clSetProgramReleaseCallback) + dispatch->clSetProgramReleaseCallback = &clSetProgramReleaseCallback_unsupp; + dispatch->clSetContextDestructorCallback = (clSetContextDestructorCallback_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clSetContextDestructorCallback"); + if (!dispatch->clSetContextDestructorCallback) + dispatch->clSetContextDestructorCallback = &clSetContextDestructorCallback_unsupp; + dispatch->clCreateBufferWithProperties = (clCreateBufferWithProperties_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateBufferWithProperties"); + if (!dispatch->clCreateBufferWithProperties) + dispatch->clCreateBufferWithProperties = &clCreateBufferWithProperties_unsupp; + dispatch->clCreateImageWithProperties = (clCreateImageWithProperties_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateImageWithProperties"); + if (!dispatch->clCreateImageWithProperties) + dispatch->clCreateImageWithProperties = &clCreateImageWithProperties_unsupp; + +/////////////////////////////////////////////////////////////////////////////// +// cl_ext_device_fission + dispatch->clReleaseDeviceEXT = (clReleaseDeviceEXT_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clReleaseDeviceEXT"); + if (!dispatch->clReleaseDeviceEXT) + dispatch->clReleaseDeviceEXT = &clReleaseDeviceEXT_unsupp; + dispatch->clRetainDeviceEXT = (clRetainDeviceEXT_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clRetainDeviceEXT"); + if (!dispatch->clRetainDeviceEXT) + dispatch->clRetainDeviceEXT = &clRetainDeviceEXT_unsupp; + dispatch->clCreateSubDevicesEXT = (clCreateSubDevicesEXT_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateSubDevicesEXT"); + if (!dispatch->clCreateSubDevicesEXT) + dispatch->clCreateSubDevicesEXT = &clCreateSubDevicesEXT_unsupp; +/////////////////////////////////////////////////////////////////////////////// + +// cl_khr_d3d10_sharing + +#if defined(_WIN32) + dispatch->clGetDeviceIDsFromD3D10KHR = (clGetDeviceIDsFromD3D10KHR_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clGetDeviceIDsFromD3D10KHR"); + if (!dispatch->clGetDeviceIDsFromD3D10KHR) + dispatch->clGetDeviceIDsFromD3D10KHR = &clGetDeviceIDsFromD3D10KHR_unsupp; + dispatch->clCreateFromD3D10BufferKHR = (clCreateFromD3D10BufferKHR_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateFromD3D10BufferKHR"); + if (!dispatch->clCreateFromD3D10BufferKHR) + dispatch->clCreateFromD3D10BufferKHR = &clCreateFromD3D10BufferKHR_unsupp; + dispatch->clCreateFromD3D10Texture2DKHR = (clCreateFromD3D10Texture2DKHR_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateFromD3D10Texture2DKHR"); + if (!dispatch->clCreateFromD3D10Texture2DKHR) + dispatch->clCreateFromD3D10Texture2DKHR = &clCreateFromD3D10Texture2DKHR_unsupp; + dispatch->clCreateFromD3D10Texture3DKHR = (clCreateFromD3D10Texture3DKHR_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateFromD3D10Texture3DKHR"); + if (!dispatch->clCreateFromD3D10Texture3DKHR) + dispatch->clCreateFromD3D10Texture3DKHR = &clCreateFromD3D10Texture3DKHR_unsupp; + dispatch->clEnqueueAcquireD3D10ObjectsKHR = (clEnqueueAcquireD3D10ObjectsKHR_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueAcquireD3D10ObjectsKHR"); + if (!dispatch->clEnqueueAcquireD3D10ObjectsKHR) + dispatch->clEnqueueAcquireD3D10ObjectsKHR = &clEnqueueAcquireD3D10ObjectsKHR_unsupp; + dispatch->clEnqueueReleaseD3D10ObjectsKHR = (clEnqueueReleaseD3D10ObjectsKHR_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueReleaseD3D10ObjectsKHR"); + if (!dispatch->clEnqueueReleaseD3D10ObjectsKHR) + dispatch->clEnqueueReleaseD3D10ObjectsKHR = &clEnqueueReleaseD3D10ObjectsKHR_unsupp; +#endif // defined(_WIN32) + +/////////////////////////////////////////////////////////////////////////////// + +// cl_khr_d3d11_sharing + +#if defined(_WIN32) + dispatch->clGetDeviceIDsFromD3D11KHR = (clGetDeviceIDsFromD3D11KHR_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clGetDeviceIDsFromD3D11KHR"); + if (!dispatch->clGetDeviceIDsFromD3D11KHR) + dispatch->clGetDeviceIDsFromD3D11KHR = &clGetDeviceIDsFromD3D11KHR_unsupp; + dispatch->clCreateFromD3D11BufferKHR = (clCreateFromD3D11BufferKHR_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateFromD3D11BufferKHR"); + if (!dispatch->clCreateFromD3D11BufferKHR) + dispatch->clCreateFromD3D11BufferKHR = &clCreateFromD3D11BufferKHR_unsupp; + dispatch->clCreateFromD3D11Texture2DKHR = (clCreateFromD3D11Texture2DKHR_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateFromD3D11Texture2DKHR"); + if (!dispatch->clCreateFromD3D11Texture2DKHR) + dispatch->clCreateFromD3D11Texture2DKHR = &clCreateFromD3D11Texture2DKHR_unsupp; + dispatch->clCreateFromD3D11Texture3DKHR = (clCreateFromD3D11Texture3DKHR_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateFromD3D11Texture3DKHR"); + if (!dispatch->clCreateFromD3D11Texture3DKHR) + dispatch->clCreateFromD3D11Texture3DKHR = &clCreateFromD3D11Texture3DKHR_unsupp; + dispatch->clEnqueueAcquireD3D11ObjectsKHR = (clEnqueueAcquireD3D11ObjectsKHR_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueAcquireD3D11ObjectsKHR"); + if (!dispatch->clEnqueueAcquireD3D11ObjectsKHR) + dispatch->clEnqueueAcquireD3D11ObjectsKHR = &clEnqueueAcquireD3D11ObjectsKHR_unsupp; + dispatch->clEnqueueReleaseD3D11ObjectsKHR = (clEnqueueReleaseD3D11ObjectsKHR_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueReleaseD3D11ObjectsKHR"); + if (!dispatch->clEnqueueReleaseD3D11ObjectsKHR) + dispatch->clEnqueueReleaseD3D11ObjectsKHR = &clEnqueueReleaseD3D11ObjectsKHR_unsupp; +#endif // defined(_WIN32) + +/////////////////////////////////////////////////////////////////////////////// + +// cl_khr_dx9_media_sharing + +#if defined(_WIN32) + dispatch->clGetDeviceIDsFromDX9MediaAdapterKHR = (clGetDeviceIDsFromDX9MediaAdapterKHR_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clGetDeviceIDsFromDX9MediaAdapterKHR"); + if (!dispatch->clGetDeviceIDsFromDX9MediaAdapterKHR) + dispatch->clGetDeviceIDsFromDX9MediaAdapterKHR = &clGetDeviceIDsFromDX9MediaAdapterKHR_unsupp; + dispatch->clCreateFromDX9MediaSurfaceKHR = (clCreateFromDX9MediaSurfaceKHR_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateFromDX9MediaSurfaceKHR"); + if (!dispatch->clCreateFromDX9MediaSurfaceKHR) + dispatch->clCreateFromDX9MediaSurfaceKHR = &clCreateFromDX9MediaSurfaceKHR_unsupp; + dispatch->clEnqueueAcquireDX9MediaSurfacesKHR = (clEnqueueAcquireDX9MediaSurfacesKHR_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueAcquireDX9MediaSurfacesKHR"); + if (!dispatch->clEnqueueAcquireDX9MediaSurfacesKHR) + dispatch->clEnqueueAcquireDX9MediaSurfacesKHR = &clEnqueueAcquireDX9MediaSurfacesKHR_unsupp; + dispatch->clEnqueueReleaseDX9MediaSurfacesKHR = (clEnqueueReleaseDX9MediaSurfacesKHR_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueReleaseDX9MediaSurfacesKHR"); + if (!dispatch->clEnqueueReleaseDX9MediaSurfacesKHR) + dispatch->clEnqueueReleaseDX9MediaSurfacesKHR = &clEnqueueReleaseDX9MediaSurfacesKHR_unsupp; +#endif // defined(_WIN32) + +/////////////////////////////////////////////////////////////////////////////// + +// cl_khr_egl_event + dispatch->clCreateEventFromEGLSyncKHR = (clCreateEventFromEGLSyncKHR_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateEventFromEGLSyncKHR"); + if (!dispatch->clCreateEventFromEGLSyncKHR) + dispatch->clCreateEventFromEGLSyncKHR = &clCreateEventFromEGLSyncKHR_unsupp; +/////////////////////////////////////////////////////////////////////////////// + +// cl_khr_egl_image + dispatch->clCreateFromEGLImageKHR = (clCreateFromEGLImageKHR_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateFromEGLImageKHR"); + if (!dispatch->clCreateFromEGLImageKHR) + dispatch->clCreateFromEGLImageKHR = &clCreateFromEGLImageKHR_unsupp; + dispatch->clEnqueueAcquireEGLObjectsKHR = (clEnqueueAcquireEGLObjectsKHR_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueAcquireEGLObjectsKHR"); + if (!dispatch->clEnqueueAcquireEGLObjectsKHR) + dispatch->clEnqueueAcquireEGLObjectsKHR = &clEnqueueAcquireEGLObjectsKHR_unsupp; + dispatch->clEnqueueReleaseEGLObjectsKHR = (clEnqueueReleaseEGLObjectsKHR_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueReleaseEGLObjectsKHR"); + if (!dispatch->clEnqueueReleaseEGLObjectsKHR) + dispatch->clEnqueueReleaseEGLObjectsKHR = &clEnqueueReleaseEGLObjectsKHR_unsupp; +/////////////////////////////////////////////////////////////////////////////// + +// cl_khr_gl_event + dispatch->clCreateEventFromGLsyncKHR = (clCreateEventFromGLsyncKHR_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateEventFromGLsyncKHR"); + if (!dispatch->clCreateEventFromGLsyncKHR) + dispatch->clCreateEventFromGLsyncKHR = &clCreateEventFromGLsyncKHR_unsupp; +/////////////////////////////////////////////////////////////////////////////// + +// cl_khr_gl_sharing + dispatch->clGetGLContextInfoKHR = (clGetGLContextInfoKHR_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clGetGLContextInfoKHR"); + if (!dispatch->clGetGLContextInfoKHR) + dispatch->clGetGLContextInfoKHR = &clGetGLContextInfoKHR_unsupp; + dispatch->clCreateFromGLBuffer = (clCreateFromGLBuffer_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateFromGLBuffer"); + if (!dispatch->clCreateFromGLBuffer) + dispatch->clCreateFromGLBuffer = &clCreateFromGLBuffer_unsupp; + dispatch->clCreateFromGLTexture = (clCreateFromGLTexture_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateFromGLTexture"); + if (!dispatch->clCreateFromGLTexture) + dispatch->clCreateFromGLTexture = &clCreateFromGLTexture_unsupp; + dispatch->clCreateFromGLRenderbuffer = (clCreateFromGLRenderbuffer_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateFromGLRenderbuffer"); + if (!dispatch->clCreateFromGLRenderbuffer) + dispatch->clCreateFromGLRenderbuffer = &clCreateFromGLRenderbuffer_unsupp; + dispatch->clGetGLObjectInfo = (clGetGLObjectInfo_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clGetGLObjectInfo"); + if (!dispatch->clGetGLObjectInfo) + dispatch->clGetGLObjectInfo = &clGetGLObjectInfo_unsupp; + dispatch->clGetGLTextureInfo = (clGetGLTextureInfo_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clGetGLTextureInfo"); + if (!dispatch->clGetGLTextureInfo) + dispatch->clGetGLTextureInfo = &clGetGLTextureInfo_unsupp; + dispatch->clEnqueueAcquireGLObjects = (clEnqueueAcquireGLObjects_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueAcquireGLObjects"); + if (!dispatch->clEnqueueAcquireGLObjects) + dispatch->clEnqueueAcquireGLObjects = &clEnqueueAcquireGLObjects_unsupp; + dispatch->clEnqueueReleaseGLObjects = (clEnqueueReleaseGLObjects_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clEnqueueReleaseGLObjects"); + if (!dispatch->clEnqueueReleaseGLObjects) + dispatch->clEnqueueReleaseGLObjects = &clEnqueueReleaseGLObjects_unsupp; + dispatch->clCreateFromGLTexture2D = (clCreateFromGLTexture2D_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateFromGLTexture2D"); + if (!dispatch->clCreateFromGLTexture2D) + dispatch->clCreateFromGLTexture2D = &clCreateFromGLTexture2D_unsupp; + dispatch->clCreateFromGLTexture3D = (clCreateFromGLTexture3D_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateFromGLTexture3D"); + if (!dispatch->clCreateFromGLTexture3D) + dispatch->clCreateFromGLTexture3D = &clCreateFromGLTexture3D_unsupp; +/////////////////////////////////////////////////////////////////////////////// + +// cl_khr_subgroups + dispatch->clGetKernelSubGroupInfoKHR = (clGetKernelSubGroupInfoKHR_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clGetKernelSubGroupInfoKHR"); + if (!dispatch->clGetKernelSubGroupInfoKHR) + dispatch->clGetKernelSubGroupInfoKHR = &clGetKernelSubGroupInfoKHR_unsupp; +/////////////////////////////////////////////////////////////////////////////// + +} +#endif // defined(CL_ENABLE_LOADER_MANAGED_DISPATCH) + +#ifdef __cplusplus +} +#endif diff --git a/loader/icd_envvars.h b/loader/icd_envvars.h new file mode 100644 index 00000000..0d34d3d6 --- /dev/null +++ b/loader/icd_envvars.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2016-2019 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#ifndef _ICD_ENVVARS_H_ +#define _ICD_ENVVARS_H_ + +char *khrIcd_getenv(const char *name); +char *khrIcd_secure_getenv(const char *name); +void khrIcd_free_getenv(char *val); + +#endif diff --git a/loader/icd_platform.h b/loader/icd_platform.h new file mode 100644 index 00000000..da8a6d86 --- /dev/null +++ b/loader/icd_platform.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2016-2019 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#ifndef _ICD_PLATFORM_H_ +#define _ICD_PLATFORM_H_ + +#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__QNXNTO__) + +#define PATH_SEPARATOR ':' +#define DIRECTORY_SYMBOL '/' +#ifdef __ANDROID__ +#define ICD_VENDOR_PATH "/system/vendor/Khronos/OpenCL/vendors" +#define LAYER_PATH "/system/vendor/Khronos/OpenCL/layers" +#else +#define ICD_VENDOR_PATH "/etc/OpenCL/vendors" +#define LAYER_PATH "/etc/OpenCL/layers" +#endif // ANDROID + +#elif defined(_WIN32) + +#define PATH_SEPARATOR ';' +#define DIRECTORY_SYMBOL '\\' + +#else +#error Unknown OS! +#endif + +#ifdef __MINGW32__ +#if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0600) +#undef _WIN32_WINNT +#define _WIN32_WINNT 0x0600 +#endif +#endif // __MINGW32__ + +#endif diff --git a/loader/icd_version.h b/loader/icd_version.h new file mode 100644 index 00000000..1ecd343b --- /dev/null +++ b/loader/icd_version.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2016-2020 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#ifndef _ICD_VERSION_H_ +#define _ICD_VERSION_H_ + +#define OPENCL_ICD_LOADER_NAME_STRING "Khronos OpenCL ICD Loader" +#define OPENCL_ICD_LOADER_VENDOR_STRING "Khronos Group" + +#define OPENCL_ICD_LOADER_VAL(_v) #_v +#define OPENCL_ICD_LOADER_TOSTRING(_d) OPENCL_ICD_LOADER_VAL(_d) +#define OPENCL_ICD_LOADER_VERSION_STRING \ + OPENCL_ICD_LOADER_TOSTRING(OPENCL_ICD_LOADER_VERSION_MAJOR) "." \ + OPENCL_ICD_LOADER_TOSTRING(OPENCL_ICD_LOADER_VERSION_MINOR) "." \ + OPENCL_ICD_LOADER_TOSTRING(OPENCL_ICD_LOADER_VERSION_REV) + +#if CL_TARGET_OPENCL_VERSION == 100 +#define OPENCL_ICD_LOADER_OCL_VERSION_NUMBER "1.0" +#endif +#if CL_TARGET_OPENCL_VERSION == 110 +#define OPENCL_ICD_LOADER_OCL_VERSION_NUMBER "1.1" +#endif +#if CL_TARGET_OPENCL_VERSION == 120 +#define OPENCL_ICD_LOADER_OCL_VERSION_NUMBER "1.2" +#endif +#if CL_TARGET_OPENCL_VERSION == 200 +#define OPENCL_ICD_LOADER_OCL_VERSION_NUMBER "2.0" +#endif +#if CL_TARGET_OPENCL_VERSION == 210 +#define OPENCL_ICD_LOADER_OCL_VERSION_NUMBER "2.1" +#endif +#if CL_TARGET_OPENCL_VERSION == 220 +#define OPENCL_ICD_LOADER_OCL_VERSION_NUMBER "2.2" +#endif +#if CL_TARGET_OPENCL_VERSION == 300 +#define OPENCL_ICD_LOADER_OCL_VERSION_NUMBER "3.0" +#endif + +#define OPENCL_ICD_LOADER_OCL_VERSION_STRING \ + "OpenCL " OPENCL_ICD_LOADER_OCL_VERSION_NUMBER + +#endif diff --git a/icd_exports.map b/loader/linux/icd_exports.map similarity index 68% rename from icd_exports.map rename to loader/linux/icd_exports.map index 60211e50..f9299c30 100644 --- a/icd_exports.map +++ b/loader/linux/icd_exports.map @@ -1,36 +1,17 @@ /* - * Copyright (c) 2016 The Khronos Group Inc. + * Copyright (c) 2016-2019 The Khronos Group Inc. * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software source and associated documentation files (the "Materials"), - * to deal in the Materials without restriction, including without limitation - * the rights to use, copy, modify, compile, merge, publish, distribute, - * sublicense, and/or sell copies of the Materials, and to permit persons to - * whom the Materials are furnished to do so, subject the following terms and - * conditions: + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * All modifications to the Materials used to create a binary that is - * distributed to third parties shall be provided to Khronos with an - * unrestricted license to use for the purposes of implementing bug fixes and - * enhancements to the Materials; + * http://www.apache.org/licenses/LICENSE-2.0 * - * If the binary is used as part of an OpenCL(TM) implementation, whether binary - * is distributed together with or separately to that implementation, then - * recipient must become an OpenCL Adopter and follow the published OpenCL - * conformance process for that implementation, details at: - * http://www.khronos.org/conformance/; - * - * The above copyright notice, the OpenCL trademark license, and this permission - * notice shall be included in all copies or substantial portions of the - * Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN - * THE MATERIALS. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * * OpenCL is a trademark of Apple Inc. used under license by Khronos. */ @@ -182,3 +163,10 @@ OPENCL_2.2 { clSetProgramReleaseCallback; clSetProgramSpecializationConstant; } OPENCL_2.1; + +OPENCL_3.0 { + global: + clCreateBufferWithProperties; + clCreateImageWithProperties; + clSetContextDestructorCallback; +} OPENCL_2.2; diff --git a/loader/linux/icd_linux.c b/loader/linux/icd_linux.c new file mode 100644 index 00000000..c6f6b542 --- /dev/null +++ b/loader/linux/icd_linux.c @@ -0,0 +1,267 @@ +/* + * Copyright (c) 2016-2020 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#include "icd.h" +#include "icd_envvars.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static pthread_once_t initialized = PTHREAD_ONCE_INIT; + +/* + * + * Vendor enumeration functions + * + */ + +typedef void khrIcdFileAdd(const char *); + +static inline void khrIcdOsDirEntryValidateAndAdd(const char *d_name, const char *path, + const char *extension, khrIcdFileAdd addFunc) +{ + struct stat statBuff; + char* fileName = NULL; + + // make sure the file name ends in `extension` (eg. .icd, or .lay) + if (strlen(extension) > strlen(d_name)) + { + return; + } + if (strcmp(d_name + strlen(d_name) - strlen(extension), extension)) + { + return; + } + + // allocate space for the full path of the vendor library name + fileName = malloc(strlen(d_name) + strlen(path) + 2); + if (!fileName) + { + KHR_ICD_TRACE("Failed allocate space for ICD file path\n"); + return; + } + sprintf(fileName, "%s/%s", path, d_name); + + if (stat(fileName, &statBuff)) + { + KHR_ICD_TRACE("Failed stat for: %s, continuing\n", fileName); + free(fileName); + return; + } + + if (S_ISREG(statBuff.st_mode) || S_ISLNK(statBuff.st_mode)) + { + FILE *fin = NULL; + char* buffer = NULL; + long bufferSize = 0; + + // open the file and read its contents + fin = fopen(fileName, "r"); + if (!fin) + { + free(fileName); + return; + } + fseek(fin, 0, SEEK_END); + bufferSize = ftell(fin); + + buffer = malloc(bufferSize+1); + if (!buffer) + { + free(fileName); + fclose(fin); + return; + } + memset(buffer, 0, bufferSize+1); + fseek(fin, 0, SEEK_SET); + if (bufferSize != (long)fread(buffer, 1, bufferSize, fin)) + { + free(fileName); + free(buffer); + fclose(fin); + return; + } + // 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 + addFunc(buffer); + + free(fileName); + free(buffer); + fclose(fin); + } + else + { + KHR_ICD_TRACE("File %s is not a regular file nor symbolic link, continuing\n", fileName); + free(fileName); + } +} + +struct dirElem +{ + char *d_name; + unsigned char d_type; +}; + +static int compareDirElem(const void *a, const void *b) +{ + // sort files the same way libc alpahnumerically sorts directory entries. + return strcoll(((const struct dirElem *)a)->d_name, ((const struct dirElem *)b)->d_name); +} + +static inline void khrIcdOsDirEnumerate(const char *path, const char *env, + const char *extension, + khrIcdFileAdd addFunc, int bSort) +{ + DIR *dir = NULL; + char* envPath = NULL; + + envPath = khrIcd_secure_getenv(env); + if (NULL != envPath) + { + path = envPath; + } + + dir = opendir(path); + if (NULL == dir) + { + KHR_ICD_TRACE("Failed to open path %s, continuing\n", path); + } + else + { + struct dirent *dirEntry = NULL; + + // attempt to load all files in the directory + if (bSort) { + // store the entries name and type in a buffer for sorting + size_t sz = 0; + size_t elemCount = 0; + size_t elemAlloc = 0; + struct dirElem *dirElems = NULL; + struct dirElem *newDirElems = NULL; + const size_t startupAlloc = 8; + + // start with a small buffer + dirElems = (struct dirElem *)malloc(startupAlloc*sizeof(struct dirElem)); + if (NULL != dirElems) { + elemAlloc = startupAlloc; + for (dirEntry = readdir(dir); dirEntry; dirEntry = readdir(dir) ) { + char *nameCopy = NULL; + + if (elemCount + 1 > elemAlloc) { + // double buffer size if necessary and possible + if (elemAlloc >= UINT_MAX/2) + break; + newDirElems = (struct dirElem *)realloc(dirElems, elemAlloc*2*sizeof(struct dirElem)); + if (NULL == newDirElems) + break; + dirElems = newDirElems; + elemAlloc *= 2; + } + sz = strlen(dirEntry->d_name) + 1; + nameCopy = (char *)malloc(sz); + if (NULL == nameCopy) + break; + memcpy(nameCopy, dirEntry->d_name, sz); + dirElems[elemCount].d_name = nameCopy; +#if defined(__QNXNTO__) + dirElems[elemCount].d_type = _DEXTRA_FIRST(dirEntry)->d_type; +#else + dirElems[elemCount].d_type = dirEntry->d_type; +#endif + elemCount++; + } + qsort(dirElems, elemCount, sizeof(struct dirElem), compareDirElem); + for (struct dirElem *elem = dirElems; elem < dirElems + elemCount; ++elem) { + khrIcdOsDirEntryValidateAndAdd(elem->d_name, path, extension, addFunc); + free(elem->d_name); + } + free(dirElems); + } + } else + // use system provided ordering + for (dirEntry = readdir(dir); dirEntry; dirEntry = readdir(dir) ) + khrIcdOsDirEntryValidateAndAdd(dirEntry->d_name, path, extension, addFunc); + + closedir(dir); + } + + if (NULL != envPath) + { + khrIcd_free_getenv(envPath); + } +} + +// go through the list of vendors in the two configuration files +void khrIcdOsVendorsEnumerate(void) +{ + khrIcdInitializeTrace(); + khrIcdVendorsEnumerateEnv(); + + khrIcdOsDirEnumerate(ICD_VENDOR_PATH, "OCL_ICD_VENDORS", ".icd", khrIcdVendorAdd, 0); + +#if defined(CL_ENABLE_LAYERS) + // system layers should be closer to the driver + khrIcdOsDirEnumerate(LAYER_PATH, "OPENCL_LAYER_PATH", ".lay", khrIcdLayerAdd, 1); + + khrIcdLayersEnumerateEnv(); +#endif // defined(CL_ENABLE_LAYERS) +} + +// go through the list of vendors only once +void khrIcdOsVendorsEnumerateOnce(void) +{ + pthread_once(&initialized, khrIcdOsVendorsEnumerate); +} + +/* + * + * Dynamic library loading functions + * + */ + +// dynamically load a library. returns NULL on failure +void *khrIcdOsLibraryLoad(const char *libraryName) +{ + void* ret = dlopen (libraryName, RTLD_NOW); + if (NULL == ret) + { + KHR_ICD_TRACE("Failed to load driver because %s.\n", dlerror()); + } + return ret; +} + +// get a function pointer from a loaded library. returns NULL on failure. +void *khrIcdOsLibraryGetFunctionAddress(void *library, const char *functionName) +{ + return dlsym(library, functionName); +} + +// unload a library +void khrIcdOsLibraryUnload(void *library) +{ + dlclose(library); +} diff --git a/loader/linux/icd_linux_envvars.c b/loader/linux/icd_linux_envvars.c new file mode 100644 index 00000000..d61dea4e --- /dev/null +++ b/loader/linux/icd_linux_envvars.c @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2016-2019 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +// for secure_getenv(): +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + +#include "icd_cmake_config.h" + +#include +#include + +char *khrIcd_getenv(const char *name) { + // No allocation of memory necessary for Linux. + return getenv(name); +} + +char *khrIcd_secure_getenv(const char *name) { +#if defined(__APPLE__) || defined(__QNXNTO__) + // Apple does not appear to have a secure getenv implementation. + // The main difference between secure getenv and getenv is that secure getenv + // returns NULL if the process is being run with elevated privileges by a normal user. + // The idea is to prevent the reading of malicious environment variables by a process + // that can do damage. + // This algorithm is derived from glibc code that sets an internal + // variable (__libc_enable_secure) if the process is running under setuid or setgid. + return geteuid() != getuid() || getegid() != getgid() ? NULL : khrIcd_getenv(name); +#else +// Linux +#ifdef HAVE_SECURE_GETENV + return secure_getenv(name); +#elif defined(HAVE___SECURE_GETENV) + return __secure_getenv(name); +#else +#pragma message( \ + "Warning: Falling back to non-secure getenv for environmental lookups! Consider" \ + " updating to a different libc.") + return khrIcd_getenv(name); +#endif +#endif +} + +void khrIcd_free_getenv(char *val) { + // No freeing of memory necessary for Linux, but we should at least touch + // val to get rid of compiler warnings. + (void)val; +} diff --git a/loader/windows/OpenCL-mingw-i686.def b/loader/windows/OpenCL-mingw-i686.def new file mode 100644 index 00000000..b7045a0b --- /dev/null +++ b/loader/windows/OpenCL-mingw-i686.def @@ -0,0 +1,162 @@ +; +; Copyright (c) 2022 The Khronos Group Inc. +; +; Licensed under the Apache License, Version 2.0 (the "License"); +; you may not use this file except in compliance with the License. +; You may obtain a copy of the License at +; +; http://www.apache.org/licenses/LICENSE-2.0 +; +; Unless required by applicable law or agreed to in writing, software +; distributed under the License is distributed on an "AS IS" BASIS, +; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +; See the License for the specific language governing permissions and +; limitations under the License. +; +; OpenCL is a trademark of Apple Inc. used under license by Khronos. + +EXPORTS + +; +; Note: This is a special .def file that should only be needed for i686 +; (32-bit) mingw builds. In this case we need to export the stdcall- +; decorated functions. In all other cases we can use the standard .def +; file that does not have decorated functions. +; + +; OpenCL 1.0 API +clBuildProgram@24 == clBuildProgram +clCreateBuffer@24 == clCreateBuffer +clCreateCommandQueue@20 == clCreateCommandQueue +clCreateContext@24 == clCreateContext +clCreateContextFromType@24 == clCreateContextFromType +clCreateFromGLBuffer@20 == clCreateFromGLBuffer +clCreateFromGLRenderbuffer@20 == clCreateFromGLRenderbuffer +clCreateFromGLTexture2D@28 == clCreateFromGLTexture2D +clCreateFromGLTexture3D@28 == clCreateFromGLTexture3D +clCreateImage2D@36 == clCreateImage2D +clCreateImage3D@44 == clCreateImage3D +clCreateKernel@12 == clCreateKernel +clCreateKernelsInProgram@16 == clCreateKernelsInProgram +clCreateProgramWithBinary@28 == clCreateProgramWithBinary +clCreateProgramWithSource@20 == clCreateProgramWithSource +clCreateSampler@20 == clCreateSampler +clEnqueueAcquireGLObjects@24 == clEnqueueAcquireGLObjects +clEnqueueBarrier@4 == clEnqueueBarrier +clEnqueueCopyBuffer@36 == clEnqueueCopyBuffer +clEnqueueCopyBufferToImage@36 == clEnqueueCopyBufferToImage +clEnqueueCopyImage@36 == clEnqueueCopyImage +clEnqueueCopyImageToBuffer@36 == clEnqueueCopyImageToBuffer +clEnqueueMapBuffer@44 == clEnqueueMapBuffer +clEnqueueMapImage@52 == clEnqueueMapImage +clEnqueueMarker@8 == clEnqueueMarker +clEnqueueNDRangeKernel@36 == clEnqueueNDRangeKernel +clEnqueueNativeKernel@40 == clEnqueueNativeKernel +clEnqueueReadBuffer@36 == clEnqueueReadBuffer +clEnqueueReadImage@44 == clEnqueueReadImage +clEnqueueReleaseGLObjects@24 == clEnqueueReleaseGLObjects +clEnqueueTask@20 == clEnqueueTask +clEnqueueUnmapMemObject@24 == clEnqueueUnmapMemObject +clEnqueueWaitForEvents@12 == clEnqueueWaitForEvents +clEnqueueWriteBuffer@36 == clEnqueueWriteBuffer +clEnqueueWriteImage@44 == clEnqueueWriteImage +clFinish@4 == clFinish +clFlush@4 == clFlush +clGetCommandQueueInfo@20 == clGetCommandQueueInfo +clGetContextInfo@20 == clGetContextInfo +clGetDeviceIDs@24 == clGetDeviceIDs +clGetDeviceInfo@20 == clGetDeviceInfo +clGetEventInfo@20 == clGetEventInfo +clGetEventProfilingInfo@20 == clGetEventProfilingInfo +clGetExtensionFunctionAddress@4 == clGetExtensionFunctionAddress +clGetGLObjectInfo@12 == clGetGLObjectInfo +clGetGLTextureInfo@20 == clGetGLTextureInfo +clGetImageInfo@20 == clGetImageInfo +clGetKernelInfo@20 == clGetKernelInfo +clGetKernelWorkGroupInfo@24 == clGetKernelWorkGroupInfo +clGetMemObjectInfo@20 == clGetMemObjectInfo +clGetPlatformIDs@12 == clGetPlatformIDs +clGetPlatformInfo@20 == clGetPlatformInfo +clGetProgramBuildInfo@24 == clGetProgramBuildInfo +clGetProgramInfo@20 == clGetProgramInfo +clGetSamplerInfo@20 == clGetSamplerInfo +clGetSupportedImageFormats@28 == clGetSupportedImageFormats +clReleaseCommandQueue@4 == clReleaseCommandQueue +clReleaseContext@4 == clReleaseContext +clReleaseEvent@4 == clReleaseEvent +clReleaseKernel@4 == clReleaseKernel +clReleaseMemObject@4 == clReleaseMemObject +clReleaseProgram@4 == clReleaseProgram +clReleaseSampler@4 == clReleaseSampler +clRetainCommandQueue@4 == clRetainCommandQueue +clRetainContext@4 == clRetainContext +clRetainEvent@4 == clRetainEvent +clRetainKernel@4 == clRetainKernel +clRetainMemObject@4 == clRetainMemObject +clRetainProgram@4 == clRetainProgram +clRetainSampler@4 == clRetainSampler +clSetCommandQueueProperty@20 == clSetCommandQueueProperty +clSetKernelArg@16 == clSetKernelArg +clUnloadCompiler@0 == clUnloadCompiler +clWaitForEvents@8 == clWaitForEvents + +; OpenCL 1.1 API +clCreateSubBuffer@24 == clCreateSubBuffer +clCreateUserEvent@8 == clCreateUserEvent +clEnqueueCopyBufferRect@52 == clEnqueueCopyBufferRect +clEnqueueReadBufferRect@56 == clEnqueueReadBufferRect +clEnqueueWriteBufferRect@56 == clEnqueueWriteBufferRect +clSetEventCallback@16 == clSetEventCallback +clSetMemObjectDestructorCallback@12 == clSetMemObjectDestructorCallback +clSetUserEventStatus@8 == clSetUserEventStatus + +; OpenCL 1.2 API +clCompileProgram@36 == clCompileProgram +clCreateFromGLTexture@28 == clCreateFromGLTexture +clCreateImage@28 == clCreateImage +clCreateProgramWithBuiltInKernels@20 == clCreateProgramWithBuiltInKernels +clCreateSubDevices@20 == clCreateSubDevices +clEnqueueBarrierWithWaitList@16 == clEnqueueBarrierWithWaitList +clEnqueueFillBuffer@36 == clEnqueueFillBuffer +clEnqueueFillImage@32 == clEnqueueFillImage +clEnqueueMarkerWithWaitList@16 == clEnqueueMarkerWithWaitList +clEnqueueMigrateMemObjects@32 == clEnqueueMigrateMemObjects +clGetExtensionFunctionAddressForPlatform@8 == clGetExtensionFunctionAddressForPlatform +clGetKernelArgInfo@24 == clGetKernelArgInfo +clLinkProgram@36 == clLinkProgram +clReleaseDevice@4 == clReleaseDevice +clRetainDevice@4 == clRetainDevice +clUnloadPlatformCompiler@4 == clUnloadPlatformCompiler + +; OpenCL 2.0 API +clCreateCommandQueueWithProperties@16 == clCreateCommandQueueWithProperties +clCreatePipe@28 == clCreatePipe +clCreateSamplerWithProperties@12 == clCreateSamplerWithProperties +clEnqueueSVMFree@32 == clEnqueueSVMFree +clEnqueueSVMMap@36 == clEnqueueSVMMap +clEnqueueSVMMemcpy@32 == clEnqueueSVMMemcpy +clEnqueueSVMMemFill@32 == clEnqueueSVMMemFill +clEnqueueSVMUnmap@20 == clEnqueueSVMUnmap +clGetPipeInfo@20 == clGetPipeInfo +clSetKernelArgSVMPointer@12 == clSetKernelArgSVMPointer +clSetKernelExecInfo@16 == clSetKernelExecInfo +clSVMAlloc@20 == clSVMAlloc +clSVMFree@8 == clSVMFree + +; OpenCL 2.1 API +clCloneKernel@8 == clCloneKernel +clCreateProgramWithIL@16 == clCreateProgramWithIL +clEnqueueSVMMigrateMem@36 == clEnqueueSVMMigrateMem +clGetDeviceAndHostTimer@12 == clGetDeviceAndHostTimer +clGetHostTimer@8 == clGetHostTimer +clGetKernelSubGroupInfo@32 == clGetKernelSubGroupInfo +clSetDefaultDeviceCommandQueue@12 == clSetDefaultDeviceCommandQueue + +; OpenCL 2.2 API +clSetProgramReleaseCallback@12 == clSetProgramReleaseCallback +clSetProgramSpecializationConstant@16 == clSetProgramSpecializationConstant + +; OpenCL 3.0 API +clCreateBufferWithProperties@28 == clCreateBufferWithProperties +clCreateImageWithProperties@32 == clCreateImageWithProperties +clSetContextDestructorCallback@12 == clSetContextDestructorCallback diff --git a/OpenCL.def b/loader/windows/OpenCL.def similarity index 62% rename from OpenCL.def rename to loader/windows/OpenCL.def index 08715223..ed451bf4 100644 --- a/OpenCL.def +++ b/loader/windows/OpenCL.def @@ -1,36 +1,17 @@ ; -; Copyright (c) 2016 The Khronos Group Inc. +; Copyright (c) 2016-2019 The Khronos Group Inc. ; -; Permission is hereby granted, free of charge, to any person obtaining a copy -; of this software source and associated documentation files (the "Materials"), -; to deal in the Materials without restriction, including without limitation -; the rights to use, copy, modify, compile, merge, publish, distribute, -; sublicense, and/or sell copies of the Materials, and to permit persons to -; whom the Materials are furnished to do so, subject the following terms and -; conditions: +; Licensed under the Apache License, Version 2.0 (the "License"); +; you may not use this file except in compliance with the License. +; You may obtain a copy of the License at ; -; All modifications to the Materials used to create a binary that is -; distributed to third parties shall be provided to Khronos with an -; unrestricted license to use for the purposes of implementing bug fixes and -; enhancements to the Materials; +; http://www.apache.org/licenses/LICENSE-2.0 ; -; If the binary is used as part of an OpenCL(TM) implementation, whether binary -; is distributed together with or separately to that implementation, then -; recipient must become an OpenCL Adopter and follow the published OpenCL -; conformance process for that implementation, details at: -; http://www.khronos.org/conformance/; -; -; The above copyright notice, the OpenCL trademark license, and this permission -; notice shall be included in all copies or substantial portions of the -; Materials. -; -; THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -; OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN -; THE MATERIALS. +; Unless required by applicable law or agreed to in writing, software +; distributed under the License is distributed on an "AS IS" BASIS, +; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +; See the License for the specific language governing permissions and +; limitations under the License. ; ; OpenCL is a trademark of Apple Inc. used under license by Khronos. @@ -179,3 +160,7 @@ clSetDefaultDeviceCommandQueue clSetProgramReleaseCallback clSetProgramSpecializationConstant +; OpenCL 3.0 API +clCreateBufferWithProperties +clCreateImageWithProperties +clSetContextDestructorCallback diff --git a/loader/windows/OpenCL.rc b/loader/windows/OpenCL.rc new file mode 100644 index 00000000..7c44cd4b --- /dev/null +++ b/loader/windows/OpenCL.rc @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016-2023 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#include +#include + +#ifdef RC_INVOKED + +VS_VERSION_INFO VERSIONINFO +FILEVERSION OPENCL_ICD_LOADER_VERSION_MAJOR,OPENCL_ICD_LOADER_VERSION_MINOR,OPENCL_ICD_LOADER_VERSION_REV,0 +PRODUCTVERSION OPENCL_ICD_LOADER_VERSION_MAJOR,OPENCL_ICD_LOADER_VERSION_MINOR,OPENCL_ICD_LOADER_VERSION_REV,0 +FILETYPE VFT_DLL + +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + BEGIN + VALUE "FileDescription" ,"OpenCL Client DLL" + VALUE "ProductName" ,OPENCL_ICD_LOADER_NAME_STRING + VALUE "LegalCopyright" ,L"Copyright \251 The Khronos Group Inc 2016-2023" + VALUE "FileVersion" ,OPENCL_ICD_LOADER_VERSION_STRING ".0" + VALUE "CompanyName" ,OPENCL_ICD_LOADER_VENDOR_STRING + VALUE "InternalName" ,"OpenCL" + VALUE "OriginalFilename","OpenCL.dll" + END + END + + BLOCK "VarFileInfo" + BEGIN + // extend this line for localized versions + VALUE "Translation", 0x0409, 0x04E4 + END +END + +#endif + diff --git a/loader/windows/adapter.h b/loader/windows/adapter.h new file mode 100644 index 00000000..ef97d665 --- /dev/null +++ b/loader/windows/adapter.h @@ -0,0 +1,80 @@ +/* +* Copyright (c) 2019 The Khronos Group Inc. +* Copyright (c) 2019 Valve Corporation +* Copyright (c) 2019 LunarG, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Author: Lenny Komow +*/ + +typedef struct LoaderEnumAdapters2 { + ULONG adapter_count; + struct { + UINT handle; + LUID luid; + ULONG source_count; + BOOL present_move_regions_preferred; + } * adapters; +} LoaderEnumAdapters2; + +typedef _Check_return_ NTSTATUS(APIENTRY *PFN_LoaderEnumAdapters2)(const LoaderEnumAdapters2 *); + +typedef enum AdapterInfoType { + LOADER_QUERY_TYPE_REGISTRY = 48, +} AdapterInfoType; + +typedef struct LoaderQueryAdapterInfo { + UINT handle; + AdapterInfoType type; + VOID *private_data; + UINT private_data_size; +} LoaderQueryAdapterInfo; + +typedef _Check_return_ NTSTATUS(APIENTRY *PFN_LoaderQueryAdapterInfo)(const LoaderQueryAdapterInfo *); + +typedef enum LoaderQueryRegistryType { + LOADER_QUERY_REGISTRY_ADAPTER_KEY = 1, +} LoaderQueryRegistryType; + +typedef enum LoaderQueryRegistryStatus { + LOADER_QUERY_REGISTRY_STATUS_SUCCESS = 0, + LOADER_QUERY_REGISTRY_STATUS_BUFFER_OVERFLOW = 1, +} LoaderQueryRegistryStatus; + +typedef struct LoaderQueryRegistryFlags { + union { + struct { + UINT translate_path : 1; + UINT mutable_value : 1; + UINT reserved : 30; + }; + UINT value; + }; +} LoaderQueryRegistryFlags; + +typedef struct LoaderQueryRegistryInfo { + LoaderQueryRegistryType query_type; + LoaderQueryRegistryFlags query_flags; + WCHAR value_name[MAX_PATH]; + ULONG value_type; + ULONG physical_adapter_index; + ULONG output_value_size; + LoaderQueryRegistryStatus status; + union { + DWORD output_dword; + UINT64 output_qword; + WCHAR output_string[1]; + BYTE output_binary[1]; + }; +} LoaderQueryRegistryInfo; diff --git a/loader/windows/icd_windows.c b/loader/windows/icd_windows.c new file mode 100644 index 00000000..a92a999d --- /dev/null +++ b/loader/windows/icd_windows.c @@ -0,0 +1,449 @@ +/* + * Copyright (c) 2016-2020 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#include + +#include "icd.h" +#include "icd_windows.h" +#include "icd_windows_hkr.h" +#include "icd_windows_dxgk.h" +#include "icd_windows_apppackage.h" +#include +#include +#include +#include + +#include +typedef HRESULT (WINAPI *PFN_CREATE_DXGI_FACTORY)(REFIID, void **); + +static INIT_ONCE initialized = INIT_ONCE_STATIC_INIT; + +typedef struct WinAdapter +{ + char * szName; + LUID luid; +} WinAdapter; + +const LUID ZeroLuid = { 0, 0 }; + +static WinAdapter* pWinAdapterBegin = NULL; +static WinAdapter* pWinAdapterEnd = NULL; +static WinAdapter* pWinAdapterCapacity = NULL; + +BOOL adapterAdd(const char* szName, LUID luid) +{ + BOOL result = TRUE; + if (pWinAdapterEnd == pWinAdapterCapacity) + { + size_t oldCapacity = pWinAdapterCapacity - pWinAdapterBegin; + size_t newCapacity = oldCapacity; + if (0 == newCapacity) + { + newCapacity = 1; + } + else if(newCapacity < UINT_MAX/2) + { + newCapacity *= 2; + } + + WinAdapter* pNewBegin = malloc(newCapacity * sizeof(*pWinAdapterBegin)); + if (!pNewBegin) + result = FALSE; + else + { + if (pWinAdapterBegin) + { + memcpy(pNewBegin, pWinAdapterBegin, oldCapacity * sizeof(*pWinAdapterBegin)); + free(pWinAdapterBegin); + } + pWinAdapterCapacity = pNewBegin + newCapacity; + pWinAdapterEnd = pNewBegin + oldCapacity; + pWinAdapterBegin = pNewBegin; + } + } + if (pWinAdapterEnd != pWinAdapterCapacity) + { + size_t nameLen = (strlen(szName) + 1)*sizeof(szName[0]); + pWinAdapterEnd->szName = malloc(nameLen); + if (!pWinAdapterEnd->szName) + result = FALSE; + else + { + memcpy(pWinAdapterEnd->szName, szName, nameLen); + pWinAdapterEnd->luid = luid; + ++pWinAdapterEnd; + } + } + return result; +} + +void adapterFree(WinAdapter *pWinAdapter) +{ + free(pWinAdapter->szName); + pWinAdapter->szName = NULL; +} + +#if defined(CL_ENABLE_LAYERS) +typedef struct WinLayer +{ + char * szName; + DWORD priority; +} WinLayer; + +static WinLayer* pWinLayerBegin; +static WinLayer* pWinLayerEnd; +static WinLayer* pWinLayerCapacity; + +static int __cdecl compareLayer(const void *a, const void *b) +{ + return ((const WinLayer *)a)->priority < ((const WinLayer *)b)->priority ? -1 : + ((const WinLayer *)a)->priority > ((const WinLayer *)b)->priority ? 1 : 0; +} + +static BOOL layerAdd(const char* szName, DWORD priority) +{ + BOOL result = TRUE; + if (pWinLayerEnd == pWinLayerCapacity) + { + size_t oldCapacity = pWinLayerCapacity - pWinLayerBegin; + size_t newCapacity = oldCapacity; + if (0 == newCapacity) + { + newCapacity = 1; + } + else if(newCapacity < UINT_MAX/2) + { + newCapacity *= 2; + } + + WinLayer* pNewBegin = malloc(newCapacity * sizeof(*pWinLayerBegin)); + if (!pNewBegin) + { + KHR_ICD_TRACE("Failed allocate space for Layers array\n"); + result = FALSE; + } + else + { + if (pWinLayerBegin) + { + memcpy(pNewBegin, pWinLayerBegin, oldCapacity * sizeof(*pWinLayerBegin)); + free(pWinLayerBegin); + } + pWinLayerCapacity = pNewBegin + newCapacity; + pWinLayerEnd = pNewBegin + oldCapacity; + pWinLayerBegin = pNewBegin; + } + } + if (pWinLayerEnd != pWinLayerCapacity) + { + size_t nameLen = (strlen(szName) + 1)*sizeof(szName[0]); + pWinLayerEnd->szName = malloc(nameLen); + if (!pWinLayerEnd->szName) + { + KHR_ICD_TRACE("Failed allocate space for Layer file path\n"); + result = FALSE; + } + else + { + memcpy(pWinLayerEnd->szName, szName, nameLen); + pWinLayerEnd->priority = priority; + ++pWinLayerEnd; + } + } + return result; +} + +void layerFree(WinLayer *pWinLayer) +{ + free(pWinLayer->szName); + pWinLayer->szName = NULL; +} +#endif // defined(CL_ENABLE_LAYERS) + +/* + * + * Vendor enumeration functions + * + */ + +// go through the list of vendors in the registry and call khrIcdVendorAdd +// for each vendor encountered +BOOL CALLBACK khrIcdOsVendorsEnumerate(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *lpContext) +{ + (void)InitOnce; + (void)Parameter; + (void)lpContext; + + LONG result; + BOOL status = FALSE, currentStatus = FALSE; + const char* platformsName = "SOFTWARE\\Khronos\\OpenCL\\Vendors"; + HKEY platformsKey = NULL; + DWORD dwIndex; + + khrIcdInitializeTrace(); + khrIcdVendorsEnumerateEnv(); + + currentStatus = khrIcdOsVendorsEnumerateDXGK(); + status |= currentStatus; + if (!currentStatus) + { + KHR_ICD_TRACE("Failed to load via DXGK interface on RS4, continuing\n"); + } + + currentStatus = khrIcdOsVendorsEnumerateHKR(); + status |= currentStatus; + if (!currentStatus) + { + KHR_ICD_TRACE("Failed to enumerate HKR entries, continuing\n"); + } + + currentStatus = khrIcdOsVendorsEnumerateAppPackage(); + status |= currentStatus; + if (!currentStatus) + { + KHR_ICD_TRACE("Failed to enumerate App package entry, continuing\n"); + } + + KHR_ICD_TRACE("Opening key HKLM\\%s...\n", platformsName); + result = RegOpenKeyExA( + HKEY_LOCAL_MACHINE, + platformsName, + 0, + KEY_READ, + &platformsKey); + if (ERROR_SUCCESS != result) + { + KHR_ICD_TRACE("Failed to open platforms key %s, continuing\n", platformsName); + } + else + { + // for each value + for (dwIndex = 0;; ++dwIndex) + { + char cszLibraryName[1024] = {0}; + DWORD dwLibraryNameSize = sizeof(cszLibraryName); + DWORD dwLibraryNameType = 0; + DWORD dwValue = 0; + DWORD dwValueSize = sizeof(dwValue); + + // read the value name + KHR_ICD_TRACE("Reading value %"PRIuDW"...\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 %"PRIuDW", 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 + status |= adapterAdd(cszLibraryName, ZeroLuid); + } + } + + // Add adapters according to DXGI's preference order + HMODULE hDXGI = LoadLibraryA("dxgi.dll"); + if (hDXGI) + { + IDXGIFactory* pFactory = NULL; + PFN_CREATE_DXGI_FACTORY pCreateDXGIFactory = (PFN_CREATE_DXGI_FACTORY)(void*)GetProcAddress(hDXGI, "CreateDXGIFactory"); + if (pCreateDXGIFactory) + { + HRESULT hr = pCreateDXGIFactory(&IID_IDXGIFactory, (void **)&pFactory); + if (SUCCEEDED(hr)) + { + UINT i = 0; + IDXGIAdapter* pAdapter = NULL; + while (SUCCEEDED(pFactory->lpVtbl->EnumAdapters(pFactory, i++, &pAdapter))) + { + DXGI_ADAPTER_DESC AdapterDesc; + if (SUCCEEDED(pAdapter->lpVtbl->GetDesc(pAdapter, &AdapterDesc))) + { + for (WinAdapter* iterAdapter = pWinAdapterBegin; iterAdapter != pWinAdapterEnd; ++iterAdapter) + { + if (iterAdapter->luid.LowPart == AdapterDesc.AdapterLuid.LowPart + && iterAdapter->luid.HighPart == AdapterDesc.AdapterLuid.HighPart) + { + khrIcdVendorAdd(iterAdapter->szName); + break; + } + } + } + + pAdapter->lpVtbl->Release(pAdapter); + } + pFactory->lpVtbl->Release(pFactory); + } + } + FreeLibrary(hDXGI); + } + + // Go through the list again, putting any remaining adapters at the end of the list in an undefined order + for (WinAdapter* iterAdapter = pWinAdapterBegin; iterAdapter != pWinAdapterEnd; ++iterAdapter) + { + khrIcdVendorAdd(iterAdapter->szName); + adapterFree(iterAdapter); + } + + free(pWinAdapterBegin); + pWinAdapterBegin = NULL; + pWinAdapterEnd = NULL; + pWinAdapterCapacity = NULL; + + result = RegCloseKey(platformsKey); + if (ERROR_SUCCESS != result) + { + KHR_ICD_TRACE("Failed to close platforms key %s, ignoring\n", platformsName); + } + +#if defined(CL_ENABLE_LAYERS) + const char* layersName = "SOFTWARE\\Khronos\\OpenCL\\Layers"; + HKEY layersKey = NULL; + + KHR_ICD_TRACE("Opening key HKLM\\%s...\n", layersName); + result = RegOpenKeyExA( + HKEY_LOCAL_MACHINE, + layersName, + 0, + KEY_READ, + &layersKey); + if (ERROR_SUCCESS != result) + { + KHR_ICD_TRACE("Failed to open layers key %s, continuing\n", layersName); + } + else + { + // for each value + for (dwIndex = 0;; ++dwIndex) + { + char cszLibraryName[1024] = {0}; + DWORD dwLibraryNameSize = sizeof(cszLibraryName); + DWORD dwLibraryNameType = 0; + DWORD dwValue = 0; + DWORD dwValueSize = sizeof(dwValue); + + // read the value name + KHR_ICD_TRACE("Reading value %"PRIuDW"...\n", dwIndex); + result = RegEnumValueA( + layersKey, + 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 %"PRIuDW", done reading key.\n", dwIndex); + break; + } + KHR_ICD_TRACE("Value %s found...\n", cszLibraryName); + + // Require that the value be a DWORD + if (REG_DWORD != dwLibraryNameType) + { + KHR_ICD_TRACE("Value not a DWORD, skipping\n"); + continue; + } + // add the library + status |= layerAdd(cszLibraryName, dwValue); + } + qsort(pWinLayerBegin, pWinLayerEnd - pWinLayerBegin, sizeof(WinLayer), compareLayer); + for (WinLayer* iterLayer = pWinLayerBegin; iterLayer != pWinLayerEnd; ++iterLayer) + { + khrIcdLayerAdd(iterLayer->szName); + layerFree(iterLayer); + } + } + + free(pWinLayerBegin); + pWinLayerBegin = NULL; + pWinLayerEnd = NULL; + pWinLayerCapacity = NULL; + + result = RegCloseKey(layersKey); + + khrIcdLayersEnumerateEnv(); +#endif // defined(CL_ENABLE_LAYERS) + return status; +} + +// go through the list of vendors only once +void khrIcdOsVendorsEnumerateOnce() +{ + InitOnceExecuteOnce(&initialized, khrIcdOsVendorsEnumerate, NULL, NULL); +} + +/* + * + * Dynamic library loading functions + * + */ + +// dynamically load a library. returns NULL on failure +void *khrIcdOsLibraryLoad(const char *libraryName) +{ + HMODULE hTemp = LoadLibraryExA(libraryName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); + if (!hTemp && GetLastError() == ERROR_INVALID_PARAMETER) + { + hTemp = LoadLibraryExA(libraryName, NULL, 0); + } + if (!hTemp) + { + KHR_ICD_TRACE("Failed to load driver. Windows error code is %"PRIuDW".\n", GetLastError()); + } + return (void*)hTemp; +} + +// get a function pointer from a loaded library. returns NULL on failure. +void *khrIcdOsLibraryGetFunctionAddress(void *library, const char *functionName) +{ + if (!library || !functionName) + { + return NULL; + } + return GetProcAddress( (HMODULE)library, functionName); +} + +// unload a library. +void khrIcdOsLibraryUnload(void *library) +{ + FreeLibrary( (HMODULE)library); +} diff --git a/loader/windows/icd_windows.h b/loader/windows/icd_windows.h new file mode 100644 index 00000000..c25b13fe --- /dev/null +++ b/loader/windows/icd_windows.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2017-2019 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#include +#include + +#ifdef _LP64 +#define PRIDW_PREFIX +#define PRIUL_PREFIX +#else +#define PRIDW_PREFIX "l" +#define PRIUL_PREFIX "l" +#endif +#define PRIuDW PRIDW_PREFIX "u" +#define PRIxDW PRIDW_PREFIX "x" +#define PRIuUL PRIUL_PREFIX "u" +#define PRIxUL PRIUL_PREFIX "x" + +#ifdef __cplusplus +extern "C" { +#endif +extern const LUID ZeroLuid; + +BOOL adapterAdd(const char* szName, LUID luid); + +// Do not free the memory returned by this function. +const char* getOpenCLRegKeyName(void); + +#ifdef __cplusplus +} +#endif diff --git a/loader/windows/icd_windows_apppackage.c b/loader/windows/icd_windows_apppackage.c new file mode 100644 index 00000000..4fe57817 --- /dev/null +++ b/loader/windows/icd_windows_apppackage.c @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2017-2022 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#include +#include "icd_windows_apppackage.h" + +typedef _Check_return_ LONG(WINAPI *PFN_GetPackagesByPackageFamily)( + _In_ PCWSTR packageFamilyName, + _Inout_ UINT32* count, + _Out_writes_opt_(*count) PWSTR* packageFullNames, + _Inout_ UINT32* bufferLength, + _Out_writes_opt_(*bufferLength) WCHAR* buffer + ); + +typedef LONG (WINAPI *PFN_GetPackagePathByFullName)( + _In_ PCWSTR packageFullName, + _Inout_ UINT32* pathLength, + _Out_writes_opt_(*pathLength) PWSTR path + ); + +bool khrIcdOsVendorsEnumerateAppPackage(void) +{ + bool ret = false; + WCHAR *buffer = NULL; + PWSTR *packages = NULL; + + HMODULE h = LoadLibraryA("kernel32.dll"); + if (h == NULL) + return ret; + + PFN_GetPackagesByPackageFamily pGetPackagesByPackageFamily = + (PFN_GetPackagesByPackageFamily)(void*)GetProcAddress(h, "GetPackagesByPackageFamily"); + if (!pGetPackagesByPackageFamily) + { + KHR_ICD_TRACE("GetProcAddress failed for GetPackagesByPackageFamily\n"); + goto cleanup; + } + + PFN_GetPackagePathByFullName pGetPackagePathByFullName = + (PFN_GetPackagePathByFullName)(void*)GetProcAddress(h, "GetPackagePathByFullName"); + if (!pGetPackagePathByFullName) + { + KHR_ICD_TRACE("GetProcAddress failed for GetPackagePathByFullName\n"); + goto cleanup; + } + + UINT32 numPackages = 0, bufferLength = 0; + PCWSTR familyName = L"Microsoft.D3DMappingLayers_8wekyb3d8bbwe"; + if (ERROR_INSUFFICIENT_BUFFER != pGetPackagesByPackageFamily(familyName, + &numPackages, NULL, + &bufferLength, NULL) || + numPackages == 0 || bufferLength == 0) + { + KHR_ICD_TRACE("Failed to find mapping layers packages by family name\n"); + goto cleanup; + } + + buffer = malloc(sizeof(WCHAR) * bufferLength); + packages = malloc(sizeof(PWSTR) * numPackages); + if (!buffer || !packages) + { + KHR_ICD_TRACE("Failed to allocate memory for package names\n"); + goto cleanup; + } + + if (ERROR_SUCCESS != pGetPackagesByPackageFamily(familyName, + &numPackages, packages, + &bufferLength, buffer)) + { + KHR_ICD_TRACE("Failed to get mapping layers package full names\n"); + goto cleanup; + } + + UINT32 pathLength = 0; + WCHAR path[MAX_PATH]; + if (ERROR_INSUFFICIENT_BUFFER != pGetPackagePathByFullName(packages[0], &pathLength, NULL) || + pathLength > MAX_PATH || + ERROR_SUCCESS != pGetPackagePathByFullName(packages[0], &pathLength, path)) + { + KHR_ICD_TRACE("Failed to get mapping layers package path length\n"); + goto cleanup; + } + +#if defined(_M_AMD64) +#define PLATFORM_PATH L"x64" +#elif defined(_M_ARM) +#define PLATFORM_PATH L"arm" +#elif defined(_M_ARM64) +#define PLATFORM_PATH L"arm64" +#elif defined(_M_IX86) +#define PLATFORM_PATH L"x86" +#endif + + wchar_t dllPath[MAX_PATH]; + wcscpy_s(dllPath, MAX_PATH, path); + wcscat_s(dllPath, MAX_PATH, L"\\" PLATFORM_PATH L"\\OpenCLOn12.dll"); + + char narrowDllPath[MAX_PATH]; + WideCharToMultiByte(CP_UTF8, 0, dllPath, -1, narrowDllPath, MAX_PATH, NULL, NULL); + + ret = adapterAdd(narrowDllPath, ZeroLuid); + +cleanup: + FreeLibrary(h); + free(buffer); + free(packages); + return ret; +} diff --git a/loader/windows/icd_windows_apppackage.h b/loader/windows/icd_windows_apppackage.h new file mode 100644 index 00000000..5419ad45 --- /dev/null +++ b/loader/windows/icd_windows_apppackage.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2017-2019 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#include +#include "icd_windows.h" + +bool khrIcdOsVendorsEnumerateAppPackage(void); diff --git a/loader/windows/icd_windows_dxgk.c b/loader/windows/icd_windows_dxgk.c new file mode 100644 index 00000000..efaba5ba --- /dev/null +++ b/loader/windows/icd_windows_dxgk.c @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2017-2020 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#include "icd.h" +#include "icd_windows_dxgk.h" + +#include +#include "adapter.h" + +#ifndef NTSTATUS +typedef LONG NTSTATUS; +#define STATUS_SUCCESS ((NTSTATUS)0x00000000L) +#define STATUS_BUFFER_TOO_SMALL ((NTSTATUS)0xC0000023) +#define NT_SUCCESS(status) (((NTSTATUS)(status)) >= 0) +#endif + +bool khrIcdOsVendorsEnumerateDXGK(void) +{ + bool ret = false; + int result = 0; + + // Get handle to GDI Runtime + HMODULE h = LoadLibraryA("gdi32.dll"); + if (h == NULL) + return ret; + + if(GetProcAddress(h, "D3DKMTSubmitPresentBltToHwQueue")) // OS Version check + { + LoaderEnumAdapters2 EnumAdapters; + NTSTATUS status = STATUS_SUCCESS; + + EnumAdapters.adapter_count = 0; + EnumAdapters.adapters = NULL; + PFN_LoaderEnumAdapters2 pEnumAdapters2 = (PFN_LoaderEnumAdapters2)(void*)GetProcAddress(h, "D3DKMTEnumAdapters2"); + if (!pEnumAdapters2) + { + KHR_ICD_TRACE("GetProcAddress failed for D3DKMTEnumAdapters2\n"); + goto out; + } + PFN_LoaderQueryAdapterInfo pQueryAdapterInfo = (PFN_LoaderQueryAdapterInfo)(void*)GetProcAddress(h, "D3DKMTQueryAdapterInfo"); + if (!pQueryAdapterInfo) + { + KHR_ICD_TRACE("GetProcAddress failed for D3DKMTQueryAdapterInfo\n"); + goto out; + } + while (1) + { + EnumAdapters.adapter_count = 0; + EnumAdapters.adapters = NULL; + status = pEnumAdapters2(&EnumAdapters); + if (status == STATUS_BUFFER_TOO_SMALL) + { + // Number of Adapters increased between calls, retry; + continue; + } + else if (!NT_SUCCESS(status)) + { + KHR_ICD_TRACE("D3DKMTEnumAdapters2 status != SUCCESS\n"); + goto out; + } + break; + } + EnumAdapters.adapters = malloc(sizeof(*EnumAdapters.adapters)*(EnumAdapters.adapter_count)); + if (EnumAdapters.adapters == NULL) + { + KHR_ICD_TRACE("Allocation failure for adapters buffer\n"); + goto out; + } + status = pEnumAdapters2(&EnumAdapters); + if (!NT_SUCCESS(status)) + { + KHR_ICD_TRACE("D3DKMTEnumAdapters2 status != SUCCESS\n"); + goto out; + } + const char* cszOpenCLRegKeyName = getOpenCLRegKeyName(); + const int szOpenCLRegKeyName = (int)(strlen(cszOpenCLRegKeyName) + 1)*sizeof(cszOpenCLRegKeyName[0]); + for (UINT AdapterIndex = 0; AdapterIndex < EnumAdapters.adapter_count; AdapterIndex++) + { + LoaderQueryRegistryInfo queryArgs = {0}; + LoaderQueryRegistryInfo* pQueryArgs = &queryArgs; + LoaderQueryRegistryInfo* pQueryBuffer = NULL; + queryArgs.query_type = LOADER_QUERY_REGISTRY_ADAPTER_KEY; + queryArgs.query_flags.translate_path = TRUE; + queryArgs.value_type = REG_SZ; + result = MultiByteToWideChar( + CP_UTF8, + 0, + cszOpenCLRegKeyName, + szOpenCLRegKeyName, + queryArgs.value_name, + ARRAYSIZE(queryArgs.value_name)); + if (!result) + { + KHR_ICD_TRACE("MultiByteToWideChar status != SUCCESS\n"); + continue; + } + LoaderQueryAdapterInfo queryAdapterInfo = {0}; + queryAdapterInfo.handle = EnumAdapters.adapters[AdapterIndex].handle; + queryAdapterInfo.type = LOADER_QUERY_TYPE_REGISTRY; + queryAdapterInfo.private_data = &queryArgs; + queryAdapterInfo.private_data_size = sizeof(queryArgs); + status = pQueryAdapterInfo(&queryAdapterInfo); + if (!NT_SUCCESS(status)) + { + // Try a different value type. Some vendors write the key as a multi-string type. + queryArgs.value_type = REG_MULTI_SZ; + status = pQueryAdapterInfo(&queryAdapterInfo); + if (NT_SUCCESS(status)) + { + KHR_ICD_TRACE("Accepting multi-string registry key type\n"); + } + else + { + // Continue trying to get as much info on each adapter as possible. + // It's too late to return FALSE and claim WDDM2_4 enumeration is not available here. + continue; + } + } + if (NT_SUCCESS(status) && pQueryArgs->status == LOADER_QUERY_REGISTRY_STATUS_BUFFER_OVERFLOW) + { + ULONG queryBufferSize = sizeof(LoaderQueryRegistryInfo) + queryArgs.output_value_size; + pQueryBuffer = malloc(queryBufferSize); + if (pQueryBuffer == NULL) + continue; + memcpy(pQueryBuffer, &queryArgs, sizeof(LoaderQueryRegistryInfo)); + queryAdapterInfo.private_data = pQueryBuffer; + queryAdapterInfo.private_data_size = queryBufferSize; + status = pQueryAdapterInfo(&queryAdapterInfo); + pQueryArgs = pQueryBuffer; + } + if (NT_SUCCESS(status) && pQueryArgs->status == LOADER_QUERY_REGISTRY_STATUS_SUCCESS) + { + char cszLibraryName[MAX_PATH]; + result = WideCharToMultiByte( + CP_UTF8, + 0, + pQueryArgs->output_string, + -1, + cszLibraryName, + MAX_PATH, + NULL, + NULL); + if (!result) + { + KHR_ICD_TRACE("WideCharToMultiByte status != SUCCESS\n"); + } + else + { + ret |= adapterAdd(cszLibraryName, EnumAdapters.adapters[AdapterIndex].luid); + } + } + else if (status == (NTSTATUS)STATUS_INVALID_PARAMETER) + { + free(pQueryBuffer); + goto out; + } + free(pQueryBuffer); + } +out: + free(EnumAdapters.adapters); + } + + FreeLibrary(h); + + return ret; +} diff --git a/loader/windows/icd_windows_dxgk.h b/loader/windows/icd_windows_dxgk.h new file mode 100644 index 00000000..34bad64a --- /dev/null +++ b/loader/windows/icd_windows_dxgk.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2017-2019 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#include +#include "icd_windows.h" + +bool khrIcdOsVendorsEnumerateDXGK(void); diff --git a/loader/windows/icd_windows_envvars.c b/loader/windows/icd_windows_envvars.c new file mode 100644 index 00000000..3c175199 --- /dev/null +++ b/loader/windows/icd_windows_envvars.c @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2016-2019 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#include +#include +#include + +char *khrIcd_getenv(const char *name) { + char *retVal; + DWORD valSize; + + valSize = GetEnvironmentVariableA(name, NULL, 0); + + // valSize DOES include the null terminator, so for any set variable + // will always be at least 1. If it's 0, the variable wasn't set. + if (valSize == 0) return NULL; + + // Allocate the space necessary for the registry entry + retVal = (char *)malloc(valSize); + + if (NULL != retVal) { + GetEnvironmentVariableA(name, retVal, valSize); + } + + return retVal; +} + +static bool khrIcd_IsHighIntegrityLevel() +{ + bool isHighIntegrityLevel = false; + + HANDLE processToken; + if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY | TOKEN_QUERY_SOURCE, &processToken)) { + // Maximum possible size of SID_AND_ATTRIBUTES is maximum size of a SID + size of attributes DWORD. + char mandatoryLabelBuffer[SECURITY_MAX_SID_SIZE + sizeof(DWORD)] = {0}; + DWORD bufferSize; + if (GetTokenInformation(processToken, TokenIntegrityLevel, mandatoryLabelBuffer, sizeof(mandatoryLabelBuffer), + &bufferSize) != 0) { + const TOKEN_MANDATORY_LABEL* mandatoryLabel = (const TOKEN_MANDATORY_LABEL*)(mandatoryLabelBuffer); + const DWORD subAuthorityCount = *GetSidSubAuthorityCount(mandatoryLabel->Label.Sid); + const DWORD integrityLevel = *GetSidSubAuthority(mandatoryLabel->Label.Sid, subAuthorityCount - 1); + + isHighIntegrityLevel = integrityLevel > SECURITY_MANDATORY_MEDIUM_RID; + } + + CloseHandle(processToken); + } + + return isHighIntegrityLevel; +} + +char *khrIcd_secure_getenv(const char *name) { + if (khrIcd_IsHighIntegrityLevel()) { + KHR_ICD_TRACE("Running at a high integrity level, so secure_getenv is returning NULL\n"); + return NULL; + } + + return khrIcd_getenv(name); +} + +void khrIcd_free_getenv(char *val) { + free((void *)val); +} diff --git a/icd_windows_hkr.c b/loader/windows/icd_windows_hkr.c similarity index 71% rename from icd_windows_hkr.c rename to loader/windows/icd_windows_hkr.c index 1e1f766a..ae4ba163 100644 --- a/icd_windows_hkr.c +++ b/loader/windows/icd_windows_hkr.c @@ -1,36 +1,17 @@ /* - * Copyright (c) 2017 The Khronos Group Inc. + * Copyright (c) 2017-2022 The Khronos Group Inc. * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software source and associated documentation files (the "Materials"), - * to deal in the Materials without restriction, including without limitation - * the rights to use, copy, modify, compile, merge, publish, distribute, - * sublicense, and/or sell copies of the Materials, and to permit persons to - * whom the Materials are furnished to do so, subject the following terms and - * conditions: + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * All modifications to the Materials used to create a binary that is - * distributed to third parties shall be provided to Khronos with an - * unrestricted license to use for the purposes of implementing bug fixes and - * enhancements to the Materials; + * http://www.apache.org/licenses/LICENSE-2.0 * - * If the binary is used as part of an OpenCL(TM) implementation, whether binary - * is distributed together with or separately to that implementation, then - * recipient must become an OpenCL Adopter and follow the published OpenCL - * conformance process for that implementation, details at: - * http://www.khronos.org/conformance/; - * - * The above copyright notice, the OpenCL trademark license, and this permission - * notice shall be included in all copies or substantial portions of the - * Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN - * THE MATERIALS. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * * OpenCL is a trademark of Apple Inc. used under license by Khronos. */ @@ -38,11 +19,12 @@ #include "icd.h" #include "icd_windows_hkr.h" #include +#include "icd_windows_dxgk.h" #include #include #include #include -#include +#include #include // This GUID was only added to devguid.h on Windows SDK v10.0.16232 which @@ -70,7 +52,7 @@ static const char OPENCL_REG_SUB_KEY_WOW[] = "OpenCLDriverNameWow"; #endif // Do not free the memory returned by this function. -static const char* GetOpenCLRegKeyName(void) +const char* getOpenCLRegKeyName(void) { #ifdef _WIN64 return OPENCL_REG_SUB_KEY; @@ -108,14 +90,14 @@ static bool ReadOpenCLKey(DEVINST dnDevNode) if (CR_SUCCESS != ret) { - KHR_ICD_TRACE("Failed with ret 0x%x\n", ret); + KHR_ICD_TRACE("Failed with ret 0x%"PRIxDW"\n", ret); goto out; } else { result = RegQueryValueExA( hkey, - GetOpenCLRegKeyName(), + getOpenCLRegKeyName(), NULL, &dwLibraryNameType, NULL, @@ -123,41 +105,46 @@ static bool ReadOpenCLKey(DEVINST dnDevNode) if (ERROR_SUCCESS != result) { - KHR_ICD_TRACE("Failed to open sub key 0x%x\n", result); + KHR_ICD_TRACE("Failed to open sub key 0x%"PRIxDW"\n", result); goto out; } cszOclPath = malloc(dwOclPathSize); if (NULL == cszOclPath) { - KHR_ICD_TRACE("Failed to allocate %u bytes for registry value\n", dwOclPathSize); + KHR_ICD_TRACE("Failed to allocate %"PRIuDW" bytes for registry value\n", dwOclPathSize); goto out; } result = RegQueryValueExA( hkey, - OPENCL_REG_SUB_KEY, + getOpenCLRegKeyName(), NULL, &dwLibraryNameType, (LPBYTE)cszOclPath, &dwOclPathSize); if (ERROR_SUCCESS != result) { - KHR_ICD_TRACE("Failed to open sub key 0x%x\n", result); + KHR_ICD_TRACE("Failed to open sub key 0x%"PRIxDW"\n", result); goto out; } if (REG_SZ != dwLibraryNameType) { - KHR_ICD_TRACE("Unexpected registry entry 0x%x! continuing\n", dwLibraryNameType); - goto out; + if (REG_MULTI_SZ == dwLibraryNameType) + { + KHR_ICD_TRACE("Accepting multi-string registry key type\n"); + } + else + { + KHR_ICD_TRACE("Unexpected registry entry 0x%"PRIxDW"! continuing\n", dwLibraryNameType); + goto out; + } } KHR_ICD_TRACE(" Path: %s\n", cszOclPath); - khrIcdVendorAdd(cszOclPath); - - bRet = true; + bRet |= adapterAdd(cszOclPath, ZeroLuid); } out: @@ -168,7 +155,7 @@ static bool ReadOpenCLKey(DEVINST dnDevNode) result = RegCloseKey(hkey); if (ERROR_SUCCESS != result) { - KHR_ICD_TRACE("WARNING: failed to close hkey 0x%x\n", result); + KHR_ICD_TRACE("WARNING: failed to close hkey 0x%"PRIxDW"\n", result); } } @@ -189,7 +176,7 @@ static DeviceProbeResult ProbeDevice(DEVINST devnode) if (CR_SUCCESS != ret) { - KHR_ICD_TRACE(" WARNING: failed to probe the status of the device 0x%x\n", ret); + KHR_ICD_TRACE(" WARNING: failed to probe the status of the device 0x%"PRIxDW"\n", ret); return ProbeFailure; } @@ -207,7 +194,7 @@ static DeviceProbeResult ProbeDevice(DEVINST devnode) if (((ulStatus & DN_HAS_PROBLEM) && ulProblem == CM_PROB_NEED_RESTART) || ulStatus & DN_NEED_RESTART) { - KHR_ICD_TRACE(" WARNING: device is pending reboot (0x%x), skipping...\n", ulStatus); + KHR_ICD_TRACE(" WARNING: device is pending reboot (0x%" PRIxUL "), skipping...\n", ulStatus); return PendingReboot; } @@ -227,8 +214,12 @@ bool khrIcdOsVendorsEnumerateHKR(void) ULONG szBuffer = 0; OLECHAR display_adapter_guid_str[MAX_GUID_STRING_LEN]; +#if defined(CM_GETIDLIST_FILTER_CLASS) && defined(CM_GETIDLIST_FILTER_PRESENT) ULONG ulFlags = CM_GETIDLIST_FILTER_CLASS | CM_GETIDLIST_FILTER_PRESENT; +#else + ULONG ulFlags = 0x300; +#endif iret = StringFromGUID2( &GUID_DEVCLASS_DISPLAY, @@ -252,7 +243,7 @@ bool khrIcdOsVendorsEnumerateHKR(void) if (CR_SUCCESS != ret) { - KHR_ICD_TRACE("CM_Get_Device_ID_List_size failed with 0x%x\n", ret); + KHR_ICD_TRACE("CM_Get_Device_ID_List_size failed with 0x%"PRIxDW"\n", ret); break; } @@ -264,7 +255,7 @@ bool khrIcdOsVendorsEnumerateHKR(void) deviceIdList = malloc(szBuffer * sizeof(wchar_t)); if (NULL == deviceIdList) { - KHR_ICD_TRACE("Failed to allocate %u bytes for device ID strings\n", szBuffer); + KHR_ICD_TRACE("Failed to allocate %" PRIuUL " bytes for device ID strings\n", szBuffer); break; } @@ -276,7 +267,7 @@ bool khrIcdOsVendorsEnumerateHKR(void) if (CR_SUCCESS != ret) { - KHR_ICD_TRACE("CM_Get_Device_ID_List failed with 0x%x\n", ret); + KHR_ICD_TRACE("CM_Get_Device_ID_List failed with 0x%"PRIxDW"\n", ret); KHR_SAFE_RELEASE(deviceIdList); } } while (CR_BUFFER_SMALL == ret); @@ -288,18 +279,16 @@ bool khrIcdOsVendorsEnumerateHKR(void) for (PWSTR deviceId = deviceIdList; *deviceId; deviceId += wcslen(deviceId) + 1) { - DEVPROPTYPE devpropType; - KHR_ICD_WIDE_TRACE(L"Device ID: %ls\n", deviceId); ret = CM_Locate_DevNodeW(&devinst, deviceId, 0); if (CR_SUCCESS == ret) { - KHR_ICD_TRACE(" devinst: %d\n", devinst); + KHR_ICD_TRACE(" devinst: %lu\n", devinst); } else { - KHR_ICD_TRACE("CM_Locate_DevNode failed with 0x%x\n", ret); + KHR_ICD_TRACE("CM_Locate_DevNode failed with 0x%"PRIxDW"\n", ret); continue; } @@ -324,7 +313,7 @@ bool khrIcdOsVendorsEnumerateHKR(void) if (CR_SUCCESS != ret) { - KHR_ICD_TRACE(" CM_Get_Child returned 0x%x, skipping children...\n", ret); + KHR_ICD_TRACE(" CM_Get_Child returned 0x%"PRIxDW", skipping children...\n", ret); } else { @@ -334,7 +323,7 @@ bool khrIcdOsVendorsEnumerateHKR(void) GUID guid; ULONG szGuid = sizeof(guid); - KHR_ICD_TRACE(" devchild: %d\n", devchild); + KHR_ICD_TRACE(" devchild: %lu\n", devchild); ret = CM_Get_Device_IDW( devchild, deviceInstanceID, @@ -343,7 +332,7 @@ bool khrIcdOsVendorsEnumerateHKR(void) if (CR_SUCCESS != ret) { - KHR_ICD_TRACE(" CM_Get_Device_ID returned 0x%x, skipping device...\n", ret); + KHR_ICD_TRACE(" CM_Get_Device_ID returned 0x%"PRIxDW", skipping device...\n", ret); continue; } else @@ -351,17 +340,22 @@ bool khrIcdOsVendorsEnumerateHKR(void) KHR_ICD_WIDE_TRACE(L" deviceInstanceID: %ls\n", deviceInstanceID); } - ret = CM_Get_DevNode_PropertyW( + ret = CM_Get_DevNode_Registry_PropertyW( devchild, - &DEVPKEY_Device_ClassGuid, - &devpropType, + CM_DRP_CLASSGUID, + NULL, (PBYTE)&guid, &szGuid, 0); - if (CR_SUCCESS != ret || - !IsEqualGUID(&OCL_GUID_DEVCLASS_SOFTWARECOMPONENT, &guid)) + if (CR_SUCCESS != ret) + { + KHR_ICD_TRACE(" CM_Get_DevNode_Registry_PropertyW returned 0x%"PRIxDW", skipping device...\n", ret); + continue; + } + else if (!IsEqualGUID(&OCL_GUID_DEVCLASS_SOFTWARECOMPONENT, &guid)) { + KHR_ICD_TRACE(" GUID does not match, skipping device...\n"); continue; } diff --git a/loader/windows/icd_windows_hkr.h b/loader/windows/icd_windows_hkr.h new file mode 100644 index 00000000..e0db713b --- /dev/null +++ b/loader/windows/icd_windows_hkr.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2017-2019 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#include +#include "icd_windows.h" + +bool khrIcdOsVendorsEnumerateHKR(void); diff --git a/scripts/.gitignore b/scripts/.gitignore new file mode 100644 index 00000000..01f6e380 --- /dev/null +++ b/scripts/.gitignore @@ -0,0 +1,2 @@ +gen/__pycache__ +*.c diff --git a/scripts/README.md b/scripts/README.md new file mode 100644 index 00000000..3da35475 --- /dev/null +++ b/scripts/README.md @@ -0,0 +1,35 @@ +# OpenCL ICD Loader Code Generation + +## Introduction + +In order to ease maintenance and enable faster development of related OpenCL ICD loader features, the OpenCL ICD loader API dispatch functions are generated from the OpenCL XML machine readable grammar. + +## Dependencies + +The API dispatch functions are generated using Python [Mako Templates](https://www.makotemplates.org/). + +In most cases, after installing Python for your platform, Mako may be installed using: + +```sh +$ pip install Mako +``` + +## Making Changes + +Most changes only require modifications to the Mako templates. +Small changes modifying syntax or layout are simple and straightforward. +Occasionally more complicated changes will be required, say when a new API is added that is unlike any previous API, but this should be rare. + +The Python script should only need to be modified if additional information needs to be propagated from the XML file into the Mako template itself. + +## Generating Files + +Files for the OpenCL ICD loader, or the test layer, may be generated by executing the scripts `gen_loader.py`, or `gen_print_layer.py`, respectively. + +The script requires the `cl.xml` machine readable grammar. +By default, the script searches for `cl.xml` in the current directory. +The latest version of `cl.xml` may be found in the Khronos OpenCL-Docs repo [here](https://github.com/KhronosGroup/OpenCL-Docs/blob/main/xml/cl.xml). + +The output from the script is placed in the current directory by default, to allow easy comparisons between the generated files and the current files. +After the generated files are evaluated, they should be manually copied into the source tree. +These steps may be automated in the future. diff --git a/scripts/gen/__init__.py b/scripts/gen/__init__.py new file mode 100644 index 00000000..0f54cb4f --- /dev/null +++ b/scripts/gen/__init__.py @@ -0,0 +1,130 @@ +# Copyright (c) 2020 The Khronos Group Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from collections import OrderedDict +from collections import namedtuple + +import argparse +import sys +import urllib +import xml.etree.ElementTree as etree +import urllib.request + +# parse_xml - Helper function to parse the XML file from a URL or local file. +def parse_xml(path): + file = urllib.request.urlopen(path) if path.startswith("http") else open(path, 'r') + with file: + tree = etree.parse(file) + return tree + +# noneStr - returns string argument, or "" if argument is None. +def noneStr(s): + if s: + return s + return "" + +def parse_args(): + parser = argparse.ArgumentParser() + + # To pull the latest registry file from GitHub, pass: + # -registry "https://raw.githubusercontent.com/KhronosGroup/OpenCL-Docs/main/xml/cl.xml" + + parser.add_argument('-registry', action='store', + default='cl.xml', + help='Use specified registry file instead of cl.xml') + parser.add_argument('-o', action='store', dest='directory', + default='.', + help='Create target and related files in specified directory') + + args = parser.parse_args() + return args + +def load_spec(args): + specpath = args.registry + + print('Parsing XML file from: ' + specpath) + spec = parse_xml(specpath) + return spec + +def get_apisigs(spec): + # Generate the API function signatures dictionary: + apisigs = OrderedDict() + ApiSignature = namedtuple('ApiSignature', 'Name RetType Params Suffix') + ApiParam = namedtuple('ApiParam', 'Type TypeEnd Name') + print('Generating API signatures dictionary...') + for command in spec.findall('commands/command'): + suffix = noneStr(command.get('suffix')) + proto = command.find('proto') + ret = noneStr(proto.text) + name = "" + params = "" + for elem in proto: + if elem.tag == 'name': + name = noneStr(elem.text) + noneStr(elem.tail) + else: + ret = ret + noneStr(elem.text) + noneStr(elem.tail) + ret = ret.strip() + name = name.strip() + + plist = [] + for param in command.findall('param'): + ptype = noneStr(param.text) + ptypeend = "" + pname = "" + for elem in param: + if elem.tag == 'name': + pname = noneStr(elem.text) + ptypeend = noneStr(elem.tail) + else: + ptype = ptype + noneStr(elem.text) + noneStr(elem.tail) + ptype = ptype.strip() + ptypeend = ptypeend.strip() + pname = pname.strip() + plist.append(ApiParam(ptype, ptypeend, pname)) + + # For an empty parameter list (for e.g. clUnloadCompiler), add a single + # unnamed void parameter to make generation easier. + if len(plist) == 0: + plist.append(ApiParam("void", "", "")) + + apisigs[name] = ApiSignature(name, ret, plist, suffix) + return apisigs + +def get_apis(spec, apisigs): + # Generate the core API dictionary: + coreapis = OrderedDict() + print('Generating core API dictionary...') + for feature in spec.findall('feature'): + version = noneStr(feature.get('name')) + + alist = [] + for function in feature.findall('require/command'): + name = function.get('name') + alist.append(apisigs[name]) + coreapis[version] = alist + + # Generate the extensions API dictionary: + extapis = OrderedDict() + print('Generating API extensions dictionary...') + for feature in spec.findall('extensions/extension'): + extension = noneStr(feature.get('name')) + + alist = [] + for function in feature.findall('require/command'): + name = function.get('name') + alist.append(apisigs[name]) + extapis[extension] = alist + return (coreapis, extapis) + + diff --git a/scripts/gen_loader.py b/scripts/gen_loader.py new file mode 100644 index 00000000..38f84f1e --- /dev/null +++ b/scripts/gen_loader.py @@ -0,0 +1,43 @@ +#!/usr/bin/python3 + +# Copyright (c) 2020 The Khronos Group Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import gen +from mako.template import Template +from mako.exceptions import RichTraceback + +if __name__ == "__main__": + args = gen.parse_args() + spec = gen.load_spec(args) + apisigs = gen.get_apisigs(spec) + (coreapis, extapis) = gen.get_apis(spec, apisigs) + + try: + # Create the loader cpp file from the API dictionary: + test = open(args.directory + '/icd_dispatch_generated.c', 'wb') + icd_dispatch_generated_template = Template(filename='icd_dispatch_generated.c.mako') + test.write( + icd_dispatch_generated_template.render_unicode( + spec=spec, + apisigs=apisigs, + coreapis=coreapis, + extapis=extapis). + encode('utf-8', 'replace')) + except: + traceback = RichTraceback() + for (filename, lineno, function, line) in traceback.traceback: + print('%s(%s) : error in %s' % (filename, lineno, function)) + print(' ', line) + print('%s: %s' % (str(traceback.error.__class__.__name__), traceback.error)) diff --git a/scripts/gen_print_layer.py b/scripts/gen_print_layer.py new file mode 100644 index 00000000..1a28883c --- /dev/null +++ b/scripts/gen_print_layer.py @@ -0,0 +1,43 @@ +#!/usr/bin/python3 + +# Copyright (c) 2020 The Khronos Group Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import gen +from mako.template import Template +from mako.exceptions import RichTraceback + +if __name__ == "__main__": + args = gen.parse_args() + spec = gen.load_spec(args) + apisigs = gen.get_apisigs(spec) + (coreapis, extapis) = gen.get_apis(spec, apisigs) + + try: + # Create the layer cpp file from the API dictionary: + test = open(args.directory + '/icd_print_layer_generated.c', 'wb') + icd_layer_generated_template = Template(filename='icd_print_layer_generated.c.mako') + test.write( + icd_layer_generated_template.render_unicode( + spec=spec, + apisigs=apisigs, + coreapis=coreapis, + extapis=extapis). + encode('utf-8', 'replace')) + except: + traceback = RichTraceback() + for (filename, lineno, function, line) in traceback.traceback: + print('%s(%s) : error in %s' % (filename, lineno, function)) + print(' ', line) + print('%s: %s' % (str(traceback.error.__class__.__name__), traceback.error)) diff --git a/scripts/icd_dispatch_generated.c.mako b/scripts/icd_dispatch_generated.c.mako new file mode 100644 index 00000000..d260af3d --- /dev/null +++ b/scripts/icd_dispatch_generated.c.mako @@ -0,0 +1,600 @@ +<% +# APIs to skip - they need to be done "manually": +apiskip = { + 'clGetPlatformIDs', # to query platforms + 'clGetExtensionFunctionAddress', # to return ICD-aware extensions + 'clGetExtensionFunctionAddressForPlatform', # to return ICD-aware extensions + } + +apiinit = { + 'clCreateContextFromType', + 'clGetGLContextInfoKHR', + } +# Handles, and mappings to errors when handles are invalid: +apihandles = { + 'cl_command_queue' : 'CL_INVALID_COMMAND_QUEUE', + 'cl_context' : 'CL_INVALID_CONTEXT', + 'cl_device_id' : 'CL_INVALID_DEVICE', + 'cl_event' : 'CL_INVALID_EVENT', + 'cl_kernel' : 'CL_INVALID_KERNEL', + 'cl_mem' : 'CL_INVALID_MEM_OBJECT', + 'cl_platform_id' : 'CL_INVALID_PLATFORM', + 'cl_program' : 'CL_INVALID_PROGRAM', + 'cl_sampler' : 'CL_INVALID_SAMPLER', + } +%>/* + * Copyright (c) 2012-2023 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#include "icd.h" +#include "icd_dispatch.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////// +// Core APIs: +%for apis in coreapis.values(): +%for api in apis: +%if not api.Name in apiskip: +<% + handle = api.Params[0] + if handle.Type in apihandles: + invalid = apihandles[handle.Type] + else: + invalid = 'NULL' +%> +%for disp in [0, 1]: +% if disp == 1: +#if defined(CL_ENABLE_LAYERS) +% endif +${("CL_API_ENTRY", "static")[disp]} ${api.RetType} CL_API_CALL ${api.Name + ("", "_disp")[disp]}( +%for i, param in enumerate(api.Params): +% if i < len(api.Params)-1: + ${param.Type} ${param.Name}${param.TypeEnd}, +% else: + ${param.Type} ${param.Name}${param.TypeEnd}) +% endif +%endfor +{ +%if api.Name in apiinit: + khrIcdInitialize(); +%endif +%if disp == 0: +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) +% if api.Name == "clSVMFree": + { + khrFirstLayer->dispatch.${api.Name}( +% else: + return khrFirstLayer->dispatch.${api.Name}( +% endif +%for i, param in enumerate(api.Params): +% if i < len(api.Params)-1: + ${param.Name}, +% else: + ${param.Name}); +% endif +%endfor +% if api.Name == "clSVMFree": + } + else +% endif +#endif // defined(CL_ENABLE_LAYERS) +%endif +%if api.RetType in apihandles or api.RetType == "void*": +## clCreateContext is a special case, since it calls through +## the dispatch table via the first "device": +% if api.Name == "clCreateContext": + if (${api.Params[1].Name} == 0 || ${api.Params[2].Name} == NULL) { + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(NULL, CL_INVALID_VALUE); + } + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(${api.Params[2].Name}[0], CL_INVALID_DEVICE); +## clCreateContextFromType is a special case, since it calls +## through a platform passed via properties: +% elif api.Name == "clCreateContextFromType": + cl_platform_id platform = NULL; + khrIcdContextPropertiesGetPlatform(properties, &platform); + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(platform, CL_INVALID_PLATFORM); +## These APIs are special cases because they return a void*, but +## do not nave an errcode_ret: +% elif api.Name == "clSVMAlloc" or api.Name == "clGetExtensionFunctionAddressForPlatform": + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(${handle.Name}, NULL); +% else: + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(${handle.Name}, ${invalid}); +% endif +%elif api.Name == "clSVMFree": +## clSVMFree has no return value or errcode_ret: + if (${handle.Name} != NULL) +## clWaitForEvents is a special case, since it calls through +## the dispatch table via the first "event": +%elif api.Name == "clWaitForEvents": + if (${api.Params[0].Name} == 0 || ${api.Params[1].Name} == NULL) { + return CL_INVALID_VALUE; + } + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(${api.Params[1].Name}[0], CL_INVALID_EVENT); +%elif api.Name == "clUnloadCompiler": + // Nothing! +%else: + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(${handle.Name}, ${invalid}); +%endif +%if api.Name == "clCreateContext": + return KHR_ICD2_DISPATCH(${api.Params[2].Name}[0])->${api.Name}( +%elif api.Name == "clWaitForEvents": + return KHR_ICD2_DISPATCH(${api.Params[1].Name}[0])->${api.Name}( +%elif api.Name == "clCreateContextFromType": + return KHR_ICD2_DISPATCH(platform)->${api.Name}( +%elif api.Name == "clSVMFree": + KHR_ICD2_DISPATCH(${handle.Name})->${api.Name}( +%elif api.Name == "clUnloadCompiler": + return CL_SUCCESS; +%else: + return KHR_ICD2_DISPATCH(${handle.Name})->${api.Name}( +%endif: +%for i, param in enumerate(api.Params): +% if i < len(api.Params)-1: + ${param.Name}, +% elif param.Name: # for clUnloadCompiler + ${param.Name}); +% endif +%endfor +} +% if disp == 1: +#endif // defined(CL_ENABLE_LAYERS) +% endif + +/////////////////////////////////////////////////////////////////////////////// +%endfor +%else: +#if defined(CL_ENABLE_LAYERS) +extern ${api.RetType} CL_API_CALL ${api.Name + "_disp"}( +%for i, param in enumerate(api.Params): +% if i < len(api.Params)-1: + ${param.Type} ${param.Name}${param.TypeEnd}, +% else: + ${param.Type} ${param.Name}${param.TypeEnd}) ${api.Suffix}; +% endif +%endfor +#endif // defined(CL_ENABLE_LAYERS) +%endif +%endfor +%endfor +<% +icdextensions = [ + 'cl_ext_device_fission', + 'cl_khr_d3d10_sharing', + 'cl_khr_d3d11_sharing', + 'cl_khr_dx9_media_sharing', + 'cl_khr_egl_event', + 'cl_khr_egl_image', + 'cl_khr_gl_event', + 'cl_khr_gl_sharing', + 'cl_khr_subgroups' + ] +win32extensions = { + 'cl_khr_d3d10_sharing', + 'cl_khr_d3d11_sharing', + 'cl_khr_dx9_media_sharing', + } +%> +%for extension in icdextensions: +<% + apis = extapis[extension] +%>// ${extension} +%if extension in win32extensions: + +#if defined(_WIN32) +%endif +%for api in apis: +<% + handle = api.Params[0] + if handle.Type in apihandles: + invalid = apihandles[handle.Type] + else: + invalid = 'NULL' +%> +%for disp in [0, 1]: +% if disp == 1: +#if defined(CL_ENABLE_LAYERS) +% endif +${("CL_API_ENTRY", "static")[disp]} ${api.RetType} CL_API_CALL ${api.Name + ("", "_disp")[disp]}( +%for i, param in enumerate(api.Params): +% if i < len(api.Params)-1: + ${param.Type} ${param.Name}${param.TypeEnd}, +% else: + ${param.Type} ${param.Name}${param.TypeEnd}) +% endif +%endfor +{ +%if disp == 0: +#if defined(CL_ENABLE_LAYERS) + if (khrFirstLayer) + return khrFirstLayer->dispatch.${api.Name}( +%for i, param in enumerate(api.Params): +% if i < len(api.Params)-1: + ${param.Name}, +% else: + ${param.Name}); +% endif +%endfor +#endif // defined(CL_ENABLE_LAYERS) +%endif +%if api.RetType in apihandles or api.RetType == "void*": +% if False: + // api.Name == "clXXX": # There are currently no API special cases here. +% else: + KHR_ICD_VALIDATE_HANDLE_RETURN_HANDLE(${handle.Name}, ${invalid}); + KHR_ICD_VALIDATE_POINTER_RETURN_HANDLE(KHR_ICD2_DISPATCH(${handle.Name})->${api.Name}); +% endif +%else: +% if api.Name == "clGetGLContextInfoKHR": + cl_platform_id platform = NULL; + khrIcdContextPropertiesGetPlatform(properties, &platform); + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, CL_INVALID_PLATFORM); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(platform)->${api.Name}); +% else: + KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(${handle.Name}, ${invalid}); + KHR_ICD_VALIDATE_POINTER_RETURN_ERROR(KHR_ICD2_DISPATCH(${handle.Name})->${api.Name}); +% endif +%endif +%if api.Name == "clGetGLContextInfoKHR": + return KHR_ICD2_DISPATCH(platform)->${api.Name}( +%else: + return KHR_ICD2_DISPATCH(${handle.Name})->${api.Name}( +%endif +%for i, param in enumerate(api.Params): +% if i < len(api.Params)-1: + ${param.Name}, +% elif param.Name: # for clUnloadCompiler + ${param.Name}); +% endif +%endfor +} +% if disp == 1: +#endif // defined(CL_ENABLE_LAYERS) +% endif +%endfor +%endfor + +%if extension in win32extensions: +#endif // defined(_WIN32) + +%endif +/////////////////////////////////////////////////////////////////////////////// + +%endfor +#if defined(CL_ENABLE_LAYERS) +struct _cl_icd_dispatch khrMasterDispatch = { + ICD_ANON_UNION_INIT_MEMBER(&clGetPlatformIDs_disp), + &clGetPlatformInfo_disp, + &clGetDeviceIDs_disp, + &clGetDeviceInfo_disp, + &clCreateContext_disp, + &clCreateContextFromType_disp, + &clRetainContext_disp, + &clReleaseContext_disp, + &clGetContextInfo_disp, + &clCreateCommandQueue_disp, + &clRetainCommandQueue_disp, + &clReleaseCommandQueue_disp, + &clGetCommandQueueInfo_disp, + &clSetCommandQueueProperty_disp, + &clCreateBuffer_disp, + &clCreateImage2D_disp, + &clCreateImage3D_disp, + &clRetainMemObject_disp, + &clReleaseMemObject_disp, + &clGetSupportedImageFormats_disp, + &clGetMemObjectInfo_disp, + &clGetImageInfo_disp, + &clCreateSampler_disp, + &clRetainSampler_disp, + &clReleaseSampler_disp, + &clGetSamplerInfo_disp, + &clCreateProgramWithSource_disp, + &clCreateProgramWithBinary_disp, + &clRetainProgram_disp, + &clReleaseProgram_disp, + &clBuildProgram_disp, + ICD_ANON_UNION_INIT_MEMBER(&clUnloadCompiler_disp), + &clGetProgramInfo_disp, + &clGetProgramBuildInfo_disp, + &clCreateKernel_disp, + &clCreateKernelsInProgram_disp, + &clRetainKernel_disp, + &clReleaseKernel_disp, + &clSetKernelArg_disp, + &clGetKernelInfo_disp, + &clGetKernelWorkGroupInfo_disp, + &clWaitForEvents_disp, + &clGetEventInfo_disp, + &clRetainEvent_disp, + &clReleaseEvent_disp, + &clGetEventProfilingInfo_disp, + &clFlush_disp, + &clFinish_disp, + &clEnqueueReadBuffer_disp, + &clEnqueueWriteBuffer_disp, + &clEnqueueCopyBuffer_disp, + &clEnqueueReadImage_disp, + &clEnqueueWriteImage_disp, + &clEnqueueCopyImage_disp, + &clEnqueueCopyImageToBuffer_disp, + &clEnqueueCopyBufferToImage_disp, + &clEnqueueMapBuffer_disp, + &clEnqueueMapImage_disp, + &clEnqueueUnmapMemObject_disp, + &clEnqueueNDRangeKernel_disp, + &clEnqueueTask_disp, + &clEnqueueNativeKernel_disp, + &clEnqueueMarker_disp, + &clEnqueueWaitForEvents_disp, + &clEnqueueBarrier_disp, + &clGetExtensionFunctionAddress_disp, + &clCreateFromGLBuffer_disp, + &clCreateFromGLTexture2D_disp, + &clCreateFromGLTexture3D_disp, + &clCreateFromGLRenderbuffer_disp, + &clGetGLObjectInfo_disp, + &clGetGLTextureInfo_disp, + &clEnqueueAcquireGLObjects_disp, + &clEnqueueReleaseGLObjects_disp, + &clGetGLContextInfoKHR_disp, + + /* cl_khr_d3d10_sharing */ +#if defined(_WIN32) + &clGetDeviceIDsFromD3D10KHR_disp, + &clCreateFromD3D10BufferKHR_disp, + &clCreateFromD3D10Texture2DKHR_disp, + &clCreateFromD3D10Texture3DKHR_disp, + &clEnqueueAcquireD3D10ObjectsKHR_disp, + &clEnqueueReleaseD3D10ObjectsKHR_disp, +#else + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, +#endif + + /* OpenCL 1.1 */ + &clSetEventCallback_disp, + &clCreateSubBuffer_disp, + &clSetMemObjectDestructorCallback_disp, + &clCreateUserEvent_disp, + &clSetUserEventStatus_disp, + &clEnqueueReadBufferRect_disp, + &clEnqueueWriteBufferRect_disp, + &clEnqueueCopyBufferRect_disp, + + /* cl_ext_device_fission */ + &clCreateSubDevicesEXT_disp, + &clRetainDeviceEXT_disp, + &clReleaseDeviceEXT_disp, + + /* cl_khr_gl_event */ + &clCreateEventFromGLsyncKHR_disp, + + /* OpenCL 1.2 */ + &clCreateSubDevices_disp, + &clRetainDevice_disp, + &clReleaseDevice_disp, + &clCreateImage_disp, + &clCreateProgramWithBuiltInKernels_disp, + &clCompileProgram_disp, + &clLinkProgram_disp, + &clUnloadPlatformCompiler_disp, + &clGetKernelArgInfo_disp, + &clEnqueueFillBuffer_disp, + &clEnqueueFillImage_disp, + &clEnqueueMigrateMemObjects_disp, + &clEnqueueMarkerWithWaitList_disp, + &clEnqueueBarrierWithWaitList_disp, + &clGetExtensionFunctionAddressForPlatform_disp, + &clCreateFromGLTexture_disp, + + /* cl_khr_d3d11_sharing */ +#if defined(_WIN32) + &clGetDeviceIDsFromD3D11KHR_disp, + &clCreateFromD3D11BufferKHR_disp, + &clCreateFromD3D11Texture2DKHR_disp, + &clCreateFromD3D11Texture3DKHR_disp, + &clCreateFromDX9MediaSurfaceKHR_disp, + &clEnqueueAcquireD3D11ObjectsKHR_disp, + &clEnqueueReleaseD3D11ObjectsKHR_disp, +#else + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, +#endif + + /* cl_khr_dx9_media_sharing */ +#if defined(_WIN32) + &clGetDeviceIDsFromDX9MediaAdapterKHR_disp, + &clEnqueueAcquireDX9MediaSurfacesKHR_disp, + &clEnqueueReleaseDX9MediaSurfacesKHR_disp, +#else + NULL, + NULL, + NULL, +#endif + + /* cl_khr_egl_image */ + &clCreateFromEGLImageKHR_disp, + &clEnqueueAcquireEGLObjectsKHR_disp, + &clEnqueueReleaseEGLObjectsKHR_disp, + + /* cl_khr_egl_event */ + &clCreateEventFromEGLSyncKHR_disp, + + /* OpenCL 2.0 */ + &clCreateCommandQueueWithProperties_disp, + &clCreatePipe_disp, + &clGetPipeInfo_disp, + &clSVMAlloc_disp, + &clSVMFree_disp, + &clEnqueueSVMFree_disp, + &clEnqueueSVMMemcpy_disp, + &clEnqueueSVMMemFill_disp, + &clEnqueueSVMMap_disp, + &clEnqueueSVMUnmap_disp, + &clCreateSamplerWithProperties_disp, + &clSetKernelArgSVMPointer_disp, + &clSetKernelExecInfo_disp, + + /* cl_khr_sub_groups */ + &clGetKernelSubGroupInfoKHR_disp, + + /* OpenCL 2.1 */ + &clCloneKernel_disp, + &clCreateProgramWithIL_disp, + &clEnqueueSVMMigrateMem_disp, + &clGetDeviceAndHostTimer_disp, + &clGetHostTimer_disp, + &clGetKernelSubGroupInfo_disp, + &clSetDefaultDeviceCommandQueue_disp, + + /* OpenCL 2.2 */ + &clSetProgramReleaseCallback_disp, + &clSetProgramSpecializationConstant_disp, + + /* OpenCL 3.0 */ + &clCreateBufferWithProperties_disp, + &clCreateImageWithProperties_disp, + &clSetContextDestructorCallback_disp +}; +#endif // defined(CL_ENABLE_LAYERS) + +#if defined(CL_ENABLE_LOADER_MANAGED_DISPATCH) +/////////////////////////////////////////////////////////////////////////////// +// Core APIs: +%for apis in coreapis.values(): +%for api in apis: +static ${api.RetType} CL_API_CALL ${api.Name}_unsupp( +%for i, param in enumerate(api.Params): +% if i < len(api.Params)-1: + ${param.Type} ${param.Name}${param.TypeEnd}, +% else: + ${param.Type} ${param.Name}${param.TypeEnd}) +% endif +%endfor +{ +%for param in api.Params: +% if param.Name: + (void)${param.Name}; +% endif +%endfor +%if api.Name == "clSVMAlloc" or api.Name == "clGetExtensionFunctionAddressForPlatform" or api.Name == "clGetExtensionFunctionAddress": + KHR_ICD_ERROR_RETURN_ERROR(NULL); +%elif api.Name == "clSVMFree": + return; +%elif api.RetType in apihandles or api.RetType == "void*": + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +%else: + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +%endif +} +%endfor +%endfor + +/////////////////////////////////////////////////////////////////////////////// +%for extension in icdextensions: +<% + apis = extapis[extension] +%>// ${extension} +%if extension in win32extensions: + +#if defined(_WIN32) +%endif +%for api in apis: +static ${api.RetType} CL_API_CALL ${api.Name}_unsupp( +%for i, param in enumerate(api.Params): +% if i < len(api.Params)-1: + ${param.Type} ${param.Name}${param.TypeEnd}, +% else: + ${param.Type} ${param.Name}${param.TypeEnd}) +% endif +%endfor +{ +%for param in api.Params: +% if param.Name: + (void)${param.Name}; +% endif +%endfor +%if api.RetType in apihandles or api.RetType == "void*": + KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION); +%else: + KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION); +%endif +} +%endfor +%if extension in win32extensions: +#endif // defined(_WIN32) + +%endif +/////////////////////////////////////////////////////////////////////////////// + +%endfor + +void khrIcd2PopulateDispatchTable( + cl_platform_id platform, + clIcdGetFunctionAddressForPlatformKHR_fn p_clIcdGetFunctionAddressForPlatform, + struct _cl_icd_dispatch* dispatch) +{ +/////////////////////////////////////////////////////////////////////////////// +// Core APIs: +%for apis in coreapis.values(): +%for api in apis: + dispatch->${api.Name} = (${api.Name}_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "${api.Name}"); + if (!dispatch->${api.Name}) + dispatch->${api.Name} = &${api.Name}_unsupp; +%endfor +%endfor + +/////////////////////////////////////////////////////////////////////////////// +%for extension in icdextensions: +<% + apis = extapis[extension] +%>// ${extension} +%if extension in win32extensions: + +#if defined(_WIN32) +%endif +%for api in apis: + dispatch->${api.Name} = (${api.Name}_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "${api.Name}"); + if (!dispatch->${api.Name}) + dispatch->${api.Name} = &${api.Name}_unsupp; +%endfor +%if extension in win32extensions: +#endif // defined(_WIN32) + +%endif +/////////////////////////////////////////////////////////////////////////////// + +%endfor +} +#endif // defined(CL_ENABLE_LOADER_MANAGED_DISPATCH) + +#ifdef __cplusplus +} +#endif diff --git a/scripts/icd_print_layer_generated.c.mako b/scripts/icd_print_layer_generated.c.mako new file mode 100644 index 00000000..3ef38d53 --- /dev/null +++ b/scripts/icd_print_layer_generated.c.mako @@ -0,0 +1,310 @@ +/* + * Copyright (c) 2020 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#include "icd_print_layer.h" + +/////////////////////////////////////////////////////////////////////////////// +// Core APIs: +%for apis in coreapis.values(): +%for api in apis: +static ${api.RetType} CL_API_CALL ${api.Name + "_wrap"}( +%for i, param in enumerate(api.Params): +% if i < len(api.Params)-1: + ${param.Type} ${param.Name}${param.TypeEnd}, +% else: + ${param.Type} ${param.Name}${param.TypeEnd}) ${api.Suffix} +% endif +%endfor +{ +printf("${api.Name}\n"); +% if api.Name == "clSVMFree": +tdispatch->${api.Name}( +% else: +return tdispatch->${api.Name}( +% endif +%for i, param in enumerate(api.Params): +% if i < len(api.Params)-1: + ${param.Name}, +% else: + ${param.Name}); +% endif +%endfor +} + +/////////////////////////////////////////////////////////////////////////////// +%endfor +%endfor +<% +icdextensions = [ + 'cl_ext_device_fission', + 'cl_khr_d3d10_sharing', + 'cl_khr_d3d11_sharing', + 'cl_khr_dx9_media_sharing', + 'cl_khr_egl_event', + 'cl_khr_egl_image', + 'cl_khr_gl_event', + 'cl_khr_gl_sharing', + 'cl_khr_subgroups' + ] +win32extensions = { + 'cl_khr_d3d10_sharing', + 'cl_khr_d3d11_sharing', + 'cl_khr_dx9_media_sharing', + } +%> +%for extension in icdextensions: +<% + apis = extapis[extension] +%>// ${extension} +%if extension in win32extensions: + +#if defined(_WIN32) +%endif +%for api in apis: +static ${api.RetType} CL_API_CALL ${api.Name + "_wrap"}( +%for i, param in enumerate(api.Params): +% if i < len(api.Params)-1: + ${param.Type} ${param.Name}${param.TypeEnd}, +% else: + ${param.Type} ${param.Name}${param.TypeEnd}) ${api.Suffix} +% endif +%endfor +{ +printf("${api.Name}\n"); +return tdispatch->${api.Name}( +%for i, param in enumerate(api.Params): +% if i < len(api.Params)-1: + ${param.Name}, +% else: + ${param.Name}); +% endif +%endfor +} +%endfor + +%if extension in win32extensions: +#endif // defined(_WIN32) + +%endif +/////////////////////////////////////////////////////////////////////////////// + +%endfor +void _init_dispatch(void) { + dispatch.clGetPlatformIDs = &clGetPlatformIDs_wrap; + dispatch.clGetPlatformInfo = &clGetPlatformInfo_wrap; + dispatch.clGetDeviceIDs = &clGetDeviceIDs_wrap; + dispatch.clGetDeviceInfo = &clGetDeviceInfo_wrap; + dispatch.clCreateContext = &clCreateContext_wrap; + dispatch.clCreateContextFromType = &clCreateContextFromType_wrap; + dispatch.clRetainContext = &clRetainContext_wrap; + dispatch.clReleaseContext = &clReleaseContext_wrap; + dispatch.clGetContextInfo = &clGetContextInfo_wrap; + dispatch.clCreateCommandQueue = &clCreateCommandQueue_wrap; + dispatch.clRetainCommandQueue = &clRetainCommandQueue_wrap; + dispatch.clReleaseCommandQueue = &clReleaseCommandQueue_wrap; + dispatch.clGetCommandQueueInfo = &clGetCommandQueueInfo_wrap; + dispatch.clSetCommandQueueProperty = &clSetCommandQueueProperty_wrap; + dispatch.clCreateBuffer = &clCreateBuffer_wrap; + dispatch.clCreateImage2D = &clCreateImage2D_wrap; + dispatch.clCreateImage3D = &clCreateImage3D_wrap; + dispatch.clRetainMemObject = &clRetainMemObject_wrap; + dispatch.clReleaseMemObject = &clReleaseMemObject_wrap; + dispatch.clGetSupportedImageFormats = &clGetSupportedImageFormats_wrap; + dispatch.clGetMemObjectInfo = &clGetMemObjectInfo_wrap; + dispatch.clGetImageInfo = &clGetImageInfo_wrap; + dispatch.clCreateSampler = &clCreateSampler_wrap; + dispatch.clRetainSampler = &clRetainSampler_wrap; + dispatch.clReleaseSampler = &clReleaseSampler_wrap; + dispatch.clGetSamplerInfo = &clGetSamplerInfo_wrap; + dispatch.clCreateProgramWithSource = &clCreateProgramWithSource_wrap; + dispatch.clCreateProgramWithBinary = &clCreateProgramWithBinary_wrap; + dispatch.clRetainProgram = &clRetainProgram_wrap; + dispatch.clReleaseProgram = &clReleaseProgram_wrap; + dispatch.clBuildProgram = &clBuildProgram_wrap; + dispatch.clUnloadCompiler = &clUnloadCompiler_wrap; + dispatch.clGetProgramInfo = &clGetProgramInfo_wrap; + dispatch.clGetProgramBuildInfo = &clGetProgramBuildInfo_wrap; + dispatch.clCreateKernel = &clCreateKernel_wrap; + dispatch.clCreateKernelsInProgram = &clCreateKernelsInProgram_wrap; + dispatch.clRetainKernel = &clRetainKernel_wrap; + dispatch.clReleaseKernel = &clReleaseKernel_wrap; + dispatch.clSetKernelArg = &clSetKernelArg_wrap; + dispatch.clGetKernelInfo = &clGetKernelInfo_wrap; + dispatch.clGetKernelWorkGroupInfo = &clGetKernelWorkGroupInfo_wrap; + dispatch.clWaitForEvents = &clWaitForEvents_wrap; + dispatch.clGetEventInfo = &clGetEventInfo_wrap; + dispatch.clRetainEvent = &clRetainEvent_wrap; + dispatch.clReleaseEvent = &clReleaseEvent_wrap; + dispatch.clGetEventProfilingInfo = &clGetEventProfilingInfo_wrap; + dispatch.clFlush = &clFlush_wrap; + dispatch.clFinish = &clFinish_wrap; + dispatch.clEnqueueReadBuffer = &clEnqueueReadBuffer_wrap; + dispatch.clEnqueueWriteBuffer = &clEnqueueWriteBuffer_wrap; + dispatch.clEnqueueCopyBuffer = &clEnqueueCopyBuffer_wrap; + dispatch.clEnqueueReadImage = &clEnqueueReadImage_wrap; + dispatch.clEnqueueWriteImage = &clEnqueueWriteImage_wrap; + dispatch.clEnqueueCopyImage = &clEnqueueCopyImage_wrap; + dispatch.clEnqueueCopyImageToBuffer = &clEnqueueCopyImageToBuffer_wrap; + dispatch.clEnqueueCopyBufferToImage = &clEnqueueCopyBufferToImage_wrap; + dispatch.clEnqueueMapBuffer = &clEnqueueMapBuffer_wrap; + dispatch.clEnqueueMapImage = &clEnqueueMapImage_wrap; + dispatch.clEnqueueUnmapMemObject = &clEnqueueUnmapMemObject_wrap; + dispatch.clEnqueueNDRangeKernel = &clEnqueueNDRangeKernel_wrap; + dispatch.clEnqueueTask = &clEnqueueTask_wrap; + dispatch.clEnqueueNativeKernel = &clEnqueueNativeKernel_wrap; + dispatch.clEnqueueMarker = &clEnqueueMarker_wrap; + dispatch.clEnqueueWaitForEvents = &clEnqueueWaitForEvents_wrap; + dispatch.clEnqueueBarrier = &clEnqueueBarrier_wrap; + dispatch.clGetExtensionFunctionAddress = &clGetExtensionFunctionAddress_wrap; + dispatch.clCreateFromGLBuffer = &clCreateFromGLBuffer_wrap; + dispatch.clCreateFromGLTexture2D = &clCreateFromGLTexture2D_wrap; + dispatch.clCreateFromGLTexture3D = &clCreateFromGLTexture3D_wrap; + dispatch.clCreateFromGLRenderbuffer = &clCreateFromGLRenderbuffer_wrap; + dispatch.clGetGLObjectInfo = &clGetGLObjectInfo_wrap; + dispatch.clGetGLTextureInfo = &clGetGLTextureInfo_wrap; + dispatch.clEnqueueAcquireGLObjects = &clEnqueueAcquireGLObjects_wrap; + dispatch.clEnqueueReleaseGLObjects = &clEnqueueReleaseGLObjects_wrap; + dispatch.clGetGLContextInfoKHR = &clGetGLContextInfoKHR_wrap; + + /* cl_khr_d3d10_sharing */ +#if defined(_WIN32) + dispatch.clGetDeviceIDsFromD3D10KHR = &clGetDeviceIDsFromD3D10KHR_wrap; + dispatch.clCreateFromD3D10BufferKHR = &clCreateFromD3D10BufferKHR_wrap; + dispatch.clCreateFromD3D10Texture2DKHR = &clCreateFromD3D10Texture2DKHR_wrap; + dispatch.clCreateFromD3D10Texture3DKHR = &clCreateFromD3D10Texture3DKHR_wrap; + dispatch.clEnqueueAcquireD3D10ObjectsKHR = &clEnqueueAcquireD3D10ObjectsKHR_wrap; + dispatch.clEnqueueReleaseD3D10ObjectsKHR = &clEnqueueReleaseD3D10ObjectsKHR_wrap; +#else + dispatch.clGetDeviceIDsFromD3D10KHR = NULL; + dispatch.clCreateFromD3D10BufferKHR = NULL; + dispatch.clCreateFromD3D10Texture2DKHR = NULL; + dispatch.clCreateFromD3D10Texture3DKHR = NULL; + dispatch.clEnqueueAcquireD3D10ObjectsKHR = NULL; + dispatch.clEnqueueReleaseD3D10ObjectsKHR = NULL; +#endif + + /* OpenCL 1.1 */ + dispatch.clSetEventCallback = &clSetEventCallback_wrap; + dispatch.clCreateSubBuffer = &clCreateSubBuffer_wrap; + dispatch.clSetMemObjectDestructorCallback = &clSetMemObjectDestructorCallback_wrap; + dispatch.clCreateUserEvent = &clCreateUserEvent_wrap; + dispatch.clSetUserEventStatus = &clSetUserEventStatus_wrap; + dispatch.clEnqueueReadBufferRect = &clEnqueueReadBufferRect_wrap; + dispatch.clEnqueueWriteBufferRect = &clEnqueueWriteBufferRect_wrap; + dispatch.clEnqueueCopyBufferRect = &clEnqueueCopyBufferRect_wrap; + + /* cl_ext_device_fission */ + dispatch.clCreateSubDevicesEXT = &clCreateSubDevicesEXT_wrap; + dispatch.clRetainDeviceEXT = &clRetainDeviceEXT_wrap; + dispatch.clReleaseDeviceEXT = &clReleaseDeviceEXT_wrap; + + /* cl_khr_gl_event */ + dispatch.clCreateEventFromGLsyncKHR = &clCreateEventFromGLsyncKHR_wrap; + + /* OpenCL 1.2 */ + dispatch.clCreateSubDevices = &clCreateSubDevices_wrap; + dispatch.clRetainDevice = &clRetainDevice_wrap; + dispatch.clReleaseDevice = &clReleaseDevice_wrap; + dispatch.clCreateImage = &clCreateImage_wrap; + dispatch.clCreateProgramWithBuiltInKernels = &clCreateProgramWithBuiltInKernels_wrap; + dispatch.clCompileProgram = &clCompileProgram_wrap; + dispatch.clLinkProgram = &clLinkProgram_wrap; + dispatch.clUnloadPlatformCompiler = &clUnloadPlatformCompiler_wrap; + dispatch.clGetKernelArgInfo = &clGetKernelArgInfo_wrap; + dispatch.clEnqueueFillBuffer = &clEnqueueFillBuffer_wrap; + dispatch.clEnqueueFillImage = &clEnqueueFillImage_wrap; + dispatch.clEnqueueMigrateMemObjects = &clEnqueueMigrateMemObjects_wrap; + dispatch.clEnqueueMarkerWithWaitList = &clEnqueueMarkerWithWaitList_wrap; + dispatch.clEnqueueBarrierWithWaitList = &clEnqueueBarrierWithWaitList_wrap; + dispatch.clGetExtensionFunctionAddressForPlatform = &clGetExtensionFunctionAddressForPlatform_wrap; + dispatch.clCreateFromGLTexture = &clCreateFromGLTexture_wrap; + + /* cl_khr_d3d11_sharing */ +#if defined(_WIN32) + dispatch.clGetDeviceIDsFromD3D11KHR = &clGetDeviceIDsFromD3D11KHR_wrap; + dispatch.clCreateFromD3D11BufferKHR = &clCreateFromD3D11BufferKHR_wrap; + dispatch.clCreateFromD3D11Texture2DKHR = &clCreateFromD3D11Texture2DKHR_wrap; + dispatch.clCreateFromD3D11Texture3DKHR = &clCreateFromD3D11Texture3DKHR_wrap; + dispatch.clCreateFromDX9MediaSurfaceKHR = &clCreateFromDX9MediaSurfaceKHR_wrap; + dispatch.clEnqueueAcquireD3D11ObjectsKHR = &clEnqueueAcquireD3D11ObjectsKHR_wrap; + dispatch.clEnqueueReleaseD3D11ObjectsKHR = &clEnqueueReleaseD3D11ObjectsKHR_wrap; +#else + dispatch.clGetDeviceIDsFromD3D11KHR = NULL; + dispatch.clCreateFromD3D11BufferKHR = NULL; + dispatch.clCreateFromD3D11Texture2DKHR = NULL; + dispatch.clCreateFromD3D11Texture3DKHR = NULL; + dispatch.clCreateFromDX9MediaSurfaceKHR = NULL; + dispatch.clEnqueueAcquireD3D11ObjectsKHR = NULL; + dispatch.clEnqueueReleaseD3D11ObjectsKHR = NULL; +#endif + + /* cl_khr_dx9_media_sharing */ +#if defined(_WIN32) + dispatch.clGetDeviceIDsFromDX9MediaAdapterKHR = &clGetDeviceIDsFromDX9MediaAdapterKHR_wrap; + dispatch.clEnqueueAcquireDX9MediaSurfacesKHR = &clEnqueueAcquireDX9MediaSurfacesKHR_wrap; + dispatch.clEnqueueReleaseDX9MediaSurfacesKHR = &clEnqueueReleaseDX9MediaSurfacesKHR_wrap; +#else + dispatch.clGetDeviceIDsFromDX9MediaAdapterKHR = NULL; + dispatch.clEnqueueAcquireDX9MediaSurfacesKHR = NULL; + dispatch.clEnqueueReleaseDX9MediaSurfacesKHR = NULL; +#endif + + /* cl_khr_egl_image */ + dispatch.clCreateFromEGLImageKHR = &clCreateFromEGLImageKHR_wrap; + dispatch.clEnqueueAcquireEGLObjectsKHR = &clEnqueueAcquireEGLObjectsKHR_wrap; + dispatch.clEnqueueReleaseEGLObjectsKHR = &clEnqueueReleaseEGLObjectsKHR_wrap; + + /* cl_khr_egl_event */ + dispatch.clCreateEventFromEGLSyncKHR = &clCreateEventFromEGLSyncKHR_wrap; + + /* OpenCL 2.0 */ + dispatch.clCreateCommandQueueWithProperties = &clCreateCommandQueueWithProperties_wrap; + dispatch.clCreatePipe = &clCreatePipe_wrap; + dispatch.clGetPipeInfo = &clGetPipeInfo_wrap; + dispatch.clSVMAlloc = &clSVMAlloc_wrap; + dispatch.clSVMFree = &clSVMFree_wrap; + dispatch.clEnqueueSVMFree = &clEnqueueSVMFree_wrap; + dispatch.clEnqueueSVMMemcpy = &clEnqueueSVMMemcpy_wrap; + dispatch.clEnqueueSVMMemFill = &clEnqueueSVMMemFill_wrap; + dispatch.clEnqueueSVMMap = &clEnqueueSVMMap_wrap; + dispatch.clEnqueueSVMUnmap = &clEnqueueSVMUnmap_wrap; + dispatch.clCreateSamplerWithProperties = &clCreateSamplerWithProperties_wrap; + dispatch.clSetKernelArgSVMPointer = &clSetKernelArgSVMPointer_wrap; + dispatch.clSetKernelExecInfo = &clSetKernelExecInfo_wrap; + + /* cl_khr_sub_groups */ + dispatch.clGetKernelSubGroupInfoKHR = &clGetKernelSubGroupInfoKHR_wrap; + + /* OpenCL 2.1 */ + dispatch.clCloneKernel = &clCloneKernel_wrap; + dispatch.clCreateProgramWithIL = &clCreateProgramWithIL_wrap; + dispatch.clEnqueueSVMMigrateMem = &clEnqueueSVMMigrateMem_wrap; + dispatch.clGetDeviceAndHostTimer = &clGetDeviceAndHostTimer_wrap; + dispatch.clGetHostTimer = &clGetHostTimer_wrap; + dispatch.clGetKernelSubGroupInfo = &clGetKernelSubGroupInfo_wrap; + dispatch.clSetDefaultDeviceCommandQueue = &clSetDefaultDeviceCommandQueue_wrap; + + /* OpenCL 2.2 */ + dispatch.clSetProgramReleaseCallback = &clSetProgramReleaseCallback_wrap; + dispatch.clSetProgramSpecializationConstant = &clSetProgramSpecializationConstant_wrap; + + /* OpenCL 3.0 */ + dispatch.clCreateBufferWithProperties = &clCreateBufferWithProperties_wrap; + dispatch.clCreateImageWithProperties = &clCreateImageWithProperties_wrap; + dispatch.clSetContextDestructorCallback = &clSetContextDestructorCallback_wrap; +} diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ed84476d..578aa259 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,7 +1,56 @@ include_directories (./inc) -add_subdirectory (platform) +add_subdirectory (log) add_subdirectory (driver_stub) add_subdirectory (loader_test) +if (ENABLE_OPENCL_LAYERS) + add_subdirectory (layer) +endif () -add_test (OPENCL_ICD_LOADER_TEST ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/icd_loader_test) +set_target_properties (IcdLog OpenCLDriverStub OpenCLDriverStubICD2 icd_loader_test + PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" + PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" +) +add_test ( + NAME opencl_icd_loader_test + COMMAND icd_loader_test +) +add_test ( + NAME opencl_icd_loader_icd2_test + COMMAND icd_loader_test +) + +if (ENABLE_OPENCL_LAYERINFO) + add_test ( + NAME cllayerinfo_test + COMMAND cllayerinfo + ) +endif () + +get_property(GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if (GENERATOR_IS_MULTI_CONFIG) + set (TEST_WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/$") +else () + set (TEST_WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") +endif() + +set_tests_properties(opencl_icd_loader_test + PROPERTIES + ENVIRONMENT OCL_ICD_FILENAMES=$ + WORKING_DIRECTORY "${TEST_WORKING_DIRECTORY}" +) +set_tests_properties(opencl_icd_loader_icd2_test + PROPERTIES + ENVIRONMENT "OCL_ICD_FILENAMES=$;APP_LOG_FILE=icd_test_app_log_icd2.txt;APP_STUB_FILE=icd_test_stub_log_icd2.txt;APP_PLATFORM=ICD_LOADER_TEST_OPENCL_STUB_ICD2" + WORKING_DIRECTORY "${TEST_WORKING_DIRECTORY}" +) +if (ENABLE_OPENCL_LAYERINFO) + set_tests_properties(cllayerinfo_test + PROPERTIES + ENVIRONMENT OPENCL_LAYERS=$ + WORKING_DIRECTORY "${TEST_WORKING_DIRECTORY}" + ) +endif() diff --git a/test/Makefile b/test/Makefile deleted file mode 100644 index db52dc5c..00000000 --- a/test/Makefile +++ /dev/null @@ -1,18 +0,0 @@ - -.PHONY: all platform driver_stub loader_test clean - -all: platform driver_stub loader_test - -platform: - ${MAKE} -C platform - -driver_stub: - ${MAKE} -C driver_stub - -loader_test: - ${MAKE} -C loader_test - -clean: - ${MAKE} -C platform clean - ${MAKE} -C driver_stub clean - ${MAKE} -C loader_test clean diff --git a/test/driver_stub/CMakeLists.txt b/test/driver_stub/CMakeLists.txt index 13048172..765ca1e4 100644 --- a/test/driver_stub/CMakeLists.txt +++ b/test/driver_stub/CMakeLists.txt @@ -7,4 +7,18 @@ endif () add_library (OpenCLDriverStub SHARED ${OPENCL_DRIVER_STUB_SOURCES}) -target_link_libraries (OpenCLDriverStub IcdLog) +target_link_libraries (OpenCLDriverStub IcdLog OpenCL::Headers) + +target_compile_definitions (OpenCLDriverStub PRIVATE CL_TARGET_OPENCL_VERSION=300) + +set (OPENCL_DRIVER_STUB_ICD2_SOURCES cl.c cl_ext.c cl_gl.c icd.c) + +if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") + list (APPEND OPENCL_DRIVER_STUB_ICD2_SOURCES driver_stub.def) +endif () + +add_library (OpenCLDriverStubICD2 SHARED ${OPENCL_DRIVER_STUB_ICD2_SOURCES}) + +target_link_libraries (OpenCLDriverStubICD2 IcdLog OpenCL::Headers) + +target_compile_definitions (OpenCLDriverStubICD2 PRIVATE CL_TARGET_OPENCL_VERSION=300 CL_ENABLE_ICD2=1) diff --git a/test/driver_stub/Makefile b/test/driver_stub/Makefile deleted file mode 100644 index dd79b51c..00000000 --- a/test/driver_stub/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -CC := gcc -CFLAGS := -I ../inc -I ../../ -fPIC -g -O0 - -OUTDIR := ../../bin - -${OUTDIR}/libOpenCLDriverStub.so: cl.c cl_ext.c cl_gl.c icd.c - ${CC} ${CFLAGS} -shared -Wl,-soname,$@ \ - -Wl,--version-script,icd_driver_exports.map \ - -o $@ $^ ${OUTDIR}/libIcdLog.so - -.PHONY: clean - -clean: - rm -f ${OUTDIR}/libOpenCLDriverStub.so diff --git a/test/driver_stub/cl.c b/test/driver_stub/cl.c index 28f626a1..7bb7205a 100644 --- a/test/driver_stub/cl.c +++ b/test/driver_stub/cl.c @@ -24,7 +24,7 @@ clIcdGetPlatformIDsKHR(cl_uint, cl_platform_id *, cl_uint *); struct _cl_platform_id { - CLIicdDispatchTable* dispatch; + CL_OBJECT_BODY; const char *profile; const char *version; const char *name; @@ -35,42 +35,42 @@ struct _cl_platform_id struct _cl_device_id { - CLIicdDispatchTable* dispatch; + CL_OBJECT_BODY; }; struct _cl_context { - CLIicdDispatchTable* dispatch; + CL_OBJECT_BODY; }; struct _cl_command_queue { - CLIicdDispatchTable* dispatch; + CL_OBJECT_BODY; }; struct _cl_mem { - CLIicdDispatchTable* dispatch; + CL_OBJECT_BODY; }; struct _cl_program { - CLIicdDispatchTable* dispatch; + CL_OBJECT_BODY; }; struct _cl_kernel { - CLIicdDispatchTable* dispatch; + CL_OBJECT_BODY; }; struct _cl_event { - CLIicdDispatchTable* dispatch; + CL_OBJECT_BODY; }; struct _cl_sampler { - CLIicdDispatchTable* dispatch; + CL_OBJECT_BODY; }; static CLIicdDispatchTable* dispatchTable = NULL; @@ -93,11 +93,9 @@ clGetPlatformIDs(cl_uint num_entries , } CL_API_ENTRY cl_int CL_API_CALL -clGetPlatformInfo(cl_platform_id platform, - cl_platform_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +clGetPlatformInfo(cl_platform_id platform_id, cl_platform_info param_name, + size_t param_value_size, void *param_value, + size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 { cl_int ret = CL_SUCCESS; const char *returnString = NULL; @@ -116,23 +114,15 @@ clGetPlatformInfo(cl_platform_id platform, } // select the string to return switch(param_name) { - case CL_PLATFORM_PROFILE: - returnString = platform->profile; - break; - case CL_PLATFORM_VERSION: - returnString = platform->version; - break; - case CL_PLATFORM_NAME: - returnString = platform->name; - break; - case CL_PLATFORM_VENDOR: - returnString = platform->vendor; - break; + case CL_PLATFORM_PROFILE: returnString = platform_id->profile; break; + case CL_PLATFORM_VERSION: returnString = platform_id->version; break; + case CL_PLATFORM_NAME: returnString = platform_id->name; break; + case CL_PLATFORM_VENDOR: returnString = platform_id->vendor; break; case CL_PLATFORM_EXTENSIONS: - returnString = platform->extensions; + returnString = platform_id->extensions; break; case CL_PLATFORM_ICD_SUFFIX_KHR: - returnString = platform->suffix; + returnString = platform_id->suffix; break; default: ret = CL_INVALID_VALUE; @@ -162,23 +152,20 @@ clGetPlatformInfo(cl_platform_id platform, /* Device APIs */ -CL_API_ENTRY cl_int CL_API_CALL -clGetDeviceIDs(cl_platform_id platform, - cl_device_type device_type, - cl_uint num_entries, - cl_device_id * devices, - cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_0 +CL_API_ENTRY cl_int CL_API_CALL clGetDeviceIDs( + cl_platform_id platform_id, cl_device_type device_type, cl_uint num_entries, + cl_device_id *devices, cl_uint *num_devices) CL_API_SUFFIX__VERSION_1_0 { cl_int ret = CL_SUCCESS; - if ((num_entries > 1 || num_entries < 0) && devices != NULL) { + if ((num_entries > 1) && devices != NULL) { ret = CL_INVALID_VALUE; goto done; } if (devices != NULL) { - cl_device_id obj = (cl_device_id) malloc(sizeof(*obj)); - obj->dispatch = dispatchTable; + cl_device_id obj = (cl_device_id) malloc(sizeof(struct _cl_device_id)); + CL_INIT_OBJECT(obj, platform); devices[0] = obj; } if (num_devices) { @@ -186,12 +173,8 @@ clGetDeviceIDs(cl_platform_id platform, } done: - test_icd_stub_log("clGetDeviceIDs(%p, %x, %u, %p, %p)\n", - platform, - device_type, - num_entries, - devices, - num_devices); + test_icd_stub_log("clGetDeviceIDs(%p, %x, %u, %p, %p)\n", platform_id, + device_type, num_entries, devices, num_devices); test_icd_stub_log("Value returned: %d\n", ret); return ret; } @@ -269,7 +252,7 @@ clCreateContext(const cl_context_properties * properties, cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 { cl_context obj = (cl_context) malloc(sizeof(struct _cl_context)); - obj->dispatch = dispatchTable; + CL_INIT_OBJECT(obj, devices[0]); test_icd_stub_log("clCreateContext(%p, %u, %p, %p, %p, %p)\n", properties, num_devices, @@ -297,7 +280,11 @@ clCreateContextFromType(const cl_context_properties * properties, cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 { cl_context obj = (cl_context) malloc(sizeof(struct _cl_context)); - obj->dispatch = dispatchTable; + cl_platform_id plt = platform; + for (const cl_context_properties * property = properties; *property; property += 2) + if (*property == (cl_context_properties)CL_CONTEXT_PLATFORM) + plt = (cl_platform_id)property[1]; + CL_INIT_OBJECT(obj, plt); test_icd_stub_log("clCreateContextFromType(%p, %x, %p, %p, %p)\n", properties, device_type, @@ -355,6 +342,26 @@ clGetContextInfo(cl_context context, return return_value; } +CL_API_ENTRY cl_int CL_API_CALL +clSetContextDestructorCallback(cl_context context, + void (CL_CALLBACK* pfn_notify)(cl_context context, + void* user_data), + void* user_data) CL_API_SUFFIX__VERSION_3_0 +{ + cl_int return_value = CL_OUT_OF_RESOURCES; + test_icd_stub_log("clSetContextDestructorCallback(%p, %p, %p)\n", + context, + pfn_notify, + user_data); + pfn_notify(context, user_data); + test_icd_stub_log("setcontextdestructor_callback(%p, %p)\n", + context, + user_data); + + test_icd_stub_log("Value returned: %d\n", return_value); + return return_value; +} + /* Command Queue APIs */ CL_API_ENTRY cl_command_queue CL_API_CALL clCreateCommandQueue(cl_context context, @@ -363,7 +370,7 @@ clCreateCommandQueue(cl_context context, cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 { cl_command_queue obj = (cl_command_queue) malloc(sizeof(struct _cl_command_queue)); - obj->dispatch = dispatchTable; + CL_INIT_OBJECT(obj, context); test_icd_stub_log("clCreateCommandQueue(%p, %p, %x, %p)\n", context, device, @@ -378,7 +385,7 @@ CL_API_ENTRY cl_int CL_API_CALL clSetCommandQueueProperty(cl_command_queue command_queue , cl_command_queue_properties properties , cl_bool enable , - cl_command_queue_properties * old_properties) CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED + cl_command_queue_properties * old_properties) CL_API_SUFFIX__VERSION_1_0_DEPRECATED { cl_int return_value = CL_OUT_OF_RESOURCES; test_icd_stub_log("clSetCommandQueueProperty(%p, %p, %u, %p)\n", @@ -440,7 +447,7 @@ clCreateBuffer(cl_context context , cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 { cl_mem obj = (cl_mem) malloc(sizeof(struct _cl_mem)); - obj->dispatch = dispatchTable; + CL_INIT_OBJECT(obj, context); test_icd_stub_log("clCreateBuffer(%p, %x, %u, %p, %p)\n", context, flags, @@ -460,7 +467,7 @@ clCreateSubBuffer(cl_mem buffer , cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_1 { cl_mem obj = (cl_mem) malloc(sizeof(struct _cl_mem)); - obj->dispatch = dispatchTable; + CL_INIT_OBJECT(obj, buffer); test_icd_stub_log("clCreateSubBuffer(%p, %x, %u, %p, %p)\n", buffer, flags, @@ -474,14 +481,14 @@ clCreateSubBuffer(cl_mem buffer , CL_API_ENTRY cl_mem CL_API_CALL clCreateImage(cl_context context, - cl_mem_flags flags, - const cl_image_format * image_format, - const cl_image_desc * image_desc, - void * host_ptr, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2 + cl_mem_flags flags, + const cl_image_format * image_format, + const cl_image_desc * image_desc, + void * host_ptr, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2 { cl_mem obj = (cl_mem) malloc(sizeof(struct _cl_mem)); - obj->dispatch = dispatchTable; + CL_INIT_OBJECT(obj, context); test_icd_stub_log("clCreateImage(%p, %x, %p, %p, %p, %p)\n", context, flags, @@ -506,7 +513,7 @@ clCreateImage2D(cl_context context , cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 { cl_mem obj = (cl_mem) malloc(sizeof(struct _cl_mem)); - obj->dispatch = dispatchTable; + CL_INIT_OBJECT(obj, context); test_icd_stub_log("clCreateImage2D(%p, %x, %p, %u, %u, %u, %p, %p)\n", context, flags, @@ -514,7 +521,8 @@ clCreateImage2D(cl_context context , image_width, image_height, image_row_pitch, - host_ptr); + host_ptr, + errcode_ret); test_icd_stub_log("Value returned: %p\n", obj); return obj; @@ -533,7 +541,7 @@ clCreateImage3D(cl_context context, cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 { cl_mem obj = (cl_mem) malloc(sizeof(struct _cl_mem)); - obj->dispatch = dispatchTable; + CL_INIT_OBJECT(obj, context); test_icd_stub_log("clCreateImage3D(%p, %x, %p, %u, %u, %u, %u, %u, %p, %p)\n", context, flags, @@ -550,6 +558,52 @@ clCreateImage3D(cl_context context, return obj; } +CL_API_ENTRY cl_mem CL_API_CALL +clCreateBufferWithProperties(cl_context context , + const cl_mem_properties * properties, + cl_mem_flags flags , + size_t size , + void * host_ptr , + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_3_0 +{ + cl_mem obj = (cl_mem) malloc(sizeof(struct _cl_mem)); + CL_INIT_OBJECT(obj, context); + test_icd_stub_log("clCreateBufferWithProperties(%p, %p, %x, %u, %p, %p)\n", + context, + properties, + flags, + size, + host_ptr, + errcode_ret); + + test_icd_stub_log("Value returned: %p\n", obj); + return obj; +} + +CL_API_ENTRY cl_mem CL_API_CALL +clCreateImageWithProperties(cl_context context, + const cl_mem_properties * properties, + cl_mem_flags flags, + const cl_image_format * image_format, + const cl_image_desc * image_desc, + void * host_ptr, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_3_0 +{ + cl_mem obj = (cl_mem) malloc(sizeof(struct _cl_mem)); + CL_INIT_OBJECT(obj, context); + test_icd_stub_log("clCreateImageWithProperties(%p, %p, %x, %p, %p, %p, %p)\n", + context, + properties, + flags, + image_format, + image_desc, + host_ptr, + errcode_ret); + + test_icd_stub_log("Value returned: %p\n", obj); + return obj; +} + CL_API_ENTRY cl_int CL_API_CALL clRetainMemObject(cl_mem memobj) CL_API_SUFFIX__VERSION_1_0 { @@ -638,10 +692,10 @@ clSetMemObjectDestructorCallback(cl_mem memobj , memobj, pfn_notify, user_data); - pfn_notify(memobj, NULL); + pfn_notify(memobj, user_data); test_icd_stub_log("setmemobjectdestructor_callback(%p, %p)\n", memobj, - NULL); + user_data); test_icd_stub_log("Value returned: %d\n", return_value); return return_value; @@ -656,7 +710,7 @@ clCreateSampler(cl_context context , cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 { cl_sampler obj = (cl_sampler) malloc(sizeof(struct _cl_sampler)); - obj->dispatch = dispatchTable; + CL_INIT_OBJECT(obj, context); test_icd_stub_log("clCreateSampler(%p, %u, %u, %u, %p)\n", context, normalized_coords, @@ -715,7 +769,7 @@ clCreateProgramWithSource(cl_context context , cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 { cl_program obj = (cl_program) malloc(sizeof(struct _cl_program)); - obj->dispatch = dispatchTable; + CL_INIT_OBJECT(obj, context); test_icd_stub_log("clCreateProgramWithSource(%p, %u, %p, %p, %p)\n", context, count, @@ -737,7 +791,7 @@ clCreateProgramWithBinary(cl_context context , cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 { cl_program obj = (cl_program) malloc(sizeof(struct _cl_program)); - obj->dispatch = dispatchTable; + CL_INIT_OBJECT(obj, context); test_icd_stub_log("clCreateProgramWithBinary(%p, %u, %p, %p, %p, %p, %p)\n", context, num_devices, @@ -759,7 +813,7 @@ clCreateProgramWithBuiltInKernels(cl_context context , cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2 { cl_program obj = (cl_program) malloc(sizeof(struct _cl_program)); - obj->dispatch = dispatchTable; + CL_INIT_OBJECT(obj, context); test_icd_stub_log("clCreateProgramWithBuiltInKernels(%p, %u, %p, %p, %p)\n", context, num_devices, @@ -835,6 +889,7 @@ clCompileProgram(cl_program program , void (CL_CALLBACK * pfn_notify)(cl_program program , void * user_data), void * user_data) CL_API_SUFFIX__VERSION_1_2 { + (void)input_headers; cl_int return_value = CL_OUT_OF_RESOURCES; test_icd_stub_log("clCompileProgram(%p, %u, %p, %p, %u, %p, %p, %p)\n", program, @@ -862,8 +917,8 @@ clLinkProgram(cl_context context , void * user_data , cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2 { - cl_program obj = (cl_program) malloc(sizeof(cl_program)); - obj->dispatch = dispatchTable; + cl_program obj = (cl_program) malloc(sizeof(struct _cl_program)); + CL_INIT_OBJECT(obj, context); test_icd_stub_log("clLinkProgram(%p, %u, %p, %p, %u, %p, %p, %p, %p)\n", context, num_devices, @@ -882,10 +937,10 @@ clLinkProgram(cl_context context , CL_API_ENTRY cl_int CL_API_CALL -clUnloadPlatformCompiler(cl_platform_id platform) CL_API_SUFFIX__VERSION_1_2 +clUnloadPlatformCompiler(cl_platform_id platform_id) CL_API_SUFFIX__VERSION_1_2 { cl_int return_value = CL_OUT_OF_RESOURCES; - test_icd_stub_log("clUnloadPlatformCompiler(%p)\n", platform); + test_icd_stub_log("clUnloadPlatformCompiler(%p)\n", platform_id); test_icd_stub_log("Value returned: %d\n", return_value); return return_value; } @@ -937,7 +992,7 @@ clCreateKernel(cl_program program , cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0 { cl_kernel obj = (cl_kernel) malloc(sizeof(struct _cl_kernel)); - obj->dispatch = dispatchTable; + CL_INIT_OBJECT(obj, program); test_icd_stub_log("clCreateKernel(%p, %p, %p)\n", program, kernel_name, @@ -1099,7 +1154,7 @@ clCreateUserEvent(cl_context context , cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_1 { cl_event obj = (cl_event) malloc(sizeof(struct _cl_event)); - obj->dispatch = dispatchTable; + CL_INIT_OBJECT(obj, context); test_icd_stub_log("clCreateUserEvent(%p, %p)\n", context, errcode_ret); test_icd_stub_log("Value returned: %p\n", obj); return obj; @@ -1767,14 +1822,15 @@ clEnqueueNativeKernel(cl_command_queue command_queue , return return_value; } -CL_API_ENTRY void * CL_API_CALL -clGetExtensionFunctionAddressForPlatform(cl_platform_id platform , - const char * func_name) CL_API_SUFFIX__VERSION_1_2 +static void extFunc(void) { } + +CL_API_ENTRY void *CL_API_CALL clGetExtensionFunctionAddressForPlatform( + cl_platform_id platform_id, + const char *func_name) CL_API_SUFFIX__VERSION_1_2 { - void *return_value = (void *) malloc(sizeof(void *)); + void *return_value = (void *)(size_t)&extFunc; test_icd_stub_log("clGetExtensionFunctionAddressForPlatform(%p, %p)\n", - platform, - func_name); + platform_id, func_name); test_icd_stub_log("Value returned: %p\n", return_value); return return_value; @@ -1886,14 +1942,17 @@ clIcdGetPlatformIDsKHR(cl_uint num_entries, platform = (cl_platform_id) malloc(sizeof(struct _cl_platform_id)); memset(platform, 0, sizeof(struct _cl_platform_id)); - platform->dispatch = dispatchTable; + CL_INIT_PLATFORM(platform, dispatchTable); platform->version = "OpenCL 1.2 Stub"; platform->vendor = "stubvendorxxx"; platform->profile = "stubprofilexxx"; +#if defined(CL_ENABLE_ICD2) + platform->name = "ICD_LOADER_TEST_OPENCL_STUB_ICD2"; +#else platform->name = "ICD_LOADER_TEST_OPENCL_STUB"; +#endif platform->extensions = "cl_khr_icd cl_khr_gl cl_khr_d3d10"; platform->suffix = "ilts"; - platform->dispatch = dispatchTable; initialized = CL_TRUE; } diff --git a/test/driver_stub/cl_ext.c b/test/driver_stub/cl_ext.c index ece0c591..b412f934 100644 --- a/test/driver_stub/cl_ext.c +++ b/test/driver_stub/cl_ext.c @@ -3,6 +3,12 @@ #define CL_USE_DEPRECATED_OPENCL_1_1_APIS #include "CL/cl.h" #include "CL/cl_ext.h" +#include "cl_khr_icd2.h" + +#if defined(CL_ENABLE_ICD2) +CL_API_ENTRY clIcdGetFunctionAddressForPlatformKHR_t clIcdGetFunctionAddressForPlatformKHR; +CL_API_ENTRY clIcdSetPlatformDispatchDataKHR_t clIcdSetPlatformDispatchDataKHR; +#endif struct driverStubextFunc_st { @@ -10,11 +16,15 @@ struct driverStubextFunc_st void *func; }; -#define EXT_FUNC(name) { #name, (void*)(name) } +#define EXT_FUNC(name) { #name, (void*)(intptr_t)(name) } static struct driverStubextFunc_st clExtensions[] = { EXT_FUNC(clIcdGetPlatformIDsKHR), +#ifdef CL_ENABLE_ICD2 + EXT_FUNC(clIcdGetFunctionAddressForPlatformKHR), + EXT_FUNC(clIcdSetPlatformDispatchDataKHR), +#endif //CL_ENABLE_ICD2 }; static const int clExtensionCount = sizeof(clExtensions) / sizeof(clExtensions[0]); diff --git a/test/driver_stub/cl_gl.c b/test/driver_stub/cl_gl.c index 3cc5cbb8..e1954639 100644 --- a/test/driver_stub/cl_gl.c +++ b/test/driver_stub/cl_gl.c @@ -1,5 +1,4 @@ #include -#include #include // Need to rename all CL API functions to prevent ICD loader functions calling @@ -207,7 +206,7 @@ clGetGLContextInfoKHR(const cl_context_properties * properties, 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_int * errcode_ret ) CL_API_SUFFIX__VERSION_1_1 { cl_event ret_event = (cl_event)(SIZE_T_MAX); diff --git a/test/driver_stub/driver_stub.def b/test/driver_stub/driver_stub.def index 5b238e8e..1ec27601 100644 --- a/test/driver_stub/driver_stub.def +++ b/test/driver_stub/driver_stub.def @@ -1,3 +1,2 @@ EXPORTS clGetExtensionFunctionAddress -clIcdGetPlatformIDsKHR diff --git a/test/driver_stub/icd.c b/test/driver_stub/icd.c index d2b1b2bd..1c815bbf 100644 --- a/test/driver_stub/icd.c +++ b/test/driver_stub/icd.c @@ -7,6 +7,9 @@ #define CL_USE_DEPRECATED_OPENCL_1_0_APIS #define CL_USE_DEPRECATED_OPENCL_1_1_APIS #define CL_USE_DEPRECATED_OPENCL_1_2_APIS +#define CL_USE_DEPRECATED_OPENCL_2_0_APIS +#define CL_USE_DEPRECATED_OPENCL_2_1_APIS +#define CL_USE_DEPRECATED_OPENCL_2_2_APIS // Need to rename all CL API functions to prevent ICD loader functions calling // themselves via the dispatch table. Include this before cl headers. @@ -14,7 +17,12 @@ #include "CL/cl.h" #include "CL/cl_gl.h" -#include "CL/cl_gl_ext.h" + +#if defined(CL_ENABLE_ICD2) +#include "cl_khr_icd2.h" +CL_API_ENTRY clIcdGetFunctionAddressForPlatformKHR_t clIcdGetFunctionAddressForPlatformKHR; +CL_API_ENTRY clIcdSetPlatformDispatchDataKHR_t clIcdSetPlatformDispatchDataKHR; +#endif /* * Prototypes for deprecated functions no longer present in cl.h @@ -27,7 +35,7 @@ clSetCommandQueueProperty(cl_command_queue /* command_queue */, #define ICD_DISPATCH_TABLE_ENTRY(fn) \ assert(dispatchTable->entryCount < 256); \ - dispatchTable->entries[dispatchTable->entryCount++] = (void*)(fn) + dispatchTable->entries[dispatchTable->entryCount++] = (void*)(intptr_t)(fn) cl_int cliIcdDispatchTableCreate(CLIicdDispatchTable **outDispatchTable) { @@ -43,7 +51,11 @@ cl_int cliIcdDispatchTableCreate(CLIicdDispatchTable **outDispatchTable) memset(dispatchTable, 0, sizeof(*dispatchTable)); // OpenCL 1.0 +#ifdef CL_ENABLE_ICD2 + ICD_DISPATCH_TABLE_ENTRY ( CL_ICD2_TAG_KHR ); +#else ICD_DISPATCH_TABLE_ENTRY ( clGetPlatformIDs ); +#endif ICD_DISPATCH_TABLE_ENTRY ( clGetPlatformInfo ); ICD_DISPATCH_TABLE_ENTRY ( clGetDeviceIDs ); ICD_DISPATCH_TABLE_ENTRY ( clGetDeviceInfo ); @@ -74,7 +86,11 @@ cl_int cliIcdDispatchTableCreate(CLIicdDispatchTable **outDispatchTable) ICD_DISPATCH_TABLE_ENTRY ( clRetainProgram ); ICD_DISPATCH_TABLE_ENTRY ( clReleaseProgram ); ICD_DISPATCH_TABLE_ENTRY ( clBuildProgram ); +#ifdef CL_ENABLE_ICD2 + ICD_DISPATCH_TABLE_ENTRY ( CL_ICD2_TAG_KHR ); +#else ICD_DISPATCH_TABLE_ENTRY ( clUnloadCompiler ); +#endif ICD_DISPATCH_TABLE_ENTRY ( clGetProgramInfo ); ICD_DISPATCH_TABLE_ENTRY ( clGetProgramBuildInfo ); ICD_DISPATCH_TABLE_ENTRY ( clCreateKernel ); @@ -148,12 +164,15 @@ cl_int cliIcdDispatchTableCreate(CLIicdDispatchTable **outDispatchTable) ICD_DISPATCH_TABLE_ENTRY ( clEnqueueWriteBufferRect); ICD_DISPATCH_TABLE_ENTRY ( clEnqueueCopyBufferRect); + /* cl_ext_device_fission */ ICD_DISPATCH_TABLE_ENTRY ( /*clCreateSubDevicesEXT*/NULL); ICD_DISPATCH_TABLE_ENTRY ( /*clRetainDeviceEXT*/ NULL); ICD_DISPATCH_TABLE_ENTRY ( /*clReleaseDevice*/NULL); + /* cl_khr_gl_event */ ICD_DISPATCH_TABLE_ENTRY ( clCreateEventFromGLsyncKHR); + /* OpenCL 1.2 */ ICD_DISPATCH_TABLE_ENTRY ( clCreateSubDevices); ICD_DISPATCH_TABLE_ENTRY ( clRetainDevice); ICD_DISPATCH_TABLE_ENTRY ( clReleaseDevice); @@ -171,6 +190,64 @@ cl_int cliIcdDispatchTableCreate(CLIicdDispatchTable **outDispatchTable) ICD_DISPATCH_TABLE_ENTRY ( clGetExtensionFunctionAddressForPlatform); ICD_DISPATCH_TABLE_ENTRY ( clCreateFromGLTexture); + /* cl_khr_d3d11_sharing */ + 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 ); + ICD_DISPATCH_TABLE_ENTRY( NULL ); + + /* cl_khr_dx9_media_sharing */ + ICD_DISPATCH_TABLE_ENTRY( NULL ); + ICD_DISPATCH_TABLE_ENTRY( NULL ); + ICD_DISPATCH_TABLE_ENTRY( NULL ); + + /* cl_khr_egl_image */ + ICD_DISPATCH_TABLE_ENTRY( NULL ); + ICD_DISPATCH_TABLE_ENTRY( NULL ); + ICD_DISPATCH_TABLE_ENTRY( NULL ); + + /* cl_khr_egl_event */ + ICD_DISPATCH_TABLE_ENTRY( NULL ); + + /* OpenCL 2.0 */ + 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 ); + 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 ); + ICD_DISPATCH_TABLE_ENTRY( NULL ); + + /* cl_khr_sub_groups */ + ICD_DISPATCH_TABLE_ENTRY( NULL ); + + /* OpenCL 2.1 */ + 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 ); + ICD_DISPATCH_TABLE_ENTRY( NULL ); + + /* OpenCL 2.2 */ + ICD_DISPATCH_TABLE_ENTRY( NULL ); + ICD_DISPATCH_TABLE_ENTRY( NULL ); + + /* OpenCL 3.0 */ + ICD_DISPATCH_TABLE_ENTRY ( clCreateBufferWithProperties ); + ICD_DISPATCH_TABLE_ENTRY ( clCreateImageWithProperties ); + ICD_DISPATCH_TABLE_ENTRY ( clSetContextDestructorCallback ); + // return success *outDispatchTable = dispatchTable; return CL_SUCCESS; @@ -184,3 +261,225 @@ cliIcdDispatchTableDestroy(CLIicdDispatchTable *dispatchTable) { free(dispatchTable); } + +#ifdef CL_ENABLE_ICD2 + +#define ICD_GET_FUNCTION_ADDRESS(fn) \ +do \ +{ \ + if (!strcmp(#fn, func_name)) \ + return (void*)(intptr_t)(fn); \ +} while (0) + +void * CL_API_CALL clIcdGetFunctionAddressForPlatformKHR( + cl_platform_id platform, + const char* func_name) +{ + (void)platform; + ICD_GET_FUNCTION_ADDRESS ( clGetPlatformIDs ); + ICD_GET_FUNCTION_ADDRESS ( clGetPlatformInfo ); + ICD_GET_FUNCTION_ADDRESS ( clGetDeviceIDs ); + ICD_GET_FUNCTION_ADDRESS ( clGetDeviceInfo ); + ICD_GET_FUNCTION_ADDRESS ( clCreateContext ); + ICD_GET_FUNCTION_ADDRESS ( clCreateContextFromType ); + ICD_GET_FUNCTION_ADDRESS ( clRetainContext ); + ICD_GET_FUNCTION_ADDRESS ( clReleaseContext ); + ICD_GET_FUNCTION_ADDRESS ( clGetContextInfo ); + ICD_GET_FUNCTION_ADDRESS ( clCreateCommandQueue ); + ICD_GET_FUNCTION_ADDRESS ( clRetainCommandQueue ); + ICD_GET_FUNCTION_ADDRESS ( clReleaseCommandQueue ); + ICD_GET_FUNCTION_ADDRESS ( clGetCommandQueueInfo ); + ICD_GET_FUNCTION_ADDRESS ( clSetCommandQueueProperty ); + ICD_GET_FUNCTION_ADDRESS ( clCreateBuffer ); + ICD_GET_FUNCTION_ADDRESS ( clCreateImage2D ); + ICD_GET_FUNCTION_ADDRESS ( clCreateImage3D ); + ICD_GET_FUNCTION_ADDRESS ( clRetainMemObject ); + ICD_GET_FUNCTION_ADDRESS ( clReleaseMemObject ); + ICD_GET_FUNCTION_ADDRESS ( clGetSupportedImageFormats ); + ICD_GET_FUNCTION_ADDRESS ( clGetMemObjectInfo ); + ICD_GET_FUNCTION_ADDRESS ( clGetImageInfo ); + ICD_GET_FUNCTION_ADDRESS ( clCreateSampler ); + ICD_GET_FUNCTION_ADDRESS ( clRetainSampler ); + ICD_GET_FUNCTION_ADDRESS ( clReleaseSampler ); + ICD_GET_FUNCTION_ADDRESS ( clGetSamplerInfo ); + ICD_GET_FUNCTION_ADDRESS ( clCreateProgramWithSource ); + ICD_GET_FUNCTION_ADDRESS ( clCreateProgramWithBinary ); + ICD_GET_FUNCTION_ADDRESS ( clRetainProgram ); + ICD_GET_FUNCTION_ADDRESS ( clReleaseProgram ); + ICD_GET_FUNCTION_ADDRESS ( clBuildProgram ); + ICD_GET_FUNCTION_ADDRESS ( clUnloadCompiler ); + ICD_GET_FUNCTION_ADDRESS ( clGetProgramInfo ); + ICD_GET_FUNCTION_ADDRESS ( clGetProgramBuildInfo ); + ICD_GET_FUNCTION_ADDRESS ( clCreateKernel ); + ICD_GET_FUNCTION_ADDRESS ( clCreateKernelsInProgram ); + ICD_GET_FUNCTION_ADDRESS ( clRetainKernel ); + ICD_GET_FUNCTION_ADDRESS ( clReleaseKernel ); + ICD_GET_FUNCTION_ADDRESS ( clSetKernelArg ); + ICD_GET_FUNCTION_ADDRESS ( clGetKernelInfo ); + ICD_GET_FUNCTION_ADDRESS ( clGetKernelWorkGroupInfo ); + ICD_GET_FUNCTION_ADDRESS ( clWaitForEvents ); + ICD_GET_FUNCTION_ADDRESS ( clGetEventInfo ); + ICD_GET_FUNCTION_ADDRESS ( clRetainEvent ); + ICD_GET_FUNCTION_ADDRESS ( clReleaseEvent ); + ICD_GET_FUNCTION_ADDRESS ( clGetEventProfilingInfo ); + ICD_GET_FUNCTION_ADDRESS ( clFlush ); + ICD_GET_FUNCTION_ADDRESS ( clFinish ); + ICD_GET_FUNCTION_ADDRESS ( clEnqueueReadBuffer ); + ICD_GET_FUNCTION_ADDRESS ( clEnqueueWriteBuffer ); + ICD_GET_FUNCTION_ADDRESS ( clEnqueueCopyBuffer ); + ICD_GET_FUNCTION_ADDRESS ( clEnqueueReadImage ); + ICD_GET_FUNCTION_ADDRESS ( clEnqueueWriteImage ); + ICD_GET_FUNCTION_ADDRESS ( clEnqueueCopyImage ); + ICD_GET_FUNCTION_ADDRESS ( clEnqueueCopyImageToBuffer ); + ICD_GET_FUNCTION_ADDRESS ( clEnqueueCopyBufferToImage ); + ICD_GET_FUNCTION_ADDRESS ( clEnqueueMapBuffer ); + ICD_GET_FUNCTION_ADDRESS ( clEnqueueMapImage ); + ICD_GET_FUNCTION_ADDRESS ( clEnqueueUnmapMemObject ); + ICD_GET_FUNCTION_ADDRESS ( clEnqueueNDRangeKernel ); + ICD_GET_FUNCTION_ADDRESS ( clEnqueueTask ); + ICD_GET_FUNCTION_ADDRESS ( clEnqueueNativeKernel ); + ICD_GET_FUNCTION_ADDRESS ( clEnqueueMarker ); + ICD_GET_FUNCTION_ADDRESS ( clEnqueueWaitForEvents ); + ICD_GET_FUNCTION_ADDRESS ( clEnqueueBarrier ); + ICD_GET_FUNCTION_ADDRESS ( clGetExtensionFunctionAddress ); + ICD_GET_FUNCTION_ADDRESS ( clCreateFromGLBuffer ); + ICD_GET_FUNCTION_ADDRESS ( clCreateFromGLTexture2D ); + ICD_GET_FUNCTION_ADDRESS ( clCreateFromGLTexture3D ); + ICD_GET_FUNCTION_ADDRESS ( clCreateFromGLRenderbuffer ); + ICD_GET_FUNCTION_ADDRESS ( clGetGLObjectInfo ); + ICD_GET_FUNCTION_ADDRESS ( clGetGLTextureInfo ); + ICD_GET_FUNCTION_ADDRESS ( clEnqueueAcquireGLObjects ); + ICD_GET_FUNCTION_ADDRESS ( clEnqueueReleaseGLObjects ); + + // cl_khr_gl_sharing + ICD_GET_FUNCTION_ADDRESS ( clGetGLContextInfoKHR ); + +#if 0 + // cl_khr_d3d10_sharing (windows-only) +#if 0 && defined(_WIN32) + ICD_GET_FUNCTION_ADDRESS ( clGetDeviceIDsFromD3D10KHR ); + ICD_GET_FUNCTION_ADDRESS ( clCreateFromD3D10BufferKHR ); + ICD_GET_FUNCTION_ADDRESS ( clCreateFromD3D10Texture2DKHR ); + ICD_GET_FUNCTION_ADDRESS ( clCreateFromD3D10Texture3DKHR ); + ICD_GET_FUNCTION_ADDRESS ( clEnqueueAcquireD3D10ObjectsKHR ); + ICD_GET_FUNCTION_ADDRESS ( clEnqueueReleaseD3D10ObjectsKHR ); +#else + ICD_GET_FUNCTION_ADDRESS( NULL ); + ICD_GET_FUNCTION_ADDRESS( NULL ); + ICD_GET_FUNCTION_ADDRESS( NULL ); + ICD_GET_FUNCTION_ADDRESS( NULL ); + ICD_GET_FUNCTION_ADDRESS( NULL ); + ICD_GET_FUNCTION_ADDRESS( NULL ); +#endif +#endif + + // OpenCL 1.1 + ICD_GET_FUNCTION_ADDRESS ( clSetEventCallback); + ICD_GET_FUNCTION_ADDRESS ( clCreateSubBuffer); + ICD_GET_FUNCTION_ADDRESS ( clSetMemObjectDestructorCallback); + ICD_GET_FUNCTION_ADDRESS ( clCreateUserEvent); + ICD_GET_FUNCTION_ADDRESS ( clSetUserEventStatus); + ICD_GET_FUNCTION_ADDRESS ( clEnqueueReadBufferRect); + ICD_GET_FUNCTION_ADDRESS ( clEnqueueWriteBufferRect); + ICD_GET_FUNCTION_ADDRESS ( clEnqueueCopyBufferRect); + +#if 0 + /* cl_ext_device_fission */ + ICD_GET_FUNCTION_ADDRESS ( /*clCreateSubDevicesEXT*/NULL); + ICD_GET_FUNCTION_ADDRESS ( /*clRetainDeviceEXT*/ NULL); + ICD_GET_FUNCTION_ADDRESS ( /*clReleaseDevice*/NULL); +#endif + + /* cl_khr_gl_event */ + ICD_GET_FUNCTION_ADDRESS ( clCreateEventFromGLsyncKHR); + + /* OpenCL 1.2 */ + ICD_GET_FUNCTION_ADDRESS ( clCreateSubDevices); + ICD_GET_FUNCTION_ADDRESS ( clRetainDevice); + ICD_GET_FUNCTION_ADDRESS ( clReleaseDevice); + ICD_GET_FUNCTION_ADDRESS ( clCreateImage); + ICD_GET_FUNCTION_ADDRESS ( clCreateProgramWithBuiltInKernels); + ICD_GET_FUNCTION_ADDRESS ( clCompileProgram); + ICD_GET_FUNCTION_ADDRESS ( clLinkProgram); + ICD_GET_FUNCTION_ADDRESS ( clUnloadPlatformCompiler); + ICD_GET_FUNCTION_ADDRESS ( clGetKernelArgInfo); + ICD_GET_FUNCTION_ADDRESS ( clEnqueueFillBuffer); + ICD_GET_FUNCTION_ADDRESS ( clEnqueueFillImage); + ICD_GET_FUNCTION_ADDRESS ( clEnqueueMigrateMemObjects); + ICD_GET_FUNCTION_ADDRESS ( clEnqueueMarkerWithWaitList); + ICD_GET_FUNCTION_ADDRESS ( clEnqueueBarrierWithWaitList); + ICD_GET_FUNCTION_ADDRESS ( clGetExtensionFunctionAddressForPlatform); + ICD_GET_FUNCTION_ADDRESS ( clCreateFromGLTexture); + +#if 0 + /* cl_khr_d3d11_sharing */ + ICD_GET_FUNCTION_ADDRESS( NULL ); + ICD_GET_FUNCTION_ADDRESS( NULL ); + ICD_GET_FUNCTION_ADDRESS( NULL ); + ICD_GET_FUNCTION_ADDRESS( NULL ); + ICD_GET_FUNCTION_ADDRESS( NULL ); + ICD_GET_FUNCTION_ADDRESS( NULL ); + ICD_GET_FUNCTION_ADDRESS( NULL ); + + /* cl_khr_dx9_media_sharing */ + ICD_GET_FUNCTION_ADDRESS( NULL ); + ICD_GET_FUNCTION_ADDRESS( NULL ); + ICD_GET_FUNCTION_ADDRESS( NULL ); + + /* cl_khr_egl_image */ + ICD_GET_FUNCTION_ADDRESS( NULL ); + ICD_GET_FUNCTION_ADDRESS( NULL ); + ICD_GET_FUNCTION_ADDRESS( NULL ); + + /* cl_khr_egl_event */ + ICD_GET_FUNCTION_ADDRESS( NULL ); + + /* OpenCL 2.0 */ + ICD_GET_FUNCTION_ADDRESS( NULL ); + ICD_GET_FUNCTION_ADDRESS( NULL ); + ICD_GET_FUNCTION_ADDRESS( NULL ); + ICD_GET_FUNCTION_ADDRESS( NULL ); + ICD_GET_FUNCTION_ADDRESS( NULL ); + ICD_GET_FUNCTION_ADDRESS( NULL ); + ICD_GET_FUNCTION_ADDRESS( NULL ); + ICD_GET_FUNCTION_ADDRESS( NULL ); + ICD_GET_FUNCTION_ADDRESS( NULL ); + ICD_GET_FUNCTION_ADDRESS( NULL ); + ICD_GET_FUNCTION_ADDRESS( NULL ); + ICD_GET_FUNCTION_ADDRESS( NULL ); + ICD_GET_FUNCTION_ADDRESS( NULL ); + + /* cl_khr_sub_groups */ + ICD_GET_FUNCTION_ADDRESS( NULL ); + + /* OpenCL 2.1 */ + ICD_GET_FUNCTION_ADDRESS( NULL ); + ICD_GET_FUNCTION_ADDRESS( NULL ); + ICD_GET_FUNCTION_ADDRESS( NULL ); + ICD_GET_FUNCTION_ADDRESS( NULL ); + ICD_GET_FUNCTION_ADDRESS( NULL ); + ICD_GET_FUNCTION_ADDRESS( NULL ); + ICD_GET_FUNCTION_ADDRESS( NULL ); + + /* OpenCL 2.2 */ + ICD_GET_FUNCTION_ADDRESS( NULL ); + ICD_GET_FUNCTION_ADDRESS( NULL ); +#endif + + /* OpenCL 3.0 */ + ICD_GET_FUNCTION_ADDRESS ( clCreateBufferWithProperties ); + ICD_GET_FUNCTION_ADDRESS ( clCreateImageWithProperties ); + ICD_GET_FUNCTION_ADDRESS ( clSetContextDestructorCallback ); + + return NULL; +} + +cl_int CL_API_CALL +clIcdSetPlatformDispatchDataKHR( + cl_platform_id platform, + void *disp_data) +{ + ((struct CLIplatform_st *)platform)->dispData = disp_data; + return CL_SUCCESS; +} +#endif //CL_ENABLE_ICD2 diff --git a/test/driver_stub/icd_structs.h b/test/driver_stub/icd_structs.h index 4b7e68b1..591618d2 100644 --- a/test/driver_stub/icd_structs.h +++ b/test/driver_stub/icd_structs.h @@ -10,9 +10,48 @@ struct CLIicdDispatchTable_st int entryCount; }; +#ifdef CL_ENABLE_ICD2 + +#define CL_OBJECT_BODY \ + CLIicdDispatchTable* dispatch; \ + void* dispData + +#define CL_INIT_OBJECT(obj, parent) \ +do \ +{ \ + obj->dispatch = parent->dispatch; \ + obj->dispData = parent->dispData; \ +} while (0) + +#define CL_INIT_PLATFORM(obj, table) \ +do \ +{ \ + obj->dispatch = table; \ + obj->dispData = NULL; \ +} while (0) + +#else //defined(CL_ENABLE_ICD2) + +#define CL_OBJECT_BODY \ + CLIicdDispatchTable* dispatch + +#define CL_INIT_OBJECT(obj, parent) \ +do \ +{ \ + obj->dispatch = parent->dispatch; \ +} while (0) + +#define CL_INIT_PLATFORM(obj, table) \ +do \ +{ \ + obj->dispatch = table; \ +} while (0) + +#endif //defined(CL_ENABLE_ICD2) + struct CLIplatform_st { - CLIicdDispatchTable* dispatch; + CL_OBJECT_BODY; }; #endif /* _ICD_STRUCTS_H_ */ diff --git a/test/driver_stub/rename_api.h b/test/driver_stub/rename_api.h index 7d5130ce..555695d4 100644 --- a/test/driver_stub/rename_api.h +++ b/test/driver_stub/rename_api.h @@ -102,5 +102,8 @@ #define clEnqueueReleaseGLObjects ___clEnqueueReleaseGLObjects #define clGetGLContextInfoKHR ___clGetGLContextInfoKHR #define clCreateEventFromGLsyncKHR ___clCreateEventFromGLsyncKHR +#define clCreateBufferWithProperties ___clCreateBufferWithProperties +#define clCreateImageWithProperties ___clCreateImageWithProperties +#define clSetContextDestructorCallback ___clSetContextDestructorCallback #endif /* __RENAME_API_H__ */ diff --git a/test/inc/platform/icd_test_log.h b/test/inc/platform/icd_test_log.h index 6db0bfe6..7b08d9f3 100644 --- a/test/inc/platform/icd_test_log.h +++ b/test/inc/platform/icd_test_log.h @@ -1,12 +1,29 @@ #ifndef _ICD_TEST_LOG_H_ #define _ICD_TEST_LOG_H_ -#if defined (_WIN32) -#define DllExport __declspec( dllexport ) +#if defined(_WIN32) +#include #else -#define DllExport +#include #endif +#if defined(_WIN32) || defined(__CYGWIN__) + #define DllExport __declspec(dllexport) +#else + #ifndef __has_attribute + #define __has_attribute(x) 0 // Compatibility with non-clang compilers. + #endif + #if (defined(__GNUC__) && (__GNUC__ >= 4)) ||\ + (defined(__clang__) && __has_attribute(visibility)) + #define DllExport __attribute__((visibility("default"))) + #else + #define DllExport + #endif +#endif + +DllExport const char * log_getenv(const char *name, const char *dflt); +DllExport void log_freeenv(const char *var); + 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); diff --git a/test/layer/CMakeLists.txt b/test/layer/CMakeLists.txt new file mode 100644 index 00000000..ea4e0e4b --- /dev/null +++ b/test/layer/CMakeLists.txt @@ -0,0 +1,22 @@ +set (OPENCL_PRINT_LAYER_SOURCES + icd_print_layer.c + icd_print_layer.h + icd_print_layer_generated.c) + +if (WIN32) + list (APPEND OPENCL_PRINT_LAYER_SOURCES icd_print_layer.def) +else () + if (NOT APPLE) + list (APPEND OPENCL_PRINT_LAYER_SOURCES icd_print_layer.map) + endif () +endif () + +add_library (PrintLayer SHARED ${OPENCL_PRINT_LAYER_SOURCES}) + +target_include_directories(PrintLayer PRIVATE ${PARENT_DIR}/include) +target_link_libraries(PrintLayer PUBLIC OpenCL::Headers) +target_compile_definitions (PrintLayer PRIVATE CL_TARGET_OPENCL_VERSION=300) + +if (NOT WIN32 AND NOT APPLE) + set_target_properties (PrintLayer PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/icd_print_layer.map") +endif () diff --git a/test/layer/icd_print_layer.c b/test/layer/icd_print_layer.c new file mode 100644 index 00000000..d8bf4627 --- /dev/null +++ b/test/layer/icd_print_layer.c @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2020 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#include "icd_print_layer.h" +#include +#include +#include + +struct _cl_icd_dispatch dispatch; + +const struct _cl_icd_dispatch *tdispatch; + +static cl_layer_api_version api_version = CL_LAYER_API_VERSION_100; +static const char name[] = "print_layer"; + +static inline cl_int +set_param_value( + size_t param_value_size, + void *param_value, + size_t *param_value_size_ret, + size_t src_size, + const void *src) { + if (param_value && param_value_size < src_size) + return CL_INVALID_VALUE; + if (param_value) + memcpy(param_value, src, src_size); + if (param_value_size_ret) + *param_value_size_ret = src_size; + return CL_SUCCESS; +} + +CL_API_ENTRY cl_int CL_API_CALL +clGetLayerInfo( + cl_layer_info param_name, + size_t param_value_size, + void *param_value, + size_t *param_value_size_ret) { + size_t sz = 0; + const void *src = NULL; + if (param_value_size && !param_value) + return CL_INVALID_VALUE; + if (!param_value && !param_value_size_ret) + return CL_INVALID_VALUE; + switch (param_name) { + case CL_LAYER_API_VERSION: + sz = sizeof(api_version); + src = &api_version; + break; + case CL_LAYER_NAME: + sz = sizeof(name); + src = name; + break; + default: + return CL_INVALID_VALUE; + } + return set_param_value(param_value_size, param_value, param_value_size_ret, sz, src); +} + +CL_API_ENTRY cl_int CL_API_CALL +clInitLayer( + cl_uint num_entries, + const struct _cl_icd_dispatch *target_dispatch, + cl_uint *num_entries_out, + const struct _cl_icd_dispatch **layer_dispatch_ret) { + if (!target_dispatch || !layer_dispatch_ret || !num_entries_out || num_entries < sizeof(dispatch)/sizeof(dispatch.clGetPlatformIDs)) + return CL_INVALID_VALUE; + + _init_dispatch(); + + tdispatch = target_dispatch; + *layer_dispatch_ret = &dispatch; + *num_entries_out = sizeof(dispatch)/sizeof(dispatch.clGetPlatformIDs); + + return CL_SUCCESS; +} + + diff --git a/test/layer/icd_print_layer.def b/test/layer/icd_print_layer.def new file mode 100644 index 00000000..c33a80b7 --- /dev/null +++ b/test/layer/icd_print_layer.def @@ -0,0 +1,3 @@ +EXPORTS +clGetLayerInfo +clInitLayer diff --git a/test/layer/icd_print_layer.h b/test/layer/icd_print_layer.h new file mode 100644 index 00000000..6c73fe6e --- /dev/null +++ b/test/layer/icd_print_layer.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2020 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#ifndef __ICD_PRINT_LAYER_H +#define __ICD_PRINT_LAYER_H + +#ifndef CL_USE_DEPRECATED_OPENCL_1_0_APIS +#define CL_USE_DEPRECATED_OPENCL_1_0_APIS +#endif + +#ifndef CL_USE_DEPRECATED_OPENCL_1_1_APIS +#define CL_USE_DEPRECATED_OPENCL_1_1_APIS +#endif + +#ifndef CL_USE_DEPRECATED_OPENCL_1_2_APIS +#define CL_USE_DEPRECATED_OPENCL_1_2_APIS +#endif + +#ifndef CL_USE_DEPRECATED_OPENCL_2_0_APIS +#define CL_USE_DEPRECATED_OPENCL_2_0_APIS +#endif + +#ifndef CL_USE_DEPRECATED_OPENCL_2_1_APIS +#define CL_USE_DEPRECATED_OPENCL_2_1_APIS +#endif + +#ifndef CL_USE_DEPRECATED_OPENCL_2_2_APIS +#define CL_USE_DEPRECATED_OPENCL_2_2_APIS +#endif + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern struct _cl_icd_dispatch dispatch; + +extern const struct _cl_icd_dispatch *tdispatch; + +extern void _init_dispatch(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __ICD_PRINT_LAYER_H */ diff --git a/test/layer/icd_print_layer.map b/test/layer/icd_print_layer.map new file mode 100644 index 00000000..b32d582a --- /dev/null +++ b/test/layer/icd_print_layer.map @@ -0,0 +1,8 @@ +{ + global: +clGetLayerInfo; +clInitLayer; + + local: + *; +}; diff --git a/test/layer/icd_print_layer_generated.c b/test/layer/icd_print_layer_generated.c new file mode 100644 index 00000000..ee9d19e5 --- /dev/null +++ b/test/layer/icd_print_layer_generated.c @@ -0,0 +1,2746 @@ +/* + * Copyright (c) 2020 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * OpenCL is a trademark of Apple Inc. used under license by Khronos. + */ + +#include "icd_print_layer.h" + +/////////////////////////////////////////////////////////////////////////////// +// Core APIs: +static cl_int CL_API_CALL clGetPlatformIDs_wrap( + cl_uint num_entries, + cl_platform_id* platforms, + cl_uint* num_platforms) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clGetPlatformIDs\n"); +return tdispatch->clGetPlatformIDs( + num_entries, + platforms, + num_platforms); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clGetPlatformInfo_wrap( + 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 +{ +printf("clGetPlatformInfo\n"); +return tdispatch->clGetPlatformInfo( + platform, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clGetDeviceIDs_wrap( + cl_platform_id platform, + cl_device_type device_type, + cl_uint num_entries, + cl_device_id* devices, + cl_uint* num_devices) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clGetDeviceIDs\n"); +return tdispatch->clGetDeviceIDs( + platform, + device_type, + num_entries, + devices, + num_devices); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clGetDeviceInfo_wrap( + cl_device_id device, + cl_device_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clGetDeviceInfo\n"); +return tdispatch->clGetDeviceInfo( + device, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_context CL_API_CALL clCreateContext_wrap( + const cl_context_properties* properties, + cl_uint num_devices, + const cl_device_id* devices, + void (CL_CALLBACK* pfn_notify)(const char* errinfo, const void* private_info, size_t cb, void* user_data), + void* user_data, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clCreateContext\n"); +return tdispatch->clCreateContext( + properties, + num_devices, + devices, + pfn_notify, + user_data, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_context CL_API_CALL clCreateContextFromType_wrap( + const cl_context_properties* properties, + cl_device_type device_type, + void (CL_CALLBACK* pfn_notify)(const char* errinfo, const void* private_info, size_t cb, void* user_data), + void* user_data, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clCreateContextFromType\n"); +return tdispatch->clCreateContextFromType( + properties, + device_type, + pfn_notify, + user_data, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clRetainContext_wrap( + cl_context context) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clRetainContext\n"); +return tdispatch->clRetainContext( + context); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clReleaseContext_wrap( + cl_context context) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clReleaseContext\n"); +return tdispatch->clReleaseContext( + context); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clGetContextInfo_wrap( + cl_context context, + cl_context_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clGetContextInfo\n"); +return tdispatch->clGetContextInfo( + context, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clRetainCommandQueue_wrap( + cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clRetainCommandQueue\n"); +return tdispatch->clRetainCommandQueue( + command_queue); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clReleaseCommandQueue_wrap( + cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clReleaseCommandQueue\n"); +return tdispatch->clReleaseCommandQueue( + command_queue); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clGetCommandQueueInfo_wrap( + cl_command_queue command_queue, + cl_command_queue_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clGetCommandQueueInfo\n"); +return tdispatch->clGetCommandQueueInfo( + command_queue, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_mem CL_API_CALL clCreateBuffer_wrap( + cl_context context, + cl_mem_flags flags, + size_t size, + void* host_ptr, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clCreateBuffer\n"); +return tdispatch->clCreateBuffer( + context, + flags, + size, + host_ptr, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clRetainMemObject_wrap( + cl_mem memobj) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clRetainMemObject\n"); +return tdispatch->clRetainMemObject( + memobj); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clReleaseMemObject_wrap( + cl_mem memobj) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clReleaseMemObject\n"); +return tdispatch->clReleaseMemObject( + memobj); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clGetSupportedImageFormats_wrap( + cl_context context, + cl_mem_flags flags, + cl_mem_object_type image_type, + cl_uint num_entries, + cl_image_format* image_formats, + cl_uint* num_image_formats) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clGetSupportedImageFormats\n"); +return tdispatch->clGetSupportedImageFormats( + context, + flags, + image_type, + num_entries, + image_formats, + num_image_formats); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clGetMemObjectInfo_wrap( + cl_mem memobj, + cl_mem_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clGetMemObjectInfo\n"); +return tdispatch->clGetMemObjectInfo( + memobj, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clGetImageInfo_wrap( + cl_mem image, + cl_image_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clGetImageInfo\n"); +return tdispatch->clGetImageInfo( + image, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clRetainSampler_wrap( + cl_sampler sampler) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clRetainSampler\n"); +return tdispatch->clRetainSampler( + sampler); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clReleaseSampler_wrap( + cl_sampler sampler) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clReleaseSampler\n"); +return tdispatch->clReleaseSampler( + sampler); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clGetSamplerInfo_wrap( + cl_sampler sampler, + cl_sampler_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clGetSamplerInfo\n"); +return tdispatch->clGetSamplerInfo( + sampler, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_program CL_API_CALL clCreateProgramWithSource_wrap( + cl_context context, + cl_uint count, + const char** strings, + const size_t* lengths, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clCreateProgramWithSource\n"); +return tdispatch->clCreateProgramWithSource( + context, + count, + strings, + lengths, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_program CL_API_CALL clCreateProgramWithBinary_wrap( + cl_context context, + cl_uint num_devices, + const cl_device_id* device_list, + const size_t* lengths, + const unsigned char** binaries, + cl_int* binary_status, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clCreateProgramWithBinary\n"); +return tdispatch->clCreateProgramWithBinary( + context, + num_devices, + device_list, + lengths, + binaries, + binary_status, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clRetainProgram_wrap( + cl_program program) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clRetainProgram\n"); +return tdispatch->clRetainProgram( + program); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clReleaseProgram_wrap( + cl_program program) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clReleaseProgram\n"); +return tdispatch->clReleaseProgram( + program); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clBuildProgram_wrap( + cl_program program, + cl_uint num_devices, + const cl_device_id* device_list, + const char* options, + void (CL_CALLBACK* pfn_notify)(cl_program program, void* user_data), + void* user_data) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clBuildProgram\n"); +return tdispatch->clBuildProgram( + program, + num_devices, + device_list, + options, + pfn_notify, + user_data); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clGetProgramInfo_wrap( + cl_program program, + cl_program_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clGetProgramInfo\n"); +return tdispatch->clGetProgramInfo( + program, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clGetProgramBuildInfo_wrap( + cl_program program, + cl_device_id device, + cl_program_build_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clGetProgramBuildInfo\n"); +return tdispatch->clGetProgramBuildInfo( + program, + device, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_kernel CL_API_CALL clCreateKernel_wrap( + cl_program program, + const char* kernel_name, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clCreateKernel\n"); +return tdispatch->clCreateKernel( + program, + kernel_name, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clCreateKernelsInProgram_wrap( + cl_program program, + cl_uint num_kernels, + cl_kernel* kernels, + cl_uint* num_kernels_ret) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clCreateKernelsInProgram\n"); +return tdispatch->clCreateKernelsInProgram( + program, + num_kernels, + kernels, + num_kernels_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clRetainKernel_wrap( + cl_kernel kernel) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clRetainKernel\n"); +return tdispatch->clRetainKernel( + kernel); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clReleaseKernel_wrap( + cl_kernel kernel) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clReleaseKernel\n"); +return tdispatch->clReleaseKernel( + kernel); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clSetKernelArg_wrap( + cl_kernel kernel, + cl_uint arg_index, + size_t arg_size, + const void* arg_value) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clSetKernelArg\n"); +return tdispatch->clSetKernelArg( + kernel, + arg_index, + arg_size, + arg_value); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clGetKernelInfo_wrap( + cl_kernel kernel, + cl_kernel_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clGetKernelInfo\n"); +return tdispatch->clGetKernelInfo( + kernel, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clGetKernelWorkGroupInfo_wrap( + cl_kernel kernel, + cl_device_id device, + cl_kernel_work_group_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clGetKernelWorkGroupInfo\n"); +return tdispatch->clGetKernelWorkGroupInfo( + kernel, + device, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clWaitForEvents_wrap( + cl_uint num_events, + const cl_event* event_list) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clWaitForEvents\n"); +return tdispatch->clWaitForEvents( + num_events, + event_list); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clGetEventInfo_wrap( + cl_event event, + cl_event_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clGetEventInfo\n"); +return tdispatch->clGetEventInfo( + event, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clRetainEvent_wrap( + cl_event event) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clRetainEvent\n"); +return tdispatch->clRetainEvent( + event); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clReleaseEvent_wrap( + cl_event event) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clReleaseEvent\n"); +return tdispatch->clReleaseEvent( + event); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clGetEventProfilingInfo_wrap( + cl_event event, + cl_profiling_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clGetEventProfilingInfo\n"); +return tdispatch->clGetEventProfilingInfo( + event, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clFlush_wrap( + cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clFlush\n"); +return tdispatch->clFlush( + command_queue); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clFinish_wrap( + cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clFinish\n"); +return tdispatch->clFinish( + command_queue); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clEnqueueReadBuffer_wrap( + cl_command_queue command_queue, + cl_mem buffer, + cl_bool blocking_read, + size_t offset, + size_t size, + void* ptr, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clEnqueueReadBuffer\n"); +return tdispatch->clEnqueueReadBuffer( + command_queue, + buffer, + blocking_read, + offset, + size, + ptr, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clEnqueueWriteBuffer_wrap( + cl_command_queue command_queue, + cl_mem buffer, + cl_bool blocking_write, + size_t offset, + size_t size, + const void* ptr, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clEnqueueWriteBuffer\n"); +return tdispatch->clEnqueueWriteBuffer( + command_queue, + buffer, + blocking_write, + offset, + size, + ptr, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clEnqueueCopyBuffer_wrap( + cl_command_queue command_queue, + cl_mem src_buffer, + cl_mem dst_buffer, + size_t src_offset, + size_t dst_offset, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clEnqueueCopyBuffer\n"); +return tdispatch->clEnqueueCopyBuffer( + command_queue, + src_buffer, + dst_buffer, + src_offset, + dst_offset, + size, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clEnqueueReadImage_wrap( + cl_command_queue command_queue, + cl_mem image, + cl_bool blocking_read, + const size_t* origin, + const size_t* region, + size_t row_pitch, + size_t slice_pitch, + void* ptr, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clEnqueueReadImage\n"); +return tdispatch->clEnqueueReadImage( + command_queue, + image, + blocking_read, + origin, + region, + row_pitch, + slice_pitch, + ptr, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clEnqueueWriteImage_wrap( + cl_command_queue command_queue, + cl_mem image, + cl_bool blocking_write, + const size_t* origin, + const size_t* region, + size_t input_row_pitch, + size_t input_slice_pitch, + const void* ptr, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clEnqueueWriteImage\n"); +return tdispatch->clEnqueueWriteImage( + command_queue, + image, + blocking_write, + origin, + region, + input_row_pitch, + input_slice_pitch, + ptr, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clEnqueueCopyImage_wrap( + cl_command_queue command_queue, + cl_mem src_image, + cl_mem dst_image, + const size_t* src_origin, + const size_t* dst_origin, + const size_t* region, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clEnqueueCopyImage\n"); +return tdispatch->clEnqueueCopyImage( + command_queue, + src_image, + dst_image, + src_origin, + dst_origin, + region, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clEnqueueCopyImageToBuffer_wrap( + cl_command_queue command_queue, + cl_mem src_image, + cl_mem dst_buffer, + const size_t* src_origin, + const size_t* region, + size_t dst_offset, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clEnqueueCopyImageToBuffer\n"); +return tdispatch->clEnqueueCopyImageToBuffer( + command_queue, + src_image, + dst_buffer, + src_origin, + region, + dst_offset, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clEnqueueCopyBufferToImage_wrap( + cl_command_queue command_queue, + cl_mem src_buffer, + cl_mem dst_image, + size_t src_offset, + const size_t* dst_origin, + const size_t* region, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clEnqueueCopyBufferToImage\n"); +return tdispatch->clEnqueueCopyBufferToImage( + command_queue, + src_buffer, + dst_image, + src_offset, + dst_origin, + region, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +static void* CL_API_CALL clEnqueueMapBuffer_wrap( + cl_command_queue command_queue, + cl_mem buffer, + cl_bool blocking_map, + cl_map_flags map_flags, + size_t offset, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clEnqueueMapBuffer\n"); +return tdispatch->clEnqueueMapBuffer( + command_queue, + buffer, + blocking_map, + map_flags, + offset, + size, + num_events_in_wait_list, + event_wait_list, + event, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static void* CL_API_CALL clEnqueueMapImage_wrap( + cl_command_queue command_queue, + cl_mem image, + cl_bool blocking_map, + cl_map_flags map_flags, + const size_t* origin, + const size_t* region, + size_t* image_row_pitch, + size_t* image_slice_pitch, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clEnqueueMapImage\n"); +return tdispatch->clEnqueueMapImage( + command_queue, + image, + blocking_map, + map_flags, + origin, + region, + image_row_pitch, + image_slice_pitch, + num_events_in_wait_list, + event_wait_list, + event, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clEnqueueUnmapMemObject_wrap( + cl_command_queue command_queue, + cl_mem memobj, + void* mapped_ptr, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clEnqueueUnmapMemObject\n"); +return tdispatch->clEnqueueUnmapMemObject( + command_queue, + memobj, + mapped_ptr, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clEnqueueNDRangeKernel_wrap( + cl_command_queue command_queue, + cl_kernel kernel, + cl_uint work_dim, + const size_t* global_work_offset, + const size_t* global_work_size, + const size_t* local_work_size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clEnqueueNDRangeKernel\n"); +return tdispatch->clEnqueueNDRangeKernel( + command_queue, + kernel, + work_dim, + global_work_offset, + global_work_size, + local_work_size, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clEnqueueNativeKernel_wrap( + cl_command_queue command_queue, + void (CL_CALLBACK* user_func)(void*), + void* args, + size_t cb_args, + cl_uint num_mem_objects, + const cl_mem* mem_list, + const void** args_mem_loc, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clEnqueueNativeKernel\n"); +return tdispatch->clEnqueueNativeKernel( + command_queue, + user_func, + args, + cb_args, + num_mem_objects, + mem_list, + args_mem_loc, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clSetCommandQueueProperty_wrap( + cl_command_queue command_queue, + cl_command_queue_properties properties, + cl_bool enable, + cl_command_queue_properties* old_properties) CL_API_SUFFIX__VERSION_1_0_DEPRECATED +{ +printf("clSetCommandQueueProperty\n"); +return tdispatch->clSetCommandQueueProperty( + command_queue, + properties, + enable, + old_properties); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_mem CL_API_CALL clCreateImage2D_wrap( + cl_context context, + cl_mem_flags flags, + const cl_image_format* image_format, + size_t image_width, + size_t image_height, + size_t image_row_pitch, + void* host_ptr, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_1_DEPRECATED +{ +printf("clCreateImage2D\n"); +return tdispatch->clCreateImage2D( + context, + flags, + image_format, + image_width, + image_height, + image_row_pitch, + host_ptr, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_mem CL_API_CALL clCreateImage3D_wrap( + cl_context context, + cl_mem_flags flags, + const cl_image_format* image_format, + size_t image_width, + size_t image_height, + size_t image_depth, + size_t image_row_pitch, + size_t image_slice_pitch, + void* host_ptr, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_1_DEPRECATED +{ +printf("clCreateImage3D\n"); +return tdispatch->clCreateImage3D( + context, + flags, + image_format, + image_width, + image_height, + image_depth, + image_row_pitch, + image_slice_pitch, + host_ptr, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clEnqueueMarker_wrap( + cl_command_queue command_queue, + cl_event* event) CL_API_SUFFIX__VERSION_1_1_DEPRECATED +{ +printf("clEnqueueMarker\n"); +return tdispatch->clEnqueueMarker( + command_queue, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clEnqueueWaitForEvents_wrap( + cl_command_queue command_queue, + cl_uint num_events, + const cl_event* event_list) CL_API_SUFFIX__VERSION_1_1_DEPRECATED +{ +printf("clEnqueueWaitForEvents\n"); +return tdispatch->clEnqueueWaitForEvents( + command_queue, + num_events, + event_list); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clEnqueueBarrier_wrap( + cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_1_DEPRECATED +{ +printf("clEnqueueBarrier\n"); +return tdispatch->clEnqueueBarrier( + command_queue); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clUnloadCompiler_wrap( + void ) CL_API_SUFFIX__VERSION_1_1_DEPRECATED +{ +printf("clUnloadCompiler\n"); +return tdispatch->clUnloadCompiler( + ); +} + +/////////////////////////////////////////////////////////////////////////////// +static void* CL_API_CALL clGetExtensionFunctionAddress_wrap( + const char* func_name) CL_API_SUFFIX__VERSION_1_1_DEPRECATED +{ +printf("clGetExtensionFunctionAddress\n"); +return tdispatch->clGetExtensionFunctionAddress( + func_name); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_command_queue CL_API_CALL clCreateCommandQueue_wrap( + cl_context context, + cl_device_id device, + cl_command_queue_properties properties, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2_DEPRECATED +{ +printf("clCreateCommandQueue\n"); +return tdispatch->clCreateCommandQueue( + context, + device, + properties, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_sampler CL_API_CALL clCreateSampler_wrap( + cl_context context, + cl_bool normalized_coords, + cl_addressing_mode addressing_mode, + cl_filter_mode filter_mode, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2_DEPRECATED +{ +printf("clCreateSampler\n"); +return tdispatch->clCreateSampler( + context, + normalized_coords, + addressing_mode, + filter_mode, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clEnqueueTask_wrap( + cl_command_queue command_queue, + cl_kernel kernel, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2_DEPRECATED +{ +printf("clEnqueueTask\n"); +return tdispatch->clEnqueueTask( + command_queue, + kernel, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_mem CL_API_CALL clCreateSubBuffer_wrap( + cl_mem buffer, + cl_mem_flags flags, + cl_buffer_create_type buffer_create_type, + const void* buffer_create_info, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_1 +{ +printf("clCreateSubBuffer\n"); +return tdispatch->clCreateSubBuffer( + buffer, + flags, + buffer_create_type, + buffer_create_info, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clSetMemObjectDestructorCallback_wrap( + cl_mem memobj, + void (CL_CALLBACK* pfn_notify)(cl_mem memobj, void* user_data), + void* user_data) CL_API_SUFFIX__VERSION_1_1 +{ +printf("clSetMemObjectDestructorCallback\n"); +return tdispatch->clSetMemObjectDestructorCallback( + memobj, + pfn_notify, + user_data); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_event CL_API_CALL clCreateUserEvent_wrap( + cl_context context, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_1 +{ +printf("clCreateUserEvent\n"); +return tdispatch->clCreateUserEvent( + context, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clSetUserEventStatus_wrap( + cl_event event, + cl_int execution_status) CL_API_SUFFIX__VERSION_1_1 +{ +printf("clSetUserEventStatus\n"); +return tdispatch->clSetUserEventStatus( + event, + execution_status); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clSetEventCallback_wrap( + cl_event event, + cl_int command_exec_callback_type, + void (CL_CALLBACK* pfn_notify)(cl_event event, cl_int event_command_status, void *user_data), + void* user_data) CL_API_SUFFIX__VERSION_1_1 +{ +printf("clSetEventCallback\n"); +return tdispatch->clSetEventCallback( + event, + command_exec_callback_type, + pfn_notify, + user_data); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clEnqueueReadBufferRect_wrap( + cl_command_queue command_queue, + cl_mem buffer, + cl_bool blocking_read, + const size_t* buffer_origin, + const size_t* host_origin, + const size_t* region, + size_t buffer_row_pitch, + size_t buffer_slice_pitch, + size_t host_row_pitch, + size_t host_slice_pitch, + void* ptr, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_1 +{ +printf("clEnqueueReadBufferRect\n"); +return tdispatch->clEnqueueReadBufferRect( + command_queue, + buffer, + blocking_read, + buffer_origin, + host_origin, + region, + buffer_row_pitch, + buffer_slice_pitch, + host_row_pitch, + host_slice_pitch, + ptr, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clEnqueueWriteBufferRect_wrap( + cl_command_queue command_queue, + cl_mem buffer, + cl_bool blocking_write, + const size_t* buffer_origin, + const size_t* host_origin, + const size_t* region, + size_t buffer_row_pitch, + size_t buffer_slice_pitch, + size_t host_row_pitch, + size_t host_slice_pitch, + const void* ptr, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_1 +{ +printf("clEnqueueWriteBufferRect\n"); +return tdispatch->clEnqueueWriteBufferRect( + command_queue, + buffer, + blocking_write, + buffer_origin, + host_origin, + region, + buffer_row_pitch, + buffer_slice_pitch, + host_row_pitch, + host_slice_pitch, + ptr, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clEnqueueCopyBufferRect_wrap( + cl_command_queue command_queue, + cl_mem src_buffer, + cl_mem dst_buffer, + const size_t* src_origin, + const size_t* dst_origin, + const size_t* region, + size_t src_row_pitch, + size_t src_slice_pitch, + size_t dst_row_pitch, + size_t dst_slice_pitch, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_1 +{ +printf("clEnqueueCopyBufferRect\n"); +return tdispatch->clEnqueueCopyBufferRect( + command_queue, + src_buffer, + dst_buffer, + src_origin, + dst_origin, + region, + src_row_pitch, + src_slice_pitch, + dst_row_pitch, + dst_slice_pitch, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clCreateSubDevices_wrap( + cl_device_id in_device, + const cl_device_partition_property* properties, + cl_uint num_devices, + cl_device_id* out_devices, + cl_uint* num_devices_ret) CL_API_SUFFIX__VERSION_1_2 +{ +printf("clCreateSubDevices\n"); +return tdispatch->clCreateSubDevices( + in_device, + properties, + num_devices, + out_devices, + num_devices_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clRetainDevice_wrap( + cl_device_id device) CL_API_SUFFIX__VERSION_1_2 +{ +printf("clRetainDevice\n"); +return tdispatch->clRetainDevice( + device); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clReleaseDevice_wrap( + cl_device_id device) CL_API_SUFFIX__VERSION_1_2 +{ +printf("clReleaseDevice\n"); +return tdispatch->clReleaseDevice( + device); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_mem CL_API_CALL clCreateImage_wrap( + cl_context context, + cl_mem_flags flags, + const cl_image_format* image_format, + const cl_image_desc* image_desc, + void* host_ptr, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2 +{ +printf("clCreateImage\n"); +return tdispatch->clCreateImage( + context, + flags, + image_format, + image_desc, + host_ptr, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_program CL_API_CALL clCreateProgramWithBuiltInKernels_wrap( + cl_context context, + cl_uint num_devices, + const cl_device_id* device_list, + const char* kernel_names, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2 +{ +printf("clCreateProgramWithBuiltInKernels\n"); +return tdispatch->clCreateProgramWithBuiltInKernels( + context, + num_devices, + device_list, + kernel_names, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clCompileProgram_wrap( + cl_program program, + cl_uint num_devices, + const cl_device_id* device_list, + const char* options, + cl_uint num_input_headers, + const cl_program* input_headers, + const char** header_include_names, + void (CL_CALLBACK* pfn_notify)(cl_program program, void* user_data), + void* user_data) CL_API_SUFFIX__VERSION_1_2 +{ +printf("clCompileProgram\n"); +return tdispatch->clCompileProgram( + program, + num_devices, + device_list, + options, + num_input_headers, + input_headers, + header_include_names, + pfn_notify, + user_data); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_program CL_API_CALL clLinkProgram_wrap( + cl_context context, + cl_uint num_devices, + const cl_device_id* device_list, + const char* options, + cl_uint num_input_programs, + const cl_program* input_programs, + void (CL_CALLBACK* pfn_notify)(cl_program program, void* user_data), + void* user_data, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2 +{ +printf("clLinkProgram\n"); +return tdispatch->clLinkProgram( + context, + num_devices, + device_list, + options, + num_input_programs, + input_programs, + pfn_notify, + user_data, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clUnloadPlatformCompiler_wrap( + cl_platform_id platform) CL_API_SUFFIX__VERSION_1_2 +{ +printf("clUnloadPlatformCompiler\n"); +return tdispatch->clUnloadPlatformCompiler( + platform); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clGetKernelArgInfo_wrap( + cl_kernel kernel, + cl_uint arg_index, + cl_kernel_arg_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) CL_API_SUFFIX__VERSION_1_2 +{ +printf("clGetKernelArgInfo\n"); +return tdispatch->clGetKernelArgInfo( + kernel, + arg_index, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clEnqueueFillBuffer_wrap( + cl_command_queue command_queue, + cl_mem buffer, + const void* pattern, + size_t pattern_size, + size_t offset, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2 +{ +printf("clEnqueueFillBuffer\n"); +return tdispatch->clEnqueueFillBuffer( + command_queue, + buffer, + pattern, + pattern_size, + offset, + size, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clEnqueueFillImage_wrap( + cl_command_queue command_queue, + cl_mem image, + const void* fill_color, + const size_t* origin, + const size_t* region, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2 +{ +printf("clEnqueueFillImage\n"); +return tdispatch->clEnqueueFillImage( + command_queue, + image, + fill_color, + origin, + region, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clEnqueueMigrateMemObjects_wrap( + cl_command_queue command_queue, + cl_uint num_mem_objects, + const cl_mem* mem_objects, + cl_mem_migration_flags flags, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2 +{ +printf("clEnqueueMigrateMemObjects\n"); +return tdispatch->clEnqueueMigrateMemObjects( + command_queue, + num_mem_objects, + mem_objects, + flags, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clEnqueueMarkerWithWaitList_wrap( + cl_command_queue command_queue, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2 +{ +printf("clEnqueueMarkerWithWaitList\n"); +return tdispatch->clEnqueueMarkerWithWaitList( + command_queue, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clEnqueueBarrierWithWaitList_wrap( + cl_command_queue command_queue, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2 +{ +printf("clEnqueueBarrierWithWaitList\n"); +return tdispatch->clEnqueueBarrierWithWaitList( + command_queue, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +static void* CL_API_CALL clGetExtensionFunctionAddressForPlatform_wrap( + cl_platform_id platform, + const char* func_name) CL_API_SUFFIX__VERSION_1_2 +{ +printf("clGetExtensionFunctionAddressForPlatform\n"); +return tdispatch->clGetExtensionFunctionAddressForPlatform( + platform, + func_name); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_command_queue CL_API_CALL clCreateCommandQueueWithProperties_wrap( + cl_context context, + cl_device_id device, + const cl_queue_properties* properties, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_2_0 +{ +printf("clCreateCommandQueueWithProperties\n"); +return tdispatch->clCreateCommandQueueWithProperties( + context, + device, + properties, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_mem CL_API_CALL clCreatePipe_wrap( + cl_context context, + cl_mem_flags flags, + cl_uint pipe_packet_size, + cl_uint pipe_max_packets, + const cl_pipe_properties* properties, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_2_0 +{ +printf("clCreatePipe\n"); +return tdispatch->clCreatePipe( + context, + flags, + pipe_packet_size, + pipe_max_packets, + properties, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clGetPipeInfo_wrap( + cl_mem pipe, + cl_pipe_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) CL_API_SUFFIX__VERSION_2_0 +{ +printf("clGetPipeInfo\n"); +return tdispatch->clGetPipeInfo( + pipe, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static void* CL_API_CALL clSVMAlloc_wrap( + cl_context context, + cl_svm_mem_flags flags, + size_t size, + cl_uint alignment) CL_API_SUFFIX__VERSION_2_0 +{ +printf("clSVMAlloc\n"); +return tdispatch->clSVMAlloc( + context, + flags, + size, + alignment); +} + +/////////////////////////////////////////////////////////////////////////////// +static void CL_API_CALL clSVMFree_wrap( + cl_context context, + void* svm_pointer) CL_API_SUFFIX__VERSION_2_0 +{ +printf("clSVMFree\n"); +tdispatch->clSVMFree( + context, + svm_pointer); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_sampler CL_API_CALL clCreateSamplerWithProperties_wrap( + cl_context context, + const cl_sampler_properties* sampler_properties, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_2_0 +{ +printf("clCreateSamplerWithProperties\n"); +return tdispatch->clCreateSamplerWithProperties( + context, + sampler_properties, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clSetKernelArgSVMPointer_wrap( + cl_kernel kernel, + cl_uint arg_index, + const void* arg_value) CL_API_SUFFIX__VERSION_2_0 +{ +printf("clSetKernelArgSVMPointer\n"); +return tdispatch->clSetKernelArgSVMPointer( + kernel, + arg_index, + arg_value); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clSetKernelExecInfo_wrap( + cl_kernel kernel, + cl_kernel_exec_info param_name, + size_t param_value_size, + const void* param_value) CL_API_SUFFIX__VERSION_2_0 +{ +printf("clSetKernelExecInfo\n"); +return tdispatch->clSetKernelExecInfo( + kernel, + param_name, + param_value_size, + param_value); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clEnqueueSVMFree_wrap( + cl_command_queue command_queue, + cl_uint num_svm_pointers, + void* svm_pointers[], + void (CL_CALLBACK* pfn_free_func)(cl_command_queue queue, cl_uint num_svm_pointers, void* svm_pointers[], void* user_data), + void* user_data, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_2_0 +{ +printf("clEnqueueSVMFree\n"); +return tdispatch->clEnqueueSVMFree( + command_queue, + num_svm_pointers, + svm_pointers, + pfn_free_func, + user_data, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clEnqueueSVMMemcpy_wrap( + cl_command_queue command_queue, + cl_bool blocking_copy, + void* dst_ptr, + const void* src_ptr, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_2_0 +{ +printf("clEnqueueSVMMemcpy\n"); +return tdispatch->clEnqueueSVMMemcpy( + command_queue, + blocking_copy, + dst_ptr, + src_ptr, + size, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clEnqueueSVMMemFill_wrap( + cl_command_queue command_queue, + void* svm_ptr, + const void* pattern, + size_t pattern_size, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_2_0 +{ +printf("clEnqueueSVMMemFill\n"); +return tdispatch->clEnqueueSVMMemFill( + command_queue, + svm_ptr, + pattern, + pattern_size, + size, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clEnqueueSVMMap_wrap( + cl_command_queue command_queue, + cl_bool blocking_map, + cl_map_flags flags, + void* svm_ptr, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_2_0 +{ +printf("clEnqueueSVMMap\n"); +return tdispatch->clEnqueueSVMMap( + command_queue, + blocking_map, + flags, + svm_ptr, + size, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clEnqueueSVMUnmap_wrap( + cl_command_queue command_queue, + void* svm_ptr, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_2_0 +{ +printf("clEnqueueSVMUnmap\n"); +return tdispatch->clEnqueueSVMUnmap( + command_queue, + svm_ptr, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clSetDefaultDeviceCommandQueue_wrap( + cl_context context, + cl_device_id device, + cl_command_queue command_queue) CL_API_SUFFIX__VERSION_2_1 +{ +printf("clSetDefaultDeviceCommandQueue\n"); +return tdispatch->clSetDefaultDeviceCommandQueue( + context, + device, + command_queue); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clGetDeviceAndHostTimer_wrap( + cl_device_id device, + cl_ulong* device_timestamp, + cl_ulong* host_timestamp) CL_API_SUFFIX__VERSION_2_1 +{ +printf("clGetDeviceAndHostTimer\n"); +return tdispatch->clGetDeviceAndHostTimer( + device, + device_timestamp, + host_timestamp); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clGetHostTimer_wrap( + cl_device_id device, + cl_ulong* host_timestamp) CL_API_SUFFIX__VERSION_2_1 +{ +printf("clGetHostTimer\n"); +return tdispatch->clGetHostTimer( + device, + host_timestamp); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_program CL_API_CALL clCreateProgramWithIL_wrap( + cl_context context, + const void* il, + size_t length, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_2_1 +{ +printf("clCreateProgramWithIL\n"); +return tdispatch->clCreateProgramWithIL( + context, + il, + length, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_kernel CL_API_CALL clCloneKernel_wrap( + cl_kernel source_kernel, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_2_1 +{ +printf("clCloneKernel\n"); +return tdispatch->clCloneKernel( + source_kernel, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clGetKernelSubGroupInfo_wrap( + cl_kernel kernel, + cl_device_id device, + cl_kernel_sub_group_info param_name, + size_t input_value_size, + const void* input_value, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) CL_API_SUFFIX__VERSION_2_1 +{ +printf("clGetKernelSubGroupInfo\n"); +return tdispatch->clGetKernelSubGroupInfo( + kernel, + device, + param_name, + input_value_size, + input_value, + param_value_size, + param_value, + param_value_size_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clEnqueueSVMMigrateMem_wrap( + cl_command_queue command_queue, + cl_uint num_svm_pointers, + const void** svm_pointers, + const size_t* sizes, + cl_mem_migration_flags flags, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_2_1 +{ +printf("clEnqueueSVMMigrateMem\n"); +return tdispatch->clEnqueueSVMMigrateMem( + command_queue, + num_svm_pointers, + svm_pointers, + sizes, + flags, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clSetProgramSpecializationConstant_wrap( + cl_program program, + cl_uint spec_id, + size_t spec_size, + const void* spec_value) CL_API_SUFFIX__VERSION_2_2 +{ +printf("clSetProgramSpecializationConstant\n"); +return tdispatch->clSetProgramSpecializationConstant( + program, + spec_id, + spec_size, + spec_value); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clSetProgramReleaseCallback_wrap( + cl_program program, + void (CL_CALLBACK* pfn_notify)(cl_program program, void* user_data), + void* user_data) CL_API_SUFFIX__VERSION_2_2_DEPRECATED +{ +printf("clSetProgramReleaseCallback\n"); +return tdispatch->clSetProgramReleaseCallback( + program, + pfn_notify, + user_data); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_int CL_API_CALL clSetContextDestructorCallback_wrap( + cl_context context, + void (CL_CALLBACK* pfn_notify)(cl_context context, void* user_data), + void* user_data) CL_API_SUFFIX__VERSION_3_0 +{ +printf("clSetContextDestructorCallback\n"); +return tdispatch->clSetContextDestructorCallback( + context, + pfn_notify, + user_data); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_mem CL_API_CALL clCreateBufferWithProperties_wrap( + cl_context context, + const cl_mem_properties* properties, + cl_mem_flags flags, + size_t size, + void* host_ptr, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_3_0 +{ +printf("clCreateBufferWithProperties\n"); +return tdispatch->clCreateBufferWithProperties( + context, + properties, + flags, + size, + host_ptr, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// +static cl_mem CL_API_CALL clCreateImageWithProperties_wrap( + cl_context context, + const cl_mem_properties* properties, + cl_mem_flags flags, + const cl_image_format* image_format, + const cl_image_desc* image_desc, + void* host_ptr, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_3_0 +{ +printf("clCreateImageWithProperties\n"); +return tdispatch->clCreateImageWithProperties( + context, + properties, + flags, + image_format, + image_desc, + host_ptr, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// + +// cl_ext_device_fission +static cl_int CL_API_CALL clReleaseDeviceEXT_wrap( + cl_device_id device) CL_API_SUFFIX__VERSION_1_1 +{ +printf("clReleaseDeviceEXT\n"); +return tdispatch->clReleaseDeviceEXT( + device); +} +static cl_int CL_API_CALL clRetainDeviceEXT_wrap( + cl_device_id device) CL_API_SUFFIX__VERSION_1_1 +{ +printf("clRetainDeviceEXT\n"); +return tdispatch->clRetainDeviceEXT( + device); +} +static cl_int CL_API_CALL clCreateSubDevicesEXT_wrap( + cl_device_id in_device, + const cl_device_partition_property_ext* properties, + cl_uint num_entries, + cl_device_id* out_devices, + cl_uint* num_devices) CL_API_SUFFIX__VERSION_1_1 +{ +printf("clCreateSubDevicesEXT\n"); +return tdispatch->clCreateSubDevicesEXT( + in_device, + properties, + num_entries, + out_devices, + num_devices); +} + +/////////////////////////////////////////////////////////////////////////////// + +// cl_khr_d3d10_sharing + +#if defined(_WIN32) +static cl_int CL_API_CALL clGetDeviceIDsFromD3D10KHR_wrap( + cl_platform_id platform, + cl_d3d10_device_source_khr d3d_device_source, + void* d3d_object, + cl_d3d10_device_set_khr d3d_device_set, + cl_uint num_entries, + cl_device_id* devices, + cl_uint* num_devices) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clGetDeviceIDsFromD3D10KHR\n"); +return tdispatch->clGetDeviceIDsFromD3D10KHR( + platform, + d3d_device_source, + d3d_object, + d3d_device_set, + num_entries, + devices, + num_devices); +} +static cl_mem CL_API_CALL clCreateFromD3D10BufferKHR_wrap( + cl_context context, + cl_mem_flags flags, + ID3D10Buffer* resource, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clCreateFromD3D10BufferKHR\n"); +return tdispatch->clCreateFromD3D10BufferKHR( + context, + flags, + resource, + errcode_ret); +} +static cl_mem CL_API_CALL clCreateFromD3D10Texture2DKHR_wrap( + cl_context context, + cl_mem_flags flags, + ID3D10Texture2D* resource, + UINT subresource, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clCreateFromD3D10Texture2DKHR\n"); +return tdispatch->clCreateFromD3D10Texture2DKHR( + context, + flags, + resource, + subresource, + errcode_ret); +} +static cl_mem CL_API_CALL clCreateFromD3D10Texture3DKHR_wrap( + cl_context context, + cl_mem_flags flags, + ID3D10Texture3D* resource, + UINT subresource, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clCreateFromD3D10Texture3DKHR\n"); +return tdispatch->clCreateFromD3D10Texture3DKHR( + context, + flags, + resource, + subresource, + errcode_ret); +} +static cl_int CL_API_CALL clEnqueueAcquireD3D10ObjectsKHR_wrap( + 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 +{ +printf("clEnqueueAcquireD3D10ObjectsKHR\n"); +return tdispatch->clEnqueueAcquireD3D10ObjectsKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} +static cl_int CL_API_CALL clEnqueueReleaseD3D10ObjectsKHR_wrap( + 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 +{ +printf("clEnqueueReleaseD3D10ObjectsKHR\n"); +return tdispatch->clEnqueueReleaseD3D10ObjectsKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} + +#endif // defined(_WIN32) + +/////////////////////////////////////////////////////////////////////////////// + +// cl_khr_d3d11_sharing + +#if defined(_WIN32) +static cl_int CL_API_CALL clGetDeviceIDsFromD3D11KHR_wrap( + cl_platform_id platform, + cl_d3d11_device_source_khr d3d_device_source, + void* d3d_object, + cl_d3d11_device_set_khr d3d_device_set, + cl_uint num_entries, + cl_device_id* devices, + cl_uint* num_devices) CL_API_SUFFIX__VERSION_1_2 +{ +printf("clGetDeviceIDsFromD3D11KHR\n"); +return tdispatch->clGetDeviceIDsFromD3D11KHR( + platform, + d3d_device_source, + d3d_object, + d3d_device_set, + num_entries, + devices, + num_devices); +} +static cl_mem CL_API_CALL clCreateFromD3D11BufferKHR_wrap( + cl_context context, + cl_mem_flags flags, + ID3D11Buffer* resource, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2 +{ +printf("clCreateFromD3D11BufferKHR\n"); +return tdispatch->clCreateFromD3D11BufferKHR( + context, + flags, + resource, + errcode_ret); +} +static cl_mem CL_API_CALL clCreateFromD3D11Texture2DKHR_wrap( + cl_context context, + cl_mem_flags flags, + ID3D11Texture2D* resource, + UINT subresource, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2 +{ +printf("clCreateFromD3D11Texture2DKHR\n"); +return tdispatch->clCreateFromD3D11Texture2DKHR( + context, + flags, + resource, + subresource, + errcode_ret); +} +static cl_mem CL_API_CALL clCreateFromD3D11Texture3DKHR_wrap( + cl_context context, + cl_mem_flags flags, + ID3D11Texture3D* resource, + UINT subresource, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2 +{ +printf("clCreateFromD3D11Texture3DKHR\n"); +return tdispatch->clCreateFromD3D11Texture3DKHR( + context, + flags, + resource, + subresource, + errcode_ret); +} +static cl_int CL_API_CALL clEnqueueAcquireD3D11ObjectsKHR_wrap( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2 +{ +printf("clEnqueueAcquireD3D11ObjectsKHR\n"); +return tdispatch->clEnqueueAcquireD3D11ObjectsKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} +static cl_int CL_API_CALL clEnqueueReleaseD3D11ObjectsKHR_wrap( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2 +{ +printf("clEnqueueReleaseD3D11ObjectsKHR\n"); +return tdispatch->clEnqueueReleaseD3D11ObjectsKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} + +#endif // defined(_WIN32) + +/////////////////////////////////////////////////////////////////////////////// + +// cl_khr_dx9_media_sharing + +#if defined(_WIN32) +static cl_int CL_API_CALL clGetDeviceIDsFromDX9MediaAdapterKHR_wrap( + cl_platform_id platform, + cl_uint num_media_adapters, + cl_dx9_media_adapter_type_khr* media_adapter_type, + void* media_adapters, + cl_dx9_media_adapter_set_khr media_adapter_set, + cl_uint num_entries, + cl_device_id* devices, + cl_uint* num_devices) CL_API_SUFFIX__VERSION_1_2 +{ +printf("clGetDeviceIDsFromDX9MediaAdapterKHR\n"); +return tdispatch->clGetDeviceIDsFromDX9MediaAdapterKHR( + platform, + num_media_adapters, + media_adapter_type, + media_adapters, + media_adapter_set, + num_entries, + devices, + num_devices); +} +static cl_mem CL_API_CALL clCreateFromDX9MediaSurfaceKHR_wrap( + cl_context context, + cl_mem_flags flags, + cl_dx9_media_adapter_type_khr adapter_type, + void* surface_info, + cl_uint plane, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2 +{ +printf("clCreateFromDX9MediaSurfaceKHR\n"); +return tdispatch->clCreateFromDX9MediaSurfaceKHR( + context, + flags, + adapter_type, + surface_info, + plane, + errcode_ret); +} +static cl_int CL_API_CALL clEnqueueAcquireDX9MediaSurfacesKHR_wrap( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2 +{ +printf("clEnqueueAcquireDX9MediaSurfacesKHR\n"); +return tdispatch->clEnqueueAcquireDX9MediaSurfacesKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} +static cl_int CL_API_CALL clEnqueueReleaseDX9MediaSurfacesKHR_wrap( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2 +{ +printf("clEnqueueReleaseDX9MediaSurfacesKHR\n"); +return tdispatch->clEnqueueReleaseDX9MediaSurfacesKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} + +#endif // defined(_WIN32) + +/////////////////////////////////////////////////////////////////////////////// + +// cl_khr_egl_event +static cl_event CL_API_CALL clCreateEventFromEGLSyncKHR_wrap( + cl_context context, + CLeglSyncKHR sync, + CLeglDisplayKHR display, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clCreateEventFromEGLSyncKHR\n"); +return tdispatch->clCreateEventFromEGLSyncKHR( + context, + sync, + display, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// + +// cl_khr_egl_image +static cl_mem CL_API_CALL clCreateFromEGLImageKHR_wrap( + cl_context context, + CLeglDisplayKHR egldisplay, + CLeglImageKHR eglimage, + cl_mem_flags flags, + const cl_egl_image_properties_khr* properties, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clCreateFromEGLImageKHR\n"); +return tdispatch->clCreateFromEGLImageKHR( + context, + egldisplay, + eglimage, + flags, + properties, + errcode_ret); +} +static cl_int CL_API_CALL clEnqueueAcquireEGLObjectsKHR_wrap( + 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 +{ +printf("clEnqueueAcquireEGLObjectsKHR\n"); +return tdispatch->clEnqueueAcquireEGLObjectsKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} +static cl_int CL_API_CALL clEnqueueReleaseEGLObjectsKHR_wrap( + 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 +{ +printf("clEnqueueReleaseEGLObjectsKHR\n"); +return tdispatch->clEnqueueReleaseEGLObjectsKHR( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} + +/////////////////////////////////////////////////////////////////////////////// + +// cl_khr_gl_event +static cl_event CL_API_CALL clCreateEventFromGLsyncKHR_wrap( + cl_context context, + cl_GLsync sync, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_1 +{ +printf("clCreateEventFromGLsyncKHR\n"); +return tdispatch->clCreateEventFromGLsyncKHR( + context, + sync, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// + +// cl_khr_gl_sharing +static cl_int CL_API_CALL clGetGLContextInfoKHR_wrap( + 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 +{ +printf("clGetGLContextInfoKHR\n"); +return tdispatch->clGetGLContextInfoKHR( + properties, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} +static cl_mem CL_API_CALL clCreateFromGLBuffer_wrap( + cl_context context, + cl_mem_flags flags, + cl_GLuint bufobj, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clCreateFromGLBuffer\n"); +return tdispatch->clCreateFromGLBuffer( + context, + flags, + bufobj, + errcode_ret); +} +static cl_mem CL_API_CALL clCreateFromGLTexture_wrap( + 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 +{ +printf("clCreateFromGLTexture\n"); +return tdispatch->clCreateFromGLTexture( + context, + flags, + target, + miplevel, + texture, + errcode_ret); +} +static cl_mem CL_API_CALL clCreateFromGLRenderbuffer_wrap( + cl_context context, + cl_mem_flags flags, + cl_GLuint renderbuffer, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clCreateFromGLRenderbuffer\n"); +return tdispatch->clCreateFromGLRenderbuffer( + context, + flags, + renderbuffer, + errcode_ret); +} +static cl_int CL_API_CALL clGetGLObjectInfo_wrap( + cl_mem memobj, + cl_gl_object_type* gl_object_type, + cl_GLuint* gl_object_name) CL_API_SUFFIX__VERSION_1_0 +{ +printf("clGetGLObjectInfo\n"); +return tdispatch->clGetGLObjectInfo( + memobj, + gl_object_type, + gl_object_name); +} +static cl_int CL_API_CALL clGetGLTextureInfo_wrap( + 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 +{ +printf("clGetGLTextureInfo\n"); +return tdispatch->clGetGLTextureInfo( + memobj, + param_name, + param_value_size, + param_value, + param_value_size_ret); +} +static cl_int CL_API_CALL clEnqueueAcquireGLObjects_wrap( + 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 +{ +printf("clEnqueueAcquireGLObjects\n"); +return tdispatch->clEnqueueAcquireGLObjects( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} +static cl_int CL_API_CALL clEnqueueReleaseGLObjects_wrap( + 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 +{ +printf("clEnqueueReleaseGLObjects\n"); +return tdispatch->clEnqueueReleaseGLObjects( + command_queue, + num_objects, + mem_objects, + num_events_in_wait_list, + event_wait_list, + event); +} +static cl_mem CL_API_CALL clCreateFromGLTexture2D_wrap( + 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_1_DEPRECATED +{ +printf("clCreateFromGLTexture2D\n"); +return tdispatch->clCreateFromGLTexture2D( + context, + flags, + target, + miplevel, + texture, + errcode_ret); +} +static cl_mem CL_API_CALL clCreateFromGLTexture3D_wrap( + 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_1_DEPRECATED +{ +printf("clCreateFromGLTexture3D\n"); +return tdispatch->clCreateFromGLTexture3D( + context, + flags, + target, + miplevel, + texture, + errcode_ret); +} + +/////////////////////////////////////////////////////////////////////////////// + +// cl_khr_subgroups +static cl_int CL_API_CALL clGetKernelSubGroupInfoKHR_wrap( + cl_kernel in_kernel, + cl_device_id in_device, + cl_kernel_sub_group_info param_name, + size_t input_value_size, + const void* input_value, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) CL_API_SUFFIX__VERSION_2_0_DEPRECATED +{ +printf("clGetKernelSubGroupInfoKHR\n"); +return tdispatch->clGetKernelSubGroupInfoKHR( + in_kernel, + in_device, + param_name, + input_value_size, + input_value, + param_value_size, + param_value, + param_value_size_ret); +} + +/////////////////////////////////////////////////////////////////////////////// + +void _init_dispatch(void) { + dispatch.clGetPlatformIDs = &clGetPlatformIDs_wrap; + dispatch.clGetPlatformInfo = &clGetPlatformInfo_wrap; + dispatch.clGetDeviceIDs = &clGetDeviceIDs_wrap; + dispatch.clGetDeviceInfo = &clGetDeviceInfo_wrap; + dispatch.clCreateContext = &clCreateContext_wrap; + dispatch.clCreateContextFromType = &clCreateContextFromType_wrap; + dispatch.clRetainContext = &clRetainContext_wrap; + dispatch.clReleaseContext = &clReleaseContext_wrap; + dispatch.clGetContextInfo = &clGetContextInfo_wrap; + dispatch.clCreateCommandQueue = &clCreateCommandQueue_wrap; + dispatch.clRetainCommandQueue = &clRetainCommandQueue_wrap; + dispatch.clReleaseCommandQueue = &clReleaseCommandQueue_wrap; + dispatch.clGetCommandQueueInfo = &clGetCommandQueueInfo_wrap; + dispatch.clSetCommandQueueProperty = &clSetCommandQueueProperty_wrap; + dispatch.clCreateBuffer = &clCreateBuffer_wrap; + dispatch.clCreateImage2D = &clCreateImage2D_wrap; + dispatch.clCreateImage3D = &clCreateImage3D_wrap; + dispatch.clRetainMemObject = &clRetainMemObject_wrap; + dispatch.clReleaseMemObject = &clReleaseMemObject_wrap; + dispatch.clGetSupportedImageFormats = &clGetSupportedImageFormats_wrap; + dispatch.clGetMemObjectInfo = &clGetMemObjectInfo_wrap; + dispatch.clGetImageInfo = &clGetImageInfo_wrap; + dispatch.clCreateSampler = &clCreateSampler_wrap; + dispatch.clRetainSampler = &clRetainSampler_wrap; + dispatch.clReleaseSampler = &clReleaseSampler_wrap; + dispatch.clGetSamplerInfo = &clGetSamplerInfo_wrap; + dispatch.clCreateProgramWithSource = &clCreateProgramWithSource_wrap; + dispatch.clCreateProgramWithBinary = &clCreateProgramWithBinary_wrap; + dispatch.clRetainProgram = &clRetainProgram_wrap; + dispatch.clReleaseProgram = &clReleaseProgram_wrap; + dispatch.clBuildProgram = &clBuildProgram_wrap; + dispatch.clUnloadCompiler = &clUnloadCompiler_wrap; + dispatch.clGetProgramInfo = &clGetProgramInfo_wrap; + dispatch.clGetProgramBuildInfo = &clGetProgramBuildInfo_wrap; + dispatch.clCreateKernel = &clCreateKernel_wrap; + dispatch.clCreateKernelsInProgram = &clCreateKernelsInProgram_wrap; + dispatch.clRetainKernel = &clRetainKernel_wrap; + dispatch.clReleaseKernel = &clReleaseKernel_wrap; + dispatch.clSetKernelArg = &clSetKernelArg_wrap; + dispatch.clGetKernelInfo = &clGetKernelInfo_wrap; + dispatch.clGetKernelWorkGroupInfo = &clGetKernelWorkGroupInfo_wrap; + dispatch.clWaitForEvents = &clWaitForEvents_wrap; + dispatch.clGetEventInfo = &clGetEventInfo_wrap; + dispatch.clRetainEvent = &clRetainEvent_wrap; + dispatch.clReleaseEvent = &clReleaseEvent_wrap; + dispatch.clGetEventProfilingInfo = &clGetEventProfilingInfo_wrap; + dispatch.clFlush = &clFlush_wrap; + dispatch.clFinish = &clFinish_wrap; + dispatch.clEnqueueReadBuffer = &clEnqueueReadBuffer_wrap; + dispatch.clEnqueueWriteBuffer = &clEnqueueWriteBuffer_wrap; + dispatch.clEnqueueCopyBuffer = &clEnqueueCopyBuffer_wrap; + dispatch.clEnqueueReadImage = &clEnqueueReadImage_wrap; + dispatch.clEnqueueWriteImage = &clEnqueueWriteImage_wrap; + dispatch.clEnqueueCopyImage = &clEnqueueCopyImage_wrap; + dispatch.clEnqueueCopyImageToBuffer = &clEnqueueCopyImageToBuffer_wrap; + dispatch.clEnqueueCopyBufferToImage = &clEnqueueCopyBufferToImage_wrap; + dispatch.clEnqueueMapBuffer = &clEnqueueMapBuffer_wrap; + dispatch.clEnqueueMapImage = &clEnqueueMapImage_wrap; + dispatch.clEnqueueUnmapMemObject = &clEnqueueUnmapMemObject_wrap; + dispatch.clEnqueueNDRangeKernel = &clEnqueueNDRangeKernel_wrap; + dispatch.clEnqueueTask = &clEnqueueTask_wrap; + dispatch.clEnqueueNativeKernel = &clEnqueueNativeKernel_wrap; + dispatch.clEnqueueMarker = &clEnqueueMarker_wrap; + dispatch.clEnqueueWaitForEvents = &clEnqueueWaitForEvents_wrap; + dispatch.clEnqueueBarrier = &clEnqueueBarrier_wrap; + dispatch.clGetExtensionFunctionAddress = &clGetExtensionFunctionAddress_wrap; + dispatch.clCreateFromGLBuffer = &clCreateFromGLBuffer_wrap; + dispatch.clCreateFromGLTexture2D = &clCreateFromGLTexture2D_wrap; + dispatch.clCreateFromGLTexture3D = &clCreateFromGLTexture3D_wrap; + dispatch.clCreateFromGLRenderbuffer = &clCreateFromGLRenderbuffer_wrap; + dispatch.clGetGLObjectInfo = &clGetGLObjectInfo_wrap; + dispatch.clGetGLTextureInfo = &clGetGLTextureInfo_wrap; + dispatch.clEnqueueAcquireGLObjects = &clEnqueueAcquireGLObjects_wrap; + dispatch.clEnqueueReleaseGLObjects = &clEnqueueReleaseGLObjects_wrap; + dispatch.clGetGLContextInfoKHR = &clGetGLContextInfoKHR_wrap; + + /* cl_khr_d3d10_sharing */ +#if defined(_WIN32) + dispatch.clGetDeviceIDsFromD3D10KHR = &clGetDeviceIDsFromD3D10KHR_wrap; + dispatch.clCreateFromD3D10BufferKHR = &clCreateFromD3D10BufferKHR_wrap; + dispatch.clCreateFromD3D10Texture2DKHR = &clCreateFromD3D10Texture2DKHR_wrap; + dispatch.clCreateFromD3D10Texture3DKHR = &clCreateFromD3D10Texture3DKHR_wrap; + dispatch.clEnqueueAcquireD3D10ObjectsKHR = &clEnqueueAcquireD3D10ObjectsKHR_wrap; + dispatch.clEnqueueReleaseD3D10ObjectsKHR = &clEnqueueReleaseD3D10ObjectsKHR_wrap; +#else + dispatch.clGetDeviceIDsFromD3D10KHR = NULL; + dispatch.clCreateFromD3D10BufferKHR = NULL; + dispatch.clCreateFromD3D10Texture2DKHR = NULL; + dispatch.clCreateFromD3D10Texture3DKHR = NULL; + dispatch.clEnqueueAcquireD3D10ObjectsKHR = NULL; + dispatch.clEnqueueReleaseD3D10ObjectsKHR = NULL; +#endif + + /* OpenCL 1.1 */ + dispatch.clSetEventCallback = &clSetEventCallback_wrap; + dispatch.clCreateSubBuffer = &clCreateSubBuffer_wrap; + dispatch.clSetMemObjectDestructorCallback = &clSetMemObjectDestructorCallback_wrap; + dispatch.clCreateUserEvent = &clCreateUserEvent_wrap; + dispatch.clSetUserEventStatus = &clSetUserEventStatus_wrap; + dispatch.clEnqueueReadBufferRect = &clEnqueueReadBufferRect_wrap; + dispatch.clEnqueueWriteBufferRect = &clEnqueueWriteBufferRect_wrap; + dispatch.clEnqueueCopyBufferRect = &clEnqueueCopyBufferRect_wrap; + + /* cl_ext_device_fission */ + dispatch.clCreateSubDevicesEXT = &clCreateSubDevicesEXT_wrap; + dispatch.clRetainDeviceEXT = &clRetainDeviceEXT_wrap; + dispatch.clReleaseDeviceEXT = &clReleaseDeviceEXT_wrap; + + /* cl_khr_gl_event */ + dispatch.clCreateEventFromGLsyncKHR = &clCreateEventFromGLsyncKHR_wrap; + + /* OpenCL 1.2 */ + dispatch.clCreateSubDevices = &clCreateSubDevices_wrap; + dispatch.clRetainDevice = &clRetainDevice_wrap; + dispatch.clReleaseDevice = &clReleaseDevice_wrap; + dispatch.clCreateImage = &clCreateImage_wrap; + dispatch.clCreateProgramWithBuiltInKernels = &clCreateProgramWithBuiltInKernels_wrap; + dispatch.clCompileProgram = &clCompileProgram_wrap; + dispatch.clLinkProgram = &clLinkProgram_wrap; + dispatch.clUnloadPlatformCompiler = &clUnloadPlatformCompiler_wrap; + dispatch.clGetKernelArgInfo = &clGetKernelArgInfo_wrap; + dispatch.clEnqueueFillBuffer = &clEnqueueFillBuffer_wrap; + dispatch.clEnqueueFillImage = &clEnqueueFillImage_wrap; + dispatch.clEnqueueMigrateMemObjects = &clEnqueueMigrateMemObjects_wrap; + dispatch.clEnqueueMarkerWithWaitList = &clEnqueueMarkerWithWaitList_wrap; + dispatch.clEnqueueBarrierWithWaitList = &clEnqueueBarrierWithWaitList_wrap; + dispatch.clGetExtensionFunctionAddressForPlatform = &clGetExtensionFunctionAddressForPlatform_wrap; + dispatch.clCreateFromGLTexture = &clCreateFromGLTexture_wrap; + + /* cl_khr_d3d11_sharing */ +#if defined(_WIN32) + dispatch.clGetDeviceIDsFromD3D11KHR = &clGetDeviceIDsFromD3D11KHR_wrap; + dispatch.clCreateFromD3D11BufferKHR = &clCreateFromD3D11BufferKHR_wrap; + dispatch.clCreateFromD3D11Texture2DKHR = &clCreateFromD3D11Texture2DKHR_wrap; + dispatch.clCreateFromD3D11Texture3DKHR = &clCreateFromD3D11Texture3DKHR_wrap; + dispatch.clCreateFromDX9MediaSurfaceKHR = &clCreateFromDX9MediaSurfaceKHR_wrap; + dispatch.clEnqueueAcquireD3D11ObjectsKHR = &clEnqueueAcquireD3D11ObjectsKHR_wrap; + dispatch.clEnqueueReleaseD3D11ObjectsKHR = &clEnqueueReleaseD3D11ObjectsKHR_wrap; +#else + dispatch.clGetDeviceIDsFromD3D11KHR = NULL; + dispatch.clCreateFromD3D11BufferKHR = NULL; + dispatch.clCreateFromD3D11Texture2DKHR = NULL; + dispatch.clCreateFromD3D11Texture3DKHR = NULL; + dispatch.clCreateFromDX9MediaSurfaceKHR = NULL; + dispatch.clEnqueueAcquireD3D11ObjectsKHR = NULL; + dispatch.clEnqueueReleaseD3D11ObjectsKHR = NULL; +#endif + + /* cl_khr_dx9_media_sharing */ +#if defined(_WIN32) + dispatch.clGetDeviceIDsFromDX9MediaAdapterKHR = &clGetDeviceIDsFromDX9MediaAdapterKHR_wrap; + dispatch.clEnqueueAcquireDX9MediaSurfacesKHR = &clEnqueueAcquireDX9MediaSurfacesKHR_wrap; + dispatch.clEnqueueReleaseDX9MediaSurfacesKHR = &clEnqueueReleaseDX9MediaSurfacesKHR_wrap; +#else + dispatch.clGetDeviceIDsFromDX9MediaAdapterKHR = NULL; + dispatch.clEnqueueAcquireDX9MediaSurfacesKHR = NULL; + dispatch.clEnqueueReleaseDX9MediaSurfacesKHR = NULL; +#endif + + /* cl_khr_egl_image */ + dispatch.clCreateFromEGLImageKHR = &clCreateFromEGLImageKHR_wrap; + dispatch.clEnqueueAcquireEGLObjectsKHR = &clEnqueueAcquireEGLObjectsKHR_wrap; + dispatch.clEnqueueReleaseEGLObjectsKHR = &clEnqueueReleaseEGLObjectsKHR_wrap; + + /* cl_khr_egl_event */ + dispatch.clCreateEventFromEGLSyncKHR = &clCreateEventFromEGLSyncKHR_wrap; + + /* OpenCL 2.0 */ + dispatch.clCreateCommandQueueWithProperties = &clCreateCommandQueueWithProperties_wrap; + dispatch.clCreatePipe = &clCreatePipe_wrap; + dispatch.clGetPipeInfo = &clGetPipeInfo_wrap; + dispatch.clSVMAlloc = &clSVMAlloc_wrap; + dispatch.clSVMFree = &clSVMFree_wrap; + dispatch.clEnqueueSVMFree = &clEnqueueSVMFree_wrap; + dispatch.clEnqueueSVMMemcpy = &clEnqueueSVMMemcpy_wrap; + dispatch.clEnqueueSVMMemFill = &clEnqueueSVMMemFill_wrap; + dispatch.clEnqueueSVMMap = &clEnqueueSVMMap_wrap; + dispatch.clEnqueueSVMUnmap = &clEnqueueSVMUnmap_wrap; + dispatch.clCreateSamplerWithProperties = &clCreateSamplerWithProperties_wrap; + dispatch.clSetKernelArgSVMPointer = &clSetKernelArgSVMPointer_wrap; + dispatch.clSetKernelExecInfo = &clSetKernelExecInfo_wrap; + + /* cl_khr_sub_groups */ + dispatch.clGetKernelSubGroupInfoKHR = &clGetKernelSubGroupInfoKHR_wrap; + + /* OpenCL 2.1 */ + dispatch.clCloneKernel = &clCloneKernel_wrap; + dispatch.clCreateProgramWithIL = &clCreateProgramWithIL_wrap; + dispatch.clEnqueueSVMMigrateMem = &clEnqueueSVMMigrateMem_wrap; + dispatch.clGetDeviceAndHostTimer = &clGetDeviceAndHostTimer_wrap; + dispatch.clGetHostTimer = &clGetHostTimer_wrap; + dispatch.clGetKernelSubGroupInfo = &clGetKernelSubGroupInfo_wrap; + dispatch.clSetDefaultDeviceCommandQueue = &clSetDefaultDeviceCommandQueue_wrap; + + /* OpenCL 2.2 */ + dispatch.clSetProgramReleaseCallback = &clSetProgramReleaseCallback_wrap; + dispatch.clSetProgramSpecializationConstant = &clSetProgramSpecializationConstant_wrap; + + /* OpenCL 3.0 */ + dispatch.clCreateBufferWithProperties = &clCreateBufferWithProperties_wrap; + dispatch.clCreateImageWithProperties = &clCreateImageWithProperties_wrap; + dispatch.clSetContextDestructorCallback = &clSetContextDestructorCallback_wrap; +} diff --git a/test/loader_test/CMakeLists.txt b/test/loader_test/CMakeLists.txt index ddc675b4..3a401210 100644 --- a/test/loader_test/CMakeLists.txt +++ b/test/loader_test/CMakeLists.txt @@ -12,4 +12,9 @@ add_executable (icd_loader_test test_clgl.c test_image_objects.c ) -target_link_libraries (icd_loader_test OpenCL IcdLog) +target_compile_definitions(icd_loader_test + PRIVATE + CL_TARGET_OPENCL_VERSION=300 +) + +target_link_libraries (icd_loader_test OpenCL IcdLog OpenCL::Headers) diff --git a/test/loader_test/Makefile b/test/loader_test/Makefile deleted file mode 100644 index 4b0dfe33..00000000 --- a/test/loader_test/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -CC := gcc -CFLAGS := -I ../inc -I ../../ -g -O0 - -OUTDIR := ../../bin - -${OUTDIR}/icd_loader_test: main.c callbacks.c icd_test_match.c - -${OUTDIR}/icd_loader_test: test_buffer_object.c test_clgl.c test_cl_runtime.c test_create_calls.c test_image_objects.c - -${OUTDIR}/icd_loader_test: test_kernel.c test_platforms.c test_program_objects.c test_sampler_objects.c - ${CC} ${CFLAGS} ${OUTDIR}/libOpenCL.so -o $@ $^ ${OUTDIR}/libIcdLog.so - -.PHONY: clean - -clean: - rm -f ${OUTDIR}/icd_loader_test diff --git a/test/loader_test/callbacks.c b/test/loader_test/callbacks.c index 8e0b4934..73d5a955 100644 --- a/test/loader_test/callbacks.c +++ b/test/loader_test/callbacks.c @@ -11,6 +11,11 @@ void CL_CALLBACK createcontext_callback(const char* _a, const void* _b, size_t _ _d); } +void CL_CALLBACK setcontextdestructor_callback(cl_context _a, void* _b) +{ + test_icd_app_log("setcontextdestructor_callback(%p, %p)\n", _a, _b); +} + void CL_CALLBACK setmemobjectdestructor_callback(cl_mem _a, void* _b) { test_icd_app_log("setmemobjectdestructor_callback(%p, %p)\n", diff --git a/test/loader_test/icd_test_match.c b/test/loader_test/icd_test_match.c index a8330b4a..cf791814 100644 --- a/test/loader_test/icd_test_match.c +++ b/test/loader_test/icd_test_match.c @@ -1,11 +1,12 @@ #include +#include #include #ifndef __APPLE__ #include #endif #include -int test_icd_match() +int test_icd_match(void) { int error = 0; char *app_log = NULL, *stub_log = NULL; @@ -25,7 +26,9 @@ int test_icd_match() } if (strcmp(app_log, stub_log)) { - printf("ERROR: App log and stub log differ.\n"); + printf("ERROR: App log and stub log differ.\n\n"); + printf("APPLOG:\n%s\n\n", app_log); + printf("STUBLOG:\n%s\n\n", stub_log); error = 1; goto End; } @@ -35,4 +38,3 @@ int test_icd_match() free(stub_log); return error; } - diff --git a/test/loader_test/main.c b/test/loader_test/main.c index a933946f..e10bee52 100644 --- a/test/loader_test/main.c +++ b/test/loader_test/main.c @@ -3,22 +3,22 @@ #include #include "param_struct.h" -extern int test_create_calls(); -extern int test_platforms(); -extern int test_cl_runtime(); -extern int test_kernel(); -extern int test_buffer_object(); -extern int test_program_objects(); -extern int test_image_objects(); -extern int test_sampler_objects(); -extern int initialize_log(); -extern int test_icd_match(); - -extern int test_OpenGL_share(); -extern int test_Direct3D10_share(); +extern int test_create_calls(void); +extern int test_platforms(void); +extern int test_cl_runtime(void); +extern int test_kernel(void); +extern int test_buffer_object(void); +extern int test_program_objects(void); +extern int test_image_objects(void); +extern int test_sampler_objects(void); +extern int test_OpenGL_share(void); +extern int test_release_calls(void); +extern int test_icd_match(void); int main(int argc, char **argv) { + (void)argc; + (void)argv; test_icd_initialize_app_log(); test_icd_initialize_stub_log(); @@ -31,9 +31,8 @@ int main(int argc, char **argv) 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(); diff --git a/test/loader_test/param_struct.h b/test/loader_test/param_struct.h index e5f8ed45..00d96a97 100644 --- a/test/loader_test/param_struct.h +++ b/test/loader_test/param_struct.h @@ -3,7 +3,6 @@ #include #include -#include struct clCreateCommandQueue_st { @@ -68,6 +67,13 @@ struct clGetContextInfo_st size_t *param_value_size_ret; }; +struct clSetContextDestructorCallback_st +{ + cl_context context; + void (CL_CALLBACK *pfn_notify)(cl_context context, void *user_data); + void *user_data; +}; + struct clGetPlatformIDs_st { cl_uint num_entries; @@ -113,6 +119,7 @@ struct clReleaseCommandQueue_st #define NUM_ITEMS_clRetainContext 1 #define NUM_ITEMS_clReleaseContext 1 #define NUM_ITEMS_clGetContextInfo 1 +#define NUM_ITEMS_clSetContextDestructorCallback 1 #define NUM_ITEMS_clGetPlatformIDs 1 #define NUM_ITEMS_clGetPlatformInfo 1 #define NUM_ITEMS_clGetDeviceIDs 1 @@ -151,6 +158,7 @@ struct clReleaseDevice_st #define NUM_ITEMS_clCreateBuffer 1 +#define NUM_ITEMS_clCreateBufferWithProperties 1 #define NUM_ITEMS_clCreateSubBuffer 1 #define NUM_ITEMS_clEnqueueReadBuffer 1 #define NUM_ITEMS_clEnqueueWriteBuffer 1 @@ -174,6 +182,17 @@ struct clCreateBuffer_st void *host_ptr; cl_int *errcode_ret; }; + +struct clCreateBufferWithProperties_st +{ + cl_context context; + const cl_mem_properties * properties; + cl_mem_flags flags; + size_t size; + void *host_ptr; + cl_int *errcode_ret; +}; + struct clCreateSubBuffer_st { cl_mem buffer; @@ -473,6 +492,7 @@ struct clGetProgramBuildInfo_st #define NUM_ITEMS_clCreateImage2D 1 #define NUM_ITEMS_clCreateImage3D 1 #define NUM_ITEMS_clCreateImage 1 +#define NUM_ITEMS_clCreateImageWithProperties 1 #define NUM_ITEMS_clGetSupportedImageFormats 1 #define NUM_ITEMS_clEnqueueCopyImageToBuffer 1 #define NUM_ITEMS_clEnqueueCopyBufferToImage 1 @@ -494,6 +514,17 @@ struct clCreateImage_st cl_int *errcode_ret; }; +struct clCreateImageWithProperties_st +{ + cl_context context; + const cl_mem_properties * properties; + cl_mem_flags flags; + const cl_image_format *image_format; + const cl_image_desc *image_desc; + void *host_ptr; + cl_int *errcode_ret; +}; + struct clCreateImage2D_st { cl_context context; @@ -760,7 +791,7 @@ struct clGetKernelWorkGroupInfo_st struct clEnqueueMigrateMemObjects_st { cl_command_queue command_queue; - size_t num_mem_objects; + cl_uint num_mem_objects; const cl_mem *mem_objects; cl_mem_migration_flags flags; cl_uint num_events_in_wait_list; @@ -771,7 +802,8 @@ struct clEnqueueMigrateMemObjects_st struct clEnqueueNDRangeKernel_st { cl_command_queue command_queue; - cl_kernel kernel; cl_uint work_dim; + cl_kernel kernel; + cl_uint work_dim; const size_t *global_work_offset; const size_t *global_work_size; const size_t *local_work_size; diff --git a/test/loader_test/test_buffer_object.c b/test/loader_test/test_buffer_object.c index 85a2178c..d133875a 100644 --- a/test/loader_test/test_buffer_object.c +++ b/test/loader_test/test_buffer_object.c @@ -1,3 +1,5 @@ +#include + #include #include "param_struct.h" #include @@ -334,6 +336,7 @@ int test_clEnqueueMapBuffer(const struct clEnqueueMapBuffer_st *data) int test_clRetainMemObject(const struct clRetainMemObject_st *data) { + (void)data; test_icd_app_log("clRetainMemObject(%p)\n", buffer); ret_val=clRetainMemObject(buffer); @@ -405,7 +408,7 @@ int test_clGetMemObjectInfo (const struct clGetMemObjectInfo_st *data) return 0; } -int test_buffer_object() +int test_buffer_object(void) { int i; for (i=0; iparam_name, @@ -40,21 +43,21 @@ int test_clGetCommandQueueInfo(const struct clGetCommandQueueInfo_st *data) 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 test_cl_runtime(void) { int i; for (i=0; i #include -#include #include "param_struct.h" #include @@ -12,8 +11,6 @@ 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} @@ -21,20 +18,21 @@ struct clCreateFromGLBuffer_st clCreateFromGLBufferData[NUM_ITEMS_clCreateFromGL int test_clCreateFromGLBuffer(const struct clCreateFromGLBuffer_st* data) { + cl_mem ret_mem; test_icd_app_log("clCreateFromGLBuffer(%p, %x, %u, %p)\n", context, data->flags, - data->bufobj, + data->bufobj, data->errcode_ret); ret_mem = clCreateFromGLBuffer(context, data->flags, - data->bufobj, - data->errcode_ret); + data->bufobj, + data->errcode_ret); test_icd_app_log("Value returned: %p\n", ret_mem); - + return 0; } @@ -44,23 +42,25 @@ struct clCreateFromGLTexture_st clCreateFromGLTextureData[NUM_ITEMS_clCreateFrom int test_clCreateFromGLTexture(const struct clCreateFromGLTexture_st* data) { + cl_mem ret_mem; + test_icd_app_log("clCreateFromGLTexture(%p, %x, %d, %d, %u, %p)\n", context, - data->flags, + data->flags, data->texture_target, - data->miplevel, - data->texture, + data->miplevel, + data->texture, data->errcode_ret); ret_mem = clCreateFromGLTexture(context, - data->flags, + data->flags, data->texture_target, - data->miplevel, - data->texture, + data->miplevel, + data->texture, data->errcode_ret); test_icd_app_log("Value returned: %p\n", ret_mem); - + return 0; } @@ -70,23 +70,25 @@ struct clCreateFromGLTexture2D_st clCreateFromGLTexture2DData[NUM_ITEMS_clCreate int test_clCreateFromGLTexture2D(const struct clCreateFromGLTexture2D_st* data) { + cl_mem ret_mem; + test_icd_app_log("clCreateFromGLTexture2D(%p, %x, %d, %d, %u, %p)\n", context, - data->flags, + data->flags, data->texture_target, - data->miplevel, - data->texture, + data->miplevel, + data->texture, data->errcode_ret); ret_mem = clCreateFromGLTexture2D(context, - data->flags, + data->flags, data->texture_target, - data->miplevel, - data->texture, + data->miplevel, + data->texture, data->errcode_ret); test_icd_app_log("Value returned: %p\n", ret_mem); - + return 0; } @@ -95,21 +97,23 @@ struct clCreateFromGLTexture3D_st clCreateFromGLTexture3DData[NUM_ITEMS_clCreate }; int test_clCreateFromGLTexture3D(const struct clCreateFromGLTexture3D_st* data) -{ +{ + cl_mem ret_mem; + test_icd_app_log("clCreateFromGLTexture3D(%p, %x, %d, %d, %u, %p)\n", context, data->flags, data->texture_target, - data->miplevel, - data->texture, + data->miplevel, + data->texture, data->errcode_ret); ret_mem = clCreateFromGLTexture3D(context, - data->flags, + data->flags, data->texture_target, - data->miplevel, - data->texture, - data->errcode_ret); + data->miplevel, + data->texture, + data->errcode_ret); test_icd_app_log("Value returned: %p\n", ret_mem); @@ -122,15 +126,17 @@ struct clCreateFromGLRenderbuffer_st clCreateFromGLRenderbufferData[NUM_ITEMS_cl int test_clCreateFromGLRenderbuffer(const struct clCreateFromGLRenderbuffer_st* data) { + cl_mem ret_mem; + test_icd_app_log("clCreateFromGLRenderbuffer(%p, %x, %d, %p)\n", - context, + context, data->flags, - data->renderbuffer, + data->renderbuffer, data->errcode_ret); - ret_mem = clCreateFromGLRenderbuffer(context, + ret_mem = clCreateFromGLRenderbuffer(context, data->flags, - data->renderbuffer, + data->renderbuffer, data->errcode_ret); test_icd_app_log("Value returned: %p\n", ret_mem); @@ -144,17 +150,19 @@ struct clGetGLObjectInfo_st clGetGLObjectInfoData[NUM_ITEMS_clGetGLObjectInfo] = int test_clGetGLObjectInfo(const struct clGetGLObjectInfo_st* data) { + cl_int ret_val; + test_icd_app_log("clGetGLObjectInfo(%p, %p, %p)\n", buffer, - data->gl_object_type, + data->gl_object_type, data->gl_object_name); ret_val = clGetGLObjectInfo(buffer, - data->gl_object_type, + data->gl_object_type, data->gl_object_name); test_icd_app_log("Value returned: %p\n", ret_val); - + return ret_val; } @@ -165,16 +173,18 @@ struct clGetGLTextureInfo_st clGetGLTextureInfoData[NUM_ITEMS_clGetGLTextureInfo int test_clGetGLTextureInfo(const struct clGetGLTextureInfo_st* data) { + cl_int ret_val; + test_icd_app_log("clGetGLTextureInfo(%p, %u, %u, %p, %p)\n", buffer, data->param_name, - data->param_value_size, + 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_size, data->param_value, data->param_value_size_ret); @@ -189,19 +199,21 @@ struct clEnqueueAcquireGLObjects_st clEnqueueAcquireGLObjectsData[NUM_ITEMS_clEn int test_clEnqueueAcquireGLObjects(const struct clEnqueueAcquireGLObjects_st* data) { + cl_int ret_val; + test_icd_app_log("clEnqueueAcquireGLObjects(%p, %u, %p, %u, %p, %p)\n", command_queue, - data->num_objects, + data->num_objects, data->mem_objects, data->num_events_in_wait_list, &event, &event); ret_val = clEnqueueAcquireGLObjects (command_queue, - data->num_objects, + data->num_objects, data->mem_objects, data->num_events_in_wait_list, - &event, + &event, &event); test_icd_app_log("Value returned: %p\n", ret_val); @@ -215,19 +227,21 @@ struct clEnqueueReleaseGLObjects_st clEnqueueReleaseGLObjectsData[NUM_ITEMS_clEn int test_clEnqueueReleaseGLObjects(const struct clEnqueueReleaseGLObjects_st* data) { + cl_int ret_val; + test_icd_app_log("clEnqueueReleaseGLObjects(%p, %u, %p, %u, %p, %p)\n", command_queue, - data->num_objects, + data->num_objects, data->mem_objects, data->num_events_in_wait_list, - &event, + &event, &event); ret_val = clEnqueueReleaseGLObjects (command_queue, - data->num_objects, + data->num_objects, data->mem_objects, data->num_events_in_wait_list, - &event, + &event, &event); @@ -240,7 +254,7 @@ struct clCreateEventFromGLsyncKHR_st clCreateEventFromGLsyncKHRData[NUM_ITEMS_cl {NULL, NULL, NULL} }; -typedef CL_API_ENTRY cl_event +typedef cl_event (CL_API_CALL *PFN_clCreateEventFromGLsyncKHR)(cl_context /* context */, cl_GLsync /* cl_GLsync */, cl_int * /* errcode_ret */); @@ -250,18 +264,19 @@ int test_clCreateEventFromGLsyncKHR(const struct clCreateEventFromGLsyncKHR_st* PFN_clCreateEventFromGLsyncKHR pfn_clCreateEventFromGLsyncKHR = NULL; test_icd_app_log("clCreateEventFromGLsyncKHR(%p, %p, %p)\n", - context, - data->sync, + context, + data->sync, data->errcode_ret); - pfn_clCreateEventFromGLsyncKHR = clGetExtensionFunctionAddress("clCreateEventFromGLsyncKHR"); + pfn_clCreateEventFromGLsyncKHR = (PFN_clCreateEventFromGLsyncKHR) + (intptr_t)clGetExtensionFunctionAddress("clCreateEventFromGLsyncKHR"); if (!pfn_clCreateEventFromGLsyncKHR) { test_icd_app_log("clGetExtensionFunctionAddress failed!\n"); return 1; } - ret_event = pfn_clCreateEventFromGLsyncKHR (context, - data->sync, + ret_event = pfn_clCreateEventFromGLsyncKHR (context, + data->sync, data->errcode_ret); test_icd_app_log("Value returned: %p\n", ret_event); @@ -272,24 +287,27 @@ struct clGetGLContextInfoKHR_st clGetGLContextInfoKHRData[NUM_ITEMS_clGetGLConte {NULL, 0, 0, NULL, NULL} }; -typedef CL_API_ENTRY cl_int +typedef 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) { + cl_int ret_val; + 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_size, data->param_value, data->param_value_size_ret); - pfn_clGetGLContextInfoKHR = clGetExtensionFunctionAddress("clGetGLContextInfoKHR"); + pfn_clGetGLContextInfoKHR = (PFN_clGetGLContextInfoKHR) + (intptr_t)clGetExtensionFunctionAddress("clGetGLContextInfoKHR"); if (!pfn_clGetGLContextInfoKHR) { test_icd_app_log("clGetExtensionFunctionAddress failed!\n"); return 1; @@ -297,7 +315,7 @@ int test_clGetGLContextInfoKHR(const struct clGetGLContextInfoKHR_st* data) ret_val = pfn_clGetGLContextInfoKHR(context_properties, data->param_name, - data->param_value_size, + data->param_value_size, data->param_value, data->param_value_size_ret); @@ -306,10 +324,10 @@ int test_clGetGLContextInfoKHR(const struct clGetGLContextInfoKHR_st* data) } -int test_OpenGL_share() +int test_OpenGL_share(void) { int i; - + for(i=0;i +#include #define CL_USE_DEPRECATED_OPENCL_1_0_APIS #define CL_USE_DEPRECATED_OPENCL_1_1_APIS @@ -10,7 +11,6 @@ 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; @@ -59,6 +59,11 @@ const struct clCreateBuffer_st clCreateBufferData[NUM_ITEMS_clCreateBuffer] = {NULL, 0, 0, NULL, NULL} }; +const struct clCreateBufferWithProperties_st clCreateBufferWithPropertiesData[NUM_ITEMS_clCreateBufferWithProperties] = +{ + {NULL, NULL, 0, 0, NULL, NULL} +}; + const struct clCreateSubBuffer_st clCreateSubBufferData[NUM_ITEMS_clCreateSubBuffer] = { {NULL, 0, 0, NULL, NULL} @@ -69,6 +74,11 @@ const struct clCreateImage_st clCreateImageData[NUM_ITEMS_clCreateImage] = { NULL, 0x0, NULL, NULL, NULL, NULL} }; +const struct clCreateImageWithProperties_st clCreateImageWithPropertiesData[NUM_ITEMS_clCreateImageWithProperties] = +{ + { NULL, NULL, 0x0, NULL, NULL, NULL, NULL} +}; + const struct clCreateImage2D_st clCreateImage2DData[NUM_ITEMS_clCreateImage2D] = { { NULL, 0x0, NULL, 0, 0, 0, NULL, NULL} @@ -85,10 +95,17 @@ struct clReleaseMemObject_st clReleaseMemObjectData[NUM_ITEMS_clReleaseMemObject {NULL} }; +struct clReleaseMemObject_st clReleaseMemObjectDataSubBuffer[NUM_ITEMS_clReleaseMemObject] = +{ + {NULL} +}; + struct clReleaseMemObject_st clReleaseMemObjectDataImage[NUM_ITEMS_clReleaseMemObject] = { {NULL} -};const struct clCreateProgramWithSource_st clCreateProgramWithSourceData[NUM_ITEMS_clCreateProgramWithSource] = +}; + +const struct clCreateProgramWithSource_st clCreateProgramWithSourceData[NUM_ITEMS_clCreateProgramWithSource] = { {NULL, 0, NULL, NULL, NULL} }; @@ -133,19 +150,25 @@ const struct clGetPlatformIDs_st clGetPlatformIDsData[NUM_ITEMS_clGetPlatformIDs */ #define ENABLE_MISMATCHING_PRINTS 0 +const char *default_platform_to_find = "ICD_LOADER_TEST_OPENCL_STUB"; + int test_clGetPlatformIDs(const struct clGetPlatformIDs_st* data) { + const char *platform_to_find = NULL; cl_int ret_val; size_t param_val_ret_size; - #define PLATFORM_NAME_SIZE 40 + #define PLATFORM_NAME_SIZE 80 char platform_name[PLATFORM_NAME_SIZE]; cl_uint i; + cl_platform_id *all_platforms; #if ENABLE_MISMATCHING_PRINTS test_icd_app_log("clGetPlatformIDs(%u, %p, %p)\n", data->num_entries, &platforms, &num_platforms); +#else + (void)data; #endif ret_val = clGetPlatformIDs(0, @@ -165,7 +188,9 @@ int test_clGetPlatformIDs(const struct clGetPlatformIDs_st* data) if (ret_val != CL_SUCCESS){ return -1; } - + + platform_to_find = log_getenv("APP_PLATFORM", "ICD_LOADER_TEST_OPENCL_STUB"); + for (i = 0; i < num_platforms; i++) { ret_val = clGetPlatformInfo(all_platforms[i], CL_PLATFORM_NAME, @@ -174,11 +199,13 @@ int test_clGetPlatformIDs(const struct clGetPlatformIDs_st* data) ¶m_val_ret_size ); if (ret_val == CL_SUCCESS ){ - if(!strcmp(platform_name, "ICD_LOADER_TEST_OPENCL_STUB")) { + if(!strcmp(platform_name, platform_to_find)) { platform = all_platforms[i]; } } } + log_freeenv(platform_to_find); + free(all_platforms); #if ENABLE_MISMATCHING_PRINTS test_icd_app_log("Value returned: %d\n", ret_val); @@ -298,6 +325,31 @@ int test_clCreateBuffer(const struct clCreateBuffer_st *data) } +int test_clCreateBufferWithProperties(const struct clCreateBufferWithProperties_st *data) +{ + test_icd_app_log("clCreateBufferWithProperties(%p, %p, %x, %u, %p, %p)\n", + context, + data->properties, + data->flags, + data->size, + data->host_ptr, + data->errcode_ret); + + buffer = clCreateBufferWithProperties(context, + data->properties, + 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", @@ -313,7 +365,7 @@ int test_clCreateSubBuffer(const struct clCreateSubBuffer_st *data) data->buffer_create_info, data->errcode_ret); - clReleaseMemObjectData->memobj = buffer; + clReleaseMemObjectDataSubBuffer->memobj = subBuffer; test_icd_app_log("Value returned: %p\n", subBuffer); @@ -345,6 +397,32 @@ int test_clCreateImage(const struct clCreateImage_st *data) } +int test_clCreateImageWithProperties(const struct clCreateImageWithProperties_st *data) +{ + test_icd_app_log("clCreateImageWithProperties(%p, %p, %x, %p, %p, %p, %p)\n", + context, + data->properties, + data->flags, + data->image_format, + data->image_desc, + data->host_ptr, + data->errcode_ret); + + image = clCreateImageWithProperties(context, + data->properties, + 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", @@ -552,6 +630,7 @@ const struct clReleaseSampler_st clReleaseSamplerData[NUM_ITEMS_clReleaseSampler int test_clReleaseSampler(const struct clReleaseSampler_st *data) { + (void)data; int ret_val = CL_OUT_OF_RESOURCES; test_icd_app_log("clReleaseSampler(%p)\n", sampler); @@ -584,6 +663,7 @@ const struct clReleaseEvent_st clReleaseEventData[NUM_ITEMS_clReleaseEvent] = int test_clReleaseEvent(const struct clReleaseEvent_st* data) { + (void)data; int ret_val = CL_OUT_OF_RESOURCES; test_icd_app_log("clReleaseEvent(%p)\n", event); @@ -603,6 +683,7 @@ const struct clReleaseKernel_st clReleaseKernelData[NUM_ITEMS_clReleaseKernel] = int test_clReleaseKernel(const struct clReleaseKernel_st* data) { + (void)data; int ret_val = CL_OUT_OF_RESOURCES; test_icd_app_log("clReleaseKernel(%p)\n", kernel); @@ -622,6 +703,7 @@ const struct clReleaseProgram_st clReleaseProgramData[NUM_ITEMS_clReleaseProgram int test_clReleaseProgram(const struct clReleaseProgram_st *data) { + (void)data; int ret_val = CL_OUT_OF_RESOURCES; test_icd_app_log("clReleaseProgram(%p)\n", program); @@ -641,6 +723,7 @@ const struct clReleaseCommandQueue_st clReleaseCommandQueueData[NUM_ITEMS_clRele int test_clReleaseCommandQueue(const struct clReleaseCommandQueue_st *data) { + (void)data; int ret_val = CL_OUT_OF_RESOURCES; test_icd_app_log("clReleaseCommandQueue(%p)\n", command_queue); @@ -660,6 +743,7 @@ const struct clReleaseContext_st clReleaseContextData[NUM_ITEMS_clReleaseContext int test_clReleaseContext(const struct clReleaseContext_st* data) { + (void)data; int ret_val = CL_OUT_OF_RESOURCES; test_icd_app_log("clReleaseContext(%p)\n", context); @@ -679,6 +763,7 @@ const struct clReleaseDevice_st clReleaseDeviceData[NUM_ITEMS_clReleaseDevice] = int test_clReleaseDevice(const struct clReleaseDevice_st* data) { + (void)data; int ret_val = CL_OUT_OF_RESOURCES; test_icd_app_log("clReleaseDevice(%p)\n", devices); @@ -691,7 +776,7 @@ int test_clReleaseDevice(const struct clReleaseDevice_st* data) } -int test_create_calls() +int test_create_calls(void) { test_clGetPlatformIDs(clGetPlatformIDsData); @@ -709,12 +794,20 @@ int test_create_calls() test_clCreateBuffer(clCreateBufferData); + test_clReleaseMemObject(clReleaseMemObjectData); + + test_clCreateBufferWithProperties(clCreateBufferWithPropertiesData); + test_clCreateSubBuffer(clCreateSubBufferData); test_clCreateImage(clCreateImageData); test_clReleaseMemObject(clReleaseMemObjectDataImage); + test_clCreateImageWithProperties(clCreateImageWithPropertiesData); + + test_clReleaseMemObject(clReleaseMemObjectDataImage); + test_clCreateImage2D(clCreateImage2DData); test_clReleaseMemObject(clReleaseMemObjectDataImage); @@ -743,12 +836,14 @@ int test_create_calls() } -int test_release_calls() +int test_release_calls(void) { test_clReleaseSampler(clReleaseSamplerData); test_clReleaseMemObject(clReleaseMemObjectData); + test_clReleaseMemObject(clReleaseMemObjectDataSubBuffer); + test_clReleaseMemObject(clReleaseMemObjectDataImage); test_clReleaseEvent(clReleaseEventData); diff --git a/test/loader_test/test_image_objects.c b/test/loader_test/test_image_objects.c index 0c47d130..f214a30d 100644 --- a/test/loader_test/test_image_objects.c +++ b/test/loader_test/test_image_objects.c @@ -1,3 +1,5 @@ +#include + #include #include "param_struct.h" #include @@ -8,8 +10,6 @@ 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 } @@ -27,7 +27,7 @@ const struct clEnqueueCopyBufferToImage_st clEnqueueCopyBufferToImageData[NUM_IT const struct clEnqueueMapImage_st clEnqueueMapImageData[NUM_ITEMS_clEnqueueMapImage] = { - { NULL, NULL, 0, 0x0, NULL, NULL, NULL, NULL,0, NULL, NULL} + { NULL, NULL, 0, 0x0, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL} }; const struct clEnqueueReadImage_st clEnqueueReadImageData[NUM_ITEMS_clEnqueueReadImage] = @@ -57,6 +57,8 @@ const struct clGetImageInfo_st clGetImageInfoData[NUM_ITEMS_clGetImageInfo] = int test_clGetSupportedImageFormats(const struct clGetSupportedImageFormats_st *data) { + cl_int ret_val; + test_icd_app_log("clGetSupportedImageFormats(%p, %x, %u, %u, %p, %p)\n", context, data->flags, @@ -64,7 +66,7 @@ int test_clGetSupportedImageFormats(const struct clGetSupportedImageFormats_st * data->num_entries, data->image_formats, data->num_image_formats); - + ret_val = clGetSupportedImageFormats(context, data->flags, data->image_type, @@ -80,6 +82,8 @@ int test_clGetSupportedImageFormats(const struct clGetSupportedImageFormats_st * int test_clEnqueueCopyImageToBuffer(const struct clEnqueueCopyImageToBuffer_st *data) { + cl_int ret_val; + test_icd_app_log("clEnqueueCopyImageToBuffer(%p, %p, %p, %p, %p, %u, %u, %p, %p)\n", command_queue, image, @@ -109,6 +113,8 @@ int test_clEnqueueCopyImageToBuffer(const struct clEnqueueCopyImageToBuffer_st * int test_clEnqueueCopyBufferToImage(const struct clEnqueueCopyBufferToImage_st *data) { + cl_int ret_val; + test_icd_app_log("clEnqueueCopyBufferToImage(%p, %p, %p, %u, %p, %p, %u, %p, %p)\n", command_queue, buffer, @@ -176,11 +182,13 @@ int test_clEnqueueMapImage(const struct clEnqueueMapImage_st *data) int test_clEnqueueReadImage(const struct clEnqueueReadImage_st *data) { + cl_int ret_val; + 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->origin, data->region, data->row_pitch, data->slice_pitch, @@ -193,11 +201,11 @@ int test_clEnqueueReadImage(const struct clEnqueueReadImage_st *data) image, data->blocking_read, data->origin, - data->region, - data->row_pitch, - data->slice_pitch, - data->ptr, - data->num_events_in_wait_list, + data->region, + data->row_pitch, + data->slice_pitch, + data->ptr, + data->num_events_in_wait_list, data->event_wait_list, &event); @@ -209,6 +217,8 @@ int test_clEnqueueReadImage(const struct clEnqueueReadImage_st *data) int test_clEnqueueWriteImage(const struct clEnqueueWriteImage_st *data) { + cl_int ret_val; + test_icd_app_log("clEnqueueWriteImage(%p, %p, %u, %p, %p, %u, %u, %p, %u, %p, %p)\n", command_queue, image, @@ -242,6 +252,8 @@ int test_clEnqueueWriteImage(const struct clEnqueueWriteImage_st *data) int test_clEnqueueFillImage(const struct clEnqueueFillImage_st *data) { + cl_int ret_val; + test_icd_app_log("clEnqueueFillImage(%p, %p, %p, %p, %p, %u, %p, %p)\n", command_queue, image, @@ -249,16 +261,16 @@ int test_clEnqueueFillImage(const struct clEnqueueFillImage_st *data) data->origin, data->region, data->num_events_in_wait_list, - data->event_wait_list, + data->event_wait_list, &event); ret_val = clEnqueueFillImage(command_queue, - image, + image, data->fill_color, data->origin, data->region, data->num_events_in_wait_list, - data->event_wait_list, + data->event_wait_list, &event); test_icd_app_log("Value returned: %d\n", ret_val); @@ -268,6 +280,8 @@ int test_clEnqueueFillImage(const struct clEnqueueFillImage_st *data) } int test_clEnqueueCopyImage(const struct clEnqueueCopyImage_st *data) { + cl_int ret_val; + test_icd_app_log("clEnqueueCopyImage(%p, %p, %p, %p, %p, %p, %u, %p, %p)\n", command_queue, image, @@ -276,7 +290,7 @@ int test_clEnqueueCopyImage(const struct clEnqueueCopyImage_st *data) data->dst_origin, data->region, data->num_events_in_wait_list, - data->event_wait_list, + data->event_wait_list, &event); ret_val = clEnqueueCopyImage(command_queue, @@ -286,7 +300,7 @@ int test_clEnqueueCopyImage(const struct clEnqueueCopyImage_st *data) data->dst_origin, data->region, data->num_events_in_wait_list, - data->event_wait_list, + data->event_wait_list, &event); test_icd_app_log("Value returned: %d\n", ret_val); @@ -298,6 +312,8 @@ int test_clEnqueueCopyImage(const struct clEnqueueCopyImage_st *data) int test_clGetImageInfo(const struct clGetImageInfo_st *data) { + cl_int ret_val; + test_icd_app_log("clGetImageInfo(%p, %u, %u, %p, %p)\n", image, data->param_name, @@ -317,7 +333,7 @@ int test_clGetImageInfo(const struct clGetImageInfo_st *data) } -int test_image_objects() +int test_image_objects(void) { int i; diff --git a/test/loader_test/test_kernel.c b/test/loader_test/test_kernel.c index a53e9805..e76c77ff 100644 --- a/test/loader_test/test_kernel.c +++ b/test/loader_test/test_kernel.c @@ -15,7 +15,7 @@ extern cl_event event; extern cl_context context; extern cl_command_queue command_queue; extern cl_device_id devices; -int ret_val; +static 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 ); @@ -26,6 +26,7 @@ struct clRetainKernel_st clRetainKernelData[NUM_ITEMS_clRetainKernel] = int test_clRetainKernel(const struct clRetainKernel_st* data) { + (void)data; test_icd_app_log("clRetainKernel(%p)\n", kernel); ret_val=clRetainKernel(kernel); @@ -168,7 +169,7 @@ int test_clEnqueueMigrateMemObjects(const struct clEnqueueMigrateMemObjects_st* struct clEnqueueNDRangeKernel_st clEnqueueNDRangeKernelData[NUM_ITEMS_clEnqueueNDRangeKernel] = { - {NULL, NULL, 0, NULL, NULL, NULL, 0, NULL} + {NULL, NULL, 0, NULL, NULL, NULL, 0, NULL, NULL} }; int test_clEnqueueNDRangeKernel(const struct clEnqueueNDRangeKernel_st* data) @@ -345,6 +346,7 @@ struct clRetainEvent_st clRetainEventData[NUM_ITEMS_clRetainEvent] = int test_clRetainEvent(const struct clRetainEvent_st* data) { + (void)data; test_icd_app_log("clRetainEvent(%p)\n", event); ret_val=clRetainEvent(event); @@ -361,6 +363,7 @@ struct clEnqueueMarker_st clEnqueueMarkerData[NUM_ITEMS_clEnqueueMarker] = int test_clEnqueueMarker(const struct clEnqueueMarker_st* data) { + (void)data; test_icd_app_log("clEnqueueMarker(%p, %p)\n", command_queue, &event); ret_val = clEnqueueMarker(command_queue, &event); @@ -443,6 +446,7 @@ struct clEnqueueBarrier_st clEnqueueBarrierData[NUM_ITEMS_clEnqueueBarrier] = int test_clEnqueueBarrier(const struct clEnqueueBarrier_st* data) { + (void)data; test_icd_app_log("clEnqueueBarrier(%p)\n", command_queue); ret_val = clEnqueueBarrier(command_queue); @@ -483,6 +487,7 @@ struct clFlush_st clFlushData[NUM_ITEMS_clFlush] = int test_clFlush(const struct clFlush_st* data) { + (void)data; test_icd_app_log("clFlush(%p)\n", command_queue); ret_val=clFlush(command_queue); @@ -499,6 +504,7 @@ struct clFinish_st clFinishData[NUM_ITEMS_clFinish] = int test_clFinish(const struct clFinish_st* data) { + (void)data; test_icd_app_log("clFinish(%p)\n", command_queue); ret_val=clFinish(command_queue); @@ -508,7 +514,7 @@ int test_clFinish(const struct clFinish_st* data) return 0; } -int test_kernel() +int test_kernel(void) { int i; diff --git a/test/loader_test/test_platforms.c b/test/loader_test/test_platforms.c index d22a3d0e..ca836283 100644 --- a/test/loader_test/test_platforms.c +++ b/test/loader_test/test_platforms.c @@ -8,7 +8,7 @@ extern cl_platform_id platform; extern cl_device_id devices; -int ret_val; +extern void CL_CALLBACK setcontextdestructor_callback(cl_context _a, void* _b); struct clRetainContext_st clRetainContextData[NUM_ITEMS_clRetainContext] = { @@ -20,6 +20,10 @@ struct clGetContextInfo_st clGetContextInfoData[NUM_ITEMS_clGetContextInfo] = {NULL, 0, 0, NULL, NULL} }; +struct clSetContextDestructorCallback_st clSetContextDestructorCallbackData[NUM_ITEMS_clSetContextDestructorCallback] = +{ + {NULL, setcontextdestructor_callback, NULL} +}; struct clGetPlatformInfo_st clGetPlatformInfoData[NUM_ITEMS_clGetPlatformInfo] = { @@ -45,7 +49,10 @@ struct clRetainDevice_st clRetainDeviceData[NUM_ITEMS_clRetainDevice] = int test_clRetainContext(const struct clRetainContext_st* data) { - test_icd_app_log("clRetainContext(%p)\n", context); + (void)data; + cl_int ret_val; + + test_icd_app_log("clRetainContext(%p)\n", context); ret_val = clRetainContext(context); @@ -55,21 +62,22 @@ int test_clRetainContext(const struct clRetainContext_st* data) } - int test_clGetContextInfo(const struct clGetContextInfo_st* data) { + cl_int ret_val; + test_icd_app_log("clGetContextInfo(%p, %u, %u, %p, %p)\n", context, - data->param_name, + data->param_name, data->param_value_size, - data->param_value, - data->param_value_size_ret); + data->param_value, + data->param_value_size_ret); ret_val = clGetContextInfo(context, - data->param_name, + data->param_name, data->param_value_size, - data->param_value, + data->param_value, data->param_value_size_ret); test_icd_app_log("Value returned: %d\n", ret_val); @@ -77,20 +85,45 @@ int test_clGetContextInfo(const struct clGetContextInfo_st* data) return 0; } + +int test_clSetContextDestructorCallback( + const struct clSetContextDestructorCallback_st* data) +{ + cl_int ret_val; + + test_icd_app_log( + "clSetContextDestructorCallback(%p, %p, %p)\n", + context, + data->pfn_notify, + data->user_data); + + ret_val = clSetContextDestructorCallback( + context, + data->pfn_notify, + data->user_data); + + test_icd_app_log("Value returned: %d\n", ret_val); + + return 0; +} + + int test_clGetPlatformInfo(const struct clGetPlatformInfo_st* data) { + cl_int ret_val; + 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); + 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); + data->param_value_size_ret); test_icd_app_log("Value returned: %d\n", ret_val); @@ -99,19 +132,21 @@ int test_clGetPlatformInfo(const struct clGetPlatformInfo_st* data) } int test_clGetDeviceInfo(const struct clGetDeviceInfo_st* data) -{ +{ + cl_int ret_val; + 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); + 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); + 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); @@ -120,18 +155,20 @@ int test_clGetDeviceInfo(const struct clGetDeviceInfo_st* data) int test_clCreateSubDevices(const struct clCreateSubDevices_st* data) { + cl_int ret_val; + test_icd_app_log("clCreateSubDevices(%p, %p, %u, %p, %p)\n", devices, - data->properties, - data->num_entries, - &devices, - data->num_devices); + data->properties, + data->num_entries, + &devices, + data->num_devices); ret_val = clCreateSubDevices(devices, - data->properties, + data->properties, data->num_entries, - &devices, - data->num_devices); + &devices, + data->num_devices); test_icd_app_log("Value returned: %d\n", ret_val); @@ -140,44 +177,51 @@ int test_clCreateSubDevices(const struct clCreateSubDevices_st* data) int test_clRetainDevice(const struct clRetainDevice_st* data) { - test_icd_app_log("clRetainDevice(%p)\n", devices); + (void)data; + cl_int ret_val; + + test_icd_app_log("clRetainDevice(%p)\n", devices); - ret_val = clRetainDevice(devices); + ret_val = clRetainDevice(devices); test_icd_app_log("Value returned: %d\n", ret_val); return 0; } -int test_platforms() +int test_platforms(void) { int i; - for (i = 0;inum_devices, @@ -90,6 +93,8 @@ int test_clBuildProgram(const struct clBuildProgram_st *data) int test_clCompileProgram(const struct clCompileProgram_st *data) { + cl_int ret_val; + test_icd_app_log("clCompileProgram(%p, %u, %p, %p, %u, %p, %p, %p)\n", program, data->num_devices, @@ -118,7 +123,8 @@ int test_clCompileProgram(const struct clCompileProgram_st *data) int test_clLinkProgram(const struct clLinkProgram_st *data) { - cl_program program; + cl_program linked_program; + cl_int ret_val; test_icd_app_log("clLinkProgram(%p, %u, %p, %p, %u, %p, %p, %p, %p)\n", context, data->num_devices, @@ -130,7 +136,7 @@ int test_clLinkProgram(const struct clLinkProgram_st *data) data->user_data, data->errcode_ret); - program=clLinkProgram(context, + linked_program=clLinkProgram(context, data->num_devices, data->device_list, data->options, @@ -140,7 +146,11 @@ int test_clLinkProgram(const struct clLinkProgram_st *data) data->user_data, data->errcode_ret); - test_icd_app_log("Value returned: %p\n", program); + test_icd_app_log("Value returned: %p\n", linked_program); + + test_icd_app_log("clReleaseProgram(%p)\n", linked_program); + ret_val = clReleaseProgram(linked_program); + test_icd_app_log("Value returned: %d\n", ret_val); return 0; @@ -148,6 +158,9 @@ int test_clLinkProgram(const struct clLinkProgram_st *data) int test_clUnloadPlatformCompiler(const struct clUnloadPlatformCompiler_st *data) { + (void)data; + cl_int ret_val; + test_icd_app_log("clUnloadPlatformCompiler(%p)\n", platform); ret_val=clUnloadPlatformCompiler(platform); @@ -162,7 +175,7 @@ int test_clGetExtensionFunctionAddressForPlatform(const struct clGetExtensionFun { void *return_value; test_icd_app_log("clGetExtensionFunctionAddressForPlatform(%p, %p)\n", - platform, + platform, data->func_name); return_value=clGetExtensionFunctionAddressForPlatform(platform, @@ -176,6 +189,8 @@ int test_clGetExtensionFunctionAddressForPlatform(const struct clGetExtensionFun int test_clGetProgramInfo(const struct clGetProgramInfo_st *data) { + cl_int ret_val; + test_icd_app_log("clGetProgramInfo(%p, %u, %u, %p, %p)\n", program, data->param_name, @@ -197,6 +212,8 @@ int test_clGetProgramInfo(const struct clGetProgramInfo_st *data) int test_clGetProgramBuildInfo(const struct clGetProgramBuildInfo_st *data) { + cl_int ret_val; + test_icd_app_log("clGetProgramBuildInfo(%p, %p, %u, %u, %p, %p)\n", program, data->device, @@ -218,13 +235,13 @@ int test_clGetProgramBuildInfo(const struct clGetProgramBuildInfo_st *data) } -int test_program_objects() +int test_program_objects(void) { int i; for (i=0;i extern cl_sampler sampler; -int ret_val; const struct clRetainSampler_st clRetainSamplerData[NUM_ITEMS_clRetainSampler]= { @@ -18,6 +17,9 @@ const struct clGetSamplerInfo_st clGetSamplerInfoData[NUM_ITEMS_clGetSamplerInfo int test_clRetainSampler(const struct clRetainSampler_st *data) { + (void)data; + cl_int ret_val; + test_icd_app_log("clRetainSampler(%p)\n", sampler); ret_val=clRetainSampler(sampler); @@ -29,6 +31,8 @@ int test_clRetainSampler(const struct clRetainSampler_st *data) int test_clGetSamplerInfo(const struct clGetSamplerInfo_st *data) { + cl_int ret_val; + test_icd_app_log("clGetSamplerInfo(%p, %u, %u, %p, %p)\n", sampler, data->param_name, @@ -47,7 +51,7 @@ int test_clGetSamplerInfo(const struct clGetSamplerInfo_st *data) return 0; } -int test_sampler_objects() +int test_sampler_objects(void) { int i; diff --git a/test/log/CMakeLists.txt b/test/log/CMakeLists.txt new file mode 100644 index 00000000..341d19ed --- /dev/null +++ b/test/log/CMakeLists.txt @@ -0,0 +1,8 @@ + +add_library (IcdLog SHARED icd_test_log.c) + +target_link_libraries (IcdLog OpenCL::Headers) +target_compile_definitions (IcdLog PRIVATE CL_TARGET_OPENCL_VERSION=300) +if (WIN32) + target_compile_definitions (IcdLog PRIVATE _CRT_SECURE_NO_WARNINGS) +endif() diff --git a/test/log/icd_test_log.c b/test/log/icd_test_log.c new file mode 100644 index 00000000..5c2ac9a3 --- /dev/null +++ b/test/log/icd_test_log.c @@ -0,0 +1,168 @@ +#include +#include +#include +#include +#include +#include + +#if defined(_WIN32) +#include +#endif + +#define APP_LOG_FILE "icd_test_app_log.txt" +#define STUB_LOG_FILE "icd_test_stub_log.txt" + +const char * log_getenv(const char *name, const char *dflt) { +#if defined(_WIN32) + char *retVal = NULL; + DWORD valSize; + + valSize = GetEnvironmentVariableA(name, NULL, 0); + + // valSize DOES include the null terminator, so for any set variable + // will always be at least 1. If it's 0, the variable wasn't set. + if (valSize == 0) { + if (dflt) { + size_t sz = strlen(dflt) + 1; + retVal = (char *)malloc(sz); + if (retVal) + strcpy(retVal, dflt); + } + return retVal; + } + + // Allocate the space necessary for the registry entry + retVal = (char *)malloc(valSize); + + if (NULL != retVal) { + GetEnvironmentVariableA(name, retVal, valSize); + } + + return retVal; +#else + const char *var = NULL; + var = getenv(name); + if (!var) + var = dflt; + return var; +#endif +} + +void log_freeenv(const char *var) { +#if defined(_WIN32) + if (var) + free((void *)var); +#else + (void)var; +#endif +} + +static FILE *app_log_file; +static FILE *stub_log_file; + +static const char *test_icd_get_app_log_file_name(void) +{ + return log_getenv("APP_LOG_FILE", APP_LOG_FILE); +} + +static const char *test_icd_get_stub_log_file_name(void) +{ + return log_getenv("APP_STUB_FILE", STUB_LOG_FILE); +} + +int test_icd_initialize_app_log(void) +{ + const char *app_log_file_name = test_icd_get_app_log_file_name(); + app_log_file = fopen(app_log_file_name, "w"); + if (!app_log_file) { + printf("Unable to open file %s\n", app_log_file_name); + log_freeenv(app_log_file_name); + return -1; + } + + log_freeenv(app_log_file_name); + return 0; +} + +void test_icd_close_app_log(void) +{ + fclose(app_log_file); +} + +void test_icd_app_log(const char *format, ...) +{ + va_list args; + va_start(args, format); + vfprintf(app_log_file, format, args); + va_end(args); +} + +int test_icd_initialize_stub_log(void) +{ + const char *stub_log_file_name = test_icd_get_stub_log_file_name(); + stub_log_file = fopen(stub_log_file_name, "w"); + if (!stub_log_file) { + printf("Unable to open file %s\n", stub_log_file_name); + log_freeenv(stub_log_file_name); + return -1; + } + + log_freeenv(stub_log_file_name); + return 0; +} + +void test_icd_close_stub_log(void) +{ + fclose(stub_log_file); +} + +void test_icd_stub_log(const char *format, ...) +{ + va_list args; + va_start(args, format); + vfprintf(stub_log_file, format, args); + va_end(args); +} + +static char *test_icd_get_log(const char *filename) +{ + struct stat statbuf; + FILE *fp; + char *source = NULL; + + fp = fopen(filename, "rb"); + log_freeenv(filename); + + 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(test_icd_get_app_log_file_name()); +} + +char *test_icd_get_stub_log(void) +{ + return test_icd_get_log(test_icd_get_stub_log_file_name()); +} diff --git a/test/pkgconfig/bare/CMakeLists.txt b/test/pkgconfig/bare/CMakeLists.txt new file mode 100644 index 00000000..f58f21e9 --- /dev/null +++ b/test/pkgconfig/bare/CMakeLists.txt @@ -0,0 +1,46 @@ +cmake_minimum_required(VERSION 3.16) + +project(PkgConfigTest + LANGUAGES C +) + +find_package(OpenCLHeaders + REQUIRED + CONFIG +) +find_package(OpenCLICDLoader + REQUIRED + CONFIG +) + +add_executable(${PROJECT_NAME} + ../pkgconfig.c +) + +target_link_libraries(${PROJECT_NAME} + PRIVATE + OpenCL::Headers + OpenCL::OpenCL +) + +target_compile_definitions(${PROJECT_NAME} + PRIVATE + CL_TARGET_OPENCL_VERSION=120 +) + +include(CTest) + +add_test( + NAME ${PROJECT_NAME} + COMMAND ${PROJECT_NAME} +) + +if(DEFINED DRIVER_STUB_PATH) + file(TO_CMAKE_PATH "${DRIVER_STUB_PATH}" DRIVER_STUB_PATH_CMAKE) + string(REGEX MATCH ".*/" DRIVER_STUB_DIR "${DRIVER_STUB_PATH_CMAKE}") + set_tests_properties(${PROJECT_NAME} + PROPERTIES + ENVIRONMENT "OCL_ICD_FILENAMES=${DRIVER_STUB_PATH}" + WORKING_DIRECTORY "${DRIVER_STUB_DIR}" + ) +endif() diff --git a/test/pkgconfig/pkgconfig.c b/test/pkgconfig/pkgconfig.c new file mode 100644 index 00000000..aadd25f1 --- /dev/null +++ b/test/pkgconfig/pkgconfig.c @@ -0,0 +1,70 @@ +#ifdef __APPLE__ //Mac OSX has a different name for the header file +#include +#else +#include +#endif + +#include // printf +#include // malloc +#include // UINTMAX_MAX +#include // strcmp + +void checkErr(cl_int err, const char * name) +{ + if (err != CL_SUCCESS) + { + printf("ERROR: %s (%i)\n", name, err); + exit( err ); + } +} + +int main(void) +{ + cl_int CL_err = CL_SUCCESS; + cl_uint numPlatforms = 0; + cl_int stub_platform_found = CL_FALSE; + + CL_err = clGetPlatformIDs(0, NULL, &numPlatforms); + checkErr(CL_err, "clGetPlatformIDs(numPlatforms)"); + + if (numPlatforms == 0) + { + printf("No OpenCL platform detected.\n"); + exit( -1 ); + } + printf("Found %u platform(s)\n\n", numPlatforms); + fflush(NULL); + + cl_platform_id* platforms = (cl_platform_id*)malloc(numPlatforms * sizeof(cl_platform_id)); + CL_err = clGetPlatformIDs(numPlatforms, platforms, NULL); + checkErr(CL_err, "clGetPlatformIDs(platforms)"); + + for (cl_uint i = 0; i < numPlatforms; ++i) + { + size_t vendor_length; + CL_err = clGetPlatformInfo(platforms[i], CL_PLATFORM_VENDOR, 0, NULL, &vendor_length); + checkErr(CL_err, "clGetPlatformInfo(CL_PLATFORM_VENDOR, NULL, &vendor_length)"); + + char* platform_name = (char*)malloc(vendor_length * sizeof(char)); + CL_err = clGetPlatformInfo(platforms[i], CL_PLATFORM_VENDOR, vendor_length, platform_name, NULL); + checkErr(CL_err, "clGetPlatformInfo(CL_PLATFORM_VENDOR, vendor_length, platform_name)"); + + printf("%s\n", platform_name); + + if (strcmp(platform_name, "stubvendorxxx") == 0) + { + stub_platform_found = CL_TRUE; + } + + fflush(NULL); + free(platform_name); + } + + if (!stub_platform_found) + { + printf("Did not locate stub platform\n"); + return -1; + } + + return 0; +} diff --git a/test/pkgconfig/pkgconfig/CMakeLists.txt b/test/pkgconfig/pkgconfig/CMakeLists.txt new file mode 100644 index 00000000..436fffdb --- /dev/null +++ b/test/pkgconfig/pkgconfig/CMakeLists.txt @@ -0,0 +1,60 @@ +cmake_minimum_required(VERSION 3.16) +find_package(PkgConfig REQUIRED) + +project(PkgConfigTest + LANGUAGES C +) + +pkg_check_modules(OPENCL REQUIRED OpenCL) + +if(CMAKE_VERSION VERSION_LESS 3.12) + link_directories("${OPENCL_LIBRARY_DIRS}") +endif() + +add_executable(${PROJECT_NAME} + ../pkgconfig.c +) + +target_include_directories(${PROJECT_NAME} + PRIVATE + ${OPENCL_INCLUDE_DIRS} +) + +if(CMAKE_VERSION VERSION_LESS 3.12) +target_link_libraries(${PROJECT_NAME} + PRIVATE + ${OPENCL_LIBRARIES} +) +else() +target_link_libraries(${PROJECT_NAME} + PRIVATE + ${OPENCL_LINK_LIBRARIES} +) +endif() + +target_compile_options(${PROJECT_NAME} + PRIVATE + ${OPENCL_CFLAGS_OTHER} +) + +target_compile_definitions(${PROJECT_NAME} + PRIVATE + CL_TARGET_OPENCL_VERSION=120 +) + +include(CTest) + +add_test( + NAME ${PROJECT_NAME} + COMMAND ${PROJECT_NAME} +) + +if(DEFINED DRIVER_STUB_PATH) + file(TO_CMAKE_PATH "${DRIVER_STUB_PATH}" DRIVER_STUB_PATH_CMAKE) + string(REGEX MATCH ".*/" DRIVER_STUB_DIR "${DRIVER_STUB_PATH_CMAKE}") + set_tests_properties(${PROJECT_NAME} + PROPERTIES + ENVIRONMENT "OCL_ICD_FILENAMES=${DRIVER_STUB_PATH}" + WORKING_DIRECTORY "${DRIVER_STUB_DIR}" + ) +endif() diff --git a/test/pkgconfig/sdk/CMakeLists.txt b/test/pkgconfig/sdk/CMakeLists.txt new file mode 100644 index 00000000..83a52b70 --- /dev/null +++ b/test/pkgconfig/sdk/CMakeLists.txt @@ -0,0 +1,45 @@ +cmake_minimum_required(VERSION 3.16) + +project(PkgConfigTest + LANGUAGES C +) + +find_package(OpenCL + REQUIRED + CONFIG + COMPONENTS + Headers + OpenCL +) + +add_executable(${PROJECT_NAME} + ../pkgconfig.c +) + +target_link_libraries(${PROJECT_NAME} + PRIVATE + OpenCL::Headers + OpenCL::OpenCL +) + +target_compile_definitions(${PROJECT_NAME} + PRIVATE + CL_TARGET_OPENCL_VERSION=120 +) + +include(CTest) + +add_test( + NAME ${PROJECT_NAME} + COMMAND ${PROJECT_NAME} +) + +if(DEFINED DRIVER_STUB_PATH) + file(TO_CMAKE_PATH "${DRIVER_STUB_PATH}" DRIVER_STUB_PATH_CMAKE) + string(REGEX MATCH ".*/" DRIVER_STUB_DIR "${DRIVER_STUB_PATH_CMAKE}") + set_tests_properties(${PROJECT_NAME} + PROPERTIES + ENVIRONMENT "OCL_ICD_FILENAMES=${DRIVER_STUB_PATH}" + WORKING_DIRECTORY "${DRIVER_STUB_DIR}" + ) +endif() diff --git a/test/platform/CMakeLists.txt b/test/platform/CMakeLists.txt deleted file mode 100644 index b35ca933..00000000 --- a/test/platform/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_library (IcdLog SHARED icd_test_log.c) diff --git a/test/platform/Makefile b/test/platform/Makefile deleted file mode 100644 index 8cfb38d4..00000000 --- a/test/platform/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -# 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 diff --git a/test/platform/icd_test_log.c b/test/platform/icd_test_log.c deleted file mode 100644 index cd7cc7d7..00000000 --- a/test/platform/icd_test_log.c +++ /dev/null @@ -1,103 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#define APP_LOG_FILE "icd_test_app_log.txt" -#define STUB_LOG_FILE "icd_test_stub_log.txt" - -static FILE *app_log_file; -static FILE *stub_log_file; - -int test_icd_initialize_app_log(void) -{ - app_log_file = fopen(APP_LOG_FILE, "w"); - if (!app_log_file) { - printf("Unable to open file %s\n", APP_LOG_FILE); - return -1; - } - - return 0; -} - -void test_icd_close_app_log(void) -{ - fclose(app_log_file); -} - -void test_icd_app_log(const char *format, ...) -{ - va_list args; - va_start(args, format); - vfprintf(app_log_file, format, args); - va_end(args); -} - -int test_icd_initialize_stub_log(void) -{ - stub_log_file = fopen(STUB_LOG_FILE, "w"); - if (!stub_log_file) { - printf("Unable to open file %s\n", STUB_LOG_FILE); - return -1; - } - - return 0; - -} - -void test_icd_close_stub_log(void) -{ - fclose(stub_log_file); -} - -void test_icd_stub_log(const char *format, ...) -{ - va_list args; - va_start(args, format); - vfprintf(stub_log_file, format, args); - va_end(args); -} - -static char *test_icd_get_log(const char *filename) -{ - struct stat statbuf; - FILE *fp; - char *source = NULL; - - fp = fopen(filename, "rb"); - - if (fp) { - size_t fsize = 0; - stat(filename, &statbuf); - fsize = statbuf.st_size; - source = (char *)malloc(fsize+1); // +1 for NULL terminator - if (source) { - if (fsize) { - if (fread(source, fsize, 1, fp) != 1) { - free(source); - source = NULL; - } else { - source[fsize] = '\0'; - } - } else { - // Don't fail when fsize = 0, just return empty string - source[fsize] = '\0'; - } - } - fclose(fp); - } - - return source; -} - -char *test_icd_get_app_log(void) -{ - return test_icd_get_log(APP_LOG_FILE); -} - -char *test_icd_get_stub_log(void) -{ - return test_icd_get_log(STUB_LOG_FILE); -}