MCPcopy Create free account
hub / github.com/Niko1221/Strata / adapt_gate_wait

Method adapt_gate_wait

engine/src/core/verify.cpp:4279–4316  ·  view source on GitHub ↗

0.1.43 (STRATA_ADAPT_OVERLAP): hold the host until the adaptive tier's copies up to `layer` have landed. The wait is a spin on an atomic the copy stream's host functions raise (no driver call here); 20 s is the window's own limit.

Source from the content-addressed store, hash-verified

4277// 0.1.43 (STRATA_ADAPT_OVERLAP): hold the host until the adaptive tier's copies up to `layer` have landed. The wait
4278// is a spin on an atomic the copy stream's host functions raise (no driver call here); 20 s is the window's own limit.
4279bool Verifier::adapt_gate_wait(int32_t layer, std::string& err) {
4280 const Clock::time_point t0 = Clock::now();
4281 uint32_t spins = 0;
4282 // each tier's counter climbs to the last layer it swaps this round, so an all-layers wait asks for that layer
4283 const AdaptGate& ag = *adapt_gate_;
4284 const int32_t want = std::min(layer, ag.last), want_peer = std::min(layer, ag.peer_last);
4285 const bool wait_main = ag.last >= 0 && ((size_t) layer >= ag.has.size() || ag.has[(size_t) layer] != 0);
4286 const bool wait_peer = ag.peer_last >= 0 && ((size_t) layer >= ag.peer_has.size() || ag.peer_has[(size_t) layer] != 0);
4287 bool announced = false; // the watchdog's label is set only once the wait really starts: no cost when the copies landed
4288 while ((wait_main && ag.reached() < want) || (wait_peer && ag.peer_reached() < want_peer)) {
4289 if (!announced) {
4290 progress_at("verify window: waiting for the adaptive tier's copies of layer", layer);
4291 announced = true;
4292 }
4293 strata_cpu_pause();
4294 if ((++spins & 1023u) != 0) continue;
4295 if (Clock::now() - t0 > std::chrono::seconds(20)) {
4296 // the release drains the window's own streams, never the tier's copy stream: say so, and hand out the
4297 // gate's words and this window's GPU breadcrumbs (STRATA_VERIFY_TRACE) - the last landed layer is the
4298 // exact place the stream stopped, which the released window's error line alone never told (#2188's class)
4299 const int32_t reach = adapt_gate_->reached(), land = adapt_gate_->landed.load();
4300 const int32_t hl = adapt_gate_->hland != nullptr ? *adapt_gate_->hland : -2;
4301 if (g_trace) trace_ev("GATE-TIMEOUT", -1, layer, reach);
4302 std::fprintf(stderr, "strata verify: the adaptive gate waited %lld ms for layer %d: reached %d "
4303 "(atomic %d, copy signal %d) - the tier's copy stream was not drained by the release\n",
4304 (long long) ms_since(t0), (int) layer, (int) reach, (int) land, (int) hl);
4305 if (g_trace) trace_dump(stderr);
4306 err = "verify: the adaptive tier's copies for layer " + std::to_string(layer) + " never landed" +
4307 released_note(release_gpu_waits(5000)) +
4308 " (the copy stream itself is not drained: reached " + std::to_string(reach) + " of " +
4309 std::to_string(layer) + ", STRATA_VERIFY_TRACE=1 prints where the stream stopped)";
4310 std::fflush(stderr);
4311 return false;
4312 }
4313 }
4314 ms_gate += ms_since(t0);
4315 return true;
4316}
4317
4318bool Verifier::handoff_failed(std::string& err) const {
4319 if (herr_h_ == nullptr || *(const volatile uint32_t*) herr_h_ == 0) return false;

Callers

nothing calls this directly

Calls 13

progress_atFunction · 0.85
strata_cpu_pauseFunction · 0.85
secondsFunction · 0.85
release_gpu_waitsFunction · 0.85
reachedMethod · 0.80
peer_reachedMethod · 0.80
ms_sinceFunction · 0.70
released_noteFunction · 0.70
nowFunction · 0.50
minFunction · 0.50
to_stringFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected