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
d436986b
Commit
d436986b
authored
Jun 17, 2023
by
Artur Wojcik
Browse files
prepare for Windows resources with resource script files
Signed-off-by:
Artur Wojcik
<
artur.wojcik@amd.com
>
parent
a694fecb
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
91 additions
and
80 deletions
+91
-80
cmake/Embed.cmake
cmake/Embed.cmake
+39
-47
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
+12
-3
src/targets/gpu/compile_hip.cpp
src/targets/gpu/compile_hip.cpp
+2
-2
src/targets/gpu/compile_hip_code_object.cpp
src/targets/gpu/compile_hip_code_object.cpp
+20
-14
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
No files found.
cmake/Embed.cmake
View file @
d436986b
...
@@ -81,16 +81,17 @@ function(generate_embed_source EMBED_NAME)
...
@@ -81,16 +81,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
()
...
@@ -101,49 +102,47 @@ function(generate_embed_source EMBED_NAME)
...
@@ -101,49 +102,47 @@ function(generate_embed_source EMBED_NAME)
endif
()
endif
()
string
(
APPEND INIT_KERNELS
"
string
(
APPEND INIT_KERNELS
"
{
\"
${
BASE_NAME
}
\"
, {
${
START_SYMBOL
}
,
${
EN
D
_SYMBOL
}
} },
{
\"
${
BASE_NAME
}
\"
, {
${
START_SYMBOL
}
,
${
L
EN
GTH
_SYMBOL
}
} },
"
)
"
)
endforeach
()
endforeach
()
file
(
WRITE
"
${
PARSE_HEADER
}
"
"
file
(
WRITE
"
${
PARSE_HEADER
}
"
"
#include <unordered_map>
#include <string>
#include <utility>
#include <utility>
const std::unordered_map<std::string, std::pair<const char*,const char*>>&
${
EMBED_NAME
}
();
#include <string_view>
#include <vector>
std::vector<std::pair<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::vector<std::pair
<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::vector<std::pair
<std::string
_view
, std::
string_view
>> result = {
${
INIT_KERNELS
}
};
return result;
return result;
}
}
"
)
"
)
endfunction
()
endfunction
()
function
(
embed_file
OUTPUT_FILE OUTPUT_SYMBOL
FILE
)
macro
(
embed_file FILE
)
set
(
WORKING_DIRECTORY
${
CMAKE_CURRENT_SOURCE_DIR
}
)
message
(
STATUS
"
${
FILE
}
"
)
# Glob is used to compute the relative path
# Glob is used to compute the relative path
file
(
GLOB FILES RELATIVE
${
WORKING_DIRECTORY
}
${
FILE
}
)
file
(
GLOB FILES RELATIVE
${
CMAKE_CURRENT_SOURCE_DIR
}
${
FILE
}
)
foreach
(
REL_FILE
${
FILES
}
)
foreach
(
REL_FILE
${
FILES
}
)
string
(
MAKE_C_IDENTIFIER
"
${
REL_FILE
}
"
SYMBOL
)
string
(
MAKE_C_IDENTIFIER
"
${
REL_FILE
}
"
OUTPUT_
SYMBOL
)
get_filename_component
(
OUTPUT_FILE_DIR
"
${
REL_FILE
}
"
DIRECTORY
)
get_filename_component
(
OUTPUT_FILE_DIR
"
${
REL_FILE
}
"
DIRECTORY
)
file
(
MAKE_DIRECTORY
"
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
OUTPUT_FILE_DIR
}
"
)
file
(
MAKE_DIRECTORY
"
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
OUTPUT_FILE_DIR
}
"
)
if
(
EMBED_USE_LD
)
if
(
EMBED_USE_LD
)
set
(
OUT_FILE
"
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
REL_FILE
}
.o"
)
set
(
OUT
PUT
_FILE
"
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
REL_FILE
}
.o"
)
else
()
else
()
set
(
OUT_FILE
"
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
REL_FILE
}
.cpp"
)
set
(
OUT
PUT
_FILE
"
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
REL_FILE
}
.cpp"
)
endif
()
endif
()
set
(
${
OUTPUT_SYMBOL
}
${
SYMBOL
}
PARENT_SCOPE
)
set
(
${
OUTPUT_FILE
}
"
${
OUT_FILE
}
"
PARENT_SCOPE
)
if
(
EMBED_USE_LD
)
if
(
EMBED_USE_LD
)
add_custom_command
(
add_custom_command
(
OUTPUT
"
${
OUT_FILE
}
"
OUTPUT
"
${
OUT
PUT
_FILE
}
"
COMMAND
${
EMBED_LD
}
-r -o
"
${
OUT_FILE
}
"
-z noexecstack --format=binary
"
${
REL_FILE
}
"
COMMAND
${
EMBED_LD
}
-r -o
"
${
OUT
PUT
_FILE
}
"
-z noexecstack --format=binary
"
${
REL_FILE
}
"
COMMAND
${
EMBED_OBJCOPY
}
--rename-section .data=.rodata,alloc,load,readonly,data,contents
"
${
OUT_FILE
}
"
COMMAND
${
EMBED_OBJCOPY
}
--rename-section .data=.rodata,alloc,load,readonly,data,contents
"
${
OUT
PUT
_FILE
}
"
WORKING_DIRECTORY
${
WORKING_DIRECTORY
}
WORKING_DIRECTORY
${
CMAKE_CURRENT_SOURCE_DIR
}
DEPENDS
${
FILE
}
DEPENDS
${
FILE
}
VERBATIM
VERBATIM
)
)
...
@@ -157,13 +156,13 @@ function(embed_file OUTPUT_FILE OUTPUT_SYMBOL FILE)
...
@@ -157,13 +156,13 @@ function(embed_file OUTPUT_FILE OUTPUT_SYMBOL FILE)
string
(
REGEX REPLACE
"([0-9a-f][0-9a-f])"
"0x
\\
1, "
ARRAY_VALUES
${
HEX_STRING
}
)
string
(
REGEX REPLACE
"([0-9a-f][0-9a-f])"
"0x
\\
1, "
ARRAY_VALUES
${
HEX_STRING
}
)
# 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
PUT
_FILE
}
"
"
extern const char _binary_
${
SYMBOL
}
_start[] = {
${
ARRAY_VALUES
}
};
extern const char _binary_
${
SYMBOL
}
_start[] = {
${
ARRAY_VALUES
}
};
extern const
char* _binary_
${
SYMBOL
}
_end =
_binary_
${
SYMBOL
}
_
start +
sizeof(_binary_
${
SYMBOL
}
_start);
extern const
size_t
_binary_
${
SYMBOL
}
_
length =
sizeof(_binary_
${
SYMBOL
}
_start);
\n
"
)
\n
"
)
endif
()
endif
()
endforeach
()
endforeach
()
end
function
()
end
macro
()
function
(
add_embed_library EMBED_NAME
)
function
(
add_embed_library EMBED_NAME
)
set
(
options
)
set
(
options
)
...
@@ -171,35 +170,28 @@ function(add_embed_library EMBED_NAME)
...
@@ -171,35 +170,28 @@ function(add_embed_library EMBED_NAME)
set
(
multiValueArgs
)
set
(
multiValueArgs
)
cmake_parse_arguments
(
PARSE
"
${
options
}
"
"
${
oneValueArgs
}
"
"
${
multiValueArgs
}
"
${
ARGN
}
)
cmake_parse_arguments
(
PARSE
"
${
options
}
"
"
${
oneValueArgs
}
"
"
${
multiValueArgs
}
"
${
ARGN
}
)
file
(
MAKE_DIRECTORY
${
CMAKE_CURRENT_BINARY_DIR
}
/embed
)
file
(
MAKE_DIRECTORY
${
CMAKE_CURRENT_BINARY_DIR
}
/embed/
${
EMBED_NAME
}
)
set
(
EMBED_DIR
${
CMAKE_CURRENT_BINARY_DIR
}
/embed/
${
EMBED_NAME
}
)
set
(
EMBED_DIR
${
CMAKE_CURRENT_BINARY_DIR
}
/embed/
${
EMBED_NAME
}
)
file
(
MAKE_DIRECTORY
${
EMBED_DIR
}
)
set
(
SRC_FILE
"
${
EMBED_DIR
}
/
${
EMBED_NAME
}
.cpp"
)
set
(
SRC_FILE
"
${
EMBED_DIR
}
/
${
EMBED_NAME
}
.cpp"
)
set
(
HEADER_FILE
"
${
EMBED_DIR
}
/include/
${
EMBED_NAME
}
.hpp"
)
set
(
HEADER_FILE
"
${
EMBED_DIR
}
/include/
${
EMBED_NAME
}
.hpp"
)
set
(
WORKING_DIRECTORY
${
CMAKE_CURRENT_BINARY_DIR
}
)
message
(
STATUS
"Embedding kernel files:"
)
set
(
OUTPUT_FILES
)
set
(
SYMBOLS
)
message
(
STATUS
"Embedding files"
)
foreach
(
FILE
${
PARSE_UNPARSED_ARGUMENTS
}
)
foreach
(
FILE
${
PARSE_UNPARSED_ARGUMENTS
}
)
embed_file
(
OUTPUT_FILE OUTPUT_SYMBOL
${
FILE
}
)
embed_file
(
${
FILE
}
)
list
(
APPEND OUTPUT_FILES
${
OUTPUT_FILE
}
)
list
(
APPEND OUTPUT_FILES
${
OUTPUT_FILE
}
)
list
(
APPEND SYMBOLS
${
OUTPUT_SYMBOL
}
)
list
(
APPEND SYMBOLS
${
OUTPUT_SYMBOL
}
)
endforeach
()
endforeach
()
message
(
STATUS
"Generating embedding library
${
EMBED_NAME
}
"
)
message
(
STATUS
"Generating embedding library '
${
EMBED_NAME
}
'"
)
generate_embed_source
(
${
EMBED_NAME
}
SRC
${
SRC_FILE
}
HEADER
${
HEADER_FILE
}
OBJECTS
${
OUTPUT_FILES
}
SYMBOLS
${
SYMBOLS
}
RELATIVE
${
PARSE_RELATIVE
}
FILES
${
PARSE_UNPARSED_ARGUMENTS
}
)
generate_embed_source
(
${
EMBED_NAME
}
SRC
${
SRC_FILE
}
set
(
INTERNAL_EMBED_LIB embed_lib_
${
EMBED_NAME
}
)
HEADER
${
HEADER_FILE
}
add_library
(
${
INTERNAL_EMBED_LIB
}
OBJECT
"
${
SRC_FILE
}
"
)
OBJECTS
${
OUTPUT_FILES
}
target_include_directories
(
${
INTERNAL_EMBED_LIB
}
PRIVATE
"
${
EMBED_DIR
}
/include"
)
SYMBOLS
${
SYMBOLS
}
target_compile_options
(
${
INTERNAL_EMBED_LIB
}
PRIVATE -Wno-reserved-identifier -Wno-extern-initializer -Wno-missing-variable-declarations
)
RELATIVE
${
PARSE_RELATIVE
}
set_target_properties
(
${
INTERNAL_EMBED_LIB
}
PROPERTIES POSITION_INDEPENDENT_CODE On
)
FILES
${
PARSE_UNPARSED_ARGUMENTS
}
)
add_library
(
${
EMBED_NAME
}
INTERFACE
)
add_library
(
${
EMBED_NAME
}
OBJECT
${
SRC_FILE
}
${
OUTPUT_FILES
}
)
if
(
EMBED_USE_LD
)
target_include_directories
(
${
EMBED_NAME
}
PUBLIC
${
EMBED_DIR
}
/include
)
target_sources
(
${
EMBED_NAME
}
INTERFACE
${
OUTPUT_FILES
}
)
target_compile_options
(
${
EMBED_NAME
}
PUBLIC -Wno-reserved-identifier -Wno-extern-initializer -Wno-missing-variable-declarations
)
else
()
set_target_properties
(
${
EMBED_NAME
}
PROPERTIES POSITION_INDEPENDENT_CODE On
)
target_sources
(
${
INTERNAL_EMBED_LIB
}
PRIVATE
${
OUTPUT_FILES
}
)
endif
()
target_sources
(
${
EMBED_NAME
}
INTERFACE $<TARGET_OBJECTS:
${
INTERNAL_EMBED_LIB
}
>
)
target_include_directories
(
${
EMBED_NAME
}
INTERFACE
"
${
EMBED_DIR
}
/include"
)
endfunction
()
endfunction
()
src/compile_src.cpp
View file @
d436986b
...
@@ -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 @
d436986b
...
@@ -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
()
=
delete
;
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 @
d436986b
...
@@ -44,11 +44,20 @@ else()
...
@@ -44,11 +44,20 @@ 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
}
"
)
add_embed_library
(
migraphx_kernels
${
KERNEL_FILES
}
RELATIVE
${
CMAKE_CURRENT_SOURCE_DIR
}
/kernels/include/
)
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
()
if
(
NOT WIN32
)
include
(
Embed
)
add_embed_library
(
migraphx_kernels
${
KERNEL_FILES
}
RELATIVE
${
CMAKE_CURRENT_SOURCE_DIR
}
/kernels/include/
)
endif
()
file
(
GLOB DEVICE_GPU_SRCS CONFIGURE_DEPENDS
${
CMAKE_CURRENT_SOURCE_DIR
}
/device/*.cpp
)
file
(
GLOB DEVICE_GPU_SRCS CONFIGURE_DEPENDS
${
CMAKE_CURRENT_SOURCE_DIR
}
/device/*.cpp
)
add_library
(
migraphx_device
${
DEVICE_GPU_SRCS
}
)
add_library
(
migraphx_device
${
DEVICE_GPU_SRCS
}
)
...
...
src/targets/gpu/compile_hip.cpp
View file @
d436986b
...
@@ -220,7 +220,7 @@ compile_hip_src(const std::vector<src_file>& srcs, std::string params, const std
...
@@ -220,7 +220,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
);
...
@@ -310,7 +310,7 @@ compile_hip_src(const std::vector<src_file>& srcs, std::string params, const std
...
@@ -310,7 +310,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
;
}
}
}
}
...
...
src/targets/gpu/compile_hip_code_object.cpp
View file @
d436986b
...
@@ -153,6 +153,20 @@ std::size_t compute_block_size(std::size_t n, std::size_t max_block_size)
...
@@ -153,6 +153,20 @@ std::size_t compute_block_size(std::size_t n, std::size_t max_block_size)
return
std
::
min
(
std
::
max
(
min_block_size
,
block_size
),
max_block_size
);
return
std
::
min
(
std
::
max
(
min_block_size
,
block_size
),
max_block_size
);
}
}
#ifndef _WIN32
std
::
vector
<
src_file
>
migraphx_kernels
()
{
auto
kernels
{
::
migraphx_kernels
()};
std
::
vector
<
src_file
>
result
;
std
::
transform
(
kernels
.
begin
(),
kernels
.
end
(),
std
::
back_inserter
(
result
),
[](
std
::
pair
<
std
::
string_view
,
std
::
string_view
>
const
&
elem
)
{
return
src_file
{
elem
};
});
return
result
;
}
#endif
operation
compile_hip_code_object
(
const
std
::
string
&
content
,
hip_compile_options
options
)
operation
compile_hip_code_object
(
const
std
::
string
&
content
,
hip_compile_options
options
)
{
{
assert
(
options
.
global
>
0
);
assert
(
options
.
global
>
0
);
...
@@ -160,22 +174,14 @@ operation compile_hip_code_object(const std::string& content, hip_compile_option
...
@@ -160,22 +174,14 @@ operation compile_hip_code_object(const std::string& content, hip_compile_option
assert
(
not
options
.
inputs
.
empty
());
assert
(
not
options
.
inputs
.
empty
());
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
{
migraphx_kernels
()};
std
::
transform
(
migraphx_kernels
().
begin
(),
srcs
.
insert
(
migraphx_kernels
().
end
(),
srcs
.
end
(),
options
.
additional_src_files
.
begin
(),
options
.
additional_src_files
.
end
());
std
::
back_inserter
(
srcs
),
srcs
.
emplace_back
(
"main.cpp"
,
content
);
[](
auto
&&
p
)
{
auto
&&
name
=
p
.
first
;
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 @
d436986b
...
@@ -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 @
d436986b
...
@@ -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 @
d436986b
...
@@ -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 @
d436986b
...
@@ -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 @
d436986b
...
@@ -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
);
}
}
...
...
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