Commit 77606a7e authored by James Willis's avatar James Willis
Browse files

Formatting.

parent e2a49f88
......@@ -408,7 +408,8 @@ __attribute__((always_inline)) INLINE void cache_read_two_partial_cells_sorted(
/* Pad cache with fake particles that exist outside the cell so will not
* interact.*/
const float max_dx = max(ci->dx_max_part, cj->dx_max_part);
const float pos_padded[3] = {-(2. * ci->width[0] + max_dx), -(2. * ci->width[1] + max_dx),
const float pos_padded[3] = {-(2. * ci->width[0] + max_dx),
-(2. * ci->width[1] + max_dx),
-(2. * ci->width[2] + max_dx)};
for (int i = ci->count - first_pi_align;
......@@ -480,8 +481,9 @@ __attribute__((always_inline)) INLINE void cache_read_two_partial_cells_sorted(
/* Pad cache with fake particles that exist outside the cell so will not
* interact.*/
const float pos_padded_j[3] = {-(2. * cj->width[0] + max_dx), -(2. * cj->width[1] + max_dx),
-(2. * cj->width[2] + max_dx)};
const float pos_padded_j[3] = {-(2. * cj->width[0] + max_dx),
-(2. * cj->width[1] + max_dx),
-(2. * cj->width[2] + max_dx)};
for (int i = last_pj_align + 1; i < last_pj_align + 1 + VEC_SIZE; i++) {
xj[i] = pos_padded_j[0];
yj[i] = pos_padded_j[1];
......@@ -596,7 +598,8 @@ cache_read_two_partial_cells_sorted_force(
/* Pad cache with fake particles that exist outside the cell so will not
* interact.*/
const float max_dx = max(ci->dx_max_part, cj->dx_max_part);
const float pos_padded[3] = {-(2. * ci->width[0] + max_dx), -(2. * ci->width[1] + max_dx),
const float pos_padded[3] = {-(2. * ci->width[0] + max_dx),
-(2. * ci->width[1] + max_dx),
-(2. * ci->width[2] + max_dx)};
const float h_padded = ci->parts[0].h;
......@@ -660,8 +663,9 @@ cache_read_two_partial_cells_sorted_force(
/* Pad cache with fake particles that exist outside the cell so will not
* interact.*/
const float pos_padded_j[3] = {-(2. * cj->width[0] + max_dx), -(2. * cj->width[1] + max_dx),
-(2. * cj->width[2] + max_dx)};
const float pos_padded_j[3] = {-(2. * cj->width[0] + max_dx),
-(2. * cj->width[1] + max_dx),
-(2. * cj->width[2] + max_dx)};
const float h_padded_j = cj->parts[0].h;
for (int i = last_pj_align + 1; i < last_pj_align + 1 + VEC_SIZE; i++) {
......
......@@ -103,7 +103,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_density(
pj->density.rot_v[0] += facj * curlvr[0];
pj->density.rot_v[1] += facj * curlvr[1];
pj->density.rot_v[2] += facj * curlvr[2];
}
/**
......@@ -152,7 +151,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_density(
pi->density.rot_v[0] += fac * curlvr[0];
pi->density.rot_v[1] += fac * curlvr[1];
pi->density.rot_v[2] += fac * curlvr[2];
}
#ifdef WITH_VECTORIZATION
......@@ -482,7 +480,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_force(
/* Change in entropy */
pi->entropy_dt += mj * visc_term * dvdr;
pj->entropy_dt += mi * visc_term * dvdr;
}
/**
......@@ -572,7 +569,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_force(
/* Change in entropy */
pi->entropy_dt += mj * visc_term * dvdr;
}
#ifdef WITH_VECTORIZATION
......
......@@ -1063,7 +1063,7 @@ void DOPAIR2(struct runner *r, struct cell *ci, struct cell *cj, const int sid,
TIMER_TIC;
/* Get the cutoff shift. */
/* Get the cutoff shift. */
double rshift = 0.0;
for (int k = 0; k < 3; k++) rshift += shift[k] * runner_shift[sid][k];
......@@ -1524,8 +1524,8 @@ void DOPAIR2_BRANCH(struct runner *r, struct cell *ci, struct cell *cj) {
for (int pid = 0; pid < ci->count; pid++) {
const struct part *p = &ci->parts[sort_i[pid].i];
const float d = p->x[0] * runner_shift[sid][0] +
p->x[1] * runner_shift[sid][1] +
p->x[2] * runner_shift[sid][2];
p->x[1] * runner_shift[sid][1] +
p->x[2] * runner_shift[sid][2];
if (fabsf(d - sort_i[pid].d) - ci->dx_max_sort >
1.0e-4 * max(fabsf(d), ci->dx_max_sort_old))
error(
......@@ -1538,8 +1538,8 @@ void DOPAIR2_BRANCH(struct runner *r, struct cell *ci, struct cell *cj) {
for (int pjd = 0; pjd < cj->count; pjd++) {
const struct part *p = &cj->parts[sort_j[pjd].i];
const float d = p->x[0] * runner_shift[sid][0] +
p->x[1] * runner_shift[sid][1] +
p->x[2] * runner_shift[sid][2];
p->x[1] * runner_shift[sid][1] +
p->x[2] * runner_shift[sid][2];
if (fabsf(d - sort_j[pjd].d) - cj->dx_max_sort >
1.0e-4 * max(fabsf(d), cj->dx_max_sort_old))
error(
......
......@@ -363,11 +363,11 @@ populate_max_index_no_cache_force(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_raw, const double hj_max_raw,
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 double hi_max_raw,
const double hj_max_raw, 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 struct part *restrict parts_i = ci->parts;
......@@ -380,10 +380,12 @@ populate_max_index_no_cache_force(const struct cell *ci, const struct cell *cj,
* particle in cell j. */
first_pi = ci->count;
int active_id = first_pi - 1;
while (first_pi > 0 && sort_i[first_pi - 1].d + dx_max + max(hi_max, hj_max) > dj_min) {
while (first_pi > 0 &&
sort_i[first_pi - 1].d + dx_max + max(hi_max, hj_max) > dj_min) {
first_pi--;
/* Store the index of the particle if it is active. */
if (part_is_active_no_debug(&parts_i[sort_i[first_pi].i], max_active_bin)) active_id = first_pi;
if (part_is_active_no_debug(&parts_i[sort_i[first_pi].i], max_active_bin))
active_id = first_pi;
}
/* Set the first active pi in range of any particle in cell j. */
......@@ -396,8 +398,9 @@ populate_max_index_no_cache_force(const struct cell *ci, const struct cell *cj,
temp = 0;
const struct part *pi = &parts_i[sort_i[first_pi].i];
const float first_di =
sort_i[first_pi].d + max(pi->h, hj_max_raw) * kernel_gamma + dx_max - rshift;
const float first_di = sort_i[first_pi].d +
max(pi->h, hj_max_raw) * kernel_gamma + dx_max -
rshift;
/* Loop through particles in cell j until they are not in range of pi. */
while (temp < cj->count - 1 && first_di > sort_j[temp].d) temp++;
......@@ -409,10 +412,11 @@ populate_max_index_no_cache_force(const struct cell *ci, const struct cell *cj,
temp = max_index_i[i - 1];
pi = &parts_i[sort_i[i].i];
const float di = sort_i[i].d + max(pi->h, hj_max_raw) * kernel_gamma + dx_max - rshift;
const float di =
sort_i[i].d + max(pi->h, hj_max_raw) * kernel_gamma + dx_max - rshift;
while (temp < cj->count - 1 && di > sort_j[temp].d) temp++;
max_index_i[i] = temp;
}
} else {
......@@ -428,7 +432,8 @@ populate_max_index_no_cache_force(const struct cell *ci, const struct cell *cj,
sort_j[last_pj + 1].d - max(hj_max, hi_max) - dx_max < di_max) {
last_pj++;
/* Store the index of the particle if it is active. */
if (part_is_active_no_debug(&parts_j[sort_j[last_pj].i], max_active_bin)) active_id = last_pj;
if (part_is_active_no_debug(&parts_j[sort_j[last_pj].i], max_active_bin))
active_id = last_pj;
}
/* Set the last active pj in range of any particle in cell i. */
......@@ -441,12 +446,12 @@ populate_max_index_no_cache_force(const struct cell *ci, const struct cell *cj,
temp = ci->count - 1;
const struct part *pj = &parts_j[sort_j[last_pj].i];
const float last_dj =
sort_j[last_pj].d - dx_max - max(pj->h, hi_max_raw) * kernel_gamma + rshift;
const float last_dj = sort_j[last_pj].d - dx_max -
max(pj->h, hi_max_raw) * kernel_gamma + rshift;
/* Loop through particles in cell i until they are not in range of pj. */
while (temp > 0 && last_dj < sort_i[temp].d) temp--;
max_index_j[last_pj] = temp;
/* Populate max_index_j for remaining particles that are within range. */
......@@ -454,10 +459,11 @@ populate_max_index_no_cache_force(const struct cell *ci, const struct cell *cj,
temp = max_index_j[i + 1];
pj = &parts_j[sort_j[i].i];
const float dj = sort_j[i].d - dx_max - (max(pj->h, hi_max_raw) * kernel_gamma) + rshift;
const float dj = sort_j[i].d - dx_max -
(max(pj->h, hi_max_raw) * kernel_gamma) + rshift;
while (temp > 0 && dj < sort_i[temp].d) temp--;
max_index_j[i] = temp;
}
} else {
......@@ -748,7 +754,7 @@ __attribute__((always_inline)) INLINE void runner_doself2_force_vec(
/* Get a pointer to the ith particle. */
pi = &parts[pid];
/* Is the ith particle active? */
if (!part_is_active_no_debug(pi, max_active_bin)) continue;
......@@ -919,7 +925,6 @@ void runner_dopair1_density_vec(struct runner *r, struct cell *ci,
const struct entry *restrict sort_i = ci->sort[sid];
const struct entry *restrict sort_j = cj->sort[sid];
/* Get some other useful values. */
const int count_i = ci->count;
const int count_j = cj->count;
......@@ -1301,7 +1306,6 @@ void runner_dopair2_force_vec(struct runner *r, struct cell *ci,
const struct entry *restrict sort_i = ci->sort[sid];
const struct entry *restrict sort_j = cj->sort[sid];
/* Get some other useful values. */
const int count_i = ci->count;
const int count_j = cj->count;
......@@ -1345,7 +1349,7 @@ void runner_dopair2_force_vec(struct runner *r, struct cell *ci,
}
if (numActive == 0) return;
/* Get both particle caches from the runner and re-allocate
* them if they are not big enough for the cells. */
struct cache *restrict ci_cache = &r->ci_cache;
......@@ -1369,8 +1373,9 @@ void runner_dopair2_force_vec(struct runner *r, struct cell *ci,
/* 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_index_no_cache_force(ci, cj, sort_i, sort_j, dx_max, rshift,
hi_max_raw, hj_max_raw, hi_max, hj_max, di_max, dj_min, max_index_i,
max_index_j, &first_pi, &last_pj, max_active_bin);
hi_max_raw, hj_max_raw, hi_max, hj_max,
di_max, dj_min, max_index_i, max_index_j,
&first_pi, &last_pj, max_active_bin);
/* Limits of the outer loops. */
int first_pi_loop = first_pi;
......@@ -1380,7 +1385,7 @@ void runner_dopair2_force_vec(struct runner *r, struct cell *ci,
* to read into the cache. */
last_pj = max(last_pj, max_index_i[count_i - 1]);
first_pi = min(first_pi, max_index_j[0]);
/* Read the needed particles into the two caches. */
int first_pi_align = first_pi;
int last_pj_align = last_pj;
......
......@@ -41,6 +41,6 @@ void runner_dopair1_density_vec(struct runner *r, struct cell *restrict ci,
const double *shift);
void runner_dopair2_force_vec(struct runner *r, struct cell *restrict ci,
struct cell *restrict cj, const int sid,
const double *shift);
const double *shift);
#endif /* SWIFT_RUNNER_VEC_H */
......@@ -265,7 +265,7 @@ void pairs_all_force(struct runner *r, struct cell *ci, struct cell *cj) {
/* Skip inactive particles. */
if (!part_is_active(pi, e)) continue;
for (int j = 0; j < cj->count; ++j) {
pj = &cj->parts[j];
......@@ -298,7 +298,7 @@ void pairs_all_force(struct runner *r, struct cell *ci, struct cell *cj) {
/* Skip inactive particles. */
if (!part_is_active(pj, e)) continue;
for (int i = 0; i < ci->count; ++i) {
pi = &ci->parts[i];
......@@ -517,7 +517,6 @@ void shuffle_particles(struct part *parts, const int count) {
parts[i] = particle;
}
}
}
......
......@@ -199,16 +199,14 @@ void dump_particle_fields(char *fileName, struct cell *ci, struct cell *cj) {
for (int pid = 0; pid < ci->count; pid++) {
fprintf(file, "%6llu %13e %13e\n", ci->parts[pid].id,
ci->parts[pid].density.wcount,
ci->parts[pid].force.h_dt);
ci->parts[pid].density.wcount, ci->parts[pid].force.h_dt);
}
fprintf(file, "# cj --------------------------------------------\n");
for (int pjd = 0; pjd < cj->count; pjd++) {
fprintf(file, "%6llu %13e %13e\n", cj->parts[pjd].id,
cj->parts[pjd].density.wcount,
cj->parts[pjd].force.h_dt);
cj->parts[pjd].density.wcount, cj->parts[pjd].force.h_dt);
}
fclose(file);
......@@ -216,12 +214,13 @@ void dump_particle_fields(char *fileName, struct cell *ci, struct cell *cj) {
/* Just a forward declaration... */
void runner_dopair1_density(struct runner *r, struct cell *ci, struct cell *cj);
void runner_dopair2_force_vec(struct runner *r, struct cell *ci, struct cell *cj);
void runner_dopair2_force_vec(struct runner *r, struct cell *ci,
struct cell *cj);
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_dopair2_branch_force(struct runner *r, struct cell *ci,
struct cell *cj);
struct cell *cj);
/**
* @brief Computes the pair interactions of two cells using SWIFT and a brute
......@@ -229,7 +228,9 @@ void runner_dopair2_branch_force(struct runner *r, struct cell *ci,
*/
void test_pair_interactions(struct runner *runner, struct cell **ci,
struct cell **cj, char *swiftOutputFileName,
char *bruteForceOutputFileName, interaction_func serial_interaction, interaction_func vec_interaction) {
char *bruteForceOutputFileName,
interaction_func serial_interaction,
interaction_func vec_interaction) {
runner_do_sort(runner, *ci, 0x1FFF, 0, 0);
runner_do_sort(runner, *cj, 0x1FFF, 0, 0);
......@@ -267,24 +268,22 @@ void test_pair_interactions(struct runner *runner, struct cell **ci,
/**
* @brief Computes the pair interactions of two cells in various configurations.
*/
void test_all_pair_interactions(struct runner *runner, double *offset2,
size_t particles, double size, double h,
double rho, long long *partId,
double perturbation, double h_pert,
char *swiftOutputFileName,
char *bruteForceOutputFileName, interaction_func serial_interaction, interaction_func vec_interaction) {
void test_all_pair_interactions(
struct runner *runner, double *offset2, size_t particles, double size,
double h, double rho, long long *partId, double perturbation, double h_pert,
char *swiftOutputFileName, char *bruteForceOutputFileName,
interaction_func serial_interaction, interaction_func vec_interaction) {
double offset1[3] = {0, 0, 0};
struct cell *ci, *cj;
/* Only one particle in each cell. */
ci = make_cell(1, offset1, size, h, rho, partId, perturbation, h_pert,
1.);
cj = make_cell(1, offset2, size, h, rho, partId, perturbation, h_pert,
1.);
ci = make_cell(1, offset1, size, h, rho, partId, perturbation, h_pert, 1.);
cj = make_cell(1, offset2, size, h, rho, partId, perturbation, h_pert, 1.);
test_pair_interactions(runner, &ci, &cj, swiftOutputFileName,
bruteForceOutputFileName, serial_interaction, vec_interaction);
bruteForceOutputFileName, serial_interaction,
vec_interaction);
clean_up(ci);
clean_up(cj);
......@@ -296,7 +295,8 @@ void test_all_pair_interactions(struct runner *runner, double *offset2,
1.);
test_pair_interactions(runner, &ci, &cj, swiftOutputFileName,
bruteForceOutputFileName, serial_interaction, vec_interaction);
bruteForceOutputFileName, serial_interaction,
vec_interaction);
clean_up(ci);
clean_up(cj);
......@@ -308,7 +308,8 @@ void test_all_pair_interactions(struct runner *runner, double *offset2,
0.5);
test_pair_interactions(runner, &ci, &cj, swiftOutputFileName,
bruteForceOutputFileName, serial_interaction, vec_interaction);
bruteForceOutputFileName, serial_interaction,
vec_interaction);
clean_up(ci);
clean_up(cj);
......@@ -320,7 +321,8 @@ void test_all_pair_interactions(struct runner *runner, double *offset2,
0.);
test_pair_interactions(runner, &ci, &cj, swiftOutputFileName,
bruteForceOutputFileName, serial_interaction, vec_interaction);
bruteForceOutputFileName, serial_interaction,
vec_interaction);
clean_up(ci);
clean_up(cj);
......@@ -332,7 +334,8 @@ void test_all_pair_interactions(struct runner *runner, double *offset2,
0.1);
test_pair_interactions(runner, &ci, &cj, swiftOutputFileName,
bruteForceOutputFileName, serial_interaction, vec_interaction);
bruteForceOutputFileName, serial_interaction,
vec_interaction);
clean_up(ci);
clean_up(cj);
......@@ -344,7 +347,8 @@ void test_all_pair_interactions(struct runner *runner, double *offset2,
0.);
test_pair_interactions(runner, &ci, &cj, swiftOutputFileName,
bruteForceOutputFileName, serial_interaction, vec_interaction);
bruteForceOutputFileName, serial_interaction,
vec_interaction);
clean_up(ci);
clean_up(cj);
......@@ -356,7 +360,8 @@ void test_all_pair_interactions(struct runner *runner, double *offset2,
1.0);
test_pair_interactions(runner, &ci, &cj, swiftOutputFileName,
bruteForceOutputFileName, serial_interaction, vec_interaction);
bruteForceOutputFileName, serial_interaction,
vec_interaction);
clean_up(ci);
clean_up(cj);
......@@ -366,7 +371,8 @@ void test_all_pair_interactions(struct runner *runner, double *offset2,
cj = make_cell(2, offset2, size, h, rho, partId, perturbation, h_pert, 1.0);
test_pair_interactions(runner, &ci, &cj, swiftOutputFileName,
bruteForceOutputFileName, serial_interaction, vec_interaction);
bruteForceOutputFileName, serial_interaction,
vec_interaction);
clean_up(ci);
clean_up(cj);
......@@ -376,7 +382,8 @@ void test_all_pair_interactions(struct runner *runner, double *offset2,
cj = make_cell(3, offset2, size, h, rho, partId, perturbation, h_pert, 0.75);
test_pair_interactions(runner, &ci, &cj, swiftOutputFileName,
bruteForceOutputFileName, serial_interaction, vec_interaction);
bruteForceOutputFileName, serial_interaction,
vec_interaction);
clean_up(ci);
clean_up(cj);
......@@ -388,7 +395,8 @@ void test_all_pair_interactions(struct runner *runner, double *offset2,
0.);
test_pair_interactions(runner, &ci, &cj, swiftOutputFileName,
bruteForceOutputFileName, serial_interaction, vec_interaction);
bruteForceOutputFileName, serial_interaction,
vec_interaction);
clean_up(ci);
clean_up(cj);
......@@ -400,7 +408,8 @@ void test_all_pair_interactions(struct runner *runner, double *offset2,
0.5);
test_pair_interactions(runner, &ci, &cj, swiftOutputFileName,
bruteForceOutputFileName, serial_interaction, vec_interaction);
bruteForceOutputFileName, serial_interaction,
vec_interaction);
/* Clean things to make the sanitizer happy ... */
clean_up(ci);
......@@ -524,7 +533,8 @@ int main(int argc, char *argv[]) {
/* Test a pair of cells face-on. */
test_all_pair_interactions(runner, offset, particles, size, h, rho, &partId,
perturbation, h_pert, swiftOutputFileName,
bruteForceOutputFileName, serial_inter_func, vec_inter_func);
bruteForceOutputFileName, serial_inter_func,
vec_inter_func);
/* Test a pair of cells edge-on. */
offset[0] = 1.;
......@@ -532,7 +542,8 @@ int main(int argc, char *argv[]) {
offset[2] = 0.;
test_all_pair_interactions(runner, offset, particles, size, h, rho, &partId,
perturbation, h_pert, swiftOutputFileName,
bruteForceOutputFileName, serial_inter_func, vec_inter_func);
bruteForceOutputFileName, serial_inter_func,
vec_inter_func);
/* Test a pair of cells corner-on. */
offset[0] = 1.;
......@@ -540,28 +551,31 @@ int main(int argc, char *argv[]) {
offset[2] = 1.;
test_all_pair_interactions(runner, offset, particles, size, h, rho, &partId,
perturbation, h_pert, swiftOutputFileName,
bruteForceOutputFileName, serial_inter_func, vec_inter_func);
bruteForceOutputFileName, serial_inter_func,
vec_inter_func);
/* Re-assign function pointers. */
serial_inter_func = &pairs_all_force;
vec_inter_func = &runner_dopair2_branch_force;
/* Create new output file names. */
sprintf(swiftOutputFileName, "swift_dopair2_force_%s.dat", outputFileNameExtension);
sprintf(swiftOutputFileName, "swift_dopair2_force_%s.dat",
outputFileNameExtension);
sprintf(bruteForceOutputFileName, "brute_force_dopair2_%s.dat",
outputFileNameExtension);
/* Delete files if they already exist. */
remove(swiftOutputFileName);
remove(bruteForceOutputFileName);
/* Test a pair of cells face-on. */
offset[0] = 1.;
offset[1] = 0.;
offset[2] = 0.;
test_all_pair_interactions(runner, offset, particles, size, h, rho, &partId,
perturbation, h_pert, swiftOutputFileName,
bruteForceOutputFileName, serial_inter_func, vec_inter_func);
bruteForceOutputFileName, serial_inter_func,
vec_inter_func);
/* Test a pair of cells edge-on. */
offset[0] = 1.;
......@@ -569,7 +583,8 @@ int main(int argc, char *argv[]) {
offset[2] = 0.;
test_all_pair_interactions(runner, offset, particles, size, h, rho, &partId,
perturbation, h_pert, swiftOutputFileName,
bruteForceOutputFileName, serial_inter_func, vec_inter_func);
bruteForceOutputFileName, serial_inter_func,
vec_inter_func);
/* Test a pair of cells corner-on. */
offset[0] = 1.;
......@@ -577,6 +592,7 @@ int main(int argc, char *argv[]) {
offset[2] = 1.;
test_all_pair_interactions(runner, offset, particles, size, h, rho, &partId,
perturbation, h_pert, swiftOutputFileName,
bruteForceOutputFileName, serial_inter_func, vec_inter_func);
bruteForceOutputFileName, serial_inter_func,
vec_inter_func);
return 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