skip to content
==> include/mesh/ptx_float_rules.h <==
1/* @ajax/mesh-ptx-float-rules: the cluster float mode's rules on PTX text: refuses a program
2 * whose float instructions are not correctly rounded, unfused and exact, or
3 * whose f32 instructions lack .ftz where they have it, so CUDA and Metal
4 * members of a cluster compute the same bits.
5 *
6 *   add sub mul div rcp sqrt   .rn, and .ftz on f32 (f64: .rn; PTX has no f64 ftz)
7 *   abs neg min max setp set slct   .ftz on f32
8 *   cvt   .ftz when the source is f32, or f64 -> f32
9 *   selp copysign testp mov ld ldu st   no rounding, no flush: allowed as they are
10 * Refused outright: .approx, div.full, fma / mad, f16 / bf16 / tf32 / fp8
11 * arithmetic, and any other float instruction (no rule for it here).
12 * Ported line for line from alpha-rust-mesh scripts/ptx-float-check.sh (awk). */
13#ifndef MESH_PTX_FLOAT_RULES_H
14#define MESH_PTX_FLOAT_RULES_H
15
16#include <stddef.h>
17#include <stdio.h>
18
19/* Why one line breaks the rules, or NULL when it is fine (or not a float
20 * instruction). The reasons are the script's words. */
21const char *mesh_ptx_float_line(const char *line, size_t len);
22
23/* Checks a whole PTX text (path names it in messages). Prints up to 5
24 * "path:line: why: the line" problems to out (as the script) and returns how
25 * many it found (it stops counting at 5). */
26int mesh_ptx_float_check(const char *path, const char *text, size_t len, FILE *out);
27
28#endif