Skip to content
Snippets Groups Projects
Commit 28e61a69 authored by James Willis's avatar James Willis
Browse files

Read a single cell into a cache in sorted order.

parent fae57756
Branches
Tags
1 merge request!320Dopair1 vectorisation merge
...@@ -270,6 +270,41 @@ __attribute__((always_inline)) INLINE void cache_read_two_cells( ...@@ -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. * @brief Populate cache by reading in the particles from two cells in sorted order.
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment