[clang] [lldb] [llvm] [OpenCL][Clang] Add support for cooperative matrix extension (PR #221328)

Sven van Haastregt via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 22 08:52:51 PDT 2026


================
@@ -0,0 +1,65 @@
+// CooperativeMatrixType AST node and type infrastructure tests
+//
+// RUN: %clang_cc1 -triple spirv64-unknown-unknown \
+// RUN:   -cl-std=CL2.0 -cl-ext=+cl_khr_cooperative_matrix \
+// RUN:   -finclude-default-header -ast-dump %s \
+// RUN:   | FileCheck %s --check-prefix=AST
+//
+// RUN: %clang_cc1 -triple spirv64-unknown-unknown \
+// RUN:   -cl-std=CL2.0 -cl-ext=+cl_khr_cooperative_matrix \
+// RUN:   -finclude-default-header -O0 -emit-pch -o %t.pch %s
+// RUN: echo "MatA_float16x16 g;" > %t.aux.cl
+
+#define SCOPE  memory_scope_sub_group
+#define USE_A  CLK_COOPERATIVE_MATRIX_A
+#define USE_B  CLK_COOPERATIVE_MATRIX_B
+#define USE_C  CLK_COOPERATIVE_MATRIX_ACCUMULATOR
+
+#pragma OPENCL EXTENSION cl_khr_cooperative_matrix : enable
+
+// Basic type construction — four use roles, float element type.
+typedef float __attribute__((coop_mat(SCOPE, 16, 16, USE_A)))  MatA_float16x16;
+typedef float __attribute__((coop_mat(SCOPE, 16, 16, USE_B)))  MatB_float16x16;
+typedef float __attribute__((coop_mat(SCOPE, 16, 16, USE_C)))  MatC_float16x16;
+typedef int   __attribute__((coop_mat(SCOPE,  8,  8, USE_A)))  MatA_int8x8;
+
----------------
svenvh wrote:

Maybe drop the newline here, so it's clear this relates to the code above.

Same for the rest of this file.

https://github.com/llvm/llvm-project/pull/221328


More information about the cfe-commits mailing list