-
Notifications
You must be signed in to change notification settings - Fork 1
/
Main.cc
112 lines (91 loc) · 3.04 KB
/
Main.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include <string>
#include "time.h"
#include "Main.h"
#include "Cell.h"
#include "Compute.h"
/* readonly */ CProxy_Main mainProxy;
/* readonly */ CProxy_Cell cellArray;
/* readonly */ CProxy_Compute computeArray;
/* readonly */ int cellArrayDimX;
/* readonly */ int cellArrayDimY;
/* readonly */ int cellArrayDimZ;
/* readonly */ int finalStepCount;
/* readonly */ int firstLdbStep;
/* readonly */ int ldbPeriod;
/* readonly */ int checkptFreq;
/* readonly */ int checkptStrategy;
/* readonly */ std::string logs;
/* readonly */ int bFactor;
// Entry point of Charm++ application
Main::Main(CkArgMsg* m) {
CkPrintf("\nLENNARD JONES MOLECULAR DYNAMICS START UP ...\n");
//set variable values to a default set
cellArrayDimX = CELLARRAY_DIM_X;
cellArrayDimY = CELLARRAY_DIM_Y;
cellArrayDimZ = CELLARRAY_DIM_Z;
finalStepCount = DEFAULT_FINALSTEPCOUNT;
firstLdbStep = DEFAULT_FIRST_LDB;
ldbPeriod = DEFAULT_LDB_PERIOD;
checkptFreq = DEFAULT_FT_PERIOD;
mainProxy = thisProxy;
bFactor = 4;
int numPes = CkNumPes();
int currPe = -1, pe;
int cur_arg = 1;
CkPrintf("\nInput Parameters...\n");
//read user parameters
//number of cells in each dimension
if (m->argc > cur_arg) {
cellArrayDimX=atoi(m->argv[cur_arg++]);
cellArrayDimY=atoi(m->argv[cur_arg++]);
cellArrayDimZ=atoi(m->argv[cur_arg++]);
CkPrintf("Cell Array Dimension X:%d Y:%d Z:%d of size %d %d %d\n",cellArrayDimX,cellArrayDimY,cellArrayDimZ,CELL_SIZE_X,CELL_SIZE_Y,CELL_SIZE_Z);
}
//number of steps in simulation
if (m->argc > cur_arg) {
finalStepCount=atoi(m->argv[cur_arg++]);
CkPrintf("Final Step Count:%d\n",finalStepCount);
}
//step after which load balancing starts
if (m->argc > cur_arg) {
firstLdbStep=atoi(m->argv[cur_arg++]);
CkPrintf("First LB Step:%d\n",firstLdbStep);
}
//periodicity of load balancing
if (m->argc > cur_arg) {
ldbPeriod=atoi(m->argv[cur_arg++]);
CkPrintf("LB Period:%d\n",ldbPeriod);
}
//periodicity of checkpointing
if (m->argc > cur_arg) {
checkptFreq=atoi(m->argv[cur_arg++]);
CkPrintf("FT Period:%d\n",checkptFreq);
}
checkptStrategy = 1;
//choose the checkpointing strategy use in disk checkpointing
if (m->argc > cur_arg) {
checkptStrategy = 0;
logs = m->argv[cur_arg];
}
CProxy_CellMap cellMap = CProxy_CellMap::ckNew(cellArrayDimX,
cellArrayDimY, cellArrayDimZ);
CkArrayOptions opts(cellArrayDimX, cellArrayDimY, cellArrayDimZ);
opts.setMap(cellMap);
//create a 3D Patch array (with a uniform distribution)
cellArray = CProxy_Cell::ckNew(opts);
//create an empty 6D computer array to be filled in by Cells
computeArray = CProxy_Compute::ckNew();
cellArray.createComputes();
CkPrintf("\nCells: %d X %d X %d .... created\n", cellArrayDimX,
cellArrayDimY, cellArrayDimZ);
delete m;
}
//constructor for chare object migration
Main::Main(CkMigrateMessage* msg): CBase_Main(msg) {
}
//pup routine incase the main chare moves, pack important information
void Main::pup(PUP::er &p) {
CBase_Main::pup(p);
__sdag_pup(p);
}
#include "leanmd.def.h"