NamdTypes.h

Go to the documentation of this file.
00001 
00007 #ifndef NAMDTYPES_H
00008 
00009 #define NAMDTYPES_H
00010 
00011 #include "common.h"
00012 #include "Vector.h"
00013 #ifndef __CUDACC__
00014 #include "ResizeArray.h"
00015 #endif
00016 
00017 class Patch;
00018 class Compute;
00019 
00020 typedef Vector Position;
00021 typedef Vector Velocity;
00022 
00023 //#ifdef ARCH_POWERPC
00024 //typedef AlignVector Force;
00025 //#else
00026 typedef Vector Force;
00027 //#endif
00028 
00029 typedef int AtomID;
00030 typedef int AtomType;
00031 typedef float Mass;
00032 typedef float Charge;
00033 
00034 typedef double Coordinate;
00035 
00036 struct Transform
00037 {
00038   signed char i,j,k;
00039   Transform(void) { i=0; j=0; k=0; }
00040 };
00041 
00042 /*
00043  * 1. "position" field in this structure is very important since it
00044  * needs to be sent to every patch after every timestep.
00045  * 2. Anything that is static (value is decided before computation)
00046  * or only changes after atom migration should be put into the CompAtomExt structure
00047  * 3. This data structure is 32-byte long which is particularly optimized for some machines
00048  * (including BG/L) for better cache and message performance. Therefore, changes
00049  * to this structure should be cautioned for the sake of performance.
00050  */
00051 
00052 struct CompAtom {
00053   Position position;
00054   Charge charge;
00055   short vdwType;
00056   unsigned char partition;
00057   unsigned int nonbondedGroupSize : 3;
00058   unsigned int hydrogenGroupSize : 4;  // could be 3 if unsigned
00059   unsigned int isWater : 1;  // 0 = particle is not in water, 1 = is in water
00060 };
00061 
00062 #ifdef NAMD_KNL
00063 struct CompAtomFlt {
00064   FloatVector position;
00065   int32 vdwType;
00066 };
00067 #endif
00068 
00069 //CompAtomExt is now needed even in normal case
00070 //for changing the packed msg type related to
00071 //ProxyPatch into varsize msg type where
00072 // two types of proxy msgs (originally, the msg 
00073 // for the step where atoms migrate (ProxyAllMsg), 
00074 // and  the msg for normal steps (ProxyDataMsg))
00075 // are declared as the same class (ProxyDataMsg).
00076 // Note that in normal case, the class is needed
00077 // just for passing the compilation, but not involved
00078 // in the actual force calculation.
00079 // --Chao Mei
00080 
00081 typedef int SigIndex;
00082 typedef int AtomSigID;
00083 typedef int ExclSigID;
00084 
00085 struct CompAtomExt {
00086   #ifdef MEM_OPT_VERSION
00087   AtomSigID sigId;
00088   ExclSigID exclId;
00089   #endif
00090   #if defined(NAMD_CUDA) || defined(NAMD_MIC)
00091   int sortOrder;  // used to reorder atoms for CUDA
00092   #endif
00093   int id : 30;  // minimum for 100M atoms is 28 signed, 27 unsigned
00094   unsigned int atomFixed : 1;
00095   unsigned int groupFixed : 1;
00096 };
00097 
00098 struct FullAtom : CompAtom, CompAtomExt{
00099   Velocity velocity;
00100   Position fixedPosition;
00101   Mass mass;
00102   union{
00103       Real langevinParam;
00104 #ifdef MEM_OPT_VERSION
00105       int hydVal;
00106 #endif      
00107   };  
00108   int32 status;
00109   Transform transform;
00110   int migrationGroupSize;
00111   Real rigidBondLength;
00112 
00113 #ifdef MEM_OPT_VERSION
00114   int outputRank;
00115 #endif
00116 
00117 #ifdef MEM_OPT_VERSION
00118   //a HACK to re-sort FullAtom list used in Parallel IO
00119   //When every home patch processor receives its atoms list for a patch,
00120   //the atoms inside this patch may not sorted according to hydList value
00121   //To save space, use anonymous union data structure to share the space
00122   //of "langevinParam" to store "hydList" from an InputAtom and then sort the 
00123   //atom list. The "langevinParam" value is not initialized until home 
00124   //patch creation -Chao Mei
00125   int operator < (const FullAtom &a) const {
00126       return hydVal < a.hydVal;
00127   }
00128 #endif
00129 };
00130 
00131 //InputAtom is used to contain the info of the atoms
00132 //loaded into input processors.
00133 struct InputAtom: FullAtom{
00134         bool isValid;
00135         short isGP;
00136         short isMP;
00137         int hydList;
00138         int GPID;
00139         int MPID;
00140         
00141         int operator < (const InputAtom &a) const{
00142                 return hydList < a.hydList;
00143         }
00144 };
00145 
00146 struct CudaAtom {
00147   float x,y,z,q;
00148 };
00149 
00150 struct CudaForce {
00151   float x, y, z;
00152 };
00153 
00154 #ifndef __CUDACC__
00155 typedef ResizeArray<CudaAtom> CudaAtomList;
00156 typedef ResizeArray<CompAtom> CompAtomList;
00157 typedef ResizeArray<CompAtomExt> CompAtomExtList;
00158 #ifdef NAMD_KNL
00159 typedef ResizeArray<CompAtomFlt> CompAtomFltList;
00160 #endif
00161 typedef ResizeArray<FullAtom> FullAtomList;
00162 typedef ResizeArray<InputAtom> InputAtomList;
00163 typedef ResizeArray<Position> PositionList;
00164 typedef ResizeArray<Velocity> VelocityList;
00165 typedef ResizeArray<Force> ForceList;
00166 typedef ResizeArray<Transform> TransformList;
00167 
00168 typedef ResizeArray<AtomID> AtomIDList;
00169 typedef ResizeArray<BigReal> BigRealList;
00170 typedef ResizeArray<Real> RealList;
00171 typedef float GBReal;
00172 typedef ResizeArray<GBReal> GBRealList;
00173 typedef ResizeArray<int> IntList;
00174 
00175 typedef int PatchID;
00176 typedef int ComputeID;
00177 typedef int NodeID;
00178 
00179 typedef ResizeArray<PatchID> PatchIDList;
00180 typedef ResizeArray<Patch *> PatchList;
00181 
00182 typedef ResizeArray<Compute *> ComputeList;
00183 
00184 // See AtomMap
00185 struct LocalID
00186 {
00187   PatchID pid;
00188   int index;
00189 };
00190 
00191 typedef ResizeArray<NodeID> NodeIDList;
00192 
00193 struct ExtForce {
00194   int replace;
00195   Force force;
00196   ExtForce() : replace(0) {;}
00197 };
00198 
00199 
00200 // DMK - Atom Sort
00201 #if NAMD_ComputeNonbonded_SortAtoms != 0
00202 
00203   typedef struct __sort_entry {
00204     int index;  // Index of atom in CompAtom array
00205     BigReal sortValue;   // Distance of PAp from P0 (see calculation code)
00206   } SortEntry;
00207 
00208 #endif
00209 
00210 //This class represents a tree node of proxy spanning tree
00211 //All pes in this array have the same "nodeID". In other words,
00212 //all those pes are in the same physical node.
00213 //This is a structure for adapting NAMD to multicore processors
00214 struct proxyTreeNode{
00215     int nodeID;
00216     int *peIDs;
00217     int numPes;
00218 
00219     proxyTreeNode(){
00220         nodeID = -1;
00221         peIDs = NULL;
00222         numPes = 0;
00223     }
00224     proxyTreeNode(int nid, int numPes_, int *pes){
00225         nodeID = nid;
00226         numPes = numPes_;
00227         peIDs = new int[numPes];
00228         memcpy(peIDs, pes, sizeof(int)*numPes);
00229     }
00230 
00231     inline proxyTreeNode(const proxyTreeNode &n){
00232         nodeID = n.nodeID;
00233         numPes = n.numPes;
00234         if(numPes==0) {
00235             peIDs = NULL;
00236         }else{
00237             peIDs = new int[n.numPes];
00238             memcpy(peIDs, n.peIDs, sizeof(int)*numPes);
00239         }
00240     }
00241     inline proxyTreeNode &operator=(const proxyTreeNode &n){
00242         nodeID = n.nodeID;
00243         numPes = n.numPes;
00244         delete [] peIDs;
00245         if(numPes==0) {
00246             peIDs = NULL;
00247             return (*this);
00248         }
00249         peIDs = new int[n.numPes];
00250         memcpy(peIDs, n.peIDs, sizeof(int)*numPes);
00251         return (*this);
00252     }
00253     ~proxyTreeNode(){
00254         delete [] peIDs;
00255     }
00256 };
00257 
00258 typedef ResizeArray<proxyTreeNode> proxyTreeNodeList;
00259 #endif // __CUDACC__
00260 
00261 #endif /* NAMDTYPES_H */
00262 

Generated on Sat Sep 23 01:17:14 2017 for NAMD by  doxygen 1.4.7