From ed2929c8134d68678c7730acea322cfe06917358 Mon Sep 17 00:00:00 2001 From: Rafael Ravedutti Date: Fri, 25 Feb 2022 14:40:33 +0100 Subject: [PATCH] Add percentage of atoms within cutoff radius when using LAMMPS reference version Signed-off-by: Rafael Ravedutti --- Makefile | 2 +- lammps/force_lj.c | 5 +++++ lammps/includes/stats.h | 2 ++ lammps/stats.c | 15 +++++++++++++-- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 76f3709..7986ebb 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ #CONFIGURE BUILD SYSTEM TARGET = MDBench-$(TAG)-$(OPT_SCHEME) -BUILD_DIR = ./$(TAG) +BUILD_DIR = ./$(TAG)-$(OPT_SCHEME) SRC_DIR = ./$(OPT_SCHEME) ASM_DIR = ./asm MAKE_DIR = ./ diff --git a/lammps/force_lj.c b/lammps/force_lj.c index 73c0269..5baa1e7 100644 --- a/lammps/force_lj.c +++ b/lammps/force_lj.c @@ -87,6 +87,11 @@ double computeForceLJ(Parameter *param, Atom *atom, Neighbor *neighbor, Stats *s fix += delx * force; fiy += dely * force; fiz += delz * force; +#ifdef USE_REFERENCE_VERSION + addStat(stats->atoms_within_cutoff, 1); + } else { + addStat(stats->atoms_outside_cutoff, 1); +#endif } } diff --git a/lammps/includes/stats.h b/lammps/includes/stats.h index 231119b..7b99870 100644 --- a/lammps/includes/stats.h +++ b/lammps/includes/stats.h @@ -28,6 +28,8 @@ typedef struct { long long int total_force_neighs; long long int total_force_iters; + long long int atoms_within_cutoff; + long long int atoms_outside_cutoff; } Stats; void initStats(Stats *s); diff --git a/lammps/stats.c b/lammps/stats.c index defaeac..1df7e5c 100644 --- a/lammps/stats.c +++ b/lammps/stats.c @@ -8,17 +8,22 @@ void initStats(Stats *s) { s->total_force_neighs = 0; s->total_force_iters = 0; + s->atoms_within_cutoff = 0; + s->atoms_outside_cutoff = 0; } void displayStatistics(Atom *atom, Parameter *param, Stats *stats, double *timer) { #ifdef COMPUTE_STATS + double force_useful_volume = 1e-9 * ( (double)(atom->Nlocal * (param->ntimes + 1)) * (sizeof(MD_FLOAT) * 6 + sizeof(int)) + (double)(stats->total_force_neighs) * (sizeof(MD_FLOAT) * 3 + sizeof(int)) ); double avg_neigh = stats->total_force_neighs / (double)(atom->Nlocal * (param->ntimes + 1)); double avg_simd = stats->total_force_iters / (double)(atom->Nlocal * (param->ntimes + 1)); -#ifdef EXPLICIT_TYPES + + #ifdef EXPLICIT_TYPES force_useful_volume += 1e-9 * (double)((atom->Nlocal * (param->ntimes + 1)) + stats->total_force_neighs) * sizeof(int); -#endif + #endif + printf("Statistics:\n"); printf("\tVector width: %d, Processor frequency: %.4f GHz\n", VECTOR_WIDTH, param->proc_freq); printf("\tAverage neighbors per atom: %.4f\n", avg_neigh); @@ -27,5 +32,11 @@ void displayStatistics(Atom *atom, Parameter *param, Stats *stats, double *timer printf("\tTotal number of SIMD iterations: %lld\n", stats->total_force_iters); printf("\tUseful read data volume for force computation: %.2fGB\n", force_useful_volume); printf("\tCycles/SIMD iteration: %.4f\n", timer[FORCE] * param->proc_freq * 1e9 / stats->total_force_iters); + + #ifdef USE_REFERENCE_VERSION + const double eff_pct = (double)stats->atoms_within_cutoff / (double)(stats->atoms_within_cutoff + stats->atoms_outside_cutoff) * 100.0; + printf("\tAtoms within/outside cutoff radius: %lld/%lld (%.2f%%)\n", stats->atoms_within_cutoff, stats->atoms_outside_cutoff, eff_pct); + #endif + #endif }