From 932a3e92ea0a5d9b86e203110a28b5407cf92429 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-No=C3=ABl=20Grad?= Date: Fri, 13 Mar 2020 13:41:54 +0100 Subject: [PATCH] Patch hipcc environment variables in ROCm 3.X In ROCm 3.0 and 3.1, environment variables for hipcc and hcc are overriden by incorrect paths (espressomd/docker#156). This causes CMake to generate an incorrect linking command for EspressoCore.so: in `/opt/rocm/bin/hipcc_cmake_linker_helper /opt/rocm -fPIC ...`, either path `/opt/rocm` is an empty string, or both the linker path and path `/opt/rocm` are empty strings. Calling `find_package()` twice with an overriden `HCC_PATH` fixes the linking command. --- CMakeLists.txt | 3 +++ cmake/FindCUDACompilerHIP.cmake | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e55d091bb4e..76da1dbe978 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,6 +138,9 @@ if(WITH_CUDA) set(ROCM_HOME "/opt/rocm" CACHE FILEPATH "Path to AMD ROCm") list(APPEND CMAKE_MODULE_PATH "${ROCM_HOME}/hip/cmake") find_package(HIP 1.5.18494 MODULE REQUIRED) + # patch HCC_PATH environment variable and reload HIP (for ROCm 3.0/3.1) + set(HCC_PATH "${HIP_ROOT_DIR}") + find_package(HIP 1.5.18494 MODULE REQUIRED) find_package(CUDACompilerHIP 6.0 REQUIRED) elseif (WITH_CUDA_COMPILER STREQUAL "clang") set(CMAKE_CUDA_STANDARD 8.0) diff --git a/cmake/FindCUDACompilerHIP.cmake b/cmake/FindCUDACompilerHIP.cmake index 5f3d0d10755..4e9d54d30f2 100644 --- a/cmake/FindCUDACompilerHIP.cmake +++ b/cmake/FindCUDACompilerHIP.cmake @@ -34,8 +34,6 @@ string(REGEX CMAKE_CUDA_COMPILER_VERSION "${HIPCC_VERSION_STRING}") -set(HCC_PATH "${HIP_ROOT_DIR}") - list(APPEND HIP_HCC_FLAGS "-I${HIP_ROOT_DIR}/include -I${ROCM_HOME}/include -Wno-c99-designator -Wno-macro-redefined -Wno-duplicate-decl-specifier -std=c++${CMAKE_CXX_STANDARD}") list(APPEND HIP_HCC_FLAGS "-pedantic -Wall -Wextra -Wno-sign-compare -Wno-unused-function -Wno-unused-variable -Wno-unused-parameter -Wno-missing-braces -Wno-gnu-anonymous-struct -Wno-nested-anon-types -Wno-gnu-zero-variadic-macro-arguments") if(WARNINGS_ARE_ERRORS)