LLVM openMP entry point

Hi,

I want to do a project with OpenMP where I add speculation with transactional memory, but I have a hard time finding an entry point to the omp library.
Therefore, I was hoping you could point me to it.

Best wishes
Krzysztof

What do you mean by entry point? It depends on what you’re interested in modifying. Others can correct me if I’m wrong but:

If you just want to modify the runtime, files will be under /openMP (https://github.com/llvm/llvm-project/tree/main/openmp)

If you want to add new clauses you need to focus more on clang, code generation and such. Some files of interest are:
https://github.com/llvm/llvm-project/blob/main/clang/lib/Parse/ParseOpenMP.cpp
https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaOpenMP.cpp

https://github.com/llvm/llvm-project/blob/main/clang/lib/AST/DeclOpenMP.cpp
https://github.com/llvm/llvm-project/blob/main/clang/lib/AST/StmtOpenMP.cpp
https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CGOpenMPRuntime.cpp (and header)
https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp (and the corresponding vendor specific files for offloading in the same folder (e.g. AMDGCN and NVPTX)
https://github.com/llvm/llvm-project/tree/main/llvm/lib/Frontend/OpenMP and https://github.com/llvm/llvm-project/tree/main/llvm/include/llvm/Frontend/OpenMP

If you are more interested in optimizations, this is where I know too little, but one file I remember is:

https://github.com/llvm/llvm-project/blob/main/llvm/lib/Transforms/IPO/OpenMPOpt.cpp and its header in /llvm/include

Other people can chime in with more ideas or files I may be missing.

My recommendation is use Godbolt a lot: Here are some examples:
https://godbolt.org/z/sWsYaz7rK
https://godbolt.org/z/YW9o1bqdx

There you can see what is being called at runtime, as well as the LLVMIR representation.

I hope this helps

Hi Krzysztof,

I was facing the same challenge when I was working with the LLVM OpenMP runtime.
What helped me is compiling the runtime in Debug mode.
Then you can enable debug output when running the benchmark/application with the following environment variables:
KMP_A_DEBUG, KMP_B_DEBUG, ... KMP_F_DEBUG
That can give you outputs with pointer to functions that are called during the process.

Example:
KMP_A_DEBUG=300 KMP_B_DEBUG=100 KMP_C_DEBUG=60 KMP_E_DEBUG=300 ./app

Thresholds are configurable and control which severity is printed.
For further information look into the source code where the debug marcos are used.

Hope that helps at least a little :slight_smile:

Best,
Jannis