AtomMap.h

Go to the documentation of this file.
00001 
00014 #ifndef ATOMMAP_H
00015 #define ATOMMAP_H
00016 
00017 #include "NamdTypes.h"
00018 
00019 #ifdef MEM_OPT_VERSION
00020 
00021 struct AtomMapEntry {
00022   AtomMapEntry *next;
00023   int pid;
00024   short index;
00025   short aid_upper;
00026 };
00027 
00028 #endif
00029 
00030 enum { notUsed = -1 };
00031 
00032 class AtomMap
00033 {
00034 public:
00035   static AtomMap *Instance();
00036   inline static AtomMap *Object() { return CkpvAccess(AtomMap_instance); }
00037   ~AtomMap(void);
00038   void checkMap();
00039 
00040   void allocateMap(int nAtomIDs);
00041 
00042   LocalID localID(AtomID id);
00043 
00044   friend class AtomMapper;
00045 #ifdef NAMD_CUDA
00046 #ifdef BONDED_CUDA
00047   friend class ComputeBondedCUDA;
00048 #endif
00049 #endif
00050 
00051 protected:
00052   AtomMap(void);
00053 
00054 private:
00055   int registerIDsCompAtomExt(PatchID pid, const CompAtomExt *begin, const CompAtomExt *end);
00056   int registerIDsFullAtom(PatchID pid, const FullAtom *begin, const FullAtom *end);
00057   int unregisterIDsCompAtomExt(PatchID pid, const CompAtomExt *begin, const CompAtomExt *end);
00058   int unregisterIDsFullAtom(PatchID pid, const FullAtom *begin, const FullAtom *end);
00059 
00060 #ifdef MEM_OPT_VERSION
00061   AtomMapEntry **entries;
00062   bool onlyUseTbl;
00063 #endif
00064 
00065   LocalID *localIDTable;
00066   int tableSz;
00067 
00068 };
00069 
00070 #ifndef MEM_OPT_VERSION
00071 //----------------------------------------------------------------------
00072 // LocalID contains patch pid and local patch atom index
00073 // for a given global atom number
00074 inline LocalID AtomMap::localID(AtomID id)
00075 {
00076   return localIDTable[id];
00077 }
00078 #endif
00079 
00080 
00081 class AtomMapper {
00082 public:
00083   AtomMapper(PatchID _pid) : pid(_pid), mapped(0), map(AtomMap::Object()) {}
00084 #ifdef NAMD_CUDA
00085 #ifdef BONDED_CUDA
00086   AtomMapper(PatchID _pid, AtomMap *_map) : pid(_pid), mapped(0), map(_map) {}
00087 #endif
00088 #endif
00089   ~AtomMapper() {
00090     if ( mapped ) NAMD_bug("deleted AtomMapper with atoms still mapped");
00091   }
00092   void registerIDsCompAtomExt(const CompAtomExt *begin, const CompAtomExt *end);
00093   void registerIDsFullAtom(const FullAtom *begin, const FullAtom *end);
00094   void unregisterIDsCompAtomExt(const CompAtomExt *begin, const CompAtomExt *end);
00095   void unregisterIDsFullAtom(const FullAtom *begin, const FullAtom *end);
00096 
00097 private:
00098   const PatchID pid;
00099   int mapped;
00100   AtomMap *map;
00101 #ifdef MEM_OPT_VERSION
00102   ResizeArray<AtomMapEntry> entries;
00103 #endif
00104 };
00105 
00106 
00107 #endif /* ATOMMAP_H */
00108 

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