From e637a26844b2b77195182afb7fce28ea843385d4 Mon Sep 17 00:00:00 2001 From: Rafael Ravedutti Date: Fri, 25 Feb 2022 14:19:48 +0100 Subject: [PATCH] Add percentage of atoms within cutoff radius when using GROMACS reference version Signed-off-by: Rafael Ravedutti --- gromacs/force_lj.c | 8 ++++++-- gromacs/includes/stats.h | 2 ++ gromacs/stats.c | 15 +++++++++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/gromacs/force_lj.c b/gromacs/force_lj.c index cdd6b82..9d7238f 100644 --- a/gromacs/force_lj.c +++ b/gromacs/force_lj.c @@ -83,6 +83,9 @@ double computeForceLJ_ref(Parameter *param, Atom *atom, Neighbor *neighbor, Stat fix += delx * force; fiy += dely * force; fiz += delz * force; + addStat(stats->atoms_within_cutoff, 1); + } else { + addStat(stats->atoms_outside_cutoff, 1); } } } @@ -93,8 +96,9 @@ double computeForceLJ_ref(Parameter *param, Atom *atom, Neighbor *neighbor, Stat } } + addStat(stats->calculated_forces, 1); addStat(stats->num_neighs, numneighs); - addStat(stats->force_iters, (numneighs + VECTOR_WIDTH - 1) / VECTOR_WIDTH); + addStat(stats->force_iters, (long long int)((double)numneighs * CLUSTER_DIM_M / CLUSTER_DIM_N)); } LIKWID_MARKER_STOP("force"); @@ -250,7 +254,7 @@ double computeForceLJ_4xn(Parameter *param, Atom *atom, Neighbor *neighbor, Stat addStat(stats->calculated_forces, 1); addStat(stats->num_neighs, numneighs); - addStat(stats->force_iters, numneighs / 2); + addStat(stats->force_iters, (long long int)((double)numneighs * CLUSTER_DIM_M / CLUSTER_DIM_N)); } LIKWID_MARKER_STOP("force"); diff --git a/gromacs/includes/stats.h b/gromacs/includes/stats.h index 9c61788..4b08e3d 100644 --- a/gromacs/includes/stats.h +++ b/gromacs/includes/stats.h @@ -29,6 +29,8 @@ typedef struct { long long int calculated_forces; long long int num_neighs; long long int force_iters; + long long int atoms_within_cutoff; + long long int atoms_outside_cutoff; } Stats; void initStats(Stats *s); diff --git a/gromacs/stats.c b/gromacs/stats.c index 562a9fa..ccc6030 100644 --- a/gromacs/stats.c +++ b/gromacs/stats.c @@ -9,10 +9,13 @@ void initStats(Stats *s) { s->calculated_forces = 0; s->num_neighs = 0; s->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 + const int MxN = CLUSTER_DIM_M * CLUSTER_DIM_N; double avg_atoms_cluster = (double)(atom->Nlocal) / (double)(atom->Nclusters_local); double force_useful_volume = 1e-9 * ( (double)(atom->Nlocal * (param->ntimes + 1)) * (sizeof(MD_FLOAT) * 6 + sizeof(int)) + @@ -20,9 +23,11 @@ void displayStatistics(Atom *atom, Parameter *param, Stats *stats, double *timer double avg_neigh_atom = (stats->num_neighs * CLUSTER_DIM_N) / (double)(atom->Nlocal * (param->ntimes + 1)); double avg_neigh_cluster = (double)(stats->num_neighs) / (double)(stats->calculated_forces); double avg_simd = stats->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->num_neighs) * sizeof(int); -#endif + #endif + printf("Statistics:\n"); printf("\tVector width: %d, Processor frequency: %.4f GHz\n", VECTOR_WIDTH, param->proc_freq); printf("\tAverage atoms per cluster: %.4f\n", avg_atoms_cluster); @@ -33,5 +38,11 @@ void displayStatistics(Atom *atom, Parameter *param, Stats *stats, double *timer printf("\tTotal number of SIMD iterations: %lld\n", stats->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->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 }