[libc-commits] [PATCH] D153897: [libc][hdr-gen] Add special offloading handling for the GPU target

Jon Chesterfield via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Jun 28 07:07:38 PDT 2023


JonChesterfield added a comment.

The offloading languages do some things with libc which seem broadly reasonable but might not be optimal. The reasoning goes roughly - the host part will probably use glibc, so the gpu part should use the same ABI as glibc, so the gpu should include the glibc headers. Unfortunately the glibc headers don't know anything about the GPU so there's a cascade of hacks to make that work which have been hard won.

I don't think this is totally sensible. For one thing, using the glibc ABI on the gpu has rather limited scope since we can't make normal function calls across that barrier by one arch emitting a jump or call. I think all that matters is agreeing on struct layout in case they get copied across. A defining characteristic of libc is that we know what is supposed to be in it, and of glibc in particular is the ABI is stable, versioned and totally documented. So the GPU could use the same struct definitions as glibc without including glibc headers. It seems unimportant to me that the two sides have exact agreement on which functions are constexpr or not.

Nevertheless, openmp/cuda/hip presently include glibc headers directly on the gpu and patch around it. The dev teams involved seem committed to this strategy so I suggest we leave it in place.

I'd therefore like us to localise whatever header related hacks the offloading languages currently use where they are at present, i.e. in the overlay stuff in clang/lib/headers, and have absolutely none of it anywhere in libc. That allows the offloading languages to add or remove complexity, diverge from one another or converge as they see fit. This totally isolates libc from any adverse behaviour that results from those changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153897



More information about the libc-commits mailing list