61ParaCommCPP11::localRank = -1;
64ParaCommCPP11::tagStringTable[] = {
77 TAG_STR(TagRacingRampUpParamSets),
86ParaCommCPP11::init(
int argc,
char **argv )
93 for(
int i = 1; i < argc; i++ )
95 if( strcmp(argv[i],
"-sth") == 0 )
99 comSize = atoi(
const_cast<const char*
>(argv[i]));
102 std::cerr <<
"missing the number of solver threads after parameter '-sth'" << std::endl;
117 GetSystemInfo(&sysinfo);
118 comSize = sysinfo.dwNumberOfProcessors + 1;
120 comSize = sysconf(_SC_NPROCESSORS_CONF) + 1;
126 for(
int i = 0; i <
comSize; i++ )
128 token[i] =
new int[2];
147 for(
int i = 0; i < (
comSize + 1 ); i++ )
221 if(
token[rank][0] == rank )
229 probe(&source, &receivedTag);
230 TAG_TRACE (Probe, From, source, receivedTag);
231 if( source == 0 && receivedTag ==
TagToken )
234 assert(
token[rank][0] == rank );
251 assert(
token[rank][0] == rank && rank != 0 );
264 if( rank ==
token[rank][0] )
275 if(
token[rank][1] == -2 )
293 assert( rank == 0 || ( rank != 0 && inToken[0] == rank ) );
294 token[rank][0] = inToken[0];
295 token[rank][1] = inToken[1];
311 for(
int i = 0; i <
comSize; i++ )
318 for(
int i = 0; i < (
comSize + 1); i++)
370 if( count == 0 )
return newBuf;
376 newBuf =
new char[count];
377 memcpy(newBuf, buffer, (
unsigned long int)
sizeof(
char)*count);
382 newBuf =
new short[count];
383 memcpy(newBuf, buffer, (
unsigned long int)
sizeof(
short)*count);
388 newBuf =
new int[count];
389 memcpy(newBuf, buffer, (
unsigned long int)
sizeof(
int)*count);
394 newBuf =
new long[count];
395 memcpy(newBuf, buffer, (
unsigned long int)
sizeof(
long)*count);
400 newBuf =
new unsigned char[count];
401 memcpy(newBuf, buffer, (
unsigned long int)
sizeof(
unsigned char)*count);
406 newBuf =
new unsigned short[count];
407 memcpy(newBuf, buffer, (
unsigned long int)
sizeof(
unsigned short)*count);
412 newBuf =
new unsigned int[count];
413 memcpy(newBuf, buffer, (
unsigned long int)
sizeof(
unsigned int)*count);
418 newBuf =
new unsigned long[count];
419 memcpy(newBuf, buffer, (
unsigned long int)
sizeof(
unsigned long)*count);
424 newBuf =
new float[count];
425 memcpy(newBuf, buffer, (
unsigned long int)
sizeof(
float)*count);
430 newBuf =
new double[count];
431 memcpy(newBuf, buffer, (
unsigned long int)
sizeof(
double)*count);
436 newBuf =
new long double[count];
437 memcpy(newBuf, buffer, (
unsigned long int)
sizeof(
long double)*count);
442 newBuf =
new char[count];
443 memcpy(newBuf, buffer, (
unsigned long int)
sizeof(
char)*count);
448 newBuf =
new char[count];
449 memcpy(newBuf, buffer, (
unsigned long int)
sizeof(
char)*count);
454 newBuf =
new long long[count];
455 memcpy(newBuf, buffer, (
unsigned long int)
sizeof(
long long)*count);
460 newBuf =
new unsigned long long[count];
461 memcpy(newBuf, buffer, (
unsigned long int)
sizeof(
unsigned long long)*count);
466 newBuf =
new bool[count];
467 memcpy(newBuf, buffer, (
unsigned long int)
sizeof(
bool)*count);
479 void *dest,
const void *src,
int count,
int datatypeId
483 if( count == 0 )
return;
489 memcpy(dest, src, (
unsigned long int)
sizeof(
char)*count);
494 memcpy(dest, src, (
unsigned long int)
sizeof(
short)*count);
499 memcpy(dest, src, (
unsigned long int)
sizeof(
int)*count);
504 memcpy(dest, src, (
unsigned long int)
sizeof(
long)*count);
509 memcpy(dest, src, (
unsigned long int)
sizeof(
unsigned char)*count);
514 memcpy(dest, src, (
unsigned long int)
sizeof(
unsigned short)*count);
519 memcpy(dest, src, (
unsigned long int)
sizeof(
unsigned int)*count);
524 memcpy(dest, src, (
unsigned long int)
sizeof(
unsigned long)*count);
529 memcpy(dest, src, (
unsigned long int)
sizeof(
float)*count);
534 memcpy(dest, src, (
unsigned long int)
sizeof(
double)*count);
539 memcpy(dest, src, (
unsigned long int)
sizeof(
long double)*count);
544 memcpy(dest, src, (
unsigned long int)
sizeof(
char)*count);
549 memcpy(dest, src, (
unsigned long int)
sizeof(
char)*count);
554 memcpy(dest, src, (
unsigned long int)
sizeof(
long long)*count);
559 memcpy(dest, src, (
unsigned long int)
sizeof(
unsigned long long)*count);
564 memcpy(dest, src, (
unsigned long int)
sizeof(
bool)*count);
581 if( count == 0 )
return;
587 delete []
static_cast<char *
>(buffer);
592 delete []
static_cast<short *
>(buffer);
597 delete []
static_cast<int *
>(buffer);
602 delete []
static_cast<long *
>(buffer);
607 delete []
static_cast<unsigned char *
>(buffer);
612 delete []
static_cast<unsigned short *
>(buffer);
617 delete []
static_cast<unsigned int *
>(buffer);
622 delete []
static_cast<unsigned long *
>(buffer);
627 delete []
static_cast<float *
>(buffer);
632 delete []
static_cast<double *
>(buffer);
637 delete []
static_cast<long double *
>(buffer);
642 delete []
static_cast<char *
>(buffer);
647 delete []
static_cast<char *
>(buffer);
652 delete []
static_cast<long long *
>(buffer);
657 delete []
static_cast<unsigned long long *
>(buffer);
662 delete []
static_cast<bool *
>(buffer);;
755 const int datatypeId,
765 send(buffer, count, datatypeId, i, -1);
771 receive(buffer, count, datatypeId, root, -1);
780 const int datatypeId,
799 const int datatypeId,
815 copy( buffer, elem->
getData(), count, datatypeId );
840 (*receivedTag) = tag;
842 TAG_TRACE (Probe, From, source, *receivedTag);
904 const int datatypeId,
921 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
Abstract interface for calculation state in a ParaSolver. Holds no data; derived classes own the fiel...
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.