CudaPmeRealSpaceCompute Class Reference

#include <CudaPmeSolverUtil.h>

Inheritance diagram for CudaPmeRealSpaceCompute:

PmeRealSpaceCompute List of all members.

Public Member Functions

 CudaPmeRealSpaceCompute (PmeGrid pmeGrid, const int jblock, const int kblock, int deviceID, cudaStream_t stream)
 ~CudaPmeRealSpaceCompute ()
void copyAtoms (const int numAtoms, const CudaAtom *atoms)
void spreadCharge (Lattice &lattice)
void gatherForce (Lattice &lattice, CudaForce *force)
void gatherForceSetCallback (ComputePmeCUDADevice *devicePtr_in)
void waitGatherForceDone ()

Detailed Description

Definition at line 98 of file CudaPmeSolverUtil.h.


Constructor & Destructor Documentation

CudaPmeRealSpaceCompute::CudaPmeRealSpaceCompute ( PmeGrid  pmeGrid,
const int  jblock,
const int  kblock,
int  deviceID,
cudaStream_t  stream 
)

Definition at line 430 of file CudaPmeSolverUtil.C.

References cudaCheck, PmeRealSpaceCompute::data, PmeRealSpaceCompute::dataSize, NAMD_bug(), PmeRealSpaceCompute::xsize, PmeRealSpaceCompute::ysize, and PmeRealSpaceCompute::zsize.

00431                                                                          : 
00432   PmeRealSpaceCompute(pmeGrid, jblock, kblock), deviceID(deviceID), stream(stream) {
00433   if (dataSize < xsize*ysize*zsize)
00434     NAMD_bug("CudaPmeRealSpaceCompute::CudaPmeRealSpaceCompute, insufficient dataSize");
00435   cudaCheck(cudaSetDevice(deviceID));
00436   d_atomsCapacity = 0;
00437   d_atoms = NULL;
00438   d_forceCapacity = 0;
00439   d_force = NULL;
00440   tex_data = NULL;
00441   tex_data_len = 0;
00442   allocate_device<float>(&data, dataSize);
00443   setupGridTexture(data, xsize*ysize*zsize);
00444   cudaCheck(cudaEventCreate(&gatherForceEvent));
00445 }

CudaPmeRealSpaceCompute::~CudaPmeRealSpaceCompute (  ) 

Definition at line 450 of file CudaPmeSolverUtil.C.

References cudaCheck, and PmeRealSpaceCompute::data.

00450                                                   {
00451   cudaCheck(cudaSetDevice(deviceID));
00452   if (d_atoms != NULL) deallocate_device<CudaAtom>(&d_atoms);
00453   if (d_force != NULL) deallocate_device<CudaForce>(&d_force);
00454   // if (d_patches != NULL) deallocate_device<PatchInfo>(&d_patches);
00455   // deallocate_device<double>(&d_selfEnergy);
00456   deallocate_device<float>(&data);
00457   cudaCheck(cudaEventDestroy(gatherForceEvent));
00458 }


Member Function Documentation

void CudaPmeRealSpaceCompute::copyAtoms ( const int  numAtoms,
const CudaAtom atoms 
) [virtual]

Implements PmeRealSpaceCompute.

Definition at line 481 of file CudaPmeSolverUtil.C.

References atoms, and cudaCheck.

00481                                                                                  {
00482   cudaCheck(cudaSetDevice(deviceID));
00483   this->numAtoms = numAtoms;
00484 
00485   // Reallocate device arrays as neccessary
00486   reallocate_device<CudaAtom>(&d_atoms, &d_atomsCapacity, numAtoms, 1.5f);
00487 
00488   // Copy atom data to device
00489   copy_HtoD<CudaAtom>(atoms, d_atoms, numAtoms, stream);
00490 }

void CudaPmeRealSpaceCompute::gatherForce ( Lattice lattice,
CudaForce force 
) [virtual]

Implements PmeRealSpaceCompute.

Definition at line 570 of file CudaPmeSolverUtil.C.

References cudaCheck, gather_force(), PmeGrid::K1, PmeGrid::K2, PmeGrid::K3, PmeRealSpaceCompute::numAtoms, PmeGrid::order, PmeRealSpaceCompute::pmeGrid, PmeRealSpaceCompute::xsize, PmeRealSpaceCompute::y0, PmeGrid::yBlocks, PmeRealSpaceCompute::ysize, PmeRealSpaceCompute::z0, PmeGrid::zBlocks, and PmeRealSpaceCompute::zsize.

00570                                                                             {
00571   cudaCheck(cudaSetDevice(deviceID));
00572 
00573   // Re-allocate force array if needed
00574   reallocate_device<CudaForce>(&d_force, &d_forceCapacity, numAtoms, 1.5f);
00575 
00576   gather_force((const float4*)d_atoms, numAtoms,
00577     pmeGrid.K1, pmeGrid.K2, pmeGrid.K3,
00578     xsize, ysize, zsize, xsize, y0, z0, (pmeGrid.yBlocks == 1), (pmeGrid.zBlocks == 1),
00579     data, pmeGrid.order, (float3*)d_force, 
00580     gridTexObj,
00581     stream);
00582 
00583   copy_DtoH<CudaForce>(d_force, force, numAtoms, stream);
00584 
00585   cudaCheck(cudaEventRecord(gatherForceEvent, stream));
00586 }

void CudaPmeRealSpaceCompute::gatherForceSetCallback ( ComputePmeCUDADevice devicePtr_in  ) 

Definition at line 538 of file CudaPmeSolverUtil.C.

References CcdCallBacksReset(), and cudaCheck.

00538                                                                                        {
00539   cudaCheck(cudaSetDevice(deviceID));
00540   devicePtr = devicePtr_in;
00541   checkCount = 0;
00542   CcdCallBacksReset(0, CmiWallTimer());
00543   // Set the call back at 0.1ms
00544   CcdCallFnAfter(cuda_gatherforce_check, this, 0.1);
00545 }

void CudaPmeRealSpaceCompute::spreadCharge ( Lattice lattice  )  [virtual]

Implements PmeRealSpaceCompute.

Definition at line 495 of file CudaPmeSolverUtil.C.

References cudaCheck, PmeRealSpaceCompute::data, PmeGrid::K1, PmeGrid::K2, PmeGrid::K3, PmeRealSpaceCompute::numAtoms, PmeGrid::order, PmeRealSpaceCompute::pmeGrid, spread_charge(), PmeRealSpaceCompute::xsize, PmeRealSpaceCompute::y0, PmeGrid::yBlocks, PmeRealSpaceCompute::ysize, PmeRealSpaceCompute::z0, PmeGrid::zBlocks, and PmeRealSpaceCompute::zsize.

00495                                                            {
00496   cudaCheck(cudaSetDevice(deviceID));
00497 
00498   // Clear grid
00499   clear_device_array<float>(data, xsize*ysize*zsize, stream);
00500 
00501   spread_charge((const float4*)d_atoms, numAtoms,
00502     pmeGrid.K1, pmeGrid.K2, pmeGrid.K3, xsize, ysize, zsize,
00503     xsize, y0, z0, (pmeGrid.yBlocks == 1), (pmeGrid.zBlocks == 1),
00504     data, pmeGrid.order, stream);
00505 
00506   // ncall++;
00507 
00508   // if (ncall == 1) writeRealToDisk(data, xsize*ysize*zsize, "data.txt");
00509 }

void CudaPmeRealSpaceCompute::waitGatherForceDone (  ) 

Definition at line 547 of file CudaPmeSolverUtil.C.

References cudaCheck.

00547                                                   {
00548   cudaCheck(cudaSetDevice(deviceID));
00549   cudaCheck(cudaEventSynchronize(gatherForceEvent));
00550 }


The documentation for this class was generated from the following files:
Generated on Tue Oct 16 01:17:19 2018 for NAMD by  doxygen 1.4.7