NAMD
Public Member Functions | Static Public Member Functions | List of all members
ComputeCUDAMgr Class Reference

#include <ComputeCUDAMgr.h>

Inheritance diagram for ComputeCUDAMgr:

Public Member Functions

 ComputeCUDAMgr ()
 
 ComputeCUDAMgr (CkMigrateMessage *)
 
 ~ComputeCUDAMgr ()
 
void initialize (CkQdMsg *msg)
 
void initialize_devices (CkQdMsg *msg)
 
void update ()
 
CudaComputeNonbondedcreateCudaComputeNonbonded (ComputeID c)
 
CudaComputeNonbondedgetCudaComputeNonbonded ()
 

Static Public Member Functions

static ComputeCUDAMgrgetComputeCUDAMgr ()
 

Detailed Description

Definition at line 13 of file ComputeCUDAMgr.h.

Constructor & Destructor Documentation

ComputeCUDAMgr::ComputeCUDAMgr ( )

Definition at line 16 of file ComputeCUDAMgr.C.

16  {
17  // __sdag_init();
18  numDevices = 0;
19  // numNodesContributed = 0;
20  // numDevicesMax = 0;
21 }
ComputeCUDAMgr::ComputeCUDAMgr ( CkMigrateMessage *  )

Definition at line 26 of file ComputeCUDAMgr.C.

References NAMD_bug().

26  {
27  // __sdag_init();
28  NAMD_bug("ComputeCUDAMgr cannot be migrated");
29  numDevices = 0;
30  // numNodesContributed = 0;
31  // numDevicesMax = 0;
32 }
void NAMD_bug(const char *err_msg)
Definition: common.C:123
ComputeCUDAMgr::~ComputeCUDAMgr ( )

Definition at line 37 of file ComputeCUDAMgr.C.

37  {
38  for (int i=0;i < numDevices;i++) {
39  if (cudaNonbondedTablesList[i] != NULL) delete cudaNonbondedTablesList[i];
40  if (cudaComputeNonbondedList[i] != NULL) delete cudaComputeNonbondedList[i];
41 #ifdef BONDED_CUDA
42  if (computeBondedCUDAList[i] != NULL) delete computeBondedCUDAList[i];
43 #endif
44  }
45 }

Member Function Documentation

CudaComputeNonbonded * ComputeCUDAMgr::createCudaComputeNonbonded ( ComputeID  c)

Definition at line 95 of file ComputeCUDAMgr.C.

References deviceCUDA, SimParameters::GBISOn, DeviceCUDA::getDeviceID(), DeviceCUDA::getNoStreaming(), NAMD_bug(), Node::Object(), and Node::simParameters.

Referenced by createCudaComputeNonbonded().

95  {
96  int deviceID = deviceCUDA->getDeviceID();
97  if (cudaComputeNonbondedList.at(deviceID) != NULL)
98  NAMD_bug("ComputeCUDAMgr::createCudaComputeNonbonded called twice");
99  if (cudaNonbondedTablesList.at(deviceID) == NULL)
100  NAMD_bug("ComputeCUDAMgr::createCudaComputeNonbonded, non-bonded CUDA tables not created");
101  bool doStreaming = !deviceCUDA->getNoStreaming() && !Node::Object()->simParameters->GBISOn;
102  cudaComputeNonbondedList[deviceID] = new CudaComputeNonbonded(c, deviceID, *cudaNonbondedTablesList[deviceID], doStreaming);
103  return cudaComputeNonbondedList[deviceID];
104 }
static Node * Object()
Definition: Node.h:86
SimParameters * simParameters
Definition: Node.h:178
void NAMD_bug(const char *err_msg)
Definition: common.C:123
int getDeviceID()
Definition: DeviceCUDA.h:107
__thread DeviceCUDA * deviceCUDA
Definition: DeviceCUDA.C:18
int getNoStreaming()
Definition: DeviceCUDA.h:93
ComputeCUDAMgr * ComputeCUDAMgr::getComputeCUDAMgr ( )
static

Definition at line 83 of file ComputeCUDAMgr.C.

References NAMD_bug().

Referenced by createCudaComputeNonbonded(), getCudaComputeNonbonded(), and SimParameters::scriptSet().

83  {
84  // Get pointer to ComputeCUDAMgr on this node
85  CProxy_ComputeCUDAMgr computeCUDAMgrProxy = CkpvAccess(BOCclass_group).computeCUDAMgr;
86  ComputeCUDAMgr* computeCUDAMgr = computeCUDAMgrProxy.ckLocalBranch();
87  if (computeCUDAMgr == NULL)
88  NAMD_bug("getComputeCUDAMgr, unable to locate local branch of BOC entry ComputeCUDAMgr");
89  return computeCUDAMgr;
90 }
void NAMD_bug(const char *err_msg)
Definition: common.C:123
CudaComputeNonbonded * ComputeCUDAMgr::getCudaComputeNonbonded ( )

Definition at line 109 of file ComputeCUDAMgr.C.

References deviceCUDA, DeviceCUDA::getDeviceID(), and NAMD_bug().

Referenced by getCudaComputeNonbonded().

109  {
110  // Get device ID for this Pe
111  int deviceID = deviceCUDA->getDeviceID();
112  CudaComputeNonbonded* p = cudaComputeNonbondedList[deviceID];
113  if (p == NULL)
114  NAMD_bug("ComputeCUDAMgr::getCudaComputeNonbonded(), device not created yet");
115  return p;
116 }
void NAMD_bug(const char *err_msg)
Definition: common.C:123
int getDeviceID()
Definition: DeviceCUDA.h:107
__thread DeviceCUDA * deviceCUDA
Definition: DeviceCUDA.C:18
void ComputeCUDAMgr::initialize ( CkQdMsg *  msg)

Definition at line 51 of file ComputeCUDAMgr.C.

References deviceCUDA, DeviceCUDA::getDeviceCount(), DeviceCUDA::getDeviceIDbyRank(), and DeviceCUDA::getNumDevice().

51  {
52  if (msg != NULL) delete msg;
53 
54  numDevices = deviceCUDA->getDeviceCount();
55 
56  // Create pointers to devices
57  cudaNonbondedTablesList.resize(numDevices, NULL);
58  cudaComputeNonbondedList.resize(numDevices, NULL);
59 #ifdef BONDED_CUDA
60  computeBondedCUDAList.resize(numDevices, NULL);
61 #endif
62 
63  // Create CUDA non-bonded tables for all devices that are used for computation
64  for (int i=0;i < deviceCUDA->getNumDevice();i++) {
65  int deviceID = deviceCUDA->getDeviceIDbyRank(i);
66  cudaNonbondedTablesList[deviceID] = new CudaNonbondedTables(deviceID);
67  }
68 }
int getDeviceCount()
Definition: DeviceCUDA.h:87
int getNumDevice()
Definition: DeviceCUDA.h:88
int getDeviceIDbyRank(int rank)
Definition: DeviceCUDA.h:108
__thread DeviceCUDA * deviceCUDA
Definition: DeviceCUDA.C:18
void ComputeCUDAMgr::initialize_devices ( CkQdMsg *  msg)
void ComputeCUDAMgr::update ( )

Definition at line 74 of file ComputeCUDAMgr.C.

References deviceCUDA, DeviceCUDA::getDeviceIDbyRank(), DeviceCUDA::getNumDevice(), and NAMD_bug().

Referenced by SimParameters::scriptSet().

74  {
75  if ( CkMyRank() ) NAMD_bug("ComputeCUDAMgr::update() should be called only by rank 0");
76  for (int i=0; i < deviceCUDA->getNumDevice(); i++) {
77  int deviceID = deviceCUDA->getDeviceIDbyRank(i);
78  // calls update function from CudaNonbondedTables
79  cudaNonbondedTablesList[deviceID]->updateTables();
80  }
81 }
int getNumDevice()
Definition: DeviceCUDA.h:88
void NAMD_bug(const char *err_msg)
Definition: common.C:123
int getDeviceIDbyRank(int rank)
Definition: DeviceCUDA.h:108
__thread DeviceCUDA * deviceCUDA
Definition: DeviceCUDA.C:18

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