summaryrefslogtreecommitdiff
path: root/libc/docs/gpu
AgeCommit message (Collapse)Author
2025-05-05[libc][gpu][docs] Fix typos in GPU libc's documentation (#138565)Howard Chu
Fix typos in GPU libc's documentation about the rpc implementation.
2025-04-22Revert "[LLVM] Replace use of `LLVM_RUNTIMES_TARGET` with ↵Joseph Huber
`LLVM_DEFAULT_TARGET_TRIPLE` (#136208)" This reverts commit 2e145f11c0bcfa2052416d96d682c75f33971a8c. Somehow causes some static assertions to fail?
2025-04-22[LLVM] Replace use of `LLVM_RUNTIMES_TARGET` with ↵Joseph Huber
`LLVM_DEFAULT_TARGET_TRIPLE` (#136208) Summary: For purposes of determining the triple, it's more correct to use `LLVM_DEFAULT_TARGET_TRIPLE`.
2025-03-13[libc] Make RPC server handling header only (#131205)Joseph Huber
Summary: This patch moves the RPC server handling to be a header only utility stored in the `shared/` directory. This is intended to be shared within LLVM for the loaders and `offload/` handling. Generally, this makes it easier to share code without weird cross-project binaries being plucked out of the build system. It also allows us to soon move the loader interface out of the `libc` project so that we don't need to bootstrap those and can build them in LLVM.
2025-02-21[libc] Enable 'strftime' for the GPU targets (#128220)Joseph Huber
Summary: These should allow us to build with locale support for libcxx.
2025-02-19[AMDGPU] Replace gfx940 and gfx941 with gfx942 in offload and libclc (#125826)Fabian Ritter
gfx940 and gfx941 are no longer supported. This is one of a series of PRs to remove them from the code base. For SWDEV-512631 and SWDEV-512633
2025-02-17[libc][Docs] Add proper 'offload' build to use libc with offloadJoseph Huber
Summary: Since this was added the offloading target now requires `offload`. Fixes: https://github.com/llvm/llvm-project/issues/127458
2025-01-28[libc][docs] Fix the RPC documentation leaking portsJoseph Huber
Summary: Forgot to close it, that'll make it deadlock after awhile.
2025-01-27[libc] Add CMake cache file for the GPU build (#124589)Joseph Huber
Summary: This introduces libc cache files and adds one for building the GPU support. The cache files will set defaults for these arguments which can be overridden if the user needs to. They also serve as documentation for how the builid is expected to look.
2025-01-23[libc][NFC] Strip all training whitespace and missing newlines (#124163)Joseph Huber
2024-12-16[libc][Docs] Update `libc` documentation for RPC and others (#120018)Joseph Huber
Summary: A few of these were out of date, update them now that the C library interface into RPC was deleted.
2024-12-03[libc] delete hdrgen (#117220)Nick Desaulniers
Thanks to the effort of @RoseZhang03 and @aaryanshukla under the guidance of @michaelrj-google and @amykhuang, we now have newhdrgen and no longer have a dependency on TableGen and thus LLVM in order to start bootstrapping a full build. This PR removes: - LIBC_HDRGEN_EXE; the in tree newhdrgen is the only hdrgen that can be used. - LIBC_USE_NEW_HEADER_GEN; newhdrgen is the default and only option. - LIBC_HDRGEN_ONLY; there is no need to have a distinct build step for old hdrgen. - libc-api-test and libc-api-test-tidy build targets. - Deletes all .td files. It does not rename newhdrgen to just hdrgen. Will follow up with a distinct PR for that. Link: #117209 Link: #117254 Fixes: #117208
2024-11-19[libc] Increase RPC opcode to 32-bit and use a class byte (#116905)Joseph Huber
Summary: Currently, the RPC interface uses a basic opcode to communicate with the server. This currently is 16 bits. There's no reason for this to be 16 bits, because on the GPU a 32-bit write is the same as a 16-bit write performance wise. Additionally, I am now making all the `libc` based opcodes qualified with the 'c' type, mimiciing how Linux handles `ioctls` all coming from the same driver. This will make it easier to extend the interface when it's exported directly.
2024-11-02[NFC] Simple typo correction. (#114548)c8ef
2024-10-04[libc][docs] Update NVPTX using documentation now that linking worksJoseph Huber
Summary: I added a wrapper linker awhile back but this still says it doesn't work.
2024-09-24[libc] Implement the 'rename' function on the GPU (#109814)Joseph Huber
Summary: Straightforward implementation like the other `stdio.h` functions.
2024-09-23[libc] Add 'strings.h' header on the GPU (#109661)Joseph Huber
Summary: These are GNU extensions but still show up, the entrypoints were enabled but we weren't emitting the header so they couldn't be used.
2024-09-23[libc] Add GPU support for the 'system' function (#109687)Joseph Huber
Summary: This function can easily be implemented by forwarding it to the host process. This shows up in a few places that we might want to test the GPU so it should be provided. Also, I find the idea of the GPU offloading work to the CPU via `system` very funny.
2024-08-21[libc] Add `scanf` support to the GPU build (#104812)Joseph Huber
Summary: The `scanf` function has a "system file" configuration, which is pretty much what the GPU implementation does at this point. So we should be able to use it in much the same way.
2024-08-21[libc][docs] Update docs to reflect new headergen (#102381)Michael Jones
Since new headergen is now the default for building LLVM-libc, the docs need to be updated to reflect that. While I was editing those docs, I took a quick pass at updating other out-of-date pages.
2024-07-24[libc] Enable 'sscanf' on the GPU #100211Joseph Huber
Summary: We can enable the sscanf function on the GPU now. This required adding the configs to the scanf list so that the GPU build didn't do float conversions.
2024-07-24Reapply "[libc] Remove 'packaged' GPU build support (#100208)"Joseph Huber
This reverts commit 550b83d658755664a7f0f93b36242e885743a91b.
2024-07-24Revert "[libc] Remove 'packaged' GPU build support (#100208)"Joseph Huber
Summary: I forgot that the OpenMP tests still look for this, reverting for now until I can make a fix. This reverts commit c1c6ed83e9ac13c511961e5f5791034a63168e7e.
2024-07-24Revert "[libc] Enable 'sscanf' on the GPU (#100211)"Joseph Huber
Summary: This fails tests in some situations, revert until it can be fixed. This reverts commit 445bb35f954ecd5c60ced71523f6b32fc306d557.
2024-07-24[libc] Enable 'sscanf' on the GPU (#100211)Joseph Huber
Summary: We can enable the `sscanf` function on the GPU now.
2024-07-24[libc] Remove 'packaged' GPU build support (#100208)Joseph Huber
Summary: Previously, the GPU built the `libc` in a fat binary version that was used to pass this to the link job in offloading languages like CUDA or OpenMP. This was mostly required because NVIDIA couldn't consume the standard static library version. Recent patches have now created the `clang-nvlink-wrapper` which lets us do that. Now, the C library is just included implicitly by the toolchain (or passed with -Xoffload-linker -lc). This code can be fully removed, which will heavily simplify the build (and removed some bugs and garbage files I've encoutnered).
2024-07-18[libc] Remove `strerror_r` on the GPU for nowJoseph Huber
Summary: This function has conflicting definitions, which makes it difficult to use in an offloading setting. Disable it for now.
2024-07-16[libc][docs] Document printf support on the GPU target (#99241)Joseph Huber
Summary: Title
2024-07-16[libc] Implement `clock_gettime` for the monotonic clock on the GPU (#99067)Joseph Huber
Summary: This patch implements `clock_gettime` using the monotonic clock. This allows users to get time elapsed at nanosecond resolution. This is primarily to facilitate compiling the `chrono` library from `libc++`. For this reason we provide both `CLOCK_MONOTONIC`, which we can implement with the GPU's global fixed-frequency clock, and `CLOCK_REALTIME` which we cannot. The latter is provided just to make people who use this header happy and it will always return failure.
2024-07-01[libc] Partially implement 'errno' on the GPU (#97107)Joseph Huber
Summary: The `errno` variable is expected to be `thread_local` by the standard. However, the GPU targets do not support `thread_local` and implementing that would be a large endeavor. Because of that, we previously didn't provide the `errno` symbol at all. However, to build some programs we at least need to be able to link against `errno`. Many things that would normally set `errno` completely ignore it currently (i.e. stdio) but some programs still need to be able to link against correct C programs. For this purpose this patch exports the `errno` symbol as a simple global. Internally, this will be updated atomically so it's at least not racy. Externally, this will be on the user. I've updated the documentation to state as such. This is required to get `libc++` to build.
2024-07-01[libc] Implement the 'remove' function on the GPU (#97096)Joseph Huber
Summary: Straightforward RPC implementation of the `remove` function for the GPU. Copies over the string and calls `remove` on it, passing the result back. This is required for building some `libc++` functionality.
2024-06-26[libc][docs] List `rand` and `srand` as supported on the GPU (#96757)Joseph Huber
Summary: I initially didn't report these as supported because they didn't provide expected behavior and were very wasteful. The recent patch moved them to a lock-free atomic implementation so they can now actually be used.
2024-06-04[NFC] Fix typo in libc/docs/gpu/using.rstJoachim Meyer
2024-04-10[libc] Add note to use `LIBC_GPU_BUILD=ON` as another formJoseph Huber
Summary: This is a shorthand to enable GPU support so it should be listed in the docs.
2024-03-29[libc][Docs] Update RPC server example using CUDA after changesJoseph Huber
Summary: This has changed, so update it to match the new interface.
2024-03-15[libc] Update GPU testing documentation (#85459)Joseph Huber
Summary: This documentation was lagging reality and didn't contain much. Update it with some more information now that it's more mature.
2024-03-13[libc][docs] document gpu support for stdbit.h (#85103)Nick Desaulniers
Via: https://github.com/llvm/llvm-project/pull/84938#issuecomment-1992120095 --------- Co-authored-by: Joseph Huber <huberjn@outlook.com>
2024-03-06[libc] Update GPU documentation pages (#84076)Joseph Huber
Summary: After the overhaul of the GPU build the documentation pages were a little stale. This updates them with more in-depth information on building the GPU runtimes and using them. Specifically using them goes through the differences between the offloading and direct compilation modes.
2024-02-23[libc][NFC] Remove all trailing spaces from libc (#82831)Joseph Huber
Summary: There are a lot of random training spaces on various lines. This patch just got rid of all of them with `sed 's/\ \+$//g'.
2024-02-23[libc] Remove 'llvm-gpu-none' directory from build (#82816)Joseph Huber
Summary: This directory is leftover from when we handled both AMDGPU and NVPTX in the same build and merged them into a pseudo triple. Now the only thing it contains is the RPC server header. This gets rid of it, but now that it's in the base install directory we should make it clear that it's an LLVM libc header.
2024-02-22[libc] Rework the GPU build to be a regular target (#81921)Joseph Huber
Summary: This is a massive patch because it reworks the entire build and everything that depends on it. This is not split up because various bots would fail otherwise. I will attempt to describe the necessary changes here. This patch completely reworks how the GPU build is built and targeted. Previously, we used a standard runtimes build and handled both NVPTX and AMDGPU in a single build via multi-targeting. This added a lot of divergence in the build system and prevented us from doing various things like building for the CPU / GPU at the same time, or exporting the startup libraries or running tests without a full rebuild. The new appraoch is to handle the GPU builds as strict cross-compiling runtimes. The first step required https://github.com/llvm/llvm-project/pull/81557 to allow the `LIBC` target to build for the GPU without touching the other targets. This means that the GPU uses all the same handling as the other builds in `libc`. The new expected way to build the GPU libc is with `LLVM_LIBC_RUNTIME_TARGETS=amdgcn-amd-amdhsa;nvptx64-nvidia-cuda`. The second step was reworking how we generated the embedded GPU library by moving it into the library install step. Where we previously had one `libcgpu.a` we now have `libcgpu-amdgpu.a` and `libcgpu-nvptx.a`. This patch includes the necessary clang / OpenMP changes to make that not break the bots when this lands. We unfortunately still require that the NVPTX target has an `internal` target for tests. This is because the NVPTX target needs to do LTO for the provided version (The offloading toolchain can handle it) but cannot use it for the native toolchain which is used for making tests. This approach is vastly superior in every way, allowing us to treat the GPU as a standard cross-compiling target. We can now install the GPU utilities to do things like use the offload tests and other fun things. Some certain utilities need to be built with `--target=${LLVM_HOST_TRIPLE}` as well. I think this is a fine workaround as we will always assume that the GPU `libc` is a cross-build with a functioning host. Depends on https://github.com/llvm/llvm-project/pull/81557
2024-01-23[libc][Docs] Update the GPU RPC documentation (#79069)Joseph Huber
Summary: This adds some more concrete information on the RPC interface. Hopefully this is intelligable and provides some useful examples.
2023-10-23[libc] Enable remaining string functions on the GPU (#68346)Joseph Huber
Summary: We previously had to disable these string functions because they were not compatible with the definitions coming from the GNU / host environment. The GPU, when exporting its declarations, has a very difficult requirement that it be compatible with the host environment as both sides of the compilation need to agree on definitions and what's present. This patch more or less gives up an just copies the definitions as expected by `glibc` if they are provided that way, otherwise we fall back to the accepted way. This is the alternative solution to an existing PR which instead disable's GCC's handling.
2023-10-17[libc] Implement the 'ungetc' function on the GPU (#69248)Joseph Huber
Summary: This function follows closely with the pattern of all the other functions. That is, making a new opcode and forwarding the call to the host. However, this also required modifying the test somewhat. It seems that not all `libc` implementations follow the same error rules as are tested here, and it is not explicit in the standard, so we simply disable these EOF checks when targeting the GPU.
2023-09-28[libc] Fix wrapper headers for some ctype macros and C++ declsJoseph Huber
Summary: These wrapper headers need to work around things in the standard headers. The existing workarounds didn't correctly handle the macros for `iscascii` and `toascii`. Additionally, `memrchr` can't be used because it has a different declaration for C++ mode. Fix this so it can be compiled.
2023-09-26[libc] Implement `fseek`, `fflush`, and `ftell` on the GPU (#67160)Joseph Huber
Summary: This patch adds the necessary entrypoints to handle the `fseek`, `fflush`, and `ftell` functions. These are all very straightfoward, we simply make RPC calls to the associated function on the other end. Implementing it this way allows us to more or less borrow the state of the stream from the server as we intentionally maintain no internal state on the GPU device. However, this does not implement the `errno` functinality so that must be ignored.
2023-09-14[libc] Implement more input functions on the GPU (#66288)Joseph Huber
Summary: This patch implements the `fgets`, `getc`, `fgetc`, and `getchar` functions on the GPU. Their implementations are straightforward enough. One thing worth noting is that the implementation of `fgets` will be extremely slow due to the high latency to read a single char. A faster solution would be to make a new RPC call to call `fgets` (due to the special rule that newline or null breaks the stream). But this is left out because performance isn't the primary concern here.
2023-09-13[libc][NFC][Docs] Update some GPU testing informationJoseph Huber
Summary: This comment is outddated and can be removed, also mention an option for limiting parallelism during tests in the documentation.
2023-09-13[libc] Implement 'qsort' and 'bsearch' on the GPU (#66230)Joseph Huber
Summary: This patch simply adds the necessary config to enable qsort and bsearch on the GPU. It is *highly* unlikely that anyone will use these, as they are single threaded, but we may as well support all entrypoints that we can.
2023-09-09[libc] Implement stdio writing functions for the GPU port (#65809)Joseph Huber
Summary: This patch implements fwrite, putc, putchar, and fputc on the GPU. These are very straightforward, the main difference for the GPU implementation is that we are currently ignoring `errno`. This patch also introduces a minimal smoke test for `putc` that is an exact copy of the `puts` test except we print the string char by char. This also modifies the `fopen` test to use `fwrite` to mirror its use of `fread` so that it is tested as well.