[libc] Begin implementing a 'libmgpu.a' for math on the GPU
authorJoseph Huber <jhuber6@vols.utk.edu>
Thu, 8 Jun 2023 22:51:43 +0000 (17:51 -0500)
committerJoseph Huber <jhuber6@vols.utk.edu>
Wed, 14 Jun 2023 17:59:15 +0000 (12:59 -0500)
commit8060d96aed7c2ee8be188fb7619a0cbb863d4f8c
tree13c19ca34fe37551f6a9eefca7b1cd8ec1c0082c
parent7d21f5714e5a040f121fa08648c748073467db82
[libc] Begin implementing a 'libmgpu.a' for math on the GPU

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.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D152486
15 files changed:
libc/config/gpu/entrypoints.txt
libc/config/gpu/headers.txt
libc/src/math/CMakeLists.txt
libc/src/math/gpu/CMakeLists.txt [new file with mode: 0644]
libc/src/math/gpu/round.cpp [new file with mode: 0644]
libc/src/math/gpu/roundf.cpp [new file with mode: 0644]
libc/src/math/gpu/roundl.cpp [new file with mode: 0644]
libc/src/math/gpu/vendor/CMakeLists.txt [new file with mode: 0644]
libc/src/math/gpu/vendor/amdgpu/amdgpu.h [new file with mode: 0644]
libc/src/math/gpu/vendor/amdgpu/declarations.h [new file with mode: 0644]
libc/src/math/gpu/vendor/amdgpu/platform.h [new file with mode: 0644]
libc/src/math/gpu/vendor/common.h [new file with mode: 0644]
libc/src/math/gpu/vendor/nvptx/declarations.h [new file with mode: 0644]
libc/src/math/gpu/vendor/nvptx/nvptx.h [new file with mode: 0644]
libc/src/math/gpu/vendor/sin.cpp [new file with mode: 0644]