Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
42104d66
Commit
42104d66
authored
Mar 04, 2019
by
Paul
Browse files
Reduce number of set stream instructions
parent
2685eb4b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletion
+14
-1
src/targets/gpu/schedule_model.cpp
src/targets/gpu/schedule_model.cpp
+13
-1
src/targets/gpu/target.cpp
src/targets/gpu/target.cpp
+1
-0
No files found.
src/targets/gpu/schedule_model.cpp
View file @
42104d66
#include <migraphx/gpu/schedule_model.hpp>
#include <migraphx/gpu/context.hpp>
#include <migraphx/program.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/operation.hpp>
namespace
migraphx
{
...
...
@@ -47,6 +48,7 @@ struct wait_event
assert
(
std
::
none_of
(
wait_for
.
begin
(),
wait_for
.
end
(),
[
&
](
auto
i
)
{
return
i
==
ctx
.
get_current_device
().
stream_id
();
}));
(
void
)
ctx
;
event
=
create_event
();
}
};
...
...
@@ -73,6 +75,16 @@ struct set_stream
std
::
size_t
schedule_model
::
concurrency
()
const
{
return
streams
;
}
void
schedule_model
::
schedule_instruction
(
program
&
p
,
instruction_ref
ins
,
std
::
size_t
n
)
const
{
auto
last_stream
=
std
::
find_if
(
std
::
make_reverse_iterator
(
ins
),
std
::
make_reverse_iterator
(
p
.
begin
()),
[
&
](
auto
&&
i
)
{
return
i
.
name
()
==
"gpu::set_stream"
;
});
if
(
last_stream
!=
std
::
make_reverse_iterator
(
p
.
begin
()))
{
auto
&&
op
=
any_cast
<
set_stream
>
(
last_stream
->
get_operator
());
// If the same stream was set earlier then skip
if
(
op
.
stream
==
n
)
return
;
}
p
.
insert_instruction
(
ins
,
set_stream
{
n
});
}
void
schedule_model
::
wait
(
program
&
p
,
...
...
@@ -80,7 +92,7 @@ void schedule_model::wait(program& p,
std
::
size_t
wait_on
,
const
std
::
vector
<
std
::
size_t
>&
wait_for
)
const
{
p
.
insert
_instruction
(
ins
,
set_stream
{
wait_on
}
);
this
->
schedule
_instruction
(
p
,
ins
,
wait_on
);
p
.
insert_instruction
(
ins
,
wait_event
{
wait_for
});
}
...
...
src/targets/gpu/target.cpp
View file @
42104d66
...
...
@@ -55,6 +55,7 @@ std::vector<pass> target::get_passes(migraphx::context& gctx) const
write_literals
{
&
ctx
},
schedule
{
gpu
::
schedule_model
{
ctx
.
get_current_device
().
nstreams
()}},
// memory_coloring{"hip::allocate"},
dead_code_elimination
{},
// eliminate_workspace{},
eliminate_allocation
{
"hip::allocate"
},
check_context
<
context
>
{},
...
...
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