[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Building rocRAND with Debian HIP



Hi Étienne,

Today I successfully built rocrand to the `make install` step using gdb buildpackage. This required fixing two problems in rocm-hipamd and two in rocrand.

HIP Fix #1

On 2022-06-04 03:32, Étienne Mollier wrote:
While I did not manage to start the rocrand build process yet,
as I am still seeing the following in the current state, during
a build attempt:

	[…]
	-- Performing Test COMPILER_HAS_TARGET_ID_gfx90a_xnack_on
	-- Performing Test COMPILER_HAS_TARGET_ID_gfx90a_xnack_on - Success
	-- Performing Test COMPILER_HAS_TARGET_ID_gfx1030
	-- Performing Test COMPILER_HAS_TARGET_ID_gfx1030 - Success
	CMake Error at /usr/lib/x86_64-linux-gnu/cmake/hip/hip-config.cmake:42 (message):
	  File or directory /usr/lib/include referenced by variable hip_INCLUDE_DIR
	  does not exist !
	Call Stack (most recent call first):
	  /usr/lib/x86_64-linux-gnu/cmake/hip/hip-config.cmake:127 (set_and_check)
	  cmake/VerifyCompiler.cmake:34 (find_package)
	  CMakeLists.txt:116 (include)

This problem is caused by the issue I described earlier:

On 2022-05-23 21:52, Cordell Bloor wrote:

the PACKAGE_PREFIX_DIR defined on line 27 of hip-config.cmake needs one more "../". Though, that seems to come from CMakePackageConfigHelpers [3], so I'm not sure why it's inaccurate.

I now believe the problem is that hipamd is not consistently using GNUInstallDirs. Jeremy Newton has proposed a more complete patch upstream, but a small change is sufficient to fix this particular issue:

--- CMakeLists.txt.orig    2022-06-04 22:21:25.834523135 -0600
+++ CMakeLists.txt    2022-06-04 22:22:40.483824982 -0600
@@ -268,9 +268,10 @@
 #############################
 # Build steps
 #############################
-set(BIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/bin)
-set(LIB_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib)
-set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include)
+include(GNUInstallDirs)
+set(BIN_INSTALL_DIR ${CMAKE_INSTALL_FULL_BINDIR})
+set(LIB_INSTALL_DIR ${CMAKE_INSTALL_FULL_LIBDIR})
+set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_FULL_INCLUDEDIR})
 set(CONFIG_PACKAGE_INSTALL_DIR ${LIB_INSTALL_DIR}/cmake/hip)
 set(CONFIG_LANG_PACKAGE_INSTALL_DIR ${LIB_INSTALL_DIR}/cmake/hip-lang)

 
/usr/lib/cmake/hip must also be updated in debian/libamdhip64-dev.install to match.

HIP Fix #2

The second problem with rocm-hipamd is that debian/patches/0007-isystem-removal.patch removes the wrong append to HIPCXXFLAGS. That's my fault. I listed the incorrect line numbers in my previous mail. It's -isystem "$HIP_INCLUDE_PATH" that causes problems, so that's lines 227-229 [1].

Those are all the changes required to rocm-hipamd, but there are a couple changes needed in rocrand.

rocRAND Fix #1

You'll need to delete the unnecessary HIP_COMPILER check at the end of VerifyCompiler.cmake [2]. It's checking that HIP_COMPILER STREQUAL "clang" and failing because HIP_COMPILER is "clang-14". It then emits a FATAL_ERROR to provide a 'friendly' error message. The entire section I linked in [2] can be deleted. All it does is suppress warnings.

rocRAND Fix #2

The variables in debian/rules can be significantly reduced.

You can remove:
DEB_HIP_ARCHITECTURES
HIP_PLATFORM
HIP_RUNTIME
HIP_COMPILER
HIP_DEVICE_LIB_PATH
HIP_LIB_PATH
HSA_PATH
LLVM_PATH
HIP_PATH

You can keep unmodified:
HIP_CLANG_PATH
DEVICE_LIB_PATH
ROCM_PATH
HCC_AMDGPU_TARGET
HIP_CLANG_HCC_COMPAT_MODE

You can update these variables to:
HIPCC_COMPILE_FLAGS_APPEND=--hip-version=5.0.0
HIPCC_LINK_FLAGS_APPEND=--hip-version=5.0.0

Making those four fixes should be sufficient to get rocrand to build and install into the tmp directory. There's definitely more cleanup that can be done, but it will build!

Sincerely,
Cory Bloor

[1]: https://salsa.debian.org/rocm-team/rocm-hipamd/-/blob/upstream/5.0.0/hip/bin/hipcc#L227-229
[2]: https://github.com/ROCmSoftwarePlatform/rocRAND/blob/rocm-5.0.0/cmake/VerifyCompiler.cmake#L43-L51


Reply to: