okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
6a74320ca
main
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 ) { 10const std::string cfg = argc > 1 ?argv [1 ] :"16_32_16" ; 11 mtl::Context cx ; 12const 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 ; 16d .p = & p ; 17d .args = {mtl::Arg ::B (out )}; 18d .tg [0 ]= 32 ; 19cx .run ({d }); 20const int * o = out .as < int > (); 21const char * nm [3 ]= {"right" ,"left" ,"dest" }; 22for (int w = 0 ;w < 3 ;++ w ) { 23 std::printf ("%s (tile %s):\n" ,nm [w ],cfg .c_str ()); 24for (int l = 0 ;l < 32 ;++ l ) { 25const int * q = o + (w * 32 + l )* 128 * 4 ; 26 std::printf (" l%-2d cap %d:" ,l ,q [2 ]); 27for (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 } 31return 0 ; 32}