tvm
Public Types | Public Member Functions | List of all members
tvm::runtime::threading::ThreadGroup Class Reference

A platform-agnostic abstraction for managing a collection of thread pool threads. More...

#include <threading_backend.h>

Collaboration diagram for tvm::runtime::threading::ThreadGroup:

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...
 

Detailed Description

A platform-agnostic abstraction for managing a collection of thread pool threads.

Member Enumeration Documentation

◆ AffinityMode

Enumerator
kBig 
kLittle 
kSpecifyOneCorePerThread 
kSpecifyThreadShareAllCore 
Examples
/workspace/include/tvm/runtime/threading_backend.h.

Constructor & Destructor Documentation

◆ 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_workersThe total number of worker threads in this group. Includes main thread if exclude_worker0 = true
worker_callbackA callback which is run in its own thread. Receives the worker_id as an argument.
exclude_worker0Whether 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.
Examples
/workspace/include/tvm/runtime/threading_backend.h.

◆ ~ThreadGroup()

tvm::runtime::threading::ThreadGroup::~ThreadGroup ( )

Member Function Documentation

◆ 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
modeThe preferred CPU type (1 = big, -1 = little ...).
nthreadsThe number of threads to use (0 = use all).
exclude_worker0Whether 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.
cpusA list of CPU used to set 'cpu affinity'.
Returns
The number of workers to use.
Examples
/workspace/include/tvm/runtime/threading_backend.h.

◆ Join()

void tvm::runtime::threading::ThreadGroup::Join ( )

Blocks until all non-main threads in the pool finish.

Examples
/workspace/include/tvm/runtime/threading_backend.h.

The documentation for this class was generated from the following file: