[libc][GSoC 2025] Bfloat16 in LLVM libc (original) (raw)
February 6, 2025, 2:39pm 1
Description: Bfloat16 is a recently developed floating point format tailored to machine learning and AI, and in the latest C++23 standard, it is officially standardized as std::bfloat16_t
. Its support could be found in many modern hardware, ranging from CPUs of all the major vendors including Intel, AMD, Apple, and Amazon, to GPUs (nVidia and AMD GPUs) and Google TPUs. On the software side, it is supported in all major accelerator libraries, such as CUDA, ROCm, oneAPI, PyTorch, and Tensorflow. The goal for this project is to implement bfloat16 math functions in the LLVM libc library.
Expected Results:
- Setup the generated headers properly so that the type and the functions can be used with various compilers (+versions) and architectures.
- Implement generic basic math operations supporting bfloat16 data types that work on supported architectures: x86_64, arm (32 + 64), risc-v (32 + 64), and GPUs.
- Implement specializations using compiler builtins or special hardware instructions to improve their performance whenever possible.
- If time permits, we can start investigating higher math functions for bfloat16.
Project Size: Large
Requirement: Basic C & C++ skills + Interest in knowing / learning more about the delicacy of floating point formats.
Difficulty: Easy/Medium
Confirm Mentor: Tue Ly, Nicolas Celik
Mohamed February 8, 2025, 10:56pm 2
I am interested in this. I have experience with LLVM. Can you share some issues to start with or further reading?
meltq February 10, 2025, 4:24am 4
This seems like something I’d love to work on. I’ve looked at the mathematical representation of Bfloat16, and have some experience contributing to LLVM (albeit in a different area). Is there any other prerequisite reading or such you’d suggest?
I’m interested in working on this! I have made some contributions into LLVM related to fixed point stuff previously. I’ll look more into this!
Hi, I am very interest in this project!I have a solid foundation in computer architecture, especially RISC-V and GPU-related architecture. Also,I have a strong interest in machine learning and have taken relevant courses on my own. I think this is the perfect project for me.
HI! I am pursuing Electrical Engineer and Computer Science majors at Boise State and I think I would work well with this project. I am very familiar with floating point representation and have coded an extremely fast double floating point parser that always returns the closest representation to the string passed in. I’ve also worked on making my own programming languages before and have had PR’s merged into the Zig project. I’ll try to compile LLVM tonight and get up to speed but I’d also like to know what I can do in the mean time to get more prepared (like issues I could work on now, etc)
leyli16 March 6, 2025, 7:37pm 8
Hi! I’m a Master’s student in Computer and Information Technology at UPenn with a strong foundation in C/C++ and a background in AI and machine learning. I’ve been exploring floating-point representations and SIMD optimizations, and I’m really interested in contributing to this project.
I’ve been looking into LLVM libc’s floating-point functions and optimizations, and I’d love to know how I can get more prepared. I also noticed that the project mentions investigating higher math functions for Bfloat16 if time permits—I have plenty of time and would be eager to explore that as well.
Looking forward to contributing!
Hi everyone,
Thank you for your interest in this project!
I would recommend the following as further reading:
- Some of the work done on
_Float16
last year:- [libc][math][c23] Add fabsf16 C23 math function by overmighty · Pull Request #93567 · llvm/llvm-project · GitHub
- [libc][math] Optimize nearest integer functions using builtins when available by overmighty · Pull Request #98376 · llvm/llvm-project · GitHub
- [gsoc2024][libc][math][c23] Implement _Float16 basic operations · Issue #93566 · llvm/llvm-project · GitHub
- [gsoc2024][libc][math][c23] Implement _Float16 higher math functions · Issue #95250 · llvm/llvm-project · GitHub
- The source code in libc/src/math/generic/ and libc/src/__support/FPUtil/ in the LLVM monorepo (GitHub - llvm/llvm-project: The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.).
- The following books:
- Handbook of Floating-Point Arithmetic by Jean-Michel Muller et al.,
- Elementary Functions: Algorithms and Implementation by Jean-Michel Muller.
If you would like to start working on the LLVM libc codebase, you can search through open issues with the “libc” label on GitHub: GitHub · Where software is built, and in particular those that also have the “good first issue” label: GitHub · Where software is built, but the latter currently (at the time of writing) all have someone assigned to them already.
If you have further questions, you can either email us or ask in the #libc
channel on the LLVM Discord server (LLVM).
Hi! I’m a Master’s student in Computer Engineering at TU Delft with a strong background in low-level systems programming, floating-point arithmetic, and AI acceleration. I’ve worked with both CPUs and GPUs, including optimizing deep learning workloads and understanding precision trade-offs in numerical computing.
I’m particularly excited about this project because it aligns perfectly with my interests in floating-point formats, hardware-aware optimizations, and compiler-level improvements. I have experience with LLVM and have explored floating-point representations in AI systems. I’m eager to contribute to implementing efficient bfloat16
math functions and leveraging hardware-specific optimizations for performance.
Looking forward to contributing!
Hello! I’m a second year student at the University of Southern California studying Computer Science and Mathematics. I’m relatively new to LLVM but I’d love to explore working with compilers, GPUs, and in this case, floating point representation. My previous experience has been in full-stack web dev and ML research, but I’m very open to learning. Please keep us posted if there are additional ways to get involved (apart from the good first issues which are taken)!
emangia March 15, 2025, 12:54pm 12
Hello, this is one of the 2 projects I’d be interested in contributing to. Here’s a bit about me…
I’m a first year M.Sc. student in Engineering Mathematics. I’ve had experience mainly with C, C++ and Python as programming languages and tools such as CUDA, OpenMP, MPI and a bit of OpenCL.
Recently, I’ve been busy with more maths focused courses, but I’ve had a Parallel Computing course and I’ll start a Compiler Construction course next week. I should mention it’d be the first time for me contributing to an open source project.
Currently, I’m also doing an internship in the machine learning field, but I’ll be quite free by June, ideally, with fresh knowledge about compilers. In the meantime, I’ll try to get up to speed about this project.
Hello everyone,
I am very excited about this project and would love to contribute to it. I am currently a second-year graduate student in Computer Science at Sun Yat-sen University. While I am new to open-source communities, I have strong programming skills in C++ and Python, as well as experience with CUDA.
My academic background includes a course on compiler principle. And I implemented a compiler frontend using ANTLR and designed an IR (Intermediate Representation) inspired by LLVM’s structure. On top of this IR, I developed a series of optimization passes. You can find my project here: YAT-CC Project Link. Additionally, I contributed to the development of a compiler teaching platform (YATCC-AI), where I was primarily responsible for Lab 3 (IR Generation) and Lab 4 (Optimization). I also worked on integrating LLM (Large Language Models) with the compiler, further deepening my familiarity with the LLVM framework.
Regarding this project, my understanding is that the input is restricted to bfloat16
, but higher precision may be used during computation. Could you confirm if this is correct? Since the target architecture involves GPUs, I’d also like to know which GPUs are planned for support and whether there are any memory constraints. Given that bfloat16
is widely used in AI computing, will quantization techniques be a key focus?
I am highly interested in this project and would love to make it my first major open-source contribution. I have ample time to dedicate to the work and am eager to learn and collaborate under your guidance. Looking forward to your insights and the opportunity to contribute!
Best regards,
Zhongchun Zheng
Hi Zhongchun,
Yes, that is correct.
LLVM libc supports AMD and NVIDIA GPUs (AMDGPU and NVPTX targets in Clang/LLVM). We don’t have an exact list of supported GPUs but anything past gfx803 for AMD and sm_52 for NVIDIA is probably supported by LLVM libc. I’m not aware of specific memory constraints.
No, we won’t be doing quantization.
Feel free to ask me if you have more questions.
Hi, I am Aditya. I am a bit late but I have been spending the last couple days going over the libc codebase and am very interested in this project. Here’s a bit about me:
I am a 4th year CS Undergrad at IIIT-H. I am an undergraduate researcher at the Computer Systems Group at my uni, and have taken courses on compilers and computer architecture in the past. I have also worked on implementing the AST translation passes on a toy compiler of my own, for a statically typed lisp.
Over the last couple days I merged my first PR, contributing to libc (#134167). I am excited to continue contributing and hope to do so through gsoc over the summer.
Is it okay if I share a draft of my proposal for review before submitting it?
Hi, I’m Maaz. I’m very interested in this project and wanted to ask:
- Will optimization using parallelization strategies (e.g., OpenMP)
- x86 vector instructions (like AVX intrinsics)
be encouraged or considered for this project? I have experience with both and would love to explore them further in the context of bfloat16.