skip to content
==> src/main.c <==
1/* mesh-ptx-float-check PTX: refuses a program PTX that breaks the cluster
2 * float mode (@ajax/mesh-ptx-float-rules). Exit 0 fine, 1 refused (the
3 * problems on stderr), 2 usage. Ported from alpha-rust-mesh
4 * scripts/ptx-float-check.sh. */
5#include "mesh/ptx_float_rules.h"
6#include "read.h"
7
8#include <stdio.h>
9#include <stdlib.h>
10
11int main(int argc, char **argv) {
12    if (argc != 2) {
13        fprintf(stderr, "usage: %s PTX\n", argc > 0 ? argv[0] : "mesh-ptx-float-check");
14        return 2;
15    }
16    size_t len = 0;
17    char *text = mesh_ptx_read_file(argv[1], &len);
18    if (!text) {
19        fprintf(stderr, "usage: %s PTX\n", argv[0]);
20        return 2;
21    }
22    char *report = NULL;
23    size_t rlen = 0;
24    FILE *mem = open_memstream(&report, &rlen);
25    int bad = mesh_ptx_float_check(argv[1], text, len, mem);
26    fclose(mem);
27    if (bad) {
28        fprintf(stderr, "error: %s: float op outside the cluster float mode (FTZ, correctly rounded, unfused):\n%s", argv[1], report);
29    }
30    free(report);
31    free(text);
32    return bad ? 1 : 0;
33}