NAMD
Classes | Public Member Functions | List of all members
ComputePmeCUDA Class Reference

#include <ComputePmeCUDA.h>

Inheritance diagram for ComputePmeCUDA:
Compute

Public Member Functions

 ComputePmeCUDA (ComputeID c, PatchIDList &pids)
 
 ComputePmeCUDA (ComputeID c, PatchID pid)
 
virtual ~ComputePmeCUDA ()
 
void initialize ()
 
void atomUpdate ()
 
int noWork ()
 
void doWork ()
 
bool storePmeForceMsg (PmeForceMsg *msg)
 
- Public Member Functions inherited from Compute
 Compute (ComputeID)
 
int type ()
 
virtual ~Compute ()
 
void setNumPatches (int n)
 
int getNumPatches ()
 
virtual void patchReady (PatchID, int doneMigration, int seq)
 
virtual void finishPatch (int)
 
int sequence (void)
 
int priority (void)
 
int getGBISPhase (void)
 
virtual void gbisP2PatchReady (PatchID, int seq)
 
virtual void gbisP3PatchReady (PatchID, int seq)
 

Additional Inherited Members

- Public Attributes inherited from Compute
const ComputeID cid
 
LDObjHandle ldObjHandle
 
LocalWorkMsg *const localWorkMsg
 
- Protected Member Functions inherited from Compute
void enqueueWork ()
 
- Protected Attributes inherited from Compute
int computeType
 
int basePriority
 
int gbisPhase
 
int gbisPhasePriority [3]
 

Detailed Description

Definition at line 17 of file ComputePmeCUDA.h.

Constructor & Destructor Documentation

◆ ComputePmeCUDA() [1/2]

ComputePmeCUDA::ComputePmeCUDA ( ComputeID  c,
PatchIDList pids 
)

Definition at line 25 of file ComputePmeCUDA.C.

References Compute::getNumPatches(), Compute::setNumPatches(), and ResizeArray< Elem >::size().

25  : Compute(c) {
26  setNumPatches(pids.size());
27  patches.resize(getNumPatches());
28  for (int i=0;i < getNumPatches();i++) {
29  patches[i].patchID = pids[i];
30  }
31  selfEnergy = 0;
32  selfEnergyFEP = 0;
33  selfEnergyTI1 = 0;
34  selfEnergyTI2 = 0;
35 }
void setNumPatches(int n)
Definition: Compute.h:52
int size(void) const
Definition: ResizeArray.h:131
int getNumPatches()
Definition: Compute.h:53
Compute(ComputeID)
Definition: Compute.C:37

◆ ComputePmeCUDA() [2/2]

ComputePmeCUDA::ComputePmeCUDA ( ComputeID  c,
PatchID  pid 
)

Definition at line 40 of file ComputePmeCUDA.C.

References Compute::getNumPatches(), and Compute::setNumPatches().

40  : Compute(c) {
41  setNumPatches(1);
42  patches.resize(getNumPatches());
43  patches[0].patchID = pid;
44  selfEnergy = 0;
45  selfEnergyFEP = 0;
46  selfEnergyTI1 = 0;
47  selfEnergyTI2 = 0;
48 }
void setNumPatches(int n)
Definition: Compute.h:52
int getNumPatches()
Definition: Compute.h:53
Compute(ComputeID)
Definition: Compute.C:37

◆ ~ComputePmeCUDA()

ComputePmeCUDA::~ComputePmeCUDA ( )
virtual

Definition at line 53 of file ComputePmeCUDA.C.

References Compute::getNumPatches(), PatchMap::Object(), PatchMap::patch(), Patch::unregisterAvgPositionPickup(), Patch::unregisterForceDeposit(), and Patch::unregisterPositionPickup().

53  {
54  for (int i=0;i < getNumPatches();i++) {
55  if (patches[i].positionBox != NULL) {
56  PatchMap::Object()->patch(patches[i].patchID)->unregisterPositionPickup(this, &patches[i].positionBox);
57  }
58  if (patches[i].avgPositionBox != NULL) {
59  PatchMap::Object()->patch(patches[i].patchID)->unregisterAvgPositionPickup(this, &patches[i].avgPositionBox);
60  }
61  if (patches[i].forceBox != NULL) {
62  PatchMap::Object()->patch(patches[i].patchID)->unregisterForceDeposit(this, &patches[i].forceBox);
63  }
64  }
65  delete reduction;
66  CmiDestroyLock(lock);
67 }
void unregisterAvgPositionPickup(Compute *cid, Box< Patch, CompAtom > **const box)
Definition: Patch.C:139
static PatchMap * Object()
Definition: PatchMap.h:27
void unregisterForceDeposit(Compute *cid, Box< Patch, Results > **const box)
Definition: Patch.C:238
Patch * patch(PatchID pid)
Definition: PatchMap.h:244
void unregisterPositionPickup(Compute *cid, Box< Patch, CompAtom > **const box)
Definition: Patch.C:121
int getNumPatches()
Definition: Compute.h:53

Member Function Documentation

◆ atomUpdate()

void ComputePmeCUDA::atomUpdate ( void  )
virtual

Reimplemented from Compute.

Definition at line 111 of file ComputePmeCUDA.C.

111  {
112  atomsChanged = true;
113 }

◆ doWork()

void ComputePmeCUDA::doWork ( void  )
virtual

Reimplemented from Compute.

Definition at line 155 of file ComputePmeCUDA.C.

References NAMD_EVENT_START, and NAMD_EVENT_STOP.

155  {
156  NAMD_EVENT_START(1, NamdProfileEvent::COMPUTE_PME_CUDA);
157 
158  if (sendAtomsDone) {
159  // Second part of computation: receive forces from ComputePmeCUDAMgr
160  // basePriority = PME_OFFLOAD_PRIORITY;
161  sendAtomsDone = false;
162  recvForces();
163  } else {
164  // First part of computation: send atoms to ComputePmeCUDAMgr
165  sendAtomsDone = true;
166  // basePriority = COMPUTE_HOME_PRIORITY + PATCH_PRIORITY(patchID);
167  sendAtoms();
168  }
169  NAMD_EVENT_STOP(1, NamdProfileEvent::COMPUTE_PME_CUDA);
170 }
#define NAMD_EVENT_STOP(eon, id)
#define NAMD_EVENT_START(eon, id)

◆ initialize()

void ComputePmeCUDA::initialize ( void  )
virtual

Reimplemented from Compute.

Definition at line 72 of file ComputePmeCUDA.C.

References Compute::getNumPatches(), ComputePmeCUDAMgr::getPmeGrid(), NAMD_bug(), PatchMap::Object(), Node::Object(), ReductionMgr::Object(), REDUCTIONS_BASIC, Node::simParameters, simParams, and ReductionMgr::willSubmit().

72  {
73  lock = CmiCreateLock();
74 
75  // Sanity Check
77  if (simParams->lesOn) NAMD_bug("ComputePmeCUDA::ComputePmeCUDA, lesOn not yet implemented");
78  if (simParams->pairInteractionOn) NAMD_bug("ComputePmeCUDA::ComputePmeCUDA, pairInteractionOn not yet implemented");
79 
80  sendAtomsDone = false;
82 #ifdef NODEGROUP_FORCE_REGISTER
83  CProxy_PatchData cpdata(CkpvAccess(BOCclass_group).patchData);
84  PatchData *patchData = cpdata.ckLocalBranch();
85 #endif
86  // basePriority = PME_PRIORITY;
87  patchCounter = getNumPatches();
88 
89  // Get proxy to ComputePmeCUDAMgr
90  computePmeCUDAMgrProxy = CkpvAccess(BOCclass_group).computePmeCUDAMgr;
91  mgr = computePmeCUDAMgrProxy.ckLocalBranch();
92  if (mgr == NULL)
93  NAMD_bug("ComputePmeCUDA::ComputePmeCUDA, unable to locate local branch of BOC entry computePmeCUDAMgr");
94  pmeGrid = mgr->getPmeGrid();
95 
96  for (int i=0;i < getNumPatches();i++) {
97  if (patches[i].positionBox != NULL || patches[i].avgPositionBox != NULL
98  || patches[i].forceBox != NULL || patches[i].patch != NULL)
99  NAMD_bug("ComputePmeCUDA::initialize() called twice or boxes not set to NULL");
100  if (!(patches[i].patch = PatchMap::Object()->patch(patches[i].patchID))) {
101  NAMD_bug("ComputePmeCUDA::initialize() patch not found");
102  }
103  patches[i].positionBox = patches[i].patch->registerPositionPickup(this);
104  patches[i].forceBox = patches[i].patch->registerForceDeposit(this);
105  patches[i].avgPositionBox = patches[i].patch->registerAvgPositionPickup(this);
106  }
107 
108  setupActivePencils();
109 }
static Node * Object()
Definition: Node.h:86
static PatchMap * Object()
Definition: PatchMap.h:27
SimParameters * simParameters
Definition: Node.h:181
SubmitReduction * willSubmit(int setID, int size=-1)
Definition: ReductionMgr.C:368
static ReductionMgr * Object(void)
Definition: ReductionMgr.h:290
void NAMD_bug(const char *err_msg)
Definition: common.C:195
#define simParams
Definition: Output.C:131
int getNumPatches()
Definition: Compute.h:53

◆ noWork()

int ComputePmeCUDA::noWork ( )
virtual

Reimplemented from Compute.

Definition at line 139 of file ComputePmeCUDA.C.

References Compute::getNumPatches(), and SubmitReduction::submit().

139  {
140 
141  if (patches[0].patch->flags.doFullElectrostatics) return 0;
142 
143  reduction->submit();
144 
145  for (int i=0;i < getNumPatches();i++) {
146  patches[i].positionBox->skip();
147  patches[i].forceBox->skip();
148  // We only need to call skip() once
149  if (patches[i].patchID == 0) computePmeCUDAMgrProxy[patches[i].homePencilNode].skip();
150  }
151 
152  return 1;
153 }
virtual void submit(void)=0
int getNumPatches()
Definition: Compute.h:53

◆ storePmeForceMsg()

bool ComputePmeCUDA::storePmeForceMsg ( PmeForceMsg msg)

Definition at line 659 of file ComputePmeCUDA.C.

References Compute::getNumPatches(), and NAMD_bug().

Referenced by ComputePmeCUDADevice::sendForcesToPatch().

659  {
660  bool done = false;
661  int i;
662  CmiLock(lock);
663  patchCounter--;
664  i = patchCounter;
665  if (patchCounter == 0) {
666  patchCounter = getNumPatches();
667  done = true;
668  }
669  CmiUnlock(lock);
670  if (patches[i].pmeForceMsg != NULL)
671  NAMD_bug("ComputePmeCUDA::storePmeForceMsg, already contains message");
672  patches[i].pmeForceMsg = msg;
673  return done;
674 }
void NAMD_bug(const char *err_msg)
Definition: common.C:195
int getNumPatches()
Definition: Compute.h:53

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