Commit b48cf575 authored by Pedro Gonnet's avatar Pedro Gonnet
Browse files

Merge remote-tracking branch 'origin' into tasks_cleanup

Conflicts:
	src/engine.c
	src/scheduler.c
	src/space.c
	src/task.c
parents 98f8fde9 35b13d49
...@@ -20,11 +20,19 @@ ...@@ -20,11 +20,19 @@
* *
******************************************************************************/ ******************************************************************************/
/* Config parameters. */
#include "../config.h"
/* Some standard headers. */
#include <stdio.h> #include <stdio.h>
/* This object's header. */
#include "debug.h"
/* Local includes. */
#include "config.h" #include "config.h"
#include "const.h" #include "const.h"
#include "debug.h" #include "inline.h"
#include "part.h" #include "part.h"
/* Import the right hydro definition */ /* Import the right hydro definition */
...@@ -51,7 +59,6 @@ ...@@ -51,7 +59,6 @@
* *
* (Should be used for debugging only as it runs in O(N).) * (Should be used for debugging only as it runs in O(N).)
*/ */
void printParticle(struct part *parts, struct xpart *xparts, long long int id, void printParticle(struct part *parts, struct xpart *xparts, long long int id,
size_t N) { size_t N) {
...@@ -69,6 +76,17 @@ void printParticle(struct part *parts, struct xpart *xparts, long long int id, ...@@ -69,6 +76,17 @@ void printParticle(struct part *parts, struct xpart *xparts, long long int id,
if (!found) printf("## Particles[???] id=%lld not found\n", id); if (!found) printf("## Particles[???] id=%lld not found\n", id);
} }
/**
* @brief Looks for the g-particle with the given id and prints its information
* to
* the standard output.
*
* @param gparts The array of g-particles.
* @param id The id too look for.
* @param N The size of the array of g-particles.
*
* (Should be used for debugging only as it runs in O(N).)
*/
void printgParticle(struct gpart *gparts, long long int id, size_t N) { void printgParticle(struct gpart *gparts, long long int id, size_t N) {
int found = 0; int found = 0;
...@@ -95,9 +113,7 @@ void printgParticle(struct gpart *gparts, long long int id, size_t N) { ...@@ -95,9 +113,7 @@ void printgParticle(struct gpart *gparts, long long int id, size_t N) {
* *
* @param p The particle to print * @param p The particle to print
* @param xp The extended data ot the particle to print * @param xp The extended data ot the particle to print
*
*/ */
void printParticle_single(struct part *p, struct xpart *xp) { void printParticle_single(struct part *p, struct xpart *xp) {
printf("## Particle: id=%lld ", p->id); printf("## Particle: id=%lld ", p->id);
...@@ -105,6 +121,18 @@ void printParticle_single(struct part *p, struct xpart *xp) { ...@@ -105,6 +121,18 @@ void printParticle_single(struct part *p, struct xpart *xp) {
printf("\n"); printf("\n");
} }
/**
* @brief Prints the details of a given particle to stdout
*
* @param gp The g-particle to print
*/
void printgParticle_single(struct gpart *gp) {
printf("## g-Particle: id=%lld ", gp->id);
gravity_debug_particle(gp);
printf("\n");
}
#ifdef HAVE_METIS #ifdef HAVE_METIS
/** /**
......
...@@ -19,14 +19,15 @@ ...@@ -19,14 +19,15 @@
#ifndef SWIFT_DEBUG_H #ifndef SWIFT_DEBUG_H
#define SWIFT_DEBUG_H #define SWIFT_DEBUG_H
/* Includes. */ struct part;
#include "cell.h" struct gpart;
#include "part.h" struct xpart;
void printParticle(struct part *parts, struct xpart *xparts, long long int id, void printParticle(struct part *parts, struct xpart *xparts, long long int id,
size_t N); size_t N);
void printgParticle(struct gpart *parts, long long int id, size_t N); void printgParticle(struct gpart *parts, long long int id, size_t N);
void printParticle_single(struct part *p, struct xpart *xp); void printParticle_single(struct part *p, struct xpart *xp);
void printgParticle_single(struct gpart *gp);
#ifdef HAVE_METIS #ifdef HAVE_METIS
#include "metis.h" #include "metis.h"
......
This diff is collapsed.
...@@ -37,13 +37,10 @@ ...@@ -37,13 +37,10 @@
#include <stdio.h> #include <stdio.h>
/* Includes. */ /* Includes. */
#include "hydro_properties.h" #include "clocks.h"
#include "lock.h"
#include "parser.h" #include "parser.h"
#include "partition.h" #include "partition.h"
#include "physical_constants.h"
#include "potentials.h" #include "potentials.h"
#include "proxy.h"
#include "runner.h" #include "runner.h"
#include "scheduler.h" #include "scheduler.h"
#include "space.h" #include "space.h"
......
...@@ -20,12 +20,6 @@ ...@@ -20,12 +20,6 @@
#ifndef SWIFT_RUNNER_IACT_H #ifndef SWIFT_RUNNER_IACT_H
#define SWIFT_RUNNER_IACT_H #define SWIFT_RUNNER_IACT_H
/* Includes. */
#include "const.h"
#include "kernel_hydro.h"
#include "part.h"
#include "vector.h"
/** /**
* @brief SPH interaction functions following the Gadget-2 version of SPH. * @brief SPH interaction functions following the Gadget-2 version of SPH.
* *
...@@ -44,7 +38,6 @@ ...@@ -44,7 +38,6 @@
/** /**
* @brief Density loop * @brief Density loop
*/ */
__attribute__((always_inline)) INLINE static void runner_iact_density( __attribute__((always_inline)) INLINE static void runner_iact_density(
float r2, float *dx, float hi, float hj, struct part *pi, struct part *pj) { float r2, float *dx, float hi, float hj, struct part *pi, struct part *pj) {
...@@ -218,7 +211,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_vec_density( ...@@ -218,7 +211,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_vec_density(
/** /**
* @brief Density loop (non-symmetric version) * @brief Density loop (non-symmetric version)
*/ */
__attribute__((always_inline)) INLINE static void runner_iact_nonsym_density( __attribute__((always_inline)) INLINE static void runner_iact_nonsym_density(
float r2, float *dx, float hi, float hj, struct part *pi, struct part *pj) { float r2, float *dx, float hi, float hj, struct part *pi, struct part *pj) {
...@@ -267,7 +259,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_density( ...@@ -267,7 +259,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_density(
/** /**
* @brief Density loop (non-symmetric vectorized version) * @brief Density loop (non-symmetric vectorized version)
*/ */
__attribute__((always_inline)) INLINE static void __attribute__((always_inline)) INLINE static void
runner_iact_nonsym_vec_density(float *R2, float *Dx, float *Hi, float *Hj, runner_iact_nonsym_vec_density(float *R2, float *Dx, float *Hi, float *Hj,
struct part **pi, struct part **pj) { struct part **pi, struct part **pj) {
...@@ -360,7 +351,6 @@ runner_iact_nonsym_vec_density(float *R2, float *Dx, float *Hi, float *Hj, ...@@ -360,7 +351,6 @@ runner_iact_nonsym_vec_density(float *R2, float *Dx, float *Hi, float *Hj,
/** /**
* @brief Force loop * @brief Force loop
*/ */
__attribute__((always_inline)) INLINE static void runner_iact_force( __attribute__((always_inline)) INLINE static void runner_iact_force(
float r2, float *dx, float hi, float hj, struct part *pi, struct part *pj) { float r2, float *dx, float hi, float hj, struct part *pi, struct part *pj) {
...@@ -456,7 +446,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_force( ...@@ -456,7 +446,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_force(
/** /**
* @brief Force loop (Vectorized version) * @brief Force loop (Vectorized version)
*/ */
__attribute__((always_inline)) INLINE static void runner_iact_vec_force( __attribute__((always_inline)) INLINE static void runner_iact_vec_force(
float *R2, float *Dx, float *Hi, float *Hj, struct part **pi, float *R2, float *Dx, float *Hi, float *Hj, struct part **pi,
struct part **pj) { struct part **pj) {
...@@ -675,7 +664,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_vec_force( ...@@ -675,7 +664,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_vec_force(
/** /**
* @brief Force loop (non-symmetric version) * @brief Force loop (non-symmetric version)
*/ */
__attribute__((always_inline)) INLINE static void runner_iact_nonsym_force( __attribute__((always_inline)) INLINE static void runner_iact_nonsym_force(
float r2, float *dx, float hi, float hj, struct part *pi, struct part *pj) { float r2, float *dx, float hi, float hj, struct part *pi, struct part *pj) {
...@@ -766,7 +754,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_force( ...@@ -766,7 +754,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_force(
/** /**
* @brief Force loop (Vectorized non-symmetric version) * @brief Force loop (Vectorized non-symmetric version)
*/ */
__attribute__((always_inline)) INLINE static void runner_iact_nonsym_vec_force( __attribute__((always_inline)) INLINE static void runner_iact_nonsym_vec_force(
float *R2, float *Dx, float *Hi, float *Hj, struct part **pi, float *R2, float *Dx, float *Hi, float *Hj, struct part **pi,
struct part **pj) { struct part **pj) {
......
...@@ -20,12 +20,6 @@ ...@@ -20,12 +20,6 @@
#ifndef SWIFT_RUNNER_IACT_LEGACY_H #ifndef SWIFT_RUNNER_IACT_LEGACY_H
#define SWIFT_RUNNER_IACT_LEGACY_H #define SWIFT_RUNNER_IACT_LEGACY_H
/* Includes. */
#include "const.h"
#include "kernel_hydro.h"
#include "part.h"
#include "vector.h"
/** /**
* @brief SPH interaction functions following the Gadget-2 version of SPH. * @brief SPH interaction functions following the Gadget-2 version of SPH.
* *
...@@ -42,7 +36,6 @@ ...@@ -42,7 +36,6 @@
/** /**
* @brief Density loop * @brief Density loop
*/ */
__attribute__((always_inline)) INLINE static void runner_iact_density( __attribute__((always_inline)) INLINE static void runner_iact_density(
float r2, float *dx, float hi, float hj, struct part *pi, struct part *pj) { float r2, float *dx, float hi, float hj, struct part *pi, struct part *pj) {
...@@ -113,7 +106,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_density( ...@@ -113,7 +106,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_density(
/** /**
* @brief Density loop (non-symmetric version) * @brief Density loop (non-symmetric version)
*/ */
__attribute__((always_inline)) INLINE static void runner_iact_nonsym_density( __attribute__((always_inline)) INLINE static void runner_iact_nonsym_density(
float r2, float *dx, float hi, float hj, struct part *pi, struct part *pj) { float r2, float *dx, float hi, float hj, struct part *pi, struct part *pj) {
...@@ -162,7 +154,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_density( ...@@ -162,7 +154,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_density(
/** /**
* @brief Force loop * @brief Force loop
*/ */
__attribute__((always_inline)) INLINE static void runner_iact_force( __attribute__((always_inline)) INLINE static void runner_iact_force(
float r2, float *dx, float hi, float hj, struct part *pi, struct part *pj) { float r2, float *dx, float hi, float hj, struct part *pi, struct part *pj) {
...@@ -260,7 +251,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_force( ...@@ -260,7 +251,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_force(
/** /**
* @brief Force loop (non-symmetric version) * @brief Force loop (non-symmetric version)
*/ */
__attribute__((always_inline)) INLINE static void runner_iact_nonsym_force( __attribute__((always_inline)) INLINE static void runner_iact_nonsym_force(
float r2, float *dx, float hi, float hj, struct part *pi, struct part *pj) { float r2, float *dx, float hi, float hj, struct part *pi, struct part *pj) {
......
...@@ -19,12 +19,6 @@ ...@@ -19,12 +19,6 @@
#ifndef SWIFT_RUNNER_IACT_MINIMAL_H #ifndef SWIFT_RUNNER_IACT_MINIMAL_H
#define SWIFT_RUNNER_IACT_MINIMAL_H #define SWIFT_RUNNER_IACT_MINIMAL_H
/* Includes. */
#include "const.h"
#include "kernel_hydro.h"
#include "part.h"
#include "vector.h"
/** /**
* @brief Minimal conservative implementation of SPH * @brief Minimal conservative implementation of SPH
* *
...@@ -70,7 +64,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_density( ...@@ -70,7 +64,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_density(
/** /**
* @brief Density loop (non-symmetric version) * @brief Density loop (non-symmetric version)
*/ */
__attribute__((always_inline)) INLINE static void runner_iact_nonsym_density( __attribute__((always_inline)) INLINE static void runner_iact_nonsym_density(
float r2, float *dx, float hi, float hj, struct part *pi, struct part *pj) { float r2, float *dx, float hi, float hj, struct part *pi, struct part *pj) {
...@@ -95,7 +88,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_density( ...@@ -95,7 +88,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_density(
/** /**
* @brief Force loop * @brief Force loop
*/ */
__attribute__((always_inline)) INLINE static void runner_iact_force( __attribute__((always_inline)) INLINE static void runner_iact_force(
float r2, float *dx, float hi, float hj, struct part *pi, struct part *pj) { float r2, float *dx, float hi, float hj, struct part *pi, struct part *pj) {
...@@ -168,7 +160,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_force( ...@@ -168,7 +160,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_force(
/** /**
* @brief Force loop (non-symmetric version) * @brief Force loop (non-symmetric version)
*/ */
__attribute__((always_inline)) INLINE static void runner_iact_nonsym_force( __attribute__((always_inline)) INLINE static void runner_iact_nonsym_force(
float r2, float *dx, float hi, float hj, struct part *pi, struct part *pj) { float r2, float *dx, float hi, float hj, struct part *pi, struct part *pj) {
......
...@@ -29,6 +29,9 @@ ...@@ -29,6 +29,9 @@
#include "hydro.h" #include "hydro.h"
#include "kernel_hydro.h" #include "kernel_hydro.h"
#define hydro_props_default_max_iterations 30
#define hydro_props_default_volume_change 2.0f
void hydro_props_init(struct hydro_props *p, void hydro_props_init(struct hydro_props *p,
const struct swift_params *params) { const struct swift_params *params) {
...@@ -39,13 +42,13 @@ void hydro_props_init(struct hydro_props *p, ...@@ -39,13 +42,13 @@ void hydro_props_init(struct hydro_props *p,
p->delta_neighbours = parser_get_param_float(params, "SPH:delta_neighbours"); p->delta_neighbours = parser_get_param_float(params, "SPH:delta_neighbours");
/* Ghost stuff */ /* Ghost stuff */
p->max_smoothing_iterations = p->max_smoothing_iterations = parser_get_opt_param_int(
parser_get_param_int(params, "SPH:max_ghost_iterations"); params, "SPH:max_ghost_iterations", hydro_props_default_max_iterations);
/* Time integration properties */ /* Time integration properties */
p->CFL_condition = parser_get_param_float(params, "SPH:CFL_condition"); p->CFL_condition = parser_get_param_float(params, "SPH:CFL_condition");
const float max_volume_change = const float max_volume_change = parser_get_opt_param_float(
parser_get_param_float(params, "SPH:max_volume_change"); params, "SPH:max_volume_change", hydro_props_default_volume_change);
p->log_max_h_change = logf(powf(max_volume_change, 0.33333333333f)); p->log_max_h_change = logf(powf(max_volume_change, 0.33333333333f));
} }
...@@ -60,4 +63,8 @@ void hydro_props_print(const struct hydro_props *p) { ...@@ -60,4 +63,8 @@ void hydro_props_print(const struct hydro_props *p) {
"Hydrodynamic integration: Max change of volume: %.2f " "Hydrodynamic integration: Max change of volume: %.2f "
"(max|dlog(h)/dt|=%f).", "(max|dlog(h)/dt|=%f).",
powf(expf(p->log_max_h_change), 3.f), p->log_max_h_change); powf(expf(p->log_max_h_change), 3.f), p->log_max_h_change);
if (p->max_smoothing_iterations != hydro_props_default_max_iterations)
message("Maximal iterations in ghost task set to %d (default is %d)",
p->max_smoothing_iterations, hydro_props_default_max_iterations);
} }
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include <pthread.h> #include <pthread.h>
/* Includes. */ /* Includes. */
#include "inline.h" #include "atomic.h"
#ifdef PTHREAD_SPINLOCK #ifdef PTHREAD_SPINLOCK
#include <pthread.h> #include <pthread.h>
...@@ -50,14 +50,14 @@ ...@@ -50,14 +50,14 @@
#define lock_init(l) (*(l) = 0) #define lock_init(l) (*(l) = 0)
#define lock_destroy(l) 0 #define lock_destroy(l) 0
INLINE static int lock_lock(volatile int *l) { INLINE static int lock_lock(volatile int *l) {
while (__sync_val_compare_and_swap(l, 0, 1) != 0) while (atomic_cas(l, 0, 1) != 0)
; ;
// while( *l ); // while( *l );
return 0; return 0;
} }
#define lock_trylock(l) ((*(l)) ? 1 : __sync_val_compare_and_swap(l, 0, 1)) #define lock_trylock(l) ((*(l)) ? 1 : atomic_cas(l, 0, 1))
#define lock_unlock(l) (__sync_val_compare_and_swap(l, 1, 0) != 1) #define lock_unlock(l) (atomic_cas(l, 1, 0) != 1)
#define lock_unlock_blind(l) __sync_val_compare_and_swap(l, 1, 0) #define lock_unlock_blind(l) atomic_cas(l, 1, 0)
#endif #endif
#endif /* SWIFT_LOCK_H */ #endif /* SWIFT_LOCK_H */
...@@ -18,15 +18,23 @@ ...@@ -18,15 +18,23 @@
* *
******************************************************************************/ ******************************************************************************/
#include "map.h" /* Config parameters. */
#include "../config.h"
/* Some standard headers. */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
/* This object's header. */
#include "map.h"
/* Local headers. */
#include "atomic.h"
#include "error.h" #include "error.h"
/** /**
* @brief Mapping function to draw a specific cell (gnuplot). * @brief Mapping function to draw a specific cell (gnuplot).
*/ */
void map_cells_plot(struct cell *c, void *data) { void map_cells_plot(struct cell *c, void *data) {
int depth = *(int *)data; int depth = *(int *)data;
...@@ -80,24 +88,21 @@ void map_cells_plot(struct cell *c, void *data) { ...@@ -80,24 +88,21 @@ void map_cells_plot(struct cell *c, void *data) {
/** /**
* @brief Mapping function for checking if each part is in its box. * @brief Mapping function for checking if each part is in its box.
*/ */
void map_check(struct part *p, struct cell *c, void *data) {
/* void map_check ( struct part *p , struct cell *c , void *data ) { if (p->x[0] < c->loc[0] || p->x[0] > c->loc[0] + c->h[0] ||
p->x[0] < c->loc[0] || p->x[0] > c->loc[0] + c->h[0] ||
if ( p->x[0] < c->loc[0] || p->x[0] > c->loc[0]+c->h[0] || p->x[0] < c->loc[0] || p->x[0] > c->loc[0] + c->h[0])
p->x[0] < c->loc[0] || p->x[0] > c->loc[0]+c->h[0] || printf("map_check: particle %lld is outside of its box.\n", p->id);
p->x[0] < c->loc[0] || p->x[0] > c->loc[0]+c->h[0] ) }
printf( "map_check: particle %i is outside of its box.\n" , p->id );
} */
/** /**
* @brief Mapping function for neighbour count. * @brief Mapping function for neighbour count.
*/ */
void map_cellcheck(struct cell *c, void *data) { void map_cellcheck(struct cell *c, void *data) {
int *count = (int *)data; int *count = (int *)data;
__sync_fetch_and_add(count, c->count); atomic_add(count, c->count);
/* Loop over all parts and check if they are in the cell. */ /* Loop over all parts and check if they are in the cell. */
for (int k = 0; k < c->count; k++) { for (int k = 0; k < c->count; k++) {
...@@ -133,7 +138,6 @@ void map_cellcheck(struct cell *c, void *data) { ...@@ -133,7 +138,6 @@ void map_cellcheck(struct cell *c, void *data) {
/** /**
* @brief Mapping function for maxdepth cell count. * @brief Mapping function for maxdepth cell count.
*/ */
void map_maxdepth(struct cell *c, void *data) { void map_maxdepth(struct cell *c, void *data) {
int maxdepth = ((int *)data)[0]; int maxdepth = ((int *)data)[0];
...@@ -147,7 +151,6 @@ void map_maxdepth(struct cell *c, void *data) { ...@@ -147,7 +151,6 @@ void map_maxdepth(struct cell *c, void *data) {
/** /**
* @brief Mapping function for neighbour count. * @brief Mapping function for neighbour count.
*/ */
void map_count(struct part *p, struct cell *c, void *data) { void map_count(struct part *p, struct cell *c, void *data) {
double *wcount = (double *)data; double *wcount = (double *)data;
...@@ -156,7 +159,6 @@ void map_count(struct part *p, struct cell *c, void *data) { ...@@ -156,7 +159,6 @@ void map_count(struct part *p, struct cell *c, void *data) {
*wcount += p->density.wcount; *wcount += p->density.wcount;
} }
void map_wcount_min(struct part *p, struct cell *c, void *data) { void map_wcount_min(struct part *p, struct cell *c, void *data) {
struct part **p2 = (struct part **)data; struct part **p2 = (struct part **)data;
...@@ -188,7 +190,6 @@ void map_h_max(struct part *p, struct cell *c, void *data) { ...@@ -188,7 +190,6 @@ void map_h_max(struct part *p, struct cell *c, void *data) {
/** /**
* @brief Mapping function for neighbour count. * @brief Mapping function for neighbour count.
*/ */
void map_icount(struct part *p, struct cell *c, void *data) { void map_icount(struct part *p, struct cell *c, void *data) {
// int *count = (int *)data; // int *count = (int *)data;
...@@ -201,7 +202,6 @@ void map_icount(struct part *p, struct cell *c, void *data) { ...@@ -201,7 +202,6 @@ void map_icount(struct part *p, struct cell *c, void *data) {
/** /**
* @brief Mapping function to print the particle position. * @brief Mapping function to print the particle position.
*/ */
void map_dump(struct part *p, struct cell *c, void *data) { void map_dump(struct part *p, struct cell *c, void *data) {
double *shift = (double *)data; double *shift = (double *)data;
......
...@@ -37,7 +37,11 @@ ...@@ -37,7 +37,11 @@
/* Local includes. */ /* Local includes. */
#include "common_io.h" #include "common_io.h"
#include "engine.h"
#include "error.h" #include "error.h"
#include "kernel_hydro.h"
#include "part.h"
#include "units.h"