cpu: --pool-tasks N sets the row tasks per batched expert phase

Opt-in (default 0 keeps three tasks per participating thread, so default
output and timing are unchanged). Adds pool_tasks_test, which compares the
split against the default partition bitwise for 0..4096 tasks.

(PR #949)
This commit is contained in:
Unmaple authored and Niko1221 committed 2026-10-07 04:07:51 +02:00
1 parent bc089d5d97
commit 6b1e303f16
6 files changed
+140 -8

No files matched your search

+19 -1
View File
@@ -408,6 +408,7 @@ struct Options {
bool graph_only = false;
bool gpu_only_full = false; ///< R0.3: pre + post + head, the true per-token GPU floor
int pool_workers = 0; ///< R2.2: 0 = "all physical cores minus the host's"; >0 overrides
int pool_tasks = 0; ///< Batched CPU expert tasks per phase; 0 keeps the existing policy
/// #272: the pool's core layout; `all` (the default) is the layout it always had, auto / p-cores are opt-in
strata::kernels::cpu::PoolAffinity pool_affinity = strata::kernels::cpu::PoolAffinity::All;
/// --host-core first|last (STRATA_HOST_CORE): the host thread's core (see HostCore in pool.hpp)
@@ -839,6 +840,8 @@ void usage() {
" except the one the host loop spins on (with --pool-affinity auto or\n"
" p-cores on a hybrid CPU: P-cores minus 1). A sweep is how the pool's\n"
" deviation from `cpu_s2` is attributed.\n"
" --pool-tasks N Batched CPU expert tasks per GU/Down phase (0..4096). Default 0 =\n"
" 3 per participating thread; positive counts are capped by row count.\n"
" --host-core WHERE The host thread's core: first (the default: the first physical core, as always) or\n"
" last (the last physical core, the workers on the others). Windows sends a GPU's\n"
" interrupts to one logical processor, usually the first, and every copy that lands\n"
@@ -1654,6 +1657,16 @@ int main(int argc, char** argv) {
else if (a == "--graph-only") o.graph_only = true;
else if (a == "--gpu-only-full") o.gpu_only_full = true;
else if (a == "--pool-workers") o.pool_workers = std::atoi(next("--pool-workers"));
else if (a == "--pool-tasks") {
const char* v = next("--pool-tasks");
char* end = nullptr;
const long tasks = std::strtol(v, &end, 10);
if (end == v || *end != '\0' || tasks < 0 || tasks > strata::kernels::cpu::ExpertPool::kMaxTasks) {
std::fprintf(stderr, "strata generate: --pool-tasks expects an integer in 0..4096 (0 = automatic)\n");
return 2;
}
o.pool_tasks = (int) tasks;
}
else if (a == "--host-core") {
o.host_core = next("--host-core");
if (o.host_core != "first" && o.host_core != "last") {
@@ -4095,7 +4108,12 @@ int main(int argc, char** argv) {
#endif
srcp = &arena_src;
}
strata::kernels::cpu::ExpertPool pool(o.pool_workers, /*pin=*/true, /*host_works=*/!o.no_host_worker, o.pool_affinity);
strata::kernels::cpu::ExpertPool pool(o.pool_workers, /*pin=*/true, /*host_works=*/!o.no_host_worker,
o.pool_affinity, o.pool_tasks);
std::fprintf(stderr, "strata generate: CPU pool tasks/phase: %d%s, participating threads: %d\n",
o.pool_tasks ? o.pool_tasks : 3 * (pool.workers() + (pool.host_works() ? 1 : 0)),
o.pool_tasks ? " (capped by rows)" : " (automatic)",
pool.workers() + (pool.host_works() ? 1 : 0));
if (pool.is_hybrid() && pool.affinity() != strata::kernels::cpu::PoolAffinity::All) {
const char* aff_str = pool.affinity() == strata::kernels::cpu::PoolAffinity::PCores ? "p-cores" :
pool.affinity() == strata::kernels::cpu::PoolAffinity::All ? "all" : "auto";