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

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

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

CudaPmeRealSpaceCompute::~CudaPmeRealSpaceCompute (  ) 

Definition at line 460 of file CudaPmeSolverUtil.C.

References cudaCheck, and PmeRealSpaceCompute::data.

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


Member Function Documentation

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

Implements PmeRealSpaceCompute.

Definition at line 491 of file CudaPmeSolverUtil.C.

References atoms, and cudaCheck.

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

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

Implements PmeRealSpaceCompute.

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

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

void CudaPmeRealSpaceCompute::gatherForceSetCallback ( ComputePmeCUDADevice devicePtr_in  ) 

Definition at line 548 of file CudaPmeSolverUtil.C.

References CcdCallBacksReset(), and cudaCheck.

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

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

Implements PmeRealSpaceCompute.

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

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

void CudaPmeRealSpaceCompute::waitGatherForceDone (  ) 

Definition at line 557 of file CudaPmeSolverUtil.C.

References cudaCheck.

00557                                                   {
00558   cudaCheck(cudaSetDevice(deviceID));
00559   cudaCheck(cudaEventSynchronize(gatherForceEvent));
00560 }


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