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
b0bc71cd
Unverified
Commit
b0bc71cd
authored
Nov 18, 2021
by
Paul Fultz II
Committed by
GitHub
Nov 18, 2021
Browse files
Parallel compilation (#1007)
Do compilation in parallel
parent
785307c3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
2 deletions
+17
-2
src/targets/gpu/compile_ops.cpp
src/targets/gpu/compile_ops.cpp
+17
-2
No files found.
src/targets/gpu/compile_ops.cpp
View file @
b0bc71cd
...
...
@@ -3,6 +3,7 @@
#include <migraphx/module.hpp>
#include <migraphx/iterator_for.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/par_for.hpp>
#include <migraphx/register_op.hpp>
#include <migraphx/op/identity.hpp>
#include <migraphx/gpu/compile_pointwise.hpp>
...
...
@@ -63,17 +64,31 @@ std::unordered_map<std::string, compiler_function> make_compilers(Ts... xs)
return
{{
xs
.
name
(),
make_compiler_function
(
xs
)}...};
}
struct
compiled_result
{
operation
op
;
instruction_ref
ins
;
};
void
compile_ops
::
apply
(
module
&
m
)
const
{
auto
compilers
=
make_compilers
(
pointwise_compiler
{});
std
::
vector
<
std
::
function
<
compiled_result
()
>>
compiles
;
for
(
auto
ins
:
iterator_for
(
m
))
{
if
(
ins
->
name
()
!=
"gpu::precompile_op"
)
continue
;
operation
preop
=
any_cast
<
precompile_op
>
(
ins
->
get_operator
()).
op
;
assert
(
contains
(
compilers
,
preop
.
name
()));
auto
op
=
compilers
[
preop
.
name
()](
*
ctx
,
ins
,
preop
);
m
.
replace_instruction
(
ins
,
op
,
ins
->
inputs
());
auto
c
=
compilers
[
preop
.
name
()];
compiles
.
emplace_back
([
=
]()
->
compiled_result
{
return
{
c
(
*
ctx
,
ins
,
preop
),
ins
};
});
}
std
::
vector
<
compiled_result
>
results
(
compiles
.
size
());
par_for
(
compiles
.
size
(),
1
,
[
&
](
auto
i
)
{
results
[
i
]
=
compiles
[
i
]();
});
for
(
const
auto
&
cr
:
results
)
{
m
.
replace_instruction
(
cr
.
ins
,
cr
.
op
,
cr
.
ins
->
inputs
());
}
}
...
...
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