#include <ComputeGridForce.h>
Public Member Functions | |
| ComputeGridForceNodeMgr () | |
| void | depositInitialGrid (GridDepositMsg *msg) |
| void | requestInitialGridData () |
| void | receiveInitialGridData (GridSegmentMsg *msg) |
| void | submitRequest (SubReqMsg *msg) |
| void | fetchGridValues (GridRequestMsg *msg) |
| void | recvGridValues (GridValuesMsg *msg) |
| void | resume () |
|
|
Definition at line 23 of file ComputeGridForce.C. 00024 {
00025 CkpvAccess(BOCclass_group).computeGridForceNodeMgr = thisgroup;
00026
00027 grids_deposited = 0;
00028 grids = NULL;
00029 requestGrids_count = 0;
00030 myNode = CkMyNode();
00031 nodeSize = CkNodeSize(myNode);
00032 gf = new ComputeGridForce*[nodeSize];
00033 proc_count = 0;
00034 cur_grid = 0;
00035 // myout = new infostream[nodeSize];
00036 // iout << iINFO << "[" << CkMyPe() << "] GridForceNodeMgr created"
00037 // << " procs=" << CkNumPes()
00038 // << " nodes=" << CkNumNodes()
00039 // << " nodesize=" << CkNodeSize(CkMyNode())
00040 // << "\n" << endi;
00041 }
|
|
|
Definition at line 43 of file ComputeGridForce.C. References GridDepositMsg::grid, GridDepositMsg::gridnum, GridforceGrid::init2(), and GridDepositMsg::num_grids. 00044 {
00045 const int gridnum = msg->gridnum;
00046 GridforceGrid *grid = msg->grid;
00047 num_grids = msg->num_grids;
00048 delete msg;
00049
00050 // iout << iINFO << "[" << CkMyPe() << "] Grid " << gridnum
00051 // << " deposited\n" << endi;
00052
00053 if (grids_deposited == 0) {
00054 // iout << iINFO << "[" << CkMyPe() << "] Allocating for "
00055 // << num_grids << " grids"
00056 // << "\n" << endi;
00057 grids = new GridforceGrid*[num_grids];
00058 }
00059 grids[gridnum] = grid;
00060 grids_deposited++;
00061 if (grids_deposited == num_grids) {
00062 // iout << iINFO << "[" << CkMyPe() << "]"
00063 // << " all grids deposited\n" << endi;
00064 int i;
00065 for(i=0;i<num_grids; i++) {
00066 grids[i]->init2();
00067 }
00068 // iout << iINFO << "[" << CkMyPe() << "]"
00069 // << " requesting from node 0"
00070 // << "\n" << endi;
00071 // Once all grids are deposited here, request grid data from node 0
00072 CProxy_ComputeGridForceNodeMgr myproxy(thisgroup);
00073 myproxy[0].requestInitialGridData();
00074 }
00075 }
|
|
|
Definition at line 243 of file ComputeGridForce.C. References GridRequestMsg::from_node, GridforceGrid::get_grid(), GridforceGrid::getBlockSize(), GridforceGrid::getIndexForBlock(), GridRequestMsg::gridIndexList, GridValuesMsg::gridStartIndex, GridRequestMsg::gridStartIndex, GridValuesMsg::gridVals, GridVal::index, j, GridValuesMsg::num_grid_indices, and GridVal::val. 00244 {
00245 // Be careful that this isn't running at the same time resume() is.
00246 // As long as this entry is exclusive, and resume() is only
00247 // called from an exclusive entry, this should be fine.
00248 // iout << iINFO << "[" << CkMyPe() << "] Getting grid values from "
00249 // << msg->from_node << " for " << msg->num_grid_indices
00250 // << " indices "
00251 // << "\n" << endi;
00252 int *startIndex = new int[num_grids+1];
00253 startIndex[0] = 0;
00254 int gridnum;
00255 int i;
00256 for(gridnum=0;gridnum<num_grids;gridnum++) {
00257 int nvals = 0;
00258 for(i=msg->gridStartIndex[gridnum];
00259 i < msg->gridStartIndex[gridnum+1]; i++) {
00260 const int block = msg->gridIndexList[i];
00261 nvals += grids[gridnum]->getBlockSize(block);
00262 // iout << iINFO << "[" << CkMyPe() << "] grid block "
00263 // << block << " size is "
00264 // << nvals << "\n" << endi;
00265 }
00266 startIndex[gridnum+1] = startIndex[gridnum] + nvals;
00267 }
00268 GridValuesMsg *outmsg
00269 = new(num_grids+1,startIndex[num_grids]) GridValuesMsg;
00270 outmsg->num_grid_indices = startIndex[num_grids];
00271
00272 for(gridnum=0;gridnum<=num_grids;gridnum++) {
00273 // iout << iINFO << "[" << CkMyPe() << "] Grid start "
00274 // << startIndex[gridnum]
00275 // << "\n" << endi;
00276 outmsg->gridStartIndex[gridnum] = startIndex[gridnum];
00277 }
00278 delete [] startIndex;
00279
00280 // Molecule *mol = Node::Object()->molecule;
00281 for (gridnum = 0; gridnum < num_grids; gridnum++) {
00282 GridforceGrid* grid = grids[gridnum];
00283 // iout << iINFO << "[" << CkMyPe() << "] filling grid from "
00284 // << msg->gridStartIndex[gridnum]
00285 // << " to "
00286 // << msg->gridStartIndex[gridnum+1]
00287 // << "\n" << endi;
00288 int outindex = outmsg->gridStartIndex[gridnum];
00289 for(i=msg->gridStartIndex[gridnum];
00290 i < msg->gridStartIndex[gridnum+1]; i++) {
00291 const int block = msg->gridIndexList[i];
00292 int j;
00293 const int jmax = grid->getBlockSize(block);
00294 // iout << iINFO << "[" << CkMyPe() << "] grid block[" << i << "] "
00295 // << block << " size is "
00296 // << jmax << " offset " << outindex
00297 // << "\n" << endi;
00298
00299 for(j=0; j < jmax; j++, outindex++) {
00300 const int idx = grid->getIndexForBlock(block,j);
00301 // CkPrintf("PVal %d Idx %d block %d boffset %d\n",
00302 // j1,idx,block,j);
00303 outmsg->gridVals[outindex].index = idx;
00304 outmsg->gridVals[outindex].val = grid->get_grid(idx);
00305 // iout << iINFO << "[" << CkMyPe() << "] Got grid value("
00306 // << i << ")(" << outmsg->gridVals[i].index << ") "
00307 // << outmsg->gridVals[i].val
00308 // << "\n" << endi;
00309 }
00310 }
00311 }
00312
00313 CProxy_ComputeGridForceNodeMgr me(thisgroup);
00314 me[msg->from_node].recvGridValues(outmsg);
00315 delete msg;
00316 }
|
|
|
Definition at line 129 of file ComputeGridForce.C. References GridSegmentMsg::count, GridSegmentMsg::grid, GridSegmentMsg::gridnum, GridforceGrid::init4(), and GridSegmentMsg::start_index. 00130 {
00131 // iout << iINFO << "[" << CkMyPe() << "] Grid received "
00132 // << "\n" << endi;
00133 // iout << iINFO << "[" << CkMyPe() << "] Grid num=" << msg->gridnum
00134 // << " count=" << msg->count
00135 // << " start=" << msg->start_index
00136 // << "\n" << endi;
00137 grids[msg->gridnum]->init4(msg->grid,msg->start_index,msg->count);
00138 delete msg;
00139
00140 CProxy_ComputeGridForceNodeMgr myproxy(thisgroup);
00141 myproxy[0].requestInitialGridData();
00142 }
|
|
|
Definition at line 318 of file ComputeGridForce.C. References GridforceGrid::addGridValue(), GridforceGrid::getGridBlockIdxOffset(), GridValuesMsg::gridStartIndex, GridValuesMsg::gridVals, GridVal::index, resume(), and GridVal::val. 00319 {
00320 // iout << iINFO << "[" << CkMyPe() << "] Receiving grid values"
00321 // << "\n" << endi;
00322
00323 int gridnum;
00324 const int myrank = CkMyRank();
00325 for (gridnum = 0; gridnum < num_grids; gridnum++) {
00326 GridforceGrid *grid = grids[gridnum];
00327 int i;
00328 // CkPrintf("Unpacking from %d to %d\n",
00329 // msg->gridStartIndex[gridnum],msg->gridStartIndex[gridnum+1]);
00330 for(i=msg->gridStartIndex[gridnum];
00331 i < msg->gridStartIndex[gridnum+1]; i++) {
00332 const int idx = msg->gridVals[i].index;
00333 int bi,boffset;
00334 grid->getGridBlockIdxOffset(idx,bi,boffset);
00335 // CkPrintf("UVal %d Idx %d block %d boffset %d\n",
00336 // i,idx,bi,boffset);
00337 grid->addGridValue(idx,msg->gridVals[i].val);
00338 /* iout << iINFO << "[" << CkMyPe() << "] Unpacking grid value(" */
00339 /* << i << ")(" << msg->gridVals[i].index << ") " */
00340 /* << grid->get_real_grid(msg->gridVals[i].index) */
00341 /* << " --- " << msg->gridVals[i].val */
00342 /* << "\n" << endi; */
00343 /* */
00344 }
00345 }
00346 msgSentCount--;
00347 // iout << iINFO << "[" << CkMyPe() << "] Done receiving grid values"
00348 // << " msgSentCount=" << msgSentCount
00349 // << "\n" << endi;
00350
00351 if (msgSentCount == 0) {
00352 resume();
00353 }
00354 delete msg;
00355 }
|
|
|
Definition at line 77 of file ComputeGridForce.C. References GridSegmentMsg::count, GridSegmentMsg::grid, GridSegmentMsg::gridnum, GridforceGrid::init3(), and GridSegmentMsg::start_index. 00078 {
00079 // iout << iINFO << "[" << CkMyPe() << "] Grids requested "
00080 // << requestGrids_count
00081 // << "\n" << endi;
00082 requestGrids_count++;
00083
00084 // When all of the grids on a node have been deposited initially
00085 // a message will get sent here. After that, each call to
00086 // receiveInitialGridData on every node will generate another call
00087 // here until the data has all been sent
00088 if (requestGrids_count == CkNumNodes()) {
00089 requestGrids_count = 0;
00090 bool sent = false;
00091 while (!sent && cur_grid < num_grids) {
00092 GridSegmentMsg *msg = new GridSegmentMsg;
00093
00094 msg->gridnum = cur_grid;
00095 grids[cur_grid]->init3(msg->grid,&(msg->start_index),
00096 &(msg->count));
00097
00098 if (msg->count > 0) {
00099 // CkPrintf("Msg is %p\n",msg);
00100 // iout << iINFO << "[" << CkMyPe() << "] Sending grid "
00101 // << msg->gridnum
00102 // << " of " << num_grids
00103 // << " start " << msg->start_index
00104 // << " count " << msg->count
00105 // << "\n" << endi;
00106 CProxy_ComputeGridForceNodeMgr myproxy(thisgroup);
00107 // iout << iINFO << "[" << CkMyPe() << "] got proxy"
00108 // << "\n" << endi;
00109 myproxy.receiveInitialGridData(msg);
00110 // iout << iINFO << "[" << CkMyPe() << "] sent data from grid "
00111 // << cur_grid
00112 // << "\n" << endi;
00113 sent = true;
00114 } else {
00115 // iout << iINFO << "[" << CkMyPe() << "] no data from grid "
00116 // << msg->gridnum
00117 // << "\n" << endi;
00118 cur_grid++;
00119 }
00120 }
00121 // if (!sent) {
00122 // iout << iINFO << "[" << CkMyPe() << "] Done sending grid data"
00123 // << "\n" << endi;
00124 // }
00125 }
00126 // iout << iINFO << "Done w/ request\n" << endi;
00127 }
|
|
|
Definition at line 374 of file ComputeGridForce.C. References ComputeGridForce::finishWork(). Referenced by recvGridValues(), and submitRequest(). 00375 {
00376 // Grid calculations should be cheap, so we won't bother parallelizing
00377 // them. As long as only one PE accesses the cache at a time, we don't
00378 // have to synchronize. Another option is to execute each finishWork()
00379 // on a separate PE, but then we have to make sure the GridCache is
00380 // thread-safe, or sequentialize access to it
00381 int rank;
00382 CProxy_ComputeGridForceMgr pemgr(CkpvAccess(BOCclass_group).
00383 computeGridForceMgr);
00384
00385 for(rank=0; rank < nodeSize; rank++) {
00386 pemgr[CkNodeFirst(myNode) + rank].finishWork();
00387 }
00388 }
|
|
|
Definition at line 146 of file ComputeGridForce.C. References GridforceGrid::consolidateGridRequests(), GridRequestMsg::from_node, GridforceGrid::getGridIndices(), GridforceGrid::getNumGridRequests(), SubReqMsg::gf, GridRequestMsg::gridIndexList, GridRequestMsg::gridStartIndex, GridRequestMsg::num_grid_indices, SubReqMsg::rank, and resume(). 00147 {
00148 // CkPrintf("[%d] submitRequest received message %d from %d\n",
00149 // CkMyPe(),proc_count,msg->rank);
00150 const int msgrank = msg->rank;
00151
00152 // Save the data from this request
00153 gf[msgrank] = msg->gf;
00154 delete msg;
00155 proc_count++;
00156
00157 if (proc_count < nodeSize) {
00158 // iout << iINFO << "[" << CkMyPe() << "] "
00159 // << " submitRequest rank=" << msgrank
00160 // << " still waiting"
00161 // << "\n" << endi;
00162 return;
00163 } else proc_count = 0;
00164
00165 // All requests received. Figure out what we actually need
00166 int i,rank;
00167 // CkPrintf("[%d] num_grids=%d nodeSize=%d\n",
00168 // CkMyPe(),num_grids,nodeSize);
00169
00170 for(i=0; i < num_grids; i++) {
00171 grids[i]->consolidateGridRequests();
00172 }
00173
00174 // Package up grid element requests and send them off
00175 int num_indices = 0;
00176 for(i=0; i < num_grids; i++) {
00177 num_indices += grids[i]->getNumGridRequests();
00178 }
00179
00180 if (num_indices == 0) {
00181 // iout << iINFO << "[" << CkMyPe() << "] no vals needed "
00182 // << "\n" << endi;
00183 resume();
00184 } else {
00185 // CkPrintf("[%d] requesting %d grid vals\n",CkMyPe(),num_indices);
00186
00187 msgSentCount=0;
00188 int *gridStart = new int[num_grids+1];
00189 int *gridIndices = new int[num_indices];
00190 int *gridNodeList = new int[num_indices];
00191 int *gridNodeCount = new int[CkNumNodes()];
00192 GridforceGrid::
00193 getGridIndices(gridStart,gridIndices,gridNodeList,gridNodeCount);
00194
00195 GridRequestMsg **msgs = new GridRequestMsg*[CkNumNodes()];
00196 int *cur_ind = new int[CkNumNodes()];
00197 int i;
00198 for(i=0; i < CkNumNodes(); i++) {
00199 msgs[i] = new(num_grids+1,gridNodeCount[i]) GridRequestMsg;
00200 msgs[i]->from_node = myNode;
00201 msgs[i]->num_grid_indices = gridNodeCount[i];
00202 cur_ind[i] = 0;
00203 }
00204
00205 int grid;
00206 CProxy_ComputeGridForceNodeMgr me(thisgroup);
00207
00208 for(grid=0; grid < num_grids; grid++) {
00209 for(i=0; i < CkNumNodes(); i++)
00210 msgs[i]->gridStartIndex[grid] = cur_ind[i];
00211
00212 for(i=gridStart[grid]; i < gridStart[grid+1]; i++) {
00213 int node = gridNodeList[i];
00214 msgs[node]->gridIndexList[cur_ind[node]] = gridIndices[i];
00215 cur_ind[node]++;
00216 }
00217 }
00218 for(i=0; i < CkNumNodes(); i++)
00219 msgs[i]->gridStartIndex[num_grids] = cur_ind[i];
00220
00221 for(i=0;i<CkNumNodes();i++) {
00222 if (gridNodeCount[i] > 0) {
00223 // iout << iINFO << "[" << CkMyPe() << "] fetching from " << i
00224 // << "\n" << endi;
00225 me[i].fetchGridValues(msgs[i]);
00226 msgSentCount++;
00227 } else {
00228 delete msgs[i];
00229 }
00230 }
00231 delete [] cur_ind;
00232 delete [] msgs;
00233 delete [] gridNodeCount;
00234 delete [] gridNodeList;
00235 delete [] gridIndices;
00236 delete [] gridStart;
00237 }
00238 // iout << iINFO << "[" << CkMyPe() << "] "
00239 // << "submitRequest DONE rank=" << msgrank
00240 // << "\n" << endi;
00241 }
|
1.3.9.1