SMAUG
Simulating Machine Learning Applications on gem5-Aladdin
|
1 #ifndef _UTILITY_THREAD_POOL_H_
2 #define _UTILITY_THREAD_POOL_H_
35 typedef void* (*WorkerThreadFunc)(
void*);
96 status = Uninitialized;
105 pthread_mutex_t cpuidMutex;
106 pthread_cond_t cpuidCond;
110 pthread_mutex_init(&cpuidMutex, NULL);
111 pthread_cond_init(&cpuidCond, NULL);
pthread_cond_t wakeupCond
The main thread signals this condition variable to wake up the thread and have it check for work (ind...
void * args
User-provided arguments.
void joinThreadPool()
Wait for all threads in the pool to finish work.
static void * workerLoop(void *args)
The main event loop executed by all worker threads.
pthread_mutex_t statusMutex
This mutex protects all of the subsequent fields of this struct.
bool exit
Set to true to inform the worker thread to terminate.
ThreadPool(int nthreads)
Create a ThreadPool with N threads.
std::vector< WorkerThread > workers
Worker threads.
void initThreadPool()
Initialize the thread pool.
pthread_cond_t statusCond
The worker thread signals this condition variable to inform the main thread of a change in status (us...
bool valid
Set to true if the func and args are valid and need to be executed.
int cpuid
The gem5 simulation CPU ID assigned to this worker thread.
ThreadStatus
Possible worker thread states.
void *(* WorkerThreadFunc)(void *)
Function signature for any work to be executed on a worker thread.
The smaug namespace is the parent namespace of all C++ code in SMAUG.
int size() const
Returns the number of worker threads.
int dispatchThread(WorkerThreadFunc func, void *args)
Dispatch the function to a worker in the thread pool.
pthread_t thread
pthread handle.
A user-space cooperatve thread pool implementation designed for gem5 in SE mode.
All state and metadata for a worker thread.