7 #ifndef COLLECTIONMASTER_H 8 #define COLLECTIONMASTER_H 17 #include "CollectionMaster.decl.h" 21 #include "ParallelIOMgr.decl.h" 47 return CkpvAccess(CollectionMaster_instance);
64 class CollectVectorInstance;
85 #ifdef MEM_OPT_VERSION 86 class CollectVectorInstance
97 if ( s == -10 )
NAMD_bug(
"seq == free in CollectionMaster");
99 CProxy_ParallelIOMgr io(CkpvAccess(BOCclass_group).ioMgr);
120 class CollectVectorSequence
125 CollectVectorInstance **c = data.begin();
126 CollectVectorInstance **c_e = data.end();
127 for( ; c != c_e && (*c)->seq != seq; ++c );
131 for( ; c != c_e && (*c)->notfree(); ++c );
133 data.add(
new CollectVectorInstance(seq));
161 CollectVectorInstance* getReady(
void)
163 CollectVectorInstance *o = 0;
167 CollectVectorInstance **c = data.begin();
168 CollectVectorInstance **c_e = data.end();
169 for( ; c != c_e && (*c)->seq != seq; ++c );
170 if ( c != c_e && (*c)->ready() )
182 int removeFirstReady(){
206 if ( s == -10 )
NAMD_bug(
"seq == free in CollectionMaster");
223 for(
int i = 0; i < size; ++i ) { ptr[a[i]] = d[i]; }
228 for(
int i = 0; i < size; ++i ) { ptr[a[i]] = fd[i]; }
281 for( ; c != c_e && (*c)->seq != seq; ++c );
285 for( ; c != c_e && (*c)->notfree(); ++c );
292 (*c)->append(msg, max_index);
308 for( ; c != c_e && (*c)->seq != seq; ++c );
309 if ( c != c_e && (*c)->ready() )
340 for( ; c != c_e && (*c)->
seq != seq; ++c );
344 for( ; c != c_e && (*c)->
notfree(); ++c );
351 (*c)->append(msg, max_index);
361 for( ; c != c_e && (*c)->
seq != seq; ++c );
362 if ( c != c_e && (*c)->
ready() )
381 #ifdef NODEGROUP_FORCE_REGISTER 382 void lock() { CmiLock(cmlock); }
383 void unlock() { CmiUnlock(cmlock); }
387 #ifdef NODEGROUP_FORCE_REGISTER 391 CollectVectorSequence positions;
392 CollectVectorSequence velocities;
393 CollectVectorSequence forces;
394 int posTimings, velTimings, forceTimings;
395 FILE *dataStreamFile;
397 #ifdef MEM_OPT_VERSION 412 void checkPosReady();
413 void checkVelReady();
414 void checkForceReady();
416 CollectVectorSequenceDcdSelection positionsDcdSelection;
444 #ifdef MEM_OPT_VERSION 445 class CollectMidVectorInstance{
448 CollectMidVectorInstance(
void) : seq(-10) {
449 CProxy_ParallelIOMgr io(CkpvAccess(BOCclass_group).ioMgr);
451 ioMgr->getMyAtomsRangeOnOutput(fromAtomID, toAtomID);
454 CollectMidVectorInstance(
int s) {
455 CProxy_ParallelIOMgr io(CkpvAccess(BOCclass_group).ioMgr);
457 ioMgr->getMyAtomsRangeOnOutput(fromAtomID, toAtomID);
461 void free() { seq = -10; }
462 int notfree() {
return ( seq != -10 ); }
465 if ( s == -10 )
NAMD_bug(
"seq == free in CollectionMidMaster");
467 remaining = toAtomID-fromAtomID+1;
476 if ( size ) data.resize(toAtomID-fromAtomID+1);
477 Vector *ptr = data.begin();
478 for(
int i = 0; i < size; ++i) { ptr[a[i]-fromAtomID] = d[i]; }
481 if ( size ) fdata.resize(toAtomID-fromAtomID+1);
483 for(
int i = 0; i < size; ++i) { ptr[a[i]-fromAtomID] = fd[i]; }
490 int ready(
void) {
return ( ! remaining ); }
512 class CollectionMidMaster{
515 CollectionMidMaster(
ParallelIOMgr *pIO_) : pIO(pIO_) { parOut =
new ParOutput(pIO_->myOutputRank); }
516 ~CollectionMidMaster(
void) {
delete parOut; }
522 void disposePositions(
int seq);
523 void disposeVelocities(
int seq);
524 void disposeForces(
int seq);
526 CollectMidVectorInstance *getReadyPositions(
int seq) {
return positions.getReady(seq); }
530 class CollectVectorSequence{
534 CollectMidVectorInstance **c = data.begin();
535 CollectMidVectorInstance **c_e = data.end();
536 for( ; c != c_e && (*c)->seq != seq; ++c );
539 for( ; c != c_e && (*c)->notfree(); ++c );
541 data.add(
new CollectMidVectorInstance(seq));
554 return (*c)->append(msg->
size,i,d,fd);
557 CollectMidVectorInstance* getReady(
int seq){
558 CollectMidVectorInstance **c = data.begin();
559 CollectMidVectorInstance **c_e = data.end();
560 for( ; c != c_e && (*c)->seq != seq; ++c );
569 CollectVectorSequence positions;
570 CollectVectorSequence velocities;
571 CollectVectorSequence forces;
CollectVectorInstance * removeReady(void)
ResizeArray< CollectVectorInstanceDcdSelection * > data
CollectVectorSequenceDcdSelection(int _index)
static PatchMap * Object()
void disposeForces(CollectVectorInstance *c)
void receiveVelocities(CollectVectorMsg *msg)
CollectVectorInstanceDcdSelection(void)
void receivePositions(CollectVectorMsg *msg)
void receivePositionsDcdSelection(CollectVectorMsg *msg)
static DataStreamMsg * unpack(void *ptr)
void enqueueVelocities(int seq)
void receiveOutputPosReady(int seq)
void submitData(CollectVectorMsg *msg, int max_index)
void enqueue(int seq, Lattice &lattice)
void startNextRoundOutputPos(double totalT)
void append(CollectVectorMsg *msg, int max_index)
int add(const Elem &elem)
void enqueuePositions(int seq, Lattice &lattice)
void enqueuePositionsDcdSelection(int seq, Lattice &lattice)
void receiveDataStream(DataStreamMsg *msg)
static void * pack(DataStreamMsg *msg)
CollectVectorSequenceDcdSelection(void)
void receiveOutputVelReady(int seq)
void NAMD_bug(const char *err_msg)
void append(CollectVectorMsg *msg, int max_index)
void disposePositions(CollectVectorInstance *c)
int get_dcd_selection_index_from_atom_id(const int index, const int atomIndex)
void submitData(CollectVectorMsg *msg, int max_index)
ResizeArray< FloatVector > fdata
void startNextRoundOutputVel(double totalT)
void receiveForces(CollectVectorMsg *msg)
void disposeVelocities(CollectVectorInstance *c)
static CollectionMaster * Object()
ResizeArray< Vector > data
CollectVectorInstanceDcdSelection * removeReady(void)
void startNextRoundOutputForce(double totalT)
CollectVectorInstance(int s)
void del(int index, int num=1)
CollectVectorInstanceDcdSelection(int s)
void enqueueForces(int seq)
CollectVectorInstance(void)
ResizeArray< Lattice > latqueue
void receiveOutputForceReady(int seq)