Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
0fd67cce
Commit
0fd67cce
authored
Mar 08, 2019
by
Paul
Browse files
Reduce number of wait events
parent
213930d8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
2 deletions
+18
-2
src/schedule.cpp
src/schedule.cpp
+18
-2
No files found.
src/schedule.cpp
View file @
0fd67cce
...
@@ -318,6 +318,8 @@ void schedule::apply(program& p) const
...
@@ -318,6 +318,8 @@ void schedule::apply(program& p) const
// Schedule instructions
// Schedule instructions
std
::
unordered_map
<
instruction_ref
,
std
::
size_t
>
ins2wait
;
std
::
unordered_map
<
instruction_ref
,
std
::
size_t
>
ins2wait
;
std
::
size_t
wait_id
=
0
;
std
::
size_t
wait_id
=
0
;
std
::
unordered_map
<
std
::
size_t
,
std
::
unordered_set
<
std
::
size_t
>>
waited_for
;
std
::
unordered_map
<
instruction_ref
,
std
::
unordered_set
<
std
::
size_t
>>
ins2waited
;
for
(
auto
ins
:
iterator_for
(
p
))
for
(
auto
ins
:
iterator_for
(
p
))
{
{
// Only schedule instructions that have a stream
// Only schedule instructions that have a stream
...
@@ -335,7 +337,8 @@ void schedule::apply(program& p) const
...
@@ -335,7 +337,8 @@ void schedule::apply(program& p) const
{
{
if
(
not
si
.
has_stream
(
i
))
if
(
not
si
.
has_stream
(
i
))
continue
;
continue
;
if
(
stream
==
si
.
get_stream
(
i
))
auto
istream
=
si
.
get_stream
(
i
);
if
(
stream
==
istream
)
continue
;
continue
;
// Create a new event if it hasn't been recorded
// Create a new event if it hasn't been recorded
if
(
ins2wait
.
count
(
i
)
==
0
)
if
(
ins2wait
.
count
(
i
)
==
0
)
...
@@ -344,9 +347,22 @@ void schedule::apply(program& p) const
...
@@ -344,9 +347,22 @@ void schedule::apply(program& p) const
model
.
record
(
p
,
i
,
wait_id
);
model
.
record
(
p
,
i
,
wait_id
);
wait_id
++
;
wait_id
++
;
}
}
model
.
wait
(
p
,
ins
,
ins2wait
.
at
(
i
));
auto
w
=
ins2wait
.
at
(
i
);
// If we already waited for the event on this stream then dont
// insert another wait event
if
(
waited_for
[
stream
].
count
(
w
)
==
0
)
model
.
wait
(
p
,
ins
,
w
);
// Store the event as waited
waited_for
[
stream
].
insert
(
w
);
// Store all wait events that have been waited on prior to the recorded instruction
waited_for
[
stream
].
insert
(
ins2waited
[
i
].
begin
(),
ins2waited
[
i
].
end
());
}
}
}
}
// Store wait events that have already been waited on
if
(
si
.
is_split_point
(
ins
,
stream
))
{
ins2waited
[
ins
]
=
waited_for
[
stream
];
}
}
}
// Add memory conflicts
// Add memory conflicts
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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