Commit 83382a18 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Added timers for the individual star feedback loops.

parent 771991d0
......@@ -481,7 +481,7 @@ void runner_do_stars_ghost(struct runner *r, struct cell *c, int timer) {
}
}
if (timer) TIMER_TOC(timer_dostars_ghost);
if (timer) TIMER_TOC(timer_do_stars_ghost);
}
/**
......
......@@ -71,6 +71,18 @@
#define _DOSUB_SELF1_STARS(f) PASTE(runner_dosub_self_stars, f)
#define DOSUB_SELF1_STARS _DOSUB_SELF1_STARS(FUNCTION)
#define _TIMER_DOSELF_STARS(f) PASTE(timer_doself_stars, f)
#define TIMER_DOSELF_STARS _TIMER_DOSELF_STARS(FUNCTION)
#define _TIMER_DOPAIR_STARS(f) PASTE(timer_dopair_stars, f)
#define TIMER_DOPAIR_STARS _TIMER_DOPAIR_STARS(FUNCTION)
#define _TIMER_DOSUB_SELF_STARS(f) PASTE(timer_dosub_self_stars, f)
#define TIMER_DOSUB_SELF_STARS _TIMER_DOSUB_SELF_STARS(FUNCTION)
#define _TIMER_DOSUB_PAIR_STARS(f) PASTE(timer_dosub_pair_stars, f)
#define TIMER_DOSUB_PAIR_STARS _TIMER_DOSUB_PAIR_STARS(FUNCTION)
#define _IACT_STARS(f) PASTE(runner_iact_nonsym_stars, f)
#define IACT_STARS _IACT_STARS(FUNCTION)
......@@ -87,6 +99,8 @@ void DOSELF1_STARS(struct runner *r, struct cell *c, int timer) {
if (c->nodeID != engine_rank) error("Should be run on a different node");
#endif
TIMER_TIC;
const struct engine *e = r->e;
const integertime_t ti_current = e->ti_current;
const struct cosmology *cosmo = e->cosmology;
......@@ -154,6 +168,8 @@ void DOSELF1_STARS(struct runner *r, struct cell *c, int timer) {
}
} /* loop over the parts in ci. */
} /* loop over the sparts in ci. */
TIMER_TOC(TIMER_DOSELF_STARS);
}
/**
......@@ -265,6 +281,8 @@ void DO_NONSYM_PAIR1_STARS_NAIVE(struct runner *r, struct cell *restrict ci,
void DO_SYM_PAIR1_STARS(struct runner *r, struct cell *ci, struct cell *cj,
const int sid, const double *shift) {
TIMER_TIC;
const struct engine *e = r->e;
const integertime_t ti_current = e->ti_current;
const struct cosmology *cosmo = e->cosmology;
......@@ -541,11 +559,15 @@ void DO_SYM_PAIR1_STARS(struct runner *r, struct cell *ci, struct cell *cj,
} /* loop over the parts in ci. */
} /* loop over the parts in cj. */
} /* Cell cj is active */
TIMER_TOC(TIMER_DOPAIR_STARS);
}
void DOPAIR1_STARS_NAIVE(struct runner *r, struct cell *restrict ci,
struct cell *restrict cj, int timer) {
TIMER_TIC;
#if (FUNCTION_TASK_LOOP == TASK_LOOP_DENSITY)
const int do_ci_stars = ci->nodeID == r->e->nodeID;
const int do_cj_stars = cj->nodeID == r->e->nodeID;
......@@ -558,6 +580,8 @@ void DOPAIR1_STARS_NAIVE(struct runner *r, struct cell *restrict ci,
DO_NONSYM_PAIR1_STARS_NAIVE(r, ci, cj);
if (do_cj_stars && cj->stars.count != 0 && ci->hydro.count != 0)
DO_NONSYM_PAIR1_STARS_NAIVE(r, cj, ci);
TIMER_TOC(TIMER_DOPAIR_STARS);
}
/**
......@@ -1701,6 +1725,8 @@ void DOPAIR1_BRANCH_STARS(struct runner *r, struct cell *ci, struct cell *cj) {
void DOSUB_PAIR1_STARS(struct runner *r, struct cell *ci, struct cell *cj,
int sid, int gettimer) {
TIMER_TIC;
struct space *s = r->e->s;
const struct engine *e = r->e;
......@@ -1976,6 +2002,8 @@ void DOSUB_PAIR1_STARS(struct runner *r, struct cell *ci, struct cell *cj,
if (do_ci || do_cj) DOPAIR1_BRANCH_STARS(r, ci, cj);
}
TIMER_TOC(TIMER_DOSUB_PAIR_STARS);
}
/**
......@@ -1987,6 +2015,8 @@ void DOSUB_PAIR1_STARS(struct runner *r, struct cell *ci, struct cell *cj,
*/
void DOSUB_SELF1_STARS(struct runner *r, struct cell *ci, int gettimer) {
TIMER_TIC;
#ifdef SWIFT_DEBUG_CHECKS
if (ci->nodeID != engine_rank)
error("This function should not be called on foreign cells");
......@@ -2018,4 +2048,6 @@ void DOSUB_SELF1_STARS(struct runner *r, struct cell *ci, int gettimer) {
DOSELF1_BRANCH_STARS(r, ci);
}
TIMER_TOC(TIMER_DOSUB_SELF_STARS);
}
......@@ -54,11 +54,15 @@ const char* timers_names[timer_count] = {
"doself_gradient",
"doself_force",
"doself_limiter",
"doself_stars_density",
"doself_stars_feedback",
"doself_grav_pp",
"dopair_density",
"dopair_gradient",
"dopair_force",
"dopair_limiter",
"dopair_stars_density",
"dopair_stars_feedback",
"dopair_grav_mm",
"dopair_grav_pp",
"dograv_external",
......@@ -70,11 +74,15 @@ const char* timers_names[timer_count] = {
"dosub_self_gradient",
"dosub_self_force",
"dosub_self_limiter",
"dosub_self_stars_density",
"dosub_self_stars_feedback",
"dosub_self_grav",
"dosub_pair_density",
"dosub_pair_gradient",
"dosub_pair_force",
"dosub_pair_limiter",
"dosub_pair_stars_density",
"dosub_pair_stars_feedback",
"dosub_pair_grav",
"doself_subset",
"dopair_subset",
......@@ -82,6 +90,7 @@ const char* timers_names[timer_count] = {
"dosub_subset",
"do_ghost",
"do_extra_ghost",
"do_stars_ghost",
"dorecv_part",
"dorecv_gpart",
"dorecv_spart",
......@@ -95,7 +104,6 @@ const char* timers_names[timer_count] = {
"locktree",
"runners",
"step",
"do_stars_ghost",
"logger",
"do_stars_sort",
};
......@@ -104,25 +112,14 @@ const char* timers_names[timer_count] = {
static FILE* timers_file;
/**
* @brief Re-set the timers.
*
* @param mask A bitmask of the timers to re-set.
* @brief Re-set all the timers.
*
* To reset all timers, use the mask #timers_mask_all.
*/
void timers_reset(unsigned long long mask) {
void timers_reset_all(void) {
/* Loop over the timers and set the masked ones to zero. */
for (int k = 0; k < timer_count; k++)
if (mask & (1ull << k)) timers[k] = 0;
for (int k = 0; k < timer_count; k++) timers[k] = 0;
}
/**
* @brief Re-set all the timers.
*
*/
void timers_reset_all(void) { timers_reset(timers_mask_all); }
/**
* @brief Outputs all the timers to the timers dump file.
*
......@@ -131,7 +128,7 @@ void timers_reset_all(void) { timers_reset(timers_mask_all); }
void timers_print(int step) {
fprintf(timers_file, "%d\t", step);
for (int k = 0; k < timer_count; k++)
fprintf(timers_file, "%18.3f ", clocks_from_ticks(timers[k]));
fprintf(timers_file, "%22.3f ", clocks_from_ticks(timers[k]));
fprintf(timers_file, "\n");
fflush(timers_file);
}
......@@ -149,7 +146,7 @@ void timers_open_file(int rank) {
fprintf(timers_file, "# timers: \n# step | ");
for (int k = 0; k < timer_count; k++)
fprintf(timers_file, "%18s ", timers_names[k]);
fprintf(timers_file, "%22s ", timers_names[k]);
fprintf(timers_file, "\n");
}
......
......@@ -55,11 +55,15 @@ enum {
timer_doself_gradient,
timer_doself_force,
timer_doself_limiter,
timer_doself_stars_density,
timer_doself_stars_feedback,
timer_doself_grav_pp,
timer_dopair_density,
timer_dopair_gradient,
timer_dopair_force,
timer_dopair_limiter,
timer_dopair_stars_density,
timer_dopair_stars_feedback,
timer_dopair_grav_mm,
timer_dopair_grav_pp,
timer_dograv_external,
......@@ -71,11 +75,15 @@ enum {
timer_dosub_self_gradient,
timer_dosub_self_force,
timer_dosub_self_limiter,
timer_dosub_self_stars_density,
timer_dosub_self_stars_feedback,
timer_dosub_self_grav,
timer_dosub_pair_density,
timer_dosub_pair_gradient,
timer_dosub_pair_force,
timer_dosub_pair_limiter,
timer_dosub_pair_stars_density,
timer_dosub_pair_stars_feedback,
timer_dosub_pair_grav,
timer_doself_subset,
timer_dopair_subset,
......@@ -83,6 +91,7 @@ enum {
timer_dosub_subset,
timer_do_ghost,
timer_do_extra_ghost,
timer_do_stars_ghost,
timer_dorecv_part,
timer_dorecv_gpart,
timer_dorecv_spart,
......@@ -96,7 +105,6 @@ enum {
timer_locktree,
timer_runners,
timer_step,
timer_dostars_ghost,
timer_logger,
timer_do_stars_sort,
timer_count,
......@@ -108,9 +116,6 @@ extern ticks timers[timer_count];
/* The timer names. */
extern const char *timers_names[];
/* Mask for all timers. */
#define timers_mask_all ((1ull << timer_count) - 1)
/* Define the timer macros. */
#ifdef SWIFT_USE_TIMERS
#define TIMER_TIC const ticks tic = getticks();
......@@ -131,7 +136,6 @@ INLINE static ticks timers_toc(unsigned int t, ticks tic) {
/* Function prototypes. */
void timers_reset_all(void);
void timers_reset(unsigned long long mask);
void timers_open_file(int rank);
void timers_close_file(void);
void timers_print(int step);
......
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