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
08211545
"src/git@developer.sourcefind.cn:gaoqiong/migraphx.git" did not exist on "80203608fa9c1ffd84667e2e203113b054a6202e"
Commit
08211545
authored
Feb 09, 2023
by
umangyadav
Browse files
changes to make it work with hip-rtc driver
parent
3e58b1e4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
45 deletions
+91
-45
src/compile_src.cpp
src/compile_src.cpp
+3
-3
src/targets/gpu/compile_hip.cpp
src/targets/gpu/compile_hip.cpp
+88
-42
No files found.
src/compile_src.cpp
View file @
08211545
...
...
@@ -37,7 +37,7 @@ std::vector<char> src_compiler::compile(const std::vector<src_file>& srcs) const
tmp_dir
td
{
"compile"
};
auto
params
=
flags
;
params
+=
" -I."
;
//
params += " -I.";
auto
out
=
output
;
...
...
@@ -49,13 +49,13 @@ std::vector<char> src_compiler::compile(const std::vector<src_file>& srcs) const
write_buffer
(
full_path
.
string
(),
src
.
content
.
first
,
src
.
len
());
if
(
src
.
path
.
extension
().
string
()
==
".cpp"
)
{
params
+=
" "
+
src
.
path
.
filename
().
string
();
//
params += " " + src.path.filename().string();
if
(
out
.
empty
())
out
=
src
.
path
.
stem
().
string
()
+
out_ext
;
}
}
params
+=
" -o "
+
out
;
//
params += " -o " + out;
if
(
not
launcher
.
empty
())
{
...
...
src/targets/gpu/compile_hip.cpp
View file @
08211545
...
...
@@ -114,8 +114,8 @@ struct hiprtc_program
{
for
(
auto
&&
src
:
srcs
)
{
std
::
string
content
{
src
.
content
.
first
,
src
.
content
.
second
};
std
::
string
path
=
src
.
path
.
string
();
std
::
string
content
{
src
.
content
.
first
,
src
.
content
.
second
};
if
(
src
.
path
.
extension
().
string
()
==
".cpp"
)
{
cpp_src
=
std
::
move
(
content
);
...
...
@@ -236,58 +236,29 @@ std::vector<std::vector<char>>
compile_hip_src
(
const
std
::
vector
<
src_file
>&
srcs
,
std
::
string
params
,
const
std
::
string
&
arch
)
{
assert
(
not
srcs
.
empty
());
if
(
not
is_hcc_compiler
()
and
not
is_hip_clang_compiler
())
MIGRAPHX_THROW
(
"Unknown hip compiler: "
+
std
::
string
(
MIGRAPHX_STRINGIZE
(
MIGRAPHX_HIP_COMPILER
)));
if
(
params
.
find
(
"-std="
)
==
std
::
string
::
npos
)
params
+=
" --std=c++17"
;
params
+=
" -fno-gpu-rdc"
;
if
(
enabled
(
MIGRAPHX_GPU_DEBUG_SYM
{}))
params
+=
" -g"
;
params
+=
" -c"
;
if
(
is_hcc_compiler
())
{
params
+=
" -amdgpu-target="
+
arch
;
}
else
if
(
is_hip_clang_compiler
())
{
params
+=
" --offload-arch="
+
arch
;
params
+=
" --cuda-device-only"
;
params
+=
" -O"
+
string_value_of
(
MIGRAPHX_GPU_OPTIMIZE
{},
"3"
)
+
" "
;
}
params
+=
" -DMIGRAPHX_USE_HIPRTC=1"
;
params
+=
" -DMIGRAPHX_HAS_DPP=0"
;
params
+=
" -DMIGRAPHX_ENABLE_HIPRTC_WORKAROUNDS=1"
;
params
+=
" -Wno-reserved-identifier"
;
params
+=
" -Wno-gnu-line-marker"
;
params
+=
" -Wno-old-style-cast"
;
if
(
enabled
(
MIGRAPHX_GPU_DEBUG
{}))
params
+=
" -DMIGRAPHX_DEBUG"
;
params
+=
" -Wno-unused-command-line-argument -Wno-cuda-compat "
;
params
+=
MIGRAPHX_STRINGIZE
(
MIGRAPHX_HIP_COMPILER_FLAGS
);
params
+=
" -std=c++17"
;
params
+=
" -fno-gpu-rdc"
;
params
+=
" -O"
+
string_value_of
(
MIGRAPHX_GPU_OPTIMIZE
{},
"3"
);
params
+=
" -Wno-cuda-compat"
;
params
+=
" --offload-arch="
+
arch
;
src_compiler
compiler
;
compiler
.
flags
=
params
;
compiler
.
compiler
=
MIGRAPHX_STRINGIZE
(
MIGRAPHX_HIP_COMPILER
)
;
compiler
.
compiler
=
"/home/umayadav/repo/hiprtc-driver/build/hiprtc-driver"
;
#ifdef MIGRAPHX_HIP_COMPILER_LAUNCHER
if
(
has_compiler_launcher
())
compiler
.
launcher
=
MIGRAPHX_STRINGIZE
(
MIGRAPHX_HIP_COMPILER_LAUNCHER
);
#endif
if
(
is_hcc_compiler
())
compiler
.
process
=
[
&
](
const
fs
::
path
&
obj_path
)
->
fs
::
path
{
process
{
MIGRAPHX_STRINGIZE
(
MIGRAPHX_EXTRACT_KERNEL
)
+
std
::
string
{
" -i "
}
+
obj_path
.
string
()}
.
cwd
(
obj_path
.
parent_path
());
for
(
const
auto
&
entry
:
fs
::
directory_iterator
{
obj_path
.
parent_path
()})
{
const
auto
&
hsaco_path
=
entry
.
path
();
if
(
not
fs
::
is_regular_file
(
hsaco_path
))
continue
;
if
(
hsaco_path
.
extension
()
!=
".hsaco"
)
continue
;
return
hsaco_path
;
}
MIGRAPHX_THROW
(
"Missing hsaco"
);
};
if
(
enabled
(
MIGRAPHX_GPU_DUMP_SRC
{}))
{
for
(
const
auto
&
src
:
srcs
)
...
...
@@ -307,6 +278,81 @@ compile_hip_src(const std::vector<src_file>& srcs, std::string params, const std
return
{
compiler
.
compile
(
srcs
)};
}
// std::vector<std::vector<char>>
// compile_hip_src(const std::vector<src_file>& srcs, std::string params, const std::string& arch)
// {
// assert(not srcs.empty());
// if(not is_hcc_compiler() and not is_hip_clang_compiler())
// MIGRAPHX_THROW("Unknown hip compiler: " +
// std::string(MIGRAPHX_STRINGIZE(MIGRAPHX_HIP_COMPILER)));
// if(params.find("-std=") == std::string::npos)
// params += " --std=c++17";
// params += " -fno-gpu-rdc";
// if(enabled(MIGRAPHX_GPU_DEBUG_SYM{}))
// params += " -g";
// params += " -c";
// if(is_hcc_compiler())
// {
// params += " -amdgpu-target=" + arch;
// }
// else if(is_hip_clang_compiler())
// {
// params += " --offload-arch=" + arch;
// params += " --cuda-device-only";
// params += " -O" + string_value_of(MIGRAPHX_GPU_OPTIMIZE{}, "3") + " ";
// }
// if(enabled(MIGRAPHX_GPU_DEBUG{}))
// params += " -DMIGRAPHX_DEBUG";
// params += " -Wno-unused-command-line-argument -Wno-cuda-compat ";
// params += MIGRAPHX_STRINGIZE(MIGRAPHX_HIP_COMPILER_FLAGS);
// src_compiler compiler;
// compiler.flags = params;
// compiler.compiler = MIGRAPHX_STRINGIZE(MIGRAPHX_HIP_COMPILER);
// #ifdef MIGRAPHX_HIP_COMPILER_LAUNCHER
// if(has_compiler_launcher())
// compiler.launcher = MIGRAPHX_STRINGIZE(MIGRAPHX_HIP_COMPILER_LAUNCHER);
// #endif
// if(is_hcc_compiler())
// compiler.process = [&](const fs::path& obj_path) -> fs::path {
// process{MIGRAPHX_STRINGIZE(MIGRAPHX_EXTRACT_KERNEL) + std::string{" -i "} +
// obj_path.string()}
// .cwd(obj_path.parent_path());
// for(const auto& entry : fs::directory_iterator{obj_path.parent_path()})
// {
// const auto& hsaco_path = entry.path();
// if(not fs::is_regular_file(hsaco_path))
// continue;
// if(hsaco_path.extension() != ".hsaco")
// continue;
// return hsaco_path;
// }
// MIGRAPHX_THROW("Missing hsaco");
// };
// if(enabled(MIGRAPHX_GPU_DUMP_SRC{}))
// {
// for(const auto& src : srcs)
// {
// if(src.path.extension() != ".cpp")
// continue;
// std::cout << std::string(src.content.first, src.len()) << std::endl;
// }
// }
// if(enabled(MIGRAPHX_GPU_DUMP_ASM{}))
// {
// std::cout << assemble(compiler).compile(srcs).data() << std::endl;
// }
// return {compiler.compile(srcs)};
// }
#endif // MIGRAPHX_USE_HIPRTC
std
::
string
enum_params
(
std
::
size_t
count
,
std
::
string
param
)
...
...
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