1 #ifndef COMPUTEBONDEDCUDA_H
2 #define COMPUTEBONDEDCUDA_H
8 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
15 class ComputeBondedCUDA :
public Compute {
19 static const int CudaTupleTypeSize[Tuples::NUM_TUPLE_TYPES];
22 bool initializeCalled;
32 std::vector<int> allPatchIDs;
38 std::vector< std::vector<int> > patchIDsPerRank;
46 std::vector<int> patchIDs;
48 SelfCompute(
int type=-1) : type(type), tuples(NULL) {}
49 int operator==(
const SelfCompute &elem)
const {
50 return (elem.type == type);
56 std::vector<char> isBasePatch;
57 std::vector<int> patchIDs;
59 std::vector< Tuples* > tuples;
63 struct ComputeRecord {
64 HomeCompute homeCompute;
66 std::vector< SelfCompute > selfComputes;
70 std::vector< ComputeRecord > computes;
75 std::array< std::list<Tuples*>, Tuples::NUM_TUPLE_TYPES > tupleList;
77 int numTuplesPerType[Tuples::NUM_TUPLE_TYPES];
80 std::vector< AtomMapper* > atomMappers;
86 std::vector<PatchRecord> patches;
89 std::vector<int> patchIndex;
92 std::vector<int> dihedralMultMap;
93 std::vector<int> improperMultMap;
97 int numModifiedExclusions;
100 std::vector<NumExcl> numExclPerRank;
104 bool hasModifiedExclusions;
120 cudaEvent_t forceDoneEvent;
150 double beforeForceCompute;
162 double* energies_virials;
167 void updatePatches();
169 static void forceDoneCheck(
void *arg,
double walltime);
170 void forceDoneSetCallback();
172 void finishPatches();
175 struct TupleCopyWork {
182 std::vector<TupleCopyWork> tupleCopyWorkList;
184 int exclusionStartPos;
185 int exclusionStartPos2;
187 void copyBondData(
const int ntuples,
const BondElem* __restrict__ src,
190 void copyAngleData(
const int ntuples,
const AngleElem* __restrict__ src,
193 template <
bool doDihedral,
typename T,
typename P>
194 void copyDihedralData(
const int ntuples,
const T* __restrict__ src,
195 const P* __restrict__ p_array,
CudaDihedral* __restrict__ dst);
197 void copyExclusionData(
const int ntuples,
const ExclElem* __restrict__ src,
const int typeSize,
200 void copyCrosstermData(
const int ntuples,
const CrosstermElem* __restrict__ src,
203 static void tupleCopyWorker(
int first,
int last,
void *result,
int paraNum,
void *param);
204 void tupleCopyWorker(
int first,
int last);
210 ~ComputeBondedCUDA();
211 void registerCompute(
int pe,
int type,
PatchIDList& pids);
212 void registerSelfCompute(
int pe,
int type,
int pid);
213 void unregisterBoxesOnPe();
214 void assignPatchesOnPe();
220 void messageEnqueueWork();
222 void openBoxesOnPe();
223 void loadTuplesOnPe();
224 void copyTupleData();
227 void finishPatchesOnPe();
228 void finishReductions();
232 #endif // BONDED_CUDA
234 #endif // COMPUTEBONDEDCUDA_H
static __thread ComputeMgr * computeMgr
static __thread atom * atoms
static __thread float4 * forces
virtual void initialize()
__thread cudaStream_t stream
int operator==(const AtomSigInfo &s1, const AtomSigInfo &s2)
virtual void atomUpdate()
virtual void patchReady(PatchID, int doneMigration, int seq)