Commit 79db2c0c authored by tonynsyde's avatar tonynsyde
Browse files

Added missing files

parent e282d379
# vtk DataFile Version 3.0
Graph
ASCII
DATASET POLYDATA
POINTS 16 float
0.500000 0.000000 0.000000
0.750000 0.000000 0.000000
0.500000 0.250000 0.000000
0.750000 0.250000 0.000000
0.000000 0.000000 0.000000
0.250000 0.000000 0.000000
0.000000 0.250000 0.000000
0.250000 0.250000 0.000000
0.500000 0.500000 0.000000
0.750000 0.500000 0.000000
0.500000 0.750000 0.000000
0.750000 0.750000 0.000000
0.000000 0.500000 0.000000
0.250000 0.500000 0.000000
0.000000 0.750000 0.000000
0.250000 0.750000 0.000000
VERTICES 16 32
1 0
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
LINES 48 144
2 0 1
2 0 5
2 0 2
2 1 0
2 1 3
2 2 3
2 2 7
2 2 8
2 2 0
2 3 2
2 3 9
2 3 1
2 4 5
2 4 6
2 5 0
2 5 4
2 5 7
2 6 7
2 6 12
2 6 4
2 7 2
2 7 6
2 7 13
2 7 5
2 8 9
2 8 13
2 8 10
2 8 2
2 9 8
2 9 11
2 9 3
2 10 11
2 10 15
2 10 8
2 11 10
2 11 9
2 12 13
2 12 14
2 12 6
2 13 8
2 13 12
2 13 15
2 13 7
2 14 15
2 14 12
2 15 10
2 15 14
2 15 13
POINT_DATA 16
VECTORS x float
0.500000 0.000000 0.000000
0.750000 0.000000 0.000000
0.500000 0.250000 0.000000
0.750000 0.250000 0.000000
0.000000 0.000000 0.000000
0.250000 0.000000 0.000000
0.000000 0.250000 0.000000
0.250000 0.250000 0.000000
0.500000 0.500000 0.000000
0.750000 0.500000 0.000000
0.500000 0.750000 0.000000
0.750000 0.750000 0.000000
0.000000 0.500000 0.000000
0.250000 0.500000 0.000000
0.000000 0.750000 0.000000
0.250000 0.750000 0.000000
SCALARS id unsigned_long
LOOKUP_TABLE default
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
SCALARS global_id unsigned_long
LOOKUP_TABLE default
2
3
6
7
0
1
4
5
10
11
14
15
8
9
12
13
CELL_DATA 64
SCALARS srcgid unsigned_long
LOOKUP_TABLE default
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
2
2
3
3
6
6
6
6
7
7
7
0
0
1
1
1
4
4
4
5
5
5
5
10
10
10
10
11
11
11
14
14
14
15
15
8
8
8
9
9
9
9
12
12
13
13
13
SCALARS dstgid unsigned_long
LOOKUP_TABLE default
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3
1
6
2
7
7
5
10
2
6
11
3
1
4
2
0
5
5
8
0
6
4
9
1
11
9
14
6
10
15
7
15
13
10
14
11
9
12
4
10
8
13
5
13
8
14
12
9
# vtk DataFile Version 3.0
Graph
ASCII
DATASET POLYDATA
POINTS 16 float
0.500000 0.000000 0.000000
0.750000 0.000000 0.000000
0.500000 0.250000 0.000000
0.750000 0.250000 0.000000
0.500000 0.500000 0.000000
0.750000 0.500000 0.000000
0.000000 0.750000 0.000000
0.000000 0.500000 0.000000
0.000000 0.000000 0.000000
0.250000 0.000000 0.000000
0.000000 0.250000 0.000000
0.250000 0.250000 0.000000
0.500000 0.750000 0.000000
0.750000 0.750000 0.000000
0.250000 0.500000 0.000000
0.250000 0.750000 0.000000
VERTICES 16 32
1 0
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
LINES 48 144
2 0 1
2 0 9
2 0 2
2 1 0
2 1 3
2 2 3
2 2 11
2 2 4
2 2 0
2 3 2
2 3 5
2 3 1
2 4 5
2 4 14
2 4 12
2 4 2
2 5 4
2 5 13
2 5 3
2 6 15
2 6 7
2 7 14
2 7 6
2 7 10
2 8 9
2 8 10
2 9 0
2 9 8
2 9 11
2 10 11
2 10 7
2 10 8
2 11 2
2 11 10
2 11 14
2 11 9
2 12 13
2 12 15
2 12 4
2 13 12
2 13 5
2 14 4
2 14 7
2 14 15
2 14 11
2 15 12
2 15 6
2 15 14
POINT_DATA 16
VECTORS x float
0.500000 0.000000 0.000000
0.750000 0.000000 0.000000
0.500000 0.250000 0.000000
0.750000 0.250000 0.000000
0.500000 0.500000 0.000000
0.750000 0.500000 0.000000
0.000000 0.750000 0.000000
0.000000 0.500000 0.000000
0.000000 0.000000 0.000000
0.250000 0.000000 0.000000
0.000000 0.250000 0.000000
0.250000 0.250000 0.000000
0.500000 0.750000 0.000000
0.750000 0.750000 0.000000
0.250000 0.500000 0.000000
0.250000 0.750000 0.000000
SCALARS id unsigned_long
LOOKUP_TABLE default
0
1
2
3
5
6
7
4
8
9
10
11
12
13
14
15
SCALARS global_id unsigned_long
LOOKUP_TABLE default
2
3
6
7
10
11
12
8
0
1
4
5
14
15
9
13
CELL_DATA 64
SCALARS srcgid unsigned_long
LOOKUP_TABLE default
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
2
2
3
3
6
6
6
6
7
7
7
10
10
10
10
11
11
11
12
12
8
8
8
0
0
1
1
1
4
4
4
5
5
5
5
14
14
14
15
15
9
9
9
9
13
13
13
SCALARS dstgid unsigned_long
LOOKUP_TABLE default
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3
1
6
2
7
7
5
10
2
6
11
3
11
9
14
6
10
15
7
13
8
9
12
4
1
4
2
0
5
5
8
0
6
4
9
1
15
13
10
14
11
10
8
13
5
14
12
9
/*
* DLB.hpp
*
* Created on: Nov 20, 2015
* Author: Antonio Leo
*/
#ifndef SRC_DECOMPOSITION_DLB_HPP_
#define SRC_DECOMPOSITION_DLB_HPP_
//! Time structure for statistical purposes
typedef struct
{
size_t simulationStartTime = 0;
size_t simulationEndTime;
double timeStep = 0.1;
size_t iterationStartTime;
size_t iterationEndTime;
} Times;
/*! Class that implements the two heuristics to determine when a re-balance of the distribution is needed.
*
* Used heuristics are: SAR and Un-balance Threshold (Default)\n
*
* To chose the heuristic use the method setHeuristic(Heuristic)
*
* In the SAR heuristic the following formula is applied:\n
* \f$W_{n} = \frac{\sum_{j=1}^{n} (T_{max}(j) - T_{avg}(j)) + C} {n}\f$
*
* \f$T_{max}(j)\f$ – wall-clock time of bottleneck process in time step j\n
* \f$T_{avg}(j)\f$ – average wall-clock time for time step j over all processes\n
* \f$C\f$ – cost of re-decomposing the problem\n
* \f$n\f$ – number of time steps since last re-decomposition\n
* \n
* For small n, load balance is good and W decreases since C is amortized over an increasing number of time steps.
* As the accumulated idle time starts to dominate, W starts to rise. At this point, C has been fully amortized.
* Re-decompose when \f$W_{n} > W_{n-1}\f$\n
*
* In the Un-balance Threshold heuristic the re-balance is triggered when the un-balance level exceeds a certain level.
* Levels can be chosen in the ThresholdLevel type.
*/
class DLB
{
public:
//! Type of DLB heuristics
enum Heuristic
{
SAR_HEURISTIC, UNBALANCE_THRLD
};
//! Level of un-balance needed to trigger the re-balance
enum ThresholdLevel
{
THRLD_LOW = 5, THRLD_MEDIUM = 7, THRLD_HIGH = 10
};
private:
//! Runtime virtual cluster machine
Vcluster & v_cl;
//! Structure that will contain all the timings
Times timeInfo;
//! Wn for SAR heuristic
float w_n = -1;
//! Computation cost for SAR heuristic
float c_c = 5;
//! Number of time-steps since the previous DLB
size_t n_ts = 1;
//! Idle time accumulated so far, needed for SAR heuristic
float i_time = 0;
//! Vector to collect all timings
openfpm::vector<long> times;
//! Type of the heuristic to use
Heuristic heuristic = UNBALANCE_THRLD;
//! Un-balance value
float unbalance = -1;
//! Threshold value
ThresholdLevel thl = THRLD_MEDIUM;
/*! \brief Function that gather times informations and decides if a rebalance is needed it uses the SAR heuristic
*
* \param t
*
*/
inline bool SAR()
{
long t = timeInfo.iterationEndTime - timeInfo.iterationStartTime;
float t_max = t, t_avg = t;
// Exchange time informations through processors
v_cl.max(t_max);
v_cl.sum(t_avg);
v_cl.execute();
t_avg /= v_cl.getProcessingUnits();
// add idle time to vector