Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

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

Generated on Sat May 25 04:07:18 2013 for NAMD by  doxygen 1.3.9.1