Scippy

UG

Ubiquity Generator framework

bbParaLoadCoordinatorTerminationState.cpp
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and software framework */
4 /* UG --- Ubquity Generator Framework */
5 /* */
6 /* Copyright Written by Yuji Shinano <shinano@zib.de>, */
7 /* Copyright (C) 2021 by Zuse Institute Berlin, */
8 /* licensed under LGPL version 3 or later. */
9 /* Commercial licenses are available through <licenses@zib.de> */
10 /* */
11 /* This code is free software; you can redistribute it and/or */
12 /* modify it under the terms of the GNU Lesser General Public License */
13 /* as published by the Free Software Foundation; either version 3 */
14 /* of the License, or (at your option) any later version. */
15 /* */
16 /* This program is distributed in the hope that it will be useful, */
17 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
18 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
19 /* GNU Lesser General Public License for more details. */
20 /* */
21 /* You should have received a copy of the GNU Lesser General Public License */
22 /* along with this program. If not, see <http://www.gnu.org/licenses/>. */
23 /* */
24 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
25 
26 /**@file paraLoadCoordinatorTerminationState.cpp
27  * @brief Load coordinator termination state.
28  * @author Yuji Shinano
29  *
30  *
31  *
32  */
33 
34 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
35 
36 
37 #include <sstream>
39 
40 using namespace UG;
41 
42 /** stringfy ParaCalculationState */
43 std::string
45  )
46 {
47  std::ostringstream s;
48  if( isCheckpointState )
49  {
50  s << "######### LoadCoordinator Rank = " << rank << " is at checkpoint. #########" << std::endl;
51  }
52  else
53  {
54  s << "######### LoadCoordinator Rank = " << rank << " is terminated. #########" << std::endl;
55  }
56 
57  s << "#=== The number of ParaNodes received = " << nReceived << std::endl;
58  s << "#=== The number of ParaNodes sent = " << nSent << std::endl;
59  s << "#=== ( # sent back immediately = " << nSentBackImmediately << ", # failed to send back = " << nFailedToSendBack << " )" << std::endl;
60  s << "#=== ( # sent back immediately ( another node ) = " << nSentBackImmediatelyAnotherNode
61  << ", # failed to send back ( another node ) = " << nFailedToSendBackAnotherNode << " )" << std::endl;
62  s << "#=== The number of ParaNodes deleted in LoadCoordinator = " << (nDeletedInLc + nDeletedByMerging)
63  << " ( by merging: " << nDeletedByMerging << " )" << std::endl;
64  s << "#=== Maximum usage of node pool = " << nMaxUsageOfNodePool << ", initial p = " << nInitialP << ", maximum multiplier = " << mMaxCollectingNodes << std::endl;
65  if( nNodesInNodePool )
66  {
67  s << "#=== LoadCoodibator NodePool is not empty. "
68  << nNodesInNodePool << " nodes remained." << std::endl;
69  }
71  {
72  s << "#=== Solvers have nodes. "
73  << nNodesLeftInAllSolvers << " nodes left in Solvers." << std::endl;
74  }
75  if( isCheckpointState )
76  {
77  s << "#=== Current global best dual bound value = " << externalGlobalBestDualBoundValue
78  << "( internal value = " << globalBestDualBoundValue << " )" << std::endl;
79  s << "#=== Idle time to checkpoint of this LoadCoordinator = " << idleTime << std::endl;
80  s << "#=== Elapsed time to checkpoint of this LoadCoordinator = " << runningTime << std::endl;
81  }
82  else
83  {
84  s << "#=== Idle time to terminate this LoadCoordinator = " << idleTime << std::endl;
85  s << "#=== Elapsed time to terminate this LoadCoordinator = " << runningTime << std::endl;
86  }
87  s << "#=== Time used for merging nodes: add = " << addingNodeToMergeStructTime
88  << ", gen. = " << generateMergeNodesCandidatesTime
89  << ", regen. = " << regenerateMergeNodesCandidatesTime
90  << ", merge = " << mergeNodeTime << std::endl;
91  return s.str();
92 }
93 
94 #ifdef UG_WITH_ZLIB
95 void
96 BbParaLoadCoordinatorTerminationState::write(
97  gzstream::ogzstream &out
98  )
99 {
100  out.write((char *)&isCheckpointState, sizeof(bool));
101  out.write((char *)&rank, sizeof(int));
102  out.write((char *)&nWarmStart, sizeof(unsigned long long));
103  out.write((char *)&nSent, sizeof(unsigned long long));
104  out.write((char *)&nSentBackImmediately, sizeof(unsigned long long));
105  out.write((char *)&nSentBackImmediatelyAnotherNode, sizeof(unsigned long long));
106  out.write((char *)&nReceived, sizeof(unsigned long long));
107  out.write((char *)&nDeletedInLc, sizeof(unsigned long long));
108  out.write((char *)&nFailedToSendBack, sizeof(unsigned long long));
109  out.write((char *)&nFailedToSendBackAnotherNode, sizeof(unsigned long long));
110  out.write((char *)&nMaxUsageOfNodePool, sizeof(unsigned long long));
111  out.write((char *)&nNodesInNodePool, sizeof(unsigned long long));
112  out.write((char *)&nNodesLeftInAllSolvers, sizeof(unsigned long long));
113  out.write((char *)&globalBestDualBoundValue, sizeof(double));
114  out.write((char *)&externalGlobalBestDualBoundValue, sizeof(double));
115  out.write((char *)&idleTime, sizeof(double));
116  out.write((char *)&runningTime, sizeof(double));
117  out.write((char *)&addingNodeToMergeStructTime, sizeof(double));
118  out.write((char *)&generateMergeNodesCandidatesTime, sizeof(double));
119  out.write((char *)&regenerateMergeNodesCandidatesTime, sizeof(double));
120  out.write((char *)&mergeNodeTime, sizeof(double));
121 }
122 
123 bool
125  ParaComm *comm,
126  gzstream::igzstream &in
127  )
128 {
129  in.read((char *)&isCheckpointState, sizeof(bool));
130  if( in.eof() ) return false;
131  in.read((char *)&rank, sizeof(int));
132  in.read((char *)&nWarmStart, sizeof(unsigned long long));
133  in.read((char *)&nSent, sizeof(unsigned long long));
134  in.read((char *)&nSentBackImmediately, sizeof(unsigned long long));
135  in.read((char *)&nSentBackImmediatelyAnotherNode, sizeof(unsigned long long));
136  in.read((char *)&nReceived, sizeof(unsigned long long));
137  in.read((char *)&nDeletedInLc, sizeof(unsigned long long));
138  in.read((char *)&nFailedToSendBack, sizeof(unsigned long long));
139  in.read((char *)&nFailedToSendBackAnotherNode, sizeof(unsigned long long));
140  in.read((char *)&nMaxUsageOfNodePool, sizeof(unsigned long long));
141  in.read((char *)&nNodesInNodePool, sizeof(unsigned long long));
142  in.read((char *)&nNodesLeftInAllSolvers, sizeof(unsigned long long));
143  in.read((char *)&globalBestDualBoundValue, sizeof(double));
144  in.read((char *)&externalGlobalBestDualBoundValue, sizeof(double));
145  in.read((char *)&idleTime, sizeof(double));
146  in.read((char *)&runningTime, sizeof(double));
147  in.read((char *)&addingNodeToMergeStructTime, sizeof(double));
148  in.read((char *)&generateMergeNodesCandidatesTime, sizeof(double));
149  in.read((char *)&regenerateMergeNodesCandidatesTime, sizeof(double));
150  in.read((char *)&mergeNodeTime, sizeof(double));
151  return true;
152 }
153 
154 #endif
double generateMergeNodesCandidatesTime
time when merge ParaNode candidates are generated
std::string toString()
stringfy ParaCalculationState
static ScipParaCommTh * comm
Definition: fscip.cpp:73
unsigned long long nSentBackImmediately
Counters related to this ParaLoadCoordinator TODO: The numbers should be classified depending on solv...
unsigned long long nDeletedInLc
number of ParaNodes deleted in LC
double regenerateMergeNodesCandidatesTime
time when merge ParaNode candidates are regenerated
unsigned long long nFailedToSendBackAnotherNode
number of ParaNodes failed to send back after AnotherNode request
double addingNodeToMergeStructTime
time when a ParaNode is added to merge struct
double runningTime
this ParaLoadCoordinator running time
double externalGlobalBestDualBoundValue
global best dual bound value (external value)
unsigned long long nNodesInNodePool
number of nodes in ParaNodePool
double globalBestDualBoundValue
global best dual bound value (internal value)
bool isCheckpointState
indicate if this state is at checkpoint or not
unsigned long long nFailedToSendBack
number of ParaNodes failed to send back
unsigned long long nMaxUsageOfNodePool
maximum number of ParaNodes in ParaNodePool
unsigned long long nSent
number of ParaTasks sent from LC
void read(ParaComm *comm, const char *filename)
read ParaParams from file
unsigned long long nNodesLeftInAllSolvers
number of nodes left in all Solvers
unsigned long long mMaxCollectingNodes
maximum multiplier for the number of collecting nodes
unsigned long long nWarmStart
number of warm starts (restarts)
unsigned long long nReceived
number of ParaTasks received from Solvers
unsigned long long nDeletedByMerging
number of ParaNodes deleted by merging
unsigned long long nInitialP
initial p value, which indicates the number of good ParaNodes try to keep in LC
unsigned long long nSentBackImmediatelyAnotherNode
number of ParaNodes sent back immediately after AnotherNode request from LC
Base class of communicator object.
Definition: paraComm.h:101