Skip to content

Drop clang rt builtins linking on hip::host#2219

Closed
haampie wants to merge 2 commits intoROCm:mainfrom
haampie:drop-rt-linking-on-host
Closed

Drop clang rt builtins linking on hip::host#2219
haampie wants to merge 2 commits intoROCm:mainfrom
haampie:drop-rt-linking-on-host

Conversation

@haampie
Copy link
Copy Markdown
Contributor

@haampie haampie commented Jan 12, 2021

Ref this comment
#2217 (comment):

Yea, this should only be linked on hip::device as I believe its needed
for __fp16 support on the GPU. If users need this on the host-side,
then they should explicitly add it.

Ref this comment
ROCm#2217 (comment):

> Yea, this should only be linked on hip::device as I believe its needed
> for __fp16 support on the GPU. If users need this on the host-side,
> then they should explicitly add it.
@haampie
Copy link
Copy Markdown
Contributor Author

haampie commented Jan 12, 2021

Ping @pfultz2

@yxsamliu
Copy link
Copy Markdown
Contributor

One difficulty for users to link this library is that users may not know the location of this library since it is compiler implementation detail.

Can we add a cmake flag to control it? Users can turn on/off the flag to link this library.

@haampie
Copy link
Copy Markdown
Contributor Author

haampie commented Jan 12, 2021

By this library you mean the runtime lib?

I think the standard way to use the runtime lib is through the compiler flag clang --rtlib=compiler-rt ... as suggested in #2215. I don't know if this does strictly more than linking to compiler runtime libs. In cmake that would mean something like (untested):

  set_property(TARGET hip::device APPEND PROPERTY
    INTERFACE_COMPILE_OPTIONS --rtlib=compiler-rt
  )

@yxsamliu
Copy link
Copy Markdown
Contributor

--rtlib=compiler-rt calls some unwinding functions which may not available be in the default unwind lib, which may require an additional option for using llvm unwind lib.

Besides, we only want to use a few fp16 conversion functions in compiler-rt and do not want to use other functions in compiler-rt. Using --rtlib=compiler-rt will make us subject to other issues of compiler-rt.

@haampie
Copy link
Copy Markdown
Contributor Author

haampie commented Jan 14, 2021

Can we add a cmake flag to control it? Users can turn on/off the flag to link this library.

How about just adding a new target for the builtin lib then so that people can use that if they really need to?

@yxsamliu
Copy link
Copy Markdown
Contributor

Can we add a cmake flag to control it? Users can turn on/off the flag to link this library.

How about just adding a new target for the builtin lib then so that people can use that if they really need to?

sounds good to me. thanks.

@haampie
Copy link
Copy Markdown
Contributor Author

haampie commented Jan 15, 2021

Ok, done @yxsamliu.

Could you also take a look at my comment here #2217 (comment)

endif()

add_library(hip::clang_rt_builtins INTERFACE)
target_link_libraries(hip::clang_rt_builtins PUBLIC -L${HIP_CLANG_INCLUDE_PATH}/../lib/linux -lclang_rt.builtins-x86_64)
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.

This should use find_library to find clang_rt_builtins:

find_library(CLANG_RT_BUILTINS lang_rt.builtins-x86_64 HINTS ${HIP_CLANG_INCLUDE_PATH}/../lib/linux PATHS /opt/rocm/llvm)

This way a user doesnt necessarily need to set HIP_CXX_COMPILER as it will still be found along the CMAKE_PREFIX_PATH.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, much better. Let me do that tomorrow.

Copy link
Copy Markdown
Contributor Author

@haampie haampie Jan 20, 2021

Choose a reason for hiding this comment

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

Hm, unfortunately it's not really working @pfultz2, in the sense that it's only reasonable to assume the user / package manager passes the install prefix of LLVM, not the path to clang, and in that case the following does not work:

find_library(CLANG_RT_BUILTINS clang_rt.builtins-x86_64 PATH_SUFFIXES "lib/clang/*/lib/linux")

where * is an attempt to enable globbing (it's an unknown version number). It's looking for literal * in the paths it seems... replacing * with 12.0.0 works in my case, but that's not great. Let me see if LLVM actually exports a cmake target for this lib.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Doesn't look like it.

@powderluv
Copy link
Copy Markdown

I am trying to build with latest AOMP and am running into this issue. Can we please merge @haampie earlier patch ?

@ronlieb
Copy link
Copy Markdown

ronlieb commented Feb 19, 2021

ubuntu 20 requires that one be in the render group

@powderluv
Copy link
Copy Markdown

yes I am in both video and render:
id
uid=1000(foo) gid=1000(foo) groups=1000(foo),4(adm),24(cdrom),27(sudo),30(dip),44(video),46(plugdev),109(render),120(lpadmin),131(lxd),132(sambashare)

@haampie
Copy link
Copy Markdown
Contributor Author

haampie commented May 19, 2021

Any news here? Seems like it didn't make it into 4.2 either? :/ ping @yxsamliu / @pfultz2

@mangupta mangupta closed this Aug 5, 2021
@mangupta mangupta reopened this Aug 5, 2021
@mangupta
Copy link
Copy Markdown
Contributor

mangupta commented Aug 5, 2021

Closing all existing pull requests that do not target the develop branch. In case this pull request is still valid, please rebase your changes against develop branch and resubmit.

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