diff --git a/src/active.h b/src/active.h index f9ed4a0d40127f1544c744a61b05515a19857b05..9eb4123392f4b1b6bca2f68d59991ff90b92614d 100644 --- a/src/active.h +++ b/src/active.h @@ -82,19 +82,19 @@ __attribute__((always_inline)) INLINE static int cell_are_gpart_drifted( * @param e The #engine containing information about the current time. * @return 1 if the #cell contains at least an active particle, 0 otherwise. */ -__attribute__((always_inline)) INLINE static int cell_is_active( +__attribute__((always_inline)) INLINE static int cell_is_active_hydro( const struct cell *c, const struct engine *e) { #ifdef SWIFT_DEBUG_CHECKS - if (c->ti_end_min < e->ti_current) + if (c->ti_hydro_end_min < e->ti_current) error( "cell in an impossible time-zone! c->ti_end_min=%lld (t=%e) and " "e->ti_current=%lld (t=%e)", - c->ti_end_min, c->ti_end_min * e->timeBase, e->ti_current, + c->ti_hydro_end_min, c->ti_hydro_end_min * e->timeBase, e->ti_current, e->ti_current * e->timeBase); #endif - return (c->ti_end_min == e->ti_current); + return (c->ti_hydro_end_min == e->ti_current); } /** @@ -104,18 +104,61 @@ __attribute__((always_inline)) INLINE static int cell_is_active( * @param e The #engine containing information about the current time. * @return 1 if all particles in a #cell are active, 0 otherwise. */ -__attribute__((always_inline)) INLINE static int cell_is_all_active( +__attribute__((always_inline)) INLINE static int cell_is_all_active_hydro( const struct cell *c, const struct engine *e) { #ifdef SWIFT_DEBUG_CHECKS - if (c->ti_end_max < e->ti_current) + if (c->ti_hydro_end_max < e->ti_current) error( "cell in an impossible time-zone! c->ti_end_max=%lld " "e->ti_current=%lld", - c->ti_end_max, e->ti_current); + c->ti_hydro_end_max, e->ti_current); #endif - return (c->ti_end_max == e->ti_current); + return (c->ti_hydro_end_max == e->ti_current); +} + +/** + * @brief Does a cell contain any g-particle finishing their time-step now ? + * + * @param c The #cell. + * @param e The #engine containing information about the current time. + * @return 1 if the #cell contains at least an active particle, 0 otherwise. + */ +__attribute__((always_inline)) INLINE static int cell_is_active_gravity( + const struct cell *c, const struct engine *e) { + +#ifdef SWIFT_DEBUG_CHECKS + if (c->ti_gravity_end_min < e->ti_current) + error( + "cell in an impossible time-zone! c->ti_end_min=%lld (t=%e) and " + "e->ti_current=%lld (t=%e)", + c->ti_gravity_end_min, c->ti_gravity_end_min * e->timeBase, + e->ti_current, e->ti_current * e->timeBase); +#endif + + return (c->ti_gravity_end_min == e->ti_current); +} + +/** + * @brief Are *all* g-particles in a cell finishing their time-step now ? + * + * @param c The #cell. + * @param e The #engine containing information about the current time. + * @return 1 if all particles in a #cell are active, 0 otherwise. + */ +__attribute__((always_inline)) INLINE static int cell_is_all_active_gravity( + const struct cell *c, const struct engine *e) { + +#ifdef SWIFT_DEBUG_CHECKS + if (c->ti_gravity_end_max < e->ti_current) + error( + "cell in an impossible time-zone! c->ti_end_max=%lld " + "e->ti_current=%lld", + c->ti_gravity_end_max, e->ti_current); +#endif + + return (c->ti_gravity_end_max == e->ti_current); } /** @@ -215,19 +258,41 @@ __attribute__((always_inline)) INLINE static int spart_is_active( * @param e The #engine containing information about the current time. * @return 1 if the #cell contains at least an active particle, 0 otherwise. */ -__attribute__((always_inline)) INLINE static int cell_is_starting( +__attribute__((always_inline)) INLINE static int cell_is_starting_hydro( const struct cell *c, const struct engine *e) { #ifdef SWIFT_DEBUG_CHECKS - if (c->ti_beg_max > e->ti_current) + if (c->ti_hydro_beg_max > e->ti_current) error( "cell in an impossible time-zone! c->ti_beg_max=%lld (t=%e) and " "e->ti_current=%lld (t=%e)", - c->ti_beg_max, c->ti_beg_max * e->timeBase, e->ti_current, + c->ti_hydro_beg_max, c->ti_hydro_beg_max * e->timeBase, e->ti_current, e->ti_current * e->timeBase); #endif - return (c->ti_beg_max == e->ti_current); + return (c->ti_hydro_beg_max == e->ti_current); +} + +/** + * @brief Does a cell contain any g-particle starting their time-step now ? + * + * @param c The #cell. + * @param e The #engine containing information about the current time. + * @return 1 if the #cell contains at least an active particle, 0 otherwise. + */ +__attribute__((always_inline)) INLINE static int cell_is_starting_gravity( + const struct cell *c, const struct engine *e) { + +#ifdef SWIFT_DEBUG_CHECKS + if (c->ti_gravity_beg_max > e->ti_current) + error( + "cell in an impossible time-zone! c->ti_beg_max=%lld (t=%e) and " + "e->ti_current=%lld (t=%e)", + c->ti_gravity_beg_max, c->ti_gravity_beg_max * e->timeBase, + e->ti_current, e->ti_current * e->timeBase); +#endif + + return (c->ti_gravity_beg_max == e->ti_current); } /** diff --git a/src/cell.c b/src/cell.c index 70bdad3396cd507ea4fd96db2d92f907bef18863..766b3cf05cd01a281f441c705674a059587c12c2 100644 --- a/src/cell.c +++ b/src/cell.c @@ -173,8 +173,10 @@ int cell_pack(struct cell *restrict c, struct pcell *restrict pc) { /* Start by packing the data of the current cell. */ pc->h_max = c->h_max; - pc->ti_end_min = c->ti_end_min; - pc->ti_end_max = c->ti_end_max; + pc->ti_hydro_end_min = c->ti_hydro_end_min; + pc->ti_hydro_end_max = c->ti_hydro_end_max; + pc->ti_gravity_end_min = c->ti_gravity_end_min; + pc->ti_gravity_end_max = c->ti_gravity_end_max; pc->ti_old_part = c->ti_old_part; pc->ti_old_gpart = c->ti_old_gpart; pc->ti_old_multipole = c->ti_old_multipole; @@ -221,8 +223,10 @@ int cell_unpack(struct pcell *restrict pc, struct cell *restrict c, /* Unpack the current pcell. */ c->h_max = pc->h_max; - c->ti_end_min = pc->ti_end_min; - c->ti_end_max = pc->ti_end_max; + c->ti_hydro_end_min = pc->ti_hydro_end_min; + c->ti_hydro_end_max = pc->ti_hydro_end_max; + c->ti_gravity_end_min = pc->ti_gravity_end_min; + c->ti_gravity_end_max = pc->ti_gravity_end_max; c->ti_old_part = pc->ti_old_part; c->ti_old_gpart = pc->ti_old_gpart; c->ti_old_multipole = pc->ti_old_multipole; @@ -291,7 +295,8 @@ int cell_pack_end_step(struct cell *restrict c, #ifdef WITH_MPI /* Pack this cell's data. */ - pcells[0].ti_end_min = c->ti_end_min; + pcells[0].ti_hydro_end_min = c->ti_hydro_end_min; + pcells[0].ti_gravity_end_min = c->ti_gravity_end_min; pcells[0].dx_max_part = c->dx_max_part; pcells[0].dx_max_gpart = c->dx_max_gpart; @@ -325,7 +330,8 @@ int cell_unpack_end_step(struct cell *restrict c, #ifdef WITH_MPI /* Unpack this cell's data. */ - c->ti_end_min = pcells[0].ti_end_min; + c->ti_hydro_end_min = pcells[0].ti_hydro_end_min; + c->ti_gravity_end_min = pcells[0].ti_gravity_end_min; c->dx_max_part = pcells[0].dx_max_part; c->dx_max_gpart = pcells[0].dx_max_gpart; @@ -1487,8 +1493,8 @@ void cell_activate_sorts(struct cell *c, int sid, struct scheduler *s) { * @param cj The second #cell we recurse in. * @param s The task #scheduler. */ -void cell_activate_subcell_tasks(struct cell *ci, struct cell *cj, - struct scheduler *s) { +void cell_activate_subcell_hydro_tasks(struct cell *ci, struct cell *cj, + struct scheduler *s) { const struct engine *e = s->space->e; /* Store the current dx_max and h_max values. */ @@ -1502,7 +1508,7 @@ void cell_activate_subcell_tasks(struct cell *ci, struct cell *cj, /* Self interaction? */ if (cj == NULL) { /* Do anything? */ - if (!cell_is_active(ci, e)) return; + if (!cell_is_active_hydro(ci, e)) return; /* Recurse? */ if (cell_can_recurse_in_self_task(ci)) { @@ -1510,10 +1516,11 @@ void cell_activate_subcell_tasks(struct cell *ci, struct cell *cj, /* Loop over all progenies and pairs of progenies */ for (int j = 0; j < 8; j++) { if (ci->progeny[j] != NULL) { - cell_activate_subcell_tasks(ci->progeny[j], NULL, s); + cell_activate_subcell_hydro_tasks(ci->progeny[j], NULL, s); for (int k = j + 1; k < 8; k++) if (ci->progeny[k] != NULL) - cell_activate_subcell_tasks(ci->progeny[j], ci->progeny[k], s); + cell_activate_subcell_hydro_tasks(ci->progeny[j], ci->progeny[k], + s); } } } else { @@ -1537,200 +1544,200 @@ void cell_activate_subcell_tasks(struct cell *ci, struct cell *cj, /* Regular sub-cell interactions of a single cell. */ case 0: /* ( 1 , 1 , 1 ) */ if (ci->progeny[7] != NULL && cj->progeny[0] != NULL) - cell_activate_subcell_tasks(ci->progeny[7], cj->progeny[0], s); + cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[0], s); break; case 1: /* ( 1 , 1 , 0 ) */ if (ci->progeny[6] != NULL && cj->progeny[0] != NULL) - cell_activate_subcell_tasks(ci->progeny[6], cj->progeny[0], s); + cell_activate_subcell_hydro_tasks(ci->progeny[6], cj->progeny[0], s); if (ci->progeny[6] != NULL && cj->progeny[1] != NULL) - cell_activate_subcell_tasks(ci->progeny[6], cj->progeny[1], s); + cell_activate_subcell_hydro_tasks(ci->progeny[6], cj->progeny[1], s); if (ci->progeny[7] != NULL && cj->progeny[0] != NULL) - cell_activate_subcell_tasks(ci->progeny[7], cj->progeny[0], s); + cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[0], s); if (ci->progeny[7] != NULL && cj->progeny[1] != NULL) - cell_activate_subcell_tasks(ci->progeny[7], cj->progeny[1], s); + cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[1], s); break; case 2: /* ( 1 , 1 , -1 ) */ if (ci->progeny[6] != NULL && cj->progeny[1] != NULL) - cell_activate_subcell_tasks(ci->progeny[6], cj->progeny[1], s); + cell_activate_subcell_hydro_tasks(ci->progeny[6], cj->progeny[1], s); break; case 3: /* ( 1 , 0 , 1 ) */ if (ci->progeny[5] != NULL && cj->progeny[0] != NULL) - cell_activate_subcell_tasks(ci->progeny[5], cj->progeny[0], s); + cell_activate_subcell_hydro_tasks(ci->progeny[5], cj->progeny[0], s); if (ci->progeny[5] != NULL && cj->progeny[2] != NULL) - cell_activate_subcell_tasks(ci->progeny[5], cj->progeny[2], s); + cell_activate_subcell_hydro_tasks(ci->progeny[5], cj->progeny[2], s); if (ci->progeny[7] != NULL && cj->progeny[0] != NULL) - cell_activate_subcell_tasks(ci->progeny[7], cj->progeny[0], s); + cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[0], s); if (ci->progeny[7] != NULL && cj->progeny[2] != NULL) - cell_activate_subcell_tasks(ci->progeny[7], cj->progeny[2], s); + cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[2], s); break; case 4: /* ( 1 , 0 , 0 ) */ if (ci->progeny[4] != NULL && cj->progeny[0] != NULL) - cell_activate_subcell_tasks(ci->progeny[4], cj->progeny[0], s); + cell_activate_subcell_hydro_tasks(ci->progeny[4], cj->progeny[0], s); if (ci->progeny[4] != NULL && cj->progeny[1] != NULL) - cell_activate_subcell_tasks(ci->progeny[4], cj->progeny[1], s); + cell_activate_subcell_hydro_tasks(ci->progeny[4], cj->progeny[1], s); if (ci->progeny[4] != NULL && cj->progeny[2] != NULL) - cell_activate_subcell_tasks(ci->progeny[4], cj->progeny[2], s); + cell_activate_subcell_hydro_tasks(ci->progeny[4], cj->progeny[2], s); if (ci->progeny[4] != NULL && cj->progeny[3] != NULL) - cell_activate_subcell_tasks(ci->progeny[4], cj->progeny[3], s); + cell_activate_subcell_hydro_tasks(ci->progeny[4], cj->progeny[3], s); if (ci->progeny[5] != NULL && cj->progeny[0] != NULL) - cell_activate_subcell_tasks(ci->progeny[5], cj->progeny[0], s); + cell_activate_subcell_hydro_tasks(ci->progeny[5], cj->progeny[0], s); if (ci->progeny[5] != NULL && cj->progeny[1] != NULL) - cell_activate_subcell_tasks(ci->progeny[5], cj->progeny[1], s); + cell_activate_subcell_hydro_tasks(ci->progeny[5], cj->progeny[1], s); if (ci->progeny[5] != NULL && cj->progeny[2] != NULL) - cell_activate_subcell_tasks(ci->progeny[5], cj->progeny[2], s); + cell_activate_subcell_hydro_tasks(ci->progeny[5], cj->progeny[2], s); if (ci->progeny[5] != NULL && cj->progeny[3] != NULL) - cell_activate_subcell_tasks(ci->progeny[5], cj->progeny[3], s); + cell_activate_subcell_hydro_tasks(ci->progeny[5], cj->progeny[3], s); if (ci->progeny[6] != NULL && cj->progeny[0] != NULL) - cell_activate_subcell_tasks(ci->progeny[6], cj->progeny[0], s); + cell_activate_subcell_hydro_tasks(ci->progeny[6], cj->progeny[0], s); if (ci->progeny[6] != NULL && cj->progeny[1] != NULL) - cell_activate_subcell_tasks(ci->progeny[6], cj->progeny[1], s); + cell_activate_subcell_hydro_tasks(ci->progeny[6], cj->progeny[1], s); if (ci->progeny[6] != NULL && cj->progeny[2] != NULL) - cell_activate_subcell_tasks(ci->progeny[6], cj->progeny[2], s); + cell_activate_subcell_hydro_tasks(ci->progeny[6], cj->progeny[2], s); if (ci->progeny[6] != NULL && cj->progeny[3] != NULL) - cell_activate_subcell_tasks(ci->progeny[6], cj->progeny[3], s); + cell_activate_subcell_hydro_tasks(ci->progeny[6], cj->progeny[3], s); if (ci->progeny[7] != NULL && cj->progeny[0] != NULL) - cell_activate_subcell_tasks(ci->progeny[7], cj->progeny[0], s); + cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[0], s); if (ci->progeny[7] != NULL && cj->progeny[1] != NULL) - cell_activate_subcell_tasks(ci->progeny[7], cj->progeny[1], s); + cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[1], s); if (ci->progeny[7] != NULL && cj->progeny[2] != NULL) - cell_activate_subcell_tasks(ci->progeny[7], cj->progeny[2], s); + cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[2], s); if (ci->progeny[7] != NULL && cj->progeny[3] != NULL) - cell_activate_subcell_tasks(ci->progeny[7], cj->progeny[3], s); + cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[3], s); break; case 5: /* ( 1 , 0 , -1 ) */ if (ci->progeny[4] != NULL && cj->progeny[1] != NULL) - cell_activate_subcell_tasks(ci->progeny[4], cj->progeny[1], s); + cell_activate_subcell_hydro_tasks(ci->progeny[4], cj->progeny[1], s); if (ci->progeny[4] != NULL && cj->progeny[3] != NULL) - cell_activate_subcell_tasks(ci->progeny[4], cj->progeny[3], s); + cell_activate_subcell_hydro_tasks(ci->progeny[4], cj->progeny[3], s); if (ci->progeny[6] != NULL && cj->progeny[1] != NULL) - cell_activate_subcell_tasks(ci->progeny[6], cj->progeny[1], s); + cell_activate_subcell_hydro_tasks(ci->progeny[6], cj->progeny[1], s); if (ci->progeny[6] != NULL && cj->progeny[3] != NULL) - cell_activate_subcell_tasks(ci->progeny[6], cj->progeny[3], s); + cell_activate_subcell_hydro_tasks(ci->progeny[6], cj->progeny[3], s); break; case 6: /* ( 1 , -1 , 1 ) */ if (ci->progeny[5] != NULL && cj->progeny[2] != NULL) - cell_activate_subcell_tasks(ci->progeny[5], cj->progeny[2], s); + cell_activate_subcell_hydro_tasks(ci->progeny[5], cj->progeny[2], s); break; case 7: /* ( 1 , -1 , 0 ) */ if (ci->progeny[4] != NULL && cj->progeny[2] != NULL) - cell_activate_subcell_tasks(ci->progeny[4], cj->progeny[2], s); + cell_activate_subcell_hydro_tasks(ci->progeny[4], cj->progeny[2], s); if (ci->progeny[4] != NULL && cj->progeny[3] != NULL) - cell_activate_subcell_tasks(ci->progeny[4], cj->progeny[3], s); + cell_activate_subcell_hydro_tasks(ci->progeny[4], cj->progeny[3], s); if (ci->progeny[5] != NULL && cj->progeny[2] != NULL) - cell_activate_subcell_tasks(ci->progeny[5], cj->progeny[2], s); + cell_activate_subcell_hydro_tasks(ci->progeny[5], cj->progeny[2], s); if (ci->progeny[5] != NULL && cj->progeny[3] != NULL) - cell_activate_subcell_tasks(ci->progeny[5], cj->progeny[3], s); + cell_activate_subcell_hydro_tasks(ci->progeny[5], cj->progeny[3], s); break; case 8: /* ( 1 , -1 , -1 ) */ if (ci->progeny[4] != NULL && cj->progeny[3] != NULL) - cell_activate_subcell_tasks(ci->progeny[4], cj->progeny[3], s); + cell_activate_subcell_hydro_tasks(ci->progeny[4], cj->progeny[3], s); break; case 9: /* ( 0 , 1 , 1 ) */ if (ci->progeny[3] != NULL && cj->progeny[0] != NULL) - cell_activate_subcell_tasks(ci->progeny[3], cj->progeny[0], s); + cell_activate_subcell_hydro_tasks(ci->progeny[3], cj->progeny[0], s); if (ci->progeny[3] != NULL && cj->progeny[4] != NULL) - cell_activate_subcell_tasks(ci->progeny[3], cj->progeny[4], s); + cell_activate_subcell_hydro_tasks(ci->progeny[3], cj->progeny[4], s); if (ci->progeny[7] != NULL && cj->progeny[0] != NULL) - cell_activate_subcell_tasks(ci->progeny[7], cj->progeny[0], s); + cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[0], s); if (ci->progeny[7] != NULL && cj->progeny[4] != NULL) - cell_activate_subcell_tasks(ci->progeny[7], cj->progeny[4], s); + cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[4], s); break; case 10: /* ( 0 , 1 , 0 ) */ if (ci->progeny[2] != NULL && cj->progeny[0] != NULL) - cell_activate_subcell_tasks(ci->progeny[2], cj->progeny[0], s); + cell_activate_subcell_hydro_tasks(ci->progeny[2], cj->progeny[0], s); if (ci->progeny[2] != NULL && cj->progeny[1] != NULL) - cell_activate_subcell_tasks(ci->progeny[2], cj->progeny[1], s); + cell_activate_subcell_hydro_tasks(ci->progeny[2], cj->progeny[1], s); if (ci->progeny[2] != NULL && cj->progeny[4] != NULL) - cell_activate_subcell_tasks(ci->progeny[2], cj->progeny[4], s); + cell_activate_subcell_hydro_tasks(ci->progeny[2], cj->progeny[4], s); if (ci->progeny[2] != NULL && cj->progeny[5] != NULL) - cell_activate_subcell_tasks(ci->progeny[2], cj->progeny[5], s); + cell_activate_subcell_hydro_tasks(ci->progeny[2], cj->progeny[5], s); if (ci->progeny[3] != NULL && cj->progeny[0] != NULL) - cell_activate_subcell_tasks(ci->progeny[3], cj->progeny[0], s); + cell_activate_subcell_hydro_tasks(ci->progeny[3], cj->progeny[0], s); if (ci->progeny[3] != NULL && cj->progeny[1] != NULL) - cell_activate_subcell_tasks(ci->progeny[3], cj->progeny[1], s); + cell_activate_subcell_hydro_tasks(ci->progeny[3], cj->progeny[1], s); if (ci->progeny[3] != NULL && cj->progeny[4] != NULL) - cell_activate_subcell_tasks(ci->progeny[3], cj->progeny[4], s); + cell_activate_subcell_hydro_tasks(ci->progeny[3], cj->progeny[4], s); if (ci->progeny[3] != NULL && cj->progeny[5] != NULL) - cell_activate_subcell_tasks(ci->progeny[3], cj->progeny[5], s); + cell_activate_subcell_hydro_tasks(ci->progeny[3], cj->progeny[5], s); if (ci->progeny[6] != NULL && cj->progeny[0] != NULL) - cell_activate_subcell_tasks(ci->progeny[6], cj->progeny[0], s); + cell_activate_subcell_hydro_tasks(ci->progeny[6], cj->progeny[0], s); if (ci->progeny[6] != NULL && cj->progeny[1] != NULL) - cell_activate_subcell_tasks(ci->progeny[6], cj->progeny[1], s); + cell_activate_subcell_hydro_tasks(ci->progeny[6], cj->progeny[1], s); if (ci->progeny[6] != NULL && cj->progeny[4] != NULL) - cell_activate_subcell_tasks(ci->progeny[6], cj->progeny[4], s); + cell_activate_subcell_hydro_tasks(ci->progeny[6], cj->progeny[4], s); if (ci->progeny[6] != NULL && cj->progeny[5] != NULL) - cell_activate_subcell_tasks(ci->progeny[6], cj->progeny[5], s); + cell_activate_subcell_hydro_tasks(ci->progeny[6], cj->progeny[5], s); if (ci->progeny[7] != NULL && cj->progeny[0] != NULL) - cell_activate_subcell_tasks(ci->progeny[7], cj->progeny[0], s); + cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[0], s); if (ci->progeny[7] != NULL && cj->progeny[1] != NULL) - cell_activate_subcell_tasks(ci->progeny[7], cj->progeny[1], s); + cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[1], s); if (ci->progeny[7] != NULL && cj->progeny[4] != NULL) - cell_activate_subcell_tasks(ci->progeny[7], cj->progeny[4], s); + cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[4], s); if (ci->progeny[7] != NULL && cj->progeny[5] != NULL) - cell_activate_subcell_tasks(ci->progeny[7], cj->progeny[5], s); + cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[5], s); break; case 11: /* ( 0 , 1 , -1 ) */ if (ci->progeny[2] != NULL && cj->progeny[1] != NULL) - cell_activate_subcell_tasks(ci->progeny[2], cj->progeny[1], s); + cell_activate_subcell_hydro_tasks(ci->progeny[2], cj->progeny[1], s); if (ci->progeny[2] != NULL && cj->progeny[5] != NULL) - cell_activate_subcell_tasks(ci->progeny[2], cj->progeny[5], s); + cell_activate_subcell_hydro_tasks(ci->progeny[2], cj->progeny[5], s); if (ci->progeny[6] != NULL && cj->progeny[1] != NULL) - cell_activate_subcell_tasks(ci->progeny[6], cj->progeny[1], s); + cell_activate_subcell_hydro_tasks(ci->progeny[6], cj->progeny[1], s); if (ci->progeny[6] != NULL && cj->progeny[5] != NULL) - cell_activate_subcell_tasks(ci->progeny[6], cj->progeny[5], s); + cell_activate_subcell_hydro_tasks(ci->progeny[6], cj->progeny[5], s); break; case 12: /* ( 0 , 0 , 1 ) */ if (ci->progeny[1] != NULL && cj->progeny[0] != NULL) - cell_activate_subcell_tasks(ci->progeny[1], cj->progeny[0], s); + cell_activate_subcell_hydro_tasks(ci->progeny[1], cj->progeny[0], s); if (ci->progeny[1] != NULL && cj->progeny[2] != NULL) - cell_activate_subcell_tasks(ci->progeny[1], cj->progeny[2], s); + cell_activate_subcell_hydro_tasks(ci->progeny[1], cj->progeny[2], s); if (ci->progeny[1] != NULL && cj->progeny[4] != NULL) - cell_activate_subcell_tasks(ci->progeny[1], cj->progeny[4], s); + cell_activate_subcell_hydro_tasks(ci->progeny[1], cj->progeny[4], s); if (ci->progeny[1] != NULL && cj->progeny[6] != NULL) - cell_activate_subcell_tasks(ci->progeny[1], cj->progeny[6], s); + cell_activate_subcell_hydro_tasks(ci->progeny[1], cj->progeny[6], s); if (ci->progeny[3] != NULL && cj->progeny[0] != NULL) - cell_activate_subcell_tasks(ci->progeny[3], cj->progeny[0], s); + cell_activate_subcell_hydro_tasks(ci->progeny[3], cj->progeny[0], s); if (ci->progeny[3] != NULL && cj->progeny[2] != NULL) - cell_activate_subcell_tasks(ci->progeny[3], cj->progeny[2], s); + cell_activate_subcell_hydro_tasks(ci->progeny[3], cj->progeny[2], s); if (ci->progeny[3] != NULL && cj->progeny[4] != NULL) - cell_activate_subcell_tasks(ci->progeny[3], cj->progeny[4], s); + cell_activate_subcell_hydro_tasks(ci->progeny[3], cj->progeny[4], s); if (ci->progeny[3] != NULL && cj->progeny[6] != NULL) - cell_activate_subcell_tasks(ci->progeny[3], cj->progeny[6], s); + cell_activate_subcell_hydro_tasks(ci->progeny[3], cj->progeny[6], s); if (ci->progeny[5] != NULL && cj->progeny[0] != NULL) - cell_activate_subcell_tasks(ci->progeny[5], cj->progeny[0], s); + cell_activate_subcell_hydro_tasks(ci->progeny[5], cj->progeny[0], s); if (ci->progeny[5] != NULL && cj->progeny[2] != NULL) - cell_activate_subcell_tasks(ci->progeny[5], cj->progeny[2], s); + cell_activate_subcell_hydro_tasks(ci->progeny[5], cj->progeny[2], s); if (ci->progeny[5] != NULL && cj->progeny[4] != NULL) - cell_activate_subcell_tasks(ci->progeny[5], cj->progeny[4], s); + cell_activate_subcell_hydro_tasks(ci->progeny[5], cj->progeny[4], s); if (ci->progeny[5] != NULL && cj->progeny[6] != NULL) - cell_activate_subcell_tasks(ci->progeny[5], cj->progeny[6], s); + cell_activate_subcell_hydro_tasks(ci->progeny[5], cj->progeny[6], s); if (ci->progeny[7] != NULL && cj->progeny[0] != NULL) - cell_activate_subcell_tasks(ci->progeny[7], cj->progeny[0], s); + cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[0], s); if (ci->progeny[7] != NULL && cj->progeny[2] != NULL) - cell_activate_subcell_tasks(ci->progeny[7], cj->progeny[2], s); + cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[2], s); if (ci->progeny[7] != NULL && cj->progeny[4] != NULL) - cell_activate_subcell_tasks(ci->progeny[7], cj->progeny[4], s); + cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[4], s); if (ci->progeny[7] != NULL && cj->progeny[6] != NULL) - cell_activate_subcell_tasks(ci->progeny[7], cj->progeny[6], s); + cell_activate_subcell_hydro_tasks(ci->progeny[7], cj->progeny[6], s); break; } } /* Otherwise, activate the sorts and drifts. */ - else if (cell_is_active(ci, e) || cell_is_active(cj, e)) { + else if (cell_is_active_hydro(ci, e) || cell_is_active_hydro(cj, e)) { /* Get the type of pair if not specified explicitly. */ double shift[3]; @@ -1774,7 +1781,7 @@ void cell_activate_subcell_grav_tasks(struct cell *ci, struct cell *cj, if (cj == NULL) { /* Do anything? */ - if (!cell_is_active(ci, e)) return; + if (!cell_is_active_gravity(ci, e)) return; /* Recurse? */ if (ci->split) { @@ -1800,7 +1807,8 @@ void cell_activate_subcell_grav_tasks(struct cell *ci, struct cell *cj, else { /* Anything to do here? */ - if (!cell_is_active(ci, e) && !cell_is_active(cj, e)) return; + if (!cell_is_active_gravity(ci, e) && !cell_is_active_gravity(cj, e)) + return; if (ci->ti_old_multipole < e->ti_current) cell_drift_multipole(ci, e); if (cj->ti_old_multipole < e->ti_current) cell_drift_multipole(cj, e); @@ -1834,7 +1842,7 @@ void cell_activate_subcell_grav_tasks(struct cell *ci, struct cell *cj, else if (!ci->split && !cj->split) { /* Activate the drifts if the cells are local. */ - if (cell_is_active(ci, e) || cell_is_active(cj, e)) { + if (cell_is_active_gravity(ci, e) || cell_is_active_gravity(cj, e)) { if (ci->nodeID == engine_rank) cell_activate_drift_gpart(ci, s); if (cj->nodeID == engine_rank) cell_activate_drift_gpart(cj, s); } @@ -1903,7 +1911,7 @@ void cell_activate_subcell_external_grav_tasks(struct cell *ci, const struct engine *e = sp->e; /* Do anything? */ - if (!cell_is_active(ci, e)) return; + if (!cell_is_active_gravity(ci, e)) return; /* Recurse? */ if (ci->split) { @@ -1922,7 +1930,7 @@ void cell_activate_subcell_external_grav_tasks(struct cell *ci, } /** - * @brief Un-skips all the tasks associated with a given cell and checks + * @brief Un-skips all the hydro tasks associated with a given cell and checks * if the space needs to be rebuilt. * * @param c the #cell. @@ -1930,7 +1938,7 @@ void cell_activate_subcell_external_grav_tasks(struct cell *ci, * * @return 1 If the space needs rebuilding. 0 otherwise. */ -int cell_unskip_tasks(struct cell *c, struct scheduler *s) { +int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) { struct engine *e = s->space->e; const int nodeID = e->nodeID; @@ -1941,8 +1949,8 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) { struct task *t = l->t; struct cell *ci = t->ci; struct cell *cj = t->cj; - const int ci_active = cell_is_active(ci, e); - const int cj_active = (cj != NULL) ? cell_is_active(cj, e) : 0; + const int ci_active = cell_is_active_hydro(ci, e); + const int cj_active = (cj != NULL) ? cell_is_active_hydro(cj, e) : 0; /* Only activate tasks that involve a local active cell. */ if ((ci_active && ci->nodeID == nodeID) || @@ -1972,7 +1980,7 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) { } /* Store current values of dx_max and h_max. */ else if (t->type == task_type_sub_pair || t->type == task_type_sub_self) { - cell_activate_subcell_tasks(t->ci, t->cj, s); + cell_activate_subcell_hydro_tasks(t->ci, t->cj, s); } } @@ -2068,13 +2076,50 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) { } } + /* Unskip all the other task types. */ + if (c->nodeID == nodeID && cell_is_active_hydro(c, e)) { + + for (struct link *l = c->gradient; l != NULL; l = l->next) + scheduler_activate(s, l->t); + for (struct link *l = c->force; l != NULL; l = l->next) + scheduler_activate(s, l->t); + + if (c->extra_ghost != NULL) scheduler_activate(s, c->extra_ghost); + if (c->ghost_in != NULL) scheduler_activate(s, c->ghost_in); + if (c->ghost_out != NULL) scheduler_activate(s, c->ghost_out); + if (c->ghost != NULL) scheduler_activate(s, c->ghost); + if (c->kick1 != NULL) scheduler_activate(s, c->kick1); + if (c->kick2 != NULL) scheduler_activate(s, c->kick2); + if (c->timestep != NULL) scheduler_activate(s, c->timestep); + if (c->cooling != NULL) scheduler_activate(s, c->cooling); + if (c->sourceterms != NULL) scheduler_activate(s, c->sourceterms); + } + + return rebuild; +} + +/** + * @brief Un-skips all the gravity tasks associated with a given cell and checks + * if the space needs to be rebuilt. + * + * @param c the #cell. + * @param s the #scheduler. + * + * @return 1 If the space needs rebuilding. 0 otherwise. + */ +int cell_unskip_gravity_tasks(struct cell *c, struct scheduler *s) { + + struct engine *e = s->space->e; + const int nodeID = e->nodeID; + int rebuild = 0; + /* Un-skip the gravity tasks involved with this cell. */ for (struct link *l = c->grav; l != NULL; l = l->next) { struct task *t = l->t; struct cell *ci = t->ci; struct cell *cj = t->cj; - const int ci_active = cell_is_active(ci, e); - const int cj_active = (cj != NULL) ? cell_is_active(cj, e) : 0; + const int ci_active = cell_is_active_gravity(ci, e); + const int cj_active = (cj != NULL) ? cell_is_active_gravity(cj, e) : 0; /* Only activate tasks that involve a local active cell. */ if ((ci_active && ci->nodeID == nodeID) || @@ -2149,17 +2194,8 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) { } /* Unskip all the other task types. */ - if (c->nodeID == nodeID && cell_is_active(c, e)) { + if (c->nodeID == nodeID && cell_is_active_gravity(c, e)) { - for (struct link *l = c->gradient; l != NULL; l = l->next) - scheduler_activate(s, l->t); - for (struct link *l = c->force; l != NULL; l = l->next) - scheduler_activate(s, l->t); - - if (c->extra_ghost != NULL) scheduler_activate(s, c->extra_ghost); - if (c->ghost_in != NULL) scheduler_activate(s, c->ghost_in); - if (c->ghost_out != NULL) scheduler_activate(s, c->ghost_out); - if (c->ghost != NULL) scheduler_activate(s, c->ghost); if (c->init_grav != NULL) scheduler_activate(s, c->init_grav); if (c->grav_ghost_in != NULL) scheduler_activate(s, c->grav_ghost_in); if (c->grav_ghost_out != NULL) scheduler_activate(s, c->grav_ghost_out); @@ -2168,8 +2204,6 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) { if (c->timestep != NULL) scheduler_activate(s, c->timestep); if (c->grav_down != NULL) scheduler_activate(s, c->grav_down); if (c->grav_long_range != NULL) scheduler_activate(s, c->grav_long_range); - if (c->cooling != NULL) scheduler_activate(s, c->cooling); - if (c->sourceterms != NULL) scheduler_activate(s, c->sourceterms); } return rebuild; @@ -2568,7 +2602,7 @@ void cell_drift_multipole(struct cell *c, const struct engine *e) { void cell_check_timesteps(struct cell *c) { #ifdef SWIFT_DEBUG_CHECKS - if (c->ti_end_min == 0 && c->nr_tasks > 0) + if (c->ti_hydro_end_min == 0 && c->ti_gravity_end_min == 0 && c->nr_tasks > 0) error("Cell without assigned time-step"); if (c->split) { diff --git a/src/cell.h b/src/cell.h index cf00ef7e57f5949d16e61a5bcd520f5d64139f03..93dfb88b8a58a85d9468a84e2205aa32733e0b23 100644 --- a/src/cell.h +++ b/src/cell.h @@ -80,14 +80,23 @@ struct pcell { /*! Maximal smoothing length. */ double h_max; - /*! Minimal integer end-of-timestep in this cell */ - integertime_t ti_end_min; + /*! Minimal integer end-of-timestep in this cell for hydro tasks */ + integertime_t ti_hydro_end_min; - /*! Maximal integer end-of-timestep in this cell */ - integertime_t ti_end_max; + /*! Maximal integer end-of-timestep in this cell for hydro tasks */ + integertime_t ti_hydro_end_max; - /*! Maximal integer beginning-of-timestep in this cell */ - integertime_t ti_beg_max; + /*! Maximal integer beginning-of-timestep in this cell for hydro tasks */ + integertime_t ti_hydro_beg_max; + + /*! Minimal integer end-of-timestep in this cell for gravity tasks */ + integertime_t ti_gravity_end_min; + + /*! Maximal integer end-of-timestep in this cell for gravity tasks */ + integertime_t ti_gravity_end_max; + + /*! Maximal integer beginning-of-timestep in this cell for gravity tasks */ + integertime_t ti_gravity_beg_max; /*! Integer time of the last drift of the #part in this cell */ integertime_t ti_old_part; @@ -125,8 +134,11 @@ struct pcell { */ struct pcell_step { - /*! Minimal integer end-of-timestep in this cell */ - integertime_t ti_end_min; + /*! Minimal integer end-of-timestep in this cell (hydro) */ + integertime_t ti_hydro_end_min; + + /*! Minimal integer end-of-timestep in this cell (gravity) */ + integertime_t ti_gravity_end_min; /*! Maximal distance any #part has travelled since last rebuild */ float dx_max_part; @@ -295,14 +307,24 @@ struct cell { #endif - /*! Minimum end of (integer) time step in this cell. */ - integertime_t ti_end_min; + /*! Minimum end of (integer) time step in this cell for hydro tasks. */ + integertime_t ti_hydro_end_min; - /*! Maximum end of (integer) time step in this cell. */ - integertime_t ti_end_max; + /*! Maximum end of (integer) time step in this cell for hydro tasks. */ + integertime_t ti_hydro_end_max; - /*! Maximum beginning of (integer) time step in this cell. */ - integertime_t ti_beg_max; + /*! Maximum beginning of (integer) time step in this cell for hydro tasks. */ + integertime_t ti_hydro_beg_max; + + /*! Minimum end of (integer) time step in this cell for gravity tasks. */ + integertime_t ti_gravity_end_min; + + /*! Maximum end of (integer) time step in this cell for gravity tasks. */ + integertime_t ti_gravity_end_max; + + /*! Maximum beginning of (integer) time step in this cell for gravity tasks. + */ + integertime_t ti_gravity_beg_max; /*! Last (integer) time the cell's part were drifted forward in time. */ integertime_t ti_old_part; @@ -470,7 +492,8 @@ void cell_check_part_drift_point(struct cell *c, void *data); void cell_check_gpart_drift_point(struct cell *c, void *data); void cell_check_multipole_drift_point(struct cell *c, void *data); void cell_reset_task_counters(struct cell *c); -int cell_unskip_tasks(struct cell *c, struct scheduler *s); +int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s); +int cell_unskip_gravity_tasks(struct cell *c, struct scheduler *s); void cell_set_super(struct cell *c, struct cell *super); void cell_drift_part(struct cell *c, const struct engine *e, int force); void cell_drift_gpart(struct cell *c, const struct engine *e, int force); @@ -478,8 +501,8 @@ void cell_drift_multipole(struct cell *c, const struct engine *e); void cell_drift_all_multipoles(struct cell *c, const struct engine *e); void cell_check_timesteps(struct cell *c); void cell_store_pre_drift_values(struct cell *c); -void cell_activate_subcell_tasks(struct cell *ci, struct cell *cj, - struct scheduler *s); +void cell_activate_subcell_hydro_tasks(struct cell *ci, struct cell *cj, + struct scheduler *s); void cell_activate_subcell_grav_tasks(struct cell *ci, struct cell *cj, struct scheduler *s); void cell_activate_subcell_external_grav_tasks(struct cell *ci, diff --git a/src/collectgroup.c b/src/collectgroup.c index b7e5486b59a2ec5e47b7b864071a2bb1e5ce1850..221bd82c7c16976298e9fa7309b6fb99c9c91f26 100644 --- a/src/collectgroup.c +++ b/src/collectgroup.c @@ -37,7 +37,8 @@ /* Local collections for MPI reduces. */ struct mpicollectgroup1 { size_t updates, g_updates, s_updates; - integertime_t ti_end_min; + integertime_t ti_hydro_end_min; + integertime_t ti_gravity_end_min; int forcerebuild; }; @@ -75,9 +76,15 @@ void collectgroup_init() { * @param e The #engine */ void collectgroup1_apply(struct collectgroup1 *grp1, struct engine *e) { - e->ti_end_min = grp1->ti_end_min; - e->ti_end_max = grp1->ti_end_max; - e->ti_beg_max = grp1->ti_beg_max; + e->ti_hydro_end_min = grp1->ti_hydro_end_min; + e->ti_hydro_end_max = grp1->ti_hydro_end_max; + e->ti_hydro_beg_max = grp1->ti_hydro_beg_max; + e->ti_gravity_end_min = grp1->ti_gravity_end_min; + e->ti_gravity_end_max = grp1->ti_gravity_end_max; + e->ti_gravity_beg_max = grp1->ti_gravity_beg_max; + e->ti_end_min = min(e->ti_hydro_end_min, e->ti_gravity_end_min); + e->ti_end_max = max(e->ti_hydro_end_max, e->ti_gravity_end_max); + e->ti_beg_max = max(e->ti_hydro_beg_max, e->ti_gravity_beg_max); e->updates = grp1->updates; e->g_updates = grp1->g_updates; e->s_updates = grp1->s_updates; @@ -99,14 +106,21 @@ void collectgroup1_apply(struct collectgroup1 *grp1, struct engine *e) { */ void collectgroup1_init(struct collectgroup1 *grp1, size_t updates, size_t g_updates, size_t s_updates, - integertime_t ti_end_min, integertime_t ti_end_max, - integertime_t ti_beg_max, int forcerebuild) { + integertime_t ti_hydro_end_min, + integertime_t ti_hydro_end_max, + integertime_t ti_hydro_beg_max, + integertime_t ti_gravity_end_min, + integertime_t ti_gravity_end_max, + integertime_t ti_gravity_beg_max, int forcerebuild) { grp1->updates = updates; grp1->g_updates = g_updates; grp1->s_updates = s_updates; - grp1->ti_end_min = ti_end_min; - grp1->ti_end_max = ti_end_max; - grp1->ti_beg_max = ti_beg_max; + grp1->ti_hydro_end_min = ti_hydro_end_min; + grp1->ti_hydro_end_max = ti_hydro_end_max; + grp1->ti_hydro_beg_max = ti_hydro_beg_max; + grp1->ti_gravity_end_min = ti_gravity_end_min; + grp1->ti_gravity_end_max = ti_gravity_end_max; + grp1->ti_gravity_beg_max = ti_gravity_beg_max; grp1->forcerebuild = forcerebuild; } @@ -127,7 +141,8 @@ void collectgroup1_reduce(struct collectgroup1 *grp1) { mpigrp11.updates = grp1->updates; mpigrp11.g_updates = grp1->g_updates; mpigrp11.s_updates = grp1->s_updates; - mpigrp11.ti_end_min = grp1->ti_end_min; + mpigrp11.ti_hydro_end_min = grp1->ti_hydro_end_min; + mpigrp11.ti_gravity_end_min = grp1->ti_gravity_end_min; mpigrp11.forcerebuild = grp1->forcerebuild; struct mpicollectgroup1 mpigrp12; @@ -139,7 +154,8 @@ void collectgroup1_reduce(struct collectgroup1 *grp1) { grp1->updates = mpigrp12.updates; grp1->g_updates = mpigrp12.g_updates; grp1->s_updates = mpigrp12.s_updates; - grp1->ti_end_min = mpigrp12.ti_end_min; + grp1->ti_hydro_end_min = mpigrp12.ti_hydro_end_min; + grp1->ti_gravity_end_min = mpigrp12.ti_gravity_end_min; grp1->forcerebuild = mpigrp12.forcerebuild; #endif @@ -162,7 +178,10 @@ static void doreduce1(struct mpicollectgroup1 *mpigrp11, mpigrp11->s_updates += mpigrp12->s_updates; /* Minimum end time. */ - mpigrp11->ti_end_min = min(mpigrp11->ti_end_min, mpigrp12->ti_end_min); + mpigrp11->ti_hydro_end_min = + min(mpigrp11->ti_hydro_end_min, mpigrp12->ti_hydro_end_min); + mpigrp11->ti_gravity_end_min = + min(mpigrp11->ti_gravity_end_min, mpigrp12->ti_gravity_end_min); /* Everyone must agree to not rebuild. */ if (mpigrp11->forcerebuild || mpigrp12->forcerebuild) diff --git a/src/collectgroup.h b/src/collectgroup.h index b0cbf0763d94dec65ea1aae2c521c1c4b9f7bf83..f2014ed254fdde7ea293224751061d824782b4a7 100644 --- a/src/collectgroup.h +++ b/src/collectgroup.h @@ -38,7 +38,8 @@ struct collectgroup1 { size_t updates, g_updates, s_updates; /* Times for the time-step */ - integertime_t ti_end_min, ti_end_max, ti_beg_max; + integertime_t ti_hydro_end_min, ti_hydro_end_max, ti_hydro_beg_max; + integertime_t ti_gravity_end_min, ti_gravity_end_max, ti_gravity_beg_max; /* Force the engine to rebuild? */ int forcerebuild; @@ -48,8 +49,12 @@ void collectgroup_init(); void collectgroup1_apply(struct collectgroup1 *grp1, struct engine *e); void collectgroup1_init(struct collectgroup1 *grp1, size_t updates, size_t g_updates, size_t s_updates, - integertime_t ti_end_min, integertime_t ti_end_max, - integertime_t ti_beg_max, int forcerebuild); + integertime_t ti_hydro_end_min, + integertime_t ti_hydro_end_max, + integertime_t ti_hydro_beg_max, + integertime_t ti_gravity_end_min, + integertime_t ti_gravity_end_max, + integertime_t ti_gravity_beg_max, int forcerebuild); void collectgroup1_reduce(struct collectgroup1 *grp1); #endif /* SWIFT_COLLECTGROUP_H */ diff --git a/src/debug.c b/src/debug.c index 4c521397b12c555923f8cea8a4f0cdb4c4551b97..9042a5ebe6f1ba6b45e1c113219a816d8eafaffb 100644 --- a/src/debug.c +++ b/src/debug.c @@ -319,7 +319,7 @@ static void dumpCells_map(struct cell *c, void *data) { /* Active cells, otherwise all. */ if (active) - active = cell_is_active(c, e); + active = cell_is_active_hydro(c, e); else active = 1; @@ -346,9 +346,9 @@ static void dumpCells_map(struct cell *c, void *data) { "%6.1f %20lld %6d %6d %6d %6d %6d\n", c->loc[0], c->loc[1], c->loc[2], c->width[0], c->width[1], c->width[2], e->step, c->count, c->gcount, c->scount, pactcount, - c->depth, ntasks, c->ti_end_min, get_time_bin(c->ti_end_min), - (c->super == c), cell_is_active(c, e), c->nodeID, - c->nodeID == e->nodeID); + c->depth, ntasks, c->ti_hydro_end_min, + get_time_bin(c->ti_hydro_end_min), (c->super == c), + cell_is_active_hydro(c, e), c->nodeID, c->nodeID == e->nodeID); } } } diff --git a/src/engine.c b/src/engine.c index 90820b7e3ad7da1b293a5afdd4a7ce554cf1b147..31f2ac653bf7a76a98d0feb0db6b53efe0532e20 100644 --- a/src/engine.c +++ b/src/engine.c @@ -104,7 +104,8 @@ int engine_rank; struct end_of_step_data { int updates, g_updates, s_updates; - integertime_t ti_end_min, ti_end_max, ti_beg_max; + integertime_t ti_hydro_end_min, ti_hydro_end_max, ti_hydro_beg_max; + integertime_t ti_gravity_end_min, ti_gravity_end_max, ti_gravity_beg_max; struct engine *e; }; @@ -3104,24 +3105,42 @@ void engine_marktasks_mapper(void *map_data, int num_elements, if (ci->nodeID != engine_rank) error("Non-local self task found"); - /* Set this task's skip. */ - if (cell_is_active(ci, e)) scheduler_activate(s, t); - /* Activate the hydro drift */ if (t->type == task_type_self && t->subtype == task_subtype_density) { - cell_activate_drift_part(ci, s); - } - /* Activate the gravity drift */ - else if (t->type == task_type_self && t->subtype == task_subtype_grav) { - cell_activate_subcell_grav_tasks(t->ci, NULL, s); + if (cell_is_active_hydro(ci, e)) { + scheduler_activate(s, t); + cell_activate_drift_part(ci, s); + } } + /* Store current values of dx_max and h_max. */ else if (t->type == task_type_sub_self && t->subtype == task_subtype_density) { - cell_activate_subcell_tasks(ci, NULL, s); + if (cell_is_active_hydro(ci, e)) { + scheduler_activate(s, t); + cell_activate_subcell_hydro_tasks(ci, NULL, s); + } + } - } else if (t->type == task_type_sub_self && - t->subtype == task_subtype_grav) { + else if (t->type == task_type_self && t->subtype == task_subtype_force) { + if (cell_is_active_hydro(ci, e)) scheduler_activate(s, t); + } + + else if (t->type == task_type_sub_self && + t->subtype == task_subtype_force) { + if (cell_is_active_hydro(ci, e)) scheduler_activate(s, t); + } + + /* Activate the gravity drift */ + else if (t->type == task_type_self && t->subtype == task_subtype_grav) { + if (cell_is_active_gravity(ci, e)) { + scheduler_activate(s, t); + cell_activate_subcell_grav_tasks(t->ci, NULL, s); + } + } + + else if (t->type == task_type_sub_self && + t->subtype == task_subtype_grav) { error("Invalid task sub-type encountered"); } } @@ -3132,12 +3151,17 @@ void engine_marktasks_mapper(void *map_data, int num_elements, /* Local pointers. */ struct cell *ci = t->ci; struct cell *cj = t->cj; - const int ci_active = cell_is_active(ci, e); - const int cj_active = cell_is_active(cj, e); + const int ci_active_hydro = cell_is_active_hydro(ci, e); + const int cj_active_hydro = cell_is_active_hydro(cj, e); + const int ci_active_gravity = cell_is_active_gravity(ci, e); + const int cj_active_gravity = cell_is_active_gravity(cj, e); /* Only activate tasks that involve a local active cell. */ - if ((ci_active && ci->nodeID == engine_rank) || - (cj_active && cj->nodeID == engine_rank)) { + if ((t->subtype == task_subtype_density || + t->subtype == task_subtype_force) && + ((ci_active_hydro && ci->nodeID == engine_rank) || + (cj_active_hydro && cj->nodeID == engine_rank))) { + scheduler_activate(s, t); /* Set the correct sorting flags */ @@ -3157,19 +3181,28 @@ void engine_marktasks_mapper(void *map_data, int num_elements, cell_activate_sorts(ci, t->flags, s); cell_activate_sorts(cj, t->flags, s); - } else if (t->type == task_type_pair && - t->subtype == task_subtype_grav) { - /* Activate the gravity drift */ - cell_activate_subcell_grav_tasks(t->ci, t->cj, s); } /* Store current values of dx_max and h_max. */ else if (t->type == task_type_sub_pair && t->subtype == task_subtype_density) { - cell_activate_subcell_tasks(t->ci, t->cj, s); + cell_activate_subcell_hydro_tasks(t->ci, t->cj, s); + } + } - } else if (t->type == task_type_sub_pair && - t->subtype == task_subtype_grav) { + if ((t->subtype == task_subtype_grav) && + ((ci_active_gravity && ci->nodeID == engine_rank) || + (cj_active_gravity && cj->nodeID == engine_rank))) { + + scheduler_activate(s, t); + + if (t->type == task_type_pair && t->subtype == task_subtype_grav) { + /* Activate the gravity drift */ + cell_activate_subcell_grav_tasks(t->ci, t->cj, s); + } + + else if (t->type == task_type_sub_pair && + t->subtype == task_subtype_grav) { error("Invalid task sub-type encountered"); } } @@ -3185,9 +3218,9 @@ void engine_marktasks_mapper(void *map_data, int num_elements, if (ci->nodeID != engine_rank) { /* If the local cell is active, receive data from the foreign cell. */ - if (cj_active) { + if (cj_active_hydro) { scheduler_activate(s, ci->recv_xv); - if (ci_active) { + if (ci_active_hydro) { scheduler_activate(s, ci->recv_rho); #ifdef EXTRA_HYDRO_LOOP scheduler_activate(s, ci->recv_gradient); @@ -3196,10 +3229,10 @@ void engine_marktasks_mapper(void *map_data, int num_elements, } /* If the foreign cell is active, we want its ti_end values. */ - if (ci_active) scheduler_activate(s, ci->recv_ti); + if (ci_active_hydro) scheduler_activate(s, ci->recv_ti); /* Is the foreign cell active and will need stuff from us? */ - if (ci_active) { + if (ci_active_hydro) { struct link *l = scheduler_activate_send(s, cj->send_xv, ci->nodeID); @@ -3210,7 +3243,7 @@ void engine_marktasks_mapper(void *map_data, int num_elements, cell_activate_drift_part(l->t->ci, s); /* If the local cell is also active, more stuff will be needed. */ - if (cj_active) { + if (cj_active_hydro) { scheduler_activate_send(s, cj->send_rho, ci->nodeID); #ifdef EXTRA_HYDRO_LOOP @@ -3220,14 +3253,15 @@ void engine_marktasks_mapper(void *map_data, int num_elements, } /* If the local cell is active, send its ti_end values. */ - if (cj_active) scheduler_activate_send(s, cj->send_ti, ci->nodeID); + if (cj_active_hydro) + scheduler_activate_send(s, cj->send_ti, ci->nodeID); } else if (cj->nodeID != engine_rank) { /* If the local cell is active, receive data from the foreign cell. */ - if (ci_active) { + if (ci_active_hydro) { scheduler_activate(s, cj->recv_xv); - if (cj_active) { + if (cj_active_hydro) { scheduler_activate(s, cj->recv_rho); #ifdef EXTRA_HYDRO_LOOP scheduler_activate(s, cj->recv_gradient); @@ -3236,10 +3270,10 @@ void engine_marktasks_mapper(void *map_data, int num_elements, } /* If the foreign cell is active, we want its ti_end values. */ - if (cj_active) scheduler_activate(s, cj->recv_ti); + if (cj_active_hydro) scheduler_activate(s, cj->recv_ti); /* Is the foreign cell active and will need stuff from us? */ - if (cj_active) { + if (cj_active_hydro) { struct link *l = scheduler_activate_send(s, ci->send_xv, cj->nodeID); @@ -3250,7 +3284,7 @@ void engine_marktasks_mapper(void *map_data, int num_elements, cell_activate_drift_part(l->t->ci, s); /* If the local cell is also active, more stuff will be needed. */ - if (ci_active) { + if (ci_active_hydro) { scheduler_activate_send(s, ci->send_rho, cj->nodeID); @@ -3261,7 +3295,8 @@ void engine_marktasks_mapper(void *map_data, int num_elements, } /* If the local cell is active, send its ti_end values. */ - if (ci_active) scheduler_activate_send(s, ci->send_ti, cj->nodeID); + if (ci_active_hydro) + scheduler_activate_send(s, ci->send_ti, cj->nodeID); } #endif } @@ -3274,15 +3309,15 @@ void engine_marktasks_mapper(void *map_data, int num_elements, if (ci->nodeID != engine_rank) { /* If the local cell is active, receive data from the foreign cell. */ - if (cj_active) { + if (cj_active_gravity) { scheduler_activate(s, ci->recv_grav); } /* If the foreign cell is active, we want its ti_end values. */ - if (ci_active) scheduler_activate(s, ci->recv_ti); + if (ci_active_gravity) scheduler_activate(s, ci->recv_ti); /* Is the foreign cell active and will need stuff from us? */ - if (ci_active) { + if (ci_active_gravity) { struct link *l = scheduler_activate_send(s, cj->send_grav, ci->nodeID); @@ -3294,20 +3329,21 @@ void engine_marktasks_mapper(void *map_data, int num_elements, } /* If the local cell is active, send its ti_end values. */ - if (cj_active) scheduler_activate_send(s, cj->send_ti, ci->nodeID); + if (cj_active_gravity) + scheduler_activate_send(s, cj->send_ti, ci->nodeID); } else if (cj->nodeID != engine_rank) { /* If the local cell is active, receive data from the foreign cell. */ - if (ci_active) { + if (ci_active_gravity) { scheduler_activate(s, cj->recv_grav); } /* If the foreign cell is active, we want its ti_end values. */ - if (cj_active) scheduler_activate(s, cj->recv_ti); + if (cj_active_gravity) scheduler_activate(s, cj->recv_ti); /* Is the foreign cell active and will need stuff from us? */ - if (cj_active) { + if (cj_active_gravity) { struct link *l = scheduler_activate_send(s, ci->send_grav, cj->nodeID); @@ -3319,28 +3355,31 @@ void engine_marktasks_mapper(void *map_data, int num_elements, } /* If the local cell is active, send its ti_end values. */ - if (ci_active) scheduler_activate_send(s, ci->send_ti, cj->nodeID); + if (ci_active_gravity) + scheduler_activate_send(s, ci->send_ti, cj->nodeID); } #endif } } /* Kick/init ? */ - else if (t->type == task_type_kick1 || t->type == task_type_kick2 || - t->type == task_type_init_grav) { - if (cell_is_active(t->ci, e)) scheduler_activate(s, t); + else if (t->type == task_type_kick1 || t->type == task_type_kick2) { + + if (cell_is_active_hydro(t->ci, e) || cell_is_active_gravity(t->ci, e)) + scheduler_activate(s, t); } /* Hydro ghost tasks ? */ else if (t->type == task_type_ghost || t->type == task_type_extra_ghost || t->type == task_type_ghost_in || t->type == task_type_ghost_out) { - if (cell_is_active(t->ci, e)) scheduler_activate(s, t); + if (cell_is_active_hydro(t->ci, e)) scheduler_activate(s, t); } /* Gravity stuff ? */ else if (t->type == task_type_grav_down || - t->type == task_type_grav_long_range) { - if (cell_is_active(t->ci, e)) scheduler_activate(s, t); + t->type == task_type_grav_long_range || + t->type == task_type_init_grav) { + if (cell_is_active_gravity(t->ci, e)) scheduler_activate(s, t); } /* Periodic gravity stuff (Note this is not linked to a cell) ? */ @@ -3355,12 +3394,13 @@ void engine_marktasks_mapper(void *map_data, int num_elements, t->ci->updated = 0; t->ci->g_updated = 0; t->ci->s_updated = 0; - if (cell_is_active(t->ci, e)) scheduler_activate(s, t); + if (cell_is_active_hydro(t->ci, e) || cell_is_active_gravity(t->ci, e)) + scheduler_activate(s, t); } /* Subgrid tasks */ else if (t->type == task_type_cooling || t->type == task_type_sourceterms) { - if (cell_is_active(t->ci, e)) scheduler_activate(s, t); + if (cell_is_active_hydro(t->ci, e)) scheduler_activate(s, t); } } } @@ -3376,6 +3416,8 @@ int engine_marktasks(struct engine *e) { const ticks tic = getticks(); int rebuild_space = 0; + message("marktask"); + /* Run through the tasks and mark as skip or not. */ size_t extra_data[3] = {(size_t)e, rebuild_space, (size_t)&e->sched}; threadpool_map(&e->threadpool, engine_marktasks_mapper, s->tasks, s->nr_tasks, @@ -3421,11 +3463,20 @@ void engine_print_task_counts(struct engine *e) { counts[(int)tasks[k].type] += 1; if (tasks[k].type == task_type_send && - tasks[k].subtype == task_subtype_tend) + tasks[k].subtype == task_subtype_tend) { count_send_ti++; + /* message("Send_ti: nodeID_i=%d cellID_i=%ld nodeID_j=%d cellID_j=%ld", + */ + /* tasks[k].ci->nodeID, tasks[k].ci - e->s->cells_top, */ + /* tasks[k].cj->nodeID, tasks[k].cj - e->s->cells_top); */ + } if (tasks[k].type == task_type_recv && - tasks[k].subtype == task_subtype_tend) + tasks[k].subtype == task_subtype_tend) { count_recv_ti++; + /* message("recv_rho: nodeID_i=%d cellID_i=%ld nodeID_j=n/a + * cellID_j=n/a", */ + /* tasks[k].ci->nodeID, tasks[k].ci - e->s->cells_top ); */ + } if (tasks[k].type == task_type_send && tasks[k].subtype == task_subtype_gpart) count_send_gpart++; @@ -3439,11 +3490,18 @@ void engine_print_task_counts(struct engine *e) { tasks[k].subtype == task_subtype_xv) count_recv_xv++; if (tasks[k].type == task_type_send && - tasks[k].subtype == task_subtype_rho) + tasks[k].subtype == task_subtype_rho) { count_send_rho++; + message("Send_rho: nodeID_i=%d cellID_i=%ld nodeID_j=%d cellID_j=%ld", + tasks[k].ci->nodeID, tasks[k].ci - e->s->cells_top, + tasks[k].cj->nodeID, tasks[k].cj - e->s->cells_top); + } if (tasks[k].type == task_type_recv && - tasks[k].subtype == task_subtype_rho) + tasks[k].subtype == task_subtype_rho) { count_recv_rho++; + message("recv_rho: nodeID_i=%d cellID_i=%ld nodeID_j=n/a cellID_j=n/a", + tasks[k].ci->nodeID, tasks[k].ci - e->s->cells_top); + } } } message("Total = %d (per cell = %d)", nr_tasks, @@ -3717,7 +3775,10 @@ void engine_collect_end_of_step_recurse(struct cell *c) { /* Counters for the different quantities. */ int updated = 0, g_updated = 0, s_updated = 0; - integertime_t ti_end_min = max_nr_timesteps, ti_end_max = 0, ti_beg_max = 0; + integertime_t ti_hydro_end_min = max_nr_timesteps, ti_hydro_end_max = 0, + ti_hydro_beg_max = 0; + integertime_t ti_gravity_end_min = max_nr_timesteps, ti_gravity_end_max = 0, + ti_gravity_beg_max = 0; /* Collect the values from the progeny. */ for (int k = 0; k < 8; k++) { @@ -3728,9 +3789,12 @@ void engine_collect_end_of_step_recurse(struct cell *c) { engine_collect_end_of_step_recurse(cp); /* And update */ - ti_end_min = min(ti_end_min, cp->ti_end_min); - ti_end_max = max(ti_end_max, cp->ti_end_max); - ti_beg_max = max(ti_beg_max, cp->ti_beg_max); + ti_hydro_end_min = min(ti_hydro_end_min, cp->ti_hydro_end_min); + ti_hydro_end_max = max(ti_hydro_end_max, cp->ti_hydro_end_max); + ti_hydro_beg_max = max(ti_hydro_beg_max, cp->ti_hydro_beg_max); + ti_gravity_end_min = min(ti_gravity_end_min, cp->ti_gravity_end_min); + ti_gravity_end_max = max(ti_gravity_end_max, cp->ti_gravity_end_max); + ti_gravity_beg_max = max(ti_gravity_beg_max, cp->ti_gravity_beg_max); updated += cp->updated; g_updated += cp->g_updated; s_updated += cp->s_updated; @@ -3743,9 +3807,12 @@ void engine_collect_end_of_step_recurse(struct cell *c) { } /* Store the collected values in the cell. */ - c->ti_end_min = ti_end_min; - c->ti_end_max = ti_end_max; - c->ti_beg_max = ti_beg_max; + c->ti_hydro_end_min = ti_hydro_end_min; + c->ti_hydro_end_max = ti_hydro_end_max; + c->ti_hydro_beg_max = ti_hydro_beg_max; + c->ti_gravity_end_min = ti_gravity_end_min; + c->ti_gravity_end_max = ti_gravity_end_max; + c->ti_gravity_beg_max = ti_gravity_beg_max; c->updated = updated; c->g_updated = g_updated; c->s_updated = s_updated; @@ -3761,7 +3828,10 @@ void engine_collect_end_of_step_mapper(void *map_data, int num_elements, /* Local collectible */ int updates = 0, g_updates = 0, s_updates = 0; - integertime_t ti_end_min = max_nr_timesteps, ti_end_max = 0, ti_beg_max = 0; + integertime_t ti_hydro_end_min = max_nr_timesteps, ti_hydro_end_max = 0, + ti_hydro_beg_max = 0; + integertime_t ti_gravity_end_min = max_nr_timesteps, ti_gravity_end_max = 0, + ti_gravity_beg_max = 0; for (int ind = 0; ind < num_elements; ind++) { struct cell *c = &s->cells_top[local_cells[ind]]; @@ -3772,9 +3842,12 @@ void engine_collect_end_of_step_mapper(void *map_data, int num_elements, engine_collect_end_of_step_recurse(c); /* And aggregate */ - ti_end_min = min(ti_end_min, c->ti_end_min); - ti_end_max = max(ti_end_max, c->ti_end_max); - ti_beg_max = max(ti_beg_max, c->ti_beg_max); + ti_hydro_end_min = min(ti_hydro_end_min, c->ti_hydro_end_min); + ti_hydro_end_max = max(ti_hydro_end_max, c->ti_hydro_end_max); + ti_hydro_beg_max = max(ti_hydro_beg_max, c->ti_hydro_beg_max); + ti_gravity_end_min = min(ti_gravity_end_min, c->ti_gravity_end_min); + ti_gravity_end_max = max(ti_gravity_end_max, c->ti_gravity_end_max); + ti_gravity_beg_max = max(ti_gravity_beg_max, c->ti_gravity_beg_max); updates += c->updated; g_updates += c->g_updated; s_updates += c->s_updated; @@ -3792,9 +3865,15 @@ void engine_collect_end_of_step_mapper(void *map_data, int num_elements, data->updates += updates; data->g_updates += g_updates; data->s_updates += s_updates; - data->ti_end_min = min(ti_end_min, data->ti_end_min); - data->ti_end_max = max(ti_end_max, data->ti_end_max); - data->ti_beg_max = max(ti_beg_max, data->ti_beg_max); + data->ti_hydro_end_min = min(ti_hydro_end_min, data->ti_hydro_end_min); + data->ti_hydro_end_max = max(ti_hydro_end_max, data->ti_hydro_end_max); + data->ti_hydro_beg_max = max(ti_hydro_beg_max, data->ti_hydro_beg_max); + data->ti_gravity_end_min = + min(ti_gravity_end_min, data->ti_gravity_end_min); + data->ti_gravity_end_max = + max(ti_gravity_end_max, data->ti_gravity_end_max); + data->ti_gravity_beg_max = + max(ti_gravity_beg_max, data->ti_gravity_beg_max); } if (lock_unlock(&s->lock) != 0) error("Failed to unlock the space"); } @@ -3822,7 +3901,10 @@ void engine_collect_end_of_step(struct engine *e, int apply) { const struct space *s = e->s; struct end_of_step_data data; data.updates = 0, data.g_updates = 0, data.s_updates = 0; - data.ti_end_min = max_nr_timesteps, data.ti_end_max = 0, data.ti_beg_max = 0; + data.ti_hydro_end_min = max_nr_timesteps, data.ti_hydro_end_max = 0, + data.ti_hydro_beg_max = 0; + data.ti_gravity_end_min = max_nr_timesteps, data.ti_gravity_end_max = 0, + data.ti_gravity_beg_max = 0; data.e = e; /* Collect information from the local top-level cells */ @@ -3831,8 +3913,10 @@ void engine_collect_end_of_step(struct engine *e, int apply) { /* Store these in the temporary collection group. */ collectgroup1_init(&e->collect_group1, data.updates, data.g_updates, - data.s_updates, data.ti_end_min, data.ti_end_max, - data.ti_beg_max, e->forcerebuild); + data.s_updates, data.ti_hydro_end_min, + data.ti_hydro_end_max, data.ti_hydro_beg_max, + data.ti_gravity_end_min, data.ti_gravity_end_max, + data.ti_gravity_beg_max, e->forcerebuild); /* Aggregate collective data from the different nodes for this step. */ #ifdef WITH_MPI @@ -3840,43 +3924,47 @@ void engine_collect_end_of_step(struct engine *e, int apply) { #ifdef SWIFT_DEBUG_CHECKS { - /* Check the above using the original MPI calls. */ - integertime_t in_i[1], out_i[1]; - in_i[0] = 0; - out_i[0] = data.ti_end_min; - if (MPI_Allreduce(out_i, in_i, 1, MPI_LONG_LONG_INT, MPI_MIN, - MPI_COMM_WORLD) != MPI_SUCCESS) - error("Failed to aggregate ti_end_min."); - if (in_i[0] != (long long)e->collect_group1.ti_end_min) - error("Failed to get same ti_end_min, is %lld, should be %lld", in_i[0], - e->collect_group1.ti_end_min); - - long long in_ll[3], out_ll[3]; - out_ll[0] = data.updates; - out_ll[1] = data.g_updates; - out_ll[2] = data.s_updates; - if (MPI_Allreduce(out_ll, in_ll, 3, MPI_LONG_LONG_INT, MPI_SUM, - MPI_COMM_WORLD) != MPI_SUCCESS) - error("Failed to aggregate particle counts."); - if (in_ll[0] != (long long)e->collect_group1.updates) - error("Failed to get same updates, is %lld, should be %ld", in_ll[0], - e->collect_group1.updates); - if (in_ll[1] != (long long)e->collect_group1.g_updates) - error("Failed to get same g_updates, is %lld, should be %ld", in_ll[1], - e->collect_group1.g_updates); - if (in_ll[2] != (long long)e->collect_group1.s_updates) - error("Failed to get same s_updates, is %lld, should be %ld", in_ll[2], - e->collect_group1.s_updates); - - int buff = 0; - if (MPI_Allreduce(&e->forcerebuild, &buff, 1, MPI_INT, MPI_MAX, - MPI_COMM_WORLD) != MPI_SUCCESS) - error("Failed to aggregate the rebuild flag across nodes."); - if (!!buff != !!e->collect_group1.forcerebuild) - error( - "Failed to get same rebuild flag from all nodes, is %d," - "should be %d", - buff, e->collect_group1.forcerebuild); + /* /\* Check the above using the original MPI calls. *\/ */ + /* integertime_t in_i[1], out_i[1]; */ + /* in_i[0] = 0; */ + /* out_i[0] = data.ti_end_min; */ + /* if (MPI_Allreduce(out_i, in_i, 1, MPI_LONG_LONG_INT, MPI_MIN, */ + /* MPI_COMM_WORLD) != MPI_SUCCESS) */ + /* error("Failed to aggregate ti_end_min."); */ + /* if (in_i[0] != (long long)e->collect_group1.ti_end_min) */ + /* error("Failed to get same ti_end_min, is %lld, should be %lld", + * in_i[0], */ + /* e->collect_group1.ti_end_min); */ + + /* long long in_ll[3], out_ll[3]; */ + /* out_ll[0] = data.updates; */ + /* out_ll[1] = data.g_updates; */ + /* out_ll[2] = data.s_updates; */ + /* if (MPI_Allreduce(out_ll, in_ll, 3, MPI_LONG_LONG_INT, MPI_SUM, */ + /* MPI_COMM_WORLD) != MPI_SUCCESS) */ + /* error("Failed to aggregate particle counts."); */ + /* if (in_ll[0] != (long long)e->collect_group1.updates) */ + /* error("Failed to get same updates, is %lld, should be %ld", in_ll[0], + */ + /* e->collect_group1.updates); */ + /* if (in_ll[1] != (long long)e->collect_group1.g_updates) */ + /* error("Failed to get same g_updates, is %lld, should be %ld", in_ll[1], + */ + /* e->collect_group1.g_updates); */ + /* if (in_ll[2] != (long long)e->collect_group1.s_updates) */ + /* error("Failed to get same s_updates, is %lld, should be %ld", in_ll[2], + */ + /* e->collect_group1.s_updates); */ + + /* int buff = 0; */ + /* if (MPI_Allreduce(&e->forcerebuild, &buff, 1, MPI_INT, MPI_MAX, */ + /* MPI_COMM_WORLD) != MPI_SUCCESS) */ + /* error("Failed to aggregate the rebuild flag across nodes."); */ + /* if (!!buff != !!e->collect_group1.forcerebuild) */ + /* error( */ + /* "Failed to get same rebuild flag from all nodes, is %d," */ + /* "should be %d", */ + /* buff, e->collect_group1.forcerebuild); */ } #endif #endif @@ -4224,6 +4312,8 @@ void engine_init_particles(struct engine *e, int flag_entropy_ICs, if (e->verbose) message("took %.3f %s.", e->wallclock_time, clocks_getunit()); } +integertime_t *address = 0; + /** * @brief Let the #engine loose to compute the forces. * @@ -4267,6 +4357,21 @@ void engine_step(struct engine *e) { /* Prepare the tasks to be launched, rebuild or repartition if needed. */ engine_prepare(e); + engine_print_task_counts(e); + space_print_cells(e->s); + +/* /\* Register the time-step information *\/ */ +/* if(e->step == 3) { */ + +/* for(int i = 0; i< e->s->nr_cells; ++i) */ +/* if(&e->s->cells_top[i] - e->s->cells_top == 12) { */ +/* message("Found cell!"); */ +/* address = &e->s->cells_top[i].ti_end_min; */ +/* message("address: %p time_end=%lld", address, + * e->s->cells_top[i].ti_end_min); */ +/* } */ +/* } */ + #ifdef WITH_MPI /* Repartition the space amongst the nodes? */ engine_repartition_trigger(e); @@ -4403,6 +4508,8 @@ void engine_unskip(struct engine *e) { const ticks tic = getticks(); + message("unskip"); + /* Activate all the regular tasks */ threadpool_map(&e->threadpool, runner_do_unskip_mapper, e->s->local_cells_top, e->s->nr_local_cells, sizeof(int), 1, e); diff --git a/src/engine.h b/src/engine.h index f7a0ddd0d277d9815a67fb5da96dc3ab45808c3a..a571f2b24d57b2720c3c77ebd7600a3830e4d2a3 100644 --- a/src/engine.h +++ b/src/engine.h @@ -147,13 +147,31 @@ struct engine { double timeBase; double timeBase_inv; - /* Minimal ti_end for the next time-step */ + /* Minimal hydro ti_end for the next time-step */ + integertime_t ti_hydro_end_min; + + /* Maximal hydro ti_end for the next time-step */ + integertime_t ti_hydro_end_max; + + /* Maximal hydro ti_beg for the next time-step */ + integertime_t ti_hydro_beg_max; + + /* Minimal gravity ti_end for the next time-step */ + integertime_t ti_gravity_end_min; + + /* Maximal gravity ti_end for the next time-step */ + integertime_t ti_gravity_end_max; + + /* Maximal gravity ti_beg for the next time-step */ + integertime_t ti_gravity_beg_max; + + /* Minimal overall ti_end for the next time-step */ integertime_t ti_end_min; - /* Maximal ti_end for the next time-step */ + /* Maximal overall ti_end for the next time-step */ integertime_t ti_end_max; - /* Maximal ti_beg for the next time-step */ + /* Maximal overall ti_beg for the next time-step */ integertime_t ti_beg_max; /* Number of particles updated in the previous step */ diff --git a/src/runner.c b/src/runner.c index 818fee226705a33ddb30fdb619e9f7175018fdde..39e314a79e30053c5a87ec2186ca6dd712d3c2b6 100644 --- a/src/runner.c +++ b/src/runner.c @@ -139,7 +139,7 @@ void runner_do_grav_external(struct runner *r, struct cell *c, int timer) { TIMER_TIC; /* Anything to do here? */ - if (!cell_is_active(c, e)) return; + if (!cell_is_active_gravity(c, e)) return; /* Recurse? */ if (c->split) { @@ -185,7 +185,7 @@ void runner_do_cooling(struct runner *r, struct cell *c, int timer) { TIMER_TIC; /* Anything to do here? */ - if (!cell_is_active(c, e)) return; + if (!cell_is_active_hydro(c, e)) return; /* Recurse? */ if (c->split) { @@ -304,7 +304,8 @@ void runner_check_sorts(struct cell *c, int flags) { if (flags & ~c->sorted) error("Inconsistent sort flags (downward)!"); if (c->split) for (int k = 0; k < 8; k++) - if (c->progeny[k] != NULL) runner_check_sorts(c->progeny[k], c->sorted); + if (c->progeny[k] != NULL && c->progeny[k]->count > 0) + runner_check_sorts(c->progeny[k], c->sorted); #else error("Calling debugging code without debugging flag activated."); #endif @@ -343,7 +344,7 @@ void runner_do_sort(struct runner *r, struct cell *c, int flags, int cleanup, /* Check that the particles have been moved to the current time */ if (flags && !cell_are_part_drifted(c, r->e)) - error("Sorting un-drifted cell"); + error("Sorting un-drifted cell c->nodeID=%d", c->nodeID); #ifdef SWIFT_DEBUG_CHECKS /* Make sure the sort flags are consistent (downward). */ @@ -376,7 +377,7 @@ void runner_do_sort(struct runner *r, struct cell *c, int flags, int cleanup, float dx_max_sort = 0.0f; float dx_max_sort_old = 0.0f; for (int k = 0; k < 8; k++) { - if (c->progeny[k] != NULL) { + if (c->progeny[k] != NULL && c->progeny[k]->count > 0) { /* Only propagate cleanup if the progeny is stale. */ runner_do_sort(r, c->progeny[k], flags, cleanup && (c->progeny[k]->dx_max_sort > @@ -550,7 +551,7 @@ void runner_do_init_grav(struct runner *r, struct cell *c, int timer) { #endif /* Anything to do here? */ - if (!cell_is_active(c, e)) return; + if (!cell_is_active_gravity(c, e)) return; /* Reset the gravity acceleration tensors */ gravity_field_tensors_init(&c->multipole->pot, e->ti_current); @@ -584,7 +585,7 @@ void runner_do_extra_ghost(struct runner *r, struct cell *c, int timer) { TIMER_TIC; /* Anything to do here? */ - if (!cell_is_active(c, e)) return; + if (!cell_is_active_hydro(c, e)) return; /* Recurse? */ if (c->split) { @@ -637,7 +638,7 @@ void runner_do_ghost(struct runner *r, struct cell *c, int timer) { TIMER_TIC; /* Anything to do here? */ - if (!cell_is_active(c, e)) return; + if (!cell_is_active_hydro(c, e)) return; /* Recurse? */ if (c->split) { @@ -830,34 +831,63 @@ void runner_do_ghost(struct runner *r, struct cell *c, int timer) { } /** - * @brief Unskip any tasks associated with active cells. + * @brief Unskip any hydro tasks associated with active cells. * * @param c The cell. * @param e The engine. */ -static void runner_do_unskip(struct cell *c, struct engine *e) { +static void runner_do_unskip_hydro(struct cell *c, struct engine *e) { /* Ignore empty cells. */ - if (c->count == 0 && c->gcount == 0) return; + if (c->count == 0) return; /* Skip inactive cells. */ - if (!cell_is_active(c, e)) return; + if (!cell_is_active_hydro(c, e)) return; /* Recurse */ if (c->split) { for (int k = 0; k < 8; k++) { if (c->progeny[k] != NULL) { struct cell *cp = c->progeny[k]; - runner_do_unskip(cp, e); + runner_do_unskip_hydro(cp, e); } } } /* Unskip any active tasks. */ - const int forcerebuild = cell_unskip_tasks(c, &e->sched); + const int forcerebuild = cell_unskip_hydro_tasks(c, &e->sched); if (forcerebuild) atomic_inc(&e->forcerebuild); } +/** + * @brief Unskip any gravity tasks associated with active cells. + * + * @param c The cell. + * @param e The engine. + */ +static void runner_do_unskip_gravity(struct cell *c, struct engine *e) { + + /* Ignore empty cells. */ + if (c->gcount == 0) return; + + /* Skip inactive cells. */ + if (!cell_is_active_gravity(c, e)) return; + + /* Recurse */ + if (c->split) { + for (int k = 0; k < 8; k++) { + if (c->progeny[k] != NULL) { + struct cell *cp = c->progeny[k]; + runner_do_unskip_gravity(cp, e); + } + } + } + + /* Unskip any active tasks. */ + cell_unskip_gravity_tasks(c, &e->sched); +} + + /** * @brief Mapper function to unskip active tasks. * @@ -874,7 +904,12 @@ void runner_do_unskip_mapper(void *map_data, int num_elements, for (int ind = 0; ind < num_elements; ind++) { struct cell *c = &s->cells_top[local_cells[ind]]; - if (c != NULL) runner_do_unskip(c, e); + if (c != NULL) { + if(e->policy & engine_policy_hydro) + runner_do_unskip_hydro(c, e); + if(e->policy & (engine_policy_self_gravity | engine_policy_external_gravity)) + runner_do_unskip_gravity(c, e); + } } } /** @@ -932,7 +967,7 @@ void runner_do_kick1(struct runner *r, struct cell *c, int timer) { TIMER_TIC; /* Anything to do here? */ - if (!cell_is_starting(c, e)) return; + if (!cell_is_starting_hydro(c, e) && !cell_is_starting_gravity(c, e)) return; /* Recurse? */ if (c->split) { @@ -1057,7 +1092,7 @@ void runner_do_kick2(struct runner *r, struct cell *c, int timer) { TIMER_TIC; /* Anything to do here? */ - if (!cell_is_active(c, e)) return; + if (!cell_is_active_hydro(c, e) && !cell_is_active_gravity(c, e)) return; /* Recurse? */ if (c->split) { @@ -1191,7 +1226,7 @@ void runner_do_timestep(struct runner *r, struct cell *c, int timer) { TIMER_TIC; /* Anything to do here? */ - if (!cell_is_active(c, e)) { + if (!cell_is_active_hydro(c, e) && !cell_is_active_gravity(c, e)) { c->updated = 0; c->g_updated = 0; c->s_updated = 0; @@ -1199,7 +1234,10 @@ void runner_do_timestep(struct runner *r, struct cell *c, int timer) { } int updated = 0, g_updated = 0, s_updated = 0; - integertime_t ti_end_min = max_nr_timesteps, ti_end_max = 0, ti_beg_max = 0; + integertime_t ti_hydro_end_min = max_nr_timesteps, ti_hydro_end_max = 0, + ti_hydro_beg_max = 0; + integertime_t ti_gravity_end_min = max_nr_timesteps, ti_gravity_end_max = 0, + ti_gravity_beg_max = 0; /* No children? */ if (!c->split) { @@ -1228,7 +1266,7 @@ void runner_do_timestep(struct runner *r, struct cell *c, int timer) { /* Update particle */ p->time_bin = get_time_bin(ti_new_step); - if (p->gpart != NULL) p->gpart->time_bin = get_time_bin(ti_new_step); + if (p->gpart != NULL) p->gpart->time_bin = p->time_bin; /* Tell the particle what the new physical time step is */ float dt = get_timestep(p->time_bin, timeBase); @@ -1239,11 +1277,21 @@ void runner_do_timestep(struct runner *r, struct cell *c, int timer) { if (p->gpart != NULL) g_updated++; /* What is the next sync-point ? */ - ti_end_min = min(ti_current + ti_new_step, ti_end_min); - ti_end_max = max(ti_current + ti_new_step, ti_end_max); + ti_hydro_end_min = min(ti_current + ti_new_step, ti_hydro_end_min); + ti_hydro_end_max = max(ti_current + ti_new_step, ti_hydro_end_max); /* What is the next starting point for this cell ? */ - ti_beg_max = max(ti_current, ti_beg_max); + ti_hydro_beg_max = max(ti_current, ti_hydro_beg_max); + + if(p->gpart != NULL) { + + /* What is the next sync-point ? */ + ti_gravity_end_min = min(ti_current + ti_new_step, ti_gravity_end_min); + ti_gravity_end_max = max(ti_current + ti_new_step, ti_gravity_end_max); + + /* What is the next starting point for this cell ? */ + ti_gravity_beg_max = max(ti_current, ti_gravity_beg_max); + } } else { /* part is inactive */ @@ -1251,15 +1299,25 @@ void runner_do_timestep(struct runner *r, struct cell *c, int timer) { const integertime_t ti_end = get_integer_time_end(ti_current, p->time_bin); - /* What is the next sync-point ? */ - ti_end_min = min(ti_end, ti_end_min); - ti_end_max = max(ti_end, ti_end_max); - const integertime_t ti_beg = get_integer_time_begin(ti_current + 1, p->time_bin); + /* What is the next sync-point ? */ + ti_hydro_end_min = min(ti_end, ti_hydro_end_min); + ti_hydro_end_max = max(ti_end, ti_hydro_end_max); + /* What is the next starting point for this cell ? */ - ti_beg_max = max(ti_beg, ti_beg_max); + ti_hydro_beg_max = max(ti_beg, ti_hydro_beg_max); + + if(p->gpart != NULL) { + + /* What is the next sync-point ? */ + ti_gravity_end_min = min(ti_end, ti_gravity_end_min); + ti_gravity_end_max = max(ti_end, ti_gravity_end_max); + + /* What is the next starting point for this cell ? */ + ti_gravity_beg_max = max(ti_beg, ti_gravity_beg_max); + } } } @@ -1294,11 +1352,13 @@ void runner_do_timestep(struct runner *r, struct cell *c, int timer) { g_updated++; /* What is the next sync-point ? */ - ti_end_min = min(ti_current + ti_new_step, ti_end_min); - ti_end_max = max(ti_current + ti_new_step, ti_end_max); + ti_gravity_end_min = + min(ti_current + ti_new_step, ti_gravity_end_min); + ti_gravity_end_max = + max(ti_current + ti_new_step, ti_gravity_end_max); /* What is the next starting point for this cell ? */ - ti_beg_max = max(ti_current, ti_beg_max); + ti_gravity_beg_max = max(ti_current, ti_gravity_beg_max); } else { /* gpart is inactive */ @@ -1306,14 +1366,14 @@ void runner_do_timestep(struct runner *r, struct cell *c, int timer) { get_integer_time_end(ti_current, gp->time_bin); /* What is the next sync-point ? */ - ti_end_min = min(ti_end, ti_end_min); - ti_end_max = max(ti_end, ti_end_max); + ti_gravity_end_min = min(ti_end, ti_gravity_end_min); + ti_gravity_end_max = max(ti_end, ti_gravity_end_max); const integertime_t ti_beg = get_integer_time_begin(ti_current + 1, gp->time_bin); /* What is the next starting point for this cell ? */ - ti_beg_max = max(ti_beg, ti_beg_max); + ti_gravity_beg_max = max(ti_beg, ti_gravity_beg_max); } } } @@ -1347,11 +1407,11 @@ void runner_do_timestep(struct runner *r, struct cell *c, int timer) { g_updated++; /* What is the next sync-point ? */ - ti_end_min = min(ti_current + ti_new_step, ti_end_min); - ti_end_max = max(ti_current + ti_new_step, ti_end_max); + ti_gravity_end_min = min(ti_current + ti_new_step, ti_gravity_end_min); + ti_gravity_end_max = max(ti_current + ti_new_step, ti_gravity_end_max); /* What is the next starting point for this cell ? */ - ti_beg_max = max(ti_current, ti_beg_max); + ti_gravity_beg_max = max(ti_current, ti_gravity_beg_max); } else { /* star particle is inactive */ @@ -1359,14 +1419,14 @@ void runner_do_timestep(struct runner *r, struct cell *c, int timer) { get_integer_time_end(ti_current, sp->time_bin); /* What is the next sync-point ? */ - ti_end_min = min(ti_end, ti_end_min); - ti_end_max = max(ti_end, ti_end_max); + ti_gravity_end_min = min(ti_end, ti_gravity_end_min); + ti_gravity_end_max = max(ti_end, ti_gravity_end_max); const integertime_t ti_beg = get_integer_time_begin(ti_current + 1, sp->time_bin); /* What is the next starting point for this cell ? */ - ti_beg_max = max(ti_beg, ti_beg_max); + ti_gravity_beg_max = max(ti_beg, ti_gravity_beg_max); } } } else { @@ -1383,9 +1443,12 @@ void runner_do_timestep(struct runner *r, struct cell *c, int timer) { updated += cp->updated; g_updated += cp->g_updated; s_updated += cp->s_updated; - ti_end_min = min(cp->ti_end_min, ti_end_min); - ti_end_max = max(cp->ti_end_max, ti_end_max); - ti_beg_max = max(cp->ti_beg_max, ti_beg_max); + ti_hydro_end_min = min(cp->ti_hydro_end_min, ti_hydro_end_min); + ti_hydro_end_max = max(cp->ti_hydro_end_max, ti_hydro_end_max); + ti_hydro_beg_max = max(cp->ti_hydro_beg_max, ti_hydro_beg_max); + ti_gravity_end_min = min(cp->ti_gravity_end_min, ti_gravity_end_min); + ti_gravity_end_max = max(cp->ti_gravity_end_max, ti_gravity_end_max); + ti_gravity_beg_max = max(cp->ti_gravity_beg_max, ti_gravity_beg_max); } } @@ -1393,9 +1456,12 @@ void runner_do_timestep(struct runner *r, struct cell *c, int timer) { c->updated = updated; c->g_updated = g_updated; c->s_updated = s_updated; - c->ti_end_min = ti_end_min; - c->ti_end_max = ti_end_max; - c->ti_beg_max = ti_beg_max; + c->ti_hydro_end_min = ti_hydro_end_min; + c->ti_hydro_end_max = ti_hydro_end_max; + c->ti_hydro_beg_max = ti_hydro_beg_max; + c->ti_gravity_end_min = ti_gravity_end_min; + c->ti_gravity_end_max = ti_gravity_end_max; + c->ti_gravity_beg_max = ti_gravity_beg_max; if (timer) TIMER_TOC(timer_timestep); } @@ -1422,7 +1488,7 @@ void runner_do_end_force(struct runner *r, struct cell *c, int timer) { TIMER_TIC; /* Anything to do here? */ - if (!cell_is_active(c, e)) return; + if (!cell_is_active_hydro(c, e) && !cell_is_active_gravity(c, e)) return; /* Recurse? */ if (c->split) { @@ -1526,8 +1592,8 @@ void runner_do_recv_part(struct runner *r, struct cell *c, int clear_sorts, TIMER_TIC; - integertime_t ti_end_min = max_nr_timesteps; - integertime_t ti_end_max = 0; + integertime_t ti_hydro_end_min = max_nr_timesteps; + integertime_t ti_hydro_end_max = 0; timebin_t time_bin_min = num_time_bins; timebin_t time_bin_max = 0; float h_max = 0.f; @@ -1551,33 +1617,35 @@ void runner_do_recv_part(struct runner *r, struct cell *c, int clear_sorts, } /* Convert into a time */ - ti_end_min = get_integer_time_end(ti_current, time_bin_min); - ti_end_max = get_integer_time_end(ti_current, time_bin_max); + ti_hydro_end_min = get_integer_time_end(ti_current, time_bin_min); + ti_hydro_end_max = get_integer_time_end(ti_current, time_bin_max); } /* Otherwise, recurse and collect. */ else { for (int k = 0; k < 8; k++) { - if (c->progeny[k] != NULL) { + if (c->progeny[k] != NULL && c->progeny[k]->count > 0) { runner_do_recv_part(r, c->progeny[k], clear_sorts, 0); - ti_end_min = min(ti_end_min, c->progeny[k]->ti_end_min); - ti_end_max = max(ti_end_max, c->progeny[k]->ti_end_max); + ti_hydro_end_min = + min(ti_hydro_end_min, c->progeny[k]->ti_hydro_end_min); + ti_hydro_end_max = + max(ti_hydro_end_max, c->progeny[k]->ti_hydro_end_max); h_max = max(h_max, c->progeny[k]->h_max); } } } #ifdef SWIFT_DEBUG_CHECKS - if (ti_end_min < ti_current) + if (ti_hydro_end_min < ti_current) error( "Received a cell at an incorrect time c->ti_end_min=%lld, " "e->ti_current=%lld.", - ti_end_min, ti_current); + ti_hydro_end_min, ti_current); #endif /* ... and store. */ - c->ti_end_min = ti_end_min; - c->ti_end_max = ti_end_max; + c->ti_hydro_end_min = ti_hydro_end_min; + c->ti_hydro_end_max = ti_hydro_end_max; c->ti_old_part = ti_current; c->h_max = h_max; @@ -1605,8 +1673,8 @@ void runner_do_recv_gpart(struct runner *r, struct cell *c, int timer) { TIMER_TIC; - integertime_t ti_end_min = max_nr_timesteps; - integertime_t ti_end_max = 0; + integertime_t ti_gravity_end_min = max_nr_timesteps; + integertime_t ti_gravity_end_max = 0; timebin_t time_bin_min = num_time_bins; timebin_t time_bin_max = 0; @@ -1630,32 +1698,34 @@ void runner_do_recv_gpart(struct runner *r, struct cell *c, int timer) { } /* Convert into a time */ - ti_end_min = get_integer_time_end(ti_current, time_bin_min); - ti_end_max = get_integer_time_end(ti_current, time_bin_max); + ti_gravity_end_min = get_integer_time_end(ti_current, time_bin_min); + ti_gravity_end_max = get_integer_time_end(ti_current, time_bin_max); } /* Otherwise, recurse and collect. */ else { for (int k = 0; k < 8; k++) { - if (c->progeny[k] != NULL) { + if (c->progeny[k] != NULL && c->progeny[k]->gcount > 0) { runner_do_recv_gpart(r, c->progeny[k], 0); - ti_end_min = min(ti_end_min, c->progeny[k]->ti_end_min); - ti_end_max = max(ti_end_max, c->progeny[k]->ti_end_max); + ti_gravity_end_min = + min(ti_gravity_end_min, c->progeny[k]->ti_gravity_end_min); + ti_gravity_end_max = + max(ti_gravity_end_max, c->progeny[k]->ti_gravity_end_max); } } } #ifdef SWIFT_DEBUG_CHECKS - if (ti_end_min < ti_current) + if (ti_gravity_end_min < ti_current) error( "Received a cell at an incorrect time c->ti_end_min=%lld, " "e->ti_current=%lld.", - ti_end_min, ti_current); + ti_gravity_end_min, ti_current); #endif /* ... and store. */ - c->ti_end_min = ti_end_min; - c->ti_end_max = ti_end_max; + c->ti_gravity_end_min = ti_gravity_end_min; + c->ti_gravity_end_max = ti_gravity_end_max; c->ti_old_gpart = ti_current; if (timer) TIMER_TOC(timer_dorecv_gpart); @@ -1682,8 +1752,8 @@ void runner_do_recv_spart(struct runner *r, struct cell *c, int timer) { TIMER_TIC; - integertime_t ti_end_min = max_nr_timesteps; - integertime_t ti_end_max = 0; + integertime_t ti_gravity_end_min = max_nr_timesteps; + integertime_t ti_gravity_end_max = 0; timebin_t time_bin_min = num_time_bins; timebin_t time_bin_max = 0; @@ -1707,32 +1777,34 @@ void runner_do_recv_spart(struct runner *r, struct cell *c, int timer) { } /* Convert into a time */ - ti_end_min = get_integer_time_end(ti_current, time_bin_min); - ti_end_max = get_integer_time_end(ti_current, time_bin_max); + ti_gravity_end_min = get_integer_time_end(ti_current, time_bin_min); + ti_gravity_end_max = get_integer_time_end(ti_current, time_bin_max); } /* Otherwise, recurse and collect. */ else { for (int k = 0; k < 8; k++) { - if (c->progeny[k] != NULL) { + if (c->progeny[k] != NULL && c->progeny[k]->scount > 0) { runner_do_recv_spart(r, c->progeny[k], 0); - ti_end_min = min(ti_end_min, c->progeny[k]->ti_end_min); - ti_end_max = max(ti_end_max, c->progeny[k]->ti_end_max); + ti_gravity_end_min = + min(ti_gravity_end_min, c->progeny[k]->ti_gravity_end_min); + ti_gravity_end_max = + max(ti_gravity_end_max, c->progeny[k]->ti_gravity_end_max); } } } #ifdef SWIFT_DEBUG_CHECKS - if (ti_end_min < ti_current) + if (ti_gravity_end_min < ti_current) error( "Received a cell at an incorrect time c->ti_end_min=%lld, " "e->ti_current=%lld.", - ti_end_min, ti_current); + ti_gravity_end_min, ti_current); #endif /* ... and store. */ - c->ti_end_min = ti_end_min; - c->ti_end_max = ti_end_max; + c->ti_gravity_end_min = ti_gravity_end_min; + c->ti_gravity_end_max = ti_gravity_end_max; c->ti_old_gpart = ti_current; if (timer) TIMER_TOC(timer_dorecv_spart); @@ -1801,54 +1873,62 @@ void *runner_main(void *data) { /* Check that we haven't scheduled an inactive task */ #ifdef SWIFT_DEBUG_CHECKS t->ti_run = e->ti_current; -#ifndef WITH_MPI - if (t->type == task_type_grav_top_level) { - if (ci != NULL || cj != NULL) - error("Top-level gravity task associated with a cell"); - } else if (ci == NULL && cj == NULL) { - - error("Task not associated with cells!"); - } else if (cj == NULL) { /* self */ - - if (!cell_is_active(ci, e) && t->type != task_type_sort && - t->type != task_type_send && t->type != task_type_recv && - t->type != task_type_kick1 && t->type != task_type_drift_part && - t->type != task_type_drift_gpart) - error( - "Task (type='%s/%s') should have been skipped ti_current=%lld " - "c->ti_end_min=%lld", - taskID_names[t->type], subtaskID_names[t->subtype], e->ti_current, - ci->ti_end_min); - - /* Special case for sorts */ - if (!cell_is_active(ci, e) && t->type == task_type_sort && - !(ci->do_sort || ci->do_sub_sort)) - error( - "Task (type='%s/%s') should have been skipped ti_current=%lld " - "c->ti_end_min=%lld t->flags=%d", - taskID_names[t->type], subtaskID_names[t->subtype], e->ti_current, - ci->ti_end_min, t->flags); - - /* Special case for kick1 */ - if (!cell_is_starting(ci, e) && t->type == task_type_kick1 && - t->flags == 0) - error( - "Task (type='%s/%s') should have been skipped ti_current=%lld " - "c->ti_end_min=%lld t->flags=%d", - taskID_names[t->type], subtaskID_names[t->subtype], e->ti_current, - ci->ti_end_min, t->flags); - - } else { /* pair */ - if (!cell_is_active(ci, e) && !cell_is_active(cj, e)) - - if (t->type != task_type_send && t->type != task_type_recv) - error( - "Task (type='%s/%s') should have been skipped ti_current=%lld " - "ci->ti_end_min=%lld cj->ti_end_min=%lld", - taskID_names[t->type], subtaskID_names[t->subtype], - e->ti_current, ci->ti_end_min, cj->ti_end_min); - } -#endif +/* #ifndef WITH_MPI */ +/* if (t->type == task_type_grav_top_level) { */ +/* if (ci != NULL || cj != NULL) */ +/* error("Top-level gravity task associated with a cell"); */ +/* } else if (ci == NULL && cj == NULL) { */ + +/* error("Task not associated with cells!"); */ +/* } else if (cj == NULL) { /\* self *\/ */ + +/* if (!cell_is_active_hydro(ci, e) && t->type != task_type_sort && */ +/* t->type != task_type_send && t->type != task_type_recv && */ +/* t->type != task_type_kick1 && t->type != task_type_drift_part && + */ +/* t->type != task_type_drift_gpart) */ +/* error( */ +/* "Task (type='%s/%s') should have been skipped ti_current=%lld " + */ +/* "c->ti_end_min=%lld", */ +/* taskID_names[t->type], subtaskID_names[t->subtype], + * e->ti_current, */ +/* ci->ti_end_min); */ + +/* /\* Special case for sorts *\/ */ +/* if (!cell_is_active_hydro(ci, e) && t->type == task_type_sort && */ +/* !(ci->do_sort || ci->do_sub_sort)) */ +/* error( */ +/* "Task (type='%s/%s') should have been skipped ti_current=%lld " + */ +/* "c->ti_end_min=%lld t->flags=%d", */ +/* taskID_names[t->type], subtaskID_names[t->subtype], + * e->ti_current, */ +/* ci->ti_end_min, t->flags); */ + +/* /\* Special case for kick1 *\/ */ +/* if (!cell_is_starting(ci, e) && t->type == task_type_kick1 && */ +/* t->flags == 0) */ +/* error( */ +/* "Task (type='%s/%s') should have been skipped ti_current=%lld " + */ +/* "c->ti_end_min=%lld t->flags=%d", */ +/* taskID_names[t->type], subtaskID_names[t->subtype], + * e->ti_current, */ +/* ci->ti_end_min, t->flags); */ + +/* } else { /\* pair *\/ */ +/* if (!cell_is_active_hydro(ci, e) && !cell_is_active_hydro(cj, e)) */ + +/* if (t->type != task_type_send && t->type != task_type_recv) */ +/* error( */ +/* "Task (type='%s/%s') should have been skipped ti_current=%lld + * " */ +/* "ci->ti_end_min=%lld cj->ti_end_min=%lld", */ +/* taskID_names[t->type], subtaskID_names[t->subtype], */ +/* e->ti_current, ci->ti_end_min, cj->ti_end_min); */ +/* } */ +/* #endif */ #endif /* Different types of tasks... */ diff --git a/src/runner_doiact.h b/src/runner_doiact.h index 4452cf08012cab63354bed02c2323ba03019cdec..a16dc28034afe70f66f22607085e9f48ed715ded 100644 --- a/src/runner_doiact.h +++ b/src/runner_doiact.h @@ -130,7 +130,7 @@ void DOPAIR1_NAIVE(struct runner *r, struct cell *restrict ci, TIMER_TIC; /* Anything to do here? */ - if (!cell_is_active(ci, e) && !cell_is_active(cj, e)) return; + if (!cell_is_active_hydro(ci, e) && !cell_is_active_hydro(cj, e)) return; const int count_i = ci->count; const int count_j = cj->count; @@ -218,7 +218,7 @@ void DOPAIR2_NAIVE(struct runner *r, struct cell *restrict ci, TIMER_TIC; /* Anything to do here? */ - if (!cell_is_active(ci, e) && !cell_is_active(cj, e)) return; + if (!cell_is_active_hydro(ci, e) && !cell_is_active_hydro(cj, e)) return; const int count_i = ci->count; const int count_j = cj->count; @@ -308,7 +308,7 @@ void DOSELF1_NAIVE(struct runner *r, struct cell *restrict c) { TIMER_TIC; /* Anything to do here? */ - if (!cell_is_active(c, e)) return; + if (!cell_is_active_hydro(c, e)) return; const int count = c->count; struct part *restrict parts = c->parts; @@ -386,7 +386,7 @@ void DOSELF2_NAIVE(struct runner *r, struct cell *restrict c) { TIMER_TIC; /* Anything to do here? */ - if (!cell_is_active(c, e)) return; + if (!cell_is_active_hydro(c, e)) return; const int count = c->count; struct part *restrict parts = c->parts; @@ -801,7 +801,7 @@ void DOPAIR1(struct runner *r, struct cell *ci, struct cell *cj, const int sid, const double dj_min = sort_j[0].d; const float dx_max = (ci->dx_max_sort + cj->dx_max_sort); - if (cell_is_active(ci, e)) { + if (cell_is_active_hydro(ci, e)) { /* Loop over the parts in ci. */ for (int pid = count_i - 1; @@ -881,7 +881,7 @@ void DOPAIR1(struct runner *r, struct cell *ci, struct cell *cj, const int sid, } /* loop over the parts in ci. */ } /* Cell ci is active */ - if (cell_is_active(cj, e)) { + if (cell_is_active_hydro(cj, e)) { /* Loop over the parts in cj. */ for (int pjd = 0; pjd < count_j && sort_j[pjd].d - hj_max - dx_max < di_max; @@ -978,7 +978,7 @@ void DOPAIR1_BRANCH(struct runner *r, struct cell *ci, struct cell *cj) { const struct engine *restrict e = r->e; /* Anything to do here? */ - if (!cell_is_active(ci, e) && !cell_is_active(cj, e)) return; + if (!cell_is_active_hydro(ci, e) && !cell_is_active_hydro(cj, e)) return; /* Check that cells are drifted. */ if (!cell_are_part_drifted(ci, e) || !cell_are_part_drifted(cj, e)) @@ -1106,11 +1106,11 @@ void DOPAIR2(struct runner *r, struct cell *ci, struct cell *cj, const int sid, int count_active_i = 0, count_active_j = 0; struct entry *restrict sort_active_i = NULL, *restrict sort_active_j = NULL; - if (cell_is_all_active(ci, e)) { + if (cell_is_all_active_hydro(ci, e)) { /* If everybody is active don't bother copying */ sort_active_i = sort_i; count_active_i = count_i; - } else if (cell_is_active(ci, e)) { + } else if (cell_is_active_hydro(ci, e)) { if (posix_memalign((void *)&sort_active_i, SWIFT_CACHE_ALIGNMENT, sizeof(struct entry) * count_i) != 0) error("Failed to allocate active sortlists."); @@ -1124,11 +1124,11 @@ void DOPAIR2(struct runner *r, struct cell *ci, struct cell *cj, const int sid, } } - if (cell_is_all_active(cj, e)) { + if (cell_is_all_active_hydro(cj, e)) { /* If everybody is active don't bother copying */ sort_active_j = sort_j; count_active_j = count_j; - } else if (cell_is_active(cj, e)) { + } else if (cell_is_active_hydro(cj, e)) { if (posix_memalign((void *)&sort_active_j, SWIFT_CACHE_ALIGNMENT, sizeof(struct entry) * count_j) != 0) error("Failed to allocate active sortlists."); @@ -1445,8 +1445,10 @@ void DOPAIR2(struct runner *r, struct cell *ci, struct cell *cj, const int sid, } /* Loop over all cj */ /* Clean-up if necessary */ - if (cell_is_active(ci, e) && !cell_is_all_active(ci, e)) free(sort_active_i); - if (cell_is_active(cj, e) && !cell_is_all_active(cj, e)) free(sort_active_j); + if (cell_is_active_hydro(ci, e) && !cell_is_all_active_hydro(ci, e)) + free(sort_active_i); + if (cell_is_active_hydro(cj, e) && !cell_is_all_active_hydro(cj, e)) + free(sort_active_j); TIMER_TOC(TIMER_DOPAIR); } @@ -1465,7 +1467,7 @@ void DOPAIR2_BRANCH(struct runner *r, struct cell *ci, struct cell *cj) { const struct engine *restrict e = r->e; /* Anything to do here? */ - if (!cell_is_active(ci, e) && !cell_is_active(cj, e)) return; + if (!cell_is_active_hydro(ci, e) && !cell_is_active_hydro(cj, e)) return; /* Check that cells are drifted. */ if (!cell_are_part_drifted(ci, e) || !cell_are_part_drifted(cj, e)) @@ -1548,7 +1550,7 @@ void DOSELF1(struct runner *r, struct cell *restrict c) { TIMER_TIC; - if (!cell_is_active(c, e)) return; + if (!cell_is_active_hydro(c, e)) return; if (!cell_are_part_drifted(c, e)) error("Interacting undrifted cell."); @@ -1685,7 +1687,7 @@ void DOSELF2(struct runner *r, struct cell *restrict c) { TIMER_TIC; - if (!cell_is_active(c, e)) return; + if (!cell_is_active_hydro(c, e)) return; if (!cell_are_part_drifted(c, e)) error("Cell is not drifted"); struct part *restrict parts = c->parts; @@ -1817,7 +1819,7 @@ void DOSUB_PAIR1(struct runner *r, struct cell *ci, struct cell *cj, int sid, TIMER_TIC; /* Should we even bother? */ - if (!cell_is_active(ci, e) && !cell_is_active(cj, e)) return; + if (!cell_is_active_hydro(ci, e) && !cell_is_active_hydro(cj, e)) return; if (ci->count == 0 || cj->count == 0) return; /* Get the type of pair if not specified explicitly. */ @@ -2026,7 +2028,7 @@ void DOSUB_PAIR1(struct runner *r, struct cell *ci, struct cell *cj, int sid, } /* Otherwise, compute the pair directly. */ - else if (cell_is_active(ci, e) || cell_is_active(cj, e)) { + else if (cell_is_active_hydro(ci, e) || cell_is_active_hydro(cj, e)) { /* Make sure both cells are drifted to the current timestep. */ if (!cell_are_part_drifted(ci, e) || !cell_are_part_drifted(cj, e)) @@ -2059,7 +2061,7 @@ void DOSUB_SELF1(struct runner *r, struct cell *ci, int gettimer) { TIMER_TIC; /* Should we even bother? */ - if (ci->count == 0 || !cell_is_active(ci, r->e)) return; + if (ci->count == 0 || !cell_is_active_hydro(ci, r->e)) return; /* Recurse? */ if (cell_can_recurse_in_self_task(ci)) { @@ -2112,7 +2114,7 @@ void DOSUB_PAIR2(struct runner *r, struct cell *ci, struct cell *cj, int sid, TIMER_TIC; /* Should we even bother? */ - if (!cell_is_active(ci, e) && !cell_is_active(cj, e)) return; + if (!cell_is_active_hydro(ci, e) && !cell_is_active_hydro(cj, e)) return; if (ci->count == 0 || cj->count == 0) return; /* Get the type of pair if not specified explicitly. */ @@ -2321,7 +2323,7 @@ void DOSUB_PAIR2(struct runner *r, struct cell *ci, struct cell *cj, int sid, } /* Otherwise, compute the pair directly. */ - else if (cell_is_active(ci, e) || cell_is_active(cj, e)) { + else if (cell_is_active_hydro(ci, e) || cell_is_active_hydro(cj, e)) { /* Make sure both cells are drifted to the current timestep. */ if (!cell_are_part_drifted(ci, e) || !cell_are_part_drifted(cj, e)) @@ -2354,7 +2356,7 @@ void DOSUB_SELF2(struct runner *r, struct cell *ci, int gettimer) { TIMER_TIC; /* Should we even bother? */ - if (ci->count == 0 || !cell_is_active(ci, r->e)) return; + if (ci->count == 0 || !cell_is_active_hydro(ci, r->e)) return; /* Recurse? */ if (cell_can_recurse_in_self_task(ci)) { @@ -2391,7 +2393,9 @@ void DOSUB_SUBSET(struct runner *r, struct cell *ci, struct part *parts, TIMER_TIC; /* Should we even bother? */ - if (!cell_is_active(ci, e) && (cj == NULL || !cell_is_active(cj, e))) return; + if (!cell_is_active_hydro(ci, e) && + (cj == NULL || !cell_is_active_hydro(cj, e))) + return; if (ci->count == 0 || (cj != NULL && cj->count == 0)) return; /* Find out in which sub-cell of ci the parts are. */ @@ -2945,7 +2949,7 @@ void DOSUB_SUBSET(struct runner *r, struct cell *ci, struct part *parts, } /* Otherwise, compute the pair directly. */ - else if (cell_is_active(ci, e) || cell_is_active(cj, e)) { + else if (cell_is_active_hydro(ci, e) || cell_is_active_hydro(cj, e)) { /* Do any of the cells need to be drifted first? */ if (!cell_are_part_drifted(cj, e)) error("Cell should be drifted!"); diff --git a/src/runner_doiact_grav.h b/src/runner_doiact_grav.h index 67ba5a7ec8760a3738a2526daf56739e0b53a6bb..384e7fa8429f6675846e10646fb873e8377b070a 100644 --- a/src/runner_doiact_grav.h +++ b/src/runner_doiact_grav.h @@ -58,7 +58,7 @@ void runner_do_grav_down(struct runner *r, struct cell *c, int timer) { struct cell *cp = c->progeny[k]; /* Do we have a progenitor with any active g-particles ? */ - if (cp != NULL && cell_is_active(cp, e)) { + if (cp != NULL && cell_is_active_gravity(cp, e)) { #ifdef SWIFT_DEBUG_CHECKS if (cp->ti_old_multipole != e->ti_current) @@ -140,7 +140,7 @@ void runner_dopair_grav_mm(const struct runner *r, struct cell *restrict ci, TIMER_TIC; /* Anything to do here? */ - if (!cell_is_active(ci, e) || ci->nodeID != engine_rank) return; + if (!cell_is_active_gravity(ci, e) || ci->nodeID != engine_rank) return; /* Short-cut to the multipole */ const struct multipole *multi_j = &cj->multipole->m_pole; @@ -436,7 +436,7 @@ void runner_dopair_grav_pp(struct runner *r, struct cell *ci, struct cell *cj) { TIMER_TIC; /* Anything to do here? */ - if (!cell_is_active(ci, e) && !cell_is_active(cj, e)) return; + if (!cell_is_active_gravity(ci, e) && !cell_is_active_gravity(cj, e)) return; /* Check that we are not doing something stupid */ if (ci->split || cj->split) error("Running P-P on splitable cells"); @@ -465,8 +465,8 @@ void runner_dopair_grav_pp(struct runner *r, struct cell *ci, struct cell *cj) { space_getsid(s, &ci, &cj, cell_shift); /* Record activity status */ - const int ci_active = cell_is_active(ci, e); - const int cj_active = cell_is_active(cj, e); + const int ci_active = cell_is_active_gravity(ci, e); + const int cj_active = cell_is_active_gravity(cj, e); /* Do we need to drift the multipoles ? */ if (cj_active && ci->ti_old_multipole != e->ti_current) @@ -639,7 +639,7 @@ void runner_doself_grav_pp_full(struct runner *r, struct cell *c) { /* Cell properties */ const int gcount = c->gcount; struct gpart *restrict gparts = c->gparts; - const int c_active = cell_is_active(c, e); + const int c_active = cell_is_active_gravity(c, e); const double loc[3] = {c->loc[0] + 0.5 * c->width[0], c->loc[1] + 0.5 * c->width[1], c->loc[2] + 0.5 * c->width[2]}; @@ -765,7 +765,7 @@ void runner_doself_grav_pp_truncated(struct runner *r, struct cell *c) { /* Cell properties */ const int gcount = c->gcount; struct gpart *restrict gparts = c->gparts; - const int c_active = cell_is_active(c, e); + const int c_active = cell_is_active_gravity(c, e); const double loc[3] = {c->loc[0] + 0.5 * c->width[0], c->loc[1] + 0.5 * c->width[1], c->loc[2] + 0.5 * c->width[2]}; @@ -892,7 +892,7 @@ void runner_doself_grav_pp(struct runner *r, struct cell *c) { #endif /* Anything to do here? */ - if (!cell_is_active(c, e)) return; + if (!cell_is_active_gravity(c, e)) return; /* Check that we are not doing something stupid */ if (c->split) error("Running P-P on a splitable cell"); @@ -945,8 +945,8 @@ void runner_dopair_grav(struct runner *r, struct cell *ci, struct cell *cj, const double max_distance2 = max_distance * max_distance; /* Anything to do here? */ - if (!((cell_is_active(ci, e) && ci->nodeID == nodeID) || - (cell_is_active(cj, e) && cj->nodeID == nodeID))) + if (!((cell_is_active_gravity(ci, e) && ci->nodeID == nodeID) || + (cell_is_active_gravity(cj, e) && cj->nodeID == nodeID))) return; #ifdef SWIFT_DEBUG_CHECKS @@ -961,9 +961,9 @@ void runner_dopair_grav(struct runner *r, struct cell *ci, struct cell *cj, /* Sanity check */ if (ci == cj) error("Pair interaction between a cell and itself."); - if (cell_is_active(ci, e) && ci->ti_old_multipole != e->ti_current) + if (cell_is_active_gravity(ci, e) && ci->ti_old_multipole != e->ti_current) error("ci->multipole not drifted."); - if (cell_is_active(cj, e) && cj->ti_old_multipole != e->ti_current) + if (cell_is_active_gravity(cj, e) && cj->ti_old_multipole != e->ti_current) error("cj->multipole not drifted."); #endif @@ -991,9 +991,9 @@ void runner_dopair_grav(struct runner *r, struct cell *ci, struct cell *cj, #ifdef SWIFT_DEBUG_CHECKS /* Need to account for the interactions we missed */ - if (cell_is_active(ci, e)) + if (cell_is_active_gravity(ci, e)) multi_i->pot.num_interacted += multi_j->m_pole.num_gpart; - if (cell_is_active(cj, e)) + if (cell_is_active_gravity(cj, e)) multi_j->pot.num_interacted += multi_i->m_pole.num_gpart; #endif return; @@ -1094,7 +1094,7 @@ void runner_doself_grav(struct runner *r, struct cell *c, int gettimer) { TIMER_TIC; /* Anything to do here? */ - if (!cell_is_active(c, e)) return; + if (!cell_is_active_gravity(c, e)) return; /* If the cell is split, interact each progeny with itself, and with each of its siblings. */ @@ -1152,7 +1152,7 @@ void runner_do_grav_long_range(struct runner *r, struct cell *ci, int timer) { const int nr_cells = s->nr_cells; /* Anything to do here? */ - if (!cell_is_active(ci, e)) return; + if (!cell_is_active_gravity(ci, e)) return; if (ci->nodeID != engine_rank) error("Non-local cell in long-range gravity task!"); diff --git a/src/scheduler.c b/src/scheduler.c index 82cfc65f5bf8f4fd1698d0a112065391727c292d..5beab065ffe0c135b2cbb247c531728c5238b865 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -1362,74 +1362,82 @@ void scheduler_start(struct scheduler *s) { scheduler_rewait_mapper(s->tid_active, s->active_count, s); } -/* Check we have not missed an active task */ -#ifdef SWIFT_DEBUG_CHECKS - - const integertime_t ti_current = s->space->e->ti_current; - - if (ti_current > 0) { - - for (int k = 0; k < s->nr_tasks; k++) { - - struct task *t = &s->tasks[k]; - struct cell *ci = t->ci; - struct cell *cj = t->cj; - - if (t->type == task_type_none) continue; - - /* Don't check MPI stuff */ - if (t->type == task_type_send || t->type == task_type_recv) continue; - - /* Don't check the FFT task */ - if (t->type == task_type_grav_top_level || - t->type == task_type_grav_ghost_in || - t->type == task_type_grav_ghost_out) - continue; - - if (ci == NULL && cj == NULL) { - - error("Task not associated with cells!"); - - } else if (cj == NULL) { /* self */ - - if (ci->ti_end_min == ti_current && t->skip && - t->type != task_type_sort && t->type != task_type_drift_part && - t->type != task_type_drift_gpart) - error( - "Task (type='%s/%s') should not have been skipped " - "ti_current=%lld " - "c->ti_end_min=%lld", - taskID_names[t->type], subtaskID_names[t->subtype], ti_current, - ci->ti_end_min); - - /* Special treatment for sort tasks */ - /* if (ci->ti_end_min == ti_current && t->skip && - t->type == task_type_sort && t->flags == 0) - error( - "Task (type='%s/%s') should not have been skipped " - "ti_current=%lld " - "c->ti_end_min=%lld t->flags=%d", - taskID_names[t->type], subtaskID_names[t->subtype], ti_current, - ci->ti_end_min, t->flags); */ - - } else { /* pair */ - - if (t->skip) { - - /* Check that the pair is active if the local cell is active */ - if ((ci->ti_end_min == ti_current && ci->nodeID == engine_rank) || - (cj->ti_end_min == ti_current && cj->nodeID == engine_rank)) - error( - "Task (type='%s/%s') should not have been skipped " - "ti_current=%lld " - "ci->ti_end_min=%lld cj->ti_end_min=%lld", - taskID_names[t->type], subtaskID_names[t->subtype], ti_current, - ci->ti_end_min, cj->ti_end_min); - } - } - } - } -#endif + /* Check we have not missed an active task */ + /* #ifdef SWIFT_DEBUG_CHECKS */ + + /* const integertime_t ti_current = s->space->e->ti_current; */ + + /* if (ti_current > 0) { */ + + /* for (int k = 0; k < s->nr_tasks; k++) { */ + + /* struct task *t = &s->tasks[k]; */ + /* struct cell *ci = t->ci; */ + /* struct cell *cj = t->cj; */ + + /* if (t->type == task_type_none) continue; */ + + /* /\* Don't check MPI stuff *\/ */ + /* if (t->type == task_type_send || t->type == task_type_recv) continue; + */ + + /* /\* Don't check the FFT task *\/ */ + /* if (t->type == task_type_grav_top_level || */ + /* t->type == task_type_grav_ghost_in || */ + /* t->type == task_type_grav_ghost_out) */ + /* continue; */ + + /* if (ci == NULL && cj == NULL) { */ + + /* error("Task not associated with cells!"); */ + + /* } else if (cj == NULL) { /\* self *\/ */ + + /* if (ci->ti_hydro_end_min == ti_current && t->skip && */ + /* t->type != task_type_sort && t->type != task_type_drift_part && + */ + /* t->type != task_type_drift_gpart) */ + /* error( */ + /* "Task (type='%s/%s') should not have been skipped " */ + /* "ti_current=%lld " */ + /* "c->ti_hydro_end_min=%lld", */ + /* taskID_names[t->type], subtaskID_names[t->subtype], + * ti_current, */ + /* ci->ti_hydro_end_min); */ + + /* /\* Special treatment for sort tasks *\/ */ + /* /\* if (ci->ti_end_min == ti_current && t->skip && */ + /* t->type == task_type_sort && t->flags == 0) */ + /* error( */ + /* "Task (type='%s/%s') should not have been skipped " */ + /* "ti_current=%lld " */ + /* "c->ti_end_min=%lld t->flags=%d", */ + /* taskID_names[t->type], subtaskID_names[t->subtype], + * ti_current, */ + /* ci->ti_end_min, t->flags); *\/ */ + + /* } else { /\* pair *\/ */ + + /* if (t->skip) { */ + + /* /\* Check that the pair is active if the local cell is active *\/ + */ + /* if ((ci->ti_hydro_end_min == ti_current && ci->nodeID == + * engine_rank) || */ + /* (cj->ti_hydro_end_min == ti_current && cj->nodeID == + * engine_rank)) */ + /* error( */ + /* "Task (type='%s/%s') should not have been skipped " */ + /* "ti_current=%lld " */ + /* "ci->ti_hydro_end_min=%lld cj->ti_hydro_end_min=%lld", */ + /* taskID_names[t->type], subtaskID_names[t->subtype], + * ti_current, */ + /* ci->ti_hydro_end_min, cj->ti_hydro_end_min); */ + /* } */ + /* } */ + /* } */ + /* } */ + /* #endif */ /* Loop over the tasks and enqueue whoever is ready. */ if (s->active_count > 1000) { diff --git a/src/space.c b/src/space.c index 924d0148e20fb6ba955ee098c5a0a67ea94135c8..c1dc04ad277e56583ce7cb443a6a865780039d8a 100644 --- a/src/space.c +++ b/src/space.c @@ -2000,7 +2000,10 @@ void space_split_recursive(struct space *s, struct cell *c, const int depth = c->depth; int maxdepth = 0; float h_max = 0.0f; - integertime_t ti_end_min = max_nr_timesteps, ti_end_max = 0, ti_beg_max = 0; + integertime_t ti_hydro_end_min = max_nr_timesteps, ti_hydro_end_max = 0, + ti_hydro_beg_max = 0; + integertime_t ti_gravity_end_min = max_nr_timesteps, ti_gravity_end_max = 0, + ti_gravity_beg_max = 0; struct part *parts = c->parts; struct gpart *gparts = c->gparts; struct spart *sparts = c->sparts; @@ -2115,9 +2118,18 @@ void space_split_recursive(struct space *s, struct cell *c, progeny_gbuff += c->progeny[k]->gcount; progeny_sbuff += c->progeny[k]->scount; h_max = max(h_max, c->progeny[k]->h_max); - ti_end_min = min(ti_end_min, c->progeny[k]->ti_end_min); - ti_end_max = max(ti_end_max, c->progeny[k]->ti_end_max); - ti_beg_max = max(ti_beg_max, c->progeny[k]->ti_beg_max); + ti_hydro_end_min = + min(ti_hydro_end_min, c->progeny[k]->ti_hydro_end_min); + ti_hydro_end_max = + max(ti_hydro_end_max, c->progeny[k]->ti_hydro_end_max); + ti_hydro_beg_max = + max(ti_hydro_beg_max, c->progeny[k]->ti_hydro_beg_max); + ti_gravity_end_min = + min(ti_gravity_end_min, c->progeny[k]->ti_gravity_end_min); + ti_gravity_end_max = + max(ti_gravity_end_max, c->progeny[k]->ti_gravity_end_max); + ti_gravity_beg_max = + max(ti_gravity_beg_max, c->progeny[k]->ti_gravity_beg_max); if (c->progeny[k]->maxdepth > maxdepth) maxdepth = c->progeny[k]->maxdepth; } @@ -2236,9 +2248,13 @@ void space_split_recursive(struct space *s, struct cell *c, } /* Convert into integer times */ - ti_end_min = get_integer_time_end(e->ti_current, time_bin_min); - ti_end_max = get_integer_time_end(e->ti_current, time_bin_max); - ti_beg_max = get_integer_time_begin(e->ti_current + 1, time_bin_max); + ti_hydro_end_min = get_integer_time_end(e->ti_current, time_bin_min); + ti_hydro_end_max = get_integer_time_end(e->ti_current, time_bin_max); + ti_hydro_beg_max = get_integer_time_begin(e->ti_current + 1, time_bin_max); + ti_gravity_end_min = get_integer_time_end(e->ti_current, time_bin_min); + ti_gravity_end_max = get_integer_time_end(e->ti_current, time_bin_max); + ti_gravity_beg_max = + get_integer_time_begin(e->ti_current + 1, time_bin_max); /* Construct the multipole and the centre of mass*/ if (s->gravity) { @@ -2272,9 +2288,12 @@ void space_split_recursive(struct space *s, struct cell *c, /* Set the values for this cell. */ c->h_max = h_max; - c->ti_end_min = ti_end_min; - c->ti_end_max = ti_end_max; - c->ti_beg_max = ti_beg_max; + c->ti_hydro_end_min = ti_hydro_end_min; + c->ti_hydro_end_max = ti_hydro_end_max; + c->ti_hydro_beg_max = ti_hydro_beg_max; + c->ti_gravity_end_min = ti_gravity_end_min; + c->ti_gravity_end_max = ti_gravity_end_max; + c->ti_gravity_beg_max = ti_gravity_beg_max; c->maxdepth = maxdepth; /* Set ownership according to the start of the parts array. */ @@ -3178,3 +3197,36 @@ void space_clean(struct space *s) { free(s->gparts); free(s->sparts); } + +void space_print_cells(const struct space *s) { + + char filename[200]; + sprintf(filename, "space_%d_%d.dat", s->e->step, engine_rank); + + FILE *file = fopen(filename, "w"); + + fprintf(file, "ti_current=%lld\n", s->e->ti_current); + + for (int k = 0; k < s->cdim[2]; ++k) { + + fprintf(file, "\n -- k=%d -- \n\n", k); + + for (int j = 0; j < s->cdim[1]; ++j) { + + for (int i = 0; i < s->cdim[0]; ++i) { +#ifdef WITH_MPI + + const int cid = cell_getid(s->cdim, i, j, k); + const struct cell *c = &s->cells_top[cid]; + fprintf(file, "|(%d-%ld-%lld-%lld-%d)", c->nodeID, c - s->cells_top, + c->ti_hydro_end_min, c->ti_gravity_end_min, c->gcount); +#endif + } + fprintf(file, "|\n"); + } + } + + fprintf(file, " -- --- --\n"); + + fclose(file); +} diff --git a/src/space.h b/src/space.h index c49dc37dc0df27cd3647044f219e36c299dcd73b..e896cc51767eb0879abf3011107a4236b7d51e2a 100644 --- a/src/space.h +++ b/src/space.h @@ -234,5 +234,6 @@ void space_replicate(struct space *s, int replicate, int verbose); void space_reset_task_counters(struct space *s); void space_clean(struct space *s); void space_free_cells(struct space *s); +void space_print_cells(const struct space *s); #endif /* SWIFT_SPACE_H */ diff --git a/src/timeline.h b/src/timeline.h index 0f38ff3e9421c122b61caf74290c170b62b2dd92..352056cf340e7bbbce336e03e67a060f172155b1 100644 --- a/src/timeline.h +++ b/src/timeline.h @@ -32,7 +32,7 @@ typedef long long integertime_t; typedef char timebin_t; /*! The number of time bins */ -#define num_time_bins 56 +#define num_time_bins 26 /*! The maximal number of timesteps in a simulation */ #define max_nr_timesteps (1LL << (num_time_bins + 1))