Skip to content

Commit 96d41e3

Browse files
svenvhJacob HodgsonMartin FredinNico Reissmannsilverclaw
committed
Add cl_khr_cooperative_matrix tests
Add tests for the `cl_khr_cooperative_matrix` extension. The extension defines various operations on cooperative matrix types. The list of tested operations is in `cooperative_matrix.def`. Each entry in that `.def` file results in a subtest. Each subtest will iterate over all supported variants reported by the runtime and test each variant. An individual variant can be run using the `--variant` command line option. This CTS suite generates textual SPIR-V and uses spirv-tools to assemble the textual SPIR-V into a SPIR-V binary. Co-authored-by: Jacob Hodgson <jacob.hodgson@arm.com> Co-authored-by: Martin Fredin <martin.fredin@arm.com> Co-authored-by: Nico Reissmann <nico.reissmann@arm.com> Co-authored-by: Pedro Olsen Ferreira <pedro.olsenferreira@arm.com> Co-authored-by: Riccardo Zanetti <riccardo.zanetti@arm.com> Co-authored-by: Stuart Brady <stuart.brady@arm.com> Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
1 parent 3f4bad4 commit 96d41e3

12 files changed

Lines changed: 4466 additions & 1 deletion

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ cmake --build ./OpenCL-ICD-Loader/build --config Release
4949
mkdir SPIRV-Tools/build
5050
cmake -S SPIRV-Tools -B SPIRV-Tools/build -DSPIRV_SKIP_TESTS=ON
5151
cmake --build SPIRV-Tools/build --config Release
52+
cmake --install SPIRV-Tools/build --prefix=SPIRV-Tools/install
5253

5354
mkdir OpenCL-CTS/build
55+
PKG_CONFIG_PATH=$PWD/SPIRV-Tools/install/lib/pkgconfig/ \
5456
cmake -S OpenCL-CTS -B OpenCL-CTS/build \
5557
-DCL_INCLUDE_DIR=$PWD/OpenCL-Headers \
5658
-DSPIRV_INCLUDE_DIR=$PWD/SPIRV-Headers \

test_conformance/compiler/test_compiler_defines_for_extensions.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ const char *known_extensions[] = {
7575
"cl_khr_terminate_context",
7676
"cl_khr_priority_hints",
7777
"cl_khr_throttle_hints",
78+
"cl_khr_cooperative_matrix",
7879
"cl_khr_spirv_no_integer_wrap_decoration",
7980
"cl_khr_extended_versioning",
8081
"cl_khr_device_uuid",

test_conformance/extensions/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# that the extension tests are included in conformance test runs.
55
add_subdirectory( cl_ext_cxx_for_opencl )
66
add_subdirectory( cl_khr_command_buffer )
7+
add_subdirectory( cl_khr_cooperative_matrix )
78
add_subdirectory( cl_khr_dx9_media_sharing )
89
if(ANDROID_PLATFORM GREATER 28)
910
add_subdirectory( cl_khr_external_memory_ahb )
@@ -17,4 +18,4 @@ if(VULKAN_IS_SUPPORTED)
1718
endif()
1819
if(D3D12_IS_SUPPORTED)
1920
add_subdirectory( cl_khr_external_semaphore_dx_fence )
20-
endif()
21+
endif()
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
include(FindPkgConfig)
2+
3+
# first try locating SPIRV-Tools via pkgconfig (the old way)
4+
pkg_search_module(SPIRV_TOOLS SPIRV-Tools)
5+
if (NOT SPIRV_TOOLS_FOUND)
6+
# then try locating SPIRV-Tools via cmake (the new way)
7+
find_package(SPIRV-Tools)
8+
find_package(SPIRV-Tools-tools)
9+
if (SPIRV-Tools_FOUND AND SPIRV-Tools-tools_FOUND)
10+
set(SPIRV_TOOLS_FOUND TRUE)
11+
# check for the existence of library targets in the found packages
12+
if(TARGET SPIRV-Tools-shared)
13+
# use the shared libary target if present
14+
set(SPIRV-Tools-library SPIRV-Tools-shared)
15+
elseif(TARGET SPIRV-Tools-static)
16+
# otherwise fallback to the static library target
17+
set(SPIRV-Tools-library SPIRV-Tools-static)
18+
else()
19+
message(FATAL_ERROR "Found SPIRV-Tools package but neither "
20+
"SPIRV-Tools-shared or SPIRV-Tools-static targets exist.")
21+
endif()
22+
set(SPIRV_TOOLS_LDFLAGS ${SPIRV-Tools-library})
23+
get_target_property(SPIRV_TOOLS_INCLUDE_DIRS ${SPIRV-Tools-library} INTERFACE_INCLUDE_DIRECTORIES)
24+
endif()
25+
endif()
26+
27+
if (SPIRV_TOOLS_FOUND)
28+
set(MODULE_NAME CL_KHR_COOPERATIVE_MATRIX)
29+
30+
set(${MODULE_NAME}_SOURCES
31+
cooperative_matrix.cpp
32+
main.cpp
33+
program.cpp
34+
)
35+
36+
include(../../CMakeCommon.txt)
37+
target_include_directories(${${MODULE_NAME}_OUT} PRIVATE ${SPIRV_TOOLS_INCLUDE_DIRS})
38+
target_link_libraries(${${MODULE_NAME}_OUT} ${SPIRV_TOOLS_LDFLAGS})
39+
else()
40+
message(STATUS "SPIRV-Tools not found; cl_khr_cooperative_matrix tests will not be built")
41+
endif()

0 commit comments

Comments
 (0)