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
8157c486
Commit
8157c486
authored
Jun 21, 2020
by
Matthieu Schaller
Browse files
Added a user-defined threshold to trigger a dump of the task graph
parent
ae845b37
Changes
3
Hide whitespace changes
Inline
Side-by-side
examples/main.c
View file @
8157c486
...
...
@@ -183,6 +183,7 @@ int main(int argc, char *argv[]) {
char
*
param_filename
=
NULL
;
char
restart_file
[
200
]
=
""
;
unsigned
long
long
cpufreq
=
0
;
float
dump_tasks_threshold
=
0
.
f
;
struct
cmdparams
cmdps
;
cmdps
.
nparam
=
0
;
cmdps
.
param
[
0
]
=
NULL
;
...
...
@@ -304,6 +305,10 @@ int main(int argc, char *argv[]) {
OPT_INTEGER
(
'Y'
,
"threadpool-dumps"
,
&
dump_threadpool
,
"Time-step frequency at which threadpool tasks are dumped."
,
NULL
,
0
,
0
),
OPT_FLOAT
(
0
,
"dump-tasks-threshold"
,
&
dump_tasks_threshold
,
"Fraction of the total step's time spent in a task to trigger "
"a dump of the task plot on this step"
,
NULL
,
0
,
0
),
OPT_END
(),
};
struct
argparse
argparse
;
...
...
@@ -1410,13 +1415,14 @@ int main(int argc, char *argv[]) {
/* Dump the task data using the given frequency. */
if
(
dump_tasks
&&
(
dump_tasks
==
1
||
j
%
dump_tasks
==
1
))
{
#ifdef SWIFT_DEBUG_TASKS
task_dump_all
(
&
e
,
j
+
1
);
if
(
dump_tasks_threshold
==
0
.)
task_dump_all
(
&
e
,
j
+
1
);
#endif
/* Generate the task statistics. */
char
dumpfile
[
40
];
snprintf
(
dumpfile
,
40
,
"thread_stats-step%d.dat"
,
e
.
step
+
1
);
task_dump_stats
(
dumpfile
,
&
e
,
/* header = */
0
,
/* allranks = */
1
);
task_dump_stats
(
dumpfile
,
&
e
,
dump_tasks_threshold
,
/* header = */
0
,
/* allranks = */
1
);
}
#ifdef SWIFT_CELL_GRAPH
...
...
src/task.c
View file @
8157c486
...
...
@@ -1095,12 +1095,14 @@ void task_dump_all(struct engine *e, int step) {
*
* @param dumpfile name of the file for the output.
* @param e the #engine
* @param dump_task_threshold Fraction of the step time above whic any task
* triggers a call to task_dump_all().
* @param header whether to write a header include file.
* @param allranks do the statistics over all ranks, if not just the current
* one, only used if header is false.
*/
void
task_dump_stats
(
const
char
*
dumpfile
,
struct
engine
*
e
,
int
header
,
int
allranks
)
{
void
task_dump_stats
(
const
char
*
dumpfile
,
struct
engine
*
e
,
float
dump_tasks_threshold
,
int
header
,
int
allranks
)
{
const
ticks
function_tic
=
getticks
();
...
...
@@ -1127,6 +1129,7 @@ void task_dump_stats(const char *dumpfile, struct engine *e, int header,
double
stepdt
=
(
double
)
e
->
toc_step
-
(
double
)
e
->
tic_step
;
double
total
[
1
]
=
{
0
.
0
};
int
dumped_plot_data
=
0
;
for
(
int
l
=
0
;
l
<
e
->
sched
.
nr_tasks
;
l
++
)
{
int
type
=
e
->
sched
.
tasks
[
l
].
type
;
...
...
@@ -1155,10 +1158,21 @@ void task_dump_stats(const char *dumpfile, struct engine *e, int header,
total
[
0
]
+=
dt
;
/* Check if this is a problematic task and make a report. */
if
(
e
->
verbose
)
if
(
dt
/
stepdt
>
0
.
05
)
message
(
"Long running task detected: %s/%s using %.1f%% of step runtime"
,
taskID_names
[
type
],
subtaskID_names
[
subtype
],
dt
/
stepdt
*
100
.
0
);
if
(
dump_tasks_threshold
>
0
.
&&
dt
/
stepdt
>
dump_tasks_threshold
)
{
if
(
e
->
verbose
)
message
(
"Long running task detected: %s/%s using %.1f%% of step runtime"
,
taskID_names
[
type
],
subtaskID_names
[
subtype
],
dt
/
stepdt
*
100
.
0
);
if
(
!
dumped_plot_data
)
{
#ifdef SWIFT_DEBUG_TASKS
task_dump_all
(
e
,
e
->
step
+
1
);
#endif
dumped_plot_data
=
1
;
}
}
}
}
...
...
src/task.h
View file @
8157c486
...
...
@@ -265,8 +265,8 @@ int task_lock(struct task *t);
void
task_do_rewait
(
struct
task
*
t
);
void
task_print
(
const
struct
task
*
t
);
void
task_dump_all
(
struct
engine
*
e
,
int
step
);
void
task_dump_stats
(
const
char
*
dumpfile
,
struct
engine
*
e
,
int
header
,
int
allranks
);
void
task_dump_stats
(
const
char
*
dumpfile
,
struct
engine
*
e
,
float
dump_tasks_threshold
,
int
header
,
int
allranks
);
void
task_dump_active
(
struct
engine
*
e
);
void
task_get_full_name
(
int
type
,
int
subtype
,
char
*
name
);
void
task_get_group_name
(
int
type
,
int
subtype
,
char
*
cluster
);
...
...
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