okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
9258e4086
main
1// cuda_launch.h - the <<<grid, block, shared, stream>>> launch syntax, as a call. 2// 3// A C++ compiler cannot parse CUDA's launch syntax, and the Metal port replaces every launch with a dispatch anyway (the grid 4// becomes a threadgroup count, the block a threadgroup size). strata_ds4_launch() is that call: the kernel first, then the 5// launch shape, then the kernel's own arguments - every parameter generic, because the shapes vary (dim3, plain ints, sizes, 6// and the stream type), and the point of this header is to make the sources parse, not to type-check the port. 7// 8// Until a kernel has a Metal implementation the call stops the run naming the kernel, so the engine reports the first one it 9// needs and the port proceeds one kernel at a time. 10#pragma once 11 12#include <cstdio> 13#include <cstdlib> 14 15template < typename K ,typename ...A > 16static inline void strata_ds4_launch (K kernel ,A && ...) { 17static_assert (sizeof (K )> 0 ,"kernel" ); 18std ::fprintf (stderr ,"strata metal: a dsv41 kernel launch has no Metal dispatch yet\n" ); 19std ::abort (); 20} 21 22// the call sites sit inside namespaces whose first argument would win argument-dependent lookup: force the global one 23// the call sites carry their own location, so a run names the exact launch that needs a dispatch 24#define strata_ds4_launch (...) ::strata_ds4_launch_at(__FILE__, __LINE__, __VA_ARGS__) 25 26// the macro adds the call site's location, so a run names the exact launch that still needs a Metal dispatch 27template < typename K ,typename ...A > 28static inline void strata_ds4_launch_at (const char * file ,int line ,K ,A && ...) { 29std ::fprintf (stderr ,"strata metal: kernel launch with no Metal dispatch at %s:%d\n" ,file ,line ); 30std ::abort (); 31}