Commit d99214d9 authored by James Willis's avatar James Willis
Browse files

Only find the max_index and interact particles that are local to the node.

parent 41417788
......@@ -265,18 +265,20 @@ __attribute__((always_inline)) INLINE static void populate_max_index_no_cache(
const float dx_max, const float rshift, const double hi_max,
const double hj_max, const double di_max, const double dj_min,
int *max_index_i, int *max_index_j, int *init_pi, int *init_pj,
const timebin_t max_active_bin) {
const timebin_t max_active_bin, const int ci_local, const int cj_local) {
const struct part *restrict parts_i = ci->parts;
const struct part *restrict parts_j = cj->parts;
int first_pi = 0, last_pj = cj->count - 1;
int temp;
int temp, active_id;
if(ci_local) {
/* Find the leftmost active particle in cell i that interacts with any
* particle in cell j. */
first_pi = ci->count;
int active_id = first_pi - 1;
active_id = first_pi - 1;
while (first_pi > 0 && sort_i[first_pi - 1].d + dx_max + hi_max > dj_min) {
first_pi--;
/* Store the index of the particle if it is active. */
......@@ -319,7 +321,10 @@ __attribute__((always_inline)) INLINE static void populate_max_index_no_cache(
/* Make sure that max index is set to first particle in cj.*/
max_index_i[ci->count - 1] = 0;
}
}
else first_pi = ci->count - 1;
if(cj_local) {
/* Find the rightmost active particle in cell j that interacts with any
* particle in cell i. */
last_pj = -1;
......@@ -364,6 +369,8 @@ __attribute__((always_inline)) INLINE static void populate_max_index_no_cache(
/* Make sure that max index is set to last particle in ci.*/
max_index_j[0] = ci->count - 1;
}
}
else last_pj = 0;
*init_pi = first_pi;
*init_pj = last_pj;
......@@ -1155,7 +1162,7 @@ const int cj_local = 1;
/* Count number of particles that are in range and active*/
int numActive = 0;
if (active_ci) {
if (active_ci && ci_local) {
for (int pid = count_i - 1;
pid >= 0 && sort_i[pid].d + hi_max + dx_max > dj_min; pid--) {
struct part *restrict pi = &parts_i[sort_i[pid].i];
......@@ -1166,7 +1173,7 @@ const int cj_local = 1;
}
}
if (!numActive && active_cj) {
if (!numActive && active_cj && cj_local) {
for (int pjd = 0; pjd < count_j && sort_j[pjd].d - hj_max - dx_max < di_max;
pjd++) {
struct part *restrict pj = &parts_j[sort_j[pjd].i];
......@@ -1204,7 +1211,7 @@ const int cj_local = 1;
* pj that interacts with any particle in ci. */
populate_max_index_no_cache(ci, cj, sort_i, sort_j, dx_max, rshift, hi_max,
hj_max, di_max, dj_min, max_index_i, max_index_j,
&first_pi, &last_pj, max_active_bin);
&first_pi, &last_pj, max_active_bin, ci_local, cj_local);
/* Limits of the outer loops. */
int first_pi_loop = first_pi;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment