Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/CUDApp/blob/main/tests/gpu_session_probe.c # CUDApp CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / tests / gpu_session_probe.c` 57 lines · 3058 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ 2 /* gpu_session_probe: FB-1 cut 4b flake investigation (first-call device-open failure). 3 * 4 * One fresh process = one sample: open the shared device through the API's own 5 * path (omega_gpu_ex2_f32 on 128 values is the smallest launch there is), report 6 * the stage that failed (with the driver's own text) or the open time, exit 0/1. 7 * 8 * ./gpu_session_probe [--label L] [--calls N] [--hold-ms M] 9 * --calls N launches after the first (default 1); keeps the device busy for an overlap test 10 * --hold-ms M sleep M ms with the device open before exit (overlap window for a second probe) 11 * 12 * Output (one line, Astra's SNAP shape; every unknown says so): 13 * PROBE label=L pid=P rc=OK|CHIP_FAIL|... stage="..." first_call_ms=F open_ms=O calls_ok=K/N opens=1 14 * Never run outside the heavy queue (tools/probe_gpu_open.sh). 15 */ 16 #include "omega_gpu_elementwise_api.h" 17 #include "omega_gpu_session.h" 18 #include 19 #include 20 #include 21 #include 22 #include 23 24 static double now_ms(void) { struct timespec t; clock_gettime(CLOCK_MONOTONIC, &t); return t.tv_sec * 1e3 + t.tv_nsec / 1e6; } 25 26 int main(int argc, char **argv) { 27 const char *label = "probe"; int calls = 1, hold_ms = 0; 28 for (int i = 1; i < argc; i++) { 29 if (strcmp(argv[i], "--label") == 0 && i + 1 < argc) label = argv[++i]; 30 else if (strcmp(argv[i], "--calls") == 0 && i + 1 < argc) calls = atoi(argv[++i]); 31 else if (strcmp(argv[i], "--hold-ms") == 0 && i + 1 < argc) hold_ms = atoi(argv[++i]); 32 else { fprintf(stderr, "unknown flag %s\n", argv[i]); return 2; } 33 } 34 float x[128], y[128]; 35 for (int i = 0; i < 128; i++) { x[i] = (float)i / 16.0f - 4.0f; y[i] = 0.0f; } 36 OmegaGpuEwInfo info; memset(&info, 0, sizeof info); 37 double t0 = now_ms(); 38 int rc = omega_gpu_ex2_f32(128, x, y, &info); 39 double first_ms = now_ms() - t0; 40 int ok = 0; 41 if (rc == OMEGA_GPU_EW_OK) { 42 /* negative control on the result itself: 2^0 must be 1 (x[64] = 0) */ 43 if (y[64] < 0.999f || y[64] > 1.001f) { rc = OMEGA_GPU_EW_UNWRITTEN; omega_gpu_session_set_error("probe: 2^0 != 1"); } 44 else ok = 1; 45 } 46 int more_ok = 0; 47 for (int i = 1; i < calls && ok; i++) if (omega_gpu_ex2_f32(128, x, y, &info) == OMEGA_GPU_EW_OK) more_ok++; 48 if (hold_ms > 0) usleep((useconds_t)hold_ms * 1000u); 49 const char *stage = omega_gpu_elementwise_last_error(); 50 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", 51 label, (int)getpid(), omega_gpu_elementwise_rc_name(rc), stage[0] ? stage : "-", first_ms, 52 info.elapsed_ns / 1e3, ok + more_ok, calls, omega_gpu_session_open_count(), 53 rc == OMEGA_GPU_EW_OK && !stage[0] ? "" : (rc == OMEGA_GPU_EW_OK ? " note=stage_text_from_earlier_failure" : "")); 54 fflush(stdout); 55 omega_gpu_session_close(); /* the explicit close is part of what the next process sees */ 56 return ok ? 0 : 1; 57 }