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
GitHub aien-dev/omega-mv#234 (code only)
Apply it
git checkout -b patch-f91c23c7beae73be 62804c30094b43f107b5809ce500b50bbaa6ff78 curl -fsSL https://interplane.io/drakestapleton/omega-mv/patches/f91c23c7beae73be.patch | git am
Provenance
github-import 1
aien-dev/omega-mv
234
ef07c91f763096aedf853bfaea7186577ce0099b
{"kind":"github-import","owner":"aien-dev","repo":"omega-mv","number":234,"url":"https://github.com/aien-dev/omega-mv/pull/234","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:54Z","metadata":"unavailable","state_derived":true}
Changes
diff --git a/src/omega_accelerator_world.c b/src/omega_accelerator_world.c index 2445fd17a..2f2188f50 100644 --- a/src/omega_accelerator_world.c +++ b/src/omega_accelerator_world.c @@ -3,6 +3,7 @@ #include "omega_blackwell_encoder.h" #include "omega_blackwell_codegen.h" #include "omega_blackwell_submit.h" +#include "omega_gpu_wait.h" #include "sha256.h" #include <stdio.h> #include <stdlib.h> @@ -39,6 +40,54 @@ static bool payload_reached(uint32_t payload, uint32_t upto) { return (int32_t)(payload - upto) <= 0; } +/* CHIPWAIT-2: completion memory and waits for the world's completion page. + * The page is GPU-uncached. Each synchronous dispatch (execute and the matmul + * variant) releases its payload at +0 and, after an L2_FLUSH_DIRTY mem-op + * (NVC96F_MEM_OP_A..D = 0x28..0x34, D bits 31:27 OPERATION = 0x10, as in + * omega_numeric_gb10.c), the same payload at +0x10; the host waits for both with + * the wrap-safe sequence wait. The same payload sequence is used so the check is + * "reached or passed", never exact equality. */ +#define WORLD_MARKER2_OFFSET 0x10 + +static volatile uint32_t *world_marker2(const OmegaAcceleratorWorld *world) { + return (volatile uint32_t *)((uint8_t *)world->completion.cpu_marker + WORLD_MARKER2_OFFSET); +} + + +/* Wait until word has reached `payload` (sequence wait). Returns 0 on PASS; + * otherwise prints one tagged line with the report and returns -1. The caller + * keeps its own fault handling. The hard total is *budget_ms; time spent is + * deducted so chained waits share one budget. */ +static int world_wait_seq(const char *site, const char *what, volatile uint32_t *word, + uint32_t payload, uint32_t progress_ms, uint32_t *budget_ms) { + uint32_t total_ms = *budget_ms; + omega_gpu_wait_cfg_t cfg; + memset(&cfg, 0, sizeof(cfg)); + cfg.progress_timeout_ms = progress_ms; + cfg.total_timeout_ms = total_ms; + omega_gpu_wait_report_t r; + if (omega_gpu_wait_sequence(word, payload, &r, &cfg)) { + uint64_t spent_ms = r.elapsed_ns / 1000000ull; + *budget_ms = spent_ms < total_ms ? total_ms - (uint32_t)spent_ms : 1u; + return 0; + } + fprintf(stderr, + "WORLD_WAIT_FAIL site=%s wait=%s kind=%s result=%s expected=%u observed=%u " + "elapsed_ns=%llu progress_count=%llu polls=%llu\n", + site, what, omega_gpu_wait_kind_name(r.wait_kind), omega_gpu_wait_result_name(r.result), + r.expected, r.last_observed, (unsigned long long)r.elapsed_ns, + (unsigned long long)r.progress_count, (unsigned long long)r.polls); + return -1; +} + +/* Synchronous dispatch: marker, then marker2 (progress stall 5000 ms, one hard + * total of 600000 ms shared by both waits). */ +static int world_wait_dispatch(const OmegaAcceleratorWorld *world, const char *site, uint32_t payload) { + uint32_t budget_ms = 600000; + if (world_wait_seq(site, "marker", world->completion.cpu_marker, payload, 5000, &budget_ms) != 0) return -1; + return world_wait_seq(site, "marker2", world_marker2(world), payload, 5000, &budget_ms); +} + static bool buffer_referenced_in_flight(const OmegaAcceleratorWorld *world, uint32_t id) { for (uint32_t i = 0; i < world->in_flight_count; i++) { const OmegaWorldSubmission *s = &world->in_flight[i]; @@ -712,10 +761,14 @@ int omega_world_drain(OmegaAcceleratorWorld *world, if (!world->channel_active) return OMEGA_WORLD_ERR_HARDWARE; if (timeout_ms < 0) return OMEGA_WORLD_ERR_INVALID_ARG; - /* Caller-built pushbuffers carry only the first release, so drain waits on - * marker 1; dispatch_vector/dispatch_matmul build the C3 tail and wait on marker 2. */ - if (m16_native_wait_marker_ge(world->completion.cpu_marker, upto_payload, - (uint64_t)timeout_ms) != 0) { + /* Caller-supplied budget (API contract, gates pass 0..10000 ms): hard total = timeout_ms + * (0 becomes 1 ms because the primitive maps 0 to its 600 s default), stall = total, so the + * caller keeps its full budget as before. + * Waits on the marker only: pushbuffers built by callers (omega_world_gates.c) release + * the marker without a flush or marker2. */ + uint32_t drain_total = timeout_ms ? (uint32_t)timeout_ms : 1u; + if (world_wait_seq(__func__, "marker", world->completion.cpu_marker, upto_payload, + drain_total, &drain_total) != 0) { world->faulted = true; return OMEGA_WORLD_ERR_HARDWARE; } @@ -1004,7 +1057,7 @@ int omega_world_dispatch_vector(OmegaAcceleratorWorld *world, return OMEGA_WORLD_ERR_HARDWARE; } - if (m16_native_wait_marker_ge(world->completion.cpu_marker2, payload, 5000) != 0) { + if (world_wait_dispatch(world, __func__, payload) != 0) { world->faulted = true; omega_world_scratch_reset(world); return OMEGA_WORLD_ERR_HARDWARE; @@ -1240,7 +1293,7 @@ int omega_world_dispatch_matmul(OmegaAcceleratorWorld *world, return OMEGA_WORLD_ERR_HARDWARE; } - if (m16_native_wait_marker_ge(world->completion.cpu_marker2, payload, 5000) != 0) { + if (world_wait_dispatch(world, __func__, payload) != 0) { world->faulted = true; omega_world_scratch_reset(world); return OMEGA_WORLD_ERR_HARDWARE; diff --git a/src/omega_blackwell_submit.c b/src/omega_blackwell_submit.c index 097195615..5ab382629 100644 --- a/src/omega_blackwell_submit.c +++ b/src/omega_blackwell_submit.c @@ -5,6 +5,7 @@ #include "omega_blackwell_engine.h" #include "omega_gpu_engine.h" #include "m16_native.h" +#include "omega_gpu_wait.h" #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -132,6 +133,30 @@ int omega_blackwell_execute_vector(const OmegaVectorSpec *spec, return parity_res; } +/* CHIPWAIT-2: the two direct launchers wait through the shared primitive + * (src/omega_gpu_wait.c): exact-value wait on the marker with marker2 required + * (marker2 lands only after the L2 flush, so the output is in memory), progress + * stall 5000 ms (the old budget), hard total 600000 ms. One tagged line on failure. + * The engine-routed launcher keeps the engine's own timed waits. */ +static int bw_wait_one(const char *site, const char *what, volatile uint32_t *w, uint32_t want, + volatile uint32_t *m2, uint32_t m2want) { + omega_gpu_wait_cfg_t cfg; + memset(&cfg, 0, sizeof(cfg)); + cfg.progress_timeout_ms = 5000; + cfg.total_timeout_ms = 600000; + cfg.marker2 = m2; + cfg.marker2_want = m2want; + omega_gpu_wait_report_t r; + if (omega_gpu_wait_fixed(w, want, &r, &cfg)) return 0; + fprintf(stderr, + "BW_WAIT_FAIL site=%s wait=%s kind=%s result=%s expected=0x%x observed=0x%x " + "marker2_observed=0x%x elapsed_ns=%llu progress_count=%llu polls=%llu\n", + site, what, omega_gpu_wait_kind_name(r.wait_kind), omega_gpu_wait_result_name(r.result), + r.expected, r.last_observed, r.last_marker2, (unsigned long long)r.elapsed_ns, + (unsigned long long)r.progress_count, (unsigned long long)r.polls); + return -1; +} + int omega_blackwell_execute_matmul(const OmegaMatMulSpec *spec, const OmegaBlackwellKernel *kernel, const uint32_t *h_a, @@ -339,9 +364,8 @@ int omega_blackwell_execute_matmul(const OmegaMatMulSpec *spec, if (m16_native_submit_methods(&ctx, pb, pb_len) != 0) { m16_native_close(&ctx); return -1; } /* Wait for hardware completion marker */ - if (m16_native_wait_marker(hmarker, OMEGA_BW_MARKER_COMPLETION_PAYLOAD, 5000) != 0) { m16_native_close(&ctx); return -1; } - /* C3: the second release lands only after the L2 flush, so the output is in memory. */ - if (m16_native_wait_marker(hmarker2, OMEGA_BW_MARKER2_PAYLOAD, 5000) != 0) { m16_native_close(&ctx); return -1; } + /* CHIPWAIT-2: marker with marker2 required (C3: the second release lands only after the L2 flush). */ + if (bw_wait_one(__func__, "marker", hmarker, OMEGA_BW_MARKER_COMPLETION_PAYLOAD, hmarker2, OMEGA_BW_MARKER2_PAYLOAD) != 0) { m16_native_close(&ctx); return -1; } __asm__ volatile("dsb sy" ::: "memory"); uint64_t t_end = current_time_ns(); @@ -580,9 +604,8 @@ int omega_blackwell_execute_matmul_tensor(const OmegaMatMulSpec *spec, uint64_t t_start = current_time_ns(); if (m16_native_submit_methods(&ctx, pb, pb_len) != 0) { m16_native_close(&ctx); return -1; } - if (m16_native_wait_marker(hmarker, OMEGA_BW_MARKER_COMPLETION_PAYLOAD, 5000) != 0) { m16_native_close(&ctx); return -1; } - /* C3: the second release lands only after the L2 flush, so the output is in memory. */ - if (m16_native_wait_marker(hmarker2, OMEGA_BW_MARKER2_PAYLOAD, 5000) != 0) { m16_native_close(&ctx); return -1; } + /* CHIPWAIT-2: marker with marker2 required (C3: the second release lands only after the L2 flush). */ + if (bw_wait_one(__func__, "marker", hmarker, OMEGA_BW_MARKER_COMPLETION_PAYLOAD, hmarker2, OMEGA_BW_MARKER2_PAYLOAD) != 0) { m16_native_close(&ctx); return -1; } __asm__ volatile("dsb sy" ::: "memory"); uint64_t t_end = current_time_ns();