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
66c55aa3
Commit
66c55aa3
authored
6 years ago
by
Loic Hausammann
Browse files
Options
Downloads
Patches
Plain Diff
Update task dependency with nber link
parent
c6b41bb3
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!616
Update task dependency with nber link
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/scheduler.c
+70
-16
70 additions, 16 deletions
src/scheduler.c
with
70 additions
and
16 deletions
src/scheduler.c
+
70
−
16
View file @
66c55aa3
...
...
@@ -113,6 +113,31 @@ void scheduler_addunlock(struct scheduler *s, struct task *ta,
atomic_inc
(
&
s
->
completed_unlock_writes
);
}
/**
* @brief generate the dependency name for the tasks
*
* @param ta The #task
* @param ta_name The formatted string
*/
void
scheduler_task_dependency_name
(
int
ta_type
,
int
ta_subtype
,
char
*
ta_name
)
{
/* Check input */
if
(
ta_type
<
0
||
ta_type
>=
task_type_count
)
error
(
"Unknown task type %i"
,
ta_type
);
if
(
ta_subtype
<
0
||
ta_subtype
>=
task_subtype_count
)
error
(
"Unknown task subtype %i with type %s"
,
ta_subtype
,
taskID_names
[
ta_type
]);
/* construct line */
if
(
ta_subtype
==
task_subtype_none
)
sprintf
(
ta_name
,
"%s"
,
taskID_names
[
ta_type
]);
else
sprintf
(
ta_name
,
"
\"
%s %s
\"
"
,
taskID_names
[
ta_type
],
subtaskID_names
[
ta_subtype
]);
}
/**
* @brief Write a dot file with the task dependencies.
*
...
...
@@ -139,10 +164,15 @@ void scheduler_write_dependencies(struct scheduler *s, int verbose) {
* task_subtype */
int
*
table
=
(
int
*
)
malloc
(
nber_relation
*
sizeof
(
int
));
if
(
table
==
NULL
)
error
(
"Error allocating memory for task-dependency graph."
);
error
(
"Error allocating memory for task-dependency graph (table)."
);
int
*
count_rel
=
(
int
*
)
malloc
(
nber_relation
*
sizeof
(
int
)
/
2
);
if
(
count_rel
==
NULL
)
error
(
"Error allocating memory for task-dependency graph (count_rel)."
);
/* Reset everything */
for
(
int
i
=
0
;
i
<
nber_relation
;
i
++
)
table
[
i
]
=
-
1
;
for
(
int
i
=
0
;
i
<
nber_relation
/
2
;
i
++
)
count_rel
[
i
]
=
0
;
/* Create file */
char
filename
[
200
]
=
"dependency_graph.dot"
;
...
...
@@ -189,13 +219,16 @@ void scheduler_write_dependencies(struct scheduler *s, int verbose) {
}
k
+=
1
;
cur
=
&
cur
[
3
];
cur
=
&
cur
[
2
];
}
/* max_nber_dep is too small */
if
(
k
==
max_nber_dep
)
error
(
"Not enough memory, please increase max_nber_dep"
);
/* Increase counter of relation */
count_rel
[
ind
/
2
+
k
]
+=
1
;
/* Not written yet => write it */
if
(
!
written
)
{
...
...
@@ -204,20 +237,8 @@ void scheduler_write_dependencies(struct scheduler *s, int verbose) {
char
tb_name
[
200
];
/* construct line */
if
(
ta
->
subtype
==
task_subtype_none
)
sprintf
(
ta_name
,
"%s"
,
taskID_names
[
ta
->
type
]);
else
sprintf
(
ta_name
,
"
\"
%s %s
\"
"
,
taskID_names
[
ta
->
type
],
subtaskID_names
[
ta
->
subtype
]);
if
(
tb
->
subtype
==
task_subtype_none
)
sprintf
(
tb_name
,
"%s"
,
taskID_names
[
tb
->
type
]);
else
sprintf
(
tb_name
,
"
\"
%s %s
\"
"
,
taskID_names
[
tb
->
type
],
subtaskID_names
[
tb
->
subtype
]);
/* Write to the ffile */
fprintf
(
f
,
"
\t
%s->%s;
\n
"
,
ta_name
,
tb_name
);
scheduler_task_dependency_name
(
ta
->
type
,
ta
->
subtype
,
ta_name
);
scheduler_task_dependency_name
(
tb
->
type
,
tb
->
subtype
,
tb_name
);
/* Change colour of implicit tasks */
if
(
ta
->
implicit
)
...
...
@@ -312,6 +333,39 @@ void scheduler_write_dependencies(struct scheduler *s, int verbose) {
fprintf
(
f
,
"
\t\t
%s;
\n
"
,
taskID_names
[
task_type_grav_mm
]);
fprintf
(
f
,
"
\t
};
\n
"
);
/* Write down the number of relation */
for
(
int
ta_type
=
0
;
ta_type
<
task_type_count
;
ta_type
++
)
{
for
(
int
ta_subtype
=
0
;
ta_subtype
<
task_subtype_count
;
ta_subtype
++
)
{
/* Get task indice */
const
int
ind
=
(
ta_type
*
task_subtype_count
+
ta_subtype
)
*
max_nber_dep
;
/* Loop over dependencies */
for
(
int
k
=
0
;
k
<
max_nber_dep
;
k
++
)
{
if
(
count_rel
[
ind
+
k
]
==
0
)
continue
;
/* Get task type */
const
int
i
=
2
*
(
ind
+
k
);
int
tb_type
=
table
[
i
];
int
tb_subtype
=
table
[
i
+
1
];
/* Get names */
char
ta_name
[
200
];
char
tb_name
[
200
];
scheduler_task_dependency_name
(
ta_type
,
ta_subtype
,
ta_name
);
scheduler_task_dependency_name
(
tb_type
,
tb_subtype
,
tb_name
);
/* Write to the fle */
fprintf
(
f
,
"
\t
%s->%s[label=%i];
\n
"
,
ta_name
,
tb_name
,
count_rel
[
ind
+
k
]);
}
}
}
/* Be clean */
fprintf
(
f
,
"}"
);
fclose
(
f
);
...
...
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