Include Likwid Markers. Allow to switch between SP and DP floats.

This commit is contained in:
Jan Eitzinger
2020-11-05 12:41:44 +01:00
parent b45ab26e03
commit b39957421c
11 changed files with 333 additions and 133 deletions

View File

@@ -28,6 +28,8 @@
#include <math.h>
#include <float.h>
#include <likwid-marker.h>
#include <timing.h>
#include <allocate.h>
#include <neighbor.h>
@@ -100,11 +102,13 @@ double reneighbour(
double S, E;
S = getTimeStamp();
LIKWID_MARKER_START("reneighbour");
updateAtomsPbc(atom, param);
setupPbc(atom, param);
updatePbc(atom, param);
/* sortAtom(); */
buildNeighbor(atom, neighbor);
LIKWID_MARKER_STOP("reneighbour");
E = getTimeStamp();
return E-S;
@@ -112,9 +116,9 @@ double reneighbour(
void initialIntegrate(Parameter *param, Atom *atom)
{
double* x = atom->x; double* y = atom->y; double* z = atom->z;
double* fx = atom->fx; double* fy = atom->fy; double* fz = atom->fz;
double* vx = atom->vx; double* vy = atom->vy; double* vz = atom->vz;
MD_FLOAT* x = atom->x; MD_FLOAT* y = atom->y; MD_FLOAT* z = atom->z;
MD_FLOAT* fx = atom->fx; MD_FLOAT* fy = atom->fy; MD_FLOAT* fz = atom->fz;
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 * fx[i];
@@ -128,8 +132,8 @@ void initialIntegrate(Parameter *param, Atom *atom)
void finalIntegrate(Parameter *param, Atom *atom)
{
double* fx = atom->fx; double* fy = atom->fy; double* fz = atom->fz;
double* vx = atom->vx; double* vy = atom->vy; double* vz = atom->vz;
MD_FLOAT* fx = atom->fx; MD_FLOAT* fy = atom->fy; MD_FLOAT* fz = atom->fz;
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 * fx[i];
@@ -142,12 +146,12 @@ double computeForce(Parameter *param, Atom *atom, Neighbor *neighbor)
{
int Nlocal = atom->Nlocal;
int* neighs;
double cutforcesq = param->cutforce * param->cutforce;
double sigma6 = param->sigma6;
double epsilon = param->epsilon;
double* x = atom->x; double* y = atom->y; double* z = atom->z;
double* fx = atom->fx; double* fy = atom->fy; double* fz = atom->fz;
double S, E;
MD_FLOAT cutforcesq = param->cutforce * param->cutforce;
MD_FLOAT sigma6 = param->sigma6;
MD_FLOAT epsilon = param->epsilon;
MD_FLOAT* x = atom->x; MD_FLOAT* y = atom->y; MD_FLOAT* z = atom->z;
MD_FLOAT* fx = atom->fx; MD_FLOAT* fy = atom->fy; MD_FLOAT* fz = atom->fz;
MD_FLOAT S, E;
S = getTimeStamp();
for(int i = 0; i < Nlocal; i++) {
@@ -156,29 +160,31 @@ double computeForce(Parameter *param, Atom *atom, Neighbor *neighbor)
fz[i] = 0.0;
}
LIKWID_MARKER_START("force");
#pragma omp parallel for
for(int i = 0; i < Nlocal; i++) {
neighs = &neighbor->neighbors[i * neighbor->maxneighs];
int numneighs = neighbor->numneigh[i];
double xtmp = x[i];
double ytmp = y[i];
double ztmp = z[i];
MD_FLOAT xtmp = x[i];
MD_FLOAT ytmp = y[i];
MD_FLOAT ztmp = z[i];
double fix = 0;
double fiy = 0;
double fiz = 0;
MD_FLOAT fix = 0;
MD_FLOAT fiy = 0;
MD_FLOAT fiz = 0;
for(int k = 0; k < numneighs; k++) {
int j = neighs[k];
double delx = xtmp - x[j];
double dely = ytmp - y[j];
double delz = ztmp - z[j];
double rsq = delx * delx + dely * dely + delz * delz;
MD_FLOAT delx = xtmp - x[j];
MD_FLOAT dely = ytmp - y[j];
MD_FLOAT delz = ztmp - z[j];
MD_FLOAT rsq = delx * delx + dely * dely + delz * delz;
if(rsq < cutforcesq) {
double sr2 = 1.0 / rsq;
double sr6 = sr2 * sr2 * sr2 * sigma6;
double force = 48.0 * sr6 * (sr6 - 0.5) * sr2 * epsilon;
MD_FLOAT sr2 = 1.0 / rsq;
MD_FLOAT sr6 = sr2 * sr2 * sr2 * sigma6;
MD_FLOAT force = 48.0 * sr6 * (sr6 - 0.5) * sr2 * epsilon;
fix += delx * force;
fiy += dely * force;
fiz += delz * force;
@@ -189,6 +195,7 @@ double computeForce(Parameter *param, Atom *atom, Neighbor *neighbor)
fy[i] += fiy;
fz[i] += fiz;
}
LIKWID_MARKER_STOP("force");
E = getTimeStamp();
return E-S;
@@ -214,6 +221,13 @@ int main (int argc, char** argv)
Neighbor neighbor;
Parameter param;
LIKWID_MARKER_INIT;
#pragma omp parallel
{
LIKWID_MARKER_REGISTER("force");
LIKWID_MARKER_REGISTER("reneighbour");
LIKWID_MARKER_REGISTER("pbc");
}
init(&param);
for(int i = 0; i < argc; i++)
@@ -279,6 +293,12 @@ int main (int argc, char** argv)
computeThermo(-1, &param, &atom);
printf(HLINE);
#if PRECISION == 1
printf("Using single precision floating point.\n");
#else
printf("Using double precision floating point.\n");
#endif
printf(HLINE);
printf("System: %d atoms %d ghost atoms, Steps: %d\n", atom.Natoms, atom.Nghost, param.ntimes);
printf("TOTAL %.2fs FORCE %.2fs NEIGH %.2fs REST %.2fs\n",
timer[TOTAL], timer[FORCE], timer[NEIGH], timer[TOTAL]-timer[FORCE]-timer[NEIGH]);
@@ -286,5 +306,6 @@ int main (int argc, char** argv)
printf("Performance: %.2f million atom updates per second\n",
1e-6 * (double) atom.Natoms * param.ntimes / timer[TOTAL]);
LIKWID_MARKER_CLOSE;
return EXIT_SUCCESS;
}