30 #include "ComputeMoaMgr.decl.h"
35 #include "ComputeMgr.decl.h"
37 #define MIN_DEBUG_LEVEL 3
49 #ifdef OPENATOM_VERSION
76 printf(
"K1,K2,K3 = %d, %d, %d\n",
K1,
K2,
K3);
77 printf(
"order = %d\n",
order);
82 class ComputeMoaMgr :
public CBase_ComputeMoaMgr {
89 void initialize(CkQdMsg *);
91 void setCompute(
ComputeMoa *c) { moaCompute = c; }
93 void recvMoaData(
const MoaData &);
95 void initWorkers(CkQdMsg *);
96 void startWorkers(CkQdMsg *);
98 void recvQ(
int g,
int numgrids,
int nq,
float qgrid[nq], CkCallback doneMoa);
100 void recvB(
int K2_start,
int K2_end,
int K3_start,
int K3_end,
int K1_len,
int K2_len,
int K3_len,
double bm1[K1_len],
double bm2[K2_len],
double bm3[K3_len],
int order);
102 const MoaData &getMoaData()
const {
return moaData; }
105 CProxy_ComputeMoaMgr moaProxy;
110 CProxy_MoaPatch moaPatchProxy;
111 CProxy_MoaS moaSProxy;
113 Moa3Grid::Write qhwrit
114 Moa3Grid::Accum qhacc;
115 Moa3Grid::Read qhread;
116 Moa3Grid::Write shwrit;
117 Moa3Grid::Accum shacc;
118 Moa3Grid::Read shread;
119 Moa3Grid::Write bhwrit;
120 Moa1Grid::Read bhread;
131 class MoaS :
public CBase_MoaS {
134 MoaS(CkMigrateMessage *m) { }
139 Moa3Grid::Write shwrite;
140 Moa3Grid::Read qhread, bhread;
151 #ifdef OPENATOM_VERSION_DEBUG
152 CkPrintf(
"Instantiated ComputeMoa %d on PE: %d, at %f.\n", thisIndex, CkMyPe(), CkWallTimer() );
153 #endif //OPENATOM_VERSION_DEBUG
155 CProxy_ComputeMoaMgr::ckLocalBranch(
156 CkpvAccess(BOCclass_group).computeMoaMgr)->setCompute(
this);
167 #ifdef OPENATOM_VERSION_DEBUG
168 CkPrintf(
"Starting ComputeMoa::doWork() %d on PE: %d, at %f.\n", thisIndex, CkMyPe(), CkWallTimer() );
169 #endif //OPENATOM_VERSION_DEBUG
173 CProxy_ComputeMoaMgr moaProxy(CkpvAccess(BOCclass_group).computeMoaMgr);
174 moaS_Proxy[CkMyPe()].compute(
new CkQdMsg);
178 ComputeMoaMgr::ComputeMoaMgr() :
179 moaProxy(thisgroup), moaCompute(0)
181 #ifdef OPENATOM_VERSION_DEBUG
182 CkPrintf(
"Instantiating ComputeMoaMgr %d on PE: %d, at %f.\n", thisIndex, CkMyPe(), CkWallTimer() );
183 #endif //OPENATOM_VERSION_DEBUG
184 CkpvAccess(BOCclass_group).computeMoaMgr = thisgroup;
187 ComputeMoaMgr::~ComputeMoaMgr()
189 #ifdef OPENATOM_VERSION_DEBUG
190 CkPrintf(
"Destructing ComputeMoaMgr %d on PE: %d, at %f.\n", thisIndex, CkMyPe(), CkWallTimer() );
191 #endif //OPENATOM_VERSION_DEBUG
196 void ComputeMoaMgr::initialize(CkQdMsg *msg)
198 #ifdef OPENATOM_VERSION_DEBUG
199 CkPrintf(
"Initializing ComputeMoaMgr %d on PE: %d, at %f.\n", thisIndex, CkMyPe(), CkWallTimer() );
200 #endif //OPENATOM_VERSION_DEBUG
203 if (CkMyPe() != 0)
return;
215 int i, num_clients=0;
216 for (i=0;i<CkNumPes(), i++)
229 CkPrintf(
"global num clients = %d\n", p.
num_clients);
256 moaProxy.recvMoaData(moaData);
258 #ifdef OPENATOM_VERSION_DEBUG
259 CkPrintf(
"Initialized ComputeMoaMgr %d on PE: %d, at %f.\n", thisIndex, CkMyPe(), CkWallTimer() );
260 #endif //OPENATOM_VERSION_DEBUG
264 void ComputeMoaMgr::recvB(
int K2_start,
int K2_end,
int K3_start,
int K3_end,
int K1_len,
int K2_len,
int K3_len,
double bm1[K1_len],
double bm2[K2_len],
double bm3[K3_len],
int order)
266 #ifdef OPENATOM_VERSION_DEBUG
267 CkPrintf(
"Started recvB() %d on PE: %d, at %f.\n", thisIndex, CkMyPe(), CkWallTimer() );
268 #endif //OPENATOM_VERSION_DEBUG
275 p.
k1r[thisIndex].nx = 0;
276 p.
k1r[thisIndex].ny = K1_len;
277 p.
k2r[thisIndex].nx = K2_start;
278 p.
k2r[thisIndex].ny = K2_end;
279 p.
k3r[thisIndex].nx = K3_start;
280 p.
k3r[thisIndex].ny = k3_end;
282 p.
bh[thisIndex].enroll();
283 bhwrit = p.
bh[thisIndex].syncToWrite();
285 for ( j=0; j < K1_len; j++ ) {
286 bhwrit.set(j,K2_start,K3_start) = bm1[j];
287 for ( m=K2_start; m < K2_end; m++ ) {
288 bhwrit.set(j,m,K3_start) = bm2[m];
289 for ( n=K3_start; n < K3_end; n++ ) {
290 bhwrit.set(j,m,n) = bm3[n];
295 bhread = bhwrit.syncToRead();
297 p.
hasLB[thisIndex]=1;
302 void ComputeMoaMgr::recvQ(
int g,
int numgrids,
int nq,
float qgrid[nq], CkCallback doneMoa)
304 #ifdef OPENATOM_VERSION_DEBUG
305 CkPrintf(
"Started recvQ() %d on PE: %d, at %f.\n", thisIndex, CkMyPe(), CkWallTimer() );
306 #endif //OPENATOM_VERSION_DEBUG
312 Eqhacc = p.
qh[g].getInitialAccum();
316 int K1_len = p.
k1r[thisIndex].ny;
317 int K2s = p.
k2r[thisIndex].nx;
318 int K2e = p.
k2r[thisIndex].ny;
319 int K3s = p.
k3r[thisIndex].nx;
320 int K3e = p.
k3r[thisIndex].ny;
323 bhread = p.
bh[thisIndex].syncToRead();
331 for ( j=CkIndex(); j < K1_len; j++ ) {
332 qhwrit.set(j,K2s,K3s) = qgrid[j];
333 for ( m=K2s; m < K2e; m++ ) {
334 bhwrit.set(j,m,K3s) = qgrid[m];
335 for ( n=K3s; n < K3e; n++ ) {
336 bhwrit.set(j,m,n) = qgrid[n];
343 for ( i = 0; i <= nq ; i++) {
344 p.qhwrite[g][i] = qgrid[i];
349 p.
hasLQ[thisIndex]=1;
354 void ComputeMoaMgr::sendS2OA()
359 if (CkMyPe() != 0)
return;
361 #ifdef OPENATOM_VERSION_DEBUG
362 CkPrintf(
"Started sendS2OA() %d on PE: %d, at %f.\n", thisIndex, CkMyPe(), CkWallTimer() );
363 #endif //OPENATOM_VERSION_DEBUG
365 CProxy_CP_LargeSP_RhoGSpacePlane oaRGSP_Proxy;
367 CkCallback resumeMoa(CkIndex_ComputeMoaMgr::recvSGrid(), thishandle);
368 oaRGSP_Proxy[CkMyPe()].recvMDSg(g, ns, sg, resumeMoa);
372 void ComputeMoaMgr::recvSGrid(
int g,
int nq,
double oaSg[nq])
374 if (CkMyPe() != 0)
return;
375 #ifdef OPENATOM_VERSION_DEBUG
376 CkPrintf(
"Started recvSGrid() %d on PE: %d, at %f.\n", thisIndex, CkMyPe(), CkWallTimer() );
377 #endif //OPENATOM_VERSION_DEBUG
380 numgrids = p.numgrids;
385 void ComputeMoaMgr::initWorkers(CkQdMsg *msg)
389 if (CkMyPe() != 0)
return;
394 moaPatchProxy = CProxy_MoaPatch::ckNew();
395 #ifdef OPENATOM_VERSION_DEBUG
396 CkPrintf(
"Instantiated MoaPatch chare %d on PE: %d, at %f.\n", thisIndex, CkMyPe(), CkWallTimer() );
397 #endif // OPENATOM_VERSION_DEBUG
399 moaSProxy = CProxy_MoaS::ckNew(p.
qh[0], p.eh[0], p.num_energy_chares);
401 #ifdef OPENATOM_VERSION_DEBUG
402 CkPrintf(
"Created MoaS chare %d at PE: %d, at %f.\n", thisIndex, CkMyPe(), CkWallTimer() );
403 #endif // OPENATOM_VERSION_DEBUG
407 void ComputeMoaMgr::startWorkers(CkQdMsg *msg)
410 if (CkMyPe() != 0)
return;
412 #ifdef OPENATOM_VERSION_DEBUG
413 CkPrintf(
"Starting MoaMgr Workers on chare %d at PE: %d, at %f.\n", thisIndex, CkMyPe(), CkWallTimer() );
414 #endif // OPENATOM_VERSION_DEBUG
437 #ifdef OPENATOM_VERSION_DEBUG
438 CkPrintf(
"Instantiating MoaS %d on PE: %d, at %f.\n", thisIndex, CkMyPe(), CkWallTimer() );
439 #endif //OPENATOM_VERSION_DEBUG
441 const MoaData &p = CProxy_ComputeMoaMgr::ckLocalBranch( CkpvAccess(BOCclass_group).computeMoaMgr)->getMoaData();
450 buff_len = (lib - lia) + (ljb - lja) + (lkb - lka);
451 qhbuff =
new float[buff_len];
452 bhbuff =
new int[buff_len];
461 #ifdef OPENATOM_VERSION_DEBUG
462 CkPrintf(
"Destructing MoaS %d on PE: %d, at %f.\n", thisIndex, CkMyPe(), CkWallTimer() );
463 #endif //OPENATOM_VERSION_DEBUG
469 #ifdef OPENATOM_VERSION_DEBUG
470 CkPrintf(
"Starting MoaS compute %d on PE: %d, at %f.\n", thisIndex, CkMyPe(), CkWallTimer() );
471 #endif //OPENATOM_VERSION_DEBUG
473 const MoaData &p = CProxy_ComputeMoaMgr::ckLocalBranch( CkpvAccess(BOCclass_group).computeMoaMgr)->getMoaData();
475 if ( ! moaS_setup ) {
480 bhread = bh.syncToRead();
481 qhacc = qh.getInitialAccum();
482 qhread = qhacc.syncToRead();
483 shwrit = sh.getInitialWrite();
487 bhread = bh.syncToRead();
491 for (index = 0, j = lia; j <= lib; j++) {
492 for (m = lja; m <= ljb; m++) {
493 for (n = lka; n <= lkb; n++, index++) {
494 bhbuff[index] = bhread.get(j,m,n);
499 qhacc = qhread.syncToEAccum();
500 qhread = qhacc.syncToRead();
501 for (index = 0, j = lia; j <= lib; j++) {
502 for (m = lja; m <= ljb; m++) {
503 for (n = lka; n <= lkb; n++, index++) {
504 qhbuff[index] = qhread.get(j,m,n);
509 shwrit = sh.getInitialWrite();
510 for (index = 0, j = lia; j <= lib; j++) {
511 for (m = lja; m <= ljb; m++) {
512 for (n = lka; n <= lkb; n++, index++) {
513 shwrite.set(j,m,n) = qhbuff[index] * bhbuff[index] * bhbuff[index+1] * bhbuff[index+2]
521 #include "ComputeMoaMgr.def.h"
523 #endif // OPENTATOM_VERSION
525 #endif // CHARM_HAS_MSA
std::vector< Moa3Grid > bh
SimParameters * simParameters
SubmitReduction * willSubmit(int setID, int size=-1)
std::vector< int > num_clients_qh
std::vector< int > num_clients_sh
std::vector< int > num_clients_bh
std::vector< Moa3Grid > qh
std::vector< Moa3Grid > sh