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
da29ed61
Commit
da29ed61
authored
May 26, 2023
by
Paul
Browse files
Add some comments
parent
acbb2e88
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
8 deletions
+17
-8
src/targets/gpu/compile_ops.cpp
src/targets/gpu/compile_ops.cpp
+17
-8
No files found.
src/targets/gpu/compile_ops.cpp
View file @
da29ed61
...
@@ -81,17 +81,20 @@ struct compile_plan
...
@@ -81,17 +81,20 @@ struct compile_plan
context
*
ctx
;
context
*
ctx
;
operation
preop
;
operation
preop
;
instruction_ref
ins
;
instruction_ref
ins
;
optional
<
tuning_config
>
config
=
nullopt
;
optional
<
tuning_config
>
config
=
nullopt
;
std
::
vector
<
compiled_result
>
results
=
{};
std
::
vector
<
compiled_result
>
results
=
{};
void
update_config
()
{
config
=
get_tuning_config
(
*
ctx
,
ins
,
preop
);
}
void
update_config
()
template
<
class
Vector
>
{
config
=
get_tuning_config
(
*
ctx
,
ins
,
preop
);
}
template
<
class
Vector
>
void
add_compiles
(
Vector
&
compiles
)
void
add_compiles
(
Vector
&
compiles
)
{
{
if
(
config
.
has_value
())
if
(
config
.
has_value
())
{
{
const
auto
&
solutions
=
config
.
value
().
solutions
;
const
auto
&
solutions
=
config
.
value
().
solutions
;
results
.
resize
(
solutions
.
size
());
results
.
resize
(
solutions
.
size
());
for
(
auto
i
:
range
(
solutions
.
size
()))
for
(
auto
i
:
range
(
solutions
.
size
()))
{
{
auto
solution
=
solutions
[
i
];
auto
solution
=
solutions
[
i
];
compiles
.
emplace_back
([
=
]
{
compiles
.
emplace_back
([
=
]
{
...
@@ -131,6 +134,7 @@ void par_compile(std::size_t n, F f)
...
@@ -131,6 +134,7 @@ void par_compile(std::size_t n, F f)
void
compile_ops
::
apply
(
module
&
m
)
const
void
compile_ops
::
apply
(
module
&
m
)
const
{
{
std
::
vector
<
compile_plan
>
cps
;
std
::
vector
<
compile_plan
>
cps
;
// Find all precompile opes
for
(
auto
ins
:
iterator_for
(
m
))
for
(
auto
ins
:
iterator_for
(
m
))
{
{
if
(
ins
->
name
()
!=
"gpu::precompile_op"
)
if
(
ins
->
name
()
!=
"gpu::precompile_op"
)
...
@@ -138,15 +142,20 @@ void compile_ops::apply(module& m) const
...
@@ -138,15 +142,20 @@ void compile_ops::apply(module& m) const
operation
preop
=
any_cast
<
precompile_op
>
(
ins
->
get_operator
()).
op
;
operation
preop
=
any_cast
<
precompile_op
>
(
ins
->
get_operator
()).
op
;
cps
.
push_back
({
ctx
,
preop
,
ins
});
cps
.
push_back
({
ctx
,
preop
,
ins
});
}
}
par_compile
(
cps
.
size
(),
[
&
](
auto
i
)
{
cps
[
i
].
update_config
();
});
// Get the tuning configs for all ops
par_compile
(
cps
.
size
(),
[
&
](
auto
i
)
{
cps
[
i
].
update_config
();
});
// Compile everything in parallel
std
::
vector
<
std
::
function
<
void
()
>>
compiles
;
std
::
vector
<
std
::
function
<
void
()
>>
compiles
;
for
(
auto
&
cp
:
cps
)
for
(
auto
&
cp
:
cps
)
{
{
cp
.
add_compiles
(
compiles
);
cp
.
add_compiles
(
compiles
);
}
}
par_compile
(
compiles
.
size
(),
[
&
](
auto
i
)
{
compiles
[
i
]();
});
par_compile
(
compiles
.
size
(),
[
&
](
auto
i
)
{
compiles
[
i
]();
});
for
(
const
auto
&
cp
:
cps
)
// Replace and/or benchmark
for
(
const
auto
&
cp
:
cps
)
{
{
cp
.
replace
(
m
);
cp
.
replace
(
m
);
}
}
...
...
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