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 43 Lattice l,
int prec,
int dcdSelectiontag)
45 int numAtoms = a.
size();
46 int dcdSelectionindex=dcdSelectiontag-1;
50 CProxy_ParallelIOMgr io(CkpvAccess(BOCclass_group).ioMgr);
52 int numOutputProcs = ioMgr->numOutputProcs;
53 for (
int i=0; i<numAtoms; ++i ) {
55 oRank[i] = a[i].outputRank;
56 if(oRank[i]>numOutputProcs || oRank[i]<0)
58 std::cout <<
"pos resetting oRank of atom "<<i<<
" to 0, how did it become "<< oRank[i] <<
"\n";
63 CollectVectorInstance *c;
64 if ( ( c = positions.
submitData(seq,aid,oRank,d,prec) ) )
68 for(
int i=0; i<c->aid.size(); i++){
69 perOList[c->outRank[i]].
add(i);
72 if(prec==1 || prec==4 || prec==5 ){
80 for(
int i=0; i<ioMgr->numOutputProcs; i++){
81 int numAtoms = perOList[i].
size();
82 if(!numAtoms && ioMgr->numProxiesPerOutputProc == 0)
continue;
86 for(
int j=0; j<numAtoms; j++){
87 int lIdx = perOList[i][j];
88 msg->
aid[j] = c->aid[lIdx];
89 msg->
data[j] = c->data[lIdx];
93 for(
int j=0; j<numAtoms; j++){
94 int lIdx = perOList[i][j];
95 msg->
aid[j] = c->aid[lIdx];
96 msg->
fdata[j] = c->fdata[lIdx];
100 for(
int j=0; j<numAtoms; j++){
101 int lIdx = perOList[i][j];
102 msg->
aid[j] = c->aid[lIdx];
103 msg->
data[j] = c->data[lIdx];
104 msg->
fdata[j] = c->fdata[lIdx];
108 msg->
size = numAtoms;
110 msg->
index = dcdSelectionindex;
111 io[ioMgr->myOutputProxies[i]].receivePositions(msg);
120 int numAtoms = a.
size();
124 for (
int i=0; i<numAtoms; ++i ) {
126 oRank[i] = a[i].outputRank;
127 if ( zero ) d[i] = 0.;
128 else d[i] = a[i].velocity;
130 CollectVectorInstance *c;
131 if ( ( c = velocities.
submitData(seq,aid,oRank,d,prec) ) )
133 CProxy_ParallelIOMgr io(CkpvAccess(BOCclass_group).ioMgr);
138 for(
int i=0; i<c->aid.size(); i++){
139 perOList[c->outRank[i]].
add(i);
150 for(
int i=0; i<ioMgr->numOutputProcs; i++){
151 int numAtoms = perOList[i].
size();
152 if(!numAtoms && ioMgr->numProxiesPerOutputProc == 0)
continue;
156 for(
int j=0; j<numAtoms; j++){
157 int lIdx = perOList[i][j];
158 msg->
aid[j] = c->aid[lIdx];
159 msg->
data[j] = c->data[lIdx];
163 for(
int j=0; j<numAtoms; j++){
164 int lIdx = perOList[i][j];
165 msg->
aid[j] = c->aid[lIdx];
166 msg->
fdata[j] = c->fdata[lIdx];
170 for(
int j=0; j<numAtoms; j++){
171 int lIdx = perOList[i][j];
172 msg->
aid[j] = c->aid[lIdx];
173 msg->
data[j] = c->data[lIdx];
174 msg->
fdata[j] = c->fdata[lIdx];
178 msg->
size = numAtoms;
180 io[ioMgr->myOutputProxies[i]].receiveVelocities(msg);
189 int numAtoms = a.
size();
193 for (
int i=0; i<numAtoms; ++i ) {
195 oRank[i] = a[i].outputRank;
198 for (
int j=0; j<=maxForceUsed; ++j ) {
200 for (
int i=0; i<numAtoms; ++i ) {
205 for (
int i=0; i<numAtoms; ++i ) {
206 if ( a[i].atomFixed ) d[i] = 0.;
209 CollectVectorInstance *c;
210 if ( ( c = forces.
submitData(seq,aid,oRank,d,prec) ) )
212 CProxy_ParallelIOMgr io(CkpvAccess(BOCclass_group).ioMgr);
217 for(
int i=0; i<c->aid.size(); i++){
218 perOList[c->outRank[i]].
add(i);
229 for(
int i=0; i<ioMgr->numOutputProcs; i++){
230 int numAtoms = perOList[i].
size();
231 if(!numAtoms && ioMgr->numProxiesPerOutputProc == 0)
continue;
235 for(
int j=0; j<numAtoms; j++){
236 int lIdx = perOList[i][j];
237 msg->
aid[j] = c->aid[lIdx];
238 msg->
data[j] = c->data[lIdx];
242 for(
int j=0; j<numAtoms; j++){
243 int lIdx = perOList[i][j];
244 msg->
aid[j] = c->aid[lIdx];
245 msg->
fdata[j] = c->fdata[lIdx];
249 for(
int j=0; j<numAtoms; j++){
250 int lIdx = perOList[i][j];
251 msg->
aid[j] = c->aid[lIdx];
252 msg->
data[j] = c->data[lIdx];
253 msg->
fdata[j] = c->fdata[lIdx];
257 msg->
size = numAtoms;
259 io[ioMgr->myOutputProxies[i]].receiveForces(msg);
269 Lattice l,
int prec,
int dcdSelectiontag)
271 int numAtomsTotal = a.
size();
272 int numAtomsDcdSelection = 0;
274 int dcdSelectionindex=dcdSelectiontag-1;
277 int bitmask = 1 << dcdSelectionindex;
278 for (
int i=0; i<numAtomsTotal; ++i ) {
279 if(a[i].flags.dcdSelection & bitmask)
280 numAtomsDcdSelection++;
282 numAtoms = numAtomsDcdSelection;
286 numAtoms = numAtomsTotal;
293 int selectionCounter=0;
294 int bitmask = 1 << dcdSelectionindex;
295 DebugM(3,
"seq " << seq <<
" prec " << prec <<
" numAtomsTotal " << numAtomsTotal<<
" dcdSelectionIndex "<< dcdSelectionindex <<
" bitmask "<< bitmask <<
"\n");
296 for (
int i=0; i<numAtomsTotal; ++i ) {
297 if(a[i].flags.dcdSelection & bitmask)
299 aid[selectionCounter] = a[i].id;
304 DebugM(3,
"["<<CkMyPe()<<
"]"<<
" selection count "<<selectionCounter<<
"\n");
308 for (
int i=0; i<numAtoms; ++i ) {
313 auto c= positions.
submitData(seq,aid,d,prec) ;
317 int data_size = c->data.size();
318 int fdata_size = c->fdata.size();
321 msg->
index=dcdSelectionindex;
328 memcpy(msg->
aid,c->aid.begin(),aid_size*
sizeof(
AtomID));
329 memcpy(msg->
data,c->data.begin(),data_size*
sizeof(
Vector));
331 #ifdef NODEGROUP_FORCE_REGISTER 334 CProxy_PatchData cpdata(CkpvAccess(BOCclass_group).patchData);
346 CProxy_CollectionMaster cm(master);
348 cm.receivePositionsDcdSelection(msg);
350 cm.receivePositions(msg);
358 int numAtoms = a.
size();
361 for (
int i=0; i<numAtoms; ++i ) {
363 if ( zero ) d[i] = 0.;
364 else d[i] = a[i].velocity;
367 if ( ( c = velocities.
submitData(seq,aid,d,prec) ) )
380 #ifdef NODEGROUP_FORCE_REGISTER 383 CProxy_PatchData cpdata(CkpvAccess(BOCclass_group).patchData);
392 CProxy_CollectionMaster cm(master);
393 cm.receiveVelocities(msg);
401 int numAtoms = a.
size();
404 for (
int i=0; i<numAtoms; ++i ) {
408 for (
int j=0; j<=maxForceUsed; ++j ) {
410 for (
int i=0; i<numAtoms; ++i ) {
415 for (
int i=0; i<numAtoms; ++i ) {
416 if ( a[i].atomFixed ) d[i] = 0.;
420 if ( ( c = forces.
submitData(seq,aid,d,prec) ) )
433 #ifdef NODEGROUP_FORCE_REGISTER 435 CProxy_PatchData cpdata(CkpvAccess(BOCclass_group).patchData);
444 CProxy_CollectionMaster cm(master);
445 cm.receiveForces(msg);
456 CProxy_CollectionMaster cm(master);
457 cm.receiveDataStream(msg);
460 #include "CollectionMgr.def.h"
void submitForces(int seq, FullAtomList &a, int maxForceUsed, ForceList *f, int prec)
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)
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 submitVelocities(int seq, int zero, FullAtomList &a, int prec)
void submitPositions(int seq, FullAtomList &a, Lattice l, int prec, int dcdSelectionIndex)
ResizeArray< FloatVector > fdata
CollectionMgr(SlaveInitMsg *msg)
void sendDataStream(const char *)