Nektar++
|
Implementation of ThreadManager using Boost threads. More...
#include <ThreadBoost.h>
Public Member Functions | |
ThreadManagerBoost (unsigned int numWorkers) | |
Constructs a ThreadManagerBoost. More... | |
virtual | ~ThreadManagerBoost () |
Shuts down threading. More... | |
![]() | |
virtual | ~ThreadManager () |
Destructor. More... | |
void | QueueJobs (std::vector< ThreadJob * > &joblist) |
Pass a list of tasklets to the master queue. More... | |
void | QueueJob (ThreadJob *job) |
Pass a single job to the master queue. More... | |
unsigned int | GetNumWorkers () |
Return the number of active workers. More... | |
unsigned int | GetWorkerNum () |
Returns the worker number of the executing thread. More... | |
void | SetNumWorkers (const unsigned int num) |
Sets the number of active workers. More... | |
void | SetNumWorkers () |
Sets the number of active workers to the maximum. More... | |
unsigned int | GetMaxNumWorkers () |
Gets the maximum available number of threads. More... | |
void | Wait () |
Waits until all queued jobs are finished. More... | |
void | SetChunkSize (unsigned int chnk) |
Controls how many jobs are sent to each worker at a time. More... | |
void | SetSchedType (SchedType s) |
Sets the current scheduling algorithm. More... | |
bool | InThread () |
Indicates whether the code is in a worker thread or not. More... | |
void | Hold () |
A calling threads holds until all active threads call this method. More... | |
const std::string & | GetType () |
Returns a description of the type of threading. More... | |
bool | IsInitialised () |
ThreadManager implementation. More... | |
int | GetThrFromPartition (int pPartition) |
int | GetRankFromPartition (int pPartition) |
int | GetPartitionFromRankThr (int pRank, unsigned int pThr) |
Static Public Member Functions | |
static ThreadManagerSharedPtr | Create (unsigned int numT) |
Called by the factory method. More... | |
Protected Member Functions | |
virtual void | v_QueueJobs (std::vector< ThreadJob * > &joblist) override |
virtual void | v_QueueJob (ThreadJob *job) override |
virtual unsigned int | v_GetNumWorkers () override |
virtual unsigned int | v_GetWorkerNum () override |
virtual void | v_SetNumWorkers (const unsigned int num) override |
virtual void | v_SetNumWorkers () override |
virtual unsigned int | v_GetMaxNumWorkers () override |
virtual void | v_Wait () override |
virtual void | v_SetChunkSize (unsigned int chnk) override |
virtual void | v_SetSchedType (SchedType s) override |
virtual bool | v_InThread () override |
virtual void | v_Hold () override |
virtual const std::string & | v_GetType () const override |
![]() | |
virtual void | v_QueueJobs (std::vector< ThreadJob * > &joblist)=0 |
virtual void | v_QueueJob (ThreadJob *job)=0 |
virtual unsigned int | v_GetNumWorkers ()=0 |
virtual unsigned int | v_GetWorkerNum ()=0 |
virtual void | v_SetNumWorkers (const unsigned int num)=0 |
virtual void | v_SetNumWorkers ()=0 |
virtual unsigned int | v_GetMaxNumWorkers ()=0 |
virtual void | v_Wait ()=0 |
virtual void | v_SetChunkSize (unsigned int chnk)=0 |
virtual void | v_SetSchedType (SchedType s)=0 |
virtual bool | v_InThread ()=0 |
virtual void | v_Hold ()=0 |
virtual const std::string & | v_GetType () const =0 |
virtual bool | v_IsInitialised () |
Private Member Functions | |
ThreadManagerBoost () | |
ThreadManagerBoost (const ThreadManagerBoost &) | |
bool | IsWorking () |
void | SetNumWorkersImpl (const unsigned int num) |
Private Attributes | |
const unsigned int | m_numThreads |
unsigned int | m_numWorkers |
std::queue< ThreadJob * > | m_masterQueue |
boost::mutex | m_masterQueueMutex |
boost::mutex | m_masterActiveMutex |
boost::condition_variable | m_masterQueueCondVar |
boost::condition_variable | m_masterActiveCondVar |
ThreadWorkerBoost ** | m_threadList |
boost::thread ** | m_threadThreadList |
boost::thread::id | m_masterThreadId |
bool * | m_threadBusyList |
bool * | m_threadActiveList |
unsigned int | m_chunkSize |
SchedType | m_schedType |
boost::barrier * | m_barrier |
std::map< boost::thread::id, unsigned int > | m_threadMap |
std::string | m_type |
Static Private Attributes | |
static std::string | className |
Friends | |
class | ThreadWorkerBoost |
Implementation of ThreadManager using Boost threads.
Definition at line 58 of file ThreadBoost.h.
Nektar::Thread::ThreadManagerBoost::ThreadManagerBoost | ( | unsigned int | numT | ) |
Constructs a ThreadManagerBoost.
numWorkers | The number of threads to start (including master thread). |
Definition at line 55 of file ThreadBoost.cpp.
References m_barrier, m_masterThreadId, m_numThreads, m_numWorkers, m_threadActiveList, m_threadBusyList, m_threadList, m_threadMap, m_threadThreadList, m_type, and ThreadWorkerBoost.
|
virtual |
Shuts down threading.
Terminates all running threads (they will finish their current job), releases resources and destructs.
Definition at line 116 of file ThreadBoost.cpp.
References m_barrier, m_masterActiveCondVar, m_masterQueueCondVar, m_numThreads, m_threadActiveList, m_threadBusyList, m_threadList, m_threadThreadList, and Nektar::Thread::ThreadWorkerBoost::Stop().
|
private |
Referenced by Create().
|
private |
|
inlinestatic |
Called by the factory method.
Definition at line 72 of file ThreadBoost.h.
References ThreadManagerBoost().
|
private |
Definition at line 166 of file ThreadBoost.cpp.
References m_masterActiveMutex, m_numWorkers, and m_threadBusyList.
Referenced by v_Wait().
|
private |
Definition at line 243 of file ThreadBoost.cpp.
References m_barrier, m_masterActiveCondVar, m_masterActiveMutex, m_numThreads, m_numWorkers, and m_threadActiveList.
Referenced by v_SetNumWorkers().
|
overrideprotectedvirtual |
Implements Nektar::Thread::ThreadManager.
Definition at line 285 of file ThreadBoost.cpp.
References m_numThreads.
|
overrideprotectedvirtual |
Implements Nektar::Thread::ThreadManager.
Definition at line 226 of file ThreadBoost.cpp.
References m_numWorkers.
|
overrideprotectedvirtual |
Implements Nektar::Thread::ThreadManager.
Definition at line 301 of file ThreadBoost.cpp.
References m_type.
|
overrideprotectedvirtual |
Implements Nektar::Thread::ThreadManager.
Definition at line 234 of file ThreadBoost.cpp.
References m_threadMap.
|
overrideprotectedvirtual |
Implements Nektar::Thread::ThreadManager.
Definition at line 293 of file ThreadBoost.cpp.
References m_barrier.
|
overrideprotectedvirtual |
Implements Nektar::Thread::ThreadManager.
Definition at line 198 of file ThreadBoost.cpp.
References m_masterThreadId.
Implements Nektar::Thread::ThreadManager.
Definition at line 156 of file ThreadBoost.cpp.
References m_masterQueue, m_masterQueueCondVar, and m_masterQueueMutex.
|
overrideprotectedvirtual |
Implements Nektar::Thread::ThreadManager.
Definition at line 144 of file ThreadBoost.cpp.
References Nektar::Thread::ThreadManager::QueueJob().
|
overrideprotectedvirtual |
Implements Nektar::Thread::ThreadManager.
Definition at line 180 of file ThreadBoost.cpp.
References m_chunkSize, and m_masterQueueMutex.
|
overrideprotectedvirtual |
Implements Nektar::Thread::ThreadManager.
Definition at line 277 of file ThreadBoost.cpp.
References m_numThreads, and SetNumWorkersImpl().
|
overrideprotectedvirtual |
Implements Nektar::Thread::ThreadManager.
Definition at line 266 of file ThreadBoost.cpp.
References m_numThreads, and SetNumWorkersImpl().
Implements Nektar::Thread::ThreadManager.
Definition at line 189 of file ThreadBoost.cpp.
References m_masterQueueMutex, and m_schedType.
|
overrideprotectedvirtual |
Implements Nektar::Thread::ThreadManager.
Definition at line 207 of file ThreadBoost.cpp.
References IsWorking(), m_masterActiveCondVar, m_masterQueue, m_masterQueueCondVar, and m_masterQueueMutex.
|
friend |
So the workers can access the master queue and locks.
Definition at line 63 of file ThreadBoost.h.
Referenced by ThreadManagerBoost().
|
staticprivate |
Definition at line 115 of file ThreadBoost.h.
|
private |
Definition at line 113 of file ThreadBoost.h.
Referenced by SetNumWorkersImpl(), ThreadManagerBoost(), v_Hold(), and ~ThreadManagerBoost().
|
private |
Definition at line 111 of file ThreadBoost.h.
Referenced by Nektar::Thread::ThreadWorkerBoost::GetNumToLoad(), and v_SetChunkSize().
|
private |
Definition at line 105 of file ThreadBoost.h.
Referenced by SetNumWorkersImpl(), v_Wait(), Nektar::Thread::ThreadWorkerBoost::WaitForActive(), and ~ThreadManagerBoost().
|
private |
Definition at line 103 of file ThreadBoost.h.
Referenced by IsWorking(), Nektar::Thread::ThreadWorkerBoost::LoadJobs(), SetNumWorkersImpl(), and Nektar::Thread::ThreadWorkerBoost::WaitForActive().
|
private |
Definition at line 101 of file ThreadBoost.h.
Referenced by Nektar::Thread::ThreadWorkerBoost::GetNumToLoad(), Nektar::Thread::ThreadWorkerBoost::LoadJobs(), v_QueueJob(), and v_Wait().
|
private |
Definition at line 104 of file ThreadBoost.h.
Referenced by Nektar::Thread::ThreadWorkerBoost::LoadJobs(), v_QueueJob(), v_Wait(), and ~ThreadManagerBoost().
|
private |
Definition at line 102 of file ThreadBoost.h.
Referenced by Nektar::Thread::ThreadWorkerBoost::LoadJobs(), v_QueueJob(), v_SetChunkSize(), v_SetSchedType(), and v_Wait().
|
private |
Definition at line 108 of file ThreadBoost.h.
Referenced by ThreadManagerBoost(), and v_InThread().
|
private |
Definition at line 99 of file ThreadBoost.h.
Referenced by SetNumWorkersImpl(), ThreadManagerBoost(), v_GetMaxNumWorkers(), v_SetNumWorkers(), and ~ThreadManagerBoost().
|
private |
Definition at line 100 of file ThreadBoost.h.
Referenced by Nektar::Thread::ThreadWorkerBoost::GetNumToLoad(), IsWorking(), SetNumWorkersImpl(), ThreadManagerBoost(), and v_GetNumWorkers().
|
private |
Definition at line 112 of file ThreadBoost.h.
Referenced by Nektar::Thread::ThreadWorkerBoost::GetNumToLoad(), and v_SetSchedType().
|
private |
Definition at line 110 of file ThreadBoost.h.
Referenced by Nektar::Thread::ThreadWorkerBoost::LoadJobs(), SetNumWorkersImpl(), ThreadManagerBoost(), Nektar::Thread::ThreadWorkerBoost::WaitForActive(), and ~ThreadManagerBoost().
|
private |
Definition at line 109 of file ThreadBoost.h.
Referenced by IsWorking(), Nektar::Thread::ThreadWorkerBoost::LoadJobs(), ThreadManagerBoost(), and ~ThreadManagerBoost().
|
private |
Definition at line 106 of file ThreadBoost.h.
Referenced by ThreadManagerBoost(), and ~ThreadManagerBoost().
|
private |
Definition at line 114 of file ThreadBoost.h.
Referenced by ThreadManagerBoost(), and v_GetWorkerNum().
|
private |
Definition at line 107 of file ThreadBoost.h.
Referenced by ThreadManagerBoost(), and ~ThreadManagerBoost().
|
private |
Definition at line 116 of file ThreadBoost.h.
Referenced by ThreadManagerBoost(), and v_GetType().