NAMD
Public Member Functions | List of all members
CudaPmePencilZ Class Reference

#include <CudaPmeSolver.h>

Inheritance diagram for CudaPmePencilZ:

Public Member Functions

CudaPmePencilZ_SDAG_CODE CudaPmePencilZ ()
 
 CudaPmePencilZ (CkMigrateMessage *m)
 
 ~CudaPmePencilZ ()
 
void initialize (CudaPmeXInitMsg *msg)
 
void initialize (CudaPmeXYInitMsg *msg)
 
void initializeDevice (InitDeviceMsg2 *msg)
 
void energyAndVirialDone (unsigned int iGrid)
 

Detailed Description

Definition at line 190 of file CudaPmeSolver.h.

Constructor & Destructor Documentation

◆ CudaPmePencilZ() [1/2]

CudaPmePencilZ_SDAG_CODE CudaPmePencilZ::CudaPmePencilZ ( )
inline

Definition at line 193 of file CudaPmeSolver.h.

193 : numGetDeviceBufferY(0), numGetDeviceBufferXY(0), eventCreated(false) {}

◆ CudaPmePencilZ() [2/2]

CudaPmePencilZ::CudaPmePencilZ ( CkMigrateMessage *  m)
inline

Definition at line 194 of file CudaPmeSolver.h.

194 : numGetDeviceBufferY(0), numGetDeviceBufferXY(0), eventCreated(false) {}

◆ ~CudaPmePencilZ()

CudaPmePencilZ::~CudaPmePencilZ ( )

Definition at line 858 of file CudaPmeSolver.C.

References cudaCheck.

858  {
859  if (eventCreated) cudaCheck(cudaEventDestroy(event));
860 }
#define cudaCheck(stmt)
Definition: CudaUtils.h:233

Member Function Documentation

◆ energyAndVirialDone()

void CudaPmePencilZ::energyAndVirialDone ( unsigned int  iGrid)

Definition at line 1092 of file CudaPmeSolver.C.

1092  {
1093  submitReductions(iGrid);
1094 }

◆ initialize() [1/2]

void CudaPmePencilZ::initialize ( CudaPmeXInitMsg msg)

Definition at line 836 of file CudaPmeSolver.C.

References CudaPmeXInitMsg::pmeGrid, CudaPmeXInitMsg::pmePencilY, and CudaPmeXInitMsg::yMap.

836  {
837  useXYslab = false;
838  pmeGrid = msg->pmeGrid;
839  pmePencilY = msg->pmePencilY;
840  yMap = msg->yMap;
841 
842  delete msg;
843 
844  initBlockSizes();
845 }
CProxy_CudaPmePencilY pmePencilY
Definition: CudaPmeSolver.h:34
CProxy_PmePencilXMap yMap
Definition: CudaPmeSolver.h:37

◆ initialize() [2/2]

void CudaPmePencilZ::initialize ( CudaPmeXYInitMsg msg)

Definition at line 847 of file CudaPmeSolver.C.

References CudaPmeXYInitMsg::pmeGrid, CudaPmeXYInitMsg::pmePencilXY, and CudaPmeXYInitMsg::xyMap.

847  {
848  useXYslab = true;
849  pmeGrid = msg->pmeGrid;
850  pmePencilXY = msg->pmePencilXY;
851  xyMap = msg->xyMap;
852 
853  delete msg;
854 
855  initBlockSizes();
856 }
CProxy_PmePencilXYMap xyMap
Definition: CudaPmeSolver.h:22
CProxy_CudaPmePencilXY pmePencilXY
Definition: CudaPmeSolver.h:19

◆ initializeDevice()

void CudaPmePencilZ::initializeDevice ( InitDeviceMsg2 msg)

Definition at line 865 of file CudaPmeSolver.C.

References cudaCheck, InitDeviceMsg2::deviceID, InitDeviceMsg2::deviceProxy, ComputeNonbondedUtil::ewaldcof, InitDeviceMsg2::mgrProxy, NUM_GRID_MAX, Perm_Z_cX_Y, and InitDeviceMsg2::stream.

865  {
866  // Get device proxy
867  CProxy_ComputePmeCUDADevice deviceProxy = msg->deviceProxy;
868  deviceID = msg->deviceID;
869  stream = msg->stream;
870  CProxy_ComputePmeCUDAMgr mgrProxy = msg->mgrProxy;
871  delete msg;
872  // deviceID = deviceProxy.ckLocalBranch()->getDeviceID();
873  // cudaStream_t stream = deviceProxy.ckLocalBranch()->getStream();
874  // CProxy_ComputePmeCUDAMgr mgrProxy = deviceProxy.ckLocalBranch()->getMgrProxy();
875  // Setup fftCompute and pmeKSpaceCompute
876  for (unsigned int iGrid = 0; iGrid < NUM_GRID_MAX; ++iGrid) {
877  if (deviceProxy.ckLocalBranch()->isGridEnabled(iGrid) == true) {
878  fftComputes[iGrid] = new CudaFFTCompute(deviceID, stream);
879  pmeTransposes[iGrid] = new CudaPmeTranspose(pmeGrid, Perm_Z_cX_Y, thisIndex.x, thisIndex.y, deviceID, stream);
880  pmeKSpaceComputes[iGrid] = new CudaPmeKSpaceCompute(pmeGrid, Perm_Z_cX_Y, thisIndex.x, thisIndex.y, ComputeNonbondedUtil::ewaldcof, deviceID, stream, iGrid);
881  energyReady[iGrid] = 0;
882  } else {
883  fftComputes[iGrid] = NULL;
884  pmeTransposes[iGrid] = NULL;
885  pmeKSpaceComputes[iGrid] = NULL;
886  energyReady[iGrid] = -1;
887  }
888  }
889 
890  // Create event. NOTE: Events are tied to devices, hence the cudaSetDevice() here
891  cudaCheck(cudaSetDevice(deviceID));
892  cudaCheck(cudaEventCreateWithFlags(&event, cudaEventDisableTiming));
893  eventCreated = true;
894 
895  deviceBuffers.resize(pmeGrid.zBlocks, DeviceBuffer(-1, false));
896  numDeviceBuffers = 0;
897 
898  if (useXYslab) {
899  for (int z=0;z < pmeGrid.zBlocks;z++) {
900  int pe = xyMap.ckLocalBranch()->procNum(0, CkArrayIndex3D(0,0,z));
901  if (CkNodeOf(pe) == CkMyNode()) {
902  int deviceID0 = mgrProxy.ckLocalBranch()->getDeviceIDPencilX(0, z);
903  // Check for Peer-to-Peer access
904  int canAccessPeer = 0;
905  if (deviceID != deviceID0) {
906  cudaCheck(cudaSetDevice(deviceID));
907  cudaCheck(cudaDeviceCanAccessPeer(&canAccessPeer, deviceID, deviceID0));
908  }
909 #ifdef DISABLE_P2P
910  canAccessPeer = 0;
911 #endif
912  numDeviceBuffers++;
913  deviceBuffers[z] = DeviceBuffer(deviceID0, canAccessPeer);
914  pmePencilXY(0,0,z).getDeviceBuffer(thisIndex.x, (deviceID0 == deviceID) || canAccessPeer, thisProxy);
915  }
916  }
917  } else {
918  for (int z=0;z < pmeGrid.zBlocks;z++) {
919  int pe = yMap.ckLocalBranch()->procNum(0, CkArrayIndex3D(thisIndex.x,0,z));
920  if (CkNodeOf(pe) == CkMyNode()) {
921  int deviceID0 = mgrProxy.ckLocalBranch()->getDeviceIDPencilY(thisIndex.x, z);
922  numDeviceBuffers++;
923  deviceBuffers[z] = DeviceBuffer(deviceID0, false);
924  pmePencilY(thisIndex.x,0,z).getDeviceBuffer(thisIndex.y, (deviceID0 == deviceID), thisProxy);
925  }
926  }
927  }
928 
929 }
CProxy_ComputePmeCUDADevice deviceProxy
Definition: CudaPmeSolver.h:54
const unsigned int NUM_GRID_MAX
Definition: PmeSolverUtil.h:9
cudaStream_t stream
Definition: CudaPmeSolver.h:52
CProxy_ComputePmeCUDAMgr mgrProxy
Definition: CudaPmeSolver.h:53
#define cudaCheck(stmt)
Definition: CudaUtils.h:233

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