37 #ifndef __PARA_COMM_PTH_H__ 38 #define __PARA_COMM_PTH_H__ 57 #define HashEntry( tid ) ( hashCode(tid) % UG::HashTableSize ) 59 #define TAG_TRACE( call, fromTo, sourceDest, tag ) \ 65 *getOstream() << timer.getRTimeInterval() << " [Rank = " << getRank() << "] " << #call << " " << #fromTo \ 66 << " " << sourceDest << " with Tag = " << getTagString(tag) << std::endl; \ 71 *getOstream() << timer.getRTimeInterval() << " [Rank = " << getRank() << "] " << #call << " " << #fromTo \ 72 << " " << sourceDest << " as broadcast" << std::endl; \ 131 ) : source(-1), count(0), dataTypeId(-1), tag(-1), data(0), next(0)
144 ) : source(inSource), count(inCount), dataTypeId(inDataTypeId), tag(inTag), data(inData), next(0)
246 ) : head(0), tail(0), size(0)
282 if( current->getSource() == source
283 && current->getDataTypeId() == datatypeId
284 && current->getTag() ==
tag )
306 if( current->getTag() ==
tag )
341 if( current == head )
343 if( current == tail )
347 *sentMessage =
false;
356 if( current == tail )
385 if( head == 0 )
return 0;
390 if( current == tail )
394 *sentMessage =
false;
416 head = tail = newElement;
420 tail->
link(newElement);
458 if( head ) empty =
false;
460 assert( !empty || size == 0 );
503 *sentMessage =
false;
541 && current->
getTag() == (*tag) )
549 *sentMessage =
false;
561 #ifdef _UG_NO_THREAD_LOCAL_STATIC 575 #ifdef _UG_NO_THREAD_LOCAL_STATIC
578 rank(0), tos(0), next(0)
586 #ifdef _UG_NO_THREAD_LOCAL_STATIC
592 #ifdef _UG_NO_THREAD_LOCAL_STATIC
595 rank(inRank), tos(0), next(0)
605 std::ostringstream s;
607 std::ofstream *ofs =
new std::ofstream();
608 ofs->open(s.str().c_str());
622 if( tos != &std::cout )
624 std::ofstream *ofs =
dynamic_cast<std::ofstream *
>(tos);
631 #ifdef _UG_NO_THREAD_LOCAL_STATIC 683 #ifdef _UG_NO_THREAD_LOCAL_STATIC 718 #ifndef _UG_NO_THREAD_LOCAL_STATIC 734 unsigned int hashCode(
741 void *allocateMemAndCopy(
770 bool freeStandardTypes(
791 messageQueueTable(0),
854 return messageQueueTable[dest]->
getSize();
859 for(
int i = 0; i < ( comSize + 1 ); i++ )
861 nTotalMessages += messageQueueTable[i]->
getSize();
863 return nTotalMessages;
960 void waitUntilRegistered(
966 void registedAllSolvers(
973 std::ostream *getOstream(
982 applicationLock.
lock();
1021 applicationLock.
lock(f,l);
1067 const int datatypeId,
1078 const int datatypeId,
1090 const int datatypeId,
1099 void waitSpecTagFromSpecSource(
1129 const int datatypeId,
1140 const int datatypeId,
1155 #define DEF_PARA_COMM( para_comm, comm ) ParaCommPth *para_comm = dynamic_cast< ParaCommPth* >(comm) 1156 #define LOCK_APP( comm ) comm->lockApp(__FILE__, __LINE__) 1157 #define LOCK_RANK( comm ) comm->lockRank(__FILE__, __LINE__) 1158 #define UNLOCK_RANK( comm ) comm->unlockRank(__FILE__, __LINE__) 1161 #endif // __PARA_COMM_PTH_H__ int count
number of the data type elements
~MessageQueueElement()
destructor of MessageQueueElement
static const char * tagStringTable[]
mutex for interrupt message monitor
void unlockApp()
unlock UG application to synchronize with other threads
std::ostream * getOstream()
getter of tag trace stream of this rank
class ParaSolverState (ParaSolver state object for notification message)
int getDataTypeId()
getter of the data type id
void lockApp()
lock UG application to synchronize with other threads
static const int ParaCalculationStateType
int ** token
index 0: token index 1: token color -1: green > 0: yellow ( termination origin solver number ) -2: re...
MessageQueueElement * getHead()
getter of head
ParaTimer extension for threads.
MessageQueueElement * extarctElement(bool *sentMessage)
extracts a message (This method is only for desctructor of ParaCommCPP11. No lock is necessary...
MessageQueueElement * checkElementWithTag(int tag)
check if the specified message with tag exists or nor
static ScipParaParamSet * paraParamSet
MessageQueueElement()
default constructor of MessageQueueElement
Pthread condition variable for UG Framework.
void * data
data of the message
int getSize()
get size of this communicator, which indicates how many threads in a UG process
void lock()
Acquire this lock. The function sets the internal file/line (debugging) fields to generic values...
void lockApp(char const *f, int l)
lock UG application to synchronize with other threads (for debugging)
void abort()
abort. How it works sometimes depends on communicator used
static const int HashTableSize
size of thread table : this limits the number of threads
static __thread int localRank
local thread rank
ParaTimer * createParaTimer()
create ParaTimer object
MessageQueueElement * checkElement(int source, int datatypeId, int tag)
check if the specified message exists or nor
Base class of Calculation state in a ParaSolver.
int getCount()
getter of the number of the data type elements
static const int ParaInstanceType
Defines for UG Framework.
const char * getTagString(int tag)
get Tag string for debugging
MessageQueueElement * getNext()
getter of the pointer to the next MessageQueueElement
#define CONDITIONVARIABLE_WAIT(var, cond)
Perform exception-safe waiting on a condition variable. This macro waits on VAR until COND is true...
class ParaTimerMpi (Timer used in thread communication)
Lock * queueLock
Lock for synchronization.
MessageQueueElement * next
point to next message queue element
ThreadsTableElement()
default constructor of ThreadsTableElement
ThreadsTableElement(int inRank, ParaParamSet *paraParamSet)
constructor of ThreadsTableElement
Class of MessageQueueTableElement.
Lock applicationLock
lock for application
static const int TYPE_LAST
Class for message queue element.
void unlockRank(char const *f, int l)
unlock rank (for debugging)
ConditionVariable * sentMsg
Condition variable for synchronization.
MessageQueueElement(int inSource, int inCount, int inDataTypeId, int inTag, void *inData)
constructor of MessageQueueElement
static const int TagTraceFileName
int getSource()
getter of source rank
ThreadsTableElement * next
next ThradsTableElement pointer
Pthread lock for UG Framework.
MessageQueueElement * extarctElement(bool *sentMessage, int source, int datatypeId, int tag)
extracts a message
Communicator object for pthreads thread communications.
int getNumOfMessagesWaitingToSend(int dest=-1)
get size of the messageQueueTable
int comSize
communicator size : number of threads joined in this system
bool waitTerminatedMessage()
function to wait Terminated message (This function is not used currently)
void unlock()
Release this lock.
static const int ParaSolverTerminationStateType
Lock * tokenAccessLock
lock to access token
Base class of communicator for UG Framework.
static const int TagTrace
void link(MessageQueueElement *nextElement)
link to the next MessageQueueElement
bool isStringParamDefaultValue(int param)
check if string parameter is default value or not
class ParaSolverTerminationState (Solver termination state in a ParaSolver)
void waitMessage(ConditionVariable *sentMsg, bool *sentMessage, int source, int *tag)
wait for a specified message coming to a queue
ParaSysTimer timer
system timer
void unlockRank()
unlock rank
ParaCommPth()
constructor of ParaCommPth
int tag
tag of the message, -1 : in case of broadcast message
void setRank(int r)
setter of this thread rank
Class for the difference between instance and subproblem.
static const int ParaSolutionType
int dataTypeId
data type id
const char * getStringParamValue(int param)
for char parameters
Class that implements a lock. The class wraps around pthread_mutex_t and adds some safeguards...
Class of ThreadsTableElement.
MessageQueueTableElement ** messageQueueTable
message queue table
void waitMessage(ConditionVariable *sentMsg, bool *sentMessage, int source, int datatypeId, int tag)
wait for a specified message coming to a queue
void waitMessage(ConditionVariable *sentMsg, bool *sentMessage)
wait for a message coming to a queue
~ThreadsTableElement()
destructor of ThreadsTableElement
MessageQueueTableElement()
default constructor of MessageQueueTableElement
void lockRank(char const *f, int l)
lock rank (for debugging)
double getStartTime(void)
get start time
int getTag()
getter of the message tag
void * getData()
getter of data
bool tagTraceFlag
indicate if tags are traced or not
bool isEmpty()
check if the queue is empty or not
int source
source thread rank of this message
int getSize()
getter of size
double getStartTime()
get start time of this communicator (should not be used)
bool tagStringTableIsSetUpCoorectly()
check if tag string table (for debugging) set up correctly
static const int ParaTaskType
Lock rankLock
lock to access rank
static const int UG_USER_TYPE_LAST
bool * sentMessage
sent message flag for synchronization
static const int ParaSolverStateType
int getRank()
getter of this thread rank
ThreadsTableElement * getNext()
get next element
static const int ParaParamSetType
static const int UG_USER_TYPE_FIRST
user defined transfer data types
static const int ParaRacingRampUpParamType
Base class of communicator object.
void enqueue(ConditionVariable *sentMsg, bool *sentMessage, MessageQueueElement *newElement)
enqueue a message
~MessageQueueTableElement()
destructor of MessageQueueTableElement
bool getBoolParamValue(int param)
for bool parameters
void solverInit(ParaParamSet *paraParamSet)
initializer for Solvers