7 #ifndef COLLECTIONMASTER_H
8 #define COLLECTIONMASTER_H
17 #include "CollectionMaster.decl.h"
21 #include "ParallelIOMgr.decl.h"
44 return CkpvAccess(CollectionMaster_instance);
59 class CollectVectorInstance;
80 #ifdef MEM_OPT_VERSION
81 class CollectVectorInstance
92 if ( s == -10 )
NAMD_bug(
"seq == free in CollectionMaster");
94 CProxy_ParallelIOMgr io(CkpvAccess(BOCclass_group).ioMgr);
100 void append(){ --remaining; }
102 int ready(
void) {
return ( ! remaining ); }
115 class CollectVectorSequence
120 CollectVectorInstance **c =
data.begin();
121 CollectVectorInstance **c_e =
data.end();
122 for( ; c != c_e && (*c)->seq != seq; ++c );
126 for( ; c != c_e && (*c)->notfree(); ++c );
128 data.add(
new CollectVectorInstance(seq));
156 CollectVectorInstance* getReady(
void)
158 CollectVectorInstance *o = 0;
162 CollectVectorInstance **c =
data.begin();
163 CollectVectorInstance **c_e =
data.end();
164 for( ; c != c_e && (*c)->seq != seq; ++c );
165 if ( c != c_e && (*c)->ready() )
177 int removeFirstReady(){
201 if ( s == -10 )
NAMD_bug(
"seq == free in CollectionMaster");
218 for(
int i = 0; i < size; ++i ) { ptr[a[i]] = d[i]; }
223 for(
int i = 0; i < size; ++i ) { ptr[a[i]] = fd[i]; }
228 int ready(
void) {
return ( ! remaining ); }
250 for( ; c != c_e && (*c)->seq != seq; ++c );
254 for( ; c != c_e && (*c)->notfree(); ++c );
261 (*c)->append(msg, max_index);
277 for( ; c != c_e && (*c)->seq != seq; ++c );
278 if ( c != c_e && (*c)->ready() )
305 int posTimings, velTimings, forceTimings;
306 FILE *dataStreamFile;
308 #ifdef MEM_OPT_VERSION
323 void checkPosReady();
324 void checkVelReady();
325 void checkForceReady();
353 #ifdef MEM_OPT_VERSION
354 class CollectMidVectorInstance{
357 CollectMidVectorInstance(
void) : seq(-10) {
358 CProxy_ParallelIOMgr io(CkpvAccess(BOCclass_group).ioMgr);
360 ioMgr->getMyAtomsRangeOnOutput(fromAtomID, toAtomID);
363 CollectMidVectorInstance(
int s) {
364 CProxy_ParallelIOMgr io(CkpvAccess(BOCclass_group).ioMgr);
366 ioMgr->getMyAtomsRangeOnOutput(fromAtomID, toAtomID);
370 void free() { seq = -10; }
371 int notfree() {
return ( seq != -10 ); }
374 if ( s == -10 )
NAMD_bug(
"seq == free in CollectionMidMaster");
376 remaining = toAtomID-fromAtomID+1;
385 if ( size ) data.resize(toAtomID-fromAtomID+1);
386 Vector *ptr = data.begin();
387 for(
int i = 0; i < size; ++i) { ptr[a[i]-fromAtomID] = d[i]; }
390 if ( size ) fdata.resize(toAtomID-fromAtomID+1);
392 for(
int i = 0; i < size; ++i) { ptr[a[i]-fromAtomID] = fd[i]; }
399 int ready(
void) {
return ( ! remaining ); }
421 class CollectionMidMaster{
424 CollectionMidMaster(
ParallelIOMgr *pIO_) : pIO(pIO_) { parOut =
new ParOutput(pIO_->myOutputRank); }
425 ~CollectionMidMaster(
void) {
delete parOut; }
431 void disposePositions(
int seq);
432 void disposeVelocities(
int seq);
433 void disposeForces(
int seq);
435 CollectMidVectorInstance *getReadyPositions(
int seq) {
return positions.getReady(seq); }
439 class CollectVectorSequence{
443 CollectMidVectorInstance **c = data.begin();
444 CollectMidVectorInstance **c_e = data.end();
445 for( ; c != c_e && (*c)->seq != seq; ++c );
448 for( ; c != c_e && (*c)->notfree(); ++c );
450 data.add(
new CollectMidVectorInstance(seq));
463 return (*c)->append(msg->
size,i,d,fd);
466 CollectMidVectorInstance* getReady(
int seq){
467 CollectMidVectorInstance **c = data.begin();
468 CollectMidVectorInstance **c_e = data.end();
469 for( ; c != c_e && (*c)->seq != seq; ++c );
478 CollectVectorSequence positions;
479 CollectVectorSequence velocities;
480 CollectVectorSequence
forces;
CollectVectorInstance * removeReady(void)
void del(int index, int num=1)
static PatchMap * Object()
void disposeForces(CollectVectorInstance *c)
void receiveVelocities(CollectVectorMsg *msg)
void receivePositions(CollectVectorMsg *msg)
static __thread float4 * forces
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)
void enqueuePositions(int seq, Lattice &lattice)
void receiveDataStream(DataStreamMsg *msg)
static void * pack(DataStreamMsg *msg)
void receiveOutputVelReady(int seq)
void NAMD_bug(const char *err_msg)
void disposePositions(CollectVectorInstance *c)
ResizeArray< FloatVector > fdata
void startNextRoundOutputVel(double totalT)
void receiveForces(CollectVectorMsg *msg)
void disposeVelocities(CollectVectorInstance *c)
static CollectionMaster * Object()
ResizeArray< Vector > data
int add(const Elem &elem)
void startNextRoundOutputForce(double totalT)
CollectVectorInstance(int s)
void enqueueForces(int seq)
ResizeArray< CollectVectorInstance * > data
CollectVectorInstance(void)
ResizeArray< Lattice > latqueue
void receiveOutputForceReady(int seq)