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
9d8331b4
Unverified
Commit
9d8331b4
authored
Oct 06, 2023
by
Artur Wojcik
Committed by
GitHub
Oct 06, 2023
Browse files
prepare for Windows resources with resource script files (#1999)
parent
c7f0fbc4
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
54 additions
and
48 deletions
+54
-48
cmake/Embed.cmake
cmake/Embed.cmake
+15
-14
src/compile_src.cpp
src/compile_src.cpp
+1
-1
src/include/migraphx/compile_src.hpp
src/include/migraphx/compile_src.hpp
+12
-2
src/targets/gpu/CMakeLists.txt
src/targets/gpu/CMakeLists.txt
+9
-1
src/targets/gpu/compile_hip.cpp
src/targets/gpu/compile_hip.cpp
+3
-5
src/targets/gpu/compile_hip_code_object.cpp
src/targets/gpu/compile_hip_code_object.cpp
+9
-13
src/targets/gpu/include/migraphx/gpu/compile_hip.hpp
src/targets/gpu/include/migraphx/gpu/compile_hip.hpp
+1
-4
src/targets/gpu/jit/ck_gemm.cpp
src/targets/gpu/jit/ck_gemm.cpp
+1
-2
test/gpu/jit.cpp
test/gpu/jit.cpp
+1
-1
test/gpu/stream_sync.cpp
test/gpu/stream_sync.cpp
+1
-1
test/jit.cpp
test/jit.cpp
+1
-3
test/multi_target/multitarget_test.cpp
test/multi_target/multitarget_test.cpp
+0
-1
No files found.
cmake/Embed.cmake
View file @
9d8331b4
...
@@ -77,16 +77,17 @@ function(generate_embed_source EMBED_NAME)
...
@@ -77,16 +77,17 @@ function(generate_embed_source EMBED_NAME)
list
(
GET PARSE_FILES
${
idx
}
FILE
)
list
(
GET PARSE_FILES
${
idx
}
FILE
)
set
(
START_SYMBOL
"_binary_
${
SYMBOL
}
_start"
)
set
(
START_SYMBOL
"_binary_
${
SYMBOL
}
_start"
)
set
(
EN
D
_SYMBOL
"_binary_
${
SYMBOL
}
_en
d
"
)
set
(
L
EN
GTH
_SYMBOL
"_binary_
${
SYMBOL
}
_
l
en
gth
"
)
if
(
EMBED_USE_LD
)
if
(
EMBED_USE_LD
)
string
(
APPEND EXTERNS
"
string
(
APPEND EXTERNS
"
extern const char
${
START_SYMBOL
}
[];
extern const char
${
START_SYMBOL
}
[];
extern const char
${
END_SYMBOL
}
[];
extern const size_t _binary_
${
SYMBOL
}
_size;
const auto
${
LENGTH_SYMBOL
}
= reinterpret_cast<size_t>(&_binary_
${
SYMBOL
}
_size);
"
)
"
)
else
()
else
()
string
(
APPEND EXTERNS
"
string
(
APPEND EXTERNS
"
extern const char
${
START_SYMBOL
}
[];
extern const char
${
START_SYMBOL
}
[];
extern const
char*
${
EN
D
_SYMBOL
}
;
extern const
size_t
${
L
EN
GTH
_SYMBOL
}
;
"
)
"
)
endif
()
endif
()
...
@@ -97,23 +98,22 @@ function(generate_embed_source EMBED_NAME)
...
@@ -97,23 +98,22 @@ function(generate_embed_source EMBED_NAME)
endif
()
endif
()
string
(
APPEND INIT_KERNELS
"
string
(
APPEND INIT_KERNELS
"
{
\"
${
BASE_NAME
}
\"
, {
${
START_SYMBOL
}
,
${
END_SYMBOL
}
} },
{
\"
${
BASE_NAME
}
\"
, {
${
START_SYMBOL
}
,
${
LENGTH_SYMBOL
}
} },"
)
"
)
endforeach
()
endforeach
()
file
(
WRITE
"
${
PARSE_HEADER
}
"
"
file
(
WRITE
"
${
PARSE_HEADER
}
"
"
#include <string_view>
#include <unordered_map>
#include <unordered_map>
#include <string>
#include <utility>
#include <utility>
const
std::unordered_map<std::string, std::
pair<const char*,const char*>>&
${
EMBED_NAME
}
();
std::unordered_map<std::string
_view
, std::
string_view>
${
EMBED_NAME
}
();
"
)
"
)
file
(
WRITE
"
${
PARSE_SRC
}
"
"
file
(
WRITE
"
${
PARSE_SRC
}
"
"
#include <
${
EMBED_NAME
}
.hpp>
#include <
${
EMBED_NAME
}
.hpp>
${
EXTERNS
}
${
EXTERNS
}
const
std::unordered_map<std::string, std::
pair<const char*,const char*>>&
${
EMBED_NAME
}
()
std::unordered_map<std::string
_view
, std::
string_view>
${
EMBED_NAME
}
()
{
{
static
const
std::unordered_map<std::string, std::
pair<const char*,const char*>
> result = {
${
INIT_KERNELS
}
};
static std::unordered_map<std::string
_view
, std::
string_view
> result = {
${
INIT_KERNELS
}
};
return result;
return result;
}
}
"
)
"
)
...
@@ -154,9 +154,10 @@ function(embed_file OUTPUT_FILE OUTPUT_SYMBOL FILE)
...
@@ -154,9 +154,10 @@ function(embed_file OUTPUT_FILE OUTPUT_SYMBOL FILE)
# removes trailing comma
# removes trailing comma
string
(
REGEX REPLACE
", $"
""
ARRAY_VALUES
${
ARRAY_VALUES
}
)
string
(
REGEX REPLACE
", $"
""
ARRAY_VALUES
${
ARRAY_VALUES
}
)
file
(
WRITE
"
${
OUT_FILE
}
"
"
file
(
WRITE
"
${
OUT_FILE
}
"
"
extern const char _binary_
${
SYMBOL
}
_start[] = {
${
ARRAY_VALUES
}
};
#include <cstddef>
extern const char* _binary_
${
SYMBOL
}
_end = _binary_
${
SYMBOL
}
_start + sizeof(_binary_
${
SYMBOL
}
_start);
extern const char _binary_
${
SYMBOL
}
_start[] = {
${
ARRAY_VALUES
}
};
\n
"
)
extern const size_t _binary_
${
SYMBOL
}
_length = sizeof(_binary_
${
SYMBOL
}
_start);
"
)
endif
()
endif
()
endforeach
()
endforeach
()
endfunction
()
endfunction
()
...
...
src/compile_src.cpp
View file @
9d8331b4
...
@@ -46,7 +46,7 @@ std::vector<char> src_compiler::compile(const std::vector<src_file>& srcs) const
...
@@ -46,7 +46,7 @@ std::vector<char> src_compiler::compile(const std::vector<src_file>& srcs) const
fs
::
path
full_path
=
td
.
path
/
src
.
path
;
fs
::
path
full_path
=
td
.
path
/
src
.
path
;
fs
::
path
parent_path
=
full_path
.
parent_path
();
fs
::
path
parent_path
=
full_path
.
parent_path
();
fs
::
create_directories
(
parent_path
);
fs
::
create_directories
(
parent_path
);
write_buffer
(
full_path
.
string
(),
src
.
content
.
first
,
src
.
len
());
write_buffer
(
full_path
.
string
(),
src
.
content
.
data
(),
src
.
content
.
size
());
if
(
src
.
path
.
extension
().
string
()
==
".cpp"
)
if
(
src
.
path
.
extension
().
string
()
==
".cpp"
)
{
{
params
+=
" "
+
src
.
path
.
filename
().
string
();
params
+=
" "
+
src
.
path
.
filename
().
string
();
...
...
src/include/migraphx/compile_src.hpp
View file @
9d8331b4
...
@@ -37,8 +37,18 @@ inline namespace MIGRAPHX_INLINE_NS {
...
@@ -37,8 +37,18 @@ inline namespace MIGRAPHX_INLINE_NS {
struct
src_file
struct
src_file
{
{
fs
::
path
path
;
fs
::
path
path
;
std
::
pair
<
const
char
*
,
const
char
*>
content
;
std
::
string_view
content
;
std
::
size_t
len
()
const
{
return
content
.
second
-
content
.
first
;
}
src_file
()
=
default
;
src_file
(
fs
::
path
file_path
,
std
::
string_view
file_content
)
:
path
{
std
::
move
(
file_path
)},
content
{
file_content
}
{
}
explicit
src_file
(
const
std
::
pair
<
std
::
string_view
,
std
::
string_view
>&
pair
)
:
path
{
pair
.
first
},
content
{
pair
.
second
}
{
}
};
};
struct
MIGRAPHX_EXPORT
src_compiler
struct
MIGRAPHX_EXPORT
src_compiler
...
...
src/targets/gpu/CMakeLists.txt
View file @
9d8331b4
...
@@ -48,10 +48,18 @@ else()
...
@@ -48,10 +48,18 @@ else()
set
(
MIGRAPHX_USE_HIPRTC ON CACHE BOOL
"Use hipRTC APIs"
)
set
(
MIGRAPHX_USE_HIPRTC ON CACHE BOOL
"Use hipRTC APIs"
)
endif
()
endif
()
include
(
Embed
)
file
(
GLOB KERNEL_FILES CONFIGURE_DEPENDS
file
(
GLOB KERNEL_FILES CONFIGURE_DEPENDS
${
CMAKE_CURRENT_SOURCE_DIR
}
/kernels/include/migraphx/kernels/*.hpp
)
${
CMAKE_CURRENT_SOURCE_DIR
}
/kernels/include/migraphx/kernels/*.hpp
)
message
(
STATUS
"KERNEL_FILES:
${
KERNEL_FILES
}
"
)
message
(
STATUS
"KERNEL_FILES:
${
KERNEL_FILES
}
"
)
if
(
WIN32
)
# TODO: re-enable when CK is ported to Windows
list
(
REMOVE_ITEM KERNEL_FILES
${
CMAKE_CURRENT_SOURCE_DIR
}
/kernels/include/migraphx/kernels/ck_gemm.hpp
${
CMAKE_CURRENT_SOURCE_DIR
}
/kernels/include/migraphx/kernels/ck.hpp
)
endif
()
include
(
Embed
)
add_embed_library
(
migraphx_kernels
${
KERNEL_FILES
}
RELATIVE
${
CMAKE_CURRENT_SOURCE_DIR
}
/kernels/include/
)
add_embed_library
(
migraphx_kernels
${
KERNEL_FILES
}
RELATIVE
${
CMAKE_CURRENT_SOURCE_DIR
}
/kernels/include/
)
configure_file
(
device/targets.hpp.in include/migraphx/gpu/device/targets.hpp
)
configure_file
(
device/targets.hpp.in include/migraphx/gpu/device/targets.hpp
)
...
...
src/targets/gpu/compile_hip.cpp
View file @
9d8331b4
...
@@ -248,7 +248,7 @@ compile_hip_src(const std::vector<src_file>& srcs, std::string params, const std
...
@@ -248,7 +248,7 @@ compile_hip_src(const std::vector<src_file>& srcs, std::string params, const std
{
{
if
(
src
.
path
.
extension
()
!=
".cpp"
)
if
(
src
.
path
.
extension
()
!=
".cpp"
)
continue
;
continue
;
std
::
cout
<<
std
::
string
(
src
.
content
.
first
,
src
.
len
()
)
<<
std
::
endl
;
std
::
cout
<<
std
::
string
(
src
.
content
)
<<
std
::
endl
;
}
}
}
}
auto
p
=
dynamic_loader
::
path
(
&
compile_hip_src_with_hiprtc
);
auto
p
=
dynamic_loader
::
path
(
&
compile_hip_src_with_hiprtc
);
...
@@ -338,7 +338,7 @@ compile_hip_src(const std::vector<src_file>& srcs, std::string params, const std
...
@@ -338,7 +338,7 @@ compile_hip_src(const std::vector<src_file>& srcs, std::string params, const std
{
{
if
(
src
.
path
.
extension
()
!=
".cpp"
)
if
(
src
.
path
.
extension
()
!=
".cpp"
)
continue
;
continue
;
std
::
cout
<<
std
::
string
(
src
.
content
.
first
,
src
.
len
()
)
<<
std
::
endl
;
std
::
cout
<<
std
::
string
(
src
.
content
)
<<
std
::
endl
;
}
}
}
}
...
@@ -359,9 +359,7 @@ bool hip_has_flags(const std::vector<std::string>& flags)
...
@@ -359,9 +359,7 @@ bool hip_has_flags(const std::vector<std::string>& flags)
join_strings
(
flags
,
" "
)
+
" -x hip -c --offload-arch=gfx900 --cuda-device-only"
;
join_strings
(
flags
,
" "
)
+
" -x hip -c --offload-arch=gfx900 --cuda-device-only"
;
std
::
string
src
;
std
::
string
src
;
src_file
input
;
src_file
input
{
"main.cpp"
,
src
};
input
.
path
=
"main.cpp"
;
input
.
content
=
std
::
make_pair
(
src
.
data
(),
src
.
data
()
+
src
.
size
());
try
try
{
{
...
...
src/targets/gpu/compile_hip_code_object.cpp
View file @
9d8331b4
...
@@ -172,21 +172,17 @@ operation compile_hip_code_object(const std::string& content, hip_compile_option
...
@@ -172,21 +172,17 @@ operation compile_hip_code_object(const std::string& content, hip_compile_option
assert
(
options
.
inputs
.
size
()
==
options
.
virtual_inputs
.
size
()
or
assert
(
options
.
inputs
.
size
()
==
options
.
virtual_inputs
.
size
()
or
options
.
virtual_inputs
.
empty
());
options
.
virtual_inputs
.
empty
());
std
::
vector
<
src_file
>
srcs
=
options
.
additional_src_files
;
std
::
vector
<
src_file
>
srcs
=
options
.
additional_src_files
;
std
::
transform
(
migraphx_kernels
().
begin
(),
static
auto
kernels
{
::
migraphx_kernels
()};
migraphx_kernels
().
end
(),
std
::
transform
(
kernels
.
begin
(),
kernels
.
end
(),
std
::
back_inserter
(
srcs
),
std
::
back_inserter
(
srcs
),
[](
auto
&&
p
)
{
[](
const
std
::
pair
<
std
::
string_view
,
std
::
string_view
>&
elem
)
{
return
src_file
{
elem
};
});
auto
&&
name
=
p
.
first
;
srcs
.
emplace_back
(
"main.cpp"
,
content
);
auto
&&
c
=
p
.
second
;
auto
path
=
name
;
return
src_file
{
path
,
c
};
});
srcs
.
push_back
(
src_file
{
fs
::
path
{
"main.cpp"
},
std
::
make_pair
(
content
.
data
(),
content
.
data
()
+
content
.
size
())});
auto
args_hpp
=
auto
args_hpp
=
generate_args_hpp
(
options
.
virtual_inputs
.
empty
()
?
options
.
inputs
:
options
.
virtual_inputs
);
generate_args_hpp
(
options
.
virtual_inputs
.
empty
()
?
options
.
inputs
:
options
.
virtual_inputs
);
srcs
.
push_back
(
src_file
{
fs
::
path
{
"
args
.
hpp
"
},
srcs
.
emplace_back
(
"args.hpp"
,
args
_
hpp
);
std
::
make_pair
(
args_hpp
.
data
(),
args_hpp
.
data
()
+
args_hpp
.
size
())});
options
.
params
+=
" -DMIGRAPHX_NGLOBAL="
+
std
::
to_string
(
options
.
global
);
options
.
params
+=
" -DMIGRAPHX_NGLOBAL="
+
std
::
to_string
(
options
.
global
);
options
.
params
+=
" -DMIGRAPHX_NLOCAL="
+
std
::
to_string
(
options
.
local
);
options
.
params
+=
" -DMIGRAPHX_NLOCAL="
+
std
::
to_string
(
options
.
local
);
options
.
params
+=
" "
+
join_strings
(
compiler_warnings
(),
" "
);
options
.
params
+=
" "
+
join_strings
(
compiler_warnings
(),
" "
);
...
...
src/targets/gpu/include/migraphx/gpu/compile_hip.hpp
View file @
9d8331b4
...
@@ -45,10 +45,7 @@ MIGRAPHX_DECLARE_ENV_VAR(MIGRAPHX_ENABLE_HIPRTC_WORKAROUNDS);
...
@@ -45,10 +45,7 @@ MIGRAPHX_DECLARE_ENV_VAR(MIGRAPHX_ENABLE_HIPRTC_WORKAROUNDS);
struct
hiprtc_src_file
struct
hiprtc_src_file
{
{
hiprtc_src_file
()
=
default
;
hiprtc_src_file
()
=
default
;
hiprtc_src_file
(
const
src_file
&
s
)
hiprtc_src_file
(
const
src_file
&
s
)
:
path
(
s
.
path
.
string
()),
content
(
s
.
content
)
{}
:
path
(
s
.
path
.
string
()),
content
(
s
.
content
.
first
,
s
.
content
.
second
)
{
}
std
::
string
path
;
std
::
string
path
;
std
::
string
content
;
std
::
string
content
;
template
<
class
Self
,
class
F
>
template
<
class
Self
,
class
F
>
...
...
src/targets/gpu/jit/ck_gemm.cpp
View file @
9d8331b4
...
@@ -112,8 +112,7 @@ static std::vector<src_file> create_ck_headers()
...
@@ -112,8 +112,7 @@ static std::vector<src_file> create_ck_headers()
std
::
vector
<
src_file
>
srcs
;
std
::
vector
<
src_file
>
srcs
;
std
::
transform
(
std
::
transform
(
header_strings
.
begin
(),
header_strings
.
end
(),
std
::
back_inserter
(
srcs
),
[
&
](
auto
&&
p
)
{
header_strings
.
begin
(),
header_strings
.
end
(),
std
::
back_inserter
(
srcs
),
[
&
](
auto
&&
p
)
{
return
src_file
{
fs
::
path
{
p
.
first
},
return
src_file
{
p
.
first
,
p
.
second
};
{
p
.
second
.
data
(),
p
.
second
.
data
()
+
p
.
second
.
size
()}};
});
});
return
srcs
;
return
srcs
;
}
}
...
...
test/gpu/jit.cpp
View file @
9d8331b4
...
@@ -155,7 +155,7 @@ int main() {}
...
@@ -155,7 +155,7 @@ int main() {}
migraphx
::
src_file
make_src_file
(
const
std
::
string
&
name
,
const
std
::
string
&
content
)
migraphx
::
src_file
make_src_file
(
const
std
::
string
&
name
,
const
std
::
string
&
content
)
{
{
return
{
name
,
std
::
make_pair
(
content
.
data
(),
content
.
data
()
+
content
.
size
())
};
return
{
name
,
content
};
}
}
TEST_CASE
(
simple_compile_hip
)
TEST_CASE
(
simple_compile_hip
)
...
...
test/gpu/stream_sync.cpp
View file @
9d8331b4
...
@@ -64,7 +64,7 @@ int main() {}
...
@@ -64,7 +64,7 @@ int main() {}
migraphx
::
src_file
make_src_file
(
const
std
::
string
&
name
,
const
std
::
string
&
content
)
migraphx
::
src_file
make_src_file
(
const
std
::
string
&
name
,
const
std
::
string
&
content
)
{
{
return
{
name
,
std
::
make_pair
(
content
.
data
(),
content
.
data
()
+
content
.
size
())
};
return
{
name
,
content
};
}
}
hip_stream_ptr
get_stream
()
hip_stream_ptr
get_stream
()
...
...
test/jit.cpp
View file @
9d8331b4
...
@@ -48,9 +48,7 @@ compile_function(const std::string& src, const std::string& flags, const std::st
...
@@ -48,9 +48,7 @@ compile_function(const std::string& src, const std::string& flags, const std::st
migraphx
::
src_compiler
compiler
;
migraphx
::
src_compiler
compiler
;
compiler
.
flags
=
flags
+
"-std=c++14 -fPIC -shared"
;
compiler
.
flags
=
flags
+
"-std=c++14 -fPIC -shared"
;
compiler
.
output
=
"libsimple.so"
;
compiler
.
output
=
"libsimple.so"
;
migraphx
::
src_file
f
;
migraphx
::
src_file
f
{
"main.cpp"
,
src
};
f
.
path
=
"main.cpp"
;
f
.
content
=
std
::
make_pair
(
src
.
data
(),
src
.
data
()
+
src
.
size
());
auto
image
=
compiler
.
compile
({
f
});
auto
image
=
compiler
.
compile
({
f
});
return
migraphx
::
dynamic_loader
{
image
}.
get_function
<
F
>
(
fname
);
return
migraphx
::
dynamic_loader
{
image
}.
get_function
<
F
>
(
fname
);
}
}
...
...
test/multi_target/multitarget_test.cpp
View file @
9d8331b4
...
@@ -37,7 +37,6 @@
...
@@ -37,7 +37,6 @@
#include <migraphx/make_op.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/check_shapes.hpp>
#include <migraphx/check_shapes.hpp>
#include <migraphx/functional.hpp>
#include <migraphx/functional.hpp>
#include <basic_ops.hpp>
#include <migraphx/compile_options.hpp>
#include <migraphx/compile_options.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/generate.hpp>
...
...
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