Skip to content

tests for cl_khr_spirv_queries #2409

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ jobs:
cd OpenCL-Headers
ln -s CL OpenCL # For OSX builds
cd ..
- name: Fetch SPIR-V Headers
shell: bash
run: |
git clone https://github.com/KhronosGroup/SPIRV-Headers.git
- name: Install Vulkan SDK
uses: humbletim/install-vulkan-sdk@main
with:
Expand Down Expand Up @@ -159,6 +163,7 @@ jobs:
-DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \
-DCMAKE_CACHE_OPTIONS="-DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache" \
-DCL_INCLUDE_DIR='${{ github.workspace }}'/OpenCL-Headers \
-DSPIRV_INCLUDE_DIR='${{ github.workspace }}'/SPIRV-Headers \
-DCL_LIB_DIR='${{ github.workspace }}'/OpenCL-ICD-Loader/build \
-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE} \
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=./bin \
Expand Down
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ else(CL_INCLUDE_DIR AND CL_LIB_DIR)
message(FATAL_ERROR "Either install OpenCL or pass -DCL_INCLUDE_DIR and -DCL_LIB_DIR")
endif(CL_INCLUDE_DIR AND CL_LIB_DIR)

# SPIRV_INCLUDE_DIR - path to dir with SPIR-V headers
if(NOT SPIRV_INCLUDE_DIR)
message(STATUS "SPIR-V headers haven't been found!")
message(FATAL_ERROR "Pass -DSPIRV_INCLUDE_DIR")
endif(NOT SPIRV_INCLUDE_DIR)

# CLConform_GL_LIBRARIES_DIR - path to OpenGL libraries
if(GL_IS_SUPPORTED AND CLConform_GL_LIBRARIES_DIR)
link_directories(${CLConform_GL_LIBRARIES_DIR})
Expand Down Expand Up @@ -191,6 +197,7 @@ if(APPLE)
endif(APPLE)

include_directories(SYSTEM ${CL_INCLUDE_DIR})
include_directories(SYSTEM ${SPIRV_INCLUDE_DIR}/include)
include_directories(${CLConform_SOURCE_DIR}/test_common/harness
${CLConform_SOURCE_DIR}/test_common/gles
${CLConform_SOURCE_DIR}/test_common/gl
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Compiling the CTS requires the following CMake configuration options to be set:

* `CL_INCLUDE_DIR` Points to the unified
[OpenCL-Headers](https://github.com/KhronosGroup/OpenCL-Headers).
* `SPIRV_INCLUDE_DIR` Points to the unified
[SPIRV-Headers](https://github.com/KhronosGroup/SPIRV-Headers).
* `CL_LIB_DIR` Directory containing the OpenCL library to build against.
* `SPIRV_TOOLS_DIR` Directory containing the `spirv-as` and `spirv-val` binaries
to be used in the CTS build process. Alternatively, the location to these binaries
Expand All @@ -31,6 +33,7 @@ a build, and compile.
```sh
git clone https://github.com/KhronosGroup/OpenCL-CTS.git
git clone https://github.com/KhronosGroup/OpenCL-Headers.git
git clone https://github.com/KhronosGroup/SPIRV-Headers.git
git clone https://github.com/KhronosGroup/OpenCL-ICD-Loader.git
git clone https://github.com/KhronosGroup/SPIRV-Tools.git
git clone https://github.com/KhronosGroup/SPIRV-Headers.git SPIRV-Tools/external/spirv-headers
Expand All @@ -50,6 +53,7 @@ cmake --build SPIRV-Tools/build --config Release
mkdir OpenCL-CTS/build
cmake -S OpenCL-CTS -B OpenCL-CTS/build \
-DCL_INCLUDE_DIR=$PWD/OpenCL-Headers \
-DSPIRV_INCLUDE_DIR=$PWD/SPIRV-Headers \
-DCL_LIB_DIR=$PWD/OpenCL-ICD-Loader/build \
-DSPIRV_TOOLS_DIR=$PWD/SPIRV-Tools/build/tools/ \
-DOPENCL_LIBRARIES=OpenCL
Expand Down
1 change: 1 addition & 0 deletions test_conformance/api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ set(${MODULE_NAME}_SOURCES
test_pipe_properties_queries.cpp
test_wg_suggested_local_work_size.cpp
test_device_command_queue.cpp
test_spirv_queries.cpp
)

include(../CMakeCommon.txt)
95 changes: 95 additions & 0 deletions test_conformance/api/generate_spirv_capability_deps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#!/usr/bin/env python3

#####################################################################
# Copyright (c) 2025 The Khronos Group Inc. All Rights Reserved.
#
# 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.
#####################################################################

"""
Generates a file describing the SPIR-V extension dependencies or SPIR-V version
dependencies for a SPIR-V capability. This can be used to ensure that if support
for a SPIR-V capability is reported, the necessary SPIR-V extensions or SPIR-V
version is also supported.
"""

import argparse
import json

header_text = """\
//
// Copyright (c) 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.
//

// This file is generated from the SPIR-V JSON grammar file.
// Please do not edit it directly!
"""

def main():
parser = argparse.ArgumentParser(description='Generate SPIR-V extension and version dependencies for SPIR-V capabilities')

parser.add_argument('--grammar', metavar='<path>',
type=str, required=True,
help='input JSON grammar file')
args = parser.parse_args()

dependencies = {}
capabilities = []
with open(args.grammar) as json_file:
grammar_json = json.loads(json_file.read())
for operand_kind in grammar_json['operand_kinds']:
if operand_kind['kind'] == 'Capability':
for cap in operand_kind['enumerants']:
capname = cap['enumerant']
capabilities.append(capname)
dependencies[capname] = {}
dependencies[capname]['extensions'] = cap['extensions'] if 'extensions' in cap else []
dependencies[capname]['version'] = ("SPIR-V_" + cap['version']) if 'version' in cap and cap['version'] != 'None' else ""

capabilities.sort()

print(header_text)
print("// clang-format off")
if False:
for cap in capabilities:
deps = dependencies[cap]
extensions_str = ', '.join(f'"{ext}"' for ext in deps['extensions'])

print('SPIRV_CAPABILITY_DEPENDENCIES( ', end = "")
print('{}, '.format(cap), end = "")
print('{{{}}}, '.format(extensions_str), end = "")
print('"{}"'.format(deps['version']), end = "")
print(' )')
else:
for cap in capabilities:
deps = dependencies[cap]
if deps['version'] != "":
print('SPIRV_CAPABILITY_VERSION_DEPENDENCY( {}, "{}" )'.format(cap, deps['version']))
for ext in deps['extensions']:
print('SPIRV_CAPABILITY_EXTENSION_DEPENDENCY( {}, "{}" )'.format(cap, ext))
print("// clang-format on")

if __name__ == '__main__':
main()
Loading
Loading