59ParaCommCPP11::localRank = -1;
62ParaCommCPP11::tagStringTable[] = {
75 TAG_STR(TagRacingRampUpParamSets),
84ParaCommCPP11::init(
int argc,
char **argv )
91 for(
int i = 1; i < argc; i++ )
93 if( strcmp(argv[i],
"-sth") == 0 )
97 comSize = atoi(
const_cast<const char*
>(argv[i]));
100 std::cerr <<
"missing the number of solver threads after parameter '-sth'" << std::endl;
115 GetSystemInfo(&sysinfo);
116 comSize = sysinfo.dwNumberOfProcessors + 1;
118 comSize = sysconf(_SC_NPROCESSORS_CONF) + 1;
124 for(
int i = 0; i <
comSize; i++ )
126 token[i] =
new int[2];
145 for(
int i = 0; i < (
comSize + 1 ); i++ )
219 if(
token[rank][0] == rank )
227 probe(&source, &receivedTag);
228 TAG_TRACE (Probe, From, source, receivedTag);
229 if( source == 0 && receivedTag ==
TagToken )
232 assert(
token[rank][0] == rank );
249 assert(
token[rank][0] == rank && rank != 0 );
262 if( rank ==
token[rank][0] )
273 if(
token[rank][1] == -2 )
291 assert( rank == 0 || ( rank != 0 && inToken[0] == rank ) );
292 token[rank][0] = inToken[0];
293 token[rank][1] = inToken[1];
309 for(
int i = 0; i <
comSize; i++ )
316 for(
int i = 0; i < (
comSize + 1); i++)
368 if( count == 0 )
return newBuf;
374 newBuf =
new char[count];
375 memcpy(newBuf, buffer, (
unsigned long int)
sizeof(
char)*count);
380 newBuf =
new short[count];
381 memcpy(newBuf, buffer, (
unsigned long int)
sizeof(
short)*count);
386 newBuf =
new int[count];
387 memcpy(newBuf, buffer, (
unsigned long int)
sizeof(
int)*count);
392 newBuf =
new long[count];
393 memcpy(newBuf, buffer, (
unsigned long int)
sizeof(
long)*count);
398 newBuf =
new unsigned char[count];
399 memcpy(newBuf, buffer, (
unsigned long int)
sizeof(
unsigned char)*count);
404 newBuf =
new unsigned short[count];
405 memcpy(newBuf, buffer, (
unsigned long int)
sizeof(
unsigned short)*count);
410 newBuf =
new unsigned int[count];
411 memcpy(newBuf, buffer, (
unsigned long int)
sizeof(
unsigned int)*count);
416 newBuf =
new unsigned long[count];
417 memcpy(newBuf, buffer, (
unsigned long int)
sizeof(
unsigned long)*count);
422 newBuf =
new float[count];
423 memcpy(newBuf, buffer, (
unsigned long int)
sizeof(
float)*count);
428 newBuf =
new double[count];
429 memcpy(newBuf, buffer, (
unsigned long int)
sizeof(
double)*count);
434 newBuf =
new long double[count];
435 memcpy(newBuf, buffer, (
unsigned long int)
sizeof(
long double)*count);
440 newBuf =
new char[count];
441 memcpy(newBuf, buffer, (
unsigned long int)
sizeof(
char)*count);
446 newBuf =
new char[count];
447 memcpy(newBuf, buffer, (
unsigned long int)
sizeof(
char)*count);
452 newBuf =
new long long[count];
453 memcpy(newBuf, buffer, (
unsigned long int)
sizeof(
long long)*count);
458 newBuf =
new unsigned long long[count];
459 memcpy(newBuf, buffer, (
unsigned long int)
sizeof(
unsigned long long)*count);
464 newBuf =
new bool[count];
465 memcpy(newBuf, buffer, (
unsigned long int)
sizeof(
bool)*count);
477 void *dest,
const void *src,
int count,
int datatypeId
481 if( count == 0 )
return;
487 memcpy(dest, src, (
unsigned long int)
sizeof(
char)*count);
492 memcpy(dest, src, (
unsigned long int)
sizeof(
short)*count);
497 memcpy(dest, src, (
unsigned long int)
sizeof(
int)*count);
502 memcpy(dest, src, (
unsigned long int)
sizeof(
long)*count);
507 memcpy(dest, src, (
unsigned long int)
sizeof(
unsigned char)*count);
512 memcpy(dest, src, (
unsigned long int)
sizeof(
unsigned short)*count);
517 memcpy(dest, src, (
unsigned long int)
sizeof(
unsigned int)*count);
522 memcpy(dest, src, (
unsigned long int)
sizeof(
unsigned long)*count);
527 memcpy(dest, src, (
unsigned long int)
sizeof(
float)*count);
532 memcpy(dest, src, (
unsigned long int)
sizeof(
double)*count);
537 memcpy(dest, src, (
unsigned long int)
sizeof(
long double)*count);
542 memcpy(dest, src, (
unsigned long int)
sizeof(
char)*count);
547 memcpy(dest, src, (
unsigned long int)
sizeof(
char)*count);
552 memcpy(dest, src, (
unsigned long int)
sizeof(
long long)*count);
557 memcpy(dest, src, (
unsigned long int)
sizeof(
unsigned long long)*count);
562 memcpy(dest, src, (
unsigned long int)
sizeof(
bool)*count);
579 if( count == 0 )
return;
585 delete []
static_cast<char *
>(buffer);
590 delete []
static_cast<short *
>(buffer);
595 delete []
static_cast<int *
>(buffer);
600 delete []
static_cast<long *
>(buffer);
605 delete []
static_cast<unsigned char *
>(buffer);
610 delete []
static_cast<unsigned short *
>(buffer);
615 delete []
static_cast<unsigned int *
>(buffer);
620 delete []
static_cast<unsigned long *
>(buffer);
625 delete []
static_cast<float *
>(buffer);
630 delete []
static_cast<double *
>(buffer);
635 delete []
static_cast<long double *
>(buffer);
640 delete []
static_cast<char *
>(buffer);
645 delete []
static_cast<char *
>(buffer);
650 delete []
static_cast<long long *
>(buffer);
655 delete []
static_cast<unsigned long long *
>(buffer);
660 delete []
static_cast<bool *
>(buffer);;
753 const int datatypeId,
763 send(buffer, count, datatypeId, i, -1);
769 receive(buffer, count, datatypeId, root, -1);
778 const int datatypeId,
797 const int datatypeId,
813 copy( buffer, elem->
getData(), count, datatypeId );
838 (*receivedTag) = tag;
840 TAG_TRACE (Probe, From, source, *receivedTag);
902 const int datatypeId,
919 const int datatypeId,
Class for message queue element.
int getSource()
getter of source rank
int getDataTypeId()
getter of the data type id
void * getData()
getter of data
int getTag()
getter of the message tag
int getCount()
getter of the number of the data type elements
Class of MessageQueueTableElement.
void enqueue(std::condition_variable &sentMsg, std::mutex &queueLockMutex, bool *sentMessage, MessageQueueElement *newElement)
enqueue a message
MessageQueueElement * extarctElement(bool *sentMessage, int source, int datatypeId, int tag)
extracts a message
MessageQueueElement * getHead()
getter of head
void waitMessage(std::condition_variable &sentMsg, std::mutex &queueLockMutex, bool *sentMessage)
wait for a message coming to a queue
MessageQueueElement * checkElementWithTag(int tag)
check if the specified message with tag exists or nor
bool isEmpty()
check if the queue is empty or not
Base class of Calculation state in a ParaSolver.
virtual void solverInit(ParaParamSet *paraParamSet)
initializer for Solvers
int comSize
communicator size : number of threads joined in this system
bool probe(int *source, int *tag)
probe function which waits a new message
int send(void *bufer, int count, const int datatypeId, int dest, const int tag)
send function for standard ParaData types
int ** token
index 0: token index 1: token color -1: green > 0: yellow ( termination origin solver number ) -2: re...
bool iProbe(int *source, int *tag)
iProbe function which checks if a new message is arrived or not
std::mutex rankLockMutex
mutex to access rank
int receive(void *bufer, int count, const int datatypeId, int source, const int tag)
receive function for standard ParaData types
void freeMem(void *buffer, int count, const int datatypeId)
free memory
std::ostream * getOstream()
get ostream pointer
virtual bool tagStringTableIsSetUpCoorectly()
check if tag string table (for debugging) set up correctly
bool tagTraceFlag
indicate if tags are traced or not
void * allocateMemAndCopy(const void *buffer, int count, const int datatypeId)
allocate memory and copy message
int uTypeSend(void *bufer, const int datatypeId, int dest, int tag)
User type send for created data type.
virtual const char * getTagString(int tag)
get Tag string for debugging
ParaSysTimer timer
system timer
int uTypeReceive(void **bufer, const int datatypeId, int source, int tag)
User type receive for created data type.
virtual void passToken(int rank)
pass token to from the rank to the next
MessageQueueTableElement ** messageQueueTable
message queue table
static const char * tagStringTable[]
tag name string table
int getRank()
get rank of caller's thread
virtual void solverDel(int rank)
delete Solver from this communicator
bool freeStandardTypes(MessageQueueElement *elem)
free memory
bool * sentMessage
sent message flag for synchronization
void copy(void *dest, const void *src, int count, int datatypeId)
copy message
virtual ~ParaCommCPP11()
destructor of this communicator
static thread_local int localRank
local thread rank
virtual void solverReInit(int rank, ParaParamSet *paraParamSet)
reinitializer of a specific Solver
virtual bool passTermToken(int rank)
pass termination token from the rank to the next
virtual void setToken(int rank, int *inToken)
set received token to this communicator
static ThreadsTableElement * threadsTable[ThreadTableSize]
threads table: index is thread rank
int bcast(void *buffer, int count, const int datatypeId, int root)
broadcast function for standard ParaData types
void waitSpecTagFromSpecSource(const int source, const int tag, int *receivedTag)
wait function for a specific tag from a specific source coming from
virtual void lcInit(ParaParamSet *paraParamSet)
initializer for LoadCoordinator
std::mutex * queueLockMutex
mutex for synchronization
std::mutex * tokenAccessLockMutex
mutex to access token
std::condition_variable * sentMsg
condition variable for synchronization
virtual bool waitToken(int rank)
wait token when UG runs with deterministic mode
class ParaRacingRampUpParamSet (parameter set for racing ramp-up)
class ParaSolverState (ParaSolver state object for notification message)
class ParaSolverTerminationState (Solver termination state in a ParaSolver)
void start(void)
start timer
Class of ThreadsTableElement.
std::ostream * getOstream()
getter of tag trace stream of this rank
static ScipParaParamSet * paraParamSet
static const int ParaUNSIGNED_LONG
static const int TagAckCompletion
static const int TagCompletionOfCalculation
static const int TagWinner
static const int ParaTaskType
static const int ParaInstanceType
static const int TagSolution
static const int ParaUNSIGNED_SHORT
static const int TagToken
static const int TagTaskReceived
static const int N_TH_TAGS
static const int TagInterruptRequest
static const int TagNotificationId
static const int ParaParamSetType
static const int TagIncumbentValue
static const int ParaLONG_DOUBLE
static const int TagTerminated
static const int ParaSolverStateType
static const int ParaCalculationStateType
static const int ParaLONG
static const int TagTerminateRequest
static const int ParaBYTE
static const int ParaSolverTerminationStateType
static const int ParaUNSIGNED
static const int TagRampUp
static const int TagSolverState
static const int TagHardTimeLimit
static const int ParaFLOAT
static const int ParaBOOL
static const int ParaCHAR
static const int UG_USER_TYPE_FIRST
user defined transfer data types
static const int TagDiffSubproblem
static const int ThreadTableSize
size of thread table : this limits the number of threads
static const int ParaSolutionType
static const int ParaRacingRampUpParamType
static const int TagParaInstance
static const int ParaSHORT
static const int TagTrace
static const int ParaUNSIGNED_LONG_LONG
static const int ParaLONG_LONG
static const int ParaUNSIGNED_CHAR
static const int ParaDOUBLE
static const int ParaSIGNED_CHAR
Base class for calculation state.
ParaComm extension for C++11 thread communication.
#define TAG_TRACE(call, fromTo, sourceDest, tag)
#define ABORT_LOGICAL_ERROR2(msg1, msg2)
#define THROW_LOGICAL_ERROR2(msg1, msg2)
#define THROW_LOGICAL_ERROR4(msg1, msg2, msg3, msg4)
Base class for initial statistics collecting class.
Base class for racing ramp-up parameter set.
This class has solver state to be transferred.
This class contains solver termination state which is transferred form Solver to LC.