NVIDIA / warp

A Python framework for high performance GPU simulation and graphics

Home Page:https://nvidia.github.io/warp/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there OpenMP support in the prebuilt Clang & LLVM libraries from packman?

AnthCol opened this issue · comments

Hello,
I am trying to modify the code generation in Warp to support OpenMP. The primary goal is to speed up execution of warp kernels on the CPU by parallelizing the loops in the generated code that call "length_cpu_kernel_forward" and "length_cpu_kernel_backward".
I am wondering if the prebuilt Clang & LLVM libraries within packman are compatible with that idea?
I am aware that there is an option to clone and build LLVM from scratch, and I could possibly enable OpenMP support through the CMake defines in build_llvm.py - Just wondering if there is a way to do this through the prebuilt libraries from packman. Among other things, I have tried adding the OpenMP flag (-fopenmp) to the arguments within cpp_to_llvm (in clang.cpp) which later gets used by clang::CompilerInvocation::CreateFromArgs(). The command is recognized by the compiler, but there are missing symbols, all of which begin with ___kmpc, and are related to OpenMP directives/pragmas.
The error looks like this:
JIT session error: Symbols not found: [ ___kmpc_critical, ___kmpc_end_critical, ___kmpc_for_static_fini, ___kmpc_for_static_init_8u, ___kmpc_fork_call ]
From what I can tell, these appear to be linker errors, which is why I am wondering whether the included LLVM & Clang binaries support OpenMP. Last year colleagues of mine were able to get OpenMP working on Warp version 0.7.2 (which uses the system compiler) using the -fopenmp flag, and I am working on porting our prototype to the latest, Clang & LLVM based version of Warp.

Thank you in advance,
Anthony

Hi Anthony, thanks for the inquiry. It's very interesting to hear that your team got GCC's -fopenmp support working for Warp.

The prebuilt Clang and LLVM libraries on packman currently use release version 15.0.7, while OpenMP support has only recently been merged into the LLVM main branch and will be part of the upcoming version 18 release.

So I'm afraid the only potential way to get it working would be to build a more recent version of LLVM from source by using the --build_llvm flag when building Warp, and modifying build_from_source_for_arch() to check out a recent revision.