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

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

00444                                                                          : 
00445   PmeRealSpaceCompute(pmeGrid, jblock, kblock), deviceID(deviceID), stream(stream) {
00446   if (dataSize < xsize*ysize*zsize)
00447     NAMD_bug("CudaPmeRealSpaceCompute::CudaPmeRealSpaceCompute, insufficient dataSize");
00448   cudaCheck(cudaSetDevice(deviceID));
00449   d_atomsCapacity = 0;
00450   d_atoms = NULL;
00451   d_forceCapacity = 0;
00452   d_force = NULL;
00453   tex_data = NULL;
00454   tex_data_len = 0;
00455   allocate_device<float>(&data, dataSize);
00456   setupGridTexture(data, xsize*ysize*zsize);
00457   cudaCheck(cudaEventCreate(&gatherForceEvent));
00458 }

CudaPmeRealSpaceCompute::~CudaPmeRealSpaceCompute (  ) 

Definition at line 463 of file CudaPmeSolverUtil.C.

References cudaCheck, and PmeRealSpaceCompute::data.

00463                                                   {
00464   cudaCheck(cudaSetDevice(deviceID));
00465   if (d_atoms != NULL) deallocate_device<CudaAtom>(&d_atoms);
00466   if (d_force != NULL) deallocate_device<CudaForce>(&d_force);
00467   // if (d_patches != NULL) deallocate_device<PatchInfo>(&d_patches);
00468   // deallocate_device<double>(&d_selfEnergy);
00469   deallocate_device<float>(&data);
00470   cudaCheck(cudaEventDestroy(gatherForceEvent));
00471 }


Member Function Documentation

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

Implements PmeRealSpaceCompute.

Definition at line 494 of file CudaPmeSolverUtil.C.

References cudaCheck.

00494                                                                                  {
00495   cudaCheck(cudaSetDevice(deviceID));
00496   this->numAtoms = numAtoms;
00497 
00498   // Reallocate device arrays as neccessary
00499   reallocate_device<CudaAtom>(&d_atoms, &d_atomsCapacity, numAtoms, 1.5f);
00500 
00501   // Copy atom data to device
00502   copy_HtoD<CudaAtom>(atoms, d_atoms, numAtoms, stream);
00503 }

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

Implements PmeRealSpaceCompute.

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

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

void CudaPmeRealSpaceCompute::gatherForceSetCallback ( ComputePmeCUDADevice devicePtr_in  ) 

Definition at line 557 of file CudaPmeSolverUtil.C.

References CcdCallBacksReset(), and cudaCheck.

00557                                                                                        {
00558   cudaCheck(cudaSetDevice(deviceID));
00559   devicePtr = devicePtr_in;
00560   checkCount = 0;
00561   CcdCallBacksReset(0, CmiWallTimer());
00562   // Set the call back at 0.1ms
00563   CcdCallFnAfter(cuda_gatherforce_check, this, 0.1);
00564 }

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

Implements PmeRealSpaceCompute.

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

00508                                                            {
00509   cudaCheck(cudaSetDevice(deviceID));
00510 
00511   // Clear grid
00512   clear_device_array<float>(data, xsize*ysize*zsize, stream);
00513 
00514   spread_charge((const float4*)d_atoms, numAtoms,
00515     pmeGrid.K1, pmeGrid.K2, pmeGrid.K3, xsize, ysize, zsize,
00516     xsize, y0, z0, (pmeGrid.yBlocks == 1), (pmeGrid.zBlocks == 1),
00517     data, pmeGrid.order, stream);
00518 
00519   // ncall++;
00520 
00521   // if (ncall == 1) writeRealToDisk(data, xsize*ysize*zsize, "data.txt");
00522 }

void CudaPmeRealSpaceCompute::waitGatherForceDone (  ) 

Definition at line 566 of file CudaPmeSolverUtil.C.

References cudaCheck.

00566                                                   {
00567   cudaCheck(cudaSetDevice(deviceID));
00568   cudaCheck(cudaEventSynchronize(gatherForceEvent));
00569 }


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

Generated on 21 Sep 2020 for NAMD by  doxygen 1.6.1