Skip to main content

ClikaRT::threading

namespace

Classes​

NameDescription
ThreadPoolA handle to ClikaRT's thread pool. Get the process-wide pool with get_thread_pool(). The default ctor is hidden; handles only come from the factory. Copyable and cheap (shares the underlying pool).

Functions​

get_thread_pool()​

ThreadPool get_thread_pool()

The process-wide thread pool that ClikaRT's compute runs on. Declared before the class so the in-class friend declaration is a redeclaration of an already-exported function (a friend cannot carry the export marker, and adding it only on a later declaration is ill-formed on PE).

Declared in ClikaRT/threading/threading.h, line 31

parallel_for()​

void parallel_for(
    std::int64_t begin,
    std::int64_t end,
    std::int64_t grain,
    std::function<void(std::int64_t begin, std::int64_t end)> body
)

Declared in ClikaRT/threading/threading.h, line 87

schedule()​

void schedule(std::function<void()> work)

Fire-and-forget work on the process-wide pool (convenience for get_thread_pool().schedule(work)). Same containment contract as ThreadPool::schedule.

Declared in ClikaRT/threading/threading.h, line 107

num_threads()​

unsigned num_threads()

The process-wide pool's PARTICIPANT count: the calling thread plus the pool's workers, which is the number of cores a parallel operator keeps busy. Configure it with the CLIKA_RT_NUM_THREADS environment variable (read when the pool is first created); it defaults to the host's physical-core count (its Performance-core count on a hybrid SoC).

Declared in ClikaRT/threading/threading.h, line 126

set_spinning_allowed()​

void set_spinning_allowed(bool allowed)

Whether the runtime's idle threads keep spinning for a while before they sleep (on by default). A serving loop's gaps between operations are short, and a sleeping thread's wake costs tens of microseconds on a server and up to a millisecond or more on a phone, so spinning keeps a generation's steps at their pace, the way ONNX Runtime's session.intra_op.allow_spinning and Intel OpenMP's KMP_BLOCKTIME do. Turn it off when this process shares its cores with other work or must idle quietly on battery; the change holds at once, in every build, for the whole process. CLIKA_RT_DISABLE_SPINNING=1 in the environment is the same switch set before the process starts.

Declared in ClikaRT/threading/threading.h, line 137

spinning_allowed()​

bool spinning_allowed()

Whether idle threads spin before they sleep (see set_spinning_allowed).

Declared in ClikaRT/threading/threading.h, line 139

num_physical_cores()​

unsigned num_physical_cores()

Number of physical CPU cores on the host.

Declared in ClikaRT/threading/threading.h, line 142

num_logical_cores()​

unsigned num_logical_cores()

Number of logical CPU cores on the host (physical cores × SMT siblings).

Declared in ClikaRT/threading/threading.h, line 145