cubek-matmul 0.2.0

CubeK: Matrix Multiplication Kernels
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
use std::fmt::Display;

use cubecl::{Runtime, client::ComputeClient, prelude::TensorBinding};
use cubek_std::InputBinding;

use crate::{
    components::{
        global::read::{
            async_full_cyclic, async_full_strided, async_partial_cyclic::AsyncPartialCyclicLoading,
            async_partial_strided::AsyncPartialStridedLoading, sync_full_strided,
            sync_full_tilewise,
        },
        stage::{ColMajorTilingOrder, RowMajorTilingOrder},
        tile::TileMatmulKind,
    },
    definition::{MatmulElems, MatmulSetupError},
    launch::{
        launch_naive, launch_tiling, launch_vecmat_plane_parallel, launch_vecmat_unit_perpendicular,
    },
    routines::{
        BlueprintStrategy, Routine,
        double_buffering::{
            AsyncCyclicDoubleBufferingAlgorithm, AsyncStridedDoubleBufferingAlgorithm,
            CyclicDoubleBufferingAlgorithm, DoubleBufferingArgs, HybridDoubleBufferingAlgorithm,
            TilewiseDoubleBufferingAlgorithm, TmaDoubleBufferingAlgorithm,
        },
        double_unit::DoubleUnitAlgorithm,
        ordered_double_buffering::{OrderedDoubleBufferingAlgorithm, OrderedSelectionArgs},
        simple::{SimpleAlgorithm, SimpleArgs, SimpleTmaAlgorithm},
        simple_unit::SimpleUnitAlgorithm,
        specialized::{SpecializedAlgorithm, SpecializedStrategy},
        vecmat_innerproduct::{DoubleVecMatInnerProductAlgorithm, VecMatInnerProductAlgorithm},
        vecmat_plane_parallel::GemvPlaneParallelRoutine,
        vecmat_unit_perpendicular::GemvUnitPerpendicularRoutine,
    },
};

/// Returns a clone of `sel` with `args.tile_matmul` overridden to `kind` when
/// in Inferred mode. Forced mode is left untouched since the user-supplied
/// blueprint already carries a `tile_matmul`.
fn stamp_kind<RC, A>(
    sel: &BlueprintStrategy<RC, A>,
    kind: TileMatmulKind,
    set: impl FnOnce(&mut A::Strategy, TileMatmulKind),
) -> BlueprintStrategy<RC, A>
where
    RC: crate::launch::RuntimeConfig,
    A: Routine<RC>,
{
    let mut sel = sel.clone();
    if let BlueprintStrategy::Inferred(args) = &mut sel {
        set(args, kind);
    }
    sel
}

fn set_simple(args: &mut SimpleArgs, kind: TileMatmulKind) {
    args.tile_matmul = kind;
}
fn set_double(args: &mut DoubleBufferingArgs, kind: TileMatmulKind) {
    args.tile_matmul = kind;
}
fn set_ordered(args: &mut OrderedSelectionArgs, kind: TileMatmulKind) {
    args.tile_matmul = kind;
}
fn set_specialized(args: &mut SpecializedStrategy, kind: TileMatmulKind) {
    args.tile_matmul = kind;
}

#[allow(clippy::type_complexity)]
#[derive(Clone, Default)]
pub enum Strategy {
    SimpleCyclicCmma(BlueprintStrategy<(), SimpleAlgorithm>),
    SimpleCyclicMma(BlueprintStrategy<(), SimpleAlgorithm>),
    SimpleStridedCmma(
        BlueprintStrategy<
            (),
            SimpleAlgorithm<
                sync_full_strided::SyncFullStridedLoading,
                sync_full_strided::SyncFullStridedLoading,
            >,
        >,
    ),
    SimpleStridedMma(
        BlueprintStrategy<
            (),
            SimpleAlgorithm<
                sync_full_strided::SyncFullStridedLoading,
                sync_full_strided::SyncFullStridedLoading,
            >,
        >,
    ),
    SimpleTilewiseCmma(
        BlueprintStrategy<
            (),
            SimpleAlgorithm<
                sync_full_tilewise::SyncFullTilewiseLoading<ColMajorTilingOrder>,
                sync_full_tilewise::SyncFullTilewiseLoading<RowMajorTilingOrder>,
            >,
        >,
    ),
    SimpleTilewiseMma(
        BlueprintStrategy<
            (),
            SimpleAlgorithm<
                sync_full_tilewise::SyncFullTilewiseLoading<ColMajorTilingOrder>,
                sync_full_tilewise::SyncFullTilewiseLoading<RowMajorTilingOrder>,
            >,
        >,
    ),
    SimpleAsyncStridedCmma(
        BlueprintStrategy<
            (),
            SimpleAlgorithm<
                async_full_strided::AsyncFullStridedLoading,
                async_full_strided::AsyncFullStridedLoading,
                async_full_strided::AsyncFullStridedLoading,
            >,
        >,
    ),
    SimpleAsyncStridedMma(
        BlueprintStrategy<
            (),
            SimpleAlgorithm<
                async_full_strided::AsyncFullStridedLoading,
                async_full_strided::AsyncFullStridedLoading,
                async_full_strided::AsyncFullStridedLoading,
            >,
        >,
    ),
    SimpleAsyncCyclicCmma(
        BlueprintStrategy<
            (),
            SimpleAlgorithm<
                async_full_cyclic::AsyncFullCyclicLoading<ColMajorTilingOrder>,
                async_full_cyclic::AsyncFullCyclicLoading<RowMajorTilingOrder>,
                async_full_cyclic::AsyncFullCyclicLoading<RowMajorTilingOrder>,
            >,
        >,
    ),
    SimpleAsyncCyclicMma(
        BlueprintStrategy<
            (),
            SimpleAlgorithm<
                async_full_cyclic::AsyncFullCyclicLoading<ColMajorTilingOrder>,
                async_full_cyclic::AsyncFullCyclicLoading<RowMajorTilingOrder>,
                async_full_cyclic::AsyncFullCyclicLoading<RowMajorTilingOrder>,
            >,
        >,
    ),
    SimpleTmaCmma(BlueprintStrategy<(), SimpleTmaAlgorithm>),
    SimpleTmaMma(BlueprintStrategy<(), SimpleTmaAlgorithm>),
    DoubleCyclicCmma(BlueprintStrategy<(), CyclicDoubleBufferingAlgorithm>),
    DoubleCyclicMma(BlueprintStrategy<(), CyclicDoubleBufferingAlgorithm>),
    DoubleTilewiseCmma(BlueprintStrategy<(), TilewiseDoubleBufferingAlgorithm>),
    DoubleTilewiseMma(BlueprintStrategy<(), TilewiseDoubleBufferingAlgorithm>),
    DoubleHybridCmma(BlueprintStrategy<(), HybridDoubleBufferingAlgorithm>),
    DoubleHybridMma(BlueprintStrategy<(), HybridDoubleBufferingAlgorithm>),
    DoubleAsyncCyclicCmma(BlueprintStrategy<(), AsyncCyclicDoubleBufferingAlgorithm>),
    DoubleAsyncCyclicMma(BlueprintStrategy<(), AsyncCyclicDoubleBufferingAlgorithm>),
    DoubleAsyncStridedCmma(BlueprintStrategy<(), AsyncStridedDoubleBufferingAlgorithm>),
    DoubleAsyncStridedMma(BlueprintStrategy<(), AsyncStridedDoubleBufferingAlgorithm>),
    DoubleTmaCmma(BlueprintStrategy<(), TmaDoubleBufferingAlgorithm>),
    DoubleTmaMma(BlueprintStrategy<(), TmaDoubleBufferingAlgorithm>),
    SpecializedCyclicCmma(
        BlueprintStrategy<(), SpecializedAlgorithm<AsyncPartialCyclicLoading<ColMajorTilingOrder>>>,
    ),
    SpecializedCyclicMma(
        BlueprintStrategy<(), SpecializedAlgorithm<AsyncPartialCyclicLoading<ColMajorTilingOrder>>>,
    ),
    SpecializedStridedCmma(BlueprintStrategy<(), SpecializedAlgorithm<AsyncPartialStridedLoading>>),
    SpecializedStridedMma(BlueprintStrategy<(), SpecializedAlgorithm<AsyncPartialStridedLoading>>),
    SpecializedTmaCmma(BlueprintStrategy<(), SpecializedAlgorithm>),
    SpecializedTmaMma(BlueprintStrategy<(), SpecializedAlgorithm>),
    OrderedDoubleCmma(BlueprintStrategy<(), OrderedDoubleBufferingAlgorithm>),
    OrderedDoubleMma(BlueprintStrategy<(), OrderedDoubleBufferingAlgorithm>),
    SimpleUnit(BlueprintStrategy<(), SimpleUnitAlgorithm>),
    DoubleUnit(BlueprintStrategy<(), DoubleUnitAlgorithm>),
    SimpleVecMat(BlueprintStrategy<(), VecMatInnerProductAlgorithm>),
    DoubleVecMat(BlueprintStrategy<(), DoubleVecMatInnerProductAlgorithm>),
    GemvUnitPerpendicular(BlueprintStrategy<(), GemvUnitPerpendicularRoutine>),
    GemvPlaneParallel(BlueprintStrategy<(), GemvPlaneParallelRoutine>),
    Naive,
    #[default]
    Auto,
}

impl Display for Strategy {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Strategy::SimpleCyclicCmma(s) => write!(f, "matmul_simple_cyclic_cmma{}", s),
            Strategy::SimpleCyclicMma(s) => write!(f, "matmul_simple_cyclic_mma{}", s),
            Strategy::SimpleStridedCmma(s) => write!(f, "matmul_simple_strided_cmma{}", s),
            Strategy::SimpleStridedMma(s) => write!(f, "matmul_simple_strided_mma{}", s),
            Strategy::SimpleTilewiseCmma(s) => write!(f, "matmul_simple_tilewise_cmma{}", s),
            Strategy::SimpleTilewiseMma(s) => write!(f, "matmul_simple_tilewise_mma{}", s),
            Strategy::SimpleAsyncStridedCmma(s) => {
                write!(f, "matmul_simple_async_strided_cmma{}", s)
            }
            Strategy::SimpleAsyncStridedMma(s) => write!(f, "matmul_simple_async_strided_mma{}", s),
            Strategy::SimpleAsyncCyclicCmma(s) => write!(f, "matmul_simple_async_cyclic_cmma{}", s),
            Strategy::SimpleAsyncCyclicMma(s) => write!(f, "matmul_simple_async_cyclic_mma{}", s),
            Strategy::SimpleTmaCmma(s) => write!(f, "matmul_simple_tma_cmma{}", s),
            Strategy::SimpleTmaMma(s) => write!(f, "matmul_simple_tma_mma{}", s),
            Strategy::DoubleCyclicCmma(s) => write!(f, "matmul_double_cyclic_cmma{}", s),
            Strategy::DoubleCyclicMma(s) => write!(f, "matmul_double_cyclic_mma{}", s),
            Strategy::DoubleTilewiseCmma(s) => write!(f, "matmul_double_tilewise_cmma{}", s),
            Strategy::DoubleTilewiseMma(s) => write!(f, "matmul_double_tilewise_mma{}", s),
            Strategy::DoubleHybridCmma(s) => write!(f, "matmul_double_hybrid_cmma{}", s),
            Strategy::DoubleHybridMma(s) => write!(f, "matmul_double_hybrid_mma{}", s),
            Strategy::DoubleAsyncCyclicCmma(s) => {
                write!(f, "matmul_double_async_cyclic_cmma{}", s)
            }
            Strategy::DoubleAsyncCyclicMma(s) => write!(f, "matmul_double_async_cyclic_mma{}", s),
            Strategy::DoubleAsyncStridedCmma(s) => {
                write!(f, "matmul_double_async_strided_cmma{}", s)
            }
            Strategy::DoubleAsyncStridedMma(s) => write!(f, "matmul_double_async_strided_mma{}", s),
            Strategy::DoubleTmaCmma(s) => write!(f, "matmul_double_tma_cmma{}", s),
            Strategy::DoubleTmaMma(s) => write!(f, "matmul_double_tma_mma{}", s),
            Strategy::SpecializedCyclicCmma(s) => write!(f, "matmul_specialized_cyclic_cmma{}", s),
            Strategy::SpecializedCyclicMma(s) => write!(f, "matmul_specialized_cyclic_mma{}", s),
            Strategy::SpecializedStridedCmma(s) => {
                write!(f, "matmul_specialized_strided_cmma{}", s)
            }
            Strategy::SpecializedStridedMma(s) => write!(f, "matmul_specialized_strided_mma{}", s),
            Strategy::SpecializedTmaCmma(s) => write!(f, "matmul_specialized_tma_cmma{}", s),
            Strategy::SpecializedTmaMma(s) => write!(f, "matmul_specialized_tma_mma{}", s),
            Strategy::OrderedDoubleCmma(s) => write!(f, "matmul_ordered_double_cmma{}", s),
            Strategy::OrderedDoubleMma(s) => write!(f, "matmul_ordered_double_mma{}", s),
            Strategy::SimpleUnit(s) => write!(f, "matmul_simple_unit{}", s),
            Strategy::DoubleUnit(s) => write!(f, "matmul_double_unit{}", s),
            Strategy::SimpleVecMat(s) => write!(f, "matmul_simple_vecmat{}", s),
            Strategy::DoubleVecMat(s) => write!(f, "matmul_double_vecmat{}", s),
            Strategy::Naive => f.write_str("matmul_naive"),
            Strategy::Auto => f.write_str("matmul_auto"),
            Strategy::GemvUnitPerpendicular(s) => write!(f, "vecmat_unit_perpendicular{}", s),
            Strategy::GemvPlaneParallel(s) => write!(f, "vecmat_plane_parallel{}", s),
        }
    }
}

#[allow(clippy::result_large_err)]
impl Strategy {
    pub(crate) fn launch_ref<R: Runtime>(
        &self,
        client: &ComputeClient<R>,
        lhs: InputBinding<R>,
        rhs: InputBinding<R>,
        out: TensorBinding<R>,
        dtypes: &mut MatmulElems,
    ) -> Result<(), MatmulSetupError> {
        use TileMatmulKind::{Cmma, Mma};
        match self {
            Strategy::SimpleCyclicCmma(s) => launch_tiling::launch_ref(
                client,
                lhs,
                rhs,
                out,
                &stamp_kind(s, Cmma, set_simple),
                dtypes,
            ),
            Strategy::SimpleCyclicMma(s) => launch_tiling::launch_ref(
                client,
                lhs,
                rhs,
                out,
                &stamp_kind(s, Mma, set_simple),
                dtypes,
            ),
            Strategy::SimpleStridedCmma(s) => launch_tiling::launch_ref(
                client,
                lhs,
                rhs,
                out,
                &stamp_kind(s, Cmma, set_simple),
                dtypes,
            ),
            Strategy::SimpleStridedMma(s) => launch_tiling::launch_ref(
                client,
                lhs,
                rhs,
                out,
                &stamp_kind(s, Mma, set_simple),
                dtypes,
            ),
            Strategy::SimpleTilewiseCmma(s) => launch_tiling::launch_ref(
                client,
                lhs,
                rhs,
                out,
                &stamp_kind(s, Cmma, set_simple),
                dtypes,
            ),
            Strategy::SimpleTilewiseMma(s) => launch_tiling::launch_ref(
                client,
                lhs,
                rhs,
                out,
                &stamp_kind(s, Mma, set_simple),
                dtypes,
            ),
            Strategy::SimpleAsyncStridedCmma(s) => launch_tiling::launch_ref(
                client,
                lhs,
                rhs,
                out,
                &stamp_kind(s, Cmma, set_simple),
                dtypes,
            ),
            Strategy::SimpleAsyncStridedMma(s) => launch_tiling::launch_ref(
                client,
                lhs,
                rhs,
                out,
                &stamp_kind(s, Mma, set_simple),
                dtypes,
            ),
            Strategy::SimpleAsyncCyclicCmma(s) => launch_tiling::launch_ref(
                client,
                lhs,
                rhs,
                out,
                &stamp_kind(s, Cmma, set_simple),
                dtypes,
            ),
            Strategy::SimpleAsyncCyclicMma(s) => launch_tiling::launch_ref(
                client,
                lhs,
                rhs,
                out,
                &stamp_kind(s, Mma, set_simple),
                dtypes,
            ),
            Strategy::SimpleTmaCmma(s) => launch_tiling::launch_ref_tma(
                client,
                lhs,
                rhs,
                out,
                &stamp_kind(s, Cmma, set_simple),
                dtypes,
            ),
            Strategy::SimpleTmaMma(s) => launch_tiling::launch_ref_tma(
                client,
                lhs,
                rhs,
                out,
                &stamp_kind(s, Mma, set_simple),
                dtypes,
            ),
            Strategy::DoubleCyclicCmma(s) => launch_tiling::launch_ref(
                client,
                lhs,
                rhs,
                out,
                &stamp_kind(s, Cmma, set_double),
                dtypes,
            ),
            Strategy::DoubleCyclicMma(s) => launch_tiling::launch_ref(
                client,
                lhs,
                rhs,
                out,
                &stamp_kind(s, Mma, set_double),
                dtypes,
            ),
            Strategy::DoubleTilewiseCmma(s) => launch_tiling::launch_ref(
                client,
                lhs,
                rhs,
                out,
                &stamp_kind(s, Cmma, set_double),
                dtypes,
            ),
            Strategy::DoubleTilewiseMma(s) => launch_tiling::launch_ref(
                client,
                lhs,
                rhs,
                out,
                &stamp_kind(s, Mma, set_double),
                dtypes,
            ),
            Strategy::DoubleHybridCmma(s) => launch_tiling::launch_ref(
                client,
                lhs,
                rhs,
                out,
                &stamp_kind(s, Cmma, set_double),
                dtypes,
            ),
            Strategy::DoubleHybridMma(s) => launch_tiling::launch_ref(
                client,
                lhs,
                rhs,
                out,
                &stamp_kind(s, Mma, set_double),
                dtypes,
            ),
            Strategy::DoubleAsyncCyclicCmma(s) => launch_tiling::launch_ref(
                client,
                lhs,
                rhs,
                out,
                &stamp_kind(s, Cmma, set_double),
                dtypes,
            ),
            Strategy::DoubleAsyncCyclicMma(s) => launch_tiling::launch_ref(
                client,
                lhs,
                rhs,
                out,
                &stamp_kind(s, Mma, set_double),
                dtypes,
            ),
            Strategy::DoubleAsyncStridedCmma(s) => launch_tiling::launch_ref(
                client,
                lhs,
                rhs,
                out,
                &stamp_kind(s, Cmma, set_double),
                dtypes,
            ),
            Strategy::DoubleAsyncStridedMma(s) => launch_tiling::launch_ref(
                client,
                lhs,
                rhs,
                out,
                &stamp_kind(s, Mma, set_double),
                dtypes,
            ),
            Strategy::DoubleTmaCmma(s) => launch_tiling::launch_ref_tma(
                client,
                lhs,
                rhs,
                out,
                &stamp_kind(s, Cmma, set_double),
                dtypes,
            ),
            Strategy::DoubleTmaMma(s) => launch_tiling::launch_ref_tma(
                client,
                lhs,
                rhs,
                out,
                &stamp_kind(s, Mma, set_double),
                dtypes,
            ),
            Strategy::SpecializedCyclicCmma(s) => launch_tiling::launch_ref(
                client,
                lhs,
                rhs,
                out,
                &stamp_kind(s, Cmma, set_specialized),
                dtypes,
            ),
            Strategy::SpecializedCyclicMma(s) => launch_tiling::launch_ref(
                client,
                lhs,
                rhs,
                out,
                &stamp_kind(s, Mma, set_specialized),
                dtypes,
            ),
            Strategy::SpecializedStridedCmma(s) => launch_tiling::launch_ref(
                client,
                lhs,
                rhs,
                out,
                &stamp_kind(s, Cmma, set_specialized),
                dtypes,
            ),
            Strategy::SpecializedStridedMma(s) => launch_tiling::launch_ref(
                client,
                lhs,
                rhs,
                out,
                &stamp_kind(s, Mma, set_specialized),
                dtypes,
            ),
            Strategy::SpecializedTmaCmma(s) => launch_tiling::launch_ref_tma(
                client,
                lhs,
                rhs,
                out,
                &stamp_kind(s, Cmma, set_specialized),
                dtypes,
            ),
            Strategy::SpecializedTmaMma(s) => launch_tiling::launch_ref_tma(
                client,
                lhs,
                rhs,
                out,
                &stamp_kind(s, Mma, set_specialized),
                dtypes,
            ),
            Strategy::OrderedDoubleCmma(s) => launch_tiling::launch_ref(
                client,
                lhs,
                rhs,
                out,
                &stamp_kind(s, Cmma, set_ordered),
                dtypes,
            ),
            Strategy::OrderedDoubleMma(s) => launch_tiling::launch_ref(
                client,
                lhs,
                rhs,
                out,
                &stamp_kind(s, Mma, set_ordered),
                dtypes,
            ),
            Strategy::SimpleUnit(selection) => {
                launch_tiling::launch_ref(client, lhs, rhs, out, selection, dtypes)
            }
            Strategy::DoubleUnit(selection) => {
                launch_tiling::launch_ref(client, lhs, rhs, out, selection, dtypes)
            }
            Strategy::SimpleVecMat(selection) => {
                launch_tiling::launch_ref(client, lhs, rhs, out, selection, dtypes)
            }
            Strategy::DoubleVecMat(selection) => {
                launch_tiling::launch_ref(client, lhs, rhs, out, selection, dtypes)
            }
            Strategy::Naive => launch_naive::launch_ref(client, lhs, rhs, out, dtypes),
            Strategy::Auto => auto(client, lhs, rhs, out, dtypes),
            Strategy::GemvUnitPerpendicular(blueprint_strategy) => {
                launch_vecmat_unit_perpendicular::launch_ref(
                    client,
                    lhs,
                    rhs,
                    out,
                    blueprint_strategy,
                    dtypes,
                )
            }
            Strategy::GemvPlaneParallel(blueprint_strategy) => {
                launch_vecmat_plane_parallel::launch_ref(
                    client,
                    lhs,
                    rhs,
                    out,
                    blueprint_strategy,
                    dtypes,
                )
            }
        }
    }
}

fn auto<R: Runtime>(
    client: &ComputeClient<R>,
    lhs: InputBinding<R>,
    rhs: InputBinding<R>,
    out: TensorBinding<R>,
    dtypes: &mut MatmulElems,
) -> Result<(), MatmulSetupError> {
    if let Err(err) = Strategy::SimpleCyclicCmma(Default::default()).launch_ref(
        client,
        lhs.clone(),
        rhs.clone(),
        out.clone(),
        dtypes,
    ) {
        match err {
            MatmulSetupError::Unavailable(_) => {
                Strategy::SimpleUnit(Default::default())
                    .launch_ref(client, lhs, rhs, out, dtypes)
                    .unwrap();
            }
            _ => panic!("{err:?}"),
        }
    }

    Ok(())
}