Skip to content

hip-config only adds compile and link options to C++#2190

Closed
robertmaynard wants to merge 1 commit intoROCm:developfrom
robertmaynard:cmake_hip_module_restrict_to_cxx
Closed

hip-config only adds compile and link options to C++#2190
robertmaynard wants to merge 1 commit intoROCm:developfrom
robertmaynard:cmake_hip_module_restrict_to_cxx

Conversation

@robertmaynard
Copy link
Copy Markdown

Previous to these any target that has mixed languages ( C++ && Fortran )
would break as the HIP specific flags such as '-x hip' would be past
to the Fortran compiler.

@bd4
Copy link
Copy Markdown

bd4 commented Nov 17, 2020

Thanks this is affecting my AMD GPU port of the GENE fusion code, which is mixed Fortran and C++.

Previous to these any target that has mixed languages ( C++ && Fortran )
would break as the HIP specific flags such as '-x hip' would be past
to the Fortran compiler.
@TomSang TomSang requested review from Rmalavally, TomSang, pfultz2, scchan and yxsamliu and removed request for Rmalavally December 7, 2020 19:15
Copy link
Copy Markdown
Contributor

@yxsamliu yxsamliu left a comment

Choose a reason for hiding this comment

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

LGTM. This is to limit some compile and link options to C++ files only. Since users may have Fortran programs. Without this fix, some options are applied to Fortran programs.

@ax3l
Copy link
Copy Markdown

ax3l commented May 19, 2021

@yxsamliu @pfultz2 @aaronenyeshi is there a way to get this merged? This also affects ECP AMReX and its dependent application projects.

# Add support for __fp16 and _Float16, explicitly link with compiler-rt
set_property(TARGET hip::host APPEND PROPERTY
INTERFACE_LINK_LIBRARIES -L${HIP_CLANG_INCLUDE_PATH}/../lib/linux -lclang_rt.builtins-x86_64
INTERFACE_LINK_LIBRARIES "$<$<LINK_LANGUAGE:CXX>:${HIP_CLANG_INCLUDE_PATH}/lib/linux/libclang_rt.builtins-x86_64.a>"
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.

Doesn't this need to be ${HIP_CLANG_INCLUDE_PATH}/../lib and not ${HIP_CLANG_INCLUDE_PATH}/lib?

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.

@TomSang Are you able to make this change to the PR before merging?

Copy link
Copy Markdown

@ax3l ax3l May 27, 2021

Choose a reason for hiding this comment

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

ping @TomSang
this is a blocker for a set of Exascale apps for OLCF's Spock/Frontier.

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'm working on this. But maybe I need you help test after it's done.

Copy link
Copy Markdown

@ax3l ax3l May 27, 2021

Choose a reason for hiding this comment

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

Sounds great, we could share code on ECP Tulip or OLCF Spock, if you have access to that.
(Or you could give me instructions how to install this stack manually.)

Alternatively, we can write a small reproducer for a C++/Fortran project.

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 cannot fix the issue under Robert account, so I created #2280 to cover the fix .
You may install the stack in terms of https://github.com/ROCm-Developer-Tools/HIP.

Copy link
Copy Markdown

@ax3l ax3l May 27, 2021

Choose a reason for hiding this comment

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

Hi @TomSang, I created a reproducer for you under
https://github.com/ax3l/hip_cxxf_cmake

Simply build with:

CXX=$(which clang++) FC=$(which gfortran) cmake -S . -B build
cmake --build build

The error that you see is:

gfortran: error: unrecognized command line option ‘-mllvm’
clang-12: warning: argument unused during compilation: '-amdgpu-function-calls=false' [-Wunused-command-line-argument]
gfortran: error: unrecognized command line option ‘-amdgpu-early-inline-all=true’
gfortran: error: unrecognized command line option ‘-amdgpu-function-calls=false’
gfortran: error: unrecognized command line option ‘--offload-arch=gfx900’; did you mean ‘--offload-abi=ilp32’?
gfortran: error: unrecognized command line option ‘--offload-arch=gfx906’; did you mean ‘--offload-abi=ilp32’?
gfortran: error: unrecognized command line option ‘--offload-arch=gfx908’; did you mean ‘--offload-abi=ilp32’?

That will likely be way faster than me pulling the stack.

@robertmaynard robertmaynard deleted the cmake_hip_module_restrict_to_cxx branch May 28, 2021 11:34
WeiqunZhang pushed a commit to AMReX-Codes/amrex that referenced this pull request Jan 21, 2022
## Summary

By now (HIP 4.5), we should be able to link also against Fortran targets.

Let's remove work-arounds and ditch old HIP releases, so improve maintainability and avoid surprises.

## Additional background

X-ref:
- ROCm/hip#2280 (ROCm/hip#2190)
- ROCm/hip#2275
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