PmeAtomFiler Class Reference

#include <ComputePmeCUDAMgr.h>

List of all members.

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 271 of file ComputePmeCUDAMgr.h.


Constructor & Destructor Documentation

PmeAtomFiler::PmeAtomFiler (  ) 

Definition at line 91 of file ComputePmeCUDAMgr.C.

00091                            {
00092   for (int p=0;p < 10;p++) {
00093     pencil[p] = NULL;
00094     pencilCapacity[p] = 0;
00095   }  
00096 }

PmeAtomFiler::PmeAtomFiler ( CkMigrateMessage *   ) 

Definition at line 97 of file ComputePmeCUDAMgr.C.

00097                                               {
00098   for (int p=0;p < 10;p++) {
00099     pencil[p] = NULL;
00100     pencilCapacity[p] = 0;
00101   }
00102 }

PmeAtomFiler::~PmeAtomFiler (  ) 

Definition at line 103 of file ComputePmeCUDAMgr.C.

00103                             {
00104   for (int p=0;p < 10;p++) {
00105     if (pencil[p] != NULL) delete [] pencil[p];
00106   }
00107 }


Member Function Documentation

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 115 of file ComputePmeCUDAMgr.C.

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

Referenced by ComputePmeCUDADevice::recvAtoms().

00116                                                                                                               {
00117 
00118   // Make sure there's enough room in the pencil arrays
00119   for (int p=0;p < 10;p++) {
00120     if (pencil[p] != NULL && pencilCapacity[p] < numAtoms) {
00121       delete [] pencil[p];
00122       pencil[p] = NULL;
00123       pencilCapacity[p] = 0;
00124     }
00125     if (pencil[p] == NULL) {
00126       int newSize = (int)(numAtoms*1.5);
00127       pencil[p] = new int[newSize];
00128       pencilCapacity[p] = newSize;
00129     }
00130     pencilSize[p] = 0;
00131   }
00132 
00133   const float recip11 = lattice.a_r().x;
00134   const float recip22 = lattice.b_r().y;
00135   const float recip33 = lattice.c_r().z;
00136   const int order1 = pmeGrid.order - 1;
00137   const int K1 = pmeGrid.K1;
00138   const int K2 = pmeGrid.K2;
00139   const int K3 = pmeGrid.K3;
00140   const int yBlocks = pmeGrid.yBlocks;
00141   const int zBlocks = pmeGrid.zBlocks;
00142 
00143   for (int i=0;i < numAtoms;i++) {
00144     float frx, fry, frz;
00145     // PmeRealSpaceCompute::calcGridCoord(atoms[i].uix, atoms[i].uiy, atoms[i].uiz,
00146     //   K1, K2, K3, frx, fry, frz);
00147     PmeRealSpaceCompute::calcGridCoord(atoms[i].x, atoms[i].y, atoms[i].z, K1, K2, K3, frx, fry, frz);
00148     // Charge is spread in the region [y0 ... y0+order-1] x [z0 ... z0+order-1]
00149     int y0 = (int)fry;
00150     int z0 = (int)frz;
00151     if (y0 < 0 || y0 >= K2 || z0 < 0 || z0 >= K3) {
00152       // Add to "Stray pencil" and skip to next atom
00153       pencil[9][pencilSize[9]++] = i;
00154       continue;
00155       // fprintf(stderr, "%lf %lf %lf\n", atoms[i].x, atoms[i].y, atoms[i].z);
00156       // NAMD_bug("PmeAtomFiler::fileAtoms, charge out of bounds");
00157     }
00158     // Calculate pencil index for the four corners of the order X order area
00159     // The corners determine the pencil indices for this atom.
00160     int occupied = 0;
00161     int plist[4];
00162 #pragma unroll
00163     for (int j=0;j < 4;j++) {
00164 
00165       int py = getPencilIndexY(pmeGrid, (y0 + (j%2)*order1) % K2) - pencilIndexY;
00166       if (py < ylo) py += yBlocks;
00167       if (py > yhi) py -= yBlocks;
00168 
00169       int pz = getPencilIndexZ(pmeGrid, (z0 + (j/2)*order1) % K3) - pencilIndexZ;
00170       if (pz < zlo) pz += zBlocks;
00171       if (pz > zhi) pz -= zBlocks;
00172 
00173       if (py < ylo || py > yhi || pz < zlo || pz > zhi) {
00174         // Add to "Stray pencil" and skip to next atom
00175         pencil[9][pencilSize[9]++] = i;
00176         goto breakjloop;
00177         // fprintf(stderr, "py %d [%d ... %d] pz %d [%d ... %d]\n", pz, zlo, zhi);
00178         // NAMD_bug("PmeAtomFiler::fileAtoms, py,pz outside bounds");
00179       }
00180       // p = 0,1,2,3,4,5,6,7,8 (maximum range)
00181       plist[j] = (py-ylo) + (pz-zlo)*3;
00182     }
00183 
00184 #pragma unroll
00185     for (int j=0;j < 4;j++) {
00186       int p = plist[j];
00187       // pbit = 0, 2, 4, 8, 16, 32, 64, 128, 256
00188       int pbit = (1 << p);
00189       if (!(occupied & pbit)) {
00190         pencil[p][pencilSize[p]++] = i;
00191         occupied |= pbit;
00192       }
00193     }
00194 
00195 breakjloop:
00196     continue;
00197   }
00198 
00199 }

int* PmeAtomFiler::getAtomIndex ( int  p  )  [inline]

Definition at line 281 of file ComputePmeCUDAMgr.h.

Referenced by ComputePmeCUDADevice::recvAtoms().

00281 {return pencil[p];}

int PmeAtomFiler::getNumAtoms ( int  p  )  [inline]

Definition at line 280 of file ComputePmeCUDAMgr.h.

Referenced by ComputePmeCUDADevice::recvAtoms().

00280 {return pencilSize[p];}


The documentation for this class was generated from the following files:
Generated on Tue Nov 21 01:17:20 2017 for NAMD by  doxygen 1.4.7