Add rpath for hipfft-test to help find libomp.#173
Conversation
|
rocBLAS and hipBLAS are now using this scheme ROCm/rocm-libraries#624 |
@TorreZuk : it looks to me like roc/hipBLAS won't be able to find all of the libraries that it needs if one installs to, for example, ~/rocBLAS. Am I mistaken about this? Has this been tested? |
Here is the hipBLAS version tested with gcc and clang ROCm/hipBLAS#1050. Tests reported along with normal CI and some manual tests (inc. windows). Are you installing the clients to some unique location? If so, there is runpath information still being set. This change prefers the cmake config for openmp amd clang that was @estewart08 addition to rocm. |
I'm looking at the use-case where the installation directory isn't /opt/rocm. We have use cases where users will install rocFFT to their home directory, so, yes, the clients may be installed to some unique location. |
ROCm strongly prefers relative paths for rpath from what I understand. If there are install locations outside of a ROCm directory structure then I would think LD_LIBRARY_PATH would need set. |
Working with and installing to a user-local directory, the installed version of hipff-test doesn't find libomp.so. |
|
Rpath is being used for multiple purposes:
If any of these are installed to different prefixes, then a single rpath entry won't be enough to find all of them. Also, we don't want absolute install rpaths, as @estewart08 points out. Build rpaths may be absolute. So we can have |
If absolute install rpaths are to be avoided, I don't think the current version of this PR is aligned with that
Fix linking directory to fix clients compilation. Allow for building from clients/tests.
|
Ok, in the current version, tests installed to non-rocm directories need LD_LIBRARY_PATH set for libomp.so to be found. For the upcoming OpenMP configuration, we can use openmp_LIB_DIR to help with linking. Also, hipfft.h is changed from including hipfft-export.h to including hipfft/hipfft-export.h, which fixes the test-only build. |
| #include "hipfft-export.h" | ||
| #include "hipfft-version.h" | ||
| #include "hipfft/hipfft-export.h" | ||
| #include "hipfft/hipfft-version.h" |
There was a problem hiding this comment.
I am wary of this change. In my understanding, once installed, hipfft.h, hipfft-export.h, and hipfft-version.h are all placed in the same directory, the last two files being automatically created when building/installing the hipfft library (they are not natively in the repository). So, for anything that includes an installed library's hipfft.h, the compiler should typically find the required hipfft-export.h, and hipfft-version.h (without any change to this file) since the directory of that included hipfft.h is the first place it should explore when using such double quotes #include (reference).
I'm actually suspecting that the test-only build failed because it was not including an installed library's hipfft.h (say /opt/rocm/include/hipfft/hipfft.h) but your local repository's header instead, due to
target_include_directories( ${target} PRIVATE [...] $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../library/include> )
being used (unconditionally of HIPFFT_BUILD_SCOPE) in clients/tests/CMakeLists.txt.
In fact, I do not think that we need to add that include directory explicitly: if hipfft is built/installed alongside the tests, cmake should use the built/installed library's header automatically; if doing a test-only build, cmake should find the installed library's header from the target_link_libraries( ${target} PRIVATE hip::hipfft [...]) command (given how the public target_include_directories of hipfft itself are defined).
Could we try reverting this file's changes and removing $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../library/include> from the tests' target_include_directories instead?
| // initialize static class member of hipfft_params | ||
| std::vector<gpubuf> hipfft_params::externally_managed_workareas = std::vector<gpubuf>(); | ||
|
|
There was a problem hiding this comment.
FYI: this may be removed as that was resolved in #174
| string( CONCAT TESTS_OUT_DIR "${PROJECT_BINARY_DIR}" ${TESTS_OUT_DIR} ) | ||
|
|
||
| option( BUILD_CLIENTS_TESTS_OPENMP "Build tests with OpenMP" ON ) | ||
| if( BUILD_CLIENTS_TESTS_OPENMP ) |
There was a problem hiding this comment.
Suggestion: maybe we could add AND BUILD_WITH_LIB NOT STREQUAL "CUDA" above, to avoid a fatal build error if building with cuda (openMP is ignored thereafter in that case, anyways)?
| #find_package( OpenMP CONFIG PATHS "${HIP_CLANG_ROOT}/lib/cmake" ) | ||
| if( NOT OPENMP_FOUND OR NOT DEFINED ${openmp_LIB_DIR} ) | ||
| # Fall-back to module mode. | ||
| find_package( OpenMP REQUIRED ) |
There was a problem hiding this comment.
Would this ever define openmp_LIB_DIR? If or when it does, is the ${HIP_CLANG_ROOT}/${openmp_LIB_DIR} used below consistent with it regardless of which OpenMP package is found?
| else() | ||
| if( DEFINED ${openmp_LIB_DIR} ) | ||
| set_target_properties( ${target} PROPERTIES BUILD_RPATH "${HIP_CLANG_ROOT}/${openmp_LIB_DIR}" ) | ||
| set_target_properties( ${target} PROPERTIES INSTALL_RPATH "${HIP_CLANG_ROOT}/${openmp_LIB_DIR}" ) |
There was a problem hiding this comment.
Would this ever set the binary's install rpath as a relative path, i.e., would ${HIP_CLANG_ROOT} ever be a relative path?
|
Imported to ROCm/rocm-libraries |
…anges for rocm-libraries CI (#1004) --- 🔁 Imported from [ROCm/hipFFT#173](ROCm/hipFFT#173) 🧑💻 Originally authored by @malcolmroberts --------- Co-authored-by: Malcolm Roberts <malcolm.roberts@amd.com> Co-authored-by: Malcolm Roberts <malcolm.i.w.roberts@gmail.com>
…anges for rocm-libraries CI (#1004) --- 🔁 Imported from [ROCm/hipFFT#173](ROCm/hipFFT#173) 🧑💻 Originally authored by @malcolmroberts --------- Co-authored-by: Malcolm Roberts <malcolm.roberts@amd.com> Co-authored-by: Malcolm Roberts <malcolm.i.w.roberts@gmail.com>
…ories cmake clause (#1381) I believe such conditionals cannot be used within `target_include_directories`. Current build lines on `develop` (when building hipfft's and its clients) are polluted, _e.g._ see the parts between `**` delimiters in the copy-pasted following example: `/opt/rocm/llvm/bin/amdclang++ -DUSE_HIPRAND -DUSE_PROF_API=1 -D__HIP_PLATFORM_AMD__=1 -I/src/rocm-libraries/projects/hipfft/clients/tests/**if -I"/src/rocm-libraries/projects/hipfft/clients/tests/(" -I/src/rocm-libraries/projects/hipfft/clients/tests/HIPFFT_BUILD_SCOPE -I"/src/rocm-libraries/projects/hipfft/clients/tests/)" -I/src/rocm-libraries/projects/hipfft/clients/tests/../../library/include -I/src/rocm-libraries/projects/hipfft/clients/tests/endif** -I/src/rocm-libraries/projects/hipfft/library/include -I/src/rocm-libraries/projects/hipfft/build/include/hipfft -I/src/rocm-libraries/projects/hipfft/build/include [...]` I also think it's not necessary to explicitly add the intended inclusion to the `cmake` logic, as mentioned in [that comment](ROCm/hipFFT#173 (comment)).
…anges for rocm-libraries CI (#1004) --- 🔁 Imported from [#173](#173) 🧑💻 Originally authored by @malcolmroberts --------- Co-authored-by: Malcolm Roberts <malcolm.roberts@amd.com> Co-authored-by: Malcolm Roberts <malcolm.i.w.roberts@gmail.com>
…ories cmake clause (#1381)
I believe such conditionals cannot be used within
`target_include_directories`.
Current build lines on `develop` (when building hipfft's and its
clients) are polluted, _e.g._ see the parts between `**` delimiters in
the copy-pasted following example:
`/opt/rocm/llvm/bin/amdclang++ -DUSE_HIPRAND -DUSE_PROF_API=1
-D__HIP_PLATFORM_AMD__=1
-I/src/rocm-libraries/projects/hipfft/clients/tests/**if
-I"/src/rocm-libraries/projects/hipfft/clients/tests/("
-I/src/rocm-libraries/projects/hipfft/clients/tests/HIPFFT_BUILD_SCOPE
-I"/src/rocm-libraries/projects/hipfft/clients/tests/)"
-I/src/rocm-libraries/projects/hipfft/clients/tests/../../library/include
-I/src/rocm-libraries/projects/hipfft/clients/tests/endif**
-I/src/rocm-libraries/projects/hipfft/library/include
-I/src/rocm-libraries/projects/hipfft/build/include/hipfft
-I/src/rocm-libraries/projects/hipfft/build/include [...]`
I also think it's not necessary to explicitly add the intended inclusion
to the `cmake` logic, as mentioned in [that
comment](#173 (comment)).
No description provided.