-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsparse_solve.ci
More file actions
69 lines (61 loc) · 2.73 KB
/
sparse_solve.ci
File metadata and controls
69 lines (61 loc) · 2.73 KB
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
mainmodule sparse_solve {
readonly CProxy_Main mainProxy;
mainchare Main {
entry Main(CkArgMsg *m);
entry [reductiontarget] void initDone(void);
entry [reductiontarget] void reportIn(void);
entry void validate(CkReductionMsg* msg);
};
message xValMsg { double xVal[]; };
array [1D] ColumnsSolve{
entry ColumnsSolve();
// initialize chare (e.g. matrix input)
entry void init() {
when getInput(int nzl, int nr, int nc, double data[nzl], int colInd[nzl], int rowInd[nr+1], bool dep[nr],
bool diag, int indn, int frs, int fMax, int rrs, int rMax)
serial {setInput(nzl, nr, nc, data, colInd, rowInd, dep, diag, indn, frs, fMax, rrs, rMax);}
when getDeps(int size, rowAttr deps[size]) serial {setDeps(size, deps);}
if(onDiagonalChare)
when getSection(CProxySection_ColumnsSolve nondiags, bool emptySec, CkGroupID mCastGrpId)
serial {setSection(nondiags, emptySec, mCastGrpId);}
serial { contribute(CkCallback(CkReductionTarget(Main, initDone), mainProxy)); }
};
// actual computation starts here
entry void start() {
// if this chare has some diagonal part of matrix
if (onDiagonalChare) {
// schedule this chare's independent computation with lower priority
serial { thisProxy[thisIndex].indepCompute(0, &CkEntryOptions().setQueueing(CK_QUEUEING_IFIFO).setPriority(10)); }
// "while" and "when" can happen in any order
overlap {
// while there are incomplete rows, receive data and compute
while (!finished) {
when receiveData(int size, double data[size], int rowInd[size])
serial {if(size>0) diagReceiveData(size, data, rowInd);}
}
// do serial independent computations scheduled above
when indepCompute(int a) serial {myIndepCompute();}
}
// if chare doesn't have diagonal part of matrix
} else {
// wait for x values
when getXvals(xValMsg* msg) serial {xVal=msg->xVal; nondiagCompute();}
// while there are incomplete rows, receive data and compute
while (!finished) {
when receiveData(int size, double data[size], int rowInd[size])
serial {nondiagReceiveData(size, data, rowInd);}
}
}
// solve is done, inform main chare
serial { contribute(CkCallback(CkReductionTarget(Main, reportIn), mainProxy)); }
};
entry void indepCompute(int a);
entry void getInput(int nzl, int nr, int nc, double data[nzl], int colInd[nzl], int rowInd[nr+1], bool dep[nr],
bool diag, int indn, int frs, int fMax, int rrs, int rMax);
entry void getDeps(int size, rowAttr deps[size]);
entry void getSection(CProxySection_ColumnsSolve, bool, CkGroupID mCastGrpId);
entry void getXvals(xValMsg* msg);
entry void receiveData(int size, double data[size], int rowInd[size]);
entry void sendResults();
};
};