Porting atom velocity memory layout to AoS, porting velocity integration to CUDA, adding measurements + logbook update
This commit is contained in:
34
src/main.c
34
src/main.c
@@ -45,6 +45,11 @@
|
||||
|
||||
#define HLINE "----------------------------------------------------------------------------\n"
|
||||
|
||||
extern void initCudaAtom(Atom *atom, Neighbor *neighbor);
|
||||
|
||||
extern void cuda_final_integrate(bool doReneighbour, Parameter *param, Atom *atom);
|
||||
extern void cuda_initial_integrate(bool doReneighbour, Parameter *param, Atom *atom);
|
||||
|
||||
extern double computeForce(bool, Parameter*, Atom*, Neighbor*);
|
||||
extern double computeForceTracing(Parameter*, Atom*, Neighbor*, Stats*, int, int);
|
||||
extern double computeForceEam(Eam* eam, Parameter*, Atom *atom, Neighbor *neighbor, Stats *stats, int first_exec, int timestep);
|
||||
@@ -101,6 +106,8 @@ double setup(
|
||||
buildNeighbor(atom, neighbor);
|
||||
E = getTimeStamp();
|
||||
|
||||
initCudaAtom(atom, neighbor);
|
||||
|
||||
return E-S;
|
||||
}
|
||||
|
||||
@@ -126,26 +133,22 @@ double reneighbour(
|
||||
|
||||
void initialIntegrate(Parameter *param, Atom *atom)
|
||||
{
|
||||
MD_FLOAT* vx = atom->vx; MD_FLOAT* vy = atom->vy; MD_FLOAT* vz = atom->vz;
|
||||
|
||||
for(int i = 0; i < atom->Nlocal; i++) {
|
||||
vx[i] += param->dtforce * atom_fx(i);
|
||||
vy[i] += param->dtforce * atom_fy(i);
|
||||
vz[i] += param->dtforce * atom_fz(i);
|
||||
atom_x(i) = atom_x(i) + param->dt * vx[i];
|
||||
atom_y(i) = atom_y(i) + param->dt * vy[i];
|
||||
atom_z(i) = atom_z(i) + param->dt * vz[i];
|
||||
atom_vx(i) += param->dtforce * atom_fx(i);
|
||||
atom_vy(i) += param->dtforce * atom_fy(i);
|
||||
atom_vz(i) += param->dtforce * atom_fz(i);
|
||||
atom_x(i) = atom_x(i) + param->dt * atom_vx(i);
|
||||
atom_y(i) = atom_y(i) + param->dt * atom_vy(i);
|
||||
atom_z(i) = atom_z(i) + param->dt * atom_vz(i);
|
||||
}
|
||||
}
|
||||
|
||||
void finalIntegrate(Parameter *param, Atom *atom)
|
||||
{
|
||||
MD_FLOAT* vx = atom->vx; MD_FLOAT* vy = atom->vy; MD_FLOAT* vz = atom->vz;
|
||||
|
||||
for(int i = 0; i < atom->Nlocal; i++) {
|
||||
vx[i] += param->dtforce * atom_fx(i);
|
||||
vy[i] += param->dtforce * atom_fy(i);
|
||||
vz[i] += param->dtforce * atom_fz(i);
|
||||
atom_vx(i) += param->dtforce * atom_fx(i);
|
||||
atom_vy(i) += param->dtforce * atom_fy(i);
|
||||
atom_vz(i) += param->dtforce * atom_fz(i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,10 +277,11 @@ int main(int argc, char** argv)
|
||||
}
|
||||
|
||||
for(int n = 0; n < param.ntimes; n++) {
|
||||
initialIntegrate(¶m, &atom);
|
||||
|
||||
const bool doReneighbour = (n + 1) % param.every == 0;
|
||||
|
||||
cuda_initial_integrate(doReneighbour, ¶m, &atom); // initialIntegrate(¶m, &atom);
|
||||
|
||||
if(doReneighbour) {
|
||||
timer[NEIGH] += reneighbour(¶m, &atom, &neighbor);
|
||||
} else {
|
||||
@@ -293,7 +297,7 @@ int main(int argc, char** argv)
|
||||
timer[FORCE] += computeForce(doReneighbour, ¶m, &atom, &neighbor);
|
||||
#endif
|
||||
}
|
||||
finalIntegrate(¶m, &atom);
|
||||
cuda_final_integrate(doReneighbour, ¶m, &atom); // finalIntegrate(¶m, &atom);
|
||||
|
||||
if(!((n + 1) % param.nstat) && (n+1) < param.ntimes) {
|
||||
computeThermo(n + 1, ¶m, &atom);
|
||||
|
Reference in New Issue
Block a user