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

Method run_phase

engine/src/kernels/cpu/pool.cpp:1545–1576  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1543}
1544
1545void ExpertPool::run_phase(int mode, int n_tasks, bool per_worker) {
1546 const bool dg = diag_pool_on() && (mode == 5 || mode == 6 || mode == 7);
1547 const int64_t dg_a = dg ? now_ns() : 0;
1548 wait_parked("before a phase");
1549 const int64_t dg_b = dg ? now_ns() : 0;
1550 mode_ = mode;
1551 njobs_ = n_tasks;
1552 per_worker_ = per_worker;
1553 if (dg) dg_pub_ns_.store(now_ns(), std::memory_order_relaxed); // before the publish: the workers' wake starts here
1554 const uint32_t e = begin_batch(n_tasks);
1555 if (host_works_ && !per_worker) drain(-1, host_scratch_, e);
1556 wait_done(n_tasks);
1557 const int64_t dg_c = dg ? now_ns() : 0;
1558 wait_parked("after a phase");
1559 if (dg) {
1560 const int64_t dg_d = now_ns();
1561 dg_wp_before_ns_ += dg_b - dg_a;
1562 dg_phase_ns_ += dg_c - dg_pub_ns_.load(std::memory_order_relaxed);
1563 dg_wp_after_ns_ += dg_d - dg_c;
1564 ++dg_phases_;
1565 }
1566 // Each slice's stamp is stored after its last `done` increment, so `wait_done` can return before it lands; the
1567 // thread that stored it has parked again since (it left the park to claim), and that re-park is what the wait
1568 // above acquired. So the stamps are read here, not in `wait_done`.
1569 if (numa_phase())
1570 for (int k = 0; k < numa_n_; ++k) {
1571 const int64_t t = nsync_[(size_t) k].drained_ns.load(std::memory_order_acquire);
1572 if (t != 0) slice_ms_[k] += (double) (t - pub_ns_) / 1e6;
1573 }
1574 hstate_.store(kIdle, std::memory_order_relaxed);
1575 hstate_ms_.store(now_ms(), std::memory_order_relaxed);
1576}
1577
1578void ExpertPool::run_split(ExpertJob* jobs, int n) {
1579 if (n <= 0) return;

Callers

nothing calls this directly

Calls 6

diag_pool_onFunction · 0.85
now_nsFunction · 0.70
now_msFunction · 0.70
drainFunction · 0.50
storeMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected