NAMD
Public Member Functions | Protected Attributes | List of all members
PmeAtomStorage Class Referenceabstract

#include <ComputePmeCUDAMgr.h>

Inheritance diagram for PmeAtomStorage:
CpuPmeAtomStorage CudaPmeAtomStorage

Public Member Functions

 PmeAtomStorage (const bool useIndex)
 
virtual ~PmeAtomStorage ()
 
int addAtoms (const int natom, const CudaAtom *src, const std::vector< float *> &lambdaArrays)
 
int addAtomsWithIndex (const int natom, const CudaAtom *src, const int *index, const std::vector< float *> &lambdaArrays)
 
void finish ()
 
void clear ()
 
CudaAtomgetAtoms ()
 
float * getAtomElecFactors (unsigned int iGrid)
 
void setupAlch (const SimParameters &simParams)
 
int * getPatchPos ()
 
int getNumPatches ()
 
int getNumAtoms ()
 
int * getAtomIndex ()
 

Protected Attributes

CudaAtomatom
 
int * atomIndex
 
CudaAtomoverflowAtom
 
int * overflowAtomIndex
 
std::vector< float * > atomElecFactorArrays
 
std::vector< float * > overflowAtomElecFactorArrays
 
std::vector< int > overflowAtomElecFactorCapacities
 
std::vector< bool > enabledGrid
 
unsigned int totalFactorArrays
 
bool alchOn
 
bool alchFepOn
 
bool alchDecouple
 

Detailed Description

Definition at line 25 of file ComputePmeCUDAMgr.h.

Constructor & Destructor Documentation

◆ PmeAtomStorage()

PmeAtomStorage::PmeAtomStorage ( const bool  useIndex)
inline

Definition at line 27 of file ComputePmeCUDAMgr.h.

References alchDecouple, alchFepOn, alchOn, atom, atomElecFactorArrays, atomIndex, overflowAtom, overflowAtomElecFactorArrays, overflowAtomElecFactorCapacities, overflowAtomIndex, and totalFactorArrays.

27  : useIndex(useIndex) {
28  numAtoms = 0;
29  atomCapacity = 0;
30  atom = NULL;
31  atomIndexCapacity = 0;
32  atomIndex = NULL;
33  overflowStart = 0;
34  overflowEnd = 0;
35  overflowAtomCapacity = 0;
36  overflowAtom = NULL;
37  overflowAtomIndexCapacity = 0;
38  overflowAtomIndex = NULL;
40  atomElecFactorArrays = std::vector<float*>(0);
41  overflowAtomElecFactorArrays = std::vector<float*>(0);
42  overflowAtomElecFactorCapacities = std::vector<int>(0);
43  alchOn = false;
44  alchFepOn = false;
45  alchDecouple = false;
46  lock_ = CmiCreateLock();
47  }
std::vector< int > overflowAtomElecFactorCapacities
CudaAtom * overflowAtom
unsigned int totalFactorArrays
std::vector< float * > overflowAtomElecFactorArrays
std::vector< float * > atomElecFactorArrays

◆ ~PmeAtomStorage()

virtual PmeAtomStorage::~PmeAtomStorage ( )
inlinevirtual

Definition at line 48 of file ComputePmeCUDAMgr.h.

48  {
49  CmiDestroyLock(lock_);
50  }

Member Function Documentation

◆ addAtoms()

int PmeAtomStorage::addAtoms ( const int  natom,
const CudaAtom src,
const std::vector< float *> &  lambdaArrays 
)
inline

Definition at line 52 of file ComputePmeCUDAMgr.h.

52  {
53  return addAtoms_(natom, src, NULL, lambdaArrays);
54  }

◆ addAtomsWithIndex()

int PmeAtomStorage::addAtomsWithIndex ( const int  natom,
const CudaAtom src,
const int *  index,
const std::vector< float *> &  lambdaArrays 
)
inline

Definition at line 56 of file ComputePmeCUDAMgr.h.

56  {
57  return addAtoms_(natom, src, index, lambdaArrays);
58  }
Index index
Definition: Parameters.C:155

◆ clear()

void PmeAtomStorage::clear ( )
inline

Definition at line 87 of file ComputePmeCUDAMgr.h.

87  {
88  patchPos.clear();
89  numAtoms = 0;
90  }

◆ finish()

void PmeAtomStorage::finish ( )
inline

Definition at line 62 of file ComputePmeCUDAMgr.h.

References alchOn, atom, atomElecFactorArrays, atomIndex, enabledGrid, overflowAtom, overflowAtomElecFactorArrays, overflowAtomIndex, and totalFactorArrays.

62  {
63  if (overflowEnd-overflowStart > 0) {
64  resize_((void **)&atom, numAtoms, atomCapacity, sizeof(CudaAtom));
65  if (useIndex) resize_((void **)&atomIndex, numAtoms, atomIndexCapacity, sizeof(int));
66  if (alchOn) {
67  for (unsigned int i = 0; i < totalFactorArrays; ++i) {
68  if (enabledGrid[i] == true)
69  resize_((void **)&(atomElecFactorArrays[i]), numAtoms, overflowAtomCapacity, sizeof(float));
70  }
71  }
72  memcpy_(atom+overflowStart, overflowAtom, (overflowEnd - overflowStart)*sizeof(CudaAtom));
73  if (useIndex) memcpy_(atomIndex+overflowStart, overflowAtomIndex, (overflowEnd - overflowStart)*sizeof(int));
74  if (alchOn) {
75  for (unsigned int i = 0; i < totalFactorArrays; ++i) {
76  if (enabledGrid[i] == true)
77  memcpy_(atomElecFactorArrays[i]+overflowStart, overflowAtomElecFactorArrays[i], (overflowEnd - overflowStart)*sizeof(float));
78  }
79  }
80  overflowStart = 0;
81  overflowEnd = 0;
82  }
83  }
std::vector< bool > enabledGrid
CudaAtom * overflowAtom
unsigned int totalFactorArrays
std::vector< float * > overflowAtomElecFactorArrays
std::vector< float * > atomElecFactorArrays

◆ getAtomElecFactors()

float* PmeAtomStorage::getAtomElecFactors ( unsigned int  iGrid)
inline

Definition at line 98 of file ComputePmeCUDAMgr.h.

References atomElecFactorArrays.

98  {
99  return atomElecFactorArrays[iGrid];
100  }
std::vector< float * > atomElecFactorArrays

◆ getAtomIndex()

int* PmeAtomStorage::getAtomIndex ( )
inline

Definition at line 142 of file ComputePmeCUDAMgr.h.

References atomIndex, and NAMD_bug().

142  {
143  if (!useIndex)
144  NAMD_bug("PmeAtomStorage::getAtomIndex, no indexing enabled");
145  return atomIndex;
146  }
void NAMD_bug(const char *err_msg)
Definition: common.C:195

◆ getAtoms()

CudaAtom* PmeAtomStorage::getAtoms ( )
inline

Definition at line 93 of file ComputePmeCUDAMgr.h.

References atom.

93  {
94  return atom;
95  }

◆ getNumAtoms()

int PmeAtomStorage::getNumAtoms ( )
inline

Definition at line 138 of file ComputePmeCUDAMgr.h.

138  {
139  return numAtoms;
140  }

◆ getNumPatches()

int PmeAtomStorage::getNumPatches ( )
inline

Definition at line 134 of file ComputePmeCUDAMgr.h.

134  {
135  return patchPos.size();
136  }

◆ getPatchPos()

int* PmeAtomStorage::getPatchPos ( )
inline

Definition at line 130 of file ComputePmeCUDAMgr.h.

130  {
131  return patchPos.data();
132  }

◆ setupAlch()

void PmeAtomStorage::setupAlch ( const SimParameters simParams)
inline

Definition at line 101 of file ComputePmeCUDAMgr.h.

References alchDecouple, alchFepOn, alchOn, atomElecFactorArrays, enabledGrid, NUM_GRID_MAX, overflowAtomElecFactorArrays, overflowAtomElecFactorCapacities, simParams, and totalFactorArrays.

101  {
102  alchOn = simParams.alchOn;
103  alchFepOn = simParams.alchFepOn;
104  alchDecouple = simParams.alchDecouple;
105  if (alchOn) {
106  enabledGrid.resize(NUM_GRID_MAX, false);
107  totalFactorArrays = 2;
108  enabledGrid[0] = true;
109  enabledGrid[1] = true;
110  if (alchDecouple) {
111  totalFactorArrays = 4;
112  enabledGrid[2] = true;
113  enabledGrid[3] = true;
114  }
115  if (bool(simParams.alchElecLambdaStart)) {
116  totalFactorArrays = 5;
117  enabledGrid[4] = true;
118  }
119  if (simParams.alchThermIntOn) {
120  totalFactorArrays = 5;
121  enabledGrid[4] = true;
122  }
126  }
127  }
std::vector< bool > enabledGrid
const unsigned int NUM_GRID_MAX
Definition: PmeSolverUtil.h:9
std::vector< int > overflowAtomElecFactorCapacities
unsigned int totalFactorArrays
#define simParams
Definition: Output.C:129
std::vector< float * > overflowAtomElecFactorArrays
std::vector< float * > atomElecFactorArrays

Member Data Documentation

◆ alchDecouple

bool PmeAtomStorage::alchDecouple
protected

Definition at line 165 of file ComputePmeCUDAMgr.h.

Referenced by PmeAtomStorage(), and setupAlch().

◆ alchFepOn

bool PmeAtomStorage::alchFepOn
protected

Definition at line 164 of file ComputePmeCUDAMgr.h.

Referenced by PmeAtomStorage(), and setupAlch().

◆ alchOn

bool PmeAtomStorage::alchOn
protected

◆ atom

CudaAtom* PmeAtomStorage::atom
protected

◆ atomElecFactorArrays

std::vector<float*> PmeAtomStorage::atomElecFactorArrays
protected

◆ atomIndex

int* PmeAtomStorage::atomIndex
protected

◆ enabledGrid

std::vector<bool> PmeAtomStorage::enabledGrid
protected

Definition at line 161 of file ComputePmeCUDAMgr.h.

Referenced by finish(), and setupAlch().

◆ overflowAtom

CudaAtom* PmeAtomStorage::overflowAtom
protected

◆ overflowAtomElecFactorArrays

std::vector<float*> PmeAtomStorage::overflowAtomElecFactorArrays
protected

◆ overflowAtomElecFactorCapacities

std::vector<int> PmeAtomStorage::overflowAtomElecFactorCapacities
protected

Definition at line 160 of file ComputePmeCUDAMgr.h.

Referenced by PmeAtomStorage(), and setupAlch().

◆ overflowAtomIndex

int* PmeAtomStorage::overflowAtomIndex
protected

◆ totalFactorArrays

unsigned int PmeAtomStorage::totalFactorArrays
protected

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