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

Apply the same change to the max operation taking place in the timestep limiter task

parent 449346aa
No related branches found
No related tags found
1 merge request!1048Atomic gravity and time-step limiter
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
/* Local includes */ /* Local includes */
#include "atomic.h" #include "atomic.h"
#include "minmax.h"
/** /**
* @file accumulate.h * @file accumulate.h
...@@ -144,4 +145,64 @@ __attribute__((always_inline)) INLINE static void accumulate_inc_ll( ...@@ -144,4 +145,64 @@ __attribute__((always_inline)) INLINE static void accumulate_inc_ll(
#endif #endif
} }
/**
* @brief Compute the max of x and the value storedd at the location address
* and store the value at the address (int8_t version).
*
* When SWIFT_TASKS_WITHOUT_ATOMICS is *not* defined this function uses an
* atomic operation.
*
* @param address The address to update.
* @param x The value to max against *address.
*/
__attribute__((always_inline)) INLINE static void accumulate_max_c(
volatile int8_t *const address, const int8_t x) {
#ifdef SWIFT_TASKS_WITHOUT_ATOMICS
*address = max(*address, x);
#else
atomic_max_c(address, x);
#endif
}
/**
* @brief Compute the max of x and the value storedd at the location address
* and store the value at the address (int version).
*
* When SWIFT_TASKS_WITHOUT_ATOMICS is *not* defined this function uses an
* atomic operation.
*
* @param address The address to update.
* @param x The value to max against *address.
*/
__attribute__((always_inline)) INLINE static void accumulate_max_i(
volatile int *const address, const int x) {
#ifdef SWIFT_TASKS_WITHOUT_ATOMICS
*address = max(*address, x);
#else
atomic_max(address, x);
#endif
}
/**
* @brief Compute the max of x and the value storedd at the location address
* and store the value at the address (float version).
*
* When SWIFT_TASKS_WITHOUT_ATOMICS is *not* defined this function uses an
* atomic operation.
*
* @param address The address to update.
* @param x The value to max against *address.
*/
__attribute__((always_inline)) INLINE static void accumulate_max_f(
volatile float *const address, const float x) {
#ifdef SWIFT_TASKS_WITHOUT_ATOMICS
*address = max(*address, x);
#else
atomic_max_f(address, x);
#endif
}
#endif /* SWIFT_ACCUMULATE_H */ #endif /* SWIFT_ACCUMULATE_H */
...@@ -87,12 +87,8 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_limiter( ...@@ -87,12 +87,8 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_limiter(
/* Wake up the neighbour? */ /* Wake up the neighbour? */
if (pj->time_bin > pi->time_bin + time_bin_neighbour_max_delta_bin) { if (pj->time_bin > pi->time_bin + time_bin_neighbour_max_delta_bin) {
/* Store the smallest time bin that woke up this particle */ /* Store the smallest time bin that woke up this particle */
#ifdef SWIFT_TASKS_WITHOUT_ATOMICS accumulate_max_c(&pj->limiter_data.wakeup, -pi->time_bin);
pj->limiter_data.wakeup = max(pj->limiter_data.wakeup, -pi->time_bin);
#else
atomic_max_c(&pj->limiter_data.wakeup, -pi->time_bin);
#endif
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment