Skip to content

[libc] How do I build clang for OpenMP program with the GPU C library? #127458

Closed
@jun-shibata

Description

@jun-shibata

About libc for GPU, OpenMP offload example does not succeed.
I tried the following script to build clang.

standard runtimes build

cmake /volume/develop/src/llvm-project/llvm -G Ninja \
   -DCMAKE_BUILD_TYPE=Release \
   -DLLVM_ENABLE_PROJECTS="clang;lld" \
   -DLLVM_ENABLE_RUNTIMES="openmp" \
   -DCMAKE_INSTALL_PREFIX=/path to install \
   -DCMAKE_C_COMPILER=/path to clang \
   -DCMAKE_CXX_COMPILER=/path to clang++ \
   -DRUNTIMES_nvptx64-nvidia-cuda_LLVM_ENABLE_RUNTIMES=libc \
   -DRUNTIMES_amdgcn-amd-amdhsa_LLVM_ENABLE_RUNTIMES=libc \
   -DLLVM_RUNTIME_TARGETS="default;amdgcn-amd-amdhsa;nvptx64-nvidia-cuda"

However, the following procedure resulted in an error.

https://libc.llvm.org/gpu/using.html#openmp-offloading-example

$ clang -v openmp.c -fopenmp --offload-arch=sm_86
clang version 19.1.7 (https://github.com/llvm/llvm-project.git cd708029e0b2869e80abe31ddb175f7c35361f90)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /--/install/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Candidate multilib: .;@m64
Selected multilib: .;@m64
Found CUDA installation: /usr/local/cuda-12.1, version 12.1
clang: error: no library 'libomptarget-nvptx-sm_86.bc' found in the default clang lib directory or in LIBRARY_PATH; use '--libomptarget-nvptx-bc-path' to specify nvptx bitcode library

I couldn't find libomptarget-nvptx-sm_*.bc, but found libc.bc.

./lib/amdgcn-amd-amdhsa/libc.bc
./lib/amdgcn-amd-amdhsa/libm.bc
./lib/nvptx64-nvidia-cuda/libc.bc
./lib/nvptx64-nvidia-cuda/libm.bc

CPU Intel Xeon Gold 6338T
GPU NVIDIA RTX A6000

OS Ubuntu 22.04
LLVM version 19.1.7
NVidia Driver 545.23.06
CUDA 12.1

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions