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
674b8442
"...gpu/git@developer.sourcefind.cn:gaoqiong/migraphx.git" did not exist on "4064d804ba6beca8f7269631c7bc3bc95abd7602"
Commit
674b8442
authored
Jun 20, 2023
by
Paul
Browse files
Handle compile failures
parent
8dd49c16
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
13 deletions
+27
-13
src/targets/gpu/compile_ops.cpp
src/targets/gpu/compile_ops.cpp
+27
-13
No files found.
src/targets/gpu/compile_ops.cpp
View file @
674b8442
...
@@ -112,11 +112,26 @@ struct compile_plan
...
@@ -112,11 +112,26 @@ struct compile_plan
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
<
optional
<
compiled_result
>
>
results
=
{};
void
update_config
(
bool
exhaustive
)
void
update_config
(
bool
exhaustive
)
{
{
config
=
get_tuning_config
(
*
ctx
,
ins
,
preop
,
exhaustive
);
config
=
get_tuning_config
(
*
ctx
,
ins
,
preop
,
exhaustive
);
}
}
template
<
class
Vector
>
void
insert_compiles
(
Vector
&
compiles
,
const
value
&
solution
,
std
::
size_t
i
)
{
compiles
.
emplace_back
([
=
]
{
try
{
results
[
i
]
=
compiled_result
{
compile
(
*
ctx
,
ins
,
preop
,
solution
),
ins
};
}
catch
(...)
{
results
[
i
]
=
nullopt
;
}
});
}
template
<
class
Vector
>
template
<
class
Vector
>
void
add_compiles
(
Vector
&
compiles
,
problem_cache
&
pc
)
void
add_compiles
(
Vector
&
compiles
,
problem_cache
&
pc
)
{
{
...
@@ -130,30 +145,25 @@ struct compile_plan
...
@@ -130,30 +145,25 @@ struct compile_plan
if
(
solution
.
is_null
())
if
(
solution
.
is_null
())
return
;
return
;
results
.
resize
(
1
);
results
.
resize
(
1
);
compiles
.
emplace_back
([
=
]
{
insert_compiles
(
compiles
,
solution
,
0
);
results
[
0
]
=
compiled_result
{
compile
(
*
ctx
,
ins
,
preop
,
solution
),
ins
};
});
}
}
else
else
{
{
pc
.
mark
(
preop
.
name
(),
problem
);
pc
.
mark
(
preop
.
name
(),
problem
);
const
auto
&
solutions
=
config
->
solutions
;
const
auto
&
solutions
=
config
->
solutions
;
std
::
cout
<<
solutions
.
size
()
<<
std
::
endl
;
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
([
=
]
{
insert_compiles
(
compiles
,
solution
,
i
);
results
[
i
]
=
compiled_result
{
compile
(
*
ctx
,
ins
,
preop
,
solution
),
ins
};
});
}
}
}
}
}
}
else
else
{
{
results
.
resize
(
1
);
results
.
resize
(
1
);
compiles
.
emplace_back
([
=
]
{
insert_compiles
(
compiles
,
value
{},
0
);
results
[
0
]
=
compiled_result
{
compile
(
*
ctx
,
ins
,
preop
,
value
{}),
ins
};
});
}
}
}
}
const
compiled_result
&
benchmark
(
problem_cache
&
pc
)
const
const
compiled_result
&
benchmark
(
problem_cache
&
pc
)
const
...
@@ -161,7 +171,7 @@ struct compile_plan
...
@@ -161,7 +171,7 @@ struct compile_plan
if
(
results
.
empty
())
if
(
results
.
empty
())
MIGRAPHX_THROW
(
"No configs to tune"
);
MIGRAPHX_THROW
(
"No configs to tune"
);
if
(
results
.
size
()
==
1
)
if
(
results
.
size
()
==
1
)
return
results
.
front
();
return
*
results
.
front
();
if
(
not
config
)
if
(
not
config
)
MIGRAPHX_THROW
(
"Multiple kernels without config"
);
MIGRAPHX_THROW
(
"Multiple kernels without config"
);
std
::
cout
<<
"Benchmarking "
<<
preop
.
name
()
<<
": "
<<
results
.
size
()
<<
" configs"
std
::
cout
<<
"Benchmarking "
<<
preop
.
name
()
<<
": "
<<
results
.
size
()
<<
" configs"
...
@@ -170,11 +180,15 @@ struct compile_plan
...
@@ -170,11 +180,15 @@ struct compile_plan
times
.
reserve
(
results
.
size
());
times
.
reserve
(
results
.
size
());
std
::
transform
(
std
::
transform
(
results
.
begin
(),
results
.
end
(),
std
::
back_inserter
(
times
),
[
&
](
const
auto
&
cr
)
{
results
.
begin
(),
results
.
end
(),
std
::
back_inserter
(
times
),
[
&
](
const
auto
&
cr
)
{
return
time_op
(
*
ctx
,
cr
.
replace
.
code_object
,
to_shapes
(
cr
.
ins
->
inputs
()),
20
).
first
;
if
(
not
cr
.
has_value
())
return
std
::
numeric_limits
<
double
>::
max
();
return
time_op
(
*
ctx
,
cr
->
replace
.
code_object
,
to_shapes
(
cr
->
ins
->
inputs
()),
20
).
first
;
});
});
auto
i
=
std
::
distance
(
times
.
begin
(),
std
::
min_element
(
times
.
begin
(),
times
.
end
()));
auto
i
=
std
::
distance
(
times
.
begin
(),
std
::
min_element
(
times
.
begin
(),
times
.
end
()));
pc
.
insert
(
preop
.
name
(),
config
->
problem
,
config
->
solutions
.
at
(
i
));
pc
.
insert
(
preop
.
name
(),
config
->
problem
,
config
->
solutions
.
at
(
i
));
return
results
[
i
];
if
(
not
results
[
i
].
has_value
())
MIGRAPHX_THROW
(
"No valid tuned compilation."
);
return
*
results
[
i
];
}
}
void
replace
(
module
&
m
,
problem_cache
&
pc
)
const
void
replace
(
module
&
m
,
problem_cache
&
pc
)
const
{
{
...
...
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