14#ifndef LLVM_SUPPORT_THREADING_H
15#define LLVM_SUPPORT_THREADING_H
19#include "llvm/Config/llvm-config.h"
27#define LLVM_THREADING_USE_STD_CALL_ONCE 1
28#elif defined(LLVM_ON_UNIX) && \
29 (defined(_LIBCPP_VERSION) || \
30 !(defined(__NetBSD__) || defined(__OpenBSD__) || defined(__powerpc__)))
34#define LLVM_THREADING_USE_STD_CALL_ONCE 1
35#elif defined(LLVM_ON_UNIX) && \
36 (defined(__powerpc__) && defined(__LITTLE_ENDIAN__))
37#define LLVM_THREADING_USE_STD_CALL_ONCE 1
39#define LLVM_THREADING_USE_STD_CALL_ONCE 0
42#if LLVM_THREADING_USE_STD_CALL_ONCE
55#if LLVM_THREADING_USE_STD_CALL_ONCE
57 typedef std::once_flag once_flag;
86 template <
typename Function,
typename... Args>
88#if LLVM_THREADING_USE_STD_CALL_ONCE
89 std::call_once(flag, std::forward<Function>(
F),
90 std::forward<Args>(ArgList)...);
96 std::forward<Function>(
F)(std::forward<Args>(ArgList)...);
106 while (tmp !=
Done) {
152 std::optional<ThreadPoolStrategy>
161 inline ThreadPoolStrategy
174 std::optional<ThreadPoolStrategy> S =
196 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