[libc-commits] [PATCH] D152486: [libc] Begin implementing a 'libmgpu.a' for math on th GPU

Joseph Huber via Phabricator via libc-commits libc-commits at lists.llvm.org
Thu Jun 8 16:31:03 PDT 2023


jhuber6 created this revision.
jhuber6 added reviewers: tra, yaxunl, arsenm, jdoerfert, tianshilei1992, JonChesterfield, sivachandra, lntue, michaelrj, gregrodgers, ye-luo.
Herald added subscribers: libc-commits, mattd, asavonic, kerbowa, jvesely.
Herald added projects: libc-project, All.
jhuber6 requested review of this revision.
Herald added a subscriber: wdng.

This patch adds an outline to begin adding a `libmgpu.a` file for
provindg math on the GPU. Currently, this is most likely going to be
wrapping around existing vendor libraries and placing them in a more
usable format. Long term, we would like to provide our own
implementations of math functions that can be used instead.

This patch works by simply forwarding the calls to the standard C math
library calls like `sin` to the appropriate vendor call like `__nv_sin`.
Currently, we will use the vendor libraries directly and link them in
via `-mlink-builtin-bitcode`. This is necessary because of bizarre
interactions with the generic bitcode, `-mlink-builtin-bitcode`
internalizes and only links in the used symbols, furthermore is
propagates the target's default attributes and its the only "truly"
correct way to pull in these vendor bitcode libraries without error.

If the vendor libraries are not availible at build time, we will still
create the `libmgpu.a`, but we will expect that the vendor library
definitions will be provided by the user's compilation as is made
possible by https://reviews.llvm.org/D152442.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152486

Files:
  libc/config/gpu/entrypoints.txt
  libc/config/gpu/headers.txt
  libc/src/math/gpu/CMakeLists.txt
  libc/src/math/gpu/amdgpu/amdgpu.h
  libc/src/math/gpu/amdgpu/declarations.h
  libc/src/math/gpu/amdgpu/platform.h
  libc/src/math/gpu/common.h
  libc/src/math/gpu/nvptx/declarations.h
  libc/src/math/gpu/nvptx/nvptx.h
  libc/src/math/gpu/sin.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152486.529775.patch
Type: text/x-patch
Size: 11745 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230608/d72ceafe/attachment.bin>


More information about the libc-commits mailing list