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
aaaf9fa1
Commit
aaaf9fa1
authored
Oct 05, 2023
by
Artur Wojcik
Browse files
enable compilation on Windows
Signed-off-by:
Artur Wojcik
<
artur.wojcik@amd.com
>
parent
216f9662
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
508 additions
and
17 deletions
+508
-17
CMakeLists.txt
CMakeLists.txt
+3
-0
extern/CMakeLists.txt
extern/CMakeLists.txt
+198
-0
src/driver/CMakeLists.txt
src/driver/CMakeLists.txt
+1
-0
src/register_target.cpp
src/register_target.cpp
+4
-0
src/targets/cpu/CMakeLists.txt
src/targets/cpu/CMakeLists.txt
+2
-2
src/targets/gpu/compile_hip.cpp
src/targets/gpu/compile_hip.cpp
+11
-3
src/targets/gpu/kernels/migraphx_kernels.cpp
src/targets/gpu/kernels/migraphx_kernels.cpp
+87
-0
src/targets/gpu/kernels/migraphx_kernels.hpp
src/targets/gpu/kernels/migraphx_kernels.hpp
+38
-0
src/targets/gpu/kernels/resource.h
src/targets/gpu/kernels/resource.h
+64
-0
src/targets/gpu/kernels/resource.rc
src/targets/gpu/kernels/resource.rc
+59
-0
src/tmp_dir.cpp
src/tmp_dir.cpp
+11
-1
test/CMakeLists.txt
test/CMakeLists.txt
+25
-6
test/api/CMakeLists.txt
test/api/CMakeLists.txt
+0
-4
test/jit.cpp
test/jit.cpp
+5
-1
No files found.
CMakeLists.txt
View file @
aaaf9fa1
...
@@ -63,6 +63,9 @@ else()
...
@@ -63,6 +63,9 @@ else()
option
(
MIGRAPHX_USE_COMPOSABLEKERNEL
"Enable MIGraphX to use composable kernel JIT library"
ON
)
option
(
MIGRAPHX_USE_COMPOSABLEKERNEL
"Enable MIGraphX to use composable kernel JIT library"
ON
)
endif
()
endif
()
# By default build shared libraries
option
(
BUILD_SHARED_LIBS
"Create shared libraries"
ON
)
find_path
(
HALF_INCLUDE_DIR half.hpp PATH_SUFFIXES half
)
find_path
(
HALF_INCLUDE_DIR half.hpp PATH_SUFFIXES half
)
if
(
NOT HALF_INCLUDE_DIR
)
if
(
NOT HALF_INCLUDE_DIR
)
message
(
FATAL_ERROR
"Could not find half.hpp - Please check that the install path of half.hpp has been added to CMAKE_PREFIX_PATH"
)
message
(
FATAL_ERROR
"Could not find half.hpp - Please check that the install path of half.hpp has been added to CMAKE_PREFIX_PATH"
)
...
...
extern/CMakeLists.txt
0 → 100644
View file @
aaaf9fa1
#####################################################################################
# The MIT License (MIT)
#
# Copyright (c) 2015-2022 Advanced Micro Devices, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#####################################################################################
# Windows build requires CMake version 3.24 at minimum, due to SYSTEM argument to FetchContent
cmake_minimum_required
(
VERSION 3.24.0 FATAL_ERROR
)
# https://cmake.org/cmake/help/latest/policy/CMP0135.html
cmake_policy
(
SET CMP0135 NEW
)
include
(
FetchContent
)
set
(
CMAKE_CXX_STANDARD 17 CACHE INTERNAL
""
)
set
(
CMAKE_CXX_STANDARD_REQUIRED ON CACHE INTERNAL
""
)
set
(
CMAKE_CXX_EXTENSIONS OFF CACHE INTERNAL
""
)
FetchContent_Declare
(
HALF
URL https://downloads.sourceforge.net/project/half/half/2.2.0/half-2.2.0.zip?ts=gAAAAABjwYR1XMSTpEV_SFhJCBhkdlggkBl9O2GQawgvJmGwqYTAsgEacimyfdBymL6etwelv_kYY7BdlCpy4mgcqceBbymbeQ%3D%3D&r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fhalf%2Ffiles%2Flatest%2Fdownload
URL_MD5 b169bcfda2c65e90f73167e06368a27a
SYSTEM
)
set
(
JSON_BuildTests OFF CACHE INTERNAL
""
)
FetchContent_Declare
(
nlohmann_json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.11.2
SYSTEM
)
set
(
protobuf_BUILD_SHARED_LIBS OFF CACHE INTERNAL
""
)
set
(
protobuf_MSVC_STATIC_RUNTIME OFF CACHE INTERNAL
""
)
set
(
ABSL_BUILD_TESTING OFF CACHE INTERNAL
""
)
set
(
ABSL_USE_SYSTEM_INCLUDES ON CACHE INTERNAL
""
)
set
(
ABSL_PROPAGATE_CXX_STD ON CACHE INTERNAL
""
)
set
(
ABSL_ENABLE_INSTALL OFF CACHE INTERNAL
""
)
set
(
protobuf_BUILD_LIBPROTOC ON CACHE INTERNAL
""
)
set
(
protobuf_BUILD_TESTS OFF CACHE INTERNAL
""
)
set
(
protobuf_BUILD_PROTOC_BINARIES ON CACHE INTERNAL
""
)
set
(
protobuf_BUILD_PROTOBUF_BINARIES ON CACHE INTERNAL
""
)
set
(
protobuf_INSTALL OFF CACHE INTERNAL
""
)
FetchContent_Declare
(
protobuf
GIT_REPOSITORY https://github.com/protocolbuffers/protobuf.git
GIT_TAG v22.2
SYSTEM
)
set
(
MSGPACK_USE_BOOST OFF CACHE INTERNAL
""
)
set
(
MSGPACK_CXX17 ON CACHE INTERNAL
""
)
set
(
MSGPACK_BUILD_TESTS OFF CACHE INTERNAL
""
)
set
(
MSGPACK_BUILD_DOCS OFF CACHE INTERNAL
""
)
FetchContent_Declare
(
msgpack
GIT_REPOSITORY https://github.com/msgpack/msgpack-c.git
GIT_TAG cpp-5.0.0
SYSTEM
)
# Workaround: we only need Blaze header file, the part below helps to pass CMake configuration.
set
(
BLAS_LIBRARIES rocBLAS CACHE INTERNAL
""
)
set
(
LAPACK_LIBRARIES rocLAPACK CACHE INTERNAL
""
)
FetchContent_Declare
(
blaze
GIT_REPOSITORY https://bitbucket.org/blaze-lib/blaze.git
GIT_TAG v3.8.2
SYSTEM
)
# Store the current value of BUILD_SHARED_LIBS
set
(
__build_shared_libs
${
BUILD_SHARED_LIBS
}
)
set
(
BUILD_SHARED_LIBS OFF CACHE INTERNAL
""
)
FetchContent_MakeAvailable
(
HALF nlohmann_json protobuf msgpack blaze
)
# Restore the old value of BUILD_SHARED_LIBS
set
(
BUILD_SHARED_LIBS
${
__build_shared_libs
}
CACHE BOOL
""
FORCE
)
if
(
MIGRAPHX_ENABLE_CPU
)
if
(
NOT MIGRAPHX_ENABLE_ZENDNN
)
set
(
DNNL_BUILD_TESTS OFF CACHE INTERNAL
""
)
if
(
CMAKE_CXX_COMPILER_ID STREQUAL
"Clang"
)
# oneDNN version 1.7 workaround on clang++ error: no such file or directory: '/Od'
set
(
MINGW ON CACHE INTERNAL
""
)
endif
()
FetchContent_Declare
(
dnnl
GIT_REPOSITORY https://github.com/oneapi-src/oneDNN.git
GIT_TAG v1.7
SYSTEM
)
FetchContent_MakeAvailable
(
dnnl
)
if
(
CMAKE_CXX_COMPILER_ID STREQUAL
"Clang"
)
unset
(
MINGW
)
endif
()
set
(
__dnnl_compile_options
-fdelayed-template-parsing
-fms-extensions
-fms-compatibility
-Wno-unused-but-set-variable
-Wno-unused-variable
)
target_compile_options
(
dnnl
PRIVATE
${
__dnnl_compile_options
}
)
target_compile_options
(
dnnl_common
PRIVATE
${
__dnnl_compile_options
}
)
target_compile_options
(
dnnl_cpu
PRIVATE
${
__dnnl_compile_options
}
)
target_compile_options
(
dnnl_cpu_x64
PRIVATE
${
__dnnl_compile_options
}
)
unset
(
__dnnl_compile_options
)
# For compatibility with find_package()
add_library
(
DNNL::dnnl INTERFACE IMPORTED GLOBAL
)
target_link_libraries
(
DNNL::dnnl INTERFACE dnnl
)
add_library
(
DNNL::dnnl_common INTERFACE IMPORTED GLOBAL
)
target_link_libraries
(
DNNL::dnnl_common INTERFACE dnnl_common
)
add_library
(
DNNL::dnnl_cpu INTERFACE IMPORTED GLOBAL
)
target_link_libraries
(
DNNL::dnnl_cpu INTERFACE dnnl_cpu
)
add_library
(
DNNL::dnnl_cpu_x64 INTERFACE IMPORTED GLOBAL
)
target_link_libraries
(
DNNL::dnnl_cpu_x64 INTERFACE dnnl_cpu_x64
)
endif
()
endif
()
set
(
__protobuf_compile_options
-Wno-undef
-Wno-deprecated-declarations
)
target_compile_options
(
libprotobuf
PRIVATE
${
__protobuf_compile_options
}
)
target_compile_options
(
libprotobuf-lite
PRIVATE
${
__protobuf_compile_options
}
)
target_compile_options
(
libprotoc
PRIVATE
${
__protobuf_compile_options
}
)
set
(
HALF_INCLUDE_DIR
${
CMAKE_BINARY_DIR
}
/_deps/half-src/include PARENT_SCOPE
)
set
(
BLAZE_INCLUDE
${
CMAKE_BINARY_DIR
}
/_deps/blaze-src PARENT_SCOPE
)
set
(
protobuf_PROTOC_EXE
${
protobuf_BINARY_DIR
}
/protoc.exe PARENT_SCOPE
)
set
(
protobuf_DIR
${
protobuf_SOURCE_DIR
}
/cmake PARENT_SCOPE
)
if
(
NOT NMAKE_DIR
)
set
(
NMAKE_DIR
"$ENV{NMAKE_DIR}"
)
endif
()
find_program
(
NMAKE_EXECUTABLE NAMES nmake.exe REQUIRED HINTS
"
${
NMAKE_DIR
}
"
)
include
(
ExternalProject
)
ExternalProject_Add
(
sqlite3
GIT_REPOSITORY https://github.com/sqlite/sqlite.git
GIT_TAG version-3.40.0
GIT_SHALLOW true
UPDATE_DISCONNECTED true
CONFIGURE_COMMAND
""
BUILD_COMMAND
${
NMAKE_EXECUTABLE
}
/f ..\\sqlite3\\Makefile.msc USE_AMALGAMATION=1 NO_TCL=1 TOP=..\\sqlite3 libsqlite3.lib
INSTALL_COMMAND
""
)
ExternalProject_Get_Property
(
sqlite3 BINARY_DIR
)
# For compatibility with PkgConfig on Linux
add_library
(
PkgConfig::SQLITE3 INTERFACE IMPORTED GLOBAL
)
add_dependencies
(
PkgConfig::SQLITE3 sqlite3
)
target_link_directories
(
PkgConfig::SQLITE3 INTERFACE
${
BINARY_DIR
}
)
target_link_libraries
(
PkgConfig::SQLITE3 INTERFACE libsqlite3.lib
)
target_include_directories
(
PkgConfig::SQLITE3 INTERFACE
${
BINARY_DIR
}
)
src/driver/CMakeLists.txt
View file @
aaaf9fa1
...
@@ -43,6 +43,7 @@ if(NOT WIN32)
...
@@ -43,6 +43,7 @@ if(NOT WIN32)
)
)
set_directory_properties
(
PROPERTIES ADDITIONAL_CLEAN_FILES
${
CMAKE_RUNTIME_OUTPUT_DIRECTORY
}
/driver
)
set_directory_properties
(
PROPERTIES ADDITIONAL_CLEAN_FILES
${
CMAKE_RUNTIME_OUTPUT_DIRECTORY
}
/driver
)
endif
()
endif
()
target_compile_options
(
driver PRIVATE -Wno-ignored-attributes -Wno-unused-parameter
)
rocm_clang_tidy_check
(
driver
)
rocm_clang_tidy_check
(
driver
)
file
(
STRINGS
"
${
CMAKE_SOURCE_DIR
}
/test/onnx/.onnxrt-commit"
String_output
)
file
(
STRINGS
"
${
CMAKE_SOURCE_DIR
}
/test/onnx/.onnxrt-commit"
String_output
)
...
...
src/register_target.cpp
View file @
aaaf9fa1
...
@@ -56,7 +56,11 @@ target make_target(const std::string& name)
...
@@ -56,7 +56,11 @@ target make_target(const std::string& name)
{
{
if
(
not
contains
(
target_map
(),
name
))
if
(
not
contains
(
target_map
(),
name
))
{
{
#ifdef _WIN32
std
::
string
target_name
=
"migraphx_"
+
name
+
".dll"
;
#else
std
::
string
target_name
=
"libmigraphx_"
+
name
+
".so"
;
std
::
string
target_name
=
"libmigraphx_"
+
name
+
".so"
;
#endif
store_target_lib
(
dynamic_loader
(
target_name
));
store_target_lib
(
dynamic_loader
(
target_name
));
}
}
const
auto
it
=
target_map
().
find
(
name
);
const
auto
it
=
target_map
().
find
(
name
);
...
...
src/targets/cpu/CMakeLists.txt
View file @
aaaf9fa1
...
@@ -56,13 +56,13 @@ add_library(migraphx_cpu
...
@@ -56,13 +56,13 @@ add_library(migraphx_cpu
set_target_properties
(
migraphx_cpu PROPERTIES EXPORT_NAME cpu
)
set_target_properties
(
migraphx_cpu PROPERTIES EXPORT_NAME cpu
)
rocm_set_soversion
(
migraphx_cpu
${
MIGRAPHX_SO_VERSION
}
)
rocm_set_soversion
(
migraphx_cpu
${
MIGRAPHX_SO_VERSION
}
)
set
(
MIGRAPHX_ENABLE_ZENDNN
Off CACHE BOOL
""
)
option
(
MIGRAPHX_ENABLE_ZENDNN
"MIGraphX enable ZenDNN"
Off
)
if
(
MIGRAPHX_ENABLE_ZENDNN
)
if
(
MIGRAPHX_ENABLE_ZENDNN
)
find_path
(
ZENDNN_INC_PATH zendnn.hpp
)
find_path
(
ZENDNN_INC_PATH zendnn.hpp
)
find_library
(
ZENDNN_LIB amdZenDNN
)
find_library
(
ZENDNN_LIB amdZenDNN
)
find_library
(
BLIS_LIB blis
)
find_library
(
BLIS_LIB blis
)
else
(
)
else
if
(
NOT WIN32
)
find_package
(
dnnl REQUIRED
)
find_package
(
dnnl REQUIRED
)
endif
()
endif
()
...
...
src/targets/gpu/compile_hip.cpp
View file @
aaaf9fa1
...
@@ -251,8 +251,12 @@ compile_hip_src(const std::vector<src_file>& srcs, std::string params, const std
...
@@ -251,8 +251,12 @@ compile_hip_src(const std::vector<src_file>& srcs, std::string params, const std
std
::
cout
<<
std
::
string
(
src
.
content
)
<<
std
::
endl
;
std
::
cout
<<
std
::
string
(
src
.
content
)
<<
std
::
endl
;
}
}
}
}
#ifdef _WIN32
fs
::
path
driver
{
"migraphx-hiprtc-driver.exe"
};
#else
auto
p
=
dynamic_loader
::
path
(
&
compile_hip_src_with_hiprtc
);
auto
p
=
dynamic_loader
::
path
(
&
compile_hip_src_with_hiprtc
);
auto
driver
=
p
.
parent_path
().
parent_path
()
/
"bin"
/
"migraphx-hiprtc-driver"
;
auto
driver
=
p
.
parent_path
().
parent_path
()
/
"bin"
/
"migraphx-hiprtc-driver"
;
#endif
if
(
fs
::
exists
(
driver
))
if
(
fs
::
exists
(
driver
))
{
{
...
@@ -284,16 +288,21 @@ std::vector<std::vector<char>> compile_hip_src_with_hiprtc(std::vector<hiprtc_sr
...
@@ -284,16 +288,21 @@ std::vector<std::vector<char>> compile_hip_src_with_hiprtc(std::vector<hiprtc_sr
bool
is_hip_clang_compiler
()
bool
is_hip_clang_compiler
()
{
{
static
const
auto
result
=
ends_with
(
MIGRAPHX_STRINGIZE
(
MIGRAPHX_HIP_COMPILER
),
"clang++"
);
static
const
auto
result
=
fs
::
path
{
MIGRAPHX_STRINGIZE
(
MIGRAPHX_HIP_COMPILER
)}.
stem
()
==
"clang++"
;
return
result
;
return
result
;
}
}
#ifdef MIGRAPHX_HIP_COMPILER_LAUNCHER
bool
has_compiler_launcher
()
bool
has_compiler_launcher
()
{
{
static
const
auto
result
=
fs
::
exists
(
MIGRAPHX_STRINGIZE
(
MIGRAPHX_HIP_COMPILER_LAUNCHER
));
static
const
auto
result
=
fs
::
exists
(
MIGRAPHX_STRINGIZE
(
MIGRAPHX_HIP_COMPILER_LAUNCHER
));
return
result
;
return
result
;
}
}
#endif
src_compiler
assemble
(
src_compiler
compiler
)
src_compiler
assemble
(
src_compiler
compiler
)
{
{
compiler
.
out_ext
=
".S"
;
compiler
.
out_ext
=
".S"
;
...
@@ -306,8 +315,7 @@ compile_hip_src(const std::vector<src_file>& srcs, std::string params, const std
...
@@ -306,8 +315,7 @@ compile_hip_src(const std::vector<src_file>& srcs, std::string params, const std
{
{
assert
(
not
srcs
.
empty
());
assert
(
not
srcs
.
empty
());
if
(
not
is_hip_clang_compiler
())
if
(
not
is_hip_clang_compiler
())
MIGRAPHX_THROW
(
"Unknown hip compiler: "
+
MIGRAPHX_THROW
(
"Unknown hip compiler: "
MIGRAPHX_STRINGIZE
(
MIGRAPHX_HIP_COMPILER
));
std
::
string
(
MIGRAPHX_STRINGIZE
(
MIGRAPHX_HIP_COMPILER
)));
if
(
params
.
find
(
"-std="
)
==
std
::
string
::
npos
)
if
(
params
.
find
(
"-std="
)
==
std
::
string
::
npos
)
params
+=
" --std=c++17"
;
params
+=
" --std=c++17"
;
...
...
src/targets/gpu/kernels/migraphx_kernels.cpp
0 → 100644
View file @
aaaf9fa1
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2022 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <Windows.h>
#include "migraphx_kernels.hpp"
#include "resource.h"
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
gpu
{
namespace
resource
{
std
::
string_view
read
(
int
id
)
{
HMODULE
handle
{
::
GetModuleHandle
(
nullptr
)};
HRSRC
rc
{
::
FindResource
(
handle
,
MAKEINTRESOURCE
(
id
),
MAKEINTRESOURCE
(
MIGRAPHX_TEXTFILE
))};
HGLOBAL
data
{
::
LoadResource
(
handle
,
rc
)};
return
{
static_cast
<
char
const
*>
(
::
LockResource
(
data
)),
::
SizeofResource
(
handle
,
rc
)};
}
}
// namespace resource
std
::
vector
<
src_file
>
migraphx_kernels
()
{
static
src_file
_kernels_
[]
=
{
{
"migraphx/kernels/algorithm.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_ALGORITHM_HPP
)},
{
"migraphx/kernels/args.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_ARGS_HPP
)},
{
"migraphx/kernels/array.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_ARRAY_HPP
)},
{
"migraphx/kernels/concat.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_CONCAT_HPP
)},
{
"migraphx/kernels/debug.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_DEBUG_HPP
)},
{
"migraphx/kernels/dfor.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_DFOR_HPP
)},
{
"migraphx/kernels/dpp.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_DPP_HPP
)},
{
"migraphx/kernels/functional.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_FUNCTIONAL_HPP
)},
{
"migraphx/kernels/gather.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_GATHER_HPP
)},
{
"migraphx/kernels/gathernd.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_GATHERND_HPP
)},
{
"migraphx/kernels/generic_constant.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_GENERIC_CONSTANT_HPP
)},
{
"migraphx/kernels/hip.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_HIP_HPP
)},
{
"migraphx/kernels/index.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_INDEX_HPP
)},
{
"migraphx/kernels/integral_constant.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_INTEGRAL_CONSTANT_HPP
)},
{
"migraphx/kernels/iota_iterator.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_IOTA_ITERATOR_HPP
)},
{
"migraphx/kernels/layernorm.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_LAYERNORM_HPP
)},
{
"migraphx/kernels/math.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_MATH_HPP
)},
{
"migraphx/kernels/ops.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_OPS_HPP
)},
{
"migraphx/kernels/pad.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_PAD_HPP
)},
{
"migraphx/kernels/pointwise.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_POINTWISE_HPP
)},
{
"migraphx/kernels/preload.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_PRELOAD_HPP
)},
{
"migraphx/kernels/print.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_PRINT_HPP
)},
{
"migraphx/kernels/ranges.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_RANGES_HPP
)},
{
"migraphx/kernels/reduce.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_REDUCE_HPP
)},
{
"migraphx/kernels/roialign.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_ROIALIGN_HPP
)},
{
"migraphx/kernels/scatternd.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_SCATTERND_HPP
)},
{
"migraphx/kernels/shape.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_SHAPE_HPP
)},
{
"migraphx/kernels/softmax.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_SOFTMAX_HPP
)},
{
"migraphx/kernels/tensor_view.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_TENSOR_VIEW_HPP
)},
{
"migraphx/kernels/type_traits.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_TYPE_TRAITS_HPP
)},
{
"migraphx/kernels/types.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_TYPES_HPP
)},
{
"migraphx/kernels/vec.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_VEC_HPP
)},
{
"migraphx/kernels/vectorize.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_VECTORIZE_HPP
)}};
return
{
std
::
begin
(
_kernels_
),
std
::
end
(
_kernels_
)};
}
}
// namespace gpu
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
src/targets/gpu/kernels/migraphx_kernels.hpp
0 → 100644
View file @
aaaf9fa1
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2022 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MIGRAPHX_GUARD_MIGRAPHX_KERNELS_HPP
#define MIGRAPHX_GUARD_MIGRAPHX_KERNELS_HPP
#include "migraphx/compile_src.hpp"
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
gpu
{
std
::
vector
<
src_file
>
migraphx_kernels
();
}
// namespace gpu
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
#endif // MIGRAPHX_GUARD_MIGRAPHX_KERNELS_HPP
src/targets/gpu/kernels/resource.h
0 → 100644
View file @
aaaf9fa1
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2022 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MIGRAPHX_GUARD_MIGRAPHX_KERNELS_RESOURCE_H
#define MIGRAPHX_GUARD_MIGRAPHX_KERNELS_RESOURCE_H
#define MIGRAPHX_TEXTFILE 256
#define MIGRAPHX_IDR_ALGORITHM_HPP 101
#define MIGRAPHX_IDR_ARGS_HPP 102
#define MIGRAPHX_IDR_ARRAY_HPP 103
#define MIGRAPHX_IDR_CONCAT_HPP 104
#define MIGRAPHX_IDR_DEBUG_HPP 105
#define MIGRAPHX_IDR_DFOR_HPP 106
#define MIGRAPHX_IDR_DPP_HPP 107
#define MIGRAPHX_IDR_FUNCTIONAL_HPP 108
#define MIGRAPHX_IDR_GATHER_HPP 109
#define MIGRAPHX_IDR_GATHERND_HPP 110
#define MIGRAPHX_IDR_GENERIC_CONSTANT_HPP 111
#define MIGRAPHX_IDR_HIP_HPP 112
#define MIGRAPHX_IDR_INDEX_HPP 113
#define MIGRAPHX_IDR_INTEGRAL_CONSTANT_HPP 114
#define MIGRAPHX_IDR_IOTA_ITERATOR_HPP 115
#define MIGRAPHX_IDR_LAYERNORM_HPP 116
#define MIGRAPHX_IDR_MATH_HPP 117
#define MIGRAPHX_IDR_OPS_HPP 118
#define MIGRAPHX_IDR_PAD_HPP 119
#define MIGRAPHX_IDR_POINTWISE_HPP 120
#define MIGRAPHX_IDR_PRELOAD_HPP 121
#define MIGRAPHX_IDR_PRINT_HPP 122
#define MIGRAPHX_IDR_RANGES_HPP 123
#define MIGRAPHX_IDR_REDUCE_HPP 124
#define MIGRAPHX_IDR_ROIALIGN_HPP 125
#define MIGRAPHX_IDR_SCATTERND_HPP 126
#define MIGRAPHX_IDR_SHAPE_HPP 127
#define MIGRAPHX_IDR_SOFTMAX_HPP 128
#define MIGRAPHX_IDR_TENSOR_VIEW_HPP 129
#define MIGRAPHX_IDR_TYPE_TRAITS_HPP 130
#define MIGRAPHX_IDR_TYPES_HPP 131
#define MIGRAPHX_IDR_VEC_HPP 132
#define MIGRAPHX_IDR_VECTORIZE_HPP 134
#endif // MIGRAPHX_GUARD_MIGRAPHX_KERNELS_RESOURCE_H
src/targets/gpu/kernels/resource.rc
0 → 100644
View file @
aaaf9fa1
//
// The MIT License (MIT)
//
// Copyright (c) 2015-2022 Advanced Micro Devices, Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#include "resource.h"
MIGRAPHX_IDR_ALGORITHM_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/algorithm.hpp"
MIGRAPHX_IDR_ARGS_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/args.hpp"
MIGRAPHX_IDR_ARRAY_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/array.hpp"
MIGRAPHX_IDR_CONCAT_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/concat.hpp"
MIGRAPHX_IDR_DEBUG_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/debug.hpp"
MIGRAPHX_IDR_DFOR_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/dfor.hpp"
MIGRAPHX_IDR_DPP_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/dpp.hpp"
MIGRAPHX_IDR_FUNCTIONAL_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/functional.hpp"
MIGRAPHX_IDR_GATHER_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/gather.hpp"
MIGRAPHX_IDR_GATHERND_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/gathernd.hpp"
MIGRAPHX_IDR_GENERIC_CONSTANT_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/generic_constant.hpp"
MIGRAPHX_IDR_HIP_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/hip.hpp"
MIGRAPHX_IDR_INDEX_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/index.hpp"
MIGRAPHX_IDR_INTEGRAL_CONSTANT_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/integral_constant.hpp"
MIGRAPHX_IDR_IOTA_ITERATOR_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/iota_iterator.hpp"
MIGRAPHX_IDR_LAYERNORM_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/layernorm.hpp"
MIGRAPHX_IDR_MATH_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/math.hpp"
MIGRAPHX_IDR_OPS_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/ops.hpp"
MIGRAPHX_IDR_PAD_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/pad.hpp"
MIGRAPHX_IDR_POINTWISE_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/pointwise.hpp"
MIGRAPHX_IDR_PRELOAD_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/preload.hpp"
MIGRAPHX_IDR_PRINT_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/print.hpp"
MIGRAPHX_IDR_RANGES_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/ranges.hpp"
MIGRAPHX_IDR_REDUCE_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/reduce.hpp"
MIGRAPHX_IDR_ROIALIGN_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/roialign.hpp"
MIGRAPHX_IDR_SCATTERND_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/scatternd.hpp"
MIGRAPHX_IDR_SHAPE_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/shape.hpp"
MIGRAPHX_IDR_SOFTMAX_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/softmax.hpp"
MIGRAPHX_IDR_TENSOR_VIEW_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/tensor_view.hpp"
MIGRAPHX_IDR_TYPE_TRAITS_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/type_traits.hpp"
MIGRAPHX_IDR_TYPES_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/types.hpp"
MIGRAPHX_IDR_VEC_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/vec.hpp"
MIGRAPHX_IDR_VECTORIZE_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/vectorize.hpp"
src/tmp_dir.cpp
View file @
aaaf9fa1
...
@@ -31,8 +31,18 @@
...
@@ -31,8 +31,18 @@
#include <sstream>
#include <sstream>
#include <iostream>
#include <iostream>
#include <string>
#include <string>
#include <sys/types.h>
#ifdef _WIN32
// cppcheck-suppress definePrefix
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#undef getpid
// cppcheck-suppress [definePrefix, defineUpperCase]
#define getpid _getpid
#else
#include <unistd.h>
#include <unistd.h>
#include <sys/types.h>
#endif
namespace
migraphx
{
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
inline
namespace
MIGRAPHX_INLINE_NS
{
...
...
test/CMakeLists.txt
View file @
aaaf9fa1
...
@@ -42,8 +42,18 @@ foreach(TEST ${TESTS})
...
@@ -42,8 +42,18 @@ foreach(TEST ${TESTS})
endforeach
()
endforeach
()
if
(
MIGRAPHX_ENABLE_GPU
)
if
(
MIGRAPHX_ENABLE_GPU
)
# gpu tests
set
(
GPU_TESTS
file
(
GLOB GPU_TESTS CONFIGURE_DEPENDS gpu/*.cpp
)
gpu/adjust_allocation.cpp
gpu/context_serialize.cpp
gpu/hip.cpp
gpu/jit.cpp
gpu/literal.cpp
gpu/manage_host_buffer.cpp
gpu/mlir.cpp
gpu/pack_args.cpp
gpu/pack_int8_args.cpp
gpu/quantization.cpp
gpu/stream_sync.cpp
)
foreach
(
TEST
${
GPU_TESTS
}
)
foreach
(
TEST
${
GPU_TESTS
}
)
get_filename_component
(
BASE_NAME
${
TEST
}
NAME_WE
)
get_filename_component
(
BASE_NAME
${
TEST
}
NAME_WE
)
...
@@ -53,16 +63,22 @@ if(MIGRAPHX_ENABLE_GPU)
...
@@ -53,16 +63,22 @@ if(MIGRAPHX_ENABLE_GPU)
COST 10
COST 10
RESOURCE_LOCK gpu
RESOURCE_LOCK gpu
)
)
if
(
WIN32
)
target_include_directories
(
test_gpu_
${
BASE_NAME
}
PRIVATE
${
CMAKE_SOURCE_DIR
}
/src/targets/gpu/kernels
)
else
()
target_link_libraries
(
test_gpu_
${
BASE_NAME
}
migraphx_kernels
)
endif
()
if
(
MIGRAPHX_USE_HIPRTC
)
if
(
MIGRAPHX_USE_HIPRTC
)
target_compile_definitions
(
test_gpu_
${
BASE_NAME
}
PUBLIC -DMIGRAPHX_USE_HIPRTC
)
target_compile_definitions
(
test_gpu_
${
BASE_NAME
}
PUBLIC -DMIGRAPHX_USE_HIPRTC
)
endif
()
endif
()
target_link_libraries
(
test_gpu_
${
BASE_NAME
}
migraphx_gpu
migraphx_kernels
)
target_link_libraries
(
test_gpu_
${
BASE_NAME
}
migraphx_gpu
)
endforeach
()
endforeach
()
endif
()
endif
()
if
(
MIGRAPHX_ENABLE_FPGA
)
if
(
MIGRAPHX_ENABLE_FPGA
)
# fpga tests
set
(
FPGA_TESTS
file
(
GLOB FPGA_TESTS CONFIGURE_DEPENDS fpga/*.cpp
)
fpga/get_target_assignments.cpp
fpga/test_compile.cpp
)
foreach
(
TEST
${
FPGA_TESTS
}
)
foreach
(
TEST
${
FPGA_TESTS
}
)
get_filename_component
(
BASE_NAME
${
TEST
}
NAME_WE
)
get_filename_component
(
BASE_NAME
${
TEST
}
NAME_WE
)
...
@@ -78,7 +94,10 @@ endif()
...
@@ -78,7 +94,10 @@ endif()
# Onnx test
# Onnx test
set
(
TEST_ONNX_DIR
${
CMAKE_CURRENT_SOURCE_DIR
}
/onnx
)
set
(
TEST_ONNX_DIR
${
CMAKE_CURRENT_SOURCE_DIR
}
/onnx
)
file
(
GLOB ONNX_TESTS
${
TEST_ONNX_DIR
}
/*.cpp
)
set
(
ONNX_TESTS
onnx/onnx_rnn_test.cpp
onnx/onnx_test.cpp
onnx/verify_onnx.cpp
)
foreach
(
ONNX_TEST
${
ONNX_TESTS
}
)
foreach
(
ONNX_TEST
${
ONNX_TESTS
}
)
get_filename_component
(
BASE_NAME
${
ONNX_TEST
}
NAME_WE
)
get_filename_component
(
BASE_NAME
${
ONNX_TEST
}
NAME_WE
)
...
...
test/api/CMakeLists.txt
View file @
aaaf9fa1
...
@@ -57,10 +57,6 @@ add_api_test(custom_op test_custom_op.cpp ${TEST_ONNX_DIR})
...
@@ -57,10 +57,6 @@ add_api_test(custom_op test_custom_op.cpp ${TEST_ONNX_DIR})
add_api_test
(
tf_parser test_tf_parser.cpp
${
TEST_TF_DIR
}
)
add_api_test
(
tf_parser test_tf_parser.cpp
${
TEST_TF_DIR
}
)
# GPU-based tests
# GPU-based tests
if
(
MIGRAPHX_ENABLE_GPU
)
if
(
MIGRAPHX_ENABLE_GPU
)
list
(
APPEND CMAKE_PREFIX_PATH /opt/rocm
)
find_package
(
hip
)
add_api_test
(
gpu test_gpu.cpp
${
TEST_ONNX_DIR
}
)
add_api_test
(
gpu test_gpu.cpp
${
TEST_ONNX_DIR
}
)
target_link_libraries
(
test_api_gpu
)
add_api_test
(
custom_op_gpu test_custom_op_gpu.cpp
${
TEST_ONNX_DIR
}
)
add_api_test
(
custom_op_gpu test_custom_op_gpu.cpp
${
TEST_ONNX_DIR
}
)
target_link_libraries
(
test_api_custom_op_gpu
)
endif
()
endif
()
test/jit.cpp
View file @
aaaf9fa1
...
@@ -46,8 +46,12 @@ std::function<F>
...
@@ -46,8 +46,12 @@ std::function<F>
compile_function
(
const
std
::
string
&
src
,
const
std
::
string
&
flags
,
const
std
::
string
&
fname
)
compile_function
(
const
std
::
string
&
src
,
const
std
::
string
&
flags
,
const
std
::
string
&
fname
)
{
{
migraphx
::
src_compiler
compiler
;
migraphx
::
src_compiler
compiler
;
compiler
.
flags
=
flags
+
"-std=c++14 -fPIC -shared"
;
compiler
.
flags
=
flags
+
"-std=c++14 -fPIC -shared"
;
#ifdef _WIN32
compiler
.
output
=
"simple.dll"
;
#else
compiler
.
output
=
"libsimple.so"
;
compiler
.
output
=
"libsimple.so"
;
#endif
migraphx
::
src_file
f
{
"main.cpp"
,
src
};
migraphx
::
src_file
f
{
"main.cpp"
,
src
};
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