You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/features/src/cooperative_matrix/README.md
+11-58Lines changed: 11 additions & 58 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,70 +2,26 @@
2
2
3
3
This example demonstrates how to use cooperative matrix operations (also known as tensor cores on NVIDIA GPUs) to perform efficient matrix multiplication on the GPU.
4
4
5
-
## Overview
5
+
For the full description of the cooperative matrix feature (supported configurations, WGSL types and operations, validation rules, and backend support), see the central API spec:
6
6
7
-
Cooperative matrices allow a workgroup to collectively load, store, and perform matrix multiply-accumulate operations on small tiles of data. This enables hardware-accelerated matrix math that can be significantly faster than traditional element-wise approaches.
7
+
-`docs/api-specs/cooperative_matrix.md`
8
8
9
-
The example computes `C = A * B + C` where:
9
+
## Example specifics
10
+
11
+
This example computes `C = A * B + C` where:
10
12
- A is a 64×64 matrix
11
13
- B is a 64×64 matrix
12
14
- C is a 64×64 matrix (accumulator/result)
13
15
14
-
## Querying Supported Configurations
15
-
16
-
Before using cooperative matrices, you should query what configurations your hardware supports:
-`ab_type`: Element type for input matrices A and B (as `naga::Scalar`)
32
-
-`cr_type`: Element type for accumulator matrix C and the result
33
-
-`saturating_accumulation`: Whether overflow clamping is supported
34
-
35
-
## Key Concepts
36
-
37
-
### Cooperative Matrix Types
38
-
39
-
In WGSL, cooperative matrices are declared with a specific size, element type, and role:
40
-
41
-
```wgsl
42
-
coop_mat8x8<f32, A> // Matrix A (left operand)
43
-
coop_mat8x8<f32, B> // Matrix B (right operand)
44
-
coop_mat8x8<f32, C> // Matrix C (accumulator)
45
-
```
46
-
47
-
The role (A, B, or C) determines how the matrix is used in multiply-accumulate operations.
48
-
49
-
### Operations
50
-
51
-
-`coopLoad<T>(pointer, stride)` - Cooperatively load a tile from memory
52
-
-`coopStore(matrix, pointer, stride)` - Cooperatively store a tile to memory
53
-
-`coopMultiplyAdd(a, b, c)` - Compute `a * b + c`
54
-
55
-
### Workgroup Cooperation
56
-
57
-
All threads in a workgroup must participate in cooperative matrix operations together. The workgroup size should match the cooperative matrix dimensions (8×8 in this example).
16
+
The example:
17
+
- Tiles the 64×64 matrices into cooperative matrix tiles (e.g. 8×8) and performs a tiled matmul
18
+
- Uses a compute shader and compares GPU results against a CPU reference implementation
58
19
59
20
## Requirements
60
21
61
-
- GPU with cooperative matrix support:
62
-
- Metal: Apple7+ (A14 chip) or Mac2+ (M1 chip) with MSL 2.3+
0 commit comments