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

Function restore_thread_affinity

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

Source from the content-addressed store, hash-verified

754}
755
756void restore_thread_affinity(const ThreadAffinity& previous) {
757 if (!previous.valid) return;
758#if defined(_WIN32)
759 // Clearing an originally empty selection restores process-default/all-group eligibility without
760 // turning the caller's implicit Windows 11 affinity into an explicit single-group hard mask.
761 if (!SetThreadSelectedCpuSets(GetCurrentThread(), previous.cpu_sets.empty() ? nullptr : previous.cpu_sets.data(),
762 (ULONG) previous.cpu_sets.size()))
763 std::fprintf(stderr, "strata cpu pool: host CPU Set restoration failed: %lu\n",
764 (unsigned long) GetLastError());
765#else
766 const int error = detail::set_thread_affinity(previous.mask);
767 if (error != 0)
768 std::fprintf(stderr, "strata cpu pool: host affinity restoration failed: %d\n", error);
769#endif
770}
771
772namespace {
773std::atomic<const ExpertPool*> g_diag_pool{nullptr};

Callers 10

round_trip_full_maskFunction · 0.70
round_trip_sparse_nestedFunction · 0.70
round_trip_high_cpuFunction · 0.70
negative_cpu_is_noopFunction · 0.70
host_round_tripsFunction · 0.70
inherited_defaultFunction · 0.70
mainFunction · 0.70
freeMethod · 0.50
freeMethod · 0.50

Calls 4

set_thread_affinityFunction · 0.70
emptyMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by 8

round_trip_full_maskFunction · 0.56
round_trip_sparse_nestedFunction · 0.56
round_trip_high_cpuFunction · 0.56
negative_cpu_is_noopFunction · 0.56
host_round_tripsFunction · 0.56
inherited_defaultFunction · 0.56
mainFunction · 0.56