Skip to content

Add cl_khr_cooperative_matrix tests - #2655

Open
svenvh wants to merge 15 commits into
KhronosGroup:mainfrom
svenvh:cl_khr_cooperative_matrix
Open

svenvh wants to merge 15 commits into
KhronosGroup:mainfrom
svenvh:cl_khr_cooperative_matrix

Conversation

@svenvh

@svenvh svenvh commented Apr 1, 2026

Copy link
Copy Markdown
Member

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.

@svenvh
svenvh force-pushed the cl_khr_cooperative_matrix branch from 96d41e3 to d865c53 Compare April 1, 2026 13:12
@svenvh
svenvh marked this pull request as draft April 1, 2026 13:23
@svenvh
svenvh force-pushed the cl_khr_cooperative_matrix branch 5 times, most recently from 1714294 to bcd2025 Compare April 1, 2026 16:01
Comment thread test_conformance/extensions/cl_khr_cooperative_matrix/program.cpp
@svenvh
svenvh force-pushed the cl_khr_cooperative_matrix branch from bcd2025 to e980541 Compare April 7, 2026 12:37
@svenvh
svenvh marked this pull request as ready for review April 7, 2026 14:24
bashbaug pushed a commit that referenced this pull request May 12, 2026
Avoid spurious failures for the new extension while the extension tests
themselves are still under review in #2655 .

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
@svenvh
svenvh force-pushed the cl_khr_cooperative_matrix branch from e980541 to 19a9a06 Compare May 13, 2026 13:01
Comment on lines +36 to +40
include(../../CMakeCommon.txt)
target_include_directories(${${MODULE_NAME}_OUT} PRIVATE ${SPIRV_TOOLS_INCLUDE_DIRS})
target_link_libraries(${${MODULE_NAME}_OUT} ${SPIRV_TOOLS_LDFLAGS})
else()
message(STATUS "SPIRV-Tools not found; cl_khr_cooperative_matrix tests will not be built")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Asking as a review comment for better threading.

I am interested in this kind of SPIR-V tools integration for general-purpose SPIR-V testing via generated SPIR-V files vs. the current SPIR-V testing using pre-written .spvasm files. Especially for cases where testing iterates over a combination of source and destination types, it's much more maintainable to generate each test case on-the-fly rather than commit tens (or more) different files.

My questions are specifically:

  1. Are we happy with this general approach? Are we OK adding a built dependency on SPIR-V tools for general-purpose SPIR-V testing? Do we want to support building SPIR-V testing (specifically, test_spirv_new) without support for SPIR-V tools, or are we OK requiring SPIR-V tools for SPIR-V testing?
  2. If so, are we OK separating out the SPIR-V tools integration into a separate PR? Is there anything we would want to change in the process?

Note that (2) is not needed if we can get this PR merged soon, but there hasn't been a lot of activity on it lately, so it will take some concerted effort and/or risk taking to get it merged in the near future.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somewhat related: We might want to revisit #2527 if we proceed with SPIR-V tools integration, especially if we add a build dependency on SPIR-V tools for test_spirv_new but not for the entire CTS. With access to SPIR-V tools, we could generate SPIR-V modules for the SPIR-V extensions, extended instruction sets, and capabilities returned by SPIR-V queries, but we'd want to do that testing as part of test_spirv_new and not as part of test_api (where the SPIR-V query testing is currently).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to factor the SPIR-V tools integration out into a separate PR. I always felt that's a substantial change warranting a dedicated PR anyway. As part of that, I can migrate an existing spirv_new test as a proof-of-concept, so that folks can test the new dependency in their environments without needing a cooperative matrix implementation.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! If you don't mind factoring out the SPIR-V tools integration into a separate PR, I'll definitely take you up on the offer. I would be interested in using this functionality soon, though, so I don't mind doing this myself if it's going to be some time. Just let me know - thanks!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's an initial attempt: #2782
It might take a few iterations to get it working on CI, so I've created it as a draft for now.

Comment thread test_conformance/extensions/cl_khr_cooperative_matrix/cooperative_matrix.cpp Outdated
Comment thread test_conformance/extensions/cl_khr_cooperative_matrix/cooperative_matrix.cpp Outdated
Comment thread test_conformance/extensions/cl_khr_cooperative_matrix/cooperative_matrix.cpp Outdated
Comment thread test_conformance/extensions/cl_khr_cooperative_matrix/halffp.hpp Outdated
Comment thread test_conformance/extensions/cl_khr_cooperative_matrix/main.cpp Outdated
Comment thread test_conformance/extensions/cl_khr_cooperative_matrix/main.cpp
Comment thread test_conformance/extensions/cl_khr_cooperative_matrix/program.cpp Outdated
Comment thread test_conformance/extensions/cl_khr_cooperative_matrix/program.cpp Outdated
Comment thread test_conformance/extensions/cl_khr_cooperative_matrix/program.cpp Outdated
Comment thread test_conformance/extensions/cl_khr_cooperative_matrix/cooperative_matrix.cpp Outdated
Comment thread test_conformance/extensions/cl_khr_cooperative_matrix/cooperative_matrix.cpp Outdated
@svenvh
svenvh force-pushed the cl_khr_cooperative_matrix branch 3 times, most recently from 22e4b71 to ce9d341 Compare September 16, 2026 12:29
Comment thread test_conformance/extensions/cl_khr_cooperative_matrix/program.cpp Outdated
Comment thread test_conformance/extensions/cl_khr_cooperative_matrix/cooperative_matrix.cpp Outdated
Comment thread test_conformance/extensions/cl_khr_cooperative_matrix/cooperative_matrix.cpp Outdated
Comment thread test_conformance/extensions/cl_khr_cooperative_matrix/program.cpp
Comment thread test_conformance/extensions/cl_khr_cooperative_matrix/program.cpp Outdated
Comment thread test_conformance/extensions/cl_khr_cooperative_matrix/cooperative_matrix.cpp Outdated
Comment thread test_conformance/extensions/cl_khr_cooperative_matrix/program.cpp Outdated
Comment thread test_conformance/extensions/cl_khr_cooperative_matrix/cooperative_matrix.hpp Outdated
Comment thread test_conformance/extensions/cl_khr_cooperative_matrix/cooperative_matrix.cpp Outdated
Comment thread test_conformance/extensions/cl_khr_cooperative_matrix/program.cpp
@svenvh
svenvh force-pushed the cl_khr_cooperative_matrix branch from 315c60b to 6750280 Compare September 29, 2026 16:13

@rjodinchr rjodinchr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates! I found a few remaining issues, notably an out-of-bounds Workgroup array size (and missing alignment decoration) in copy_workgroup, signed 64-bit integer overflow UB in the mul bounds calculation and Matrix::fill, and a leftover typo in opencl_conformance_tests_full.csv.

Comment thread test_conformance/opencl_conformance_tests_full.csv Outdated
Comment thread test_conformance/extensions/cl_khr_cooperative_matrix/program.cpp Outdated
Comment thread test_conformance/extensions/cl_khr_cooperative_matrix/cooperative_matrix.cpp Outdated
Comment thread test_conformance/extensions/cl_khr_cooperative_matrix/cooperative_matrix.cpp Outdated
Comment thread test_conformance/extensions/cl_khr_cooperative_matrix/program.cpp Outdated
svenvh and others added 4 commits September 30, 2026 11:26
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>
@svenvh
svenvh force-pushed the cl_khr_cooperative_matrix branch from 6750280 to 7d462b2 Compare September 30, 2026 14:00
rjodinchr
rjodinchr previously approved these changes Sep 30, 2026
Comment thread test_conformance/extensions/cl_khr_cooperative_matrix/main.cpp Outdated
Comment thread test_conformance/extensions/cl_khr_cooperative_matrix/cooperative_matrix.cpp Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants