Skip to content
Snippets Groups Projects
Commit dc1be8ad authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Do not use the accumulate_add functions

parent 09b63358
Branches
Tags
2 merge requests!1086Gravity interactions locked at the cell level, not particle level,!1077Improved multipole acceptance criterion (MAC)
......@@ -23,7 +23,6 @@
#include <float.h>
/* Local includes. */
#include "accumulate.h"
#include "cosmology.h"
#include "error.h"
#include "gravity_properties.h"
......@@ -62,7 +61,7 @@ __attribute__((always_inline)) INLINE static float gravity_get_softening(
__attribute__((always_inline)) INLINE static void
gravity_add_comoving_potential(struct gpart* restrict gp, float pot) {
accumulate_add_f(&gp->potential, pot);
gp->potential += pot;
}
/**
......
......@@ -23,7 +23,6 @@
#include <float.h>
/* Local includes. */
#include "accumulate.h"
#include "cosmology.h"
#include "gravity_properties.h"
#include "kernel_gravity.h"
......@@ -64,7 +63,7 @@ __attribute__((always_inline)) INLINE static float gravity_get_softening(
__attribute__((always_inline)) INLINE static void
gravity_add_comoving_potential(struct gpart* restrict gp, float pot) {
accumulate_add_f(&gp->potential, pot);
gp->potential += pot;
}
/**
......
......@@ -490,9 +490,9 @@ INLINE static void gravity_cache_write_back(const struct gravity_cache *c,
#endif
for (int i = 0; i < gcount; ++i) {
if (active[i]) {
accumulate_add_f(&gparts[i].a_grav[0], a_x[i]);
accumulate_add_f(&gparts[i].a_grav[1], a_y[i]);
accumulate_add_f(&gparts[i].a_grav[2], a_z[i]);
gparts[i].a_grav[0] += a_x[i];
gparts[i].a_grav[1] += a_y[i];
gparts[i].a_grav[2] += a_z[i];
gravity_add_comoving_potential(&gparts[i], pot[i]);
}
}
......
......@@ -28,7 +28,6 @@
#include "mesh_gravity.h"
/* Local includes. */
#include "accumulate.h"
#include "active.h"
#include "debug.h"
#include "engine.h"
......@@ -336,9 +335,9 @@ void mesh_to_gparts_CIC(struct gpart* gp, const double* pot, const int N,
/* ---- */
/* Store things back */
accumulate_add_f(&gp->a_grav[0], fac * a[0]);
accumulate_add_f(&gp->a_grav[1], fac * a[1]);
accumulate_add_f(&gp->a_grav[2], fac * a[2]);
gp->a_grav[0] += fac * a[0];
gp->a_grav[1] += fac * a[1];
gp->a_grav[2] += fac * a[2];
gravity_add_comoving_potential(gp, p);
#ifdef SWIFT_GRAVITY_FORCE_CHECKS
gp->potential_PM = p;
......
......@@ -2993,15 +2993,15 @@ __attribute__((nonnull)) INLINE static void gravity_L2P(
#endif
/* Update the particle */
accumulate_add_f(&gp->a_grav[0], a_grav[0]);
accumulate_add_f(&gp->a_grav[1], a_grav[1]);
accumulate_add_f(&gp->a_grav[2], a_grav[2]);
gp->a_grav[0] += a_grav[0];
gp->a_grav[1] += a_grav[1];
gp->a_grav[2] += a_grav[2];
gravity_add_comoving_potential(gp, pot);
#ifdef SWIFT_GRAVITY_FORCE_CHECKS
accumulate_add_f(&gp->a_grav_m2l[0], a_grav[0]);
accumulate_add_f(&gp->a_grav_m2l[1], a_grav[1]);
accumulate_add_f(&gp->a_grav_m2l[2], a_grav[2]);
gp->a_grav_m2l[0] += a_grav[0];
gp->a_grav_m2l[1] += a_grav[1];
gp->a_grav_m2l[2] += a_grav[2];
#endif
}
......
......@@ -155,6 +155,10 @@ static INLINE void runner_dopair_grav_pp_full_no_cache(
const int gcount_padded_i = gcount_i - (gcount_i % VEC_SIZE) + VEC_SIZE;
gravity_cache_zero_output(cache_i, gcount_padded_i);
#ifdef SWIFT_DEBUG_CHECKS
if (ci->split) error("Using function above leaf level!");
#endif
/* Loop over sink particles */
for (int i = 0; i < gcount_i; ++i) {
......@@ -219,9 +223,9 @@ static INLINE void runner_dopair_grav_pp_full_no_cache(
/* Update the M2P interaction counter and forces. */
accumulate_add_ll(&gparts_i[i].num_interacted_m2p,
multi_j->m_pole.num_gpart);
accumulate_add_f(&gparts_i[i].a_grav_m2p[0], f_x);
accumulate_add_f(&gparts_i[i].a_grav_m2p[1], f_y);
accumulate_add_f(&gparts_i[i].a_grav_m2p[2], f_z);
gparts_i[i].a_grav_m2p[0] += f_x;
gparts_i[i].a_grav_m2p[1] += f_y;
gparts_i[i].a_grav_m2p[2] += f_z;
#endif
} else {
......@@ -283,9 +287,9 @@ static INLINE void runner_dopair_grav_pp_full_no_cache(
#ifdef SWIFT_GRAVITY_FORCE_CHECKS
/* Update the p2p interaction counter */
accumulate_inc_ll(&gparts_i[i].num_interacted_p2p);
accumulate_add_f(&gparts_i[i].a_grav_p2p[0], a_x);
accumulate_add_f(&gparts_i[i].a_grav_p2p[1], a_y);
accumulate_add_f(&gparts_i[i].a_grav_p2p[2], a_z);
gparts_i[i].a_grav_p2p[0] += a_x;
gparts_i[i].a_grav_p2p[1] += a_y;
gparts_i[i].a_grav_p2p[2] += a_z;
#endif
}
}
......@@ -312,6 +316,8 @@ static INLINE void runner_dopair_grav_pp_truncated_no_cache(
#ifdef SWIFT_DEBUG_CHECKS
if (!e->s->periodic)
error("Calling truncated PP function in non-periodic setup.");
if (ci->split) error("Using function above leaf level!");
#endif
const float r_s_inv = grav_props->r_s_inv;
......@@ -389,9 +395,9 @@ static INLINE void runner_dopair_grav_pp_truncated_no_cache(
/* Update the M2P interaction counter and forces. */
accumulate_add_ll(&gparts_i[i].num_interacted_m2p,
multi_j->m_pole.num_gpart);
accumulate_add_f(&gparts_i[i].a_grav_m2p[0], f_x);
accumulate_add_f(&gparts_i[i].a_grav_m2p[1], f_y);
accumulate_add_f(&gparts_i[i].a_grav_m2p[2], f_z);
gparts_i[i].a_grav_m2p[0] += f_x;
gparts_i[i].a_grav_m2p[1] += f_y;
gparts_i[i].a_grav_m2p[2] += f_z;
#endif
} else {
......@@ -458,9 +464,9 @@ static INLINE void runner_dopair_grav_pp_truncated_no_cache(
#ifdef SWIFT_GRAVITY_FORCE_CHECKS
/* Update the p2p interaction counter */
accumulate_inc_ll(&gparts_i[i].num_interacted_p2p);
accumulate_add_f(&gparts_i[i].a_grav_p2p[0], a_x);
accumulate_add_f(&gparts_i[i].a_grav_p2p[1], a_y);
accumulate_add_f(&gparts_i[i].a_grav_p2p[2], a_z);
gparts_i[i].a_grav_p2p[0] += a_x;
gparts_i[i].a_grav_p2p[1] += a_y;
gparts_i[i].a_grav_p2p[2] += a_z;
#endif
}
}
......@@ -621,9 +627,9 @@ static INLINE void runner_dopair_grav_pp_full(
ci_cache->pot[pid] += pot;
#ifdef SWIFT_GRAVITY_FORCE_CHECKS
accumulate_add_f(&gparts_i[pid].a_grav_p2p[0], a_x);
accumulate_add_f(&gparts_i[pid].a_grav_p2p[1], a_y);
accumulate_add_f(&gparts_i[pid].a_grav_p2p[2], a_z);
gparts_i[pid].a_grav_p2p[0] += a_x;
gparts_i[pid].a_grav_p2p[1] += a_y;
gparts_i[pid].a_grav_p2p[2] += a_z;
#endif
}
}
......@@ -777,9 +783,9 @@ static INLINE void runner_dopair_grav_pp_truncated(
ci_cache->pot[pid] += pot;
#ifdef SWIFT_GRAVITY_FORCE_CHECKS
accumulate_add_f(&gparts_i[pid].a_grav_p2p[0], a_x);
accumulate_add_f(&gparts_i[pid].a_grav_p2p[1], a_y);
accumulate_add_f(&gparts_i[pid].a_grav_p2p[2], a_z);
gparts_i[pid].a_grav_p2p[0] += a_x;
gparts_i[pid].a_grav_p2p[1] += a_y;
gparts_i[pid].a_grav_p2p[2] += a_z;
#endif
}
}
......@@ -910,9 +916,9 @@ static INLINE void runner_dopair_grav_pm_full(
if (pid < gcount_i) {
accumulate_add_ll(&gparts_i[pid].num_interacted_m2p,
cj->grav.multipole->m_pole.num_gpart);
accumulate_add_f(&gparts_i[pid].a_grav_m2p[0], f_x);
accumulate_add_f(&gparts_i[pid].a_grav_m2p[1], f_y);
accumulate_add_f(&gparts_i[pid].a_grav_m2p[2], f_z);
gparts_i[pid].a_grav_m2p[0] += f_x;
gparts_i[pid].a_grav_m2p[1] += f_y;
gparts_i[pid].a_grav_m2p[2] += f_z;
}
#endif
}
......@@ -1049,9 +1055,9 @@ static INLINE void runner_dopair_grav_pm_truncated(
if (pid < gcount_i) {
accumulate_add_ll(&gparts_i[pid].num_interacted_m2p,
cj->grav.multipole->m_pole.num_gpart);
accumulate_add_f(&gparts_i[pid].a_grav_m2p[0], f_x);
accumulate_add_f(&gparts_i[pid].a_grav_m2p[1], f_y);
accumulate_add_f(&gparts_i[pid].a_grav_m2p[2], f_z);
gparts_i[pid].a_grav_m2p[0] += f_x;
gparts_i[pid].a_grav_m2p[1] += f_y;
gparts_i[pid].a_grav_m2p[2] += f_z;
}
#endif
}
......@@ -1459,9 +1465,9 @@ static INLINE void runner_doself_grav_pp_full(
ci_cache->pot[pid] += pot;
#ifdef SWIFT_GRAVITY_FORCE_CHECKS
accumulate_add_f(&gparts[pid].a_grav_p2p[0], a_x);
accumulate_add_f(&gparts[pid].a_grav_p2p[1], a_y);
accumulate_add_f(&gparts[pid].a_grav_p2p[2], a_z);
gparts[pid].a_grav_p2p[0] += a_x;
gparts[pid].a_grav_p2p[1] += a_y;
gparts[pid].a_grav_p2p[2] += a_z;
#endif
}
}
......@@ -1598,9 +1604,9 @@ static INLINE void runner_doself_grav_pp_truncated(
ci_cache->pot[pid] += pot;
#ifdef SWIFT_GRAVITY_FORCE_CHECKS
accumulate_add_f(&gparts[pid].a_grav_p2p[0], a_x);
accumulate_add_f(&gparts[pid].a_grav_p2p[1], a_y);
accumulate_add_f(&gparts[pid].a_grav_p2p[2], a_z);
gparts[pid].a_grav_p2p[0] += a_x;
gparts[pid].a_grav_p2p[1] += a_y;
gparts[pid].a_grav_p2p[2] += a_z;
#endif
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment