Scippy

UG

Ubiquity Generator framework

paraSolverTerminationState.h
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 paraSolverTerminationState.h
27  * @brief This class contains solver termination state which is transferred form Solver to LC.
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 #ifndef __PARA_SOLVER_TERMINATION_STATE_H__
38 #define __PARA_SOLVER_TERMINATION_STATE_H__
39 
40 #include "paraComm.h"
41 #include "paraInitiator.h"
42 #ifdef UG_WITH_ZLIB
43 #include "gzstream.h"
44 #endif
45 
46 namespace UG
47 {
48 
49 ///
50 /// class ParaSolverTerminationState
51 /// (Solver termination state in a ParaSolver)
52 ///
54 {
55 protected:
56 
57  int interrupted; ///< indicate that this solver is interrupted or not.
58  ///< 0: not interrupted,
59  ///< 1: interrupted,
60  ///< 2: checkpoint,
61  ///< 3: racing-ramp up
62  int rank; ///< rank of this solver
63  ///-------------------------------------
64  /// Counters related to this ParaSolver
65  ///-------------------------------------
66  int nParaTasksReceived; ///< number of ParaTasks received in this ParaSolver
67  int nParaTasksSolved; ///< number of ParaTasks solved ( received ) in this ParaSolvere
68  ///----------------------
69  /// times of this solver
70  ///----------------------
71  double runningTime; ///< this solver running time
72  double idleTimeToFirstParaTask; ///< idle time to start solving the first ParaTask
73  double idleTimeBetweenParaTasks; ///< idle time between ParaTasks processing
74  double idleTimeAfterLastParaTask; ///< idle time after the last ParaTask was solved
75  double idleTimeToWaitNotificationId; ///< idle time to wait notification Id messages
76  double idleTimeToWaitAckCompletion; ///< idle time to wait ack completion message
77  double idleTimeToWaitToken; ///< idle time to wait token
78  ///-----------------------------
79  /// times for root task process
80  ///-----------------------------
81  double detTime; ///< deterministic time, -1: should be non-deterministic
82 
83 public:
84 
85  ///
86  /// default constructor
87  ///
89  )
90  : interrupted(-1),
91  rank(-1),
92  nParaTasksReceived(-1),
93  nParaTasksSolved(-1),
94  runningTime(0.0),
95  idleTimeToFirstParaTask(0.0),
96  idleTimeBetweenParaTasks(0.0),
97  idleTimeAfterLastParaTask(0.0),
98  idleTimeToWaitNotificationId(0.0),
99  idleTimeToWaitAckCompletion(0.0),
100  idleTimeToWaitToken(0.0),
101  detTime(-1.0)
102  {
103  }
104 
105  ///
106  /// constructor
107  ///
109  int inInterrupted, ///< indicate that this solver is interrupted or not.
110  ///< 0: not interrupted,
111  ///< 1: interrupted
112  ///< 2: checkpoint,
113  ///< 3: racing-ramp up
114  int inRank, ///< rank of this solver
115  int inNParaTasksReceived, ///< number of ParaTasks received in this ParaSolver
116  int inNParaTasksSolved, ///< number of ParaTasks solved ( received ) in this ParaSolver
117  double inRunningTime, ///< this solver running time
118  double inIdleTimeToFirstParaTask, ///< idle time to start solving the first ParaTask
119  double inIdleTimeBetweenParaTasks, ///< idle time between ParaTasks processing
120  double inIddleTimeAfterLastParaTask, ///< idle time after the last ParaTask was solved
121  double inIdleTimeToWaitNotificationId, ///< idle time to wait notification Id messages
122  double inIdleTimeToWaitAckCompletion, ///< idle time to wait ack completion message
123  double inIdleTimeToWaitToken, ///< idle time to wait token
124  double inDetTime ///< deterministic time, -1: should be non-deterministic
125  )
126  : interrupted(inInterrupted),
127  rank(inRank),
128  nParaTasksReceived(inNParaTasksReceived),
129  nParaTasksSolved(inNParaTasksSolved),
130  runningTime(inRunningTime),
131  idleTimeToFirstParaTask(inIdleTimeToFirstParaTask),
132  idleTimeBetweenParaTasks(inIdleTimeBetweenParaTasks),
133  idleTimeAfterLastParaTask(inIddleTimeAfterLastParaTask),
134  idleTimeToWaitNotificationId(inIdleTimeToWaitNotificationId),
135  idleTimeToWaitAckCompletion(inIdleTimeToWaitAckCompletion),
136  idleTimeToWaitToken(inIdleTimeToWaitToken),
137  detTime(inDetTime)
138  {
139  }
140 
141  ///
142  /// destructor
143  ///
145  )
146  {
147  }
148 
149  ///
150  /// stringfy ParaSolverTerminationState object
151  /// @return string to show inside of ParaSolverTerminationState object
152  ///
153  virtual std::string toString(
154  ParaInitiator *initiator ///< pointer to ParaInitiator object
155  ) = 0;
156 
157  ///
158  /// getter of interrupted flag
159  /// @return true if it is interrupted, false otherwise
160  ///
162  )
163  {
164  return interrupted;
165  }
166 
167  ///
168  /// getter of deterministic time
169  /// @return deterministic time
170  ///
172  )
173  {
174  return detTime;
175  }
176 
177 #ifdef UG_WITH_ZLIB
178 
179  ///
180  /// write ParaSolverTerminationState to checkpoint file
181  ///
182  virtual void write(
183  gzstream::ogzstream &out ///< gzstream to output
184  ) = 0;
185 
186  ///
187  /// read ParaSolverTerminationState from checkpoint file
188  ///
189  virtual bool read(
190  ParaComm *comm, ///< communicator used
191  gzstream::igzstream &in ///< gzstream to input
192  ) = 0;
193 
194 #endif
195 
196  ///
197  /// send this object
198  /// @return always 0 (for future extensions)
199  ///
200  virtual void send(
201  ParaComm *comm, ///< communicator used
202  int destination, ///< destination rank
203  int tag ///< TagTerminated
204  ) = 0;
205 
206  ///
207  /// receive this object
208  /// @return always 0 (for future extensions)
209  ///
210  virtual void receive(
211  ParaComm *comm, ///< communicator used
212  int source, ///< source rank
213  int tag ///< TagTerminated
214  ) = 0;
215 
216 };
217 
218 }
219 
220 #endif // __PARA_SOLVER_TERMINATION_STATE_H__
221 
int interrupted
indicate that this solver is interrupted or not. 0: not interrupted, 1: interrupted, 2: checkpoint, 3: racing-ramp up
virtual std::string toString(ParaInitiator *initiator)=0
stringfy ParaSolverTerminationState object
static ScipParaCommTh * comm
Definition: fscip.cpp:73
int getInterruptedMode()
getter of interrupted flag
ParaSolverTerminationState(int inInterrupted, int inRank, int inNParaTasksReceived, int inNParaTasksSolved, double inRunningTime, double inIdleTimeToFirstParaTask, double inIdleTimeBetweenParaTasks, double inIddleTimeAfterLastParaTask, double inIdleTimeToWaitNotificationId, double inIdleTimeToWaitAckCompletion, double inIdleTimeToWaitToken, double inDetTime)
constructor
int rank
rank of this solver Counters related to this ParaSolver
double getDeterministicTime()
getter of deterministic time
int nParaTasksReceived
number of ParaTasks received in this ParaSolver
int nParaTasksSolved
number of ParaTasks solved ( received ) in this ParaSolvere times of this solver
virtual void receive(ParaComm *comm, int source, int tag)=0
receive this object
Class for initiator.
Definition: paraInitiator.h:62
double idleTimeToWaitAckCompletion
idle time to wait ack completion message
double idleTimeToFirstParaTask
idle time to start solving the first ParaTask
double idleTimeAfterLastParaTask
idle time after the last ParaTask was solved
double runningTime
this solver running time
Base class of communicator for UG Framework.
virtual void send(ParaComm *comm, int destination, int tag)=0
send this object
class ParaSolverTerminationState (Solver termination state in a ParaSolver)
double idleTimeToWaitNotificationId
idle time to wait notification Id messages
void read(ParaComm *comm, const char *filename)
read ParaParams from file
ParaSolverTerminationState()
default constructor
Base class of initiator that maintains original problem and incumbent solution.
double detTime
deterministic time, -1: should be non-deterministic
double idleTimeToWaitToken
idle time to wait token times for root task process
Base class of communicator object.
Definition: paraComm.h:101
double idleTimeBetweenParaTasks
idle time between ParaTasks processing