|
tvm
|
A platform-agnostic abstraction for managing a collection of thread pool threads. More...
#include <threading_backend.h>
Public Types | |
| enum | AffinityMode : int { kBig = 1 , kLittle = -1 , kSpecifyOneCorePerThread = -2 , kSpecifyThreadShareAllCore = -3 } |
Public Member Functions | |
| 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.
| 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.
| 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. |
| tvm::runtime::threading::ThreadGroup::~ThreadGroup | ( | ) |
| int tvm::runtime::threading::ThreadGroup::Configure | ( | AffinityMode | mode, |
| int | nthreads, | ||
| bool | exclude_worker0, | ||
| std::vector< unsigned int > | cpus = {} |
||
| ) |
configure the CPU id affinity
| 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'. |
| void tvm::runtime::threading::ThreadGroup::Join | ( | ) |
Blocks until all non-main threads in the pool finish.