interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / evidence / FB1-CUT4B-88f3f59-probe / gpu_session_probe.c

56 lines · 2996 bytes Raw Blame History
1/* gpu_session_probe: FB-1 cut 4b flake investigation (first-call device-open failure).
2 *
3 * One fresh process = one sample: open the shared device through the API's own
4 * path (omega_gpu_ex2_f32 on 128 values is the smallest launch there is), report
5 * the stage that failed (with the driver's own text) or the open time, exit 0/1.
6 *
7 * ./gpu_session_probe [--label L] [--calls N] [--hold-ms M]
8 * --calls N launches after the first (default 1); keeps the device busy for an overlap test
9 * --hold-ms M sleep M ms with the device open before exit (overlap window for a second probe)
10 *
11 * Output (one line, Astra's SNAP shape; every unknown says so):
12 * PROBE label=L pid=P rc=OK|CHIP_FAIL|... stage="..." first_call_ms=F open_ms=O calls_ok=K/N opens=1
13 * Never run outside the heavy queue (tools/probe_gpu_open.sh).
14 */
15#include "omega_gpu_elementwise_api.h"
16#include "omega_gpu_session.h"
17#include <stdio.h>
18#include <stdlib.h>
19#include <string.h>
20#include <time.h>
21#include <unistd.h>
22
23static double now_ms(void) { struct timespec t; clock_gettime(CLOCK_MONOTONIC, &t); return t.tv_sec * 1e3 + t.tv_nsec / 1e6; }
24
25int main(int argc, char **argv) {
26 const char *label = "probe"; int calls = 1, hold_ms = 0;
27 for (int i = 1; i < argc; i++) {
28 if (strcmp(argv[i], "--label") == 0 && i + 1 < argc) label = argv[++i];
29 else if (strcmp(argv[i], "--calls") == 0 && i + 1 < argc) calls = atoi(argv[++i]);
30 else if (strcmp(argv[i], "--hold-ms") == 0 && i + 1 < argc) hold_ms = atoi(argv[++i]);
31 else { fprintf(stderr, "unknown flag %s\n", argv[i]); return 2; }
32 }
33 float x[128], y[128];
34 for (int i = 0; i < 128; i++) { x[i] = (float)i / 16.0f - 4.0f; y[i] = 0.0f; }
35 OmegaGpuEwInfo info; memset(&info, 0, sizeof info);
36 double t0 = now_ms();
37 int rc = omega_gpu_ex2_f32(128, x, y, &info);
38 double first_ms = now_ms() - t0;
39 int ok = 0;
40 if (rc == OMEGA_GPU_EW_OK) {
41 /* negative control on the result itself: 2^0 must be 1 (x[64] = 0) */
42 if (y[64] < 0.999f || y[64] > 1.001f) { rc = OMEGA_GPU_EW_UNWRITTEN; omega_gpu_session_set_error("probe: 2^0 != 1"); }
43 else ok = 1;
44 }
45 int more_ok = 0;
46 for (int i = 1; i < calls && ok; i++) if (omega_gpu_ex2_f32(128, x, y, &info) == OMEGA_GPU_EW_OK) more_ok++;
47 if (hold_ms > 0) usleep((useconds_t)hold_ms * 1000u);
48 const char *stage = omega_gpu_elementwise_last_error();
49 printf("PROBE label=%s pid=%d rc=%s stage=\"%s\" first_call_ms=%.1f chip_us=%.1f calls_ok=%d/%d opens=%u%s\n",
50 label, (int)getpid(), omega_gpu_elementwise_rc_name(rc), stage[0] ? stage : "-", first_ms,
51 info.elapsed_ns / 1e3, ok + more_ok, calls, omega_gpu_session_open_count(),
52 rc == OMEGA_GPU_EW_OK && !stage[0] ? "" : (rc == OMEGA_GPU_EW_OK ? " note=stage_text_from_earlier_failure" : ""));
53 fflush(stdout);
54 omega_gpu_session_close(); /* the explicit close is part of what the next process sees */
55 return ok ? 0 : 1;
56}