LLVM: lib/Support/Threading.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
15#include "llvm/Config/config.h"
16#include "llvm/Config/llvm-config.h"
18
19#include
20#include
21#include <stdlib.h>
22
23using namespace llvm;
24
25
26
27
28
29
30#if LLVM_ENABLE_THREADS == 0 || \
31 (!defined(_WIN32) && !defined(HAVE_PTHREAD_H))
33
35
37
39
41
46
47
49
50#else
51
52static int computeHostNumHardwareThreads();
53
57 return JS->getNumJobs();
58
59 int MaxThreadCount =
61 if (MaxThreadCount <= 0)
62 MaxThreadCount = 1;
64 return MaxThreadCount;
68}
69
70
71#ifdef LLVM_ON_UNIX
73#endif
74#ifdef _WIN32
76#endif
77
78
79
80
82
83#if defined(__APPLE__)
84
85
86
87
88const std::optional llvm::thread::DefaultStackSize = 8 * 1024 * 1024;
89#elif defined(_AIX)
90
91
92
93const std::optional llvm::thread::DefaultStackSize = 4 * 1024 * 1024;
94#else
95const std::optional llvm::thread::DefaultStackSize;
96#endif
97
98
99#endif
100
101std::optional
103 if (Num == "all")
107 unsigned V;
109 return std::nullopt;
110 if (V == 0)
112
113
114
115
118 return S;
119}
static LLVM_ABI_FOR_TEST JobserverClient * getInstance()
Returns the singleton instance of the JobserverClient.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
StringRef - Represent a constant reference to a string, i.e.
bool getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
constexpr bool empty() const
empty - Check if the string is empty.
This tells how a thread pool will be used.
unsigned ThreadsRequested
LLVM_ABI unsigned compute_thread_count() const
Retrieves the max available threads for the current strategy.
Definition Threading.cpp:42
bool UseJobserver
If true, the thread pool will attempt to coordinate with a GNU Make jobserver, acquiring a job slot b...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
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,...
LLVM_ABI llvm::BitVector get_thread_affinity_mask()
Returns a mask that represents on which hardware thread, core, CPU, NUMA group, the calling thread ca...
Definition Threading.cpp:40
LLVM_ABI uint32_t get_max_thread_name_length()
Get the maximum length of a thread name on this platform.
Definition Threading.cpp:34
LLVM_ABI void set_thread_name(const Twine &Name)
Set the name of the current thread.
Definition Threading.cpp:36
LLVM_ABI void get_thread_name(SmallVectorImpl< char > &Name)
Get the name of the current thread.
Definition Threading.cpp:38
LLVM_ABI int get_physical_cores()
Returns how many physical cores (as opposed to logical cores returned from thread::hardware_concurren...
Definition Threading.cpp:48
LLVM_ABI std::optional< ThreadPoolStrategy > get_threadpool_strategy(StringRef Num, ThreadPoolStrategy Default={})
Build a strategy from a number of threads as a string provided in Num.
Definition Threading.cpp:102
LLVM_ABI uint64_t get_threadid()
Return the current thread id, as used in various OS system calls.
Definition Threading.cpp:32
@ Default
The result values are uniform if and only if all operands are uniform.