Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
8b1bf283
Commit
8b1bf283
authored
7 years ago
by
lhausamm
Browse files
Options
Downloads
Patches
Plain Diff
task dependency graph: use a table and not reading the file anymore
parent
201ab915
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!459
Task graph
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/scheduler.c
+53
-16
53 additions, 16 deletions
src/scheduler.c
with
53 additions
and
16 deletions
src/scheduler.c
+
53
−
16
View file @
8b1bf283
...
...
@@ -113,17 +113,34 @@ void scheduler_addunlock(struct scheduler *s, struct task *ta,
}
void
scheduler_write_dependency
(
struct
scheduler
*
s
)
{
#ifdef WITH_MPI
if
(
engine_rank
!=
0
)
return
;
#endif
int
i
,
j
;
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
-1 means that it is not set yet
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
;
message
(
"Writing dependencies"
);
/* create file */
char
filename
[
200
]
=
"dependency_graph.dot"
;
FILE
*
f
;
/* file containing the output */
f
=
open_and_check_file
(
filename
,
"w
r
"
);
f
=
open_and_check_file
(
filename
,
"w"
);
/* write header */
fprintf
(
f
,
"digraph task_dep {
\n
"
);
...
...
@@ -132,7 +149,6 @@ void scheduler_write_dependency(struct scheduler *s) {
fprintf
(
f
,
"
\t
node[nodesep=0.15];
\n
"
);
/* loop over all tasks */
int
i
,
j
;
for
(
i
=
0
;
i
<
s
->
nr_tasks
;
i
++
)
{
struct
task
*
ta
;
ta
=
&
s
->
tasks
[
i
];
...
...
@@ -142,6 +158,7 @@ void scheduler_write_dependency(struct scheduler *s) {
struct
task
*
tb
;
tb
=
ta
->
unlock_tasks
[
j
];
char
tmp
[
200
];
/* text to write */
char
ta_name
[
200
];
char
tb_name
[
200
];
...
...
@@ -165,21 +182,40 @@ void scheduler_write_dependency(struct scheduler *s) {
tb_name
);
/* check if dependency already written */
int
test
=
1
;
/* loop over all lines */
char
*
line
=
NULL
;
/* buff for reading line */
size_t
len
=
0
;
ssize_t
read
;
fseek
(
f
,
0
,
SEEK_SET
);
while
(
test
&&
(
read
=
getline
(
&
line
,
&
len
,
f
))
!=
-
1
)
{
/* check if line == dependency word */
if
(
strcmp
(
tmp
,
line
)
==
0
)
test
=
0
;
}
int
written
=
0
;
fseek
(
f
,
0
,
SEEK_END
);
int
ind
=
ta
->
type
*
task_subtype_count
+
ta
->
subtype
;
ind
*=
2
*
max_nber_dep
;
int
k
=
0
;
int
*
cur
=
&
table
[
ind
];
while
(
k
<
max_nber_dep
)
{
/* not written yet */
if
(
cur
[
0
]
==
-
1
)
{
cur
[
0
]
=
tb
->
type
;
cur
[
1
]
=
tb
->
subtype
;
break
;
}
/* already written */
if
(
cur
[
0
]
==
tb
->
type
&&
cur
[
1
]
==
tb
->
subtype
)
{
written
=
1
;
break
;
}
k
+=
1
;
cur
=
&
cur
[
3
];
}
/* max_nber_dep is too small */
if
(
k
==
max_nber_dep
)
error
(
"Not enough memory, please increase max_nber_dep"
);
/* Not written yet => write it */
if
(
test
)
{
if
(
!
written
)
{
fprintf
(
f
,
tmp
);
}
}
...
...
@@ -187,6 +223,7 @@ void scheduler_write_dependency(struct scheduler *s) {
fprintf
(
f
,
"}"
);
fclose
(
f
);
free
(
table
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment