7 #include "CollectionMgr.decl.h" 9 #include "CollectionMaster.decl.h" 16 #include "ParallelIOMgr.decl.h" 18 #define MIN_DEBUG_LEVEL 3 25 if (CkpvAccess(CollectionMgr_instance) == 0) {
26 CkpvAccess(CollectionMgr_instance) =
this;
28 DebugM(1,
"CollectionMgr::CollectionMgr() - another instance of CollectionMgr exists!\n");
37 #ifdef MEM_OPT_VERSION 45 int numAtoms = a.
size();
49 for (
int i=0; i<numAtoms; ++i ) {
51 oRank[i] = a[i].outputRank;
54 CollectVectorInstance *c;
55 if ( ( c = positions.
submitData(seq,aid,oRank,d,prec) ) )
57 CProxy_ParallelIOMgr io(CkpvAccess(BOCclass_group).ioMgr);
62 for(
int i=0; i<c->aid.size(); i++){
63 perOList[c->outRank[i]].
add(i);
74 for(
int i=0; i<ioMgr->numOutputProcs; i++){
75 int numAtoms = perOList[i].
size();
76 if(!numAtoms && ioMgr->numProxiesPerOutputProc == 0)
continue;
80 for(
int j=0; j<numAtoms; j++){
81 int lIdx = perOList[i][j];
82 msg->
aid[j] = c->aid[lIdx];
83 msg->
data[j] = c->data[lIdx];
87 for(
int j=0; j<numAtoms; j++){
88 int lIdx = perOList[i][j];
89 msg->
aid[j] = c->aid[lIdx];
90 msg->
fdata[j] = c->fdata[lIdx];
94 for(
int j=0; j<numAtoms; j++){
95 int lIdx = perOList[i][j];
96 msg->
aid[j] = c->aid[lIdx];
97 msg->
data[j] = c->data[lIdx];
98 msg->
fdata[j] = c->fdata[lIdx];
102 msg->
size = numAtoms;
104 io[ioMgr->myOutputProxies[i]].receivePositions(msg);
113 int numAtoms = a.
size();
117 for (
int i=0; i<numAtoms; ++i ) {
119 oRank[i] = a[i].outputRank;
120 if ( zero ) d[i] = 0.;
121 else d[i] = a[i].velocity;
123 CollectVectorInstance *c;
124 if ( ( c = velocities.
submitData(seq,aid,oRank,d) ) )
126 CProxy_ParallelIOMgr io(CkpvAccess(BOCclass_group).ioMgr);
131 for(
int i=0; i<c->aid.size(); i++){
132 perOList[c->outRank[i]].
add(i);
136 for(
int i=0; i<ioMgr->numOutputProcs; i++){
137 int numAtoms = perOList[i].
size();
138 if(!numAtoms && ioMgr->numProxiesPerOutputProc == 0)
continue;
142 msg->
size = numAtoms;
144 for(
int j=0; j<numAtoms; j++){
145 int lIdx = perOList[i][j];
146 msg->
aid[j] = c->aid[lIdx];
147 msg->
data[j] = c->data[lIdx];
149 io[ioMgr->myOutputProxies[i]].receiveVelocities(msg);
158 int numAtoms = a.
size();
162 for (
int i=0; i<numAtoms; ++i ) {
164 oRank[i] = a[i].outputRank;
167 for (
int j=0; j<=maxForceUsed; ++j ) {
169 for (
int i=0; i<numAtoms; ++i ) {
174 for (
int i=0; i<numAtoms; ++i ) {
175 if ( a[i].atomFixed ) d[i] = 0.;
178 CollectVectorInstance *c;
179 if ( ( c = forces.
submitData(seq,aid,oRank,d) ) )
181 CProxy_ParallelIOMgr io(CkpvAccess(BOCclass_group).ioMgr);
186 for(
int i=0; i<c->aid.size(); i++){
187 perOList[c->outRank[i]].
add(i);
191 for(
int i=0; i<ioMgr->numOutputProcs; i++){
192 int numAtoms = perOList[i].
size();
193 if(!numAtoms && ioMgr->numProxiesPerOutputProc == 0)
continue;
197 msg->
size = numAtoms;
199 for(
int j=0; j<numAtoms; j++){
200 int lIdx = perOList[i][j];
201 msg->
aid[j] = c->aid[lIdx];
202 msg->
data[j] = c->data[lIdx];
204 io[ioMgr->myOutputProxies[i]].receiveForces(msg);
213 Lattice l,
int prec,
int dcdSelectiontag)
215 int numAtomsTotal = a.
size();
216 int numAtomsDcdSelection = 0;
218 int dcdSelectionindex=dcdSelectiontag-1;
221 int bitmask = 1 << dcdSelectionindex;
222 for (
int i=0; i<numAtomsTotal; ++i ) {
223 if(a[i].flags.dcdSelection & bitmask)
224 numAtomsDcdSelection++;
226 numAtoms = numAtomsDcdSelection;
230 numAtoms = numAtomsTotal;
237 int selectionCounter=0;
238 int bitmask = 1 << dcdSelectionindex;
239 DebugM(3,
"seq " << seq <<
" prec " << prec <<
" numAtomsTotal " << numAtomsTotal<<
" dcdSelectionIndex "<< dcdSelectionindex <<
" bitmask "<< bitmask <<
"\n");
240 for (
int i=0; i<numAtomsTotal; ++i ) {
241 if(a[i].flags.dcdSelection & bitmask)
243 aid[selectionCounter] = a[i].id;
248 DebugM(3,
"["<<CkMyPe()<<
"]"<<
" selection count "<<selectionCounter<<
"\n");
252 for (
int i=0; i<numAtoms; ++i ) {
257 auto c= positions.
submitData(seq,aid,d,prec) ;
261 int data_size = c->data.size();
262 int fdata_size = c->fdata.size();
265 msg->
index=dcdSelectionindex;
272 memcpy(msg->
aid,c->aid.begin(),aid_size*
sizeof(
AtomID));
273 memcpy(msg->
data,c->data.begin(),data_size*
sizeof(
Vector));
275 #ifdef NODEGROUP_FORCE_REGISTER 277 CProxy_PatchData cpdata(CkpvAccess(BOCclass_group).patchData);
289 CProxy_CollectionMaster cm(master);
291 cm.receivePositionsDcdSelection(msg);
293 cm.receivePositions(msg);
301 int numAtoms = a.
size();
304 for (
int i=0; i<numAtoms; ++i ) {
306 if ( zero ) d[i] = 0.;
307 else d[i] = a[i].velocity;
310 if ( ( c = velocities.
submitData(seq,aid,d) ) )
321 #ifdef NODEGROUP_FORCE_REGISTER 323 CProxy_PatchData cpdata(CkpvAccess(BOCclass_group).patchData);
332 CProxy_CollectionMaster cm(master);
333 cm.receiveVelocities(msg);
341 int numAtoms = a.
size();
344 for (
int i=0; i<numAtoms; ++i ) {
348 for (
int j=0; j<=maxForceUsed; ++j ) {
350 for (
int i=0; i<numAtoms; ++i ) {
355 for (
int i=0; i<numAtoms; ++i ) {
356 if ( a[i].atomFixed ) d[i] = 0.;
371 #ifdef NODEGROUP_FORCE_REGISTER 373 CProxy_PatchData cpdata(CkpvAccess(BOCclass_group).patchData);
382 CProxy_CollectionMaster cm(master);
383 cm.receiveForces(msg);
394 CProxy_CollectionMaster cm(master);
395 cm.receiveDataStream(msg);
398 #include "CollectionMgr.def.h"
Bool fixedAtomsForceOutput
NAMD_HOST_DEVICE Position reverse_transform(Position data, const Transform &t) const
void receiveVelocities(CollectVectorMsg *msg)
SimParameters * simParameters
void receivePositions(CollectVectorMsg *msg)
void receivePositionsDcdSelection(CollectVectorMsg *msg)
void submitVelocities(int seq, int zero, FullAtomList &a)
int add(const Elem &elem)
CollectVectorInstance * submitData(int seq, AtomIDList &i, ResizeArray< Vector > &d, int prec=2)
ResizeArray< Vector > data
void receiveForces(CollectVectorMsg *msg)
void submitForces(int seq, FullAtomList &a, int maxForceUsed, ForceList *f)
void submitPositions(int seq, FullAtomList &a, Lattice l, int prec, int dcdSelectionIndex)
CollectionMgr(SlaveInitMsg *msg)
void sendDataStream(const char *)