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
ec33e285
Commit
ec33e285
authored
Nov 14, 2017
by
Matthieu Schaller
Browse files
Small style improvements
parent
d74f024e
Changes
4
Hide whitespace changes
Inline
Side-by-side
examples/main.c
View file @
ec33e285
...
...
@@ -59,9 +59,6 @@ void print_help_message() {
printf
(
" swift_mpi [OPTION]... PARAMFILE
\n\n
"
);
printf
(
"Valid options are:
\n
"
);
#ifdef SWIFT_DEBUG_CHECKS
printf
(
" %2s %14s %s
\n
"
,
"-x"
,
""
,
"Write task dependencies."
);
#endif
printf
(
" %2s %14s %s
\n
"
,
"-a"
,
""
,
"Pin runners using processor affinity."
);
printf
(
" %2s %14s %s
\n
"
,
"-c"
,
""
,
"Run with cosmological time integration."
);
...
...
@@ -174,9 +171,6 @@ int main(int argc, char *argv[]) {
int
with_fp_exceptions
=
0
;
int
with_drift_all
=
0
;
int
with_mpole_reconstruction
=
0
;
#ifdef SWIFT_DEBUG_CHECKS
int
write_dependencies
=
0
;
#endif
int
verbose
=
0
;
int
nr_threads
=
1
;
int
with_verbose_timers
=
0
;
...
...
@@ -202,11 +196,6 @@ int main(int argc, char *argv[]) {
case
'c'
:
with_cosmology
=
1
;
break
;
#ifdef SWIFT_DEBUG_CHECKS
case
'x'
:
write_dependencies
=
1
;
break
;
#endif
case
'C'
:
with_cooling
=
1
;
break
;
...
...
@@ -702,10 +691,6 @@ int main(int argc, char *argv[]) {
engine_dump_snapshot
(
&
e
);
engine_print_stats
(
&
e
);
#ifdef SWIFT_DEBUG_CHECKS
if
(
write_dependencies
)
scheduler_write_dependency
(
&
e
.
sched
);
#endif
/* Legend */
if
(
myrank
==
0
)
printf
(
"# %6s %14s %14s %10s %10s %10s %16s [%s]
\n
"
,
"Step"
,
"Time"
,
...
...
src/engine.c
View file @
ec33e285
...
...
@@ -3587,6 +3587,9 @@ void engine_init_particles(struct engine *e, int flag_entropy_ICs,
gravity_exact_force_compute
(
e
->
s
,
e
);
#endif
if
(
e
->
nodeID
==
0
)
scheduler_write_dependencies
(
&
e
->
sched
,
e
->
verbose
);
/* Run the 0th time-step */
engine_launch
(
e
);
...
...
src/scheduler.c
View file @
ec33e285
...
...
@@ -115,57 +115,54 @@ void scheduler_addunlock(struct scheduler *s, struct task *ta,
/**
* @brief Write a dot file with the task dependencies.
*
* See examples/task_graph for an example of how to use it
* Run plot_task_dependencies.sh for an example of how to use it
* to generate the figure.
*
* @param s The #scheduler we are working in.
* @param verbose Are we verbose about this?
*/
void
scheduler_write_dependency
(
struct
scheduler
*
s
)
{
#ifdef WITH_MPI
if
(
engine_rank
!=
0
)
return
;
#endif
int
i
,
j
;
void
scheduler_write_dependencies
(
struct
scheduler
*
s
,
int
verbose
)
{
const
ticks
tic
=
getticks
();
int
max_nber_dep
=
5
;
/* 2 => we need 1 int for type and 1 for subtype */
int
nber_relation
=
2
*
task_type_count
*
task_subtype_count
*
max_nber_dep
;
/* For each type/subtype, a table of 2*max_nber_dep int is available =>
max_nber_dep task with subtype available
/* Conservative number of dependencies per task type */
const
int
max_nber_dep
=
128
;
-1 means that it is not set yet
/* Number of possibble relations between tasks */
const
int
nber_relation
=
2
*
task_type_count
*
task_subtype_count
*
max_nber_dep
;
to get the table of max_nber_dep for a task:
ind = (ta * task_subtype_count + sa) * max_nber_dep * 2
where ta is the value of task_type and sa is the value of
task_subtype
*/
/* To get the table of max_nber_dep for a task:
* ind = (ta * task_subtype_count + sa) * max_nber_dep * 2
* where ta is the value of task_type and sa is the value of
* task_subtype */
int
*
table
=
malloc
(
nber_relation
*
sizeof
(
int
));
for
(
i
=
0
;
i
<
nber_relation
;
i
++
)
table
[
i
]
=
-
1
;
if
(
table
==
NULL
)
error
(
"Error allocating memory for task-dependency graph."
)
;
message
(
"Writing dependencies"
);
/* Reset everything */
for
(
int
i
=
0
;
i
<
nber_relation
;
i
++
)
table
[
i
]
=
-
1
;
/*
c
reate file */
/*
C
reate file */
char
filename
[
200
]
=
"dependency_graph.dot"
;
FILE
*
f
;
/* file containing the output */
f
=
open_and_check_file
(
filename
,
"w"
);
FILE
*
f
=
open_and_check_file
(
filename
,
"w"
);
/*
w
rite header */
/*
W
rite header */
fprintf
(
f
,
"digraph task_dep {
\n
"
);
fprintf
(
f
,
"
\t
compound=true;
\n
"
);
fprintf
(
f
,
"
\t
ratio=0.66;
\n
"
);
fprintf
(
f
,
"
\t
node[nodesep=0.15];
\n
"
);
/* loop over all tasks */
for
(
i
=
0
;
i
<
s
->
nr_tasks
;
i
++
)
{
struct
task
*
ta
;
ta
=
&
s
->
tasks
[
i
];
for
(
int
i
=
0
;
i
<
s
->
nr_tasks
;
i
++
)
{
const
struct
task
*
ta
=
&
s
->
tasks
[
i
];
/* and theirs dependencies */
for
(
j
=
0
;
j
<
ta
->
nr_unlock_tasks
;
j
++
)
{
struct
task
*
tb
;
tb
=
ta
->
unlock_tasks
[
j
];
for
(
int
j
=
0
;
j
<
ta
->
nr_unlock_tasks
;
j
++
)
{
const
struct
task
*
tb
=
ta
->
unlock_tasks
[
j
];
char
tmp
[
200
];
/* text to write */
char
ta_name
[
200
];
char
tb_name
[
200
];
/* construct line */
if
(
ta
->
subtype
==
task_subtype_none
)
sprintf
(
ta_name
,
"%s"
,
taskID_names
[
ta
->
type
]);
...
...
@@ -190,6 +187,7 @@ void scheduler_write_dependency(struct scheduler *s) {
int
k
=
0
;
int
*
cur
=
&
table
[
ind
];
while
(
k
<
max_nber_dep
)
{
/* not written yet */
if
(
cur
[
0
]
==
-
1
)
{
cur
[
0
]
=
tb
->
type
;
...
...
@@ -218,9 +216,14 @@ void scheduler_write_dependency(struct scheduler *s) {
}
}
/* Be clean */
fprintf
(
f
,
"}"
);
fclose
(
f
);
free
(
table
);
if
(
verbose
)
message
(
"Printing task graph took %.3f %s."
,
clocks_from_ticks
(
getticks
()
-
tic
),
clocks_getunit
());
}
/**
...
...
src/scheduler.h
View file @
ec33e285
...
...
@@ -168,6 +168,6 @@ void scheduler_dump_queue(struct scheduler *s);
void
scheduler_print_tasks
(
const
struct
scheduler
*
s
,
const
char
*
fileName
);
void
scheduler_clean
(
struct
scheduler
*
s
);
void
scheduler_free_tasks
(
struct
scheduler
*
s
);
void
scheduler_write_dependenc
y
(
struct
scheduler
*
s
);
void
scheduler_write_dependenc
ies
(
struct
scheduler
*
s
,
int
verbose
);
#endif
/* SWIFT_SCHEDULER_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