Skip to content

Replace per-capability libdevice bitcode with unified libdevice.10.bc#9226

Open
alexreinking wants to merge 1 commit into
mainfrom
alexreinking/update-bitcode
Open

Replace per-capability libdevice bitcode with unified libdevice.10.bc#9226
alexreinking wants to merge 1 commit into
mainfrom
alexreinking/update-bitcode

Conversation

@alexreinking

Copy link
Copy Markdown
Member

Summary

  • Halide has vendored NVIDIA's per-architecture libdevice bitcode (libdevice.compute_{20,30,35}.10.bc) since its original CUDA/PTX backend landed circa 2013. NVIDIA itself dropped this per-capability split in CUDA 9.0 (2017) in favor of a single, architecture-generic libdevice.10.bc.
  • The capability-based selection logic in LLVM_Runtime_Linker.cpp was never extended past sm_50, so every newer capability Halide supports (sm_61, sm_70, sm_75, sm_80, sm_86) silently fell through to libdevice.compute_20.10.bc — a Fermi-era (2010) file — regardless of the actual target GPU.
  • This replaces the three vendored files with a single libdevice.10.bc (sourced from CUDA Toolkit 11.6) and simplifies Makefile, src/runtime/CMakeLists.txt, and src/LLVM_Runtime_Linker.cpp accordingly: one initmod, no capability-based selection table to keep in sync as NVIDIA adds compute capabilities.
  • Adds src/runtime/nvidia_libdevice_bitcode/README.md documenting what the file is, how to refresh it, and the governing NVIDIA CUDA Toolkit EULA.

Fixes #9225

Test plan

  • Configured and built libHalide from scratch (Ninja, LLVM 22, NVPTX enabled) with these changes; links clean.
  • Compiled a small sin/sqrt GPU pipeline to PTX for sm_35, sm_61, and sm_86 targets — all succeed.
  • Confirmed the sm_61 output now calls into the new libdevice (__nv_sinf, __internal_trig_reduction_slowpath, __nv_fmul_rn), where previously it would have silently linked the Fermi-era compute_20 file instead.

Halide vendored NVIDIA's libdevice.compute_{20,30,35}.10.bc since its
original CUDA/PTX backend (~2013), and picked between them via a
capability table that was never extended past sm_50. Every newer
capability (sm_61 and up) silently linked libdevice.compute_20.10.bc,
a Fermi-era math library, regardless of the actual target GPU.

NVIDIA replaced the whole per-capability split with a single
libdevice.10.bc back in CUDA 9.0 (2017). Switch to vendoring that
file instead (taken from CUDA 11.6) and simplify the Makefile,
CMakeLists.txt, and LLVM_Runtime_Linker.cpp accordingly: one initmod,
no capability-based selection logic.

Fixes #9225

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@alexreinking
alexreinking requested a review from shoaibkamil July 21, 2026 04:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PTX libdevice selection silently falls back to compute_20 for capabilities above sm_50

1 participant