Add clusters efficiency on stats

Signed-off-by: Rafael Ravedutti <rafaelravedutti@gmail.com>
This commit is contained in:
Rafael Ravedutti 2022-02-28 16:10:09 +01:00
parent ed2929c813
commit c62e4ea4ad
3 changed files with 16 additions and 2 deletions

View File

@ -61,6 +61,7 @@ double computeForceLJ_ref(Parameter *param, Atom *atom, Neighbor *neighbor, Stat
for(int k = 0; k < numneighs; k++) { for(int k = 0; k < numneighs; k++) {
int cj = neighs[k]; int cj = neighs[k];
int any = 0;
MD_FLOAT *cjptr = cluster_pos_ptr(cj); MD_FLOAT *cjptr = cluster_pos_ptr(cj);
for(int cii = 0; cii < CLUSTER_DIM_M; cii++) { for(int cii = 0; cii < CLUSTER_DIM_M; cii++) {
MD_FLOAT xtmp = cluster_x(ciptr, cii); MD_FLOAT xtmp = cluster_x(ciptr, cii);
@ -83,6 +84,7 @@ double computeForceLJ_ref(Parameter *param, Atom *atom, Neighbor *neighbor, Stat
fix += delx * force; fix += delx * force;
fiy += dely * force; fiy += dely * force;
fiz += delz * force; fiz += delz * force;
any = 1;
addStat(stats->atoms_within_cutoff, 1); addStat(stats->atoms_within_cutoff, 1);
} else { } else {
addStat(stats->atoms_outside_cutoff, 1); addStat(stats->atoms_outside_cutoff, 1);
@ -90,6 +92,12 @@ double computeForceLJ_ref(Parameter *param, Atom *atom, Neighbor *neighbor, Stat
} }
} }
if(any != 0) {
addStat(stats->clusters_within_cutoff, 1);
} else {
addStat(stats->clusters_outside_cutoff, 1);
}
cluster_x(cifptr, cii) += fix; cluster_x(cifptr, cii) += fix;
cluster_y(cifptr, cii) += fiy; cluster_y(cifptr, cii) += fiy;
cluster_z(cifptr, cii) += fiz; cluster_z(cifptr, cii) += fiz;

View File

@ -31,6 +31,8 @@ typedef struct {
long long int force_iters; long long int force_iters;
long long int atoms_within_cutoff; long long int atoms_within_cutoff;
long long int atoms_outside_cutoff; long long int atoms_outside_cutoff;
long long int clusters_within_cutoff;
long long int clusters_outside_cutoff;
} Stats; } Stats;
void initStats(Stats *s); void initStats(Stats *s);

View File

@ -11,6 +11,8 @@ void initStats(Stats *s) {
s->force_iters = 0; s->force_iters = 0;
s->atoms_within_cutoff = 0; s->atoms_within_cutoff = 0;
s->atoms_outside_cutoff = 0; s->atoms_outside_cutoff = 0;
s->clusters_within_cutoff = 0;
s->clusters_outside_cutoff = 0;
} }
void displayStatistics(Atom *atom, Parameter *param, Stats *stats, double *timer) { void displayStatistics(Atom *atom, Parameter *param, Stats *stats, double *timer) {
@ -40,8 +42,10 @@ void displayStatistics(Atom *atom, Parameter *param, Stats *stats, double *timer
printf("\tCycles/SIMD iteration: %.4f\n", timer[FORCE] * param->proc_freq * 1e9 / stats->force_iters); printf("\tCycles/SIMD iteration: %.4f\n", timer[FORCE] * param->proc_freq * 1e9 / stats->force_iters);
#ifdef USE_REFERENCE_VERSION #ifdef USE_REFERENCE_VERSION
const double eff_pct = (double)stats->atoms_within_cutoff / (double)(stats->atoms_within_cutoff + stats->atoms_outside_cutoff) * 100.0; const double atoms_eff = (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); printf("\tAtoms within/outside cutoff radius: %lld/%lld (%.2f%%)\n", stats->atoms_within_cutoff, stats->atoms_outside_cutoff, atoms_eff);
const double clusters_eff = (double)stats->clusters_within_cutoff / (double)(stats->clusters_within_cutoff + stats->clusters_outside_cutoff) * 100.0;
printf("\tClusters within/outside cutoff radius: %lld/%lld (%.2f%%)\n", stats->clusters_within_cutoff, stats->clusters_outside_cutoff, clusters_eff);
#endif #endif
#endif #endif