Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HIP/ROCm 5.6 include directory info not propagated through CMake interface libraries #28

Closed
pelesh opened this issue Oct 26, 2023 · 2 comments
Assignees

Comments

@pelesh
Copy link
Collaborator

pelesh commented Oct 26, 2023

I am not sure if I am doing something wrong here, but it seems that include directory information for ROCm 5.6 does not propagate through CMake configuration the way I think it should. Here is a simple example to reproduce the issue:

find_package(hip REQUIRED)

add_library(resolve_hip INTERFACE)
target_link_libraries(resolve_hip INTERFACE hip::device)

get_target_property(hip_includes hip::device INTERFACE_INCLUDE_DIRECTORIES)
message(STATUS "HIP include directories: ${hip_includes}")

get_target_property(resolve_hip_includes resolve_hip INTERFACE_INCLUDE_DIRECTORIES)
message(STATUS "ReSolve HIP include directories: ${resolve_hip_includes}")

When this code is executed, I get something like this in the output.

...
-- HIP include directories: /opt/rocm-5.6.0/include
-- ReSolve HIP include directories: resolve_hip_includes-NOTFOUND
...

Do I need to export hip::device target before interfacing it to resolve_hip?

I could use some help to understand this better.

@cameronrutherford
Copy link
Collaborator

cameronrutherford commented Oct 26, 2023

I feel like this is a feature not a bug, but maybe this is something that is CMake bug....

What I suggest would fix this:

find_package(hip REQUIRED)

add_library(resolve_hip INTERFACE)
target_link_libraries(resolve_hip INTERFACE hip::device)

get_target_property(hip_includes hip::device INTERFACE_INCLUDE_DIRECTORIES)
message(STATUS "HIP include directories: ${hip_includes}")

target_include_directories(resolve_hip INTERFACE ${hip_includes})
get_target_property(resolve_hip_includes resolve_hip INTERFACE_INCLUDE_DIRECTORIES)
message(STATUS "ReSolve HIP include directories: ${resolve_hip_includes}")

or, this might work?

find_package(hip REQUIRED)

add_library(resolve_hip INTERFACE)
target_link_libraries(resolve_hip PUBLIC hip::device)

I am somewhat guessing here

@pelesh pelesh mentioned this issue Oct 26, 2023
@pelesh pelesh added this to the Hackathon milestone Oct 27, 2023
@pelesh pelesh removed this from the Hackathon milestone Nov 6, 2023
@pelesh
Copy link
Collaborator Author

pelesh commented Nov 6, 2023

The workaround currently used in the code partially addresses this issue:

get_target_property(hip_includes hip::device INTERFACE_INCLUDE_DIRECTORIES)

target_include_directories(resolve_hip INTERFACE 
  $<BUILD_INTERFACE:${hip_includes}>)

I guess the root cause is in CMake's HIP support. Closing this issue for now.

@pelesh pelesh closed this as completed Nov 6, 2023
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

No branches or pull requests

4 participants