Some of the functions were missing LIBC_INLINE and some of the variable
names were less descriptive than I liked. This PR fixes both as well as
cleaning up dependencies.
Summary:
Right now the scan checks to avoid the unspecified behavior in
`clzg(0)`. This is used as the source to the shuffle instruction, but
the argument is discarded at zero anyway. So, we simply pass unspecified
behavior to shuffle and then discard it. This should be fine. The scan
routines are expected to be optimal.
Also renames `sum` to `add`.
Get rid of several .h.def files which were used to ensure that the
macro definitions from llvm-libc-macro would be included in the public
header. Replace this logic with YAML instead - add entries to the
"macros" list that point to the correct "macro_header" to ensure it
would be included.
For C standard library headers, list several standard-define macros
to document their availability. For POSIX/Linux headers, only reference
a handful of macro, since more planning is needed to decide how to
represent platform-specific macro in YAML.
The docgen script was previously hardcoded to assume all implemented
macros must be placed in a *-macros.h header. This updates docgen to
read inline macro_value properties directly from the source YAML files,
correctly recognizing them as implemented.
Define the POSIX cpio.h header and its standard macros in the libc build
system. Configure the macros directly in the YAML specification to allow
automated header generation without a custom definition template.
Switches the following headers to hdrgen-produced ones by referencing
some macro from C standard and the file containing the declarations in
corresponding YAML files:
* limits.h (referenced _WIDTH / _MAX / _MIN families).
* locale.h (referenced LC_ family).
* time.h (referenced CLOCKS_PER_SEC).
* wchar.h (referenced WEOF).
Added a brief description of the libc-shared-tests target to the
Building and Testing page.
This target allows running tests for shared standalone components like
math primitives without the full libc runtime.
Fix broken POSIX basedefs links for nested headers in llvm-libc docs.
The docgen script currently emits paths like `sys/wait.h.html`, but the
Open Group uses `sys_wait.h.html`, for example:
-
https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_wait.h.html
This updates nested-header link generation while leaving flat headers
unchanged.
Previously there was a single rule for stdbit, this PR adds generated
header targets for the rest of the linux headers. It also adds a
cc_library
for all of the public headers which also includes the types and macros
headers.
Added a "Building and Testing with an Emulator" section to
full_cross_build.rst using riscv64 and qemu-riscv64 as the example.
Outlined necessary CMake flags for cross-compiling with Clang, including
CMAKE_C_COMPILER_TARGET, CMAKE_CXX_COMPILER_TARGET, and
LLVM_ENABLE_LLD=ON. Switched from CMAKE_SYSROOT to LIBC_KERNEL_HEADERS
and added the gcc-riscv64-linux-gnu package dependency to ensure sysroot
issues on Debian-based systems are avoided while retaining access to
cross-compiler runtime objects.
Explained the self-hosted libc-hermetic-tests target as the required
target for executing tests during a standalone cross build, since the
standard check-libc tests are not hermetic.
Refactored existing CMake examples in full_cross_build.rst to use -S and
-B flags instead of cd and mkdir.
Removed prompt characters from code blocks and separated host
environment setup into explicit code blocks for easier copy-pasting.
Also removed the initial 'cd llvm-project' directory changes to reduce
boilerplate.
Added a cross-reference to the new emulator section in
build_and_test.rst.
Add support for the half-precision complementary error function
`erfcf16``, using a Sollya generated polynomial implementation with
proper handling of special cases.
Extend the MPFR utilities with erfc support to allow tests.
closes: #180927
Updated check-libc-lit to depend only on build-only targets. Added
libc-integration-tests-build to track integration test executables and
updated LLVMLibCTestRules.cmake to populate it.
Removed incorrect dependencies on execution suites in include and
integration tests that were introduced in #184366.
Clean up the `%public_api` printer code slightly - get rid of explicit
`\n` and ensure we only print `__BEGIN_C_DECLS` and `__END_C_DECLS` if
the generated header actually contains functions or objects to declare.
I've noticed that after 27ba9e2a44c11f8123528c350227db2c9a707c8f landed,
generated errno.h header has two blocks of `__BEGIN_C_DECLS` /
`__END_C_DECLS`: an empty one was generated automatically from
`%public_api` section that was intended to only add the `errno_t` type
declaration.
Summary:
We store the locks in local device memory for performance and
simplicity. The number here needs to correspond to the maximum occupancy
so that we never have a situation where a GPU thread is blocking another
GPU thread.
The number now is sufficient for most hardware, but modern compute chips
like the MI300x are already pushing ~12000 resident waves. This has ABI
impliciations so I'd like to bump it up sooner rather than later. The
ABI change is within what OpenMP expects, LLVM major versions, and it
will be caught statically so there's no risk of silent corruption (size
doesn't match).
Summary:
This PR primarily changes using `LLVM_RUNTIMES_TARGET` to
`LLVM_DEFAULT_TARGET_TRIPLE`. The reason is that the default target
triple is the true cross-compiling architecture we are using, while the
runtimes_target can contain multilib strings like `+debug` or similar.
Additionally add the proper path handling to the OpenMP / Offload
libraries.
Added implementing_a_function.rst providing a checklist for adding a new
function to LLVM-libc.
Updated dev/index.rst to include the new guide in the toctree.
- Switch log1pf to use the same log_eval from inverse hyperbolic
functions.
- Optimize log_eval to use the same range reduction scheme as double
precision log
- Reduce the table size needed for log range reduction.
- This lower the overall latency of log1pf and inverse hyperbolic
functions.
Implement support for flushing all open streams when fflush is called
with a NULL pointer.
* Added a global linked list to track all open File objects.
* Updated File class to include prev/next pointers and list management
methods.
* Implemented POSIX requirement for fflush to sync seekable input
streams back to the host environment.
* Updated Linux-specific file creation to register new files in the
global list.
* Fixed a memory safety bug in create_file_from_fd using delete instead
of free.
* Added unit test for fflush(NULL).
* Added explanatory comments to fflush.cpp and file.cpp.
- Fix header guard name.
- Define `__STDC_WANT_LIB_EXT1__` in `hdr/types/rsize_t.h` so that the
type is available for internal use.
- In accordance to the standard, make `stdio.h`, `stdlib.h`, `string.h`,
`time.h` and `wchar.h` define the type. It should already be available
in `stddef.h` as it's provided by Clang, not LLVM libc.
- Change `errno.h.def` to include a placeholder where hdrgen emits the
public API, which contains the `errno_t` definition.
- Make headers `stdio.h`, `stdlib.h`, `string.h` and `time.h` also
define `errno_t` as specified in the standard.
Moved the declaration of 'ret' inside the SYS_utimes block to prevent an
unused variable warning on the libc-riscv32-qemu-yocto-fullbuild-dbg
builder, which doesn't define SYS_utimes.
With currently only LIBC_INLINE, we just hint the compiler to inline the
function which however in practice is not always the case.
Since we added `[[gnu::always_inline]]` on linux/x86_64 it makes sense
to do it on all platforms consistently and add a comment explaining why
we need it.
Implemented the utimensat syscall for Linux and added the entrypoint to
sys/stat.h.
* Added utimensat syscall wrapper to OSUtil
* Updated utimes to use the utimensat wrapper
* Added utimensat unit tests to sys/stat
* Configured entrypoints for x86_64, riscv, and aarch64
Expanded entrypoints.rst with details about definitions, registration
rules, and the lifecycle of an entrypoint.
Updated multiple documents to remove redundant technical details and
link to the centralized entrypoints reference:
- libc/docs/dev/cmake_build_rules.rst
- libc/docs/dev/implementation_standard.rst
- libc/docs/porting.rst
- libc/docs/dev/source_tree_layout.rst
Currently the guards for `totalorderbf16` and `totalordermagbf16` are as
follows:
```
#ifndef LLVM_LIBC_SRC_MATH_TOTALORDERMAGF16_H
#define LLVM_LIBC_SRC_MATH_TOTALORDERMAGF16_H
-
#endif // LLVM_LIBC_SRC_MATH_TOTALORDERMAGF16_H
```
and
```
#ifndef LLVM_LIBC_SRC_MATH_TOTALORDERF16_H
#define LLVM_LIBC_SRC_MATH_TOTALORDERF16_H
-
#endif // LLVM_LIBC_SRC_MATH_TOTALORDERF16_H
```
As we can see these are for F16 and not BF16 .
This Pr intends to fix that with correct guards as `TOTALORDERBF16` and
`TOTALORDERMAGBF16`
This PR intends to fix a small nit caused in
[1c1135b](1c1135b3fc)
```
#endif // LLVM_LIBC_SRC_MATH_ASINIF16_H
```
to
```
#endif // LLVM_LIBC_SRC_MATH_ATANPIF16_H
```
Replace the explicit `if constexpr` branching for big and little
endianness with compile-time calculated shift constants `VAL_SHIFT` and
`NEXT_SHIFT`. This simplifies the logic and reduces code duplication,
relying on the compiler to constant-fold the zero shifts into no-ops.
This PR intends to fix the nit (mostly caused during the refactor in
693a018dcf08e )
- During refactor we move the implementation along with the explanation
comments to header.
```CPP
// This is an algorithm for log(x) in single precision which is correctly
// rounded for all rounding modes, based on the implementation of log(x) from
// the RLIBM project at:
// https://people.cs.rutgers.edu/~sn349/rlibm
// Step 1 - Range reduction:
// For x = 2^m * 1.mant, log(x) = m * log(2) + log(1.m)
// If x is denormal, we normalize it by multiplying x by 2^23 and subtracting
.....
// Symposium on Principles of Programming Languages (POPL-2022), Philadelphia,
// USA, January 16-22, 2022.
// https://people.cs.rutgers.edu/~sn349/papers/rlibmall-popl-2022.pdf
```
Though the explanation comments were copied and moved to header in
d2492c1 . It wasn't deleted from the `cpp` file.
Along with this in the same,
`#include "src/__support/math/logf.h" // Lookup table for (1/f) and
log(f)`
is wrong as it is actually for
`#include "src/__support/math/common_constants.h" // Lookup table for
(1/f) and log(f)`
Fixesllvm/llvm-project#123821.
Re-enabling pthread docs created a global CMake utility target named
`pthread`, which collides in combined runtime builds where `pthread` is
expected to be a library name. Namespace the internal libc docgen helper
targets under `libc-docgen-*` and restore the generated pthread docs
page. `docs-libc-html` is unchanged.
Summary:
One of the main disadvantages to using the RPC interface is that it
requires a server thread to spin on the mailboxes checking for work.
The vast majority of the time, there will be no work and work will come
in large bursts.
The HSA / KFD interface supports device-side interrupts and already has
handling for binding these events to an HSA signal. This means that we
can send interrupts from the GPU to wake a sleeping thread on the CPU.
The sleeping thread will be descheduled with a blocking HSA wait call
and woken up when its event ID is raised through the kernel driver's
interrupt.
This is very target-specific handling, but I believe it is valuable
enough to warrant it being in the protocol. It is completely optional,
as it is ignored if uninitialized. This should bring this support at
parity with the interface HIP expects.
This PR intends to make the cbrtf guard sync with the general format (
as other functions consistently use `LLVM_LIBC_SHARED_MATH_<func>_H`).
This was found during refactoring cbrtbf16.
Updated LibcTest to handle Windows test executables:
* Added support for .exe extensions when identifying test executables.
* Skipped the executable bit check on Windows as it is not applicable.
* Updated .params file discovery to look for both <test>.exe.params and
<test>.params.
This allows running libc tests on Windows hosts.
This PR intends to add/update the following things:
- Add missing doc for CMake for shared_math
- Add missing testing command for shared_math_test
- Nits (e.g., grammar, spaces, missing colons, etc.)