56 double *node_solutiontimes =
new double [ nproc ];
57 double *node_relcomppowers =
new double [ nproc ];
58 double *node_equivelements =
new double [ nproc ];
59 double min_st, max_st;
60 double relWallClockImbalance;
61 double absWallClockImbalance;
62 double neqelems, sum_relcomppowers;
64 if ( node_solutiontimes == NULL ) {
65 OOFEM_ERROR(
"failed to allocate node_solutiontimes array");
68 if ( node_relcomppowers == NULL ) {
69 OOFEM_ERROR(
"failed to allocate node_relcomppowers array");
72 if ( node_equivelements == NULL ) {
73 OOFEM_ERROR(
"failed to allocate node_equivelements array");
84 if ( perturbedStep.test( tStep->
giveNumber() ) ) {
98 MPI_Allgather(& mySolutionTime, 1, MPI_DOUBLE, node_solutiontimes, 1, MPI_DOUBLE, MPI_COMM_WORLD);
101 for (
int i = 0; i < nproc; i++ ) {
108 min_st = max_st = node_solutiontimes [ 0 ];
109 for (
int i = 0; i < nproc; i++ ) {
110 min_st =
min(min_st, node_solutiontimes [ i ]);
111 max_st =
max(max_st, node_solutiontimes [ i ]);
114 absWallClockImbalance = ( max_st - min_st );
116 relWallClockImbalance = ( ( max_st - min_st ) / min_st );
118 relWallClockImbalance = 0.0;
126 for (
int ie = 1; ie <= nelem; ie++ ) {
135 MPI_Allgather(& neqelems, 1, MPI_DOUBLE, node_equivelements, 1, MPI_DOUBLE, MPI_COMM_WORLD);
140 for (
int i = 0; i < nproc; i++ ) {
141 node_relcomppowers [ i ] = node_equivelements [ i ] / node_solutiontimes [ i ];
145 sum_relcomppowers = 0.0;
146 for (
int i = 0; i < nproc; i++ ) {
147 sum_relcomppowers += node_relcomppowers [ i ];
150 for (
int i = 0; i < nproc; i++ ) {
151 nodeWeights(i) = node_relcomppowers [ i ] / sum_relcomppowers;
157 for (
int i = 0; i < nproc; i++ ) {
165 for (
int i = 0; i < nproc; i++ ) {
175 delete[] node_solutiontimes;
176 delete[] node_relcomppowers;
177 delete[] node_equivelements;
184 double procWeight, sumWeight = 0.0, *procWeights =
new double [ nproc ];
188 OOFEM_LOG_RELEVANT(
"[%d] WallClockLoadBalancerMonitor: processing weight overriden by value=%e\n", myrank, procWeight);
191 MPI_Allgather(& procWeight, 1, MPI_DOUBLE, procWeights, 1, MPI_DOUBLE, MPI_COMM_WORLD);
192 for (
int i = 0; i < nproc; i++ ) {
194 sumWeight += procWeights [ i ];
197 delete[] procWeights;
199 if ( fabs(sumWeight - 1.0) > 1.0e-10 ) {
200 OOFEM_ERROR(
"[%d] processing weights do not sum to 1.0 (sum = %e)\n", sumWeight);
203 OOFEM_LOG_RELEVANT(
"[%d] LoadBalancer: wall clock imbalance rel=%.2f\%,abs=%.2fs, recovering load\n", myrank, 100 * relWallClockImbalance, absWallClockImbalance);
206 OOFEM_LOG_RELEVANT(
"[%d] LoadBalancer: wall clock imbalance rel=%.2f\%,abs=%.2fs, continuing\n", myrank, 100 * relWallClockImbalance, absWallClockImbalance);
217 OOFEM_LOG_RELEVANT(
"[%d] LoadBalancer: wall clock imbalance rel=%.2f\%,abs=%.2fs, recovering load\n", myrank, 100 * relWallClockImbalance, absWallClockImbalance);
220 OOFEM_LOG_RELEVANT(
"[%d] LoadBalancer: wall clock imbalance rel=%.2f\%,abs=%.2fs, continuing\n", myrank, 100 * relWallClockImbalance, absWallClockImbalance);
249 OOFEM_ERROR(
"mismatch size of lbrecoveredsteps and lbprocessingweights");
double & at(int i)
Coefficient access function.
int max(int i, int j)
Returns bigger value form two given decimals.
double relWallClockImbalanceTreshold
Declares min abs imbalance to perform relative imbalance check.
void clear()
Clears receiver (zero size).
#define _IFT_WallClockLoadBalancerMonitor_abswct
int giveNumberOfProcesses() const
Returns the number of collaborating processes.
int giveNumberOfElements() const
Returns number of elements in domain.
#define _IFT_WallClockLoadBalancerMonitor_minwct
#define OOFEM_LOG_RELEVANT(...)
double perturbFactor
Perturbing factor.
FloatArray processingWeights
processing weights for lb recovery.
REGISTER_LoadBalancerMonitor(WallClockLoadBalancerMonitor)
LoadBalancerDecisionType decide(TimeStep *)
Returns flag indicating whether rebalancing is necessary; should update node weights as well...
int giveNumber()
Returns receiver's number.
Element * giveElement(int n)
Service for accessing particular domain fe element.
#define _IFT_WallClockLoadBalancerMonitor_lbstep
void clear()
Clears the array (zero size).
double getWtime(EngngModelTimerType t)
Returns elapsed wall clock time.
double minAbsWallClockImbalanceTreshold
bool staticNodeWeightFlag
std::list< Range > perturbedSteps
List of steps with perturbed balancing.
#define _IFT_WallClockLoadBalancerMonitor_relwct
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
#define _IFT_WallClockLoadBalancerMonitor_processingweights
elementParallelMode giveParallelMode() const
Return elementParallelMode of receiver.
IRResultType
Type defining the return values of InputRecord reading operations.
virtual double predictRelativeComputationalCost()
Returns the weight representing relative computational cost of receiver The reference element is tria...
#define _IFT_WallClockLoadBalancerMonitor_perturbfactor
int giveRank() const
Returns domain rank in a group of collaborating processes (0..groupSize-1)
Element in active domain is only mirror of some remote element.
IntArray recoveredSteps
list of step at which to performed lb recovery.
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
int min(int i, int j)
Returns smaller value from two given decimals.
Domain * giveDomain()
Returns reference to its domain.
int giveSize() const
Returns the size of receiver.
#define _IFT_WallClockLoadBalancerMonitor_recoveredsteps
the oofem namespace is to define a context or scope in which all oofem names are defined.
#define _IFT_WallClockLoadBalancerMonitor_perturbedsteps
double absWallClockImbalanceTreshold
virtual LoadBalancer * giveLoadBalancer()
Returns reference to receiver's load balancer.
EngngModelTimer * giveTimer()
Returns reference to receiver timer (EngngModelTimer).
Class representing solution step.
int findFirstIndexOf(int value) const
Finds index of first occurrence of given value in array.
int lbstep
The rebalancing done every lbstep.