okami.mom/strata

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

Niko1221Merge f-0271-macds (DeepSeek on the Mac) into 0.2.7.1: setup.py keeps the Mac sentence and adds the DGX Spark one for Linux ARM649258e4086

main
1.7 KiB31 linesraw
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&&...) {
17    static_assert(sizeof(K) > 0, "kernel");
18    std::fprintf(stderr, "strata metal: a dsv41 kernel launch has no Metal dispatch yet\n");
19    std::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&&...) {
29    std::fprintf(stderr, "strata metal: kernel launch with no Metal dispatch at %s:%d\n", file, line);
30    std::abort();
31}