14#ifndef LLVM_SUPPORT_THREADING_H
15#define LLVM_SUPPORT_THREADING_H
19#include "llvm/Config/llvm-config.h"
26#define LLVM_THREADING_USE_STD_CALL_ONCE 1
27#elif defined(LLVM_ON_UNIX) && \
28 (defined(_LIBCPP_VERSION) || \
29 !(defined(__NetBSD__) || defined(__OpenBSD__) || defined(__powerpc__)))
33#define LLVM_THREADING_USE_STD_CALL_ONCE 1
34#elif defined(LLVM_ON_UNIX) && \
35 (defined(__powerpc__) && defined(__LITTLE_ENDIAN__))
36#define LLVM_THREADING_USE_STD_CALL_ONCE 1
38#define LLVM_THREADING_USE_STD_CALL_ONCE 0
41#if LLVM_THREADING_USE_STD_CALL_ONCE
54#if LLVM_THREADING_USE_STD_CALL_ONCE
56 typedef std::once_flag once_flag;
85 template <
typename Function,
typename... Args>
87#if LLVM_THREADING_USE_STD_CALL_ONCE
88 std::call_once(flag, std::forward<Function>(
F),
89 std::forward<Args>(ArgList)...);
95 std::forward<Function>(
F)(std::forward<Args>(ArgList)...);
105 while (tmp !=
Done) {
151 std::optional<ThreadPoolStrategy>
160 inline ThreadPoolStrategy
173 std::optional<ThreadPoolStrategy> S =
195 std::optional<ThreadPoolStrategy> S =
This file implements the BitVector class.
#define TsanHappensBefore(cv)
#define TsanHappensAfter(cv)
#define TsanIgnoreWritesEnd()
#define TsanIgnoreWritesBegin()
static cl::opt< int > ThreadCount("threads", cl::init(0))
StringRef - Represent a constant reference to a string, i.e.
This tells how a thread pool will be used.
std::optional< unsigned > compute_cpu_socket(unsigned ThreadPoolNum) const
Finds the CPU socket where a thread should go.
unsigned ThreadsRequested
void apply_thread_strategy(unsigned ThreadPoolNum) const
Assign the current thread to an ideal hardware CPU or NUMA node.
unsigned compute_thread_count() const
Retrieves the max available threads for the current strategy.
cas_flag CompareAndSwap(volatile cas_flag *ptr, cas_flag new_value, cas_flag old_value)
This is an optimization pass for GlobalISel generic memory operations.
ThreadPoolStrategy hardware_concurrency(unsigned ThreadCount=0)
Returns a default thread strategy where all available hardware resources are to be used,...
ThreadPoolStrategy heavyweight_hardware_concurrency(unsigned ThreadCount=0)
Returns a thread strategy for tasks requiring significant memory or other resources.
@ Low
Lower the current thread's priority such that it does not affect foreground tasks significantly.
@ Background
Lower the current thread's priority as much as possible.
SetThreadPriorityResult set_thread_priority(ThreadPriority Priority)
constexpr bool llvm_is_multithreaded()
Returns true if LLVM is compiled with support for multi-threading, and false otherwise.
llvm::BitVector get_thread_affinity_mask()
Returns a mask that represents on which hardware thread, core, CPU, NUMA group, the calling thread ca...
uint32_t get_max_thread_name_length()
Get the maximum length of a thread name on this platform.
unsigned get_cpus()
Returns how many physical CPUs or NUMA groups the system has.
ThreadPoolStrategy optimal_concurrency(unsigned TaskCount=0)
Returns an optimal thread strategy to execute specified amount of tasks.
void set_thread_name(const Twine &Name)
Set the name of the current thread.
void get_thread_name(SmallVectorImpl< char > &Name)
Get the name of the current thread.
int get_physical_cores()
Returns how many physical cores (as opposed to logical cores returned from thread::hardware_concurren...
std::optional< ThreadPoolStrategy > get_threadpool_strategy(StringRef Num, ThreadPoolStrategy Default={})
Build a strategy from a number of threads as a string provided in Num.
uint64_t get_threadid()
Return the current thread id, as used in various OS system calls.
void call_once(once_flag &flag, Function &&F, Args &&... ArgList)
Execute the function specified as a parameter once.
@ Default
The result values are uniform if and only if all operands are uniform.
The llvm::once_flag structure.
volatile sys::cas_flag status