Commit 34f4318d authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Code formatting. Elimination of unused variable. Missing documentation parameters.

parent 28cb441d
......@@ -884,8 +884,11 @@ void DOSELF_SUBSET(struct runner *r, struct cell *restrict ci,
* @param r The #runner.
* @param ci The first #cell.
* @param cj The second #cell.
* @param sid The direction of the pair
* @param shift The shift vector to apply to the particles in ci.
*/
void DOPAIR1(struct runner *r, struct cell *ci, struct cell *cj, const int sid, const double *shift) {
void DOPAIR1(struct runner *r, struct cell *ci, struct cell *cj, const int sid,
const double *shift) {
const struct engine *restrict e = r->e;
......@@ -1100,8 +1103,9 @@ void DOPAIR1(struct runner *r, struct cell *ci, struct cell *cj, const int sid,
TIMER_TOC(TIMER_DOPAIR);
}
/**
* @brief Determine which version of DOPAIR1 needs to be called depending on the orientation of the cells or whether DOPAIR1 needs to be called at all.
/**
* @brief Determine which version of DOPAIR1 needs to be called depending on the
* orientation of the cells or whether DOPAIR1 needs to be called at all.
*
* @param r #runner
* @param ci #cell ci
......@@ -1118,7 +1122,7 @@ void DOPAIR1_BRANCH(struct runner *r, struct cell *ci, struct cell *cj) {
/* Check that cells are drifted. */
if (!cell_are_part_drifted(ci, e) || !cell_are_part_drifted(cj, e))
error("Interacting undrifted cells.");
/* Get the sort ID. */
double shift[3] = {0.0, 0.0, 0.0};
const int sid = space_getsid(e->s, &ci, &cj, shift);
......@@ -1133,12 +1137,13 @@ void DOPAIR1_BRANCH(struct runner *r, struct cell *ci, struct cell *cj) {
if (!(ci->sorted & (1 << sid)) || !(cj->sorted & (1 << sid)))
error("Trying to interact unsorted cells.");
#if defined(WITH_VECTORIZATION) && defined(GADGET2_SPH) && (DOPAIR1_BRANCH == runner_dopair1_density_branch)
if(!sort_is_corner(sid))
#if defined(WITH_VECTORIZATION) && defined(GADGET2_SPH) && \
(DOPAIR1_BRANCH == runner_dopair1_density_branch)
if (!sort_is_corner(sid))
runner_dopair1_density_vec(r, ci, cj, sid, shift);
else
DOPAIR1(r, ci, cj, sid, shift);
#else
#else
DOPAIR1(r, ci, cj, sid, shift);
#endif
}
......@@ -2317,7 +2322,7 @@ void DOSUB_PAIR1(struct runner *r, struct cell *ci, struct cell *cj, int sid,
cj->dx_max_sort > cj->dmin * space_maxreldx)
runner_do_sort(r, cj, (1 << sid), 1);
/* Compute the interactions. */
/* Compute the interactions. */
DOPAIR1_BRANCH(r, ci, cj);
}
......
......@@ -20,13 +20,12 @@
/* Config parameters. */
#include "../config.h"
#include "swift.h"
#include "active.h"
/* This object's header. */
#include "runner_doiact_vec.h"
/* Local headers. */
#include "active.h"
#ifdef WITH_VECTORIZATION
/**
* @brief Compute the vector remainder interactions from the secondary cache.
......@@ -262,37 +261,40 @@ __attribute__((always_inline)) INLINE static void storeInteractions(
}
}
/* @brief Populates the arrays max_di and max_dj with the maximum distances of
/**
* @brief Populates the arrays max_di and max_dj with the maximum distances of
* particles into their neighbouring cells. Also finds the first pi that
* interacts with any particle in cj and the last pj that interacts with any
* particle in ci.
*
* @param ci #cell pointer to ci
* @param cj #cell pointer to cj
* @param sort_i #entry array for particle distance in ci
* @param sort_j #entry array for particle distance in cj
* @param ci_cache #cache for cell ci
* @param cj_cache #cache for cell cj
* @param dx_max maximum particle movement allowed in cell
* @param rshift cutoff shift
* @param hi_max Maximal smoothing length in cell ci
* @param hj_max Maximal smoothing length in cell cj
* @param di_max Maximal position on the axis that can interact in cell ci
* @param dj_min Minimal position on the axis that can interact in cell ci
* @param max_di array to hold the maximum distances of pi particles into cell
* cj
* @param max_dj array to hold the maximum distances of pj particles into cell
* cj
* @param init_pi first pi to interact with a pj particle
* @param init_pj last pj to interact with a pi particle
* @param e The #engine.
*/
__attribute__((always_inline)) INLINE static void populate_max_d_no_cache(
const struct cell *ci, const struct cell *cj,
const struct entry *restrict sort_i, const struct entry *restrict sort_j,
const float dx_max, const float rshift, const double hi_max, const double hj_max,
const double di_max, const double dj_min, float *max_di, float *max_dj,
int *init_pi, int *init_pj, const struct engine *e) {
const float dx_max, const float rshift, const double hi_max,
const double hj_max, const double di_max, const double dj_min,
float *max_di, float *max_dj, int *init_pi, int *init_pj,
const struct engine *e) {
struct part *restrict parts_i = ci->parts;
struct part *restrict parts_j = cj->parts;
struct part *p = &parts_i[sort_i[0].i];
float h, d;
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;
......@@ -301,11 +303,10 @@ __attribute__((always_inline)) INLINE static void populate_max_d_no_cache(
/* Populate max_di with distances. */
int active_id = ci->count - 1;
for (int k = ci->count - 1; k >= 0; k--) {
p = &parts_i[sort_i[k].i];
h = p->h;
d = sort_i[k].d + dx_max;
const struct part *pi = &parts_i[sort_i[k].i];
const float d = sort_i[k].d + dx_max;
//max_di[k] = d + h * kernel_gamma - rshift;
// max_di[k] = d + h * kernel_gamma - rshift;
max_di[k] = d + hi_max;
/* If the particle is out of range set the index to
......@@ -314,7 +315,7 @@ __attribute__((always_inline)) INLINE static void populate_max_d_no_cache(
first_pi = active_id;
break;
} else {
if (part_is_active(p, e)) active_id = k;
if (part_is_active(pi, e)) active_id = k;
}
}
......@@ -327,12 +328,11 @@ __attribute__((always_inline)) INLINE static void populate_max_d_no_cache(
/* Populate max_dj with distances. */
active_id = 0;
for (int k = 0; k < cj->count; k++) {
p = &parts_j[sort_j[k].i];
h = p->h;
d = sort_j[k].d - dx_max;
const struct part *pj = &parts_j[sort_j[k].i];
const float d = sort_j[k].d - dx_max;
/*TODO: don't think rshift should be taken off here, waiting on Pedro. */
//max_dj[k] = d - h * kernel_gamma - rshift;
// max_dj[k] = d - h * kernel_gamma - rshift;
max_dj[k] = d - hj_max;
/* If the particle is out of range set the index to
......@@ -341,7 +341,7 @@ __attribute__((always_inline)) INLINE static void populate_max_d_no_cache(
last_pj = active_id;
break;
} else {
if (part_is_active(p, e)) active_id = k;
if (part_is_active(pj, e)) active_id = k;
}
}
......@@ -611,9 +611,12 @@ __attribute__((always_inline)) INLINE void runner_doself1_density_vec(
* @param r The #runner.
* @param ci The first #cell.
* @param cj The second #cell.
* @param sid The direction of the pair
* @param shift The shift vector to apply to the particles in ci.
*/
void runner_dopair1_density_vec(struct runner *r, struct cell *ci,
struct cell *cj, const int sid, const double *shift) {
struct cell *cj, const int sid,
const double *shift) {
#ifdef WITH_VECTORIZATION
const struct engine *restrict e = r->e;
......@@ -710,8 +713,9 @@ void runner_dopair1_density_vec(struct runner *r, struct cell *ci,
/* Find particles maximum distance into cj, max_di[] and ci, max_dj[]. */
/* Also find the first pi that interacts with any particle in cj and the last
* pj that interacts with any particle in ci. */
populate_max_d_no_cache(ci, cj, sort_i, sort_j, dx_max, rshift, hi_max,
hj_max, di_max, dj_min, max_di, max_dj, &first_pi, &last_pj, e);
populate_max_d_no_cache(ci, cj, sort_i, sort_j, dx_max, rshift, hi_max,
hj_max, di_max, dj_min, max_di, max_dj, &first_pi,
&last_pj, e);
/* Find the maximum index into cj that is required by a particle in ci. */
/* Find the maximum index into ci that is required by a particle in cj. */
......@@ -766,7 +770,8 @@ void runner_dopair1_density_vec(struct runner *r, struct cell *ci,
/* Skip this particle if no particle in cj is within range of it. */
const float hi = ci_cache->h[ci_cache_idx];
const double di_test = sort_i[pid].d + hi * kernel_gamma + dx_max - rshift;
const double di_test =
sort_i[pid].d + hi * kernel_gamma + dx_max - rshift;
if (di_test < dj_min) continue;
/* Determine the exit iteration of the interaction loop. */
......@@ -779,7 +784,7 @@ void runner_dopair1_density_vec(struct runner *r, struct cell *ci,
int exit_iteration = max_ind_j + 1;
const float hig2 = hi * hi * kernel_gamma2;
vector pix, piy, piz;
/* Fill particle pi vectors. */
......@@ -891,7 +896,7 @@ void runner_dopair1_density_vec(struct runner *r, struct cell *ci,
}
if (cell_is_active(cj, e)) {
/* Loop over the parts in cj until nothing is within range in ci. */
for (int pjd = 0; pjd <= last_pj_loop && max_ind_i < count_i; pjd++) {
......@@ -905,9 +910,10 @@ void runner_dopair1_density_vec(struct runner *r, struct cell *ci,
/*TODO: rshift term. */
/* Skip this particle if no particle in ci is within range of it. */
const float hj = cj_cache->h[cj_cache_idx];
const double dj_test = sort_j[pjd].d - hj * kernel_gamma - dx_max - rshift;
const double dj_test =
sort_j[pjd].d - hj * kernel_gamma - dx_max - rshift;
if (dj_test > di_max) continue;
/* Determine the exit iteration of the interaction loop. */
di = sort_i[max_ind_i].d;
while (max_ind_i < count_i - 1 && max_dj[pjd] > di) {
......
......@@ -36,6 +36,7 @@
/* Function prototypes. */
void runner_doself1_density_vec(struct runner *r, struct cell *restrict c);
void runner_dopair1_density_vec(struct runner *r, struct cell *restrict ci,
struct cell *restrict cj, const int sid, const double *shift);
struct cell *restrict cj, const int sid,
const double *shift);
#endif /* SWIFT_RUNNER_VEC_H */
......@@ -432,7 +432,8 @@ void dump_particle_fields(char *fileName, struct cell *main_cell,
/* Just a forward declaration... */
void runner_dopair1_density(struct runner *r, struct cell *ci, struct cell *cj);
void runner_dopair1_branch_density(struct runner *r, struct cell *ci, struct cell *cj);
void runner_dopair1_branch_density(struct runner *r, struct cell *ci,
struct cell *cj);
void runner_doself1_density(struct runner *r, struct cell *ci);
void runner_dopair2_force(struct runner *r, struct cell *ci, struct cell *cj);
void runner_doself2_force(struct runner *r, struct cell *ci);
......
......@@ -62,12 +62,13 @@ enum velocity_types {
* @param offset The position of the cell offset from (0,0,0).
* @param size The cell size.
* @param h The smoothing length of the particles in units of the inter-particle
*separation.
* separation.
* @param density The density of the fluid.
* @param partId The running counter of IDs.
* @param pert The perturbation to apply to the particles in the cell in units
*of the inter-particle separation.
* of the inter-particle separation.
* @param vel The type of velocity field (0, random, divergent, rotating)
* @param h_pert The perturbation to apply to the smoothing length.
*/
struct cell *make_cell(size_t n, double *offset, double size, double h,
double density, long long *partId, double pert,
......@@ -120,8 +121,8 @@ struct cell *make_cell(size_t n, double *offset, double size, double h,
part->v[2] = 0.f;
break;
}
if(h_pert)
part->h = size * h * random_uniform(1.f,1.1f) / (float)n;
if (h_pert)
part->h = size * h * random_uniform(1.f, 1.1f) / (float)n;
else
part->h = size * h / (float)n;
h_max = fmax(h_max, part->h);
......@@ -294,7 +295,8 @@ void dump_particle_fields(char *fileName, struct cell *main_cell,
/* Just a forward declaration... */
void runner_doself1_density(struct runner *r, struct cell *ci);
void runner_doself1_density_vec(struct runner *r, struct cell *ci);
void runner_dopair1_branch_density(struct runner *r, struct cell *ci, struct cell *cj);
void runner_dopair1_branch_density(struct runner *r, struct cell *ci,
struct cell *cj);
/* And go... */
int main(int argc, char *argv[]) {
......@@ -415,8 +417,9 @@ int main(int argc, char *argv[]) {
for (int j = 0; j < 3; ++j) {
for (int k = 0; k < 3; ++k) {
double offset[3] = {i * size, j * size, k * size};
cells[i * 9 + j * 3 + k] = make_cell(particles, offset, size, h, rho,
&partId, perturbation, vel, h_pert);
cells[i * 9 + j * 3 + k] =
make_cell(particles, offset, size, h, rho, &partId, perturbation,
vel, h_pert);
runner_do_drift_part(&runner, cells[i * 9 + j * 3 + k], 0);
......
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