CollectionMaster Class Reference

#include <CollectionMaster.h>

List of all members.

Public Types

 NOT_PROCESSED
 IN_PROCESS
 HAS_PROCESSED
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 blockPositions ()
void unblockPositions ()
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

static CollectionMasterObject ()

Classes

class  CollectVectorInstance
class  CollectVectorSequence


Detailed Description

Definition at line 40 of file CollectionMaster.h.


Member Enumeration Documentation

enum CollectionMaster::OperationStatus

Enumerator:
NOT_PROCESSED 
IN_PROCESS 
HAS_PROCESSED 

Definition at line 78 of file CollectionMaster.h.


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::blockPositions (  )  [inline]

Definition at line 64 of file CollectionMaster.h.

References CollectionMaster::CollectVectorSequence::block().

Referenced by sendReplicaDcdData(), and sendReplicaDcdInit().

00064 { positions.block(); }

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 }

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

Definition at line 43 of file CollectionMaster.h.

Referenced by recvReplicaDcdAck(), sendReplicaDcdData(), and sendReplicaDcdInit().

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(), Node::Object(), 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(), Node::Object(), 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(), Node::Object(), 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 293 of file CollectionMaster.C.

References CollectionMaster::CollectVectorInstance::free(), IN_PROCESS, memusage_MB(), Node::Object(), and CollectionMaster::CollectVectorInstance::seq.

00293                                                              {
00294 #ifdef MEM_OPT_VERSION
00295         
00296         if(totalT > forceIOTime) forceIOTime = totalT;
00297 
00298 #if OUTPUT_SINGLE_FILE
00299     if(++forceDoneCnt < Node::Object()->simParameters->numoutputwrts)  return;
00300 #else
00301         if(++forceDoneCnt < Node::Object()->simParameters->numoutputprocs)  return;
00302 #endif
00303 
00304     forceDoneCnt = 0;
00305 
00306     //retrieve the last ready instance
00307     CollectVectorInstance *c = forces.getReady();
00308     int seq = c->seq;
00309     CmiAssert(c->status == IN_PROCESS);
00310     double mem = memusage_MB();
00311     forces.removeFirstReady();
00312     c->free();
00313     forceOutTime = CmiWallTimer()-forceOutTime;
00314     if ( forceTimings ) {
00315       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);
00316       --forceTimings;
00317     }
00318 
00319     //Actually the c->status doesn't need to be checked because it is
00320     //certain that the new ready one will not be in  IN_PROCESS status 
00321     checkForceReady();
00322 #endif
00323 }

void CollectionMaster::startNextRoundOutputPos ( double  totalT  ) 

Definition at line 225 of file CollectionMaster.C.

References CollectionMaster::CollectVectorInstance::free(), IN_PROCESS, memusage_MB(), Node::Object(), and CollectionMaster::CollectVectorInstance::seq.

00225                                                            {
00226 #ifdef MEM_OPT_VERSION
00227 
00228         if(totalT > posIOTime) posIOTime = totalT;
00229 
00230 #ifndef OUTPUT_SINGLE_FILE
00231 #error OUTPUT_SINGLE_FILE not defined!
00232 #endif
00233 
00234 #if OUTPUT_SINGLE_FILE
00235     if(++posDoneCnt < Node::Object()->simParameters->numoutputwrts)  return;
00236 #else
00237         if(++posDoneCnt < Node::Object()->simParameters->numoutputprocs)  return;
00238 #endif
00239 
00240         posDoneCnt = 0;
00241 
00242     //retrieve the last ready instance
00243     CollectVectorInstance *c = positions.getReady();
00244     int seq = c->seq;
00245     CmiAssert(c->status == IN_PROCESS);
00246     double mem = memusage_MB();
00247     positions.removeFirstReady();
00248     c->free();
00249     posOutTime = CmiWallTimer()-posOutTime;
00250     if ( posTimings ) {
00251       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);
00252       --posTimings;
00253     }
00254 
00255     //Actually the c->status doesn't need to be checked because it is
00256     //certain that the new ready one will not be in  IN_PROCESS status 
00257     checkPosReady();
00258 #endif
00259 }

void CollectionMaster::startNextRoundOutputVel ( double  totalT  ) 

Definition at line 261 of file CollectionMaster.C.

References CollectionMaster::CollectVectorInstance::free(), IN_PROCESS, memusage_MB(), Node::Object(), and CollectionMaster::CollectVectorInstance::seq.

00261                                                            {
00262 #ifdef MEM_OPT_VERSION
00263         
00264         if(totalT > velIOTime) velIOTime = totalT;
00265 
00266 #if OUTPUT_SINGLE_FILE
00267     if(++velDoneCnt < Node::Object()->simParameters->numoutputwrts)  return;
00268 #else
00269         if(++velDoneCnt < Node::Object()->simParameters->numoutputprocs)  return;
00270 #endif
00271 
00272     velDoneCnt = 0;
00273 
00274     //retrieve the last ready instance
00275     CollectVectorInstance *c = velocities.getReady();
00276     int seq = c->seq;
00277     CmiAssert(c->status == IN_PROCESS);
00278     double mem = memusage_MB();
00279     velocities.removeFirstReady();
00280     c->free();
00281     velOutTime = CmiWallTimer()-velOutTime;
00282     if ( velTimings ) {
00283       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);
00284       --velTimings;
00285     }
00286 
00287     //Actually the c->status doesn't need to be checked because it is
00288     //certain that the new ready one will not be in  IN_PROCESS status 
00289     checkVelReady();
00290 #endif
00291 }

void CollectionMaster::unblockPositions (  )  [inline]

Definition at line 65 of file CollectionMaster.h.

References CollectionMaster::CollectVectorSequence::unblock().

Referenced by recvReplicaDcdAck().

00065 { positions.unblock(); }

void CollectionMaster::wrapCoorFinished (  ) 

Definition at line 326 of file CollectionMaster.C.

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

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


The documentation for this class was generated from the following files:
Generated on Sat Sep 23 01:17:17 2017 for NAMD by  doxygen 1.4.7