[PATCH] D105191: [Clang][OpenMP] Add support for Static Device Libraries

Saiyedul Islam via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 13 12:20:07 PDT 2021


saiislam added a comment.

In D105191#2997272 <https://reviews.llvm.org/D105191#2997272>, @ye-luo wrote:

> @saiislam did you turn on offload? https://github.com/ye-luo/openmp-target/wiki/OpenMP-offload-compilers#llvm-clang
> On NVIDIA, it fails at CMake step. On AMD, make step stops because of unrelated issue.
>
> Please make the exact reproducer 1 working. Right now I got
>
>   $ clang++ -fopenmp -fopenmp-targets=nvptx64 -Xopenmp-target=nvptx64 -march=sm_80 modf.o
>   nvlink fatal   : Could not open input file '/tmp/modf-88b730.cubin'
>   /soft/llvm/main-patched/bin/clang-nvlink-wrapper: error: 'nvlink' failed
>   clang-14: error: nvlink command failed with exit code 1 (use -v to see invocation)

@ye-luo 
Can you please take this latest update and verify if it is working for you?
It is working for me.

Following modifications were also required for the compile.sh and compile-amd.sh.
Assuming name of your fat archive is **libmylib.a** and it is present in the **current directory**, the command to use it will be as follows:

> clang++ -fopenmp -fopenmp-targets=nvptx64 main.cpp **-L. -lmylib**

or

> clang++ -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 main.cpp** -L. -lmylib**

So, compile.sh should be:

> clang++ -fopenmp -fopenmp-targets=nvptx64 -c -Xopenmp-target=nvptx64 -march=sm_50 classA.cpp
> rm -f libmylib.a
> ar qc libmylib.a classA.o
> ranlib libmylib.a
> clang++ -fopenmp -fopenmp-targets=nvptx64 main.cpp **-L. -lmylib**
> ./a.out

And compile-amd.sh should be:

> clang++ -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 -c classA.cpp
> rm -f libmylib.a
> llvm-ar qc libmylib.a classA.o
> llvm-ranlib libmylib.a
> clang++ -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 main.cpp **-L. -lmylib**
> ./a.out


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105191/new/

https://reviews.llvm.org/D105191



More information about the cfe-commits mailing list