Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
a31b7c6e
MegEngine
项目概览
MegEngine 天元
/
MegEngine
1 年多 前同步成功
通知
404
Star
4705
Fork
582
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
MegEngine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
a31b7c6e
编写于
11月 18, 2020
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
build(rocm): partially support hcc compilation
GitOrigin-RevId: ca9f1f8e8e967565bafd65476a841c4570fb77ee
上级
621ae0a1
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
92 addition
and
99 deletion
+92
-99
cmake/rocm.cmake
cmake/rocm.cmake
+65
-75
dnn/include/hcc_detail/hcc_defs_epilogue.h.in
dnn/include/hcc_detail/hcc_defs_epilogue.h.in
+1
-5
dnn/include/hcc_detail/hcc_defs_prologue.h.in
dnn/include/hcc_detail/hcc_defs_prologue.h.in
+1
-1
dnn/src/CMakeLists.txt
dnn/src/CMakeLists.txt
+24
-14
dnn/src/fallback/batched_matrix_mul/opr_impl.cpp
dnn/src/fallback/batched_matrix_mul/opr_impl.cpp
+0
-1
dnn/src/rocm/miopen_with_check.h
dnn/src/rocm/miopen_with_check.h
+1
-3
未找到文件。
cmake/rocm.cmake
浏览文件 @
a31b7c6e
...
...
@@ -13,89 +13,79 @@ else()
message
(
FATAL_ERROR
"Could not find HIP. Ensure that HIP is either installed in /opt/rocm/hip or the variable HIP_PATH is set to point to the right location."
)
endif
()
string
(
REPLACE
"."
";"
HIP_VERSION_LIST
${
HIP_VERSION
}
)
list
(
GET HIP_VERSION_LIST 0 HIP_VERSION_MAJOR
)
list
(
GET HIP_VERSION_LIST 1 HIP_VERSION_MINOR
)
if
(
NOT
${
HIP_VERSION_MAJOR
}
STREQUAL
"3"
)
message
(
FATAL_ERROR
"ROCM version needed 3.x, Please update ROCM."
)
else
()
if
(
${
HIP_VERSION_MINOR
}
LESS
"7"
)
message
(
WARNING
"ROCM version 3.x which x(got
${
HIP_VERSION_MINOR
}
) greater equal 7 is prefered."
)
endif
()
endif
()
set
(
MGE_ROCM_LIBS OpenCL amdhip64 MIOpen rocblas rocrand
)
set
(
HIP_INCLUDE_DIR
${
HIP_ROOT_DIR
}
/../include
)
set
(
HIP_LIBRARY_DIR
${
HIP_ROOT_DIR
}
/../lib
)
#miopen
get_filename_component
(
__found_miopen_library
${
HIP_ROOT_DIR
}
/../miopen/lib REALPATH
)
find_path
(
MIOPEN_LIBRARY_DIR
NAMES libMIOpen.so
HINTS
${
PC_MIOPEN_INCLUDE_DIRS
}
${
MIOPEN_ROOT_DIR
}
${
ROCM_TOOLKIT_INCLUDE
}
${
__found_miopen_library
}
PATH_SUFFIXES lib
DOC
"Path to MIOPEN library directory."
)
if
(
MIOPEN_LIBRARY_DIR STREQUAL
"MIOPEN_LIBRARY_DIR-NOTFOUND"
)
message
(
FATAL_ERROR
"Can not find MIOPEN Library"
)
if
(
${
HIP_VERSION
}
VERSION_LESS 3.0
)
message
(
FATAL_ERROR
"ROCM version needed 3. Please update ROCM."
)
endif
()
get_filename_component
(
__found_miopen_include
${
HIP_ROOT_DIR
}
/../miopen/include REALPATH
)
find_path
(
MIOPEN_INCLUDE_DIR
NAMES miopen
HINTS
${
PC_MIOPEN_INCLUDE_DIRS
}
${
MIOPEN_ROOT_DIR
}
${
ROCM_TOOLKIT_INCLUDE
}
${
__found_miopen_include
}
PATH_SUFFIXES include
DOC
"Path to MIOPEN include directory."
)
if
(
MIOPEN_INCLUDE_DIR STREQUAL
"MIOPEN_INCLUDE_DIR-NOTFOUND"
)
message
(
FATAL_ERROR
"Can not find MIOEPN INCLUDE"
)
endif
()
macro
(
hipconfig_get_option variable option
)
if
(
NOT DEFINED
${
variable
}
)
execute_process
(
COMMAND
${
HIP_HIPCONFIG_EXECUTABLE
}
${
option
}
OUTPUT_VARIABLE
${
variable
}
)
endif
()
endmacro
()
hipconfig_get_option
(
HIP_COMPILER
"--compiler"
)
hipconfig_get_option
(
HIP_CPP_CONFIG
"--cpp_config"
)
separate_arguments
(
HIP_CPP_CONFIG
)
foreach
(
hip_config_item
${
HIP_CPP_CONFIG
}
)
foreach
(
macro_name
"__HIP_PLATFORM_HCC__"
"__HIP_ROCclr__"
)
if
(
${
hip_config_item
}
STREQUAL
"-D
${
macro_name
}
="
)
set
(
HIP_CPP_DEFINE
"
${
HIP_CPP_DEFINE
}
#define
${
macro_name
}
\n
"
)
set
(
HIP_CPP_UNDEFINE
"
${
HIP_CPP_UNDEFINE
}
\
#ifdef
${
macro_name
}
\n
#undef
${
macro_name
}
\n
\
#else
\n
#error
\n
\
#endif
\n
"
)
elseif
(
${
hip_config_item
}
STREQUAL
"-D
${
macro_name
}
"
)
set
(
HIP_CPP_DEFINE
"
${
HIP_CPP_DEFINE
}
#define
${
macro_name
}
1
\n
"
)
set
(
HIP_CPP_UNDEFINE
"
${
HIP_CPP_UNDEFINE
}
\
#ifdef
${
macro_name
}
\n
#undef
${
macro_name
}
\n
\
#else
\n
#error
\n
\
#endif
\n
"
)
endif
()
endforeach
()
endforeach
()
#rocblas
get_filename_component
(
__found_rocblas_library
${
HIP_ROOT_DIR
}
/../rocblas/lib REALPATH
)
find_path
(
ROCBLAS_LIBRARY_DIR
NAMES librocblas.so
HINTS
${
PC_ROCBLAS_INCLUDE_DIRS
}
${
ROCBLAS_ROOT_DIR
}
${
ROCM_TOOLKIT_INCLUDE
}
${
__found_rocblas_library
}
PATH_SUFFIXES lib
DOC
"Path to ROCBLAS library directory."
)
message
(
STATUS
"Using HIP compiler
${
HIP_COMPILER
}
"
)
if
(
ROCBLAS_LIBRARY_DIR STREQUAL
"ROCBLAS_LIBRARY_DIR-NOTFOUND"
)
message
(
FATAL_ERROR
"Can not find ROCBLAS Library"
)
if
(
${
HIP_COMPILER
}
STREQUAL
"hcc"
)
set
(
MGE_ROCM_LIBS hip_hcc
)
message
(
WARNING
"hcc is not well supported, please modify link.txt to link with hipcc"
)
elseif
(
${
HIP_COMPILER
}
STREQUAL
"clang"
)
set
(
MGE_ROCM_LIBS amdhip64
)
endif
()
get_filename_component
(
__found_rocblas_include
${
HIP_ROOT_DIR
}
/../rocblas/include REALPATH
)
find_path
(
ROCBLAS_INCLUDE_DIR
NAMES rocblas.h
HINTS
${
PC_ROCBLAS_INCLUDE_DIRS
}
${
ROCBLAS_ROOT_DIR
}
${
ROCM_TOOLKIT_INCLUDE
}
${
__found_rocblas_include
}
PATH_SUFFIXES include
DOC
"Path to ROCBLAS include directory."
)
list
(
APPEND MGE_ROCM_LIBS amdocl64 MIOpen rocblas rocrand
)
if
(
ROCBLAS_INCLUDE_DIR STREQUAL
"ROCBLAS_INCLUDE_DIR-NOTFOUND"
)
message
(
FATAL_ERROR
"Can not find ROCBLAS INCLUDE"
)
endif
()
set
(
HIP_INCLUDE_DIR
${
HIP_ROOT_DIR
}
/../include
)
set
(
HIP_LIBRARY_DIR
${
HIP_ROOT_DIR
}
/../lib
)
#rocrand
get_filename_component
(
__found_rocrand_library
${
HIP_ROOT_DIR
}
/../rocrand/lib REALPATH
)
find_path
(
ROCRAND_LIBRARY_DIR
NAMES librocrand.so
HINTS
${
PC_ROCRAND_INCLUDE_DIRS
}
${
ROCRAND_ROOT_DIR
}
${
ROCM_TOOLKIT_INCLUDE
}
${
__found_rocrand_library
}
PATH_SUFFIXES lib
DOC
"Path to ROCRAND library directory."
)
function
(
find_rocm_library name dirname include library
)
find_path
(
${
name
}
_LIBRARY_DIR
NAMES
${
library
}
HINTS
"
${
HIP_ROOT_DIR
}
/../
${
dirname
}
"
PATH_SUFFIXES lib lib/x86_64
DOC
"Path to
${
name
}
library directory"
)
if
(
ROCRAND_LIBRARY_DIR STREQUAL
"ROCRAND_LIBRARY_DIR-NOTFOUND
"
)
message
(
FATAL_ERROR
"Can not find ROCRAND L
ibrary"
)
endif
()
if
(
${${
name
}
_LIBRARY_DIR
}
MATCHES
"NOTFOUND$
"
)
message
(
FATAL_ERROR
"Can not find
${
name
}
l
ibrary"
)
endif
()
get_filename_component
(
__found_rocrand_include
${
HIP_ROOT_DIR
}
/../rocrand/include REALPATH
)
find_path
(
ROCRAND_INCLUDE_DIR
NAMES rocrand.h
HINTS
${
PC_ROCRAND_INCLUDE_DIRS
}
${
ROCRAND_ROOT_DIR
}
${
ROCM_TOOLKIT_INCLUDE
}
${
__found_rocrand_include
}
find_path
(
${
name
}
_INCLUDE_DIR
NAMES
${
include
}
HINTS
"
${
HIP_ROOT_DIR
}
/../
${
dirname
}
"
PATH_SUFFIXES include
DOC
"Path to ROCRAND include directory."
)
if
(
ROCRAND_INCLUDE_DIR STREQUAL
"ROCRAND_INCLUDE_DIR-NOTFOUND"
)
message
(
FATAL_ERROR
"Can not find ROCRAND INCLUDE"
)
endif
()
DOC
"Path to
${
name
}
include directory"
)
if
(
${
name
}
_INCLUDE_DIR MATCHES
"NOTFOUND$"
)
message
(
FATAL_ERROR
"Can not find
${
name
}
include"
)
endif
()
message
(
DEBUG
"Found lib
${${
name
}
_LIBRARY_DIR
}
, include
${${
name
}
_INCLUDE_DIR
}
"
)
endfunction
()
find_rocm_library
(
MIOPEN miopen miopen libMIOpen.so
)
find_rocm_library
(
ROCBLAS rocblas rocblas.h librocblas.so
)
find_rocm_library
(
ROCRAND rocrand rocrand.h librocrand.so
)
find_rocm_library
(
AMDOCL opencl CL libamdocl64.so
)
dnn/include/hcc_detail/hcc_defs_epilogue.h
→
dnn/include/hcc_detail/hcc_defs_epilogue.h
.in
浏览文件 @
a31b7c6e
...
...
@@ -9,10 +9,6 @@
* "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
#ifdef __HIP_PLATFORM_HCC__
#undef __HIP_PLATFORM_HCC__
#else
#error "hcc_defs_epilogue.h must be included after hcc_defs_prologue.h"
#endif
@
HIP_CPP_UNDEFINE
@
// vim: syntax=cpp.doxygen
dnn/include/hcc_detail/hcc_defs_prologue.h
→
dnn/include/hcc_detail/hcc_defs_prologue.h
.in
浏览文件 @
a31b7c6e
...
...
@@ -9,6 +9,6 @@
* "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
#define __HIP_PLATFORM_HCC__
@
HIP_CPP_DEFINE
@
// vim: syntax=cpp.doxygen
dnn/src/CMakeLists.txt
浏览文件 @
a31b7c6e
...
...
@@ -63,7 +63,7 @@ macro (HIP_COMPILE _hip_target _hip_objs)
add_custom_target
(
${
_hip_target
}
)
# set return value
set
(
${
_hip_objs
}
${
_generated_files
}
)
set
(
${
_hip_objs
}
${
_generated_files
}
)
endmacro
()
if
(
MGE_WITH_ROCM
)
...
...
@@ -74,14 +74,21 @@ if (MGE_WITH_ROCM)
# empty file to bypass this error.
file
(
GLOB start.cpp.hip
""
)
list
(
APPEND HIP_SOURCES start.cpp.hip
)
configure_file
(
${
PROJECT_SOURCE_DIR
}
/dnn/include/hcc_detail/hcc_defs_prologue.h.in
${
PROJECT_BINARY_DIR
}
/dnn/include/hcc_detail/hcc_defs_prologue.h
)
file
(
GLOB_RECURSE HIPSOURCES rocm/*.cpp.hip
)
set
(
HIP_TARGET_NAME hip_kernel
)
configure_file
(
${
PROJECT_SOURCE_DIR
}
/dnn/include/hcc_detail/hcc_defs_epilogue.h.in
${
PROJECT_BINARY_DIR
}
/dnn/include/hcc_detail/hcc_defs_epilogue.h
)
file
(
GLOB_RECURSE HIP_SOURCES_ rocm/*.cpp.hip
)
set
(
HIP_TARGET_NAME megdnn_hip_kernel
)
set
(
_HIPCC_OPTIONS
"-fPIC"
)
set
(
_HCC_OPTIONS
"-fPIC"
)
set
(
_NVCC_OPTIONS
"-fPIC"
)
list
(
APPEND HIP_SOURCES
${
HIP
SOURCES
}
)
list
(
APPEND HIP_SOURCES
${
HIP
_SOURCES_
}
)
set_source_files_properties
(
${
HIP_SOURCES
}
PROPERTIES HIP_SOURCE_PROPERTY_FORMAT 1
)
HIP_INCLUDE_DIRECTORIES
(
${
PROJECT_SOURCE_DIR
}
/dnn
${
PROJECT_SOURCE_DIR
}
/dnn/include
...
...
@@ -91,13 +98,14 @@ if (MGE_WITH_ROCM)
${
HIP_INCLUDE_DIR
}
${
MIOPEN_INCLUDE_DIR
}
${
ROCBLAS_INCLUDE_DIR
}
${
ROCRAND_INCLUDE_DIR
}
)
${
ROCRAND_INCLUDE_DIR
}
${
AMDOCL_INCLUDE_DIR
}
)
hip_compile
(
${
HIP_TARGET_NAME
}
HIPOBJS
${
HIP_SOURCES
}
HIPCC_OPTIONS
${
_HIPCC_OPTIONS
}
HCC_OPTIONS
${
_HCC_OPTIONS
}
NVCC_OPTIONS
${
_NVCC_OPTIONS
}
)
list
(
APPEND SOURCES
${
HIPOBJS
}
)
list
(
APPEND SOURCES
${
HIPOBJS
}
)
endif
()
if
(
MGE_WITH_CUDA
)
...
...
@@ -143,12 +151,14 @@ if(MGE_WITH_ROCM)
${
HIP_INCLUDE_DIR
}
${
MIOPEN_INCLUDE_DIR
}
${
ROCBLAS_INCLUDE_DIR
}
${
ROCRAND_INCLUDE_DIR
}
)
${
ROCRAND_INCLUDE_DIR
}
${
AMDOCL_INCLUDE_DIR
}
)
target_link_directories
(
megdnn PUBLIC
${
HIP_LIBRARY_DIR
}
${
MIOPEN_LIBRARY_DIR
}
${
ROCBLAS_LIBRARY_DIR
}
${
ROCRAND_LIBRARY_DIR
}
)
${
ROCRAND_LIBRARY_DIR
}
${
AMDOCL_LIBRARY_DIR
}
)
endif
()
...
...
dnn/src/fallback/batched_matrix_mul/opr_impl.cpp
浏览文件 @
a31b7c6e
...
...
@@ -11,7 +11,6 @@
*/
#include "./opr_impl.h"
#include "./algos.h"
#include "hcc_detail/hcc_defs_prologue.h"
#include "src/common/algo_chooser.h"
#include "src/common/utils.cuh"
...
...
dnn/src/rocm/miopen_with_check.h
浏览文件 @
a31b7c6e
...
...
@@ -11,9 +11,7 @@
#pragma once
#ifndef __HIP_PLATFORM_HCC__
#define __HIP_PLATFORM_HCC__
#endif
#include "hcc_detail/hcc_defs_prologue.h"
#include <miopen/version.h>
#pragma GCC diagnostic push
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录