Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

CollectionMaster Class Reference

#include <CollectionMaster.h>

List of all members.

Public Types

enum  OperationStatus { NOT_PROCESSED, IN_PROCESS, HAS_PROCESSED }

Public Member Functions

 CollectionMaster ()
 ~CollectionMaster (void)
void receivePositions (CollectVectorMsg *msg)
void receiveVelocities (CollectVectorMsg *msg)
void receiveForces (CollectVectorMsg *msg)
void receiveDataStream (DataStreamMsg *msg)
void enqueuePositions (int seq, Lattice &lattice)
void enqueueVelocities (int seq)
void enqueueForces (int seq)
void disposePositions (CollectVectorInstance *c)
void disposeVelocities (CollectVectorInstance *c)
void disposeForces (CollectVectorInstance *c)
void receiveOutputPosReady (int seq)
void receiveOutputVelReady (int seq)
void receiveOutputForceReady (int seq)
void startNextRoundOutputPos (double totalT)
void startNextRoundOutputVel (double totalT)
void startNextRoundOutputForce (double totalT)
void wrapCoorFinished ()

Static Public Member Functions

CollectionMasterObject ()


Member Enumeration Documentation

enum CollectionMaster::OperationStatus
 

Enumeration values:
NOT_PROCESSED 
IN_PROCESS 
HAS_PROCESSED 

Definition at line 75 of file CollectionMaster.h.

00075 {NOT_PROCESSED, IN_PROCESS, HAS_PROCESSED};


Constructor & Destructor Documentation

CollectionMaster::CollectionMaster  ) 
 

Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000 by The Board of Trustees of the University of Illinois. All rights reserved.

Definition at line 22 of file CollectionMaster.C.

References DebugM.

00023 {
00024   if (CkpvAccess(CollectionMaster_instance) == 0) {
00025     CkpvAccess(CollectionMaster_instance) = this;
00026   } else {
00027     DebugM(1, "CollectionMaster::CollectionMaster() - another instance of CollectionMaster exists!\n");
00028   }
00029   dataStreamFile = 0;
00030 
00031 #ifdef MEM_OPT_VERSION
00032   wrapCoorDoneCnt = 0;
00033   posDoneCnt = 0;
00034   velDoneCnt = 0;
00035   parOut = new ParOutput();
00036 #endif
00037 
00038   posTimings = 10;  velTimings = forceTimings = 5;
00039 }

CollectionMaster::~CollectionMaster void   ) 
 

Definition at line 42 of file CollectionMaster.C.

00043 {
00044 }


Member Function Documentation

void CollectionMaster::disposeForces CollectVectorInstance c  ) 
 

Definition at line 157 of file CollectionMaster.C.

References ResizeArray< Elem >::begin(), CollectionMaster::CollectVectorInstance::data, DebugM, Output::force(), CollectionMaster::CollectVectorInstance::free(), memusage_MB(), Node::Object(), Node::output, CollectionMaster::CollectVectorInstance::seq, and ResizeArray< Elem >::size().

Referenced by enqueueForces(), and receiveForces().

00158 {
00159 #ifndef MEM_OPT_VERSION
00160     DebugM(3,"Collected forces at " << c->seq << std::endl);
00161     int seq = c->seq;
00162     int size = c->data.size();
00163     Vector *data = c->data.begin();
00164     double exectime = CmiWallTimer();
00165     double mem = memusage_MB();
00166     Node::Object()->output->force(seq,size,data);
00167     c->free();
00168     exectime = CmiWallTimer()-exectime;
00169     if ( forceTimings ) {
00170       CkPrintf("The last force output (seq=%d) takes %.3f seconds, %.3f MB of memory in use\n", seq, exectime, mem);
00171       --forceTimings;
00172     }
00173 #endif
00174 }

void CollectionMaster::disposePositions CollectVectorInstance c  ) 
 

Definition at line 69 of file CollectionMaster.C.

References ResizeArray< Elem >::begin(), Output::coordinate(), CollectionMaster::CollectVectorInstance::data, DebugM, CollectionMaster::CollectVectorInstance::fdata, CollectionMaster::CollectVectorInstance::free(), CollectionMaster::CollectVectorInstance::lattice, memusage_MB(), Node::Object(), Node::output, CollectionMaster::CollectVectorInstance::seq, and ResizeArray< Elem >::size().

Referenced by enqueuePositions(), and receivePositions().

00070 {
00071 #ifndef MEM_OPT_VERSION
00072     DebugM(3,"Collected positions at " << c->seq << std::endl);
00073     int seq = c->seq;
00074     int size = c->data.size();
00075     if ( ! size ) size = c->fdata.size();
00076     Vector *data = c->data.begin();
00077     FloatVector *fdata = c->fdata.begin();
00078     double exectime = CmiWallTimer();
00079     double mem = memusage_MB();
00080     Node::Object()->output->coordinate(seq,size,data,fdata,c->lattice);
00081     c->free();
00082     exectime = CmiWallTimer()-exectime;
00083     if ( posTimings ) {
00084       CkPrintf("The last position output (seq=%d) takes %.3f seconds, %.3f MB of memory in use\n", seq, exectime, mem);
00085       --posTimings;
00086     }
00087 #endif
00088 }

void CollectionMaster::disposeVelocities CollectVectorInstance c  ) 
 

Definition at line 114 of file CollectionMaster.C.

References ResizeArray< Elem >::begin(), CollectionMaster::CollectVectorInstance::data, DebugM, CollectionMaster::CollectVectorInstance::free(), memusage_MB(), Node::Object(), Node::output, CollectionMaster::CollectVectorInstance::seq, ResizeArray< Elem >::size(), and Output::velocity().

Referenced by enqueueVelocities(), and receiveVelocities().

00115 {
00116 #ifndef MEM_OPT_VERSION
00117     DebugM(3,"Collected velocities at " << c->seq << std::endl);
00118     int seq = c->seq;
00119     int size = c->data.size();
00120     Vector *data = c->data.begin();
00121     double exectime = CmiWallTimer();
00122     double mem = memusage_MB();
00123     Node::Object()->output->velocity(seq,size,data);
00124     c->free();
00125     exectime = CmiWallTimer()-exectime;
00126     if ( velTimings ) {
00127       CkPrintf("The last velocity output (seq=%d) takes %.3f seconds, %.3f MB of memory in use\n", seq, exectime, mem);
00128       --velTimings;
00129     }
00130 #endif
00131 }

void CollectionMaster::enqueueForces int  seq  ) 
 

Definition at line 145 of file CollectionMaster.C.

References disposeForces(), CollectionMaster::CollectVectorSequence::enqueue(), and CollectionMaster::CollectVectorSequence::removeReady().

Referenced by Controller::enqueueCollections().

00146 {
00147   Lattice dummy;
00148   forces.enqueue(seq,dummy);
00149 #ifndef MEM_OPT_VERSION
00150   CollectVectorInstance *c;
00151   while ( ( c = forces.removeReady() ) ) { disposeForces(c); }
00152 #else
00153   checkForceReady();
00154 #endif
00155 }

void CollectionMaster::enqueuePositions int  seq,
Lattice lattice
 

Definition at line 57 of file CollectionMaster.C.

References disposePositions(), CollectionMaster::CollectVectorSequence::enqueue(), and CollectionMaster::CollectVectorSequence::removeReady().

Referenced by Controller::enqueueCollections().

00058 {
00059   positions.enqueue(seq,lattice);
00060 
00061 #ifndef MEM_OPT_VERSION
00062   CollectVectorInstance *c;
00063   while ( ( c = positions.removeReady() ) ) { disposePositions(c); }
00064 #else
00065   checkPosReady();
00066 #endif
00067 }

void CollectionMaster::enqueueVelocities int  seq  ) 
 

Definition at line 102 of file CollectionMaster.C.

References disposeVelocities(), CollectionMaster::CollectVectorSequence::enqueue(), and CollectionMaster::CollectVectorSequence::removeReady().

Referenced by Controller::enqueueCollections().

00103 {
00104   Lattice dummy;
00105   velocities.enqueue(seq,dummy);
00106 #ifndef MEM_OPT_VERSION
00107   CollectVectorInstance *c;
00108   while ( ( c = velocities.removeReady() ) ) { disposeVelocities(c); }
00109 #else
00110   checkVelReady();
00111 #endif
00112 }

CollectionMaster* CollectionMaster::Object  )  [inline, static]
 

Definition at line 43 of file CollectionMaster.h.

00043                                     { 
00044     return CkpvAccess(CollectionMaster_instance); 
00045   }

void CollectionMaster::receiveDataStream DataStreamMsg msg  ) 
 

Definition at line 177 of file CollectionMaster.C.

References SimParameters::auxFilename, ResizeArray< Elem >::begin(), DataStreamMsg::data, NAMD_backup_file(), NAMD_die(), Node::Object(), and Node::simParameters.

00177                                                            {
00178     if ( ! dataStreamFile ) {
00179       char *fname = Node::Object()->simParameters->auxFilename;
00180       // iout has large file linking issues on AIX
00181       // iout << iINFO << "OPENING AUXILIARY DATA STREAM FILE "
00182       //                                << fname << "\n" << endi;
00183       CkPrintf("Info: OPENING AUXILIARY DATA STREAM FILE %s\n", fname);
00184       NAMD_backup_file(fname);
00185       dataStreamFile = fopen(fname,"w");
00186       if ( ! dataStreamFile )
00187                 NAMD_die("Can't open auxiliary data stream file!");
00188     }
00189     fprintf(dataStreamFile,"%s",msg->data.begin());
00190     fflush(dataStreamFile);
00191     delete msg;
00192 }

void CollectionMaster::receiveForces CollectVectorMsg msg  ) 
 

Definition at line 134 of file CollectionMaster.C.

References disposeForces(), CollectionMaster::CollectVectorSequence::removeReady(), and CollectionMaster::CollectVectorSequence::submitData().

00135 {
00136 #ifndef MEM_OPT_VERSION
00137   forces.submitData(msg,Node::Object()->molecule->numAtoms);
00138   delete msg;
00139 
00140   CollectVectorInstance *c;
00141   while ( ( c = forces.removeReady() ) ) { disposeForces(c); }
00142 #endif
00143 }

void CollectionMaster::receiveOutputForceReady int  seq  ) 
 

Definition at line 217 of file CollectionMaster.C.

References CollectionMaster::CollectVectorSequence::submitData().

00217                                                      {
00218 #ifdef MEM_OPT_VERSION
00219     forces.submitData(seq);
00220     checkForceReady();
00221 #endif
00222 }

void CollectionMaster::receiveOutputPosReady int  seq  ) 
 

void CollectionMaster::receiveOutputVelReady int  seq  ) 
 

Definition at line 210 of file CollectionMaster.C.

References CollectionMaster::CollectVectorSequence::submitData().

00210                                                    {
00211 #ifdef MEM_OPT_VERSION
00212     velocities.submitData(seq);
00213     checkVelReady();
00214 #endif
00215 }

void CollectionMaster::receivePositions CollectVectorMsg msg  ) 
 

Definition at line 46 of file CollectionMaster.C.

References disposePositions(), CollectionMaster::CollectVectorSequence::removeReady(), and CollectionMaster::CollectVectorSequence::submitData().

00047 {
00048 #ifndef MEM_OPT_VERSION
00049   positions.submitData(msg,Node::Object()->molecule->numAtoms);
00050   delete msg;
00051   
00052   CollectVectorInstance *c;
00053   while ( ( c = positions.removeReady() ) ) { disposePositions(c); }
00054 #endif
00055 }

void CollectionMaster::receiveVelocities CollectVectorMsg msg  ) 
 

Definition at line 91 of file CollectionMaster.C.

References disposeVelocities(), CollectionMaster::CollectVectorSequence::removeReady(), and CollectionMaster::CollectVectorSequence::submitData().

00092 {
00093 #ifndef MEM_OPT_VERSION
00094   velocities.submitData(msg,Node::Object()->molecule->numAtoms);
00095   delete msg;
00096 
00097   CollectVectorInstance *c;
00098   while ( ( c = velocities.removeReady() ) ) { disposeVelocities(c); }
00099 #endif
00100 }

void CollectionMaster::startNextRoundOutputForce double  totalT  ) 
 

Definition at line 289 of file CollectionMaster.C.

References CollectionMaster::CollectVectorInstance::free(), IN_PROCESS, memusage_MB(), SimParameters::numoutputprocs, SimParameters::numoutputwrts, Node::Object(), CollectionMaster::CollectVectorInstance::seq, and Node::simParameters.

00289                                                              {
00290 #ifdef MEM_OPT_VERSION
00291         
00292         if(totalT > forceIOTime) forceIOTime = totalT;
00293 
00294 #if OUTPUT_SINGLE_FILE
00295     if(++forceDoneCnt < Node::Object()->simParameters->numoutputwrts)  return;
00296 #else
00297         if(++forceDoneCnt < Node::Object()->simParameters->numoutputprocs)  return;
00298 #endif
00299 
00300     forceDoneCnt = 0;
00301 
00302     //retrieve the last ready instance
00303     CollectVectorInstance *c = forces.getReady();
00304     int seq = c->seq;
00305     CmiAssert(c->status == IN_PROCESS);
00306     double mem = memusage_MB();
00307     forces.removeFirstReady();
00308     c->free();
00309     forceOutTime = CmiWallTimer()-forceOutTime;
00310     if ( forceTimings ) {
00311       CkPrintf("The last force output (seq=%d) takes %.3f seconds(file I/O: %.3f secs), %.3f MB of memory in use\n", seq, forceOutTime, forceIOTime, mem);
00312       --forceTimings;
00313     }
00314 
00315     //Actually the c->status doesn't need to be checked because it is
00316     //certain that the new ready one will not be in  IN_PROCESS status 
00317     checkForceReady();
00318 #endif
00319 }

void CollectionMaster::startNextRoundOutputPos double  totalT  ) 
 

Definition at line 225 of file CollectionMaster.C.

References CollectionMaster::CollectVectorInstance::free(), IN_PROCESS, memusage_MB(), SimParameters::numoutputprocs, SimParameters::numoutputwrts, Node::Object(), CollectionMaster::CollectVectorInstance::seq, and Node::simParameters.

00225                                                            {
00226 #ifdef MEM_OPT_VERSION
00227 
00228         if(totalT > posIOTime) posIOTime = totalT;
00229 
00230 #if OUTPUT_SINGLE_FILE
00231     if(++posDoneCnt < Node::Object()->simParameters->numoutputwrts)  return;
00232 #else
00233         if(++posDoneCnt < Node::Object()->simParameters->numoutputprocs)  return;
00234 #endif
00235 
00236         posDoneCnt = 0;
00237 
00238     //retrieve the last ready instance
00239     CollectVectorInstance *c = positions.getReady();
00240     int seq = c->seq;
00241     CmiAssert(c->status == IN_PROCESS);
00242     double mem = memusage_MB();
00243     positions.removeFirstReady();
00244     c->free();
00245     posOutTime = CmiWallTimer()-posOutTime;
00246     if ( posTimings ) {
00247       CkPrintf("The last position output (seq=%d) takes %.3f seconds(file I/O: %.3f secs), %.3f MB of memory in use\n", seq, posOutTime, posIOTime, mem);
00248       --posTimings;
00249     }
00250 
00251     //Actually the c->status doesn't need to be checked because it is
00252     //certain that the new ready one will not be in  IN_PROCESS status 
00253     checkPosReady();
00254 #endif
00255 }

void CollectionMaster::startNextRoundOutputVel double  totalT  ) 
 

Definition at line 257 of file CollectionMaster.C.

References CollectionMaster::CollectVectorInstance::free(), IN_PROCESS, memusage_MB(), SimParameters::numoutputprocs, SimParameters::numoutputwrts, Node::Object(), CollectionMaster::CollectVectorInstance::seq, and Node::simParameters.

00257                                                            {
00258 #ifdef MEM_OPT_VERSION
00259         
00260         if(totalT > velIOTime) velIOTime = totalT;
00261 
00262 #if OUTPUT_SINGLE_FILE
00263     if(++velDoneCnt < Node::Object()->simParameters->numoutputwrts)  return;
00264 #else
00265         if(++velDoneCnt < Node::Object()->simParameters->numoutputprocs)  return;
00266 #endif
00267 
00268     velDoneCnt = 0;
00269 
00270     //retrieve the last ready instance
00271     CollectVectorInstance *c = velocities.getReady();
00272     int seq = c->seq;
00273     CmiAssert(c->status == IN_PROCESS);
00274     double mem = memusage_MB();
00275     velocities.removeFirstReady();
00276     c->free();
00277     velOutTime = CmiWallTimer()-velOutTime;
00278     if ( velTimings ) {
00279       CkPrintf("The last velocity output (seq=%d) takes %.3f seconds(file I/O: %.3f secs), %.3f MB of memory in use\n", seq, velOutTime, velIOTime, mem);
00280       --velTimings;
00281     }
00282 
00283     //Actually the c->status doesn't need to be checked because it is
00284     //certain that the new ready one will not be in  IN_PROCESS status 
00285     checkVelReady();
00286 #endif
00287 }

void CollectionMaster::wrapCoorFinished  ) 
 

Definition at line 322 of file CollectionMaster.C.

References ParallelIOMgr::disposePositions(), ParallelIOMgr::numOutputProcs, SimParameters::numoutputprocs, ParallelIOMgr::numOutputWrts, Node::Object(), ParallelIOMgr::outputProcArray, CollectionMaster::CollectVectorInstance::seq, and Node::simParameters.

00322                                        {
00323 #ifdef MEM_OPT_VERSION
00324     if(++wrapCoorDoneCnt == Node::Object()->simParameters->numoutputprocs){
00325         wrapCoorDoneCnt = 0;
00326 
00327                 //count the wrapping-coor time into master writing time
00328                 posIOTime = CmiWallTimer()-posOutTime; 
00329 
00330         //it's ready to output positions
00331         CollectVectorInstance *c = positions.getReady();
00332 
00333                 CProxy_ParallelIOMgr io(CkpvAccess(BOCclass_group).ioMgr);
00334                 ParallelIOMgr *ioMgr = io.ckLocalBranch();
00335 
00336 #if OUTPUT_SINGLE_FILE
00337         //notify output procs to do Token based output
00338         int grpsize = ioMgr->numOutputProcs / ioMgr->numOutputWrts;
00339         int remains = ioMgr->numOutputProcs % ioMgr->numOutputWrts;
00340         int outrank = 0;
00341         int i;
00342         for(i=0; i<remains; i++){
00343             io[ioMgr->outputProcArray[outrank]].disposePositions(c->seq, posIOTime);
00344             outrank += (grpsize+1);
00345         }
00346         for(; i<ioMgr->numOutputWrts; i++){
00347             io[ioMgr->outputProcArray[outrank]].disposePositions(c->seq, posIOTime);
00348             outrank += grpsize;
00349         }
00350 #else
00351                 //output multiple files
00352                 for(int i=0; i<ioMgr->numOutputProcs; i++) {
00353                         io[ioMgr->outputProcArray[i]].disposePositions(c->seq, posIOTime);
00354                 }
00355 #endif
00356 
00357     }
00358 #endif
00359 }


The documentation for this class was generated from the following files:
Generated on Fri May 25 04:07:19 2012 for NAMD by  doxygen 1.3.9.1