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 112 of file ComputePmeCUDA.C.

112  {
113  atomsChanged = true;
114 }

◆ doWork()

void ComputePmeCUDA::doWork ( void  )
virtual

Reimplemented from Compute.

Definition at line 156 of file ComputePmeCUDA.C.

References NAMD_EVENT_START, and NAMD_EVENT_STOP.

156  {
157  NAMD_EVENT_START(1, NamdProfileEvent::COMPUTE_PME_CUDA);
158 
159  if (sendAtomsDone) {
160  // Second part of computation: receive forces from ComputePmeCUDAMgr
161  // basePriority = PME_OFFLOAD_PRIORITY;
162  sendAtomsDone = false;
163  recvForces();
164  } else {
165  // First part of computation: send atoms to ComputePmeCUDAMgr
166  sendAtomsDone = true;
167  // basePriority = COMPUTE_HOME_PRIORITY + PATCH_PRIORITY(patchID);
168  sendAtoms();
169  }
170  NAMD_EVENT_STOP(1, NamdProfileEvent::COMPUTE_PME_CUDA);
171 }
#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(), PatchData::reduction, 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  nodeReduction = patchData->reduction;
86 #endif
87  // basePriority = PME_PRIORITY;
88  patchCounter = getNumPatches();
89 
90  // Get proxy to ComputePmeCUDAMgr
91  computePmeCUDAMgrProxy = CkpvAccess(BOCclass_group).computePmeCUDAMgr;
92  mgr = computePmeCUDAMgrProxy.ckLocalBranch();
93  if (mgr == NULL)
94  NAMD_bug("ComputePmeCUDA::ComputePmeCUDA, unable to locate local branch of BOC entry computePmeCUDAMgr");
95  pmeGrid = mgr->getPmeGrid();
96 
97  for (int i=0;i < getNumPatches();i++) {
98  if (patches[i].positionBox != NULL || patches[i].avgPositionBox != NULL
99  || patches[i].forceBox != NULL || patches[i].patch != NULL)
100  NAMD_bug("ComputePmeCUDA::initialize() called twice or boxes not set to NULL");
101  if (!(patches[i].patch = PatchMap::Object()->patch(patches[i].patchID))) {
102  NAMD_bug("ComputePmeCUDA::initialize() patch not found");
103  }
104  patches[i].positionBox = patches[i].patch->registerPositionPickup(this);
105  patches[i].forceBox = patches[i].patch->registerForceDeposit(this);
106  patches[i].avgPositionBox = patches[i].patch->registerAvgPositionPickup(this);
107  }
108 
109  setupActivePencils();
110 }
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:366
static ReductionMgr * Object(void)
Definition: ReductionMgr.h:279
NodeReduction * reduction
Definition: PatchData.h:133
void NAMD_bug(const char *err_msg)
Definition: common.C:195
#define simParams
Definition: Output.C:129
int getNumPatches()
Definition: Compute.h:53

◆ noWork()

int ComputePmeCUDA::noWork ( )
virtual

Reimplemented from Compute.

Definition at line 140 of file ComputePmeCUDA.C.

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

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

◆ storePmeForceMsg()

bool ComputePmeCUDA::storePmeForceMsg ( PmeForceMsg msg)

Definition at line 671 of file ComputePmeCUDA.C.

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

Referenced by ComputePmeCUDADevice::sendForcesToPatch().

671  {
672  bool done = false;
673  int i;
674  CmiLock(lock);
675  patchCounter--;
676  i = patchCounter;
677  if (patchCounter == 0) {
678  patchCounter = getNumPatches();
679  done = true;
680  }
681  CmiUnlock(lock);
682  if (patches[i].pmeForceMsg != NULL)
683  NAMD_bug("ComputePmeCUDA::storePmeForceMsg, already contains message");
684  patches[i].pmeForceMsg = msg;
685  return done;
686 }
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: