[ROCM] update cmake and dockerfile, test=develop (#30598)
parent
cf9bdb9404
commit
1f5841c2a0
@ -1,104 +1,86 @@
|
|||||||
if(NOT WITH_ROCM_PLATFORM)
|
if(NOT WITH_ROCM)
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include_directories("${ROCM_PATH}/include")
|
if(NOT DEFINED ENV{ROCM_PATH})
|
||||||
include_directories("${ROCM_PATH}/hip/include")
|
set(ROCM_PATH "/opt/rocm" CACHE PATH "Path to which ROCm has been installed")
|
||||||
include_directories("${ROCM_PATH}/miopen/include")
|
set(HIP_PATH ${ROCM_PATH}/hip CACHE PATH "Path to which HIP has been installed")
|
||||||
include_directories("${ROCM_PATH}/hipblas/include")
|
set(HIP_CLANG_PATH ${ROCM_PATH}/llvm/bin CACHE PATH "Path to which clang has been installed")
|
||||||
include_directories("${ROCM_PATH}/rocblas/include")
|
|
||||||
include_directories("${ROCM_PATH}/hiprand/include")
|
|
||||||
include_directories("${ROCM_PATH}/rocrand/include")
|
|
||||||
include_directories("${ROCM_PATH}/rccl/include")
|
|
||||||
|
|
||||||
include_directories("${ROCM_PATH}/rocthrust/include/")
|
|
||||||
include_directories("${ROCM_PATH}/hipcub/include/")
|
|
||||||
include_directories("${ROCM_PATH}/rocprim/include/")
|
|
||||||
include_directories("${ROCM_PATH}/hipsparse/include/")
|
|
||||||
include_directories("${ROCM_PATH}/rocsparse/include/")
|
|
||||||
include_directories("${ROCM_PATH}/rocfft/include/")
|
|
||||||
|
|
||||||
set(HIP_CLANG_PARALLEL_BUILD_COMPILE_OPTIONS "")
|
|
||||||
set(HIP_CLANG_PARALLEL_BUILD_LINK_OPTIONS "")
|
|
||||||
# now default is clang
|
|
||||||
set(HIP_COMPILER "clang")
|
|
||||||
|
|
||||||
list(APPEND EXTERNAL_LIBS "-L${ROCM_PATH}/lib/ -lhip_hcc")
|
|
||||||
set(HIP_HIPCC_FLAGS "${HIP_HIPCC_FLAGS} -fPIC -DPADDLE_WITH_HIP -DEIGEN_USE_HIP -DEIGEN_USE_GPU -D__HIP_NO_HALF_CONVERSIONS__ -std=c++11 --amdgpu-target=gfx906" )
|
|
||||||
|
|
||||||
if(WITH_RCCL)
|
|
||||||
set(HIP_HIPCC_FLAGS "${HIP_HIPCC_FLAGS} -DPADDLE_WITH_RCCL")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT WITH_PYTHON)
|
|
||||||
set(HIP_HIPCC_FLAGS "${HIP_HIPCC_FLAGS} -DPADDLE_NO_PYTHON")
|
|
||||||
endif(NOT WITH_PYTHON)
|
|
||||||
|
|
||||||
if(WITH_DSO)
|
|
||||||
set(HIP_HIPCC_FLAGS "${HIP_HIPCC_FLAGS} -DPADDLE_USE_DSO")
|
|
||||||
endif(WITH_DSO)
|
|
||||||
|
|
||||||
if(WITH_TESTING)
|
|
||||||
set(HIP_HIPCC_FLAGS "${HIP_HIPCC_FLAGS} -DPADDLE_WITH_TESTING")
|
|
||||||
endif(WITH_TESTING)
|
|
||||||
|
|
||||||
if(WITH_DISTRIBUTE)
|
|
||||||
set(HIP_HIPCC_FLAGS "${HIP_HIPCC_FLAGS} -DPADDLE_WITH_DISTRIBUTE")
|
|
||||||
endif(WITH_DISTRIBUTE)
|
|
||||||
|
|
||||||
if(WITH_GRPC)
|
|
||||||
set(HIP_HIPCC_FLAGS "${HIP_HIPCC_FLAGS} -DPADDLE_WITH_GRPC")
|
|
||||||
endif(WITH_GRPC)
|
|
||||||
|
|
||||||
if(WITH_MKLDNN)
|
|
||||||
set(HIP_HIPCC_FLAGS "${HIP_HIPCC_FLAGS} -DPADDLE_WITH_MKLDNN")
|
|
||||||
endif(WITH_MKLDNN)
|
|
||||||
|
|
||||||
set(HIP_HIPCC_FLAGS "${HIP_HIPCC_FLAGS} -DANY_IMPL_ANY_CAST_MOVEABLE")
|
|
||||||
|
|
||||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
||||||
list(APPEND HIP_HIPCC_FLAGS ${CMAKE_CXX_FLAGS_DEBUG})
|
|
||||||
elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
|
|
||||||
list(APPEND HIP_HIPCC_FLAGS ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})
|
|
||||||
elseif(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
|
|
||||||
list(APPEND HIP_HIPCC_FLAGS ${CMAKE_CXX_FLAGS_MINSIZEREL})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("${HIP_COMPILER}" STREQUAL "hcc")
|
|
||||||
if("x${HCC_HOME}" STREQUAL "x")
|
|
||||||
set(HCC_HOME "${ROCM_PATH}/hcc")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(CMAKE_HIP_LINK_EXECUTABLE "${HIP_HIPCC_CMAKE_LINKER_HELPER} ${HCC_HOME} <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -ldl --amdgpu-target=gfx906 ")
|
|
||||||
set(CMAKE_HIP_CREATE_SHARED_LIBRARY "${HIP_HIPCC_CMAKE_LINKER_HELPER} ${HCC_HOME} <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -shared --amdgpu-target=gfx906")
|
|
||||||
set(CMAKE_HIP_CREATE_SHARED_MODULE "${HIP_HIPCC_CMAKE_LINKER_HELPER} ${HCC_HOME} <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -shared --amdgpu-target=gfx906")
|
|
||||||
|
|
||||||
elseif("${HIP_COMPILER}" STREQUAL "clang")
|
|
||||||
|
|
||||||
if("x${HIP_CLANG_PATH}" STREQUAL "x")
|
|
||||||
set(HIP_CLANG_PATH "${ROCM_PATH}/llvm/bin")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#Number of parallel jobs by default is 1
|
|
||||||
if(NOT DEFINED HIP_CLANG_NUM_PARALLEL_JOBS)
|
|
||||||
set(HIP_CLANG_NUM_PARALLEL_JOBS 1)
|
|
||||||
endif()
|
|
||||||
#Add support for parallel build and link
|
|
||||||
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
|
|
||||||
check_cxx_compiler_flag("-parallel-jobs=1" HIP_CLANG_SUPPORTS_PARALLEL_JOBS)
|
|
||||||
endif()
|
|
||||||
if(HIP_CLANG_NUM_PARALLEL_JOBS GREATER 1)
|
|
||||||
if(${HIP_CLANG_SUPPORTS_PARALLEL_JOBS})
|
|
||||||
set(HIP_CLANG_PARALLEL_BUILD_COMPILE_OPTIONS "-parallel-jobs=${HIP_CLANG_NUM_PARALLEL_JOBS} -Wno-format-nonliteral")
|
|
||||||
set(HIP_CLANG_PARALLEL_BUILD_LINK_OPTIONS "-parallel-jobs=${HIP_CLANG_NUM_PARALLEL_JOBS}")
|
|
||||||
else()
|
else()
|
||||||
message("clang compiler doesn't support parallel jobs")
|
set(ROCM_PATH $ENV{ROCM_PATH} CACHE PATH "Path to which ROCm has been installed")
|
||||||
|
set(HIP_PATH ${ROCM_PATH}/hip CACHE PATH "Path to which HIP has been installed")
|
||||||
|
set(HIP_CLANG_PATH ${ROCM_PATH}/llvm/bin CACHE PATH "Path to which clang has been installed")
|
||||||
endif()
|
endif()
|
||||||
|
set(CMAKE_MODULE_PATH "${HIP_PATH}/cmake" ${CMAKE_MODULE_PATH})
|
||||||
|
|
||||||
|
find_package(HIP REQUIRED)
|
||||||
|
include_directories(${ROCM_PATH}/include)
|
||||||
|
message(STATUS "HIP version: ${HIP_VERSION}")
|
||||||
|
message(STATUS "HIP_CLANG_PATH: ${HIP_CLANG_PATH}")
|
||||||
|
|
||||||
|
macro(find_package_and_include PACKAGE_NAME)
|
||||||
|
find_package("${PACKAGE_NAME}" REQUIRED)
|
||||||
|
include_directories("${ROCM_PATH}/${PACKAGE_NAME}/include")
|
||||||
|
message(STATUS "${PACKAGE_NAME} version: ${${PACKAGE_NAME}_VERSION}")
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
find_package_and_include(miopen)
|
||||||
|
find_package_and_include(rocblas)
|
||||||
|
find_package_and_include(hiprand)
|
||||||
|
find_package_and_include(rocrand)
|
||||||
|
find_package_and_include(rccl)
|
||||||
|
find_package_and_include(rocthrust)
|
||||||
|
find_package_and_include(hipcub)
|
||||||
|
find_package_and_include(rocprim)
|
||||||
|
find_package_and_include(hipsparse)
|
||||||
|
find_package_and_include(rocsparse)
|
||||||
|
find_package_and_include(rocfft)
|
||||||
|
|
||||||
|
# set CXX flags for HIP
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__HIP_PLATFORM_HCC__")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__HIP_PLATFORM_HCC__")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_HIP")
|
||||||
|
set(THRUST_DEVICE_SYSTEM THRUST_DEVICE_SYSTEM_HIP)
|
||||||
|
|
||||||
|
# define HIP_CXX_FLAGS
|
||||||
|
list(APPEND HIP_CXX_FLAGS -fPIC)
|
||||||
|
list(APPEND HIP_CXX_FLAGS -D__HIP_PLATFORM_HCC__=1)
|
||||||
|
list(APPEND HIP_CXX_FLAGS -D__HIP_NO_HALF_CONVERSIONS__=1)
|
||||||
|
list(APPEND HIP_CXX_FLAGS -Wno-macro-redefined)
|
||||||
|
list(APPEND HIP_CXX_FLAGS -Wno-inconsistent-missing-override)
|
||||||
|
list(APPEND HIP_CXX_FLAGS -Wno-exceptions)
|
||||||
|
list(APPEND HIP_CXX_FLAGS -Wno-shift-count-negative)
|
||||||
|
list(APPEND HIP_CXX_FLAGS -Wno-shift-count-overflow)
|
||||||
|
list(APPEND HIP_CXX_FLAGS -Wno-unused-command-line-argument)
|
||||||
|
list(APPEND HIP_CXX_FLAGS -Wno-duplicate-decl-specifier)
|
||||||
|
list(APPEND HIP_CXX_FLAGS -Wno-implicit-int-float-conversion)
|
||||||
|
list(APPEND HIP_CXX_FLAGS -Wno-pass-failed)
|
||||||
|
list(APPEND HIP_CXX_FLAGS -DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_HIP)
|
||||||
|
list(APPEND HIP_CXX_FLAGS -std=c++14)
|
||||||
|
|
||||||
|
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
||||||
|
list(APPEND HIP_CXX_FLAGS -g2)
|
||||||
|
list(APPEND HIP_CXX_FLAGS -O0)
|
||||||
|
list(APPEND HIP_HIPCC_FLAGS -fdebug-info-for-profiling)
|
||||||
|
endif(CMAKE_BUILD_TYPE MATCHES Debug)
|
||||||
|
|
||||||
|
set(HIP_HCC_FLAGS ${HIP_CXX_FLAGS})
|
||||||
|
set(HIP_CLANG_FLAGS ${HIP_CXX_FLAGS})
|
||||||
|
# Ask hcc to generate device code during compilation so we can use
|
||||||
|
# host linker to link.
|
||||||
|
list(APPEND HIP_HCC_FLAGS -fno-gpu-rdc)
|
||||||
|
list(APPEND HIP_HCC_FLAGS --amdgpu-target=gfx906)
|
||||||
|
list(APPEND HIP_CLANG_FLAGS -fno-gpu-rdc)
|
||||||
|
list(APPEND HIP_CLANG_FLAGS --amdgpu-target=gfx906)
|
||||||
|
|
||||||
|
|
||||||
|
if(HIP_COMPILER STREQUAL clang)
|
||||||
|
set(hip_library_name amdhip64)
|
||||||
|
else()
|
||||||
|
set(hip_library_name hip_hcc)
|
||||||
endif()
|
endif()
|
||||||
|
message(STATUS "HIP library name: ${hip_library_name}")
|
||||||
|
|
||||||
|
# set HIP link libs
|
||||||
# Set the CMake Flags to use the HIP-Clang Compiler.
|
find_library(ROCM_HIPRTC_LIB ${hip_library_name} HINTS ${HIP_PATH}/lib)
|
||||||
set(CMAKE_HIP_CREATE_SHARED_LIBRARY "${HIP_HIPCC_CMAKE_LINKER_HELPER} ${HIP_CLANG_PATH} ${HIP_CLANG_PARALLEL_BUILD_LINK_OPTIONS} <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES> --amdgpu-target=gfx906")
|
message(STATUS "ROCM_HIPRTC_LIB: ${ROCM_HIPRTC_LIB}")
|
||||||
set(CMAKE_HIP_CREATE_SHARED_MODULE "${HIP_HIPCC_CMAKE_LINKER_HELPER} ${HIP_CLANG_PATH} ${HIP_CLANG_PARALLEL_BUILD_LINK_OPTIONS} <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <LINK_LIBRARIES> -shared --amdgpu-target=gfx906" )
|
|
||||||
set(CMAKE_HIP_LINK_EXECUTABLE "${HIP_HIPCC_CMAKE_LINKER_HELPER} ${HIP_CLANG_PATH} ${HIP_CLANG_PARALLEL_BUILD_LINK_OPTIONS} <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -ldl --amdgpu-target=gfx906")
|
|
||||||
endif()
|
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
if(NOT WITH_ROCM)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Now we don't support RCCL on windows
|
||||||
|
if(WIN32)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WITH_RCCL)
|
||||||
|
set(RCCL_ROOT ${ROCM_PATH}/rccl CACHE PATH "RCCL ROOT")
|
||||||
|
find_path(RCCL_INCLUDE_DIR rccl.h
|
||||||
|
PATHS ${RCCL_ROOT} ${RCCL_ROOT}/include ${RCCL_ROOT}/local/include
|
||||||
|
$ENV{RCCL_ROOT} $ENV{RCCL_ROOT}/include $ENV{RCCL_ROOT}/local/include
|
||||||
|
NO_DEFAULT_PATH
|
||||||
|
)
|
||||||
|
|
||||||
|
file(READ ${RCCL_INCLUDE_DIR}/rccl.h RCCL_VERSION_FILE_CONTENTS)
|
||||||
|
|
||||||
|
string(REGEX MATCH "define NCCL_VERSION_CODE +([0-9]+)"
|
||||||
|
RCCL_VERSION "${RCCL_VERSION_FILE_CONTENTS}")
|
||||||
|
string(REGEX REPLACE "define NCCL_VERSION_CODE +([0-9]+)" "\\1"
|
||||||
|
RCCL_VERSION "${RCCL_VERSION}")
|
||||||
|
|
||||||
|
# 2604 for ROCM3.5 and 2708 for ROCM 3.9
|
||||||
|
message(STATUS "Current RCCL header is ${RCCL_INCLUDE_DIR}/rccl.h. "
|
||||||
|
"Current RCCL version is v${RCCL_VERSION}. ")
|
||||||
|
endif()
|
File diff suppressed because it is too large
Load Diff
@ -1,45 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
|
|
||||||
function rocm() {
|
|
||||||
# ROCM 3.3 - not work as rocthrust build fail without AMD GPU
|
|
||||||
# sed 's#<rocm_repo_version>#3.3#g' Dockerfile.rocm >test/rocm33.dockerfile
|
|
||||||
# sed -ri 's#<rocprim_version>#3.3.0#g' test/rocm33.dockerfile
|
|
||||||
# sed -ri 's#<rocthrust_version>#3.3.0#g' test/rocm33.dockerfile
|
|
||||||
# sed -ri 's#<hipcub_version>#3.3.0#g' test/rocm33.dockerfile
|
|
||||||
|
|
||||||
# ROCM 3.5
|
|
||||||
sed 's#<rocm_repo_version>#3.5.1#g' Dockerfile.rocm >test/rocm35.dockerfile
|
|
||||||
sed -ri 's#<rocprim_version>#3.5.1#g' test/rocm35.dockerfile
|
|
||||||
sed -ri 's#<rocthrust_version>#3.5.0#g' test/rocm35.dockerfile
|
|
||||||
sed -ri 's#<hipcub_version>#3.5.0#g' test/rocm35.dockerfile
|
|
||||||
|
|
||||||
# ROCM 3.9
|
|
||||||
sed 's#<rocm_repo_version>#3.9.1#g' Dockerfile.rocm >test/rocm39.dockerfile
|
|
||||||
sed -ri 's#<rocprim_version>#3.9.0#g' test/rocm39.dockerfile
|
|
||||||
sed -ri 's#<rocthrust_version>#3.9.0#g' test/rocm39.dockerfile
|
|
||||||
sed -ri 's#<hipcub_version>#3.9.0#g' test/rocm39.dockerfile
|
|
||||||
}
|
|
||||||
|
|
||||||
function main() {
|
|
||||||
if [ ! -d "test" ];then
|
|
||||||
mkdir test
|
|
||||||
fi
|
|
||||||
rocm
|
|
||||||
}
|
|
||||||
|
|
||||||
main
|
|
Loading…
Reference in new issue