| 1321 | } |
| 1322 | |
| 1323 | void ExpertPool::wait_done(int n) { |
| 1324 | hstate_.store(kWaitDone, std::memory_order_relaxed); |
| 1325 | hstate_ms_.store(now_ms(), std::memory_order_relaxed); |
| 1326 | uint32_t spins = 0, seen = 0; |
| 1327 | std::chrono::steady_clock::time_point t0{}; |
| 1328 | for (;;) { |
| 1329 | uint32_t d = 0; |
| 1330 | if (numa_phase()) // the slices' counts, each bounded by its tasks: the sum is n only when every slice is done |
| 1331 | for (int k = 0; k < numa_n_; ++k) d += nsync_[(size_t) k].done.load(std::memory_order_acquire); |
| 1332 | else |
| 1333 | d = done_.load(std::memory_order_acquire); |
| 1334 | if (d >= (uint32_t) n) return; // `>=`: never a wait that an overshoot outlives |
| 1335 | strata_cpu_pause(); |
| 1336 | if ((++spins & 1023u) != 0) continue; |
| 1337 | const auto now = std::chrono::steady_clock::now(); |
| 1338 | if (spins == 1024u || d != seen) { t0 = now; seen = d; } // progress restarts the clock |
| 1339 | else if (now - t0 > kStall) { |
| 1340 | std::fprintf(stderr, "strata: the CPU expert pool stalled: %u of %d jobs done, %u of %d workers parked%s - " |
| 1341 | "stopping the engine so the server can start it again (issue #29)\n", |
| 1342 | d, n, parked_count(), n_, numa_counters().c_str()); |
| 1343 | dump_thread_stacks(threads_); |
| 1344 | diag(stderr); // as above |
| 1345 | strata::core::release_gpu_waits(stderr); // #267 |
| 1346 | std::fflush(stderr); |
| 1347 | std::abort(); |
| 1348 | } |
| 1349 | } |
| 1350 | } |
| 1351 | |
| 1352 | void ExpertPool::native_rows(int e, int r0, int r1) { |
| 1353 | // the native row phases' work for expert `e` of the batch, rows [r0, r1) of its gate/up (mode 5) or down (mode 6) |
nothing calls this directly
no test coverage detected