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

#include <ComputePmeCUDAMgr.h>

Inheritance diagram for PmeAtomFiler:

Public Member Functions

 PmeAtomFiler ()
 
 PmeAtomFiler (CkMigrateMessage *)
 
 ~PmeAtomFiler ()
 
void fileAtoms (const int numAtoms, const CudaAtom *atoms, Lattice &lattice, const PmeGrid &pmeGrid, const int pencilIndexY, const int pencilIndexZ, const int ylo, const int yhi, const int zlo, const int zhi)
 
int getNumAtoms (int p)
 
int * getAtomIndex (int p)
 

Detailed Description

Definition at line 400 of file ComputePmeCUDAMgr.h.

Constructor & Destructor Documentation

◆ PmeAtomFiler() [1/2]

PmeAtomFiler::PmeAtomFiler ( )

Definition at line 108 of file ComputePmeCUDAMgr.C.

108  {
109  for (int p=0;p < 10;p++) {
110  pencil[p] = NULL;
111  pencilCapacity[p] = 0;
112  }
113 }

◆ PmeAtomFiler() [2/2]

PmeAtomFiler::PmeAtomFiler ( CkMigrateMessage *  m)

Definition at line 114 of file ComputePmeCUDAMgr.C.

114  {
115  for (int p=0;p < 10;p++) {
116  pencil[p] = NULL;
117  pencilCapacity[p] = 0;
118  }
119 }

◆ ~PmeAtomFiler()

PmeAtomFiler::~PmeAtomFiler ( )

Definition at line 120 of file ComputePmeCUDAMgr.C.

120  {
121  for (int p=0;p < 10;p++) {
122  if (pencil[p] != NULL) delete [] pencil[p];
123  }
124 }

Member Function Documentation

◆ fileAtoms()

void PmeAtomFiler::fileAtoms ( const int  numAtoms,
const CudaAtom atoms,
Lattice lattice,
const PmeGrid pmeGrid,
const int  pencilIndexY,
const int  pencilIndexZ,
const int  ylo,
const int  yhi,
const int  zlo,
const int  zhi 
)

Definition at line 132 of file ComputePmeCUDAMgr.C.

References Lattice::a_r(), Lattice::b_r(), Lattice::c_r(), PmeRealSpaceCompute::calcGridCoord(), DebugM, endi(), getPencilIndexY(), getPencilIndexZ(), PmeGrid::K1, PmeGrid::K2, PmeGrid::K3, PmeGrid::order, Vector::x, Vector::y, PmeGrid::yBlocks, Vector::z, and PmeGrid::zBlocks.

Referenced by ComputePmeCUDADevice::recvAtoms().

133  {
134  DebugM(2, "PmeAtomFiler::fileAtoms\n" << endi);
135  // Make sure there's enough room in the pencil arrays
136  for (int p=0;p < 10;p++) {
137  if (pencil[p] != NULL && pencilCapacity[p] < numAtoms) {
138  delete [] pencil[p];
139  pencil[p] = NULL;
140  pencilCapacity[p] = 0;
141  }
142  if (pencil[p] == NULL) {
143  int newSize = (int)(numAtoms*1.5);
144  pencil[p] = new int[newSize];
145  pencilCapacity[p] = newSize;
146  }
147  pencilSize[p] = 0;
148  }
149 
150  const float recip11 = lattice.a_r().x;
151  const float recip22 = lattice.b_r().y;
152  const float recip33 = lattice.c_r().z;
153  const int order1 = pmeGrid.order - 1;
154  const int K1 = pmeGrid.K1;
155  const int K2 = pmeGrid.K2;
156  const int K3 = pmeGrid.K3;
157  const int yBlocks = pmeGrid.yBlocks;
158  const int zBlocks = pmeGrid.zBlocks;
159 
160  for (int i=0;i < numAtoms;i++) {
161  float frx, fry, frz;
162  // PmeRealSpaceCompute::calcGridCoord(atoms[i].uix, atoms[i].uiy, atoms[i].uiz,
163  // K1, K2, K3, frx, fry, frz);
164  PmeRealSpaceCompute::calcGridCoord(atoms[i].x, atoms[i].y, atoms[i].z, K1, K2, K3, frx, fry, frz);
165  // Charge is spread in the region [y0 ... y0+order-1] x [z0 ... z0+order-1]
166  int y0 = (int)fry;
167  int z0 = (int)frz;
168  if (y0 < 0 || y0 >= K2 || z0 < 0 || z0 >= K3) {
169  // Add to "Stray pencil" and skip to next atom
170  pencil[9][pencilSize[9]++] = i;
171  continue;
172  // fprintf(stderr, "%lf %lf %lf\n", atoms[i].x, atoms[i].y, atoms[i].z);
173  // NAMD_bug("PmeAtomFiler::fileAtoms, charge out of bounds");
174  }
175  // Calculate pencil index for the four corners of the order X order area
176  // The corners determine the pencil indices for this atom.
177  int occupied = 0;
178  int plist[4];
179 #pragma unroll
180  for (int j=0;j < 4;j++) {
181 
182  int py = getPencilIndexY(pmeGrid, (y0 + (j%2)*order1) % K2) - pencilIndexY;
183  if (py < ylo) py += yBlocks;
184  if (py > yhi) py -= yBlocks;
185 
186  int pz = getPencilIndexZ(pmeGrid, (z0 + (j/2)*order1) % K3) - pencilIndexZ;
187  if (pz < zlo) pz += zBlocks;
188  if (pz > zhi) pz -= zBlocks;
189 
190  if (py < ylo || py > yhi || pz < zlo || pz > zhi) {
191  // Add to "Stray pencil" and skip to next atom
192  pencil[9][pencilSize[9]++] = i;
193  goto breakjloop;
194  // fprintf(stderr, "py %d [%d ... %d] pz %d [%d ... %d]\n", pz, zlo, zhi);
195  // NAMD_bug("PmeAtomFiler::fileAtoms, py,pz outside bounds");
196  }
197  // p = 0,1,2,3,4,5,6,7,8 (maximum range)
198  plist[j] = (py-ylo) + (pz-zlo)*3;
199  }
200 
201 #pragma unroll
202  for (int j=0;j < 4;j++) {
203  int p = plist[j];
204  // pbit = 0, 2, 4, 8, 16, 32, 64, 128, 256
205  int pbit = (1 << p);
206  if (!(occupied & pbit)) {
207  pencil[p][pencilSize[p]++] = i;
208  occupied |= pbit;
209  }
210  }
211 
212 breakjloop:
213  continue;
214  }
215 
216 }
int zBlocks
Definition: PmeBase.h:25
int K2
Definition: PmeBase.h:21
int K1
Definition: PmeBase.h:21
#define DebugM(x, y)
Definition: Debug.h:75
std::ostream & endi(std::ostream &s)
Definition: InfoStream.C:54
BigReal z
Definition: Vector.h:74
static int getPencilIndexY(const PmeGrid &pmeGrid, const int y)
Definition: PmeSolverUtil.h:23
static double calcGridCoord(const double x, const double recip11, const int nfftx)
int yBlocks
Definition: PmeBase.h:25
int order
Definition: PmeBase.h:23
BigReal x
Definition: Vector.h:74
NAMD_HOST_DEVICE Vector a_r() const
Definition: Lattice.h:284
NAMD_HOST_DEVICE Vector b_r() const
Definition: Lattice.h:285
NAMD_HOST_DEVICE Vector c_r() const
Definition: Lattice.h:286
int K3
Definition: PmeBase.h:21
BigReal y
Definition: Vector.h:74
static int getPencilIndexZ(const PmeGrid &pmeGrid, const int z)
Definition: PmeSolverUtil.h:28

◆ getAtomIndex()

int* PmeAtomFiler::getAtomIndex ( int  p)
inline

Definition at line 410 of file ComputePmeCUDAMgr.h.

Referenced by ComputePmeCUDADevice::recvAtoms().

410 {return pencil[p];}

◆ getNumAtoms()

int PmeAtomFiler::getNumAtoms ( int  p)
inline

Definition at line 409 of file ComputePmeCUDAMgr.h.

Referenced by ComputePmeCUDADevice::recvAtoms().

409 {return pencilSize[p];}

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