core 1.5.0
Shared MPI block decomposition, asynchronous ghost-layer exchange, SDF geometry, load balancing (header-only C++20)
Loading...
Searching...
No Matches
cpu_budget.hpp File Reference
#include <algorithm>
#include <cstdlib>
#include <fstream>
#include <sstream>
#include <string>

Go to the source code of this file.

Namespaces

namespace  peclet
 
namespace  peclet::core
 
namespace  peclet::core::detail
 

Functions

int peclet::core::detail::affinityCpus ()
 CPUs in this process's affinity mask, or 0 if that cannot be determined.
 
std::string peclet::core::detail::readFirstLine (const std::string &path)
 First whitespace-separated fields of a file, or an empty string if it cannot be read.
 
std::string peclet::core::detail::cgroupPath (const std::string &procSelfCgroup, const std::string &controller)
 The cgroup path of this process for controller ("" = the v2 unified hierarchy), e.g.
 
int peclet::core::detail::quotaFromCpuMax (const std::string &file)
 CPUs allowed by one cgroup-v2 cpu.max file ("max 100000" or "200000 100000"), rounded UP so a fractional budget still gets one thread.
 
int peclet::core::detail::quotaFromCfs (const std::string &dir)
 The same for cgroup v1's pair of files in dir. 0 = no limit here.
 
int peclet::core::detail::cgroupQuota (const std::string &cgroupRoot, const std::string &procSelfCgroup)
 The tightest CPU quota binding this process, walking from its own cgroup up to the root.
 
int peclet::core::usableCpus ()
 How many CPUs this process may actually use: the affinity count, lowered by any cgroup quota binding it.
 
int peclet::core::defaultHostThreads (bool hostBackendSizesItself)
 The host thread count to hand a backend that has not been told one, or 0 for "say nothing".