Skip to content

Add rpath for hipfft-test to help find libomp.#173

Closed
malcolmroberts wants to merge 5 commits into
ROCm:developfrom
malcolmroberts:omprpath
Closed

Add rpath for hipfft-test to help find libomp.#173
malcolmroberts wants to merge 5 commits into
ROCm:developfrom
malcolmroberts:omprpath

Conversation

@malcolmroberts
Copy link
Copy Markdown
Contributor

No description provided.

Comment thread clients/tests/CMakeLists.txt
Comment thread clients/tests/CMakeLists.txt Outdated
@TorreZuk
Copy link
Copy Markdown

rocBLAS and hipBLAS are now using this scheme ROCm/rocm-libraries#624

@malcolmroberts
Copy link
Copy Markdown
Contributor Author

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?

@TorreZuk
Copy link
Copy Markdown

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.

@malcolmroberts
Copy link
Copy Markdown
Contributor Author

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.

@estewart08
Copy link
Copy Markdown

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.

@malcolmroberts
Copy link
Copy Markdown
Contributor Author

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.

Working with

set_target_properties( ${target} PROPERTIES BUILD_RPATH "${HIP_CLANG_ROOT}/lib" )
set_target_properties( ${target} PROPERTIES INSTALL_RPATH "$ORIGIN/../llvm/lib" )

and installing to a user-local directory, the installed version of hipff-test doesn't find libomp.so.

@malcolmroberts malcolmroberts requested a review from regan-amd July 24, 2025 01:15
regan-amd
regan-amd previously approved these changes Jul 24, 2025
Copy link
Copy Markdown
Contributor

@regan-amd regan-amd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@evetsso
Copy link
Copy Markdown
Contributor

evetsso commented Jul 24, 2025

Rpath is being used for multiple purposes:

  • Finding libhipfft.so
  • Finding runtime libraries (libamdhip64.so)
  • Finding libomp.so

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 ${HIP_CLANG_ROOT}/lib as a build rpath, but install rpath will need to be something relative to $ORIGIN. If different libraries are in different prefixes, then IMO it's reasonable to expect users to have to change their configuration to make them findable by the dynamic linker. Rpath isn't really meant to solve this whole problem. Users could either change /etc/ld.so.conf.d or set LD_LIBRARY_PATH.

@regan-amd regan-amd dismissed their stale review July 24, 2025 16:03

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.
@malcolmroberts malcolmroberts requested a review from a team as a code owner July 28, 2025 22:07
@malcolmroberts malcolmroberts requested a review from regan-amd July 28, 2025 22:07
@malcolmroberts
Copy link
Copy Markdown
Contributor Author

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.

Comment on lines -48 to +49
#include "hipfft-export.h"
#include "hipfft-version.h"
#include "hipfft/hipfft-export.h"
#include "hipfft/hipfft-version.h"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment on lines +26 to +28
// initialize static class member of hipfft_params
std::vector<gpubuf> hipfft_params::externally_managed_workareas = std::vector<gpubuf>();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 )
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 )
Copy link
Copy Markdown
Contributor

@regan-amd regan-amd Jul 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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}" )
Copy link
Copy Markdown
Contributor

@regan-amd regan-amd Jul 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this ever set the binary's install rpath as a relative path, i.e., would ${HIP_CLANG_ROOT} ever be a relative path?

@ammallya
Copy link
Copy Markdown
Contributor

Imported to ROCm/rocm-libraries

@ammallya ammallya closed this Jul 31, 2025
amd-aakash pushed a commit to ROCm/rocm-libraries that referenced this pull request Aug 11, 2025
…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>
amd-garydeng pushed a commit to ROCm/rocm-libraries that referenced this pull request Aug 13, 2025
…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>
regan-amd added a commit to ROCm/rocm-libraries that referenced this pull request Sep 5, 2025
…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)).
ammallya pushed a commit that referenced this pull request Oct 28, 2025
…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>
ammallya pushed a commit that referenced this pull request Oct 28, 2025
…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)).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants