[PATCH] D102507: [HIP] Support <functional> in device code

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 27 07:33:38 PDT 2021


yaxunl added a comment.

In D102507#2760025 <https://reviews.llvm.org/D102507#2760025>, @tra wrote:

> In effect this patch applies `__host__ __device__` to a subset of the standard library headers and whatever headers *they* happen to include. While it may happen to work, I'm not at all confident that it does not create interesting issues.
>
> Considering that the patch only works with libc++ anyways, perhaps it's time to make (parts) of libc++ itself usable from CUDA/HIP, instead of hacking around it in the wrappers?
>
> @rsmith Richard, who would be the right person to discuss the standard library changes we may need?

ping.

If we are allowed to make changes to libc++ we may have cleaner implementation for supporting libc++ in HIP device functions.

Currently by default libc++ functions are host functions except constexpr functions. Except constexpr functions, we can't call libc++ host functions in HIP device functions. Our goal is to make libc++ functions `__host__ __device__` functions so that they can be called in HIP device functions. We may not be able to support all libc++ functions, e.g. file I/O, threads, but at least we should be able to support some of them, e.g. type_traits, functional, containers. We do this by supporting the underlying functions e.g. malloc/free on device.

The change will be NFC for other languages.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102507/new/

https://reviews.llvm.org/D102507



More information about the cfe-commits mailing list