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 436 of file CudaPmeSolverUtil.C.

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

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

CudaPmeRealSpaceCompute::~CudaPmeRealSpaceCompute (  ) 

Definition at line 456 of file CudaPmeSolverUtil.C.

References cudaCheck, and PmeRealSpaceCompute::data.

00456                                                   {
00457   cudaCheck(cudaSetDevice(deviceID));
00458   if (d_atoms != NULL) deallocate_device<CudaAtom>(&d_atoms);
00459   if (d_force != NULL) deallocate_device<CudaForce>(&d_force);
00460   // if (d_patches != NULL) deallocate_device<PatchInfo>(&d_patches);
00461   // deallocate_device<double>(&d_selfEnergy);
00462   deallocate_device<float>(&data);
00463   cudaCheck(cudaEventDestroy(gatherForceEvent));
00464 }


Member Function Documentation

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

Implements PmeRealSpaceCompute.

Definition at line 487 of file CudaPmeSolverUtil.C.

References cudaCheck.

00487                                                                                  {
00488   cudaCheck(cudaSetDevice(deviceID));
00489   this->numAtoms = numAtoms;
00490 
00491   // Reallocate device arrays as neccessary
00492   reallocate_device<CudaAtom>(&d_atoms, &d_atomsCapacity, numAtoms, 1.5f);
00493 
00494   // Copy atom data to device
00495   copy_HtoD<CudaAtom>(atoms, d_atoms, numAtoms, stream);
00496 }

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

Implements PmeRealSpaceCompute.

Definition at line 582 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.

00582                                                                             {
00583   cudaCheck(cudaSetDevice(deviceID));
00584 
00585   // Re-allocate force array if needed
00586   reallocate_device<CudaForce>(&d_force, &d_forceCapacity, numAtoms, 1.5f);
00587 
00588   gather_force((const float4*)d_atoms, numAtoms,
00589     pmeGrid.K1, pmeGrid.K2, pmeGrid.K3,
00590     xsize, ysize, zsize, xsize, y0, z0, (pmeGrid.yBlocks == 1), (pmeGrid.zBlocks == 1),
00591     data, pmeGrid.order, (float3*)d_force, 
00592     gridTexObj,
00593     stream);
00594 
00595   copy_DtoH<CudaForce>(d_force, force, numAtoms, stream);
00596 
00597   cudaCheck(cudaEventRecord(gatherForceEvent, stream));
00598 }

void CudaPmeRealSpaceCompute::gatherForceSetCallback ( ComputePmeCUDADevice devicePtr_in  ) 

Definition at line 550 of file CudaPmeSolverUtil.C.

References CcdCallBacksReset(), and cudaCheck.

00550                                                                                        {
00551   cudaCheck(cudaSetDevice(deviceID));
00552   devicePtr = devicePtr_in;
00553   checkCount = 0;
00554   CcdCallBacksReset(0, CmiWallTimer());
00555   // Set the call back at 0.1ms
00556   CcdCallFnAfter(cuda_gatherforce_check, this, 0.1);
00557 }

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

Implements PmeRealSpaceCompute.

Definition at line 501 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.

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

void CudaPmeRealSpaceCompute::waitGatherForceDone (  ) 

Definition at line 559 of file CudaPmeSolverUtil.C.

References cudaCheck.

00559                                                   {
00560   cudaCheck(cudaSetDevice(deviceID));
00561   cudaCheck(cudaEventSynchronize(gatherForceEvent));
00562 }


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

Generated on 10 Dec 2018 for NAMD by  doxygen 1.6.1