From 28e61a69e198e7490a7a44b42edc53e70ce5bbfe Mon Sep 17 00:00:00 2001 From: James Willis <james.s.willis@durham.ac.uk> Date: Thu, 19 Jan 2017 12:16:30 +0000 Subject: [PATCH] Read a single cell into a cache in sorted order. --- src/cache.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/cache.h b/src/cache.h index 295a9d9a64..0986ced872 100644 --- a/src/cache.h +++ b/src/cache.h @@ -270,6 +270,41 @@ __attribute__((always_inline)) INLINE void cache_read_two_cells( } } +__attribute__((always_inline)) INLINE void cache_read_cell_sorted( + const struct cell *const ci, struct cache *const ci_cache, const struct entry *restrict sort_i, const double *const shift) { + + int idx; + /* Shift the particles positions to a local frame (ci frame) so single precision can be + * used instead of double precision. Also shift the cell ci, particles positions due to BCs but leave cell cj. */ +#ifdef WITH_VECTORIZATION +#pragma simd +#endif + for (int i = 0; i < ci->count; i++) { + idx = sort_i[i].i; + + ci_cache->x[i] = ci->parts[idx].x[0] - ci->loc[0] - shift[0]; + ci_cache->y[i] = ci->parts[idx].x[1] - ci->loc[1] - shift[1]; + ci_cache->z[i] = ci->parts[idx].x[2] - ci->loc[2] - shift[2]; + ci_cache->h[i] = ci->parts[idx].h; + + ci_cache->m[i] = ci->parts[idx].mass; + ci_cache->vx[i] = ci->parts[idx].v[0]; + ci_cache->vy[i] = ci->parts[idx].v[1]; + ci_cache->vz[i] = ci->parts[idx].v[2]; + +#ifdef DOPAIR1_AUTO_VEC + ci_cache->rho[i] = 0.0f; + ci_cache->rho_dh[i] = 0.0f; + ci_cache->wcount[i] = 0.0f; + ci_cache->wcount_dh[i] = 0.0f; + ci_cache->div_v[i] = 0.0f; + ci_cache->curl_vx[i] = 0.0f; + ci_cache->curl_vy[i] = 0.0f; + ci_cache->curl_vz[i] = 0.0f; +#endif + } +} + /** * @brief Populate cache by reading in the particles from two cells in sorted order. * -- GitLab