24 #ifndef TVM_RUNTIME_THREADING_BACKEND_H_ 25 #define TVM_RUNTIME_THREADING_BACKEND_H_ 31 #if defined(__linux__) || defined(__ANDROID__) 32 #if defined(__ANDROID__) 34 #define CPU_SETSIZE 1024 35 #define __NCPUBITS (8 * sizeof(uint64_t)) 37 uint64_t __bits[CPU_SETSIZE / __NCPUBITS];
40 #define CPU_SET(cpu, cpusetp) \ 41 ((cpusetp)->__bits[(cpu) / __NCPUBITS] |= (1UL << ((cpu) % __NCPUBITS))) 42 #define CPU_ZERO(cpusetp) memset((cpusetp), 0, sizeof(cpu_set_t)) 43 #define CPU_ISSET(cpu, cpusetp) \ 44 (1UL << ((cpu) % __NCPUBITS)) == \ 45 ((cpusetp)->__bits[(cpu) / __NCPUBITS] & (1UL << ((cpu) % __NCPUBITS))) 46 #define CPU_EQUAL(left, right) (memcmp(&left, &right, sizeof(cpu_set_t)) == 0) 76 ThreadGroup(
int num_workers, std::function<
void(
int)> worker_callback,
77 bool exclude_worker0 =
false);
107 std::vector<unsigned int> cpus = {});
141 std::vector<unsigned int> cpus);
153 #endif // TVM_RUNTIME_THREADING_BACKEND_H_ A platform-agnostic abstraction for managing a collection of thread pool threads. ...
Definition: threading_backend.h:60
void Join()
Blocks until all non-main threads in the pool finish.
void Yield()
Platform-agnostic no-op.
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
Definition: threading_backend.h:89
Definition: threading_backend.h:91
int Configure(AffinityMode mode, int nthreads, bool exclude_worker0, std::vector< unsigned int > cpus={})
configure the CPU id affinity
ThreadGroup(int num_workers, std::function< void(int)> worker_callback, bool exclude_worker0=false)
Creates a collection of threads which run a provided function.
Definition: threading_backend.h:86
void SetMaxConcurrency(int value)
Setting the maximum number of available cores.
AffinityMode
Definition: threading_backend.h:85
void ResetThreadPool()
Reset the threads in the pool. All current threads are destroyed and new ones are created...
int32_t NumThreads()
Get the number of threads being used by the TVM runtime.
Definition: threading_backend.h:87