Add useful data volume calculation for force kernel

Signed-off-by: Rafael Ravedutti <rafaelravedutti@gmail.com>
This commit is contained in:
Rafael Ravedutti 2021-10-11 16:57:02 +02:00
parent 4e0390404a
commit f295f54fca
5 changed files with 20 additions and 12 deletions

View File

@ -33,7 +33,7 @@
#endif #endif
#ifndef TRACER_CONDITION #ifndef TRACER_CONDITION
# define TRACER_CONDITION (!(timestep % every)) # define TRACER_CONDITION (!(timestep % param->every))
#endif #endif
#ifdef MEM_TRACER #ifdef MEM_TRACER
@ -118,10 +118,9 @@
# define DIST_TRACE(l, e) # define DIST_TRACE(l, e)
#endif #endif
double computeForce(Parameter *param, Atom *atom, Neighbor *neighbor, int first_exec, int timestep, int every) { double computeForce(Parameter *param, Atom *atom, Neighbor *neighbor, int first_exec, int timestep) {
MEM_TRACER_INIT; MEM_TRACER_INIT;
INDEX_TRACER_INIT; INDEX_TRACER_INIT;
double S = getTimeStamp();
int Nlocal = atom->Nlocal; int Nlocal = atom->Nlocal;
int* neighs; int* neighs;
MD_FLOAT* fx = atom->fx; MD_FLOAT* fy = atom->fy; MD_FLOAT* fz = atom->fz; MD_FLOAT* fx = atom->fx; MD_FLOAT* fy = atom->fy; MD_FLOAT* fz = atom->fz;
@ -138,11 +137,13 @@ double computeForce(Parameter *param, Atom *atom, Neighbor *neighbor, int first_
} }
INDEX_TRACE_NATOMS(Nlocal, atom->Nghost, neighbor->maxneighs); INDEX_TRACE_NATOMS(Nlocal, atom->Nghost, neighbor->maxneighs);
double S = getTimeStamp();
LIKWID_MARKER_START("force"); LIKWID_MARKER_START("force");
#pragma omp parallel for #pragma omp parallel for
for(int i = 0; i < Nlocal; i++) { for(int i = 0; i < Nlocal; i++) {
neighs = &neighbor->neighbors[i * neighbor->maxneighs]; neighs = &neighbor->neighbors[i * neighbor->maxneighs];
int numneighs = neighbor->numneigh[i]; int numneighs = neighbor->numneigh[i];
neighbor->totalneighs += numneighs; // Maybe remove this for real time measurements
MD_FLOAT xtmp = atom_x(i); MD_FLOAT xtmp = atom_x(i);
MD_FLOAT ytmp = atom_y(i); MD_FLOAT ytmp = atom_y(i);
MD_FLOAT ztmp = atom_z(i); MD_FLOAT ztmp = atom_z(i);
@ -217,8 +218,8 @@ double computeForce(Parameter *param, Atom *atom, Neighbor *neighbor, int first_
MEM_TRACE(fz[i], 'W'); MEM_TRACE(fz[i], 'W');
} }
LIKWID_MARKER_STOP("force"); LIKWID_MARKER_STOP("force");
double E = getTimeStamp(); double E = getTimeStamp();
INDEX_TRACER_END; INDEX_TRACER_END;
MEM_TRACER_END; MEM_TRACER_END;
return E-S; return E-S;

View File

@ -31,6 +31,7 @@ typedef struct {
int* neighbors; int* neighbors;
int maxneighs; int maxneighs;
int* numneigh; int* numneigh;
long long int totalneighs;
} Neighbor; } Neighbor;
extern void initNeighbor(Neighbor*, Parameter*); extern void initNeighbor(Neighbor*, Parameter*);

View File

@ -16,7 +16,7 @@
#define LATTICE_DISTANCE 10.0 #define LATTICE_DISTANCE 10.0
#define NEIGH_DISTANCE 1.0 #define NEIGH_DISTANCE 1.0
extern double computeForce(Parameter*, Atom*, Neighbor*, int, int, int); extern double computeForce(Parameter*, Atom*, Neighbor*, int, int);
void init(Parameter *param) { void init(Parameter *param) {
param->epsilon = 1.0; param->epsilon = 1.0;
@ -207,12 +207,12 @@ int main(int argc, const char *argv[]) {
DEBUG("Building neighbor lists...\n"); DEBUG("Building neighbor lists...\n");
buildNeighbor(atom, &neighbor); buildNeighbor(atom, &neighbor);
DEBUG("Computing forces...\n"); DEBUG("Computing forces...\n");
computeForce(&param, atom, &neighbor, 1, 0, param.every); computeForce(&param, atom, &neighbor, 1, 0);
double S, E; double S, E;
S = getTimeStamp(); S = getTimeStamp();
for(int i = 0; i < param.ntimes; i++) { for(int i = 0; i < param.ntimes; i++) {
computeForce(&param, atom, &neighbor, 0, i + 1, param.every); computeForce(&param, atom, &neighbor, 0, i + 1);
} }
E = getTimeStamp(); E = getTimeStamp();
double T_accum = E-S; double T_accum = E-S;

View File

@ -47,7 +47,7 @@ typedef enum {
NUMTIMER NUMTIMER
} timertype; } timertype;
extern double computeForce(Parameter*, Atom*, Neighbor*, int, int, int); extern double computeForce(Parameter*, Atom*, Neighbor*, int, int);
void init(Parameter *param) void init(Parameter *param)
{ {
@ -206,14 +206,13 @@ int main (int argc, char** argv)
setup(&param, &atom, &neighbor); setup(&param, &atom, &neighbor);
computeThermo(0, &param, &atom); computeThermo(0, &param, &atom);
computeForce(&param, &atom, &neighbor, 1, 0, param.every); computeForce(&param, &atom, &neighbor, 1, 0);
timer[FORCE] = 0.0; timer[FORCE] = 0.0;
timer[NEIGH] = 0.0; timer[NEIGH] = 0.0;
timer[TOTAL] = getTimeStamp(); timer[TOTAL] = getTimeStamp();
for(int n = 0; n < param.ntimes; n++) { for(int n = 0; n < param.ntimes; n++) {
initialIntegrate(&param, &atom); initialIntegrate(&param, &atom);
if((n + 1) % param.every) { if((n + 1) % param.every) {
@ -222,7 +221,7 @@ int main (int argc, char** argv)
timer[NEIGH] += reneighbour(&param, &atom, &neighbor); timer[NEIGH] += reneighbour(&param, &atom, &neighbor);
} }
timer[FORCE] += computeForce(&param, &atom, &neighbor, 0, n + 1, param.every); timer[FORCE] += computeForce(&param, &atom, &neighbor, 0, n + 1);
finalIntegrate(&param, &atom); finalIntegrate(&param, &atom);
if(!((n + 1) % param.nstat) && (n+1) < param.ntimes) { if(!((n + 1) % param.nstat) && (n+1) < param.ntimes) {
@ -247,7 +246,13 @@ int main (int argc, char** argv)
printf(HLINE); printf(HLINE);
printf("Performance: %.2f million atom updates per second\n", printf("Performance: %.2f million atom updates per second\n",
1e-6 * (double) atom.Natoms * param.ntimes / timer[TOTAL]); 1e-6 * (double) atom.Natoms * param.ntimes / timer[TOTAL]);
double force_useful_volume = 1e-9 * ( (double)(atom.Nlocal * (param.ntimes + 1)) * (sizeof(MD_FLOAT) * 6 + sizeof(int)) +
(double)(neighbor.totalneighs) * (sizeof(MD_FLOAT) * 3 + sizeof(int)) );
#ifdef EXPLICIT_TYPES
force_useful_volume += 1e-9 * (double)((atom.Nlocal * (param.ntimes + 1)) + neighbor.totalneighs) * sizeof(int);
#endif
printf("total_neighs = %lld/%.2f\n", neighbor.totalneighs, (double)(neighbor.totalneighs));
printf("Useful read data volume for force computation: %.2fGB\n", force_useful_volume);
LIKWID_MARKER_CLOSE; LIKWID_MARKER_CLOSE;
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@ -69,6 +69,7 @@ void initNeighbor(Neighbor *neighbor, Parameter *param)
neighbor->maxneighs = 100; neighbor->maxneighs = 100;
neighbor->numneigh = NULL; neighbor->numneigh = NULL;
neighbor->neighbors = NULL; neighbor->neighbors = NULL;
neighbor->totalneighs = 0;
} }
void setupNeighbor() void setupNeighbor()