NAMD
Public Member Functions | List of all members
AtomMapper Class Reference

#include <AtomMap.h>

Public Member Functions

 AtomMapper (PatchID _pid)
 
 ~AtomMapper ()
 
void registerIDsCompAtomExt (const CompAtomExt *begin, const CompAtomExt *end)
 
void registerIDsFullAtom (const FullAtom *begin, const FullAtom *end)
 
void unregisterIDsCompAtomExt (const CompAtomExt *begin, const CompAtomExt *end)
 
void unregisterIDsFullAtom (const FullAtom *begin, const FullAtom *end)
 

Detailed Description

Definition at line 81 of file AtomMap.h.

Constructor & Destructor Documentation

AtomMapper::AtomMapper ( PatchID  _pid)
inline

Definition at line 83 of file AtomMap.h.

83 : pid(_pid), mapped(0), map(AtomMap::Object()) {}
static AtomMap * Object()
Definition: AtomMap.h:36
AtomMapper::~AtomMapper ( )
inline

Definition at line 89 of file AtomMap.h.

References NAMD_bug().

89  {
90  if ( mapped ) NAMD_bug("deleted AtomMapper with atoms still mapped");
91  }
void NAMD_bug(const char *err_msg)
Definition: common.C:123

Member Function Documentation

void AtomMapper::registerIDsCompAtomExt ( const CompAtomExt begin,
const CompAtomExt end 
)

Definition at line 24 of file AtomMap.C.

References NAMD_bug().

Referenced by Patch::positionsReady().

24  {
25  if ( mapped ) return;
26  mapped = 1;
27 #ifdef MEM_OPT_VERSION
28  if ( ! map->onlyUseTbl ) {
29  int n = end - begin;
30  entries.resize(n);
31  AtomMapEntry *e = entries.begin();
32  for ( int i=0; i<n; ++i, ++e ) {
33  e->pid = pid;
34  e->index = i;
35  AtomID aid = begin[i].id;
36  short aid_upper = aid >> MAXBITS;
37  e->aid_upper = aid_upper;
38  int aid_hash = aid & (MAXNUMATOMS-1);
39  AtomMapEntry **me = map->entries + aid_hash;
40  while ( *me && (*me)->aid_upper < aid_upper ) me = &((*me)->next);
41  e->next = *me;
42  *me = e;
43  }
44  } else
45 #endif
46  if ( map->registerIDsCompAtomExt(pid, begin, end) ) NAMD_bug("atom map failed");
47 }
int AtomID
Definition: NamdTypes.h:29
void NAMD_bug(const char *err_msg)
Definition: common.C:123
void AtomMapper::registerIDsFullAtom ( const FullAtom begin,
const FullAtom end 
)

Definition at line 50 of file AtomMap.C.

References NAMD_bug().

Referenced by Sequencer::integrate(), Sequencer::minimize(), HomePatch::recvCheckpointLoad(), HomePatch::recvExchangeMsg(), and HomePatch::revert().

50  {
51  if ( mapped ) return;
52  mapped = 1;
53 #ifdef MEM_OPT_VERSION
54  if ( ! map->onlyUseTbl ) {
55  int n = end - begin;
56  entries.resize(n);
57  AtomMapEntry *e = entries.begin();
58  for ( int i=0; i<n; ++i, ++e ) {
59  e->pid = pid;
60  e->index = i;
61  AtomID aid = begin[i].id;
62  short aid_upper = aid >> MAXBITS;
63  e->aid_upper = aid_upper;
64  int aid_hash = aid & (MAXNUMATOMS-1);
65  AtomMapEntry **me = map->entries + aid_hash;
66  while ( *me && (*me)->aid_upper < aid_upper ) me = &((*me)->next);
67  e->next = *me;
68  *me = e;
69  }
70  } else
71 #endif
72  if ( map->registerIDsFullAtom(pid, begin, end) ) NAMD_bug("atom map failed");
73 }
int AtomID
Definition: NamdTypes.h:29
void NAMD_bug(const char *err_msg)
Definition: common.C:123
void AtomMapper::unregisterIDsCompAtomExt ( const CompAtomExt begin,
const CompAtomExt end 
)

Definition at line 76 of file AtomMap.C.

References NAMD_bug().

Referenced by ProxyPatch::receiveAll(), and ProxyPatch::~ProxyPatch().

76  {
77  if ( ! mapped ) return;
78  mapped = 0;
79 #ifdef MEM_OPT_VERSION
80  if ( ! map->onlyUseTbl ) {
81  int n = end - begin;
82  if ( entries.size() != n ) {
83  CkPrintf("AtomMapper entries.size() %d != %d\n", entries.size(), n);
84  NAMD_bug("AtomMapper::unregisterIDsCompAtomExt size mismatch");
85  }
86  AtomMapEntry *e = entries.begin();
87  for ( int i=0; i<n; ++i, ++e ) {
88  AtomID aid = begin[i].id;
89  int aid_hash = aid & (MAXNUMATOMS-1);
90  AtomMapEntry **me = map->entries + aid_hash;
91  while ( *me != e ) me = &((*me)->next);
92  *me = e->next;
93  }
94  } else
95 #endif
96  if ( map->unregisterIDsCompAtomExt(pid, begin, end) ) NAMD_bug("atom map failed");
97 }
int AtomID
Definition: NamdTypes.h:29
void NAMD_bug(const char *err_msg)
Definition: common.C:123
void AtomMapper::unregisterIDsFullAtom ( const FullAtom begin,
const FullAtom end 
)

Definition at line 100 of file AtomMap.C.

References NAMD_bug().

Referenced by HomePatch::doAtomMigration(), HomePatch::recvCheckpointLoad(), HomePatch::recvExchangeMsg(), HomePatch::revert(), and HomePatch::~HomePatch().

100  {
101  if ( ! mapped ) return;
102  mapped = 0;
103 #ifdef MEM_OPT_VERSION
104  if ( ! map->onlyUseTbl ) {
105  int n = end - begin;
106  if ( entries.size() != n ) {
107  CkPrintf("AtomMapper entries.size() %d != %d\n", entries.size(), n);
108  NAMD_bug("AtomMapper::unregisterIDsFullAtom size mismatch");
109  }
110  AtomMapEntry *e = entries.begin();
111  for ( int i=0; i<n; ++i, ++e ) {
112  AtomID aid = begin[i].id;
113  int aid_hash = aid & (MAXNUMATOMS-1);
114  AtomMapEntry **me = map->entries + aid_hash;
115  while ( *me != e ) me = &((*me)->next);
116  *me = e->next;
117  }
118  } else
119 #endif
120  if ( map->unregisterIDsFullAtom(pid, begin, end) ) NAMD_bug("atom map failed");
121 }
int AtomID
Definition: NamdTypes.h:29
void NAMD_bug(const char *err_msg)
Definition: common.C:123

The documentation for this class was generated from the following files: