okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-mac-rel (Mac Metal support) into f-144-rel6a74320ca

main
1.2 KiB32 linesraw
1// metal/tests/coop_layout.cpp - which (index 0, index 1) elements of a single-simdgroup matmul2d's right input, left
2// input and destination cooperative tensors each lane holds (mm_bench.metal coop_layout).
3//   coop_layout [TM_TN_TK]
4#include "mtl_rt.h"
5
6#include <cstdio>
7#include <string>
8
9int main(int argc, char** argv) {
10    const std::string cfg = argc > 1 ? argv[1] : "16_32_16";
11    mtl::Context cx;
12    const int lib = cx.compile({"mm_bench.metal"}, "#define NO_GGML_COMMON 1\n");
13    mtl::Pipeline p = cx.pipeline(lib, "coop_layout_" + cfg);
14    mtl::Buffer out = cx.alloc(4 * 3 * 32 * 128 * 4);
15    mtl::Dispatch d;
16    d.p = &p;
17    d.args = {mtl::Arg::B(out)};
18    d.tg[0] = 32;
19    cx.run({d});
20    const int* o = out.as<int>();
21    const char* nm[3] = {"right", "left", "dest"};
22    for (int w = 0; w < 3; ++w) {
23        std::printf("%s (tile %s):\n", nm[w], cfg.c_str());
24        for (int l = 0; l < 32; ++l) {
25            const int* q = o + (w * 32 + l) * 128 * 4;
26            std::printf(" l%-2d cap %d:", l, q[2]);
27            for (int i = 0; i < q[2] && i < 128; ++i) std::printf(" (%d,%d)", q[i * 4], q[i * 4 + 1]);
28            std::printf("\n");
29        }
30    }
31    return 0;
32}