Scippy

UG

Ubiquity Generator framework

paraSolverState.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 paraSolverState.h
27  * @brief This class has solver state to be transferred.
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_STATE_H__
38 #define __PARA_SOLVER_STATE_H__
39 
40 #include <cfloat>
41 #include "paraComm.h"
42 
43 namespace UG
44 {
45 
46 ///
47 /// class ParaSolverState
48 /// (ParaSolver state object for notification message)
49 ///
51 {
52 
53 protected:
54 
55  int racingStage; ///< if this value is 1, solver is in racing stage
56  unsigned int notificationId; ///< id for this notification
57  int lcId; ///< lc id of current ParaTask
58  int globalSubtreeIdInLc; ///< global subtree id of current ParaTask
59  double detTime; ///< deterministic time, -1: should be non-deterministic
60 
61 public:
62 
63  ///
64  /// default constructor
65  ///
67  )
68  : racingStage(0),
69  notificationId(0),
70  lcId(-1),
71  globalSubtreeIdInLc(-1),
72  detTime(-1.0)
73  {
74  }
75 
76  ///
77  /// copy constructor
78  ///
80  const ParaSolverState& paraSolverState
81  )
82  : racingStage(paraSolverState.racingStage),
83  notificationId(paraSolverState.notificationId),
84  lcId(paraSolverState.lcId),
85  globalSubtreeIdInLc(paraSolverState.globalSubtreeIdInLc),
86  detTime(paraSolverState.detTime)
87  {
88  }
89 
90  ///
91  /// constructor
92  ///
94  int inRacingStage, ///< if this value is 1, solver is in racing stage
95  unsigned int inNotificationId, ///< id for this notification
96  int inLcId, ///< lc id of current ParaTask
97  int inGlobalSubtreeIdInLc, ///< global subtree id of current ParaTask
98  double inDetTime ///< deterministic time, -1: should be non-deterministic
99  )
100  : racingStage(inRacingStage),
101  notificationId(inNotificationId),
102  lcId(inLcId),
103  globalSubtreeIdInLc(inGlobalSubtreeIdInLc),
104  detTime(inDetTime)
105  {
106  }
107 
108  ///
109  /// destractor
110  ///
112  )
113  {
114  }
115 
116  ///
117  /// getter of isRacingStage
118  /// @return true if the Solver notified this message is in racing stage, false otherwise
119  ///
121  )
122  {
123  return (racingStage == 1);
124  }
125 
126  ///
127  /// getter of notification id
128  /// @return notification id
129  ///
130  unsigned int getNotificaionId(
131  )
132  {
133  return notificationId;
134  }
135 
136  ///
137  /// getter of LoadCoordintor id
138  /// @return LoadCoordinator id
139  ///
140  int getLcId(
141  )
142  {
143  return lcId;
144  }
145 
146  ///
147  /// getter of global subtree id
148  /// @return global subtree id
149  ///
151  )
152  {
153  return globalSubtreeIdInLc;
154  }
155 
156  ///
157  /// getter of deterministic time
158  /// @return deterministic time
159  ///
161  )
162  {
163  return detTime;
164  }
165 
166  ///
167  /// stringfy ParaSolverState
168  /// @return string to show inside of ParaSolverState
169  ///
170  virtual std::string toString(
171  ) = 0;
172 
173  ///
174  /// send this object
175  /// @return always 0 (for future extensions)
176  ///
177  virtual void send(
178  ParaComm *comm, ///< communicator used
179  int destination, ///< destination rank
180  int tag ///< TagSolverState
181  ) = 0;
182 
183  ///
184  /// receive this object
185  /// @return always 0 (for future extensions)
186  ///
187  virtual void receive(
188  ParaComm *comm, ///< communicator used
189  int source, ///< source rank
190  int tag ///< TagSolverState
191  ) = 0;
192 
193 };
194 
195 }
196 
197 #endif // __PARA_SOLVER_STATE_H__
ParaSolverState(const ParaSolverState &paraSolverState)
copy constructor
class ParaSolverState (ParaSolver state object for notification message)
double getDeterministicTime()
getter of deterministic time
bool isRacingStage()
getter of isRacingStage
static ScipParaCommTh * comm
Definition: fscip.cpp:73
virtual ~ParaSolverState()
destractor
int globalSubtreeIdInLc
global subtree id of current ParaTask
virtual void receive(ParaComm *comm, int source, int tag)=0
receive this object
virtual std::string toString()=0
stringfy ParaSolverState
Base class of communicator for UG Framework.
double detTime
deterministic time, -1: should be non-deterministic
virtual void send(ParaComm *comm, int destination, int tag)=0
send this object
unsigned int getNotificaionId()
getter of notification id
int lcId
lc id of current ParaTask
int getGlobalSubtreeId()
getter of global subtree id
ParaSolverState()
default constructor
ParaSolverState(int inRacingStage, unsigned int inNotificationId, int inLcId, int inGlobalSubtreeIdInLc, double inDetTime)
constructor
int racingStage
if this value is 1, solver is in racing stage
int getLcId()
getter of LoadCoordintor id
Base class of communicator object.
Definition: paraComm.h:101
unsigned int notificationId
id for this notification