Nektar++
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
Nektar::Thread::ThreadStartupManager Class Reference

A default ThreadManager. More...

#include <Thread.h>

Inheritance diagram for Nektar::Thread::ThreadStartupManager:
[legend]

Public Member Functions

 ThreadStartupManager ()
 ThreadDefaultManager. More...
 
 ThreadStartupManager (const ThreadStartupManager &src)=default
 
 ~ThreadStartupManager () override
 
- Public Member Functions inherited from Nektar::Thread::ThreadManager
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)
 

Protected Member Functions

void v_QueueJobs (std::vector< ThreadJob * > &joblist) override
 
void v_QueueJob (ThreadJob *job) override
 
unsigned int v_GetNumWorkers () override
 
unsigned int v_GetWorkerNum () override
 
void v_SetNumWorkers (const unsigned int num) override
 
void v_SetNumWorkers () override
 
unsigned int v_GetMaxNumWorkers () override
 
void v_Wait () override
 
void v_SetChunkSize (unsigned int chnk) override
 
void v_SetSchedType (SchedType s) override
 
bool v_InThread () override
 
void v_Hold () override
 
bool v_IsInitialised () override
 
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

ThreadStartupManageroperator= (const ThreadStartupManager &src)
 ThreadDefaultManager copy constructor. More...
 

Private Attributes

const std::string m_type
 

Detailed Description

A default ThreadManager.

This will be returned by ThreadMaster if a ThreadManager has not been initialised, such as if the code is still in static initialisation.

This manager pretends to be a ThreadManager with 1 thread. It will cause an error if anything more than trivial functions are called.

Definition at line 435 of file Thread.h.

Constructor & Destructor Documentation

◆ ThreadStartupManager() [1/2]

Nektar::Thread::ThreadStartupManager::ThreadStartupManager ( )

ThreadDefaultManager.

Definition at line 192 of file Thread.cpp.

192 : m_type("Threading starting up")
193{
194 // empty
195}

◆ ThreadStartupManager() [2/2]

Nektar::Thread::ThreadStartupManager::ThreadStartupManager ( const ThreadStartupManager src)
default

◆ ~ThreadStartupManager()

Nektar::Thread::ThreadStartupManager::~ThreadStartupManager ( )
override

Definition at line 200 of file Thread.cpp.

201{
202 // empty
203}

Member Function Documentation

◆ operator=()

ThreadStartupManager & Nektar::Thread::ThreadStartupManager::operator= ( const ThreadStartupManager src)
private

ThreadDefaultManager copy constructor.

Definition at line 326 of file Thread.cpp.

328{
329 return *this;
330}

◆ v_GetMaxNumWorkers()

unsigned int Nektar::Thread::ThreadStartupManager::v_GetMaxNumWorkers ( )
overrideprotectedvirtual

Implements Nektar::Thread::ThreadManager.

Definition at line 260 of file Thread.cpp.

261{
262 return 1;
263}

◆ v_GetNumWorkers()

unsigned int Nektar::Thread::ThreadStartupManager::v_GetNumWorkers ( )
overrideprotectedvirtual

Implements Nektar::Thread::ThreadManager.

Definition at line 227 of file Thread.cpp.

228{
229 return 1;
230}

◆ v_GetType()

const std::string & Nektar::Thread::ThreadStartupManager::v_GetType ( ) const
overrideprotectedvirtual

Implements Nektar::Thread::ThreadManager.

Definition at line 318 of file Thread.cpp.

319{
320 return m_type;
321}

References m_type.

◆ v_GetWorkerNum()

unsigned int Nektar::Thread::ThreadStartupManager::v_GetWorkerNum ( )
overrideprotectedvirtual

Implements Nektar::Thread::ThreadManager.

Definition at line 235 of file Thread.cpp.

236{
237 return 0;
238}

◆ v_Hold()

void Nektar::Thread::ThreadStartupManager::v_Hold ( )
overrideprotectedvirtual

Implements Nektar::Thread::ThreadManager.

Definition at line 302 of file Thread.cpp.

303{
304 return;
305}

◆ v_InThread()

bool Nektar::Thread::ThreadStartupManager::v_InThread ( )
overrideprotectedvirtual

Implements Nektar::Thread::ThreadManager.

Definition at line 294 of file Thread.cpp.

295{
296 return false;
297}

◆ v_IsInitialised()

bool Nektar::Thread::ThreadStartupManager::v_IsInitialised ( )
overrideprotectedvirtual

Implementations should not override this function, since they are initialised.

Returns
True if this ThreadManager has been initialised.

Reimplemented from Nektar::Thread::ThreadManager.

Definition at line 310 of file Thread.cpp.

311{
312 return false;
313}

◆ v_QueueJob()

void Nektar::Thread::ThreadStartupManager::v_QueueJob ( ThreadJob job)
overrideprotectedvirtual

Implements Nektar::Thread::ThreadManager.

Definition at line 218 of file Thread.cpp.

219{
221 "Attempted to QueueJob in ThreadDefaultManager");
222}
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
Definition: ErrorUtil.hpp:202

References Nektar::ErrorUtil::efatal, and NEKERROR.

◆ v_QueueJobs()

void Nektar::Thread::ThreadStartupManager::v_QueueJobs ( std::vector< ThreadJob * > &  joblist)
overrideprotectedvirtual

Implements Nektar::Thread::ThreadManager.

Definition at line 208 of file Thread.cpp.

210{
212 "Attempted to QueueJobs in ThreadDefaultManager");
213}

References Nektar::ErrorUtil::efatal, and NEKERROR.

◆ v_SetChunkSize()

void Nektar::Thread::ThreadStartupManager::v_SetChunkSize ( unsigned int  chnk)
overrideprotectedvirtual

Implements Nektar::Thread::ThreadManager.

Definition at line 276 of file Thread.cpp.

277{
279 "Attempted to SetChunkSize in ThreadDefaultManager");
280}

References Nektar::ErrorUtil::efatal, and NEKERROR.

◆ v_SetNumWorkers() [1/2]

void Nektar::Thread::ThreadStartupManager::v_SetNumWorkers ( )
overrideprotectedvirtual

Implements Nektar::Thread::ThreadManager.

Definition at line 252 of file Thread.cpp.

253{
254 return;
255}

◆ v_SetNumWorkers() [2/2]

void Nektar::Thread::ThreadStartupManager::v_SetNumWorkers ( const unsigned int  num)
overrideprotectedvirtual

Implements Nektar::Thread::ThreadManager.

Definition at line 243 of file Thread.cpp.

244{
245 ASSERTL0(num == 1,
246 "Attempted to SetNumWorkers to != 1 in ThreadDefaultManager");
247}
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208

References ASSERTL0.

◆ v_SetSchedType()

void Nektar::Thread::ThreadStartupManager::v_SetSchedType ( SchedType  s)
overrideprotectedvirtual

Implements Nektar::Thread::ThreadManager.

Definition at line 285 of file Thread.cpp.

286{
288 "Attempted to SetSchedType in ThreadDefaultManager");
289}

References Nektar::ErrorUtil::efatal, and NEKERROR.

◆ v_Wait()

void Nektar::Thread::ThreadStartupManager::v_Wait ( )
overrideprotectedvirtual

Implements Nektar::Thread::ThreadManager.

Definition at line 268 of file Thread.cpp.

269{
270 return;
271}

Member Data Documentation

◆ m_type

const std::string Nektar::Thread::ThreadStartupManager::m_type
private

Definition at line 462 of file Thread.h.

Referenced by v_GetType().