| version 1.1 | version 1.2 |
|---|
| |
| // | // |
| ComputeCUDAMgr::~ComputeCUDAMgr() { | ComputeCUDAMgr::~ComputeCUDAMgr() { |
| for (int i=0;i < numDevices;i++) { | for (int i=0;i < numDevices;i++) { |
| | if (cudaNonbondedTablesList[i] != NULL) delete cudaNonbondedTablesList[i]; |
| if (cudaComputeNonbondedList[i] != NULL) delete cudaComputeNonbondedList[i]; | if (cudaComputeNonbondedList[i] != NULL) delete cudaComputeNonbondedList[i]; |
| | #ifdef BONDED_CUDA |
| | if (computeBondedCUDAList[i] != NULL) delete computeBondedCUDAList[i]; |
| | #endif |
| } | } |
| } | } |
| | |
| |
| numDevices = deviceCUDA->getDeviceCount(); | numDevices = deviceCUDA->getDeviceCount(); |
| | |
| // Create pointers to devices | // Create pointers to devices |
| | cudaNonbondedTablesList.resize(numDevices, NULL); |
| cudaComputeNonbondedList.resize(numDevices, NULL); | cudaComputeNonbondedList.resize(numDevices, NULL); |
| | #ifdef BONDED_CUDA |
| | computeBondedCUDAList.resize(numDevices, NULL); |
| | #endif |
| | |
| | // Create CUDA non-bonded tables for all devices that are used for computation |
| | for (int i=0;i < deviceCUDA->getNumDevice();i++) { |
| | int deviceID = deviceCUDA->getDeviceIDbyRank(i); |
| | cudaNonbondedTablesList[deviceID] = new CudaNonbondedTables(deviceID); |
| | } |
| } | } |
| | |
| ComputeCUDAMgr* ComputeCUDAMgr::getComputeCUDAMgr() { | ComputeCUDAMgr* ComputeCUDAMgr::getComputeCUDAMgr() { |
| |
| int deviceID = deviceCUDA->getDeviceID(); | int deviceID = deviceCUDA->getDeviceID(); |
| if (cudaComputeNonbondedList.at(deviceID) != NULL) | if (cudaComputeNonbondedList.at(deviceID) != NULL) |
| NAMD_bug("ComputeCUDAMgr::createCudaComputeNonbonded called twice"); | NAMD_bug("ComputeCUDAMgr::createCudaComputeNonbonded called twice"); |
| | if (cudaNonbondedTablesList.at(deviceID) == NULL) |
| | NAMD_bug("ComputeCUDAMgr::createCudaComputeNonbonded, non-bonded CUDA tables not created"); |
| bool doStreaming = !deviceCUDA->getNoStreaming() && !Node::Object()->simParameters->GBISOn; | bool doStreaming = !deviceCUDA->getNoStreaming() && !Node::Object()->simParameters->GBISOn; |
| cudaComputeNonbondedList[deviceID] = new CudaComputeNonbonded(c, deviceID, doStreaming); | cudaComputeNonbondedList[deviceID] = new CudaComputeNonbonded(c, deviceID, *cudaNonbondedTablesList[deviceID], doStreaming); |
| cudaComputeNonbondedList[deviceID]->buildTables(); | |
| return cudaComputeNonbondedList[deviceID]; | return cudaComputeNonbondedList[deviceID]; |
| } | } |
| | |
| |
| NAMD_bug("ComputeCUDAMgr::getCudaComputeNonbonded(), device not created yet"); | NAMD_bug("ComputeCUDAMgr::getCudaComputeNonbonded(), device not created yet"); |
| return p; | return p; |
| } | } |
| | |
| | #ifdef BONDED_CUDA |
| | // |
| | // Creates ComputeBondedCUDA object |
| | // |
| | ComputeBondedCUDA* ComputeCUDAMgr::createComputeBondedCUDA(ComputeID c, ComputeMgr* computeMgr) { |
| | int deviceID = deviceCUDA->getDeviceID(); |
| | if (computeBondedCUDAList.at(deviceID) != NULL) |
| | NAMD_bug("ComputeCUDAMgr::createComputeBondedCUDA called twice"); |
| | if (cudaNonbondedTablesList.at(deviceID) == NULL) |
| | NAMD_bug("ComputeCUDAMgr::createCudaComputeNonbonded, non-bonded CUDA tables not created"); |
| | computeBondedCUDAList[deviceID] = new ComputeBondedCUDA(c, computeMgr, deviceID, *cudaNonbondedTablesList[deviceID]); |
| | return computeBondedCUDAList[deviceID]; |
| | } |
| | |
| | // |
| | // Returns ComputeBondedCUDA for this Pe |
| | // |
| | ComputeBondedCUDA* ComputeCUDAMgr::getComputeBondedCUDA() { |
| | // Get device ID for this Pe |
| | int deviceID = deviceCUDA->getDeviceID(); |
| | ComputeBondedCUDA* p = computeBondedCUDAList[deviceID]; |
| | if (p == NULL) |
| | NAMD_bug("ComputeCUDAMgr::getComputeBondedCUDA(), device not created yet"); |
| | return p; |
| | } |
| | #endif // BONDED_CUDA |
| | |
| #endif // NAMD_CUDA | #endif // NAMD_CUDA |
| | |
| #include "ComputeCUDAMgr.def.h" | #include "ComputeCUDAMgr.def.h" |