From 95cb0e07dfbf24a9ce7b4d417ea4d6356df8de0c Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <matthieu.schaller@durham.ac.uk> Date: Fri, 11 Aug 2017 14:06:10 +0100 Subject: [PATCH] Correctly skip inactive particles in the P-P pair tasks. --- src/runner_doiact_grav.h | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/runner_doiact_grav.h b/src/runner_doiact_grav.h index 59f4493630..7f2570b493 100644 --- a/src/runner_doiact_grav.h +++ b/src/runner_doiact_grav.h @@ -200,6 +200,9 @@ void runner_dopair_grav_pp_full(struct runner *r, struct cell *ci, /* Loop over all particles in ci... */ for (int pid = 0; pid < gcount_i; pid++) { + /* Skip inactive particles */ + if (!gpart_is_active(&gparts_i[pid], e)) continue; + const float x_i = ci_cache->x[pid]; const float y_i = ci_cache->y[pid]; const float z_i = ci_cache->z[pid]; @@ -272,7 +275,8 @@ void runner_dopair_grav_pp_full(struct runner *r, struct cell *ci, a_z -= f_ij * dz; #ifdef SWIFT_DEBUG_CHECKS - gparts_i[pid].num_interacted++; + /* Update the interaction counter if it's not a padded gpart */ + if (pjd < gcount_j) gparts_i[pid].num_interacted++; #endif } @@ -289,6 +293,9 @@ void runner_dopair_grav_pp_full(struct runner *r, struct cell *ci, /* Loop over all particles in ci... */ for (int pjd = 0; pjd < gcount_j; pjd++) { + /* Skip inactive particles */ + if (!gpart_is_active(&gparts_j[pjd], e)) continue; + const float x_j = cj_cache->x[pjd]; const float y_j = cj_cache->y[pjd]; const float z_j = cj_cache->z[pjd]; @@ -361,7 +368,8 @@ void runner_dopair_grav_pp_full(struct runner *r, struct cell *ci, a_z -= f_ji * dz; #ifdef SWIFT_DEBUG_CHECKS - gparts_j[pjd].num_interacted++; + /* Update the interaction counter if it's not a padded gpart */ + if (pid < gcount_i) gparts_j[pjd].num_interacted++; #endif } @@ -535,6 +543,9 @@ void runner_dopair_grav_pp_truncated(struct runner *r, struct cell *ci, /* Loop over all particles in ci... */ for (int pid = 0; pid < gcount_i; pid++) { + /* Skip inactive particles */ + if (!gpart_is_active(&gparts_i[pid], e)) continue; + const float x_i = ci_cache->x[pid]; const float y_i = ci_cache->y[pid]; const float z_i = ci_cache->z[pid]; @@ -612,7 +623,8 @@ void runner_dopair_grav_pp_truncated(struct runner *r, struct cell *ci, a_z -= f_ij * dz; #ifdef SWIFT_DEBUG_CHECKS - gparts_i[pid].num_interacted++; + /* Update the interaction counter if it's not a padded gpart */ + if (pjd < gcount_j) gparts_i[pid].num_interacted++; #endif } @@ -629,6 +641,9 @@ void runner_dopair_grav_pp_truncated(struct runner *r, struct cell *ci, /* Loop over all particles in ci... */ for (int pjd = 0; pjd < gcount_j; pjd++) { + /* Skip inactive particles */ + if (!gpart_is_active(&gparts_j[pjd], e)) continue; + const float x_j = cj_cache->x[pjd]; const float y_j = cj_cache->y[pjd]; const float z_j = cj_cache->z[pjd]; @@ -706,7 +721,8 @@ void runner_dopair_grav_pp_truncated(struct runner *r, struct cell *ci, a_z -= f_ji * dz; #ifdef SWIFT_DEBUG_CHECKS - gparts_j[pjd].num_interacted++; + /* Update the interaction counter if it's not a padded gpart */ + if (pid < gcount_i) gparts_j[pjd].num_interacted++; #endif } -- GitLab