37 #ifndef __PARA_COMM_MPI_H__ 38 #define __PARA_COMM_MPI_H__ 62 #include "ugs/ugsParaCommMpi.h" 68 #define MPI_CALL( mpicall ) do \ 71 _error_value_ = ( mpicall ); \ 72 if( _error_value_ != MPI_SUCCESS ) \ 74 std::cout << "[MPI ERROR: " << __FILE__ << "] func = " \ 75 << __func__ << ", line = " << __LINE__ << ": " \ 76 << "error_code = " << _error_value_ << std::endl; \ 77 MPI_Abort(MPI_COMM_WORLD, 1); \ 81 #define TAG_TRACE( call, fromTo, sourceDest, tag ) \ 84 *tos << (MPI_Wtime() - startTime) << " [Rank = " << myRank << "] " << #call << " " << #fromTo \ 85 << " " << sourceDest << " with Tag = " << getTagString(tag) << std::endl; \ 88 class ParaIsendRequest;
121 UGS::UgsParaCommMpi *commUgs;
140 : myComm(MPI_COMM_NULL),
152 pthread_mutex_init(&tokenAccessLock, NULL);
237 return iSendRequestDeque.size();
303 std::lock_guard<std::mutex> lock(tokenAccessLock);
305 pthread_mutex_lock(&tokenAccessLock);
307 token[0] = inToken[0]; token[1] = inToken[1];
309 pthread_mutex_unlock(&tokenAccessLock);
323 applicationLockMutex.lock();
333 applicationLockMutex.unlock();
353 const int datatypeId,
364 const int datatypeId,
376 const int datatypeId,
389 const int datatypeId,
429 MPI_Datatype datatype,
440 MPI_Datatype datatype,
452 MPI_Datatype datatype,
465 MPI_Datatype datatype,
485 #define DEF_PARA_COMM( para_comm, comm ) ParaCommMpi *para_comm = dynamic_cast< ParaCommMpi* >(comm) 489 #endif // __PARA_COMM_MPI_H__ pthread_mutex_t tokenAccessLock
mutex for pthread thread
void lcInit(ParaParamSet *paraParamSet)
initializer for LoadCoordinator
static const char * tagStringTable[]
table for tag name string
static ScipParaCommTh * comm
static ScipParaParamSet * paraParamSet
MPI_Comm & getMpiComm()
getter of MPI_Comm
Base class for a container which has difference between instance and subproblem.
virtual void init(int argc, char **argv)
initializer of this communicator
ParaCommMpi()
default constructor of ParaCommMpi
virtual void unlockApp()
unlock UG application to synchronize with other threads
bool tagTraceFlag
indicate if tags are traced or not
int myCommSize
communicator size : number of processes joined in this system
std::ofstream ofs
output file stream for tag trace
int ureceive(void *bufer, int count, MPI_Datatype datatype, int source, int tag)
User type receive for created data type.
virtual void unlockApp()=0
unlock UG application to synchronize with other threads
int getRank()
get rank of caller's thread
ParaTimer extension for MPI timer.
ParaCommMpi(MPI_Comm comm)
constructor of ParaCommMpi with MPI communicator
virtual ~ParaCommMpi()
destructor of this communicator
static const int TYPE_LIST_SIZE
Defines for UG Framework.
void waitSpecTagFromSpecSource(const int source, const int tag, int *receivedTag)
wait function for a specific tag from a specific source coming from
std::deque< ParaIsendRequest * > iSendRequestDeque
double startTime
start time of this communicator
int getSize()
get size of this communicator, which indicates how many threads in a UG process
virtual void setToken(int rank, int *inToken)
set received token to this communicator
class ParaTimerMpi (Timer used in MPI communication)
virtual void lockApp()
lock UG application to synchronize with other threads
virtual void lockApp()=0
lock UG application to synchronize with other threads
virtual int send(void *bufer, int count, const int datatypeId, int dest, const int tag)
send function for standard ParaData types
Communicator object for MPI communications.
Base class of communicator for UG Framework.
bool probe(int *source, int *tag)
probe function which waits a new message
Base class for instance data.
MPI_Comm myComm
MPI communicator.
virtual bool waitTerminatedMessage()
function to wait Terminated message (This function is not used currently)
char procName[MPI_MAX_PROCESSOR_NAME]
process name
std::mutex applicationLockMutex
mutex for applications
int token[2]
index 0: token index 1: token color -1: green > 0: yellow ( termination origin solver number ) -2: re...
virtual const char * getTagString(int tag)
get Tag string for debugging
virtual bool waitToken(int rank)
wait token when UG runs with deterministic mode
int iUsend(void *bufer, int count, MPI_Datatype datatype, int dest, int tag, MPI_Request *req)
User type send for created data type.
static MPI_Datatype datatypes[TYPE_LIST_SIZE]
data type mapping table to MPI data type
virtual bool passTermToken(int rank)
pass termination token from the rank to the next
int receive(void *bufer, int count, const int datatypeId, int source, const int tag)
receive function for standard ParaData types
int bcast(void *buffer, int count, const int datatypeId, int root)
broadcast function for standard ParaData types
void abort()
abort. How it works sometimes depends on communicator used
int ubcast(void *buffer, int count, MPI_Datatype datatype, int root)
User type bcast for created data type.
virtual void passToken(int rank)
pass token to from the rank to the next
ParaParamSet extension for MPI communication.
std::ostream * tos
output file stream for tag trace to change file name
int getNumOfMessagesWaitingToSend(int dest=-1)
get size of the messageQueueTable
ParaTimer * createParaTimer()
create ParaTimer object
int namelen
length of this process name
double getStartTime()
get start time of this communicator
virtual bool tagStringTableIsSetUpCoorectly()
check if tag string table (for debugging) set up correctly
int myRank
rank of this process
Base class of communicator object.
int usend(void *bufer, int count, MPI_Datatype datatype, int dest, int tag)
User type send for created data type.
int iSend(void *bufer, int count, const int datatypeId, int dest, const int tag, MPI_Request *req)
send function for standard ParaData types
bool iProbe(int *source, int *tag)
iProbe function which checks if a new message is arrived or not
void solverInit(ParaParamSet *paraParamSet)
initializer for Solvers