Commit ee15a02e authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Uniform debugging #defines

parent 8d3bf0c4
# This file is part of SWIFT. # This file is part of SWIFT.
# Copyright (c) 2012 pedro.gonnet@durham.ac.uk # Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
# matthieu.schaller@durham.ac.uk. # Matthieu Schaller (matthieu.schaller@durham.ac.uk).
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
......
...@@ -685,7 +685,7 @@ void cell_clean_links(struct cell *c, void *data) { ...@@ -685,7 +685,7 @@ void cell_clean_links(struct cell *c, void *data) {
int cell_are_neighbours(const struct cell *restrict ci, int cell_are_neighbours(const struct cell *restrict ci,
const struct cell *restrict cj) { const struct cell *restrict cj) {
#ifdef SANITY_CHECKS #ifdef SWIFT_DEBUG_CHECKS
if (ci->h[0] != cj->h[0]) error("Cells of different size !"); if (ci->h[0] != cj->h[0]) error("Cells of different size !");
#endif #endif
......
...@@ -63,6 +63,5 @@ ...@@ -63,6 +63,5 @@
/* Are we debugging ? */ /* Are we debugging ? */
//#define SWIFT_DEBUG_CHECKS //#define SWIFT_DEBUG_CHECKS
#define SANITY_CHECKS
#endif /* SWIFT_CONST_H */ #endif /* SWIFT_CONST_H */
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include "gravity.h" #include "gravity.h"
#include "part.h" #include "part.h"
#define ICHECK -1 #define ICHECK 1000
/** /**
* @brief Compute the recursive upward sweep, i.e. construct the * @brief Compute the recursive upward sweep, i.e. construct the
...@@ -78,7 +78,7 @@ __attribute__((always_inline)) INLINE static void runner_dopair_grav_pm( ...@@ -78,7 +78,7 @@ __attribute__((always_inline)) INLINE static void runner_dopair_grav_pm(
// message("rlr_inv= %f", rlr_inv); // message("rlr_inv= %f", rlr_inv);
#ifdef SANITY_CHECKS #ifdef SWIFT_DEBUG_CHECKS
if (gcount == 0) error("Empty cell!"); // MATTHIEU sanity check if (gcount == 0) error("Empty cell!"); // MATTHIEU sanity check
if (multi.mass == 0.0) // MATTHIEU sanity check if (multi.mass == 0.0) // MATTHIEU sanity check
...@@ -94,9 +94,10 @@ __attribute__((always_inline)) INLINE static void runner_dopair_grav_pm( ...@@ -94,9 +94,10 @@ __attribute__((always_inline)) INLINE static void runner_dopair_grav_pm(
/* Get a hold of the ith part in ci. */ /* Get a hold of the ith part in ci. */
struct gpart *restrict gp = &gparts[pid]; struct gpart *restrict gp = &gparts[pid];
if (gp->id == -ICHECK) if (gp->id_or_neg_offset == ICHECK)
message("id=%lld loc=[ %f %f %f ] size= %f count= %d", gp->id, cj->loc[0], message("id=%lld loc=[ %f %f %f ] size= %f count= %d",
cj->loc[1], cj->loc[2], cj->h[0], cj->gcount); gp->id_or_neg_offset, cj->loc[0], cj->loc[1], cj->loc[2],
cj->h[0], cj->gcount);
} }
#endif #endif
...@@ -144,7 +145,7 @@ __attribute__((always_inline)) INLINE static void runner_dopair_grav_pp( ...@@ -144,7 +145,7 @@ __attribute__((always_inline)) INLINE static void runner_dopair_grav_pp(
TIMER_TIC; TIMER_TIC;
#ifdef SANITY_CHECKS #ifdef SWIFT_DEBUG_CHECKS
if (ci->h[0] != cj->h[0]) // MATTHIEU sanity check if (ci->h[0] != cj->h[0]) // MATTHIEU sanity check
error("Non matching cell sizes !! h_i=%f h_j=%f", ci->h[0], cj->h[0]); error("Non matching cell sizes !! h_i=%f h_j=%f", ci->h[0], cj->h[0]);
#endif #endif
...@@ -158,9 +159,10 @@ __attribute__((always_inline)) INLINE static void runner_dopair_grav_pp( ...@@ -158,9 +159,10 @@ __attribute__((always_inline)) INLINE static void runner_dopair_grav_pp(
/* Get a hold of the ith part in ci. */ /* Get a hold of the ith part in ci. */
struct gpart *restrict gp = &gparts_i[pid]; struct gpart *restrict gp = &gparts_i[pid];
if (gp->id == -ICHECK) if (gp->id_or_neg_offset == ICHECK)
message("id=%lld loc=[ %f %f %f ] size= %f count= %d", gp->id, cj->loc[0], message("id=%lld loc=[ %f %f %f ] size= %f count= %d",
cj->loc[1], cj->loc[2], cj->h[0], cj->gcount); gp->id_or_neg_offset, cj->loc[0], cj->loc[1], cj->loc[2],
cj->h[0], cj->gcount);
} }
for (int pid = 0; pid < gcount_j; pid++) { for (int pid = 0; pid < gcount_j; pid++) {
...@@ -168,9 +170,10 @@ __attribute__((always_inline)) INLINE static void runner_dopair_grav_pp( ...@@ -168,9 +170,10 @@ __attribute__((always_inline)) INLINE static void runner_dopair_grav_pp(
/* Get a hold of the ith part in ci. */ /* Get a hold of the ith part in ci. */
struct gpart *restrict gp = &gparts_j[pid]; struct gpart *restrict gp = &gparts_j[pid];
if (gp->id == -ICHECK) if (gp->id_or_neg_offset == ICHECK)
message("id=%lld loc=[ %f %f %f ] size= %f count=%d", gp->id, ci->loc[0], message("id=%lld loc=[ %f %f %f ] size= %f count=%d",
ci->loc[1], ci->loc[2], ci->h[0], ci->gcount); gp->id_or_neg_offset, ci->loc[0], ci->loc[1], ci->loc[2],
ci->h[0], ci->gcount);
} }
#endif #endif
...@@ -238,7 +241,7 @@ __attribute__((always_inline)) INLINE static void runner_doself_grav_pp( ...@@ -238,7 +241,7 @@ __attribute__((always_inline)) INLINE static void runner_doself_grav_pp(
TIMER_TIC; TIMER_TIC;
#ifdef SANITY_CHECKS #ifdef SWIFT_DEBUG_CHECKS
if (c->gcount == 0) // MATTHIEU sanity check if (c->gcount == 0) // MATTHIEU sanity check
error("Empty cell !"); error("Empty cell !");
#endif #endif
...@@ -252,9 +255,10 @@ __attribute__((always_inline)) INLINE static void runner_doself_grav_pp( ...@@ -252,9 +255,10 @@ __attribute__((always_inline)) INLINE static void runner_doself_grav_pp(
/* Get a hold of the ith part in ci. */ /* Get a hold of the ith part in ci. */
struct gpart *restrict gp = &gparts[pid]; struct gpart *restrict gp = &gparts[pid];
if (gp->id == -ICHECK) if (gp->id_or_neg_offset == ICHECK)
message("id=%lld loc=[ %f %f %f ] size= %f count= %d", gp->id, c->loc[0], message("id=%lld loc=[ %f %f %f ] size= %f count= %d",
c->loc[1], c->loc[2], c->h[0], c->gcount); gp->id_or_neg_offset, c->loc[0], c->loc[1], c->loc[2], c->h[0],
c->gcount);
} }
#endif #endif
...@@ -314,7 +318,7 @@ __attribute__((always_inline)) INLINE static void runner_doself_grav_pp( ...@@ -314,7 +318,7 @@ __attribute__((always_inline)) INLINE static void runner_doself_grav_pp(
static void runner_dopair_grav(struct runner *r, struct cell *ci, static void runner_dopair_grav(struct runner *r, struct cell *ci,
struct cell *cj) { struct cell *cj) {
#ifdef SANITY_CHECKS #ifdef SWIFT_DEBUG_CHECKS
const int gcount_i = ci->gcount; const int gcount_i = ci->gcount;
const int gcount_j = cj->gcount; const int gcount_j = cj->gcount;
...@@ -343,24 +347,26 @@ static void runner_dopair_grav(struct runner *r, struct cell *ci, ...@@ -343,24 +347,26 @@ static void runner_dopair_grav(struct runner *r, struct cell *ci,
#endif #endif
#if ICHECK > 0 #if ICHECK > 0
for (int pid = 0; pid < gcount_i; pid++) { for (int pid = 0; pid < ci->gcount; pid++) {
/* Get a hold of the ith part in ci. */ /* Get a hold of the ith part in ci. */
struct gpart *restrict gp = &ci->gparts[pid]; struct gpart *restrict gp = &ci->gparts[pid];
if (gp->id == -ICHECK) if (gp->id_or_neg_offset == ICHECK)
message("id=%lld loc=[ %f %f %f ] size= %f count= %d", gp->id, cj->loc[0], message("id=%lld loc=[ %f %f %f ] size= %f count= %d",
cj->loc[1], cj->loc[2], cj->h[0], cj->gcount); gp->id_or_neg_offset, cj->loc[0], cj->loc[1], cj->loc[2],
cj->h[0], cj->gcount);
} }
for (int pid = 0; pid < gcount_j; pid++) { for (int pid = 0; pid < cj->gcount; pid++) {
/* Get a hold of the ith part in ci. */ /* Get a hold of the ith part in ci. */
struct gpart *restrict gp = &cj->gparts[pid]; struct gpart *restrict gp = &cj->gparts[pid];
if (gp->id == -ICHECK) if (gp->id_or_neg_offset == ICHECK)
message("id=%lld loc=[ %f %f %f ] size= %f count= %d", gp->id, ci->loc[0], message("id=%lld loc=[ %f %f %f ] size= %f count= %d",
ci->loc[1], ci->loc[2], ci->h[0], ci->gcount); gp->id_or_neg_offset, ci->loc[0], ci->loc[1], ci->loc[2],
ci->h[0], ci->gcount);
} }
#endif #endif
...@@ -397,7 +403,7 @@ static void runner_dopair_grav(struct runner *r, struct cell *ci, ...@@ -397,7 +403,7 @@ static void runner_dopair_grav(struct runner *r, struct cell *ci,
static void runner_doself_grav(struct runner *r, struct cell *c) { static void runner_doself_grav(struct runner *r, struct cell *c) {
#ifdef SANITY_CHECKS #ifdef SWIFT_DEBUG_CHECKS
/* Early abort? */ /* Early abort? */
if (c->gcount == 0) error("Empty cell !"); if (c->gcount == 0) error("Empty cell !");
...@@ -439,7 +445,7 @@ static void runner_dosub_grav(struct runner *r, struct cell *ci, ...@@ -439,7 +445,7 @@ static void runner_dosub_grav(struct runner *r, struct cell *ci,
} else { } else {
#ifdef SANITY_CHECKS #ifdef SWIFT_DEBUG_CHECKS
if (!cell_are_neighbours(ci, cj)) if (!cell_are_neighbours(ci, cj))
error("Non-neighbouring cells in pair task !"); error("Non-neighbouring cells in pair task !");
#endif #endif
...@@ -456,9 +462,10 @@ static void runner_do_grav_mm(struct runner *r, struct cell *ci, int timer) { ...@@ -456,9 +462,10 @@ static void runner_do_grav_mm(struct runner *r, struct cell *ci, int timer) {
/* Get a hold of the ith part in ci. */ /* Get a hold of the ith part in ci. */
struct gpart *restrict gp = &ci->gparts[pid]; struct gpart *restrict gp = &ci->gparts[pid];
if (gp->id == -ICHECK) if (gp->id_or_neg_offset == ICHECK)
message("id=%lld loc=[ %f %f %f ] size= %f count= %d", gp->id, ci->loc[0], message("id=%lld loc=[ %f %f %f ] size= %f count= %d",
ci->loc[1], ci->loc[2], ci->h[0], ci->gcount); gp->id_or_neg_offset, ci->loc[0], ci->loc[1], ci->loc[2],
ci->h[0], ci->gcount);
} }
#endif #endif
......
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