#include <ReductionMgr.h>
Inheritance diagram for ReductionMgr:

Public Member Functions | |
| ReductionMgr () | |
| ~ReductionMgr () | |
| void | buildSpanTree (const int pe, const int max_intranode_children, const int max_internode_children, int *parent, int *num_children, int **children) |
| SubmitReduction * | willSubmit (int setID, int size=-1) |
| RequireReduction * | willRequire (int setID, int size=-1) |
| void | remoteRegister (ReductionRegisterMsg *msg) |
| void | remoteUnregister (ReductionRegisterMsg *msg) |
| void | remoteSubmit (ReductionSubmitMsg *msg) |
Static Public Member Functions | |
| ReductionMgr * | Object (void) |
Friends | |
| class | SubmitReduction |
| class | RequireReduction |
|
|
Definition at line 285 of file ReductionMgr.C. References buildSpanTree(), DebugM, and REDUCTION_MAX_CHILDREN. 00285 {
00286 if (CkpvAccess(ReductionMgr_instance) == 0) {
00287 CkpvAccess(ReductionMgr_instance) = this;
00288 } else {
00289 DebugM(1, "ReductionMgr::ReductionMgr() - another instance exists!\n");
00290 }
00291
00292 buildSpanTree(CkMyPe(),REDUCTION_MAX_CHILDREN,REDUCTION_MAX_CHILDREN,
00293 &myParent,&numChildren,&children);
00294
00295 // CkPrintf("TREE [%d] parent %d %d children\n",
00296 // CkMyPe(),myParent,numChildren);
00297 // if (numChildren > 0) {
00298 // for(int i=0; i < numChildren; i++) {
00299 // CkPrintf("TREE [%d] child %d %d\n",CkMyPe(),i,children[i]);
00300 // }
00301 // }
00302
00303 // fill in the spanning tree fields
00304 #if 0 // Old spanning tree
00305 if (CkMyPe() == 0) {
00306 myParent = -1;
00307 } else {
00308 myParent = (CkMyPe()-1)/REDUCTION_MAX_CHILDREN;
00309 }
00310 firstChild = CkMyPe()*REDUCTION_MAX_CHILDREN + 1;
00311 if (firstChild > CkNumPes()) firstChild = CkNumPes();
00312 lastChild = firstChild + REDUCTION_MAX_CHILDREN;
00313 if (lastChild > CkNumPes()) lastChild = CkNumPes();
00314 #endif
00315
00316 // initialize data
00317 for(int i=0; i<REDUCTION_MAX_SET_ID; i++) {
00318 reductionSets[i] = 0;
00319 }
00320
00321 DebugM(1,"ReductionMgr() instantiated.\n");
00322 }
|
|
|
Definition at line 325 of file ReductionMgr.C. 00325 {
00326 if (children != 0)
00327 delete [] children;
00328 for(int i=0; i<REDUCTION_MAX_SET_ID; i++) {
00329 delete reductionSets[i];
00330 }
00331
00332 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 119 of file ReductionMgr.C. References CmiGetFirstPeOnPhysicalNode, CmiNumPesOnPhysicalNode, CmiPeOnSamePhysicalNode, CmiPhysicalNodeID, NAMD_bug(), and NAMD_die(). Referenced by ReductionMgr(). 00125 {
00126 // If pe is a first-node, children are same-node pes and perhaps some
00127 // other first-nodes, and parents are other first-nodes. If pe is not a
00128 // first-node, build the spanning tree among the children, and the parent
00129 // is the corresponding first-node
00130
00131 #if CHARM_VERSION < 60103
00132 #define CmiPhysicalNodeID(X) X
00133 #define CmiNumPesOnPhysicalNode(X) 1
00134 #define CmiGetFirstPeOnPhysicalNode(X) (X)
00135 #define CmiPeOnSamePhysicalNode(X,Y) ((X)==(Y))
00136 #endif
00137 // No matter what, build list of PEs on my node first
00138 const int num_pes = CkNumPes();
00139 const int num_node_pes = CmiNumPesOnPhysicalNode(CmiPhysicalNodeID(pe));
00140 int *node_pes = new int[num_node_pes];
00141 int pe_index = -1;
00142 const int first_pe = CmiGetFirstPeOnPhysicalNode(CmiPhysicalNodeID(pe));
00143 int num_nodes = 0;
00144 int *node_ids = new int[num_pes];
00145 int first_pe_index = -1;
00146 int my_parent_index;
00147
00148 // Make sure PE 0 is a first-node
00149 if (pe == 0 && first_pe != pe) {
00150 NAMD_die("PE 0 is not the first physical node. This shouldn't happen");
00151 }
00152 // Get all the PEs on my node, and also build the list of all first-nodes
00153 int i;
00154 int node_pe_count=0;
00155 for (i = 0; i < num_pes; i++) {
00156 // Save first-nodes
00157 if (CmiGetFirstPeOnPhysicalNode(CmiPhysicalNodeID(i)) == i) {
00158 node_ids[num_nodes] = i;
00159 if (i == first_pe)
00160 first_pe_index = num_nodes;
00161 num_nodes++;
00162 }
00163
00164 // Also, find pes on my node
00165 const int i1 = (i + first_pe) % num_pes;
00166 if (CmiPeOnSamePhysicalNode(first_pe,i1)) {
00167 if ( node_pe_count == num_node_pes )
00168 NAMD_bug("ReductionMgr::buildSpanTree found inconsistent physical node data from Charm++ runtime");
00169 node_pes[node_pe_count] = i1;
00170 if (pe == i1)
00171 pe_index = node_pe_count;
00172 node_pe_count++;
00173 }
00174 }
00175 if ( pe_index < 0 || first_pe_index < 0 )
00176 NAMD_bug("ReductionMgr::buildSpanTree found inconsistent physical node data from Charm++ runtime");
00177
00178 // Any PE might have children on the same node, plus, if its a first-node,
00179 // it may have several children on other nodes
00180
00181 int first_loc_child_index = pe_index * max_intranode_children + 1;
00182 int last_loc_child_index
00183 = first_loc_child_index + max_intranode_children - 1;
00184 if (first_loc_child_index > num_node_pes) {
00185 first_loc_child_index = num_node_pes;
00186 last_loc_child_index = num_node_pes;
00187 } else {
00188 if (last_loc_child_index >= num_node_pes)
00189 last_loc_child_index = num_node_pes-1;
00190 }
00191 // CkPrintf("Local [%d] firstpe %d max %d num %d firstloc %d lastloc %d\n",
00192 // pe,pe_index,max_intranode_children,num_node_pes,
00193 // first_loc_child_index,last_loc_child_index);
00194
00195 int first_rem_child_index = num_nodes;
00196 int last_rem_child_index = num_nodes;
00197 int rem_children=0;
00198 int *rem_child_index = new int[max_internode_children];
00199
00200 if (first_pe != pe) {
00201 // I'm not a first_pe, so I have no more children, and my parent
00202 // is someone else on my node
00203 my_parent_index = (pe_index-1)/max_intranode_children;
00204 *parent = node_pes[my_parent_index];
00205 } else {
00206 // I am a first_pe, so I may have additional children
00207 // on other nodes, and my parent will be on another node
00208
00209 int range_begin = 0;
00210 int range_end = num_nodes;
00211
00212 if (pe == 0) {
00213 my_parent_index = -1;
00214 *parent = -1;
00215 } else {
00216 my_parent_index = 0;
00217 while ( first_pe_index != range_begin ) {
00218 my_parent_index = range_begin;
00219 ++range_begin;
00220 for ( int i = 0; i < max_internode_children; ++i ) {
00221 int split = range_begin + ( range_end - range_begin ) / ( max_internode_children - i );
00222 if ( first_pe_index < split ) { range_end = split; break; }
00223 else { range_begin = split; }
00224 }
00225 }
00226 *parent = node_ids[my_parent_index];
00227 }
00228
00229 // now we know parent and need only repeat calculation of children
00230 int prev_child_index = range_begin;
00231 ++range_begin;
00232 for ( int i = 0; i < max_internode_children; ++i ) {
00233 if ( range_begin >= range_end ) break;
00234 if ( range_begin > prev_child_index ) {
00235 rem_child_index[rem_children++] = prev_child_index = range_begin;
00236 }
00237 range_begin += ( range_end - range_begin ) / ( max_internode_children - i );
00238 }
00239 }
00240
00241 *num_children = 0;
00242 //CkPrintf("TREE pe %d my_parent %d %d\n",pe,my_parent_index,*parent);
00243
00244 int loc_children=0;
00245 if (first_loc_child_index != num_node_pes) {
00246 loc_children = last_loc_child_index - first_loc_child_index + 1;
00247 *num_children += loc_children;
00248 // CkPrintf("TREE pe %d %d local children\n",pe,loc_children);
00249 // } else {
00250 // CkPrintf("TREE pe %d No local children\n",pe);
00251 }
00252
00253 if (rem_children) {
00254 *num_children += rem_children;
00255 // CkPrintf("TREE pe %d %d rem children\n",pe,rem_children);
00256 // } else {
00257 // CkPrintf("TREE pe %d No rem children\n",pe);
00258 }
00259 if (*num_children == 0)
00260 *children = 0;
00261 else {
00262 *children = new int[*num_children];
00263 // CkPrintf("TREE pe %d children %d\n",pe,*num_children);
00264 int k;
00265 int child=0;
00266 if (loc_children > 0) {
00267 for(k=first_loc_child_index; k <= last_loc_child_index; k++) {
00268 // CkPrintf("TREE pe %d loc child[%d,%d] %d\n",pe,child,k,node_pes[k]);
00269 (*children)[child++]=node_pes[k];
00270 }
00271 }
00272 if (rem_children > 0) {
00273 for(k=0; k < rem_children; k++) {
00274 // CkPrintf("TREE pe %d rem child[%d,%d] %d\n",pe,child,k,node_ids[rem_child_index[k]]);
00275 (*children)[child++]=node_ids[rem_child_index[k]];
00276 }
00277 }
00278 }
00279 delete [] rem_child_index;
00280 delete [] node_ids;
00281 delete [] node_pes;
00282 }
|
|
|
|
Definition at line 419 of file ReductionMgr.C. References ReductionSet::addToRemoteSequenceNumber, ReductionRegisterMsg::dataSize, ReductionSet::getData(), NAMD_die(), ReductionSet::nextSequenceNumber, ReductionRegisterMsg::reductionSetID, ReductionRegisterMsg::sourceNode, ReductionSetData::submitsRecorded, and ReductionSet::submitsRegistered. 00419 {
00420
00421 int setID = msg->reductionSetID;
00422 int size = msg->dataSize;
00423 ReductionSet *set = getSet(setID,size);
00424 if ( set->getData(set->nextSequenceNumber)->submitsRecorded ) {
00425 NAMD_die("ReductionMgr::remoteRegister called while reductions outstanding on parent!");
00426 }
00427
00428 set->submitsRegistered++;
00429 set->addToRemoteSequenceNumber[childIndex(msg->sourceNode)]
00430 = set->nextSequenceNumber;
00431 // CkPrintf("[%d] reduction register received from node[%d] %d\n",
00432 // CkMyPe(),childIndex(msg->sourceNode),msg->sourceNode);
00433
00434 delete msg;
00435 }
|
|
|
Definition at line 453 of file ReductionMgr.C. References ReductionSet::addToRemoteSequenceNumber, BigReal, ReductionSetData::data, ReductionSubmitMsg::data, ReductionSet::dataSize, ReductionSubmitMsg::dataSize, ReductionSet::getData(), NAMD_bug(), ReductionSubmitMsg::reductionSetID, ReductionSubmitMsg::sequenceNumber, ReductionSubmitMsg::sourceNode, ReductionSetData::submitsRecorded, and ReductionSet::submitsRegistered. 00453 {
00454 int setID = msg->reductionSetID;
00455 ReductionSet *set = reductionSets[setID];
00456 int seqNum = msg->sequenceNumber
00457 + set->addToRemoteSequenceNumber[childIndex(msg->sourceNode)];
00458
00459 //iout << "seq " << seqNum << " from " << msg->sourceNode << " received on " << CkMyPe() << "\n" << endi;
00460 int size = msg->dataSize;
00461 if ( size != set->dataSize ) {
00462 NAMD_bug("ReductionMgr::remoteSubmit data sizes do not match.");
00463 }
00464
00465 BigReal *newData = msg->data;
00466 ReductionSetData *data = set->getData(seqNum);
00467 BigReal *curData = data->data;
00468 #ifdef ARCH_POWERPC
00469 #pragma disjoint (*curData, *newData)
00470 #pragma unroll(4)
00471 #endif
00472 for ( int i = 0; i < size; ++i ) {
00473 curData[i] += newData[i];
00474 }
00475 // CkPrintf("[%d] reduction Submit received from node[%d] %d\n",
00476 // CkMyPe(),childIndex(msg->sourceNode),msg->sourceNode);
00477 delete msg;
00478
00479 data->submitsRecorded++;
00480 if ( data->submitsRecorded == set->submitsRegistered ) {
00481 mergeAndDeliver(set,seqNum);
00482 }
00483 }
|
|
|
Definition at line 438 of file ReductionMgr.C. References ReductionSet::getData(), NAMD_die(), ReductionSet::nextSequenceNumber, ReductionRegisterMsg::reductionSetID, ReductionSetData::submitsRecorded, and ReductionSet::submitsRegistered. 00438 {
00439
00440 int setID = msg->reductionSetID;
00441 ReductionSet *set = reductionSets[setID];
00442 if ( set->getData(set->nextSequenceNumber)->submitsRecorded ) {
00443 NAMD_die("SubmitReduction deleted while reductions outstanding on parent!");
00444 }
00445
00446 set->submitsRegistered--;
00447
00448 delSet(setID);
00449 delete msg;
00450 }
|
|
||||||||||||
|
Definition at line 524 of file ReductionMgr.C. References ReductionSet::getData(), RequireReduction::master, NAMD_die(), ReductionSet::nextSequenceNumber, RequireReduction::reductionSetID, ReductionSet::requireRegistered, RequireReduction::sequenceNumber, and ReductionSetData::submitsRecorded. Referenced by Controller::Controller(), and PressureProfileReduction::PressureProfileReduction(). 00524 {
00525 ReductionSet *set = getSet(setID,size);
00526 set->requireRegistered++;
00527 if ( set->getData(set->nextSequenceNumber)->submitsRecorded ) {
00528 NAMD_die("ReductionMgr::willRequire called while reductions outstanding!");
00529 }
00530
00531 RequireReduction *handle = new RequireReduction;
00532 handle->reductionSetID = setID;
00533 handle->sequenceNumber = set->nextSequenceNumber;
00534 handle->master = this;
00535
00536 return handle;
00537 }
|
|
||||||||||||
|
|
Definition at line 223 of file ReductionMgr.h. |
|
|
Definition at line 222 of file ReductionMgr.h. |
1.3.9.1