From 3768bb176616447fbe4c48b1cb44c8fd46611445 Mon Sep 17 00:00:00 2001 From: James Willis Date: Wed, 16 Aug 2017 14:57:58 +0100 Subject: [PATCH] Correct the use of rshift to reduce the number of distance calculations. --- src/runner_doiact.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/runner_doiact.h b/src/runner_doiact.h index 47ebba61d..906e9ad35 100644 --- a/src/runner_doiact.h +++ b/src/runner_doiact.h @@ -1037,9 +1037,9 @@ void DOPAIR1(struct runner *r, struct cell *ci, struct cell *cj, const int sid, struct part *restrict pj = &parts_j[sort_j[pjd].i]; if (!part_is_active(pj, e)) continue; const float hj = pj->h; - const double dj = sort_j[pjd].d - hj * kernel_gamma - dx_max - rshift; - if (dj > di_max) continue; - + const double dj = sort_j[pjd].d - hj * kernel_gamma - dx_max + rshift; + if (dj - rshift > di_max) continue; + double pjx[3]; for (int k = 0; k < 3; k++) pjx[k] = pj->x[k] + shift[k]; const float hjg2 = hj * hj * kernel_gamma2; @@ -1449,9 +1449,9 @@ void DOPAIR2(struct runner *r, struct cell *ci, struct cell *cj) { /* Get a hold of the jth part in cj. */ struct part *restrict pj = &parts_j[sort_j[pjd].i]; const float hj = pj->h; - const double dj = sort_j[pjd].d - hj * kernel_gamma - dx_max - rshift; - if (dj > di_max) continue; - + const double dj = sort_j[pjd].d - hj * kernel_gamma - dx_max + rshift; + if (dj - rshift > di_max) continue; + double pjx[3]; for (int k = 0; k < 3; k++) pjx[k] = pj->x[k] + shift[k]; const float hjg2 = hj * hj * kernel_gamma2; -- GitLab