OpenAtom  Version1.5a
AtomsCache.h
Go to the documentation of this file.
1 /** \file atomsCache.h
2  */
3 #ifndef ATOMSCACHE_H
4 #define ATOMSCACHE_H
5 #include "Atoms.h"
6 struct EnergyStruct;
7 #include "Atoms.decl.h"
8 #include "atomMessages.h"
9 #include "CPcharmParaInfo.decl.h"
10 
11 
12 #include "uber/Uber.h"
13 
14 
15 /** \file AtomsCache.h
16  * @defgroup Atoms Atoms
17  *
18  * \brief Handles coordinate and force integration for Atoms, keeping a distributed coordinate cache in AtomsCache and computing updates in AtomsCompute
19  *
20  *
21  * AtomsCache is a mostly passive structure for handling data
22  * replication of the atom coordinates and write-back collation of
23  * force contributions.
24  *
25  * various chares use CkLocal to access the atoms:
26  * Rho_RHart RhoGHart StructureFactor RealParticlePlane
27  * ParticlePlane
28  * -> fastAtoms read coords write forces
29  * RhoRHart
30  * -> natm read
31  * -> fastAtoms read coords write forces
32  * -> iteration read
33  * RhoGHart
34  * -> natm read
35  * -> iteration read coords write forces
36  * -> fastAtoms read
37  * RealParticlePlane
38  * -> temperScreenFile* read
39  * -> iteration read
40  * -> fastAtoms read coords write forces
41  * StructureFactor
42  * -> iteration read
43  * -> fastAtoms read coords write forces
44  * InstanceController
45  * -> iteration read
46  * -> temperScreenFile* read
47  * GSpacePlane
48  * -> natm read
49  * -> fastAtoms read coords for genwave
50  * -> temperScreenFile* read
51 
52  * EJB: this could perhaps be better implemented in an MSA, once they
53  * shake performance bugs out of MSA, and pay attention to
54  * partitioning considerations, we'll revisit it.
55 
56 
57  CkCache could be considered here, but our use case is so simple that
58  CkCache is wildly over engineered for our purposes. The number of
59  atoms is always relatively small, so we have no eviction
60  requirements. Similarly the number of clients is static and all
61  clients need access to all the atom coordinates every iteration, so
62  there is no segmentation and no window of opportunity for clever
63  just in time delivery.
64 
65  Nodegroup? AtomsCache is an excellent candidate for Nodegroup. All
66  force updates are a purely additive operation, each computation will
67  use the coordinates and its own chare local data to produce its
68  force contribution. Force updates are handled via by reference
69  passage into the PINY compute routines. Updates are order
70  independent, so as long as the memory subsystem doesn't lose its
71  mind maintaining associative additive consistency (almost the
72  weakest consistency one could ask for in a shared memory context)
73  then correctness is guaranteed without locks or explicit fencing.
74  False sharing shouldn't be an issue given that each force component
75  is in its own vector as are the coordinates. Having only one of
76  these per node gives us a slight memory footprint reduction. More
77  importantly it requires numprocs/node fewer update messages. If you
78  think this gives us grief just replace nodegroup with Group and
79  recompile, the nodegroup advantages are all implicit.
80 
81  However, AtomsCache directly uses the registration in the eesCache to
82  execute releaseGSP. So, AtomsCache's nodegroupness needs to be 1:1
83  with eesCache's nodegroupness, or an alternate launch scheme put
84  in place for releaseGSP to break that dependency.
85  * @addtogroup Atoms
86  * @{
87  */
88 
89 class AtomsCache: public Group {
90  public:
91  const UberCollection thisInstance;
92  int natm;
93  int natm_nl;
94  int iteration;
95  FastAtoms fastAtoms;
96  FILE *temperScreenFile;
97 
98 
99  AtomsCache(int,int,Atom *,UberCollection thisInstance);
100  AtomsCache(CkMigrateMessage *m) {}
101  ~AtomsCache();
102  void contributeforces();
103  void atomsDone();
104  void atomsDone(CkReductionMsg *);
105  void acceptAtoms(AtomMsg *); // entry method
106  void releaseGSP();
107  void zeroforces() {
108  double *fx = fastAtoms.fx;
109  double *fy = fastAtoms.fy;
110  double *fz = fastAtoms.fz;
111  for(int i=0; i<natm; i++){
112  fx[i] = 0;
113  fy[i] = 0;
114  fz[i] = 0;
115  }//endfor
116  }//end routine
117 };
118 
119 /*@}*/
120 #endif // ATOMSCACHE_H
holds the UberIndex and the offset for proxies
Definition: Uber.h:68
~AtomsCache()
Destructor.
Definition: AtomsCache.C:264
void contributeforces()
Contributeforces Every proc assigned an electronic structure chare of the bead=i temper=j (i...
Definition: AtomsCache.C:105
void atomsDone()
= Needs to have each proc invoke directly doneMovingAtoms method of the GSpaceDrivers which are mappe...
Definition: AtomsCache.C:188
void acceptAtoms(AtomMsg *)
acceptAtoms
Definition: AtomsCache.C:137
Definition: Atoms.h:20
void releaseGSP()
= Use eesCache's registered GSPs to
Definition: AtomsCache.C:219