A platform-agnostic abstraction for managing a collection of thread pool threads.
More...
#include <threading_backend.h>
|
| ThreadGroup (int num_workers, std::function< void(int)> worker_callback, bool exclude_worker0=false) |
| Creates a collection of threads which run a provided function. More...
|
|
| ~ThreadGroup () |
|
void | Join () |
| Blocks until all non-main threads in the pool finish. More...
|
|
int | Configure (AffinityMode mode, int nthreads, bool exclude_worker0, std::vector< unsigned int > cpus={}) |
| configure the CPU id affinity More...
|
|
A platform-agnostic abstraction for managing a collection of thread pool threads.
◆ AffinityMode
Enumerator |
---|
kBig | |
kLittle | |
kSpecifyOneCorePerThread | |
kSpecifyThreadShareAllCore | |
◆ ThreadGroup()
tvm::runtime::threading::ThreadGroup::ThreadGroup |
( |
int |
num_workers, |
|
|
std::function< void(int)> |
worker_callback, |
|
|
bool |
exclude_worker0 = false |
|
) |
| |
Creates a collection of threads which run a provided function.
- Parameters
-
num_workers | The total number of worker threads in this group. Includes main thread if exclude_worker0 = true |
worker_callback | A callback which is run in its own thread. Receives the worker_id as an argument. |
exclude_worker0 | Whether to use the main thread as a worker. If true , worker0 will not be launched in a new thread and worker_callback will only be called for values >= 1. This allows use of the main thread as a worker. |
◆ ~ThreadGroup()
tvm::runtime::threading::ThreadGroup::~ThreadGroup |
( |
| ) |
|
◆ Configure()
int tvm::runtime::threading::ThreadGroup::Configure |
( |
AffinityMode |
mode, |
|
|
int |
nthreads, |
|
|
bool |
exclude_worker0, |
|
|
std::vector< unsigned int > |
cpus = {} |
|
) |
| |
configure the CPU id affinity
- Parameters
-
mode | The preferred CPU type (1 = big, -1 = little ...). |
nthreads | The number of threads to use (0 = use all). |
exclude_worker0 | Whether to use the main thread as a worker. If true , worker0 will not be launched in a new thread and worker_callback will only be called for values >= 1. This allows use of the main thread as a worker. |
cpus | A list of CPU used to set 'cpu affinity'. |
- Returns
- The number of workers to use.
◆ Join()
void tvm::runtime::threading::ThreadGroup::Join |
( |
| ) |
|
Blocks until all non-main threads in the pool finish.
The documentation for this class was generated from the following file: