version 1.1129 | version 1.1130 |
---|
| |
#include "ComputeDPME.h" | #include "ComputeDPME.h" |
#include "ComputeDPMEMsgs.h" | #include "ComputeDPMEMsgs.h" |
#include "ComputePme.h" | #include "ComputePme.h" |
| // #ifdef NAMD_CUDA |
| #include "ComputePmeCUDA.h" |
| #include "ComputeCUDAMgr.h" |
| #include "CudaComputeNonbonded.h" |
| #include "ComputePmeCUDAMgr.h" |
| // #endif |
#include "OptPme.h" | #include "OptPme.h" |
#include "ComputeEwald.h" | #include "ComputeEwald.h" |
#include "ComputeEField.h" | #include "ComputeEField.h" |
| |
| |
#include "DeviceCUDA.h" | #include "DeviceCUDA.h" |
#ifdef NAMD_CUDA | #ifdef NAMD_CUDA |
| #ifdef WIN32 |
| #define __thread __declspec(thread) |
| #endif |
extern __thread DeviceCUDA *deviceCUDA; | extern __thread DeviceCUDA *deviceCUDA; |
#endif | #endif |
| |
| |
// } | // } |
} | } |
| |
| #ifdef NAMD_CUDA |
| // Helper functions for creating and getting pointers to CUDA computes |
| CudaComputeNonbonded* getCudaComputeNonbonded() { |
| return ComputeCUDAMgr::getComputeCUDAMgr()->getCudaComputeNonbonded(); |
| } |
| |
| CudaComputeNonbonded* createCudaComputeNonbonded(ComputeID c) { |
| return ComputeCUDAMgr::getComputeCUDAMgr()->createCudaComputeNonbonded(c); |
| } |
| |
| #endif |
| |
// | // |
void | void |
ComputeMgr::createCompute(ComputeID i, ComputeMap *map) | ComputeMgr::createCompute(ComputeID i, ComputeMap *map) |
| |
{ | { |
case computeNonbondedSelfType: | case computeNonbondedSelfType: |
#ifdef NAMD_CUDA | #ifdef NAMD_CUDA |
| if (simParams->useCUDA2) { |
| getCudaComputeNonbonded()->registerComputeSelf(i, map->computeData[i].pids[0].pid); |
| } else { |
register_cuda_compute_self(i,map->computeData[i].pids[0].pid); | register_cuda_compute_self(i,map->computeData[i].pids[0].pid); |
| } |
#elif defined(NAMD_MIC) | #elif defined(NAMD_MIC) |
if (map->directToDevice(i) == 0) { | if (map->directToDevice(i) == 0) { |
c = new ComputeNonbondedSelf(i,map->computeData[i].pids[0].pid, | c = new ComputeNonbondedSelf(i,map->computeData[i].pids[0].pid, |
| |
pid2[1] = map->computeData[i].pids[1].pid; | pid2[1] = map->computeData[i].pids[1].pid; |
trans2[1] = map->computeData[i].pids[1].trans; | trans2[1] = map->computeData[i].pids[1].trans; |
#ifdef NAMD_CUDA | #ifdef NAMD_CUDA |
| if (simParams->useCUDA2) { |
| getCudaComputeNonbonded()->registerComputePair(i, pid2, trans2); |
| } else { |
register_cuda_compute_pair(i,pid2,trans2); | register_cuda_compute_pair(i,pid2,trans2); |
| } |
#elif defined(NAMD_MIC) | #elif defined(NAMD_MIC) |
if (map->directToDevice(i) == 0) { | if (map->directToDevice(i) == 0) { |
c = new ComputeNonbondedPair(i,pid2,trans2, | c = new ComputeNonbondedPair(i,pid2,trans2, |
| |
map->registerCompute(i,c); | map->registerCompute(i,c); |
c->initialize(); | c->initialize(); |
break; | break; |
| case computeNonbondedCUDA2Type: |
| c = createCudaComputeNonbonded(i); |
| map->registerCompute(i,c); |
| // NOTE: initialize() is called at the end of createComputes(), |
| // after all computes have been created |
| //c->initialize(); |
| break; |
#endif | #endif |
#ifdef NAMD_MIC | #ifdef NAMD_MIC |
case computeNonbondedMICType: | case computeNonbondedMICType: |
| |
map->registerCompute(i,c); | map->registerCompute(i,c); |
c->initialize(); | c->initialize(); |
break; | break; |
| #ifdef NAMD_CUDA |
| case computePmeCUDAType: |
| // PatchMap::Object()->basePatchIDList(CkMyPe(),pids); |
| // c = new ComputePmeCUDA(i, pids); |
| c = new ComputePmeCUDA(i, map->computeData[i].pids[0].pid); |
| map->registerCompute(i,c); |
| c->initialize(); |
| break; |
| #endif |
case computeEwaldType: | case computeEwaldType: |
c = computeEwaldObject = new ComputeEwald(i,this); // unknown delete | c = computeEwaldObject = new ComputeEwald(i,this); // unknown delete |
map->registerCompute(i,c); | map->registerCompute(i,c); |
| |
case computePmeType: | case computePmeType: |
sprintf(user_des, "computePMEType_%d", i); | sprintf(user_des, "computePMEType_%d", i); |
break; | break; |
| #ifdef NAMD_CUDA |
| case computePmeCUDAType: |
| sprintf(user_des, "computePMECUDAType_%d", i); |
| break; |
| #endif |
case computeEwaldType: | case computeEwaldType: |
sprintf(user_des, "computeEwaldType_%d", i); | sprintf(user_des, "computeEwaldType_%d", i); |
break; | break; |
| |
void | void |
ComputeMgr::createComputes(ComputeMap *map) | ComputeMgr::createComputes(ComputeMap *map) |
{ | { |
| // #ifdef NAMD_CUDA |
| // int ComputePmeCUDACounter = 0; |
| // #endif |
Node *node = Node::Object(); | Node *node = Node::Object(); |
SimParameters *simParams = node->simParameters; | SimParameters *simParams = node->simParameters; |
int myNode = node->myid(); | int myNode = node->myid(); |
| |
switch ( map->type(i) ) | switch ( map->type(i) ) |
{ | { |
#ifdef NAMD_CUDA | #ifdef NAMD_CUDA |
| // case computePmeCUDAType: |
| // // Only create single ComputePmeCUDA object per Pe |
| // if ( map->computeData[i].node != myNode ) continue; |
| // if (ComputePmeCUDACounter > 0) continue; |
| // ComputePmeCUDACounter++; |
| // break; |
case computeNonbondedSelfType: | case computeNonbondedSelfType: |
case computeNonbondedPairType: | case computeNonbondedPairType: |
if ( ! deviceIsMine ) continue; | if ( ! deviceIsMine ) continue; |
| |
| |
#endif | #endif |
case computeNonbondedCUDAType: | case computeNonbondedCUDAType: |
| #ifdef NAMD_CUDA |
| case computeNonbondedCUDA2Type: |
| #endif |
case computeNonbondedMICType: | case computeNonbondedMICType: |
if ( ! deviceIsMine ) continue; | if ( ! deviceIsMine ) continue; |
default: | default: |
| |
} | } |
| |
#ifdef NAMD_CUDA | #ifdef NAMD_CUDA |
| if (simParams->useCUDA2) { |
| if (deviceIsMine) { |
| getCudaComputeNonbonded()->assignPatches(this); |
| getCudaComputeNonbonded()->initialize(); |
| } |
| } else { |
if ( computeNonbondedCUDAObject ) { | if ( computeNonbondedCUDAObject ) { |
computeNonbondedCUDAObject->assignPatches(); | computeNonbondedCUDAObject->assignPatches(); |
} | } |
| } |
#endif | #endif |
#ifdef NAMD_MIC | #ifdef NAMD_MIC |
if ( computeNonbondedMICObject ) { | if ( computeNonbondedMICObject ) { |
| |
ComputeNonbondedMIC *master; | ComputeNonbondedMIC *master; |
}; | }; |
| |
| #ifdef NAMD_CUDA |
| class CudaComputeNonbondedMsg : public CMessage_CudaComputeNonbondedMsg { |
| public: |
| CudaComputeNonbonded* c; |
| int i; |
| }; |
| |
| void ComputeMgr::sendAssignPatchesOnPe(std::vector<int>& pes, CudaComputeNonbonded* c) { |
| for (int i=0;i < pes.size();i++) { |
| CudaComputeNonbondedMsg *msg = new CudaComputeNonbondedMsg; |
| msg->c = c; |
| thisProxy[pes[i]].recvAssignPatchesOnPe(msg); |
| } |
| } |
| |
| void ComputeMgr::recvAssignPatchesOnPe(CudaComputeNonbondedMsg *msg) { |
| msg->c->assignPatchesOnPe(); |
| delete msg; |
| } |
| |
| void ComputeMgr::sendSkipPatchesOnPe(std::vector<int>& pes, CudaComputeNonbonded* c) { |
| for (int i=0;i < pes.size();i++) { |
| CudaComputeNonbondedMsg *msg = new CudaComputeNonbondedMsg; |
| msg->c = c; |
| thisProxy[pes[i]].recvSkipPatchesOnPe(msg); |
| } |
| } |
| |
| void ComputeMgr::recvSkipPatchesOnPe(CudaComputeNonbondedMsg *msg) { |
| msg->c->skipPatchesOnPe(); |
| delete msg; |
| } |
| |
| void ComputeMgr::sendFinishPatchesOnPe(std::vector<int>& pes, CudaComputeNonbonded* c) { |
| for (int i=0;i < pes.size();i++) { |
| CudaComputeNonbondedMsg *msg = new CudaComputeNonbondedMsg; |
| msg->c = c; |
| thisProxy[pes[i]].recvFinishPatchesOnPe(msg); |
| } |
| } |
| |
| void ComputeMgr::recvFinishPatchesOnPe(CudaComputeNonbondedMsg *msg) { |
| msg->c->finishPatchesOnPe(); |
| delete msg; |
| } |
| |
| void ComputeMgr::sendFinishPatchOnPe(int pe, CudaComputeNonbonded* c, int i) { |
| CudaComputeNonbondedMsg *msg = new CudaComputeNonbondedMsg; |
| msg->c = c; |
| msg->i = i; |
| thisProxy[pe].recvFinishPatchOnPe(msg); |
| } |
| |
| void ComputeMgr::recvFinishPatchOnPe(CudaComputeNonbondedMsg *msg) { |
| msg->c->finishPatchOnPe(msg->i); |
| delete msg; |
| } |
| |
| void ComputeMgr::sendOpenBoxesOnPe(std::vector<int>& pes, CudaComputeNonbonded* c) { |
| for (int i=0;i < pes.size();i++) { |
| CudaComputeNonbondedMsg *msg = new CudaComputeNonbondedMsg; |
| msg->c = c; |
| thisProxy[pes[i]].recvOpenBoxesOnPe(msg); |
| } |
| } |
| |
| void ComputeMgr::recvOpenBoxesOnPe(CudaComputeNonbondedMsg *msg) { |
| msg->c->openBoxesOnPe(); |
| delete msg; |
| } |
| |
| void ComputeMgr::sendFinishReductions(int pe, CudaComputeNonbonded* c) { |
| CudaComputeNonbondedMsg *msg = new CudaComputeNonbondedMsg; |
| msg->c = c; |
| thisProxy[pe].recvFinishReductions(msg); |
| } |
| |
| void ComputeMgr::recvFinishReductions(CudaComputeNonbondedMsg *msg) { |
| msg->c->finishReductions(); |
| delete msg; |
| } |
| |
| void ComputeMgr::sendMessageEnqueueWork(int pe, CudaComputeNonbonded* c) { |
| CudaComputeNonbondedMsg *msg = new CudaComputeNonbondedMsg; |
| msg->c = c; |
| thisProxy[pe].recvMessageEnqueueWork(msg); |
| } |
| |
| void ComputeMgr::recvMessageEnqueueWork(CudaComputeNonbondedMsg *msg) { |
| msg->c->messageEnqueueWork(); |
| delete msg; |
| } |
| |
| void ComputeMgr::sendLaunchWork(int pe, CudaComputeNonbonded* c) { |
| CudaComputeNonbondedMsg *msg = new CudaComputeNonbondedMsg; |
| msg->c = c; |
| thisProxy[pe].recvLaunchWork(msg); |
| } |
| |
| void ComputeMgr::recvLaunchWork(CudaComputeNonbondedMsg *msg) { |
| msg->c->launchWork(); |
| delete msg; |
| } |
| |
| void ComputeMgr::sendUnregisterBoxesOnPe(std::vector<int>& pes, CudaComputeNonbonded* c) { |
| for (int i=0;i < pes.size();i++) { |
| CudaComputeNonbondedMsg *msg = new CudaComputeNonbondedMsg; |
| msg->c = c; |
| thisProxy[pes[i]].recvUnregisterBoxesOnPe(msg); |
| } |
| } |
| |
| void ComputeMgr::recvUnregisterBoxesOnPe(CudaComputeNonbondedMsg *msg) { |
| msg->c->unregisterBoxesOnPe(); |
| delete msg; |
| } |
| #endif // NAMD_CUDA |
| |
void ComputeMgr::sendCreateNonbondedMICSlave(int pe, int index) { | void ComputeMgr::sendCreateNonbondedMICSlave(int pe, int index) { |
NonbondedMICSlaveMsg *msg = new NonbondedMICSlaveMsg; | NonbondedMICSlaveMsg *msg = new NonbondedMICSlaveMsg; |
msg->master = computeNonbondedMICObject; | msg->master = computeNonbondedMICObject; |