<div dir="ltr"><div>I think your concern is part of a more profound problem.</div><div><br></div><div>At compile,<br></div><div>-fopenmp needs headers and -fopemmp-targets needs deviceRTL.</div><div>I think those under clang installation are picked by default.</div><div>I had not encountered an issue with this.<br></div><div><br></div><div>At link,</div><div>-fopenmp links libomp and -fopenmp-target needs libomptarget.</div><div>I reported an incident <a href="https://lists.llvm.org/pipermail/openmp-dev/2019-December/002990.html">https://lists.llvm.org/pipermail/openmp-dev/2019-December/002990.html</a> <br></div><div>I don't see a good reason to pick up the one from OS instead of the one from clang installation if found.</div><div></div><div>Joel E. Denny attempted to tackle the issue but it went nowhere <a href="https://reviews.llvm.org/D55725">https://reviews.llvm.org/D55725</a></div><div>I would like to by default pick up the one from clang installation before looking for OS locations.</div><div>On the other hand, we should allow clang to accept libomp libomptarget from an alternative location.</div><div>Maybe we can have -fopenmp=libomp=/path/to/installation_root if an alternative searching location is desired.</div><div>Or -fopenmp=libompapi to turn on only compilation and requires setting all the include and library paths manually.</div><div>I mean more of the desired behaviors and please feel free to propose sane solutions.<br></div><div><br></div><div>At run,</div><div>LD_LIBRARY_PATH currently is needed to point out where libomp and libomptarget are.</div><div></div><div>As an application user, I'm unhappy if my apps stop because I forgot to load the llvm compiler module on an HPC to set LD_LIBRARY_PATH or my OS libomp got picked up for whatever reason. So I do support adding rpath for OpenMP libraries.</div><div>LD_LIBRARY_PATH has higher priority than rpath, using it to pick up alternative libraries remains working I believe.<br></div><div><br></div><div>With -fopenmp=libomp=/path/to/installation_root, we should be able to select alternative libraries at compiling and linking and with LD_LIBRARY_PATHw we can select dynamic libraries at running.<br></div><div><br></div><div>Best,<br></div><div>Ye<br></div><div><div><div><div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr">===================<br>
Ye Luo, Ph.D.<br>Computational Science Division & Leadership Computing Facility<br>
Argonne National Laboratory</div></div></div></div></div><br></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, May 5, 2021 at 6:56 PM Jon Chesterfield via Openmp-dev <<a href="mailto:openmp-dev@lists.llvm.org">openmp-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Today, to run an openmp application, one compiles it:<div>> clang -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa hello.c -o a.out</div><div>execute,</div><div>> ./a.out</div><div>error while loading shared libraries: libomp.so: cannot open shared object file: No such file or directory<br></div><div><br></div><div>D101960, and this email, starts a discussion to remove that property of our toolchain. Today, the next steps go something like:</div><div><br></div><div>> find $HOME -type f -iname libomp.so</div><div>and gets, on the machine I'm currently using,</div><div>$HOME/llvm-install/lib/libomp.so<br>$HOME/llvm-install-dbg/lib/libomp.so<br>$HOME/llvm-build-dbg/llvm/runtimes/runtimes-bins/openmp/runtime/src/libomp.so<br>$HOME/llvm-build/llvm/runtimes/runtimes-bins/openmp/runtime/src/libomp.so<br>$HOME/.emacs.d/lib/libomp.so<br>$HOME/.emacs.d/llvm/openmp/runtime/exports/lin_32e.ompt.optional/lib/libomp.so<br>$HOME/aomp/build/openmp/runtime/src/libomp.so<br>$HOME/aomp/build/openmp_debug/runtime/src/libomp.so<br>$HOME/rocm/aomp_13.0-3/lib/libomp.so<br>$HOME/rocm/aomp_13.0-3/lib-debug/libomp.so<br>$HOME/ROCm-llvm-build/llvm/lib/libomp.so<br></div><div><br></div><div>Brief confusion while I convince myself that I wanted the first one in that list,</div><div>> export LD_LIBRARY_PATH=$HOME/llvm-install/lib/</div><div>> ./a.out</div><div>> success</div><div><br></div><div>Similarly, if one takes a failing openmp test, it has a RUN line that can be copied into a shell, e.g.<br></div><div><br></div><div>$HOME/llvm-build/llvm/./bin/clang++ -fopenmp  -fno-experimental-isel   -I $HOME/llvm-project/openmp/libomptarget/test -I $HOME/llvm-build/llvm/runtimes/runtimes-bins/openmp/runtime/src -L $HOME/llvm-build/llvm/runtimes/runtimes-bins/openmp/libomptarget -L $HOME/llvm-build/llvm/runtimes/runtimes-bins/openmp/runtime/src  -fopenmp-targets=amdgcn-amd-amdhsa $HOME/llvm-project/openmp/libomptarget/test/offloading/parallel_offloading_map.cpp -o $HOME/llvm-build/llvm/runtimes/runtimes-bins/openmp/libomptarget/test/amdgcn-amd-amdhsa/offloading/Output/parallel_offloading_map.cpp.tmp && $HOME/llvm-build/llvm/runtimes/runtimes-bins/openmp/libomptarget/test/amdgcn-amd-amdhsa/offloading/Output/parallel_offloading_map.cpp.tmp | $HOME/llvm-build/llvm/./bin/FileCheck $HOME/llvm-project/openmp/libomptarget/test/offloading/parallel_offloading_map.cpp<br></div><div><br></div><div>That will also fail, but for different reasons. Lit sets up LD_LIBRARY_PATH to find libomp + libomptarget, and LIBRARY_PATH to find the devicertl. The build tree puts the first two in different places, so the invocation to successfully hit the same failure from the test suite is something like</div><div>> export LD_LIBRARY_PATH="$HOME/llvm-build/llvm/runtimes/runtimes-bins/openmp/libomptarget:$HOME/llvm-build/llvm/runtimes/runtimes-bins/openmp/runtime/src"<br>> export LIBRARY_PATH="$HOME/llvm-build/llvm/runtimes/runtimes-bins/openmp/libomptarget/"<br>then the above.</div><div><br></div><div>Instead of this, let's do something roughly equivalent to <a href="https://reviews.llvm.org/D101960" target="_blank">https://reviews.llvm.org/D101960</a>.</div><div><br></div><div>That does a bunch of small, semi-orthogonal things with the end result that clang -fopenmp makes an executable that runs, without an environment variable, and the failures from the test suite can be copied into a new shell for debugging.</div><div><br></div><div>Thanks all,</div><div><br></div><div>Jon</div><div><br></div></div>
_______________________________________________<br>
Openmp-dev mailing list<br>
<a href="mailto:Openmp-dev@lists.llvm.org" target="_blank">Openmp-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/openmp-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/openmp-dev</a><br>
</blockquote></div>