Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SWIFT
SWIFTsim
Commits
173583f7
Commit
173583f7
authored
Feb 27, 2017
by
Matthieu Schaller
Browse files
Added a debugging flag to each cell, listing the tasks that have been run up to this stage.
parent
d20b6ca6
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/cell.c
View file @
173583f7
...
...
@@ -1056,6 +1056,23 @@ void cell_check_drift_point(struct cell *c, void *data) {
#endif
}
/**
* @brief Resets all the individual cell task counters to 0.
*
* Should only be used for debugging purposes.
*
* @param c The #cell to reset.
*/
void
cell_reset_task_counters
(
struct
cell
*
c
)
{
#ifdef SWIFT_DEBUG_CHECKS
for
(
int
t
=
0
;
t
<
task_type_count
;
++
t
)
c
->
tasks_executed
[
t
]
=
0
;
for
(
int
t
=
0
;
t
<
task_subtype_count
;
++
t
)
c
->
subtasks_executed
[
t
]
=
0
;
#else
error
(
"Calling debugging code without debugging flag activated."
);
#endif
}
/**
* @brief Checks whether the cells are direct neighbours ot not. Both cells have
* to be of the same size
...
...
@@ -1095,6 +1112,7 @@ int cell_are_neighbours(const struct cell *restrict ci,
*/
void
cell_check_multipole
(
struct
cell
*
c
,
void
*
data
)
{
#ifdef SWIFT_DEBUG_CHECKS
struct
multipole
ma
;
const
double
tolerance
=
1e-5
;
/* Relative */
...
...
@@ -1118,6 +1136,9 @@ void cell_check_multipole(struct cell *c, void *data) {
error
(
"Aborting"
);
}
}
#else
error
(
"Calling debugging code without debugging flag activated."
);
#endif
}
/**
...
...
src/cell.h
View file @
173583f7
...
...
@@ -308,6 +308,14 @@ struct cell {
/*! The maximal depth of this cell and its progenies */
char
maxdepth
;
#ifdef SWIFT_DEBUG_CHECKS
/*! The list of tasks that have been executed on this cell */
char
tasks_executed
[
64
];
/*! The list of sub-tasks that have been executed on this cell */
char
subtasks_executed
[
64
];
#endif
}
SWIFT_STRUCT_ALIGN
;
/* Convert cell location to ID. */
...
...
@@ -342,6 +350,7 @@ int cell_are_neighbours(const struct cell *restrict ci,
void
cell_check_multipole
(
struct
cell
*
c
,
void
*
data
);
void
cell_clean
(
struct
cell
*
c
);
void
cell_check_drift_point
(
struct
cell
*
c
,
void
*
data
);
void
cell_reset_task_counters
(
struct
cell
*
c
);
int
cell_is_drift_needed
(
struct
cell
*
c
,
const
struct
engine
*
e
);
int
cell_unskip_tasks
(
struct
cell
*
c
,
struct
scheduler
*
s
);
void
cell_set_super
(
struct
cell
*
c
,
struct
cell
*
super
);
...
...
src/engine.c
View file @
173583f7
...
...
@@ -1573,8 +1573,8 @@ void engine_make_gravity_tasks(struct engine *e) {
0
);
/* Let's also build a task for all the non-neighbouring pm calculations */
scheduler_addtask
(
sched
,
task_type_grav_
mm
,
task_subtype_none
,
0
,
0
,
ci
,
NULL
,
0
);
scheduler_addtask
(
sched
,
task_type_grav_
long_range
,
task_subtype_none
,
0
,
0
,
ci
,
NULL
,
0
);
for
(
int
cjd
=
cid
+
1
;
cjd
<
nr_cells
;
++
cjd
)
{
...
...
@@ -1777,25 +1777,22 @@ void engine_count_and_link_tasks(struct engine *e) {
}
}
/*
/*
*
* @brief Creates the dependency network for the gravity tasks of a given cell.
*
* @param sched The #scheduler.
* @param gravity The gravity task to link.
* @param c The cell.
*/
/* static inline void engine_make_gravity_dependencies(struct scheduler *sched,
*/
/* struct task *gravity, */
/* struct cell *c) { */
static
inline
void
engine_make_gravity_dependencies
(
struct
scheduler
*
sched
,
struct
task
*
gravity
,
struct
cell
*
c
)
{
/* /\* init --> gravity --> kick *\/ */
/* scheduler_addunlock(sched, c->super->init, gravity); */
/* scheduler_addunlock(sched, gravity, c->super->kick2); */
/* /\* grav_up --> gravity ( --> kick) *\/ */
/* scheduler_addunlock(sched, c->super->grav_up, gravity); */
/* } */
/* init --> gravity --> grav_down --> kick */
scheduler_addunlock
(
sched
,
c
->
super
->
init
,
gravity
);
scheduler_addunlock
(
sched
,
gravity
,
c
->
super
->
grav_down
);
scheduler_addunlock
(
sched
,
gravity
,
c
->
super
->
kick2
);
}
/**
* @brief Creates the dependency network for the external gravity tasks of a
...
...
@@ -2874,6 +2871,11 @@ void engine_launch(struct engine *e, int nr_runners) {
const
ticks
tic
=
getticks
();
#ifdef SWIFT_DEBUG_CHECKS
/* Re-set all the cell task counters to 0 */
space_reset_task_counters
(
e
->
s
);
#endif
/* Prepare the scheduler. */
atomic_inc
(
&
e
->
sched
.
waiting
);
...
...
src/runner.c
View file @
173583f7
...
...
@@ -1612,6 +1612,8 @@ void *runner_main(void *data) {
/* Get the cells. */
struct
cell
*
ci
=
t
->
ci
;
struct
cell
*
cj
=
t
->
cj
;
/* Mark the thread we run on */
#ifdef SWIFT_DEBUG_TASKS
t
->
rid
=
r
->
cpuid
;
#endif
...
...
@@ -1816,6 +1818,18 @@ void *runner_main(void *data) {
error
(
"Unknown/invalid task type (%d)."
,
t
->
type
);
}
/* Mark that we have run this task on these cells */
#ifdef SWIFT_DEBUG_CHECKS
if
(
ci
!=
NULL
)
{
ci
->
tasks_executed
[
t
->
type
]
++
;
ci
->
subtasks_executed
[
t
->
subtype
]
++
;
}
if
(
cj
!=
NULL
)
{
cj
->
tasks_executed
[
t
->
type
]
++
;
cj
->
subtasks_executed
[
t
->
subtype
]
++
;
}
#endif
/* We're done with this task, see if we get a next one. */
prev
=
t
;
t
=
scheduler_done
(
sched
,
t
);
...
...
src/space.c
View file @
173583f7
...
...
@@ -2827,27 +2827,51 @@ void space_link_cleanup(struct space *s) {
/**
* @brief Checks that all cells have been drifted to a given point in time
*
*
Expensive function.
Should only be used for debugging purposes.
* Should only be used for debugging purposes.
*
* @param s The #space to check.
* @param ti_drift The (integer) time.
*/
void
space_check_drift_point
(
struct
space
*
s
,
integertime_t
ti_drift
)
{
#ifdef SWIFT_DEBUG_CHECKS
/* Recursively check all cells */
space_map_cells_pre
(
s
,
1
,
cell_check_drift_point
,
&
ti_drift
);
#else
error
(
"Calling debugging code without debugging flag activated."
);
#endif
}
/**
* @brief Checks that all particles and local cells have a non-zero time-step.
*
* Should only be used for debugging purposes.
*
* @param s The #space to check.
*/
void
space_check_timesteps
(
struct
space
*
s
)
{
#ifdef SWIFT_DEBUG_CHECKS
for
(
int
i
=
0
;
i
<
s
->
nr_cells
;
++
i
)
{
cell_check_timesteps
(
&
s
->
cells_top
[
i
]);
}
#else
error
(
"Calling debugging code without debugging flag activated."
);
#endif
}
/**
* @brief Resets all the individual cell task counters to 0.
*
* Should only be used for debugging purposes.
*
* @param s The #space to reset.
*/
void
space_reset_task_counters
(
struct
space
*
s
)
{
#ifdef SWIFT_DEBUG_CHECKS
for
(
int
i
=
0
;
i
<
s
->
nr_cells
;
++
i
)
{
cell_reset_task_counters
(
&
s
->
cells_top
[
i
]);
}
#else
error
(
"Calling debugging code without debugging flag activated."
);
#endif
}
...
...
src/space.h
View file @
173583f7
...
...
@@ -215,6 +215,7 @@ void space_link_cleanup(struct space *s);
void
space_check_drift_point
(
struct
space
*
s
,
integertime_t
ti_drift
);
void
space_check_timesteps
(
struct
space
*
s
);
void
space_replicate
(
struct
space
*
s
,
int
replicate
,
int
verbose
);
void
space_reset_task_counters
(
struct
space
*
s
);
void
space_clean
(
struct
space
*
s
);
#endif
/* SWIFT_SPACE_H */
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment