LLVM  16.0.0git
Public Member Functions | Public Attributes | List of all members
llvm::ThreadPoolStrategy Class Reference

This tells how a thread pool will be used. More...

#include "llvm/Support/Threading.h"

Collaboration diagram for llvm::ThreadPoolStrategy:
Collaboration graph
[legend]

Public Member Functions

unsigned compute_thread_count () const
 Retrieves the max available threads for the current strategy. More...
 
void apply_thread_strategy (unsigned ThreadPoolNum) const
 Assign the current thread to an ideal hardware CPU or NUMA node. More...
 
Optional< unsigned > compute_cpu_socket (unsigned ThreadPoolNum) const
 Finds the CPU socket where a thread should go. More...
 

Public Attributes

unsigned ThreadsRequested = 0
 
bool UseHyperThreads = true
 
bool Limit = false
 

Detailed Description

This tells how a thread pool will be used.

Definition at line 116 of file Threading.h.

Member Function Documentation

◆ apply_thread_strategy()

void llvm::ThreadPoolStrategy::apply_thread_strategy ( unsigned  ThreadPoolNum) const

Assign the current thread to an ideal hardware CPU or NUMA node.

In a multi-socket system, this ensures threads are assigned to all CPU sockets. ThreadPoolNum represents a number bounded by [0, compute_thread_count()).

◆ compute_cpu_socket()

Optional<unsigned> llvm::ThreadPoolStrategy::compute_cpu_socket ( unsigned  ThreadPoolNum) const

Finds the CPU socket where a thread should go.

Returns 'None' if the thread shall remain on the actual CPU socket.

◆ compute_thread_count()

unsigned llvm::ThreadPoolStrategy::compute_thread_count ( ) const

Retrieves the max available threads for the current strategy.

This accounts for affinity masks and takes advantage of all CPU sockets.

Definition at line 52 of file Threading.cpp.

References computeHostNumHardwareThreads(), llvm::sys::getHostNumPhysicalCores(), Limit, llvm::min(), ThreadsRequested, and UseHyperThreads.

Member Data Documentation

◆ Limit

bool llvm::ThreadPoolStrategy::Limit = false

Definition at line 130 of file Threading.h.

Referenced by compute_thread_count().

◆ ThreadsRequested

unsigned llvm::ThreadPoolStrategy::ThreadsRequested = 0

Definition at line 122 of file Threading.h.

Referenced by compute_thread_count().

◆ UseHyperThreads

bool llvm::ThreadPoolStrategy::UseHyperThreads = true

Definition at line 126 of file Threading.h.

Referenced by compute_thread_count().


The documentation for this class was generated from the following files: