7 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
9 #define __thread __declspec(thread)
28 NAMD_bug(
"ComputeCUDAMgr cannot be migrated");
38 for (
int i=0;i < numDevices;i++) {
39 if (cudaNonbondedTablesList[i] != NULL)
delete cudaNonbondedTablesList[i];
40 if (cudaComputeNonbondedList[i] != NULL)
delete cudaComputeNonbondedList[i];
42 if (computeBondedCUDAList[i] != NULL)
delete computeBondedCUDAList[i];
52 if (msg != NULL)
delete msg;
57 cudaNonbondedTablesList.resize(numDevices, NULL);
58 cudaComputeNonbondedList.resize(numDevices, NULL);
60 computeBondedCUDAList.resize(numDevices, NULL);
75 if ( CkMyRank() )
NAMD_bug(
"ComputeCUDAMgr::update() should be called only by rank 0");
79 cudaNonbondedTablesList[deviceID]->updateTables();
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;
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");
102 cudaComputeNonbondedList[deviceID] =
new CudaComputeNonbonded(c, deviceID, *cudaNonbondedTablesList[deviceID], doStreaming);
103 return cudaComputeNonbondedList[deviceID];
114 NAMD_bug(
"ComputeCUDAMgr::getCudaComputeNonbonded(), device not created yet");
124 if (computeBondedCUDAList.at(deviceID) != NULL)
125 NAMD_bug(
"ComputeCUDAMgr::createComputeBondedCUDA called twice");
126 if (cudaNonbondedTablesList.at(deviceID) == NULL)
127 NAMD_bug(
"ComputeCUDAMgr::createCudaComputeNonbonded, non-bonded CUDA tables not created");
128 computeBondedCUDAList[deviceID] =
new ComputeBondedCUDA(c, computeMgr, deviceID, *cudaNonbondedTablesList[deviceID]);
129 return computeBondedCUDAList[deviceID];
135 ComputeBondedCUDA* ComputeCUDAMgr::getComputeBondedCUDA() {
138 ComputeBondedCUDA* p = computeBondedCUDAList[deviceID];
140 NAMD_bug(
"ComputeCUDAMgr::getComputeBondedCUDA(), device not created yet");
143 #endif // BONDED_CUDA
145 #endif // NAMD_CUDA or NAMD_HIP
147 #include "ComputeCUDAMgr.def.h"
static __thread ComputeMgr * computeMgr
SimParameters * simParameters
void initialize(CkQdMsg *msg)
void NAMD_bug(const char *err_msg)
static ComputeCUDAMgr * getComputeCUDAMgr()
int getDeviceIDbyRank(int rank)
__thread DeviceCUDA * deviceCUDA
CudaComputeNonbonded * getCudaComputeNonbonded()
CudaComputeNonbonded * createCudaComputeNonbonded(ComputeID c)