diff --git a/src/runner_doiact.h b/src/runner_doiact.h index 18ca7663f009acae653e1e120d76ced9c91ff8d7..2b53e8b4b484bd194203d73c33465a283e9fdec3 100644 --- a/src/runner_doiact.h +++ b/src/runner_doiact.h @@ -32,15 +32,18 @@ #define _DOPAIR2(f) PASTE(runner_dopair2, f) #define DOPAIR2 _DOPAIR2(FUNCTION) -#define _DOPAIR1_NOSORT(f) PASTE(runner_dopair1_sort, f) +#define _DOPAIR1_NOSORT(f) PASTE(runner_dopair1_nosort, f) #define DOPAIR1_NOSORT _DOPAIR1_NOSORT(FUNCTION) -#define _DOPAIR2_NOSORT(f) PASTE(runner_dopair2_sort, f) +#define _DOPAIR2_NOSORT(f) PASTE(runner_dopair2_nosort, f) #define DOPAIR2_NOSORT _DOPAIR2_NOSORT(FUNCTION) #define _DOPAIR_SUBSET(f) PASTE(runner_dopair_subset, f) #define DOPAIR_SUBSET _DOPAIR_SUBSET(FUNCTION) +#define _DOPAIR_SUBSET_NOSORT(f) PASTE(runner_dopair_subset_nosort, f) +#define DOPAIR_SUBSET_NOSORT _DOPAIR_SUBSET_NOSORT(FUNCTION) + #define _DOPAIR_SUBSET_NAIVE(f) PASTE(runner_dopair_subset_naive, f) #define DOPAIR_SUBSET_NAIVE _DOPAIR_SUBSET_NAIVE(FUNCTION) @@ -430,6 +433,13 @@ void DOPAIR_SUBSET(struct runner *r, struct cell *restrict ci, struct engine *e = r->e; +#ifdef WITH_MPI + if(ci->nodeID != cj->nodeID) { + DOPAIR_SUBSET_NOSORT(r, ci, parts_i, ind, count, cj); + return; + } +#endif + #ifdef WITH_OLD_VECTORIZATION int icount = 0; float r2q[VEC_SIZE] __attribute__((aligned(16))); diff --git a/src/runner_doiact_nosort.h b/src/runner_doiact_nosort.h index f2fa71915f6803fa3d87ee83ed80cff4d27f5fc7..e0938828332db3eca84ef0ed7615b2a0ad4a1772 100644 --- a/src/runner_doiact_nosort.h +++ b/src/runner_doiact_nosort.h @@ -241,3 +241,76 @@ void DOPAIR2_NOSORT(struct runner *r, struct cell *ci, TIMER_TOC(TIMER_DOPAIR); } + + +/** + * @brief Compute the interactions between a cell pair, but only for the + * given indices in ci. + * + * @param r The #runner. + * @param ci The first #cell. + * @param parts_i The #part to interact with @c cj. + * @param ind The list of indices of particles in @c ci to interact with. + * @param count The number of particles in @c ind. + * @param cj The second #cell. + */ +void DOPAIR_SUBSET_NOSORT(struct runner *r, struct cell *restrict ci, + struct part *restrict parts_i, int *restrict ind, int count, + struct cell *restrict cj) { + + struct engine *e = r->e; + + + TIMER_TIC; + + const int count_j = cj->count; + struct part *restrict parts_j = cj->parts; + + /* Get the relative distance between the pairs, wrapping. */ + double shift[3] = {0.0, 0.0, 0.0}; + for (int k = 0; k < 3; k++) { + if (cj->loc[k] - ci->loc[k] < -e->s->dim[k] / 2) + shift[k] = e->s->dim[k]; + else if (cj->loc[k] - ci->loc[k] > e->s->dim[k] / 2) + shift[k] = -e->s->dim[k]; + } + + + /* Loop over the parts_i. */ + for (int pid = 0; pid < count; pid++) { + + /* Get a hold of the ith part in ci. */ + struct part *restrict pi = &parts_i[ind[pid]]; + double pix[3]; + for (int k = 0; k < 3; k++) pix[k] = pi->x[k] - shift[k]; + const float hi = pi->h; + const float hig2 = hi * hi * kernel_gamma2; + + if (!part_is_active(pi, e)) + error("Trying to correct smoothing length of inactive particle !"); + + /* Loop over the parts in cj. */ + for (int pjd = 0; pjd < count_j; pjd++) { + + /* Get a pointer to the jth particle. */ + struct part *restrict pj = &parts_j[pjd]; + + /* Compute the pairwise distance. */ + float r2 = 0.0f; + float dx[3]; + for (int k = 0; k < 3; k++) { + dx[k] = pix[k] - pj->x[k]; + r2 += dx[k] * dx[k]; + } + + /* Hit or miss? */ + if (r2 < hig2) { + + IACT_NONSYM(r2, dx, hi, pj->h, pi, pj); + + } + } /* loop over the parts in cj. */ + } /* loop over the parts in ci. */ + + TIMER_TOC(timer_dopair_subset); +}