Issue 64624
Summary [OpenMP][libomptarget][DeviceRTL] Executable hangs when offloading to GPU
Labels new issue
Assignees
Reporter tavakkoliamirmohammad
    I have a problem with using OpenMP target offloading on NVIDIA A100.

Here is my build step from the latest cloned LLVM.
```
mkdir build
cd build
cmake -G Ninja ../llvm -DLLVM_ENABLE_PROJECTS="clang;lld" -DLLVM_ENABLE_RUNTIMES="openmp" -DLLVM_TARGETS_TO_BUILD="Native;NVPTX;AMDGPU" -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DLLVM_ENABLE_LLD=ON -DLLVM_CCACHE_BUILD=ON
cmake --build . -j 128
```
The build finishes with the follwoing message

`[4047/4047] Completed 'runtimes'
`

Now using the example provided in the [Clang documentation](https://clang.llvm.org/docs/OffloadingDesign.html#offloading-example)
```
#include <complex>

using complex = std::complex<double>;

void zaxpy(complex *X, complex *Y, complex D, std::size_t N) {
#pragma omp target teams distribute parallel for
  for (std::size_t i = 0; i < N; ++i)
    Y[i] = D * X[i] + Y[i];
}

int main() {
  const std::size_t N = 1024;
  complex X[N], Y[N], D;
#pragma omp target data map(to:X[0 : N]) map(tofrom:Y[0 : N])
  zaxpy(X, Y, D, N);
}
```
Saved as `zaxpy.cpp`

Now compile command 

```
./bin/clang++ --libomptarget-nvptx-bc-path=./runtimes/runtimes-bins/openmp/libomptarget/DeviceRTL/ -fopenmp -fopenmp-targets=nvptx64 -O3 zaxpy.cpp -c
```
Also checking the .o file.
```
$  llvm-readelf -WS zaxpy.o
There are 24 section headers, starting at offset 0x90c8:

Section Headers:
  [Nr] Name Type            Address          Off    Size   ES Flg Lk Inf Al
 [ 0]                   NULL            0000000000000000 000000 000000 00 0   0  0
  [ 1] .strtab           STRTAB          0000000000000000 008d0c 0003b9 00      0   0  1
  [ 2] .text             PROGBITS 0000000000000000 000040 00057a 00  AX  0   0 16
  [ 3] .rela.text RELA            0000000000000000 0088d0 000318 18   I 23   2  8
  [ 4] .rodata.cst16     PROGBITS        0000000000000000 0005c0 000030 10  AM  0 0 16
  [ 5] .text.startup     PROGBITS        0000000000000000 0005f0 00000a 00  AX  0   0 16
  [ 6] .rela.text.startup RELA 0000000000000000 008be8 000018 18   I 23   5  8
  [ 7] .rodata.str1.1 PROGBITS        0000000000000000 0005fa 000017 01 AMS  0   0  1
  [ 8] .data.rel.ro      PROGBITS        0000000000000000 000618 000048 00  WA  0 0  8
  [ 9] .rela.data.rel.ro RELA            0000000000000000 008c00 000048 18   I 23   8  8
  [10] .rodata           PROGBITS 0000000000000000 000660 000001 00   A  0   0  1
  [11] .rodata.cst32 PROGBITS        0000000000000000 000670 000040 20  AM  0   0 16
  [12] .rodata.str1.16   PROGBITS        0000000000000000 0006b0 00003e 01 AMS  0 0 16
  [13] omp_offloading_entries PROGBITS   0000000000000000 0006ee 000020 00  WA  0   0  1
  [14] .relaomp_offloading_entries RELA 0000000000000000 008c48 000030 18   I 23  13  8
  [15] .init_array.0 INIT_ARRAY      0000000000000000 000710 000008 00  WA  0   0  8
  [16] .rela.init_array.0 RELA           0000000000000000 008c78 000018 18   I 23 15  8
  [17] .llvm.offloading  LLVM_OFFLOADING 0000000000000000 000718 007d18 00   E  0   0  8
  [18] .comment          PROGBITS 0000000000000000 008430 00006a 01  MS  0   0  1
  [19] .note.GNU-stack PROGBITS        0000000000000000 00849a 000000 00      0   0  1
  [20] .eh_frame         X86_64_UNWIND   0000000000000000 0084a0 000178 00   A  0 0  8
  [21] .rela.eh_frame    RELA            0000000000000000 008c90 000078 18   I 23  20  8
  [22] .llvm_addrsig     LLVM_ADDRSIG 0000000000000000 008d08 000004 00   E 23   0  1
  [23] .symtab SYMTAB          0000000000000000 008618 0002b8 18      1  15  8
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
  L (link order), O (extra OS processing required), G (group), T (TLS),
  C (compressed), x (unknown), o (OS specific), E (exclude),
  R (retain), l (large), p (processor specific)
```
Now compiling with command 
```
./bin/clang++ --libomptarget-nvptx-bc-path=./runtimes/runtimes-bins/openmp/libomptarget/DeviceRTL/ -fopenmp -fopenmp-targets=nvptx64 -O3 zaxpy.cpp -o zaxpy
export LD_LIBRARY_PATH=/uufs/chpc.utah.edu/common/home/u1419116/projects/openmp/llvm-project/build/lib:$LD_LIBRARY_PATH
./zaxpy
```
The binary hangs indefinitely!

Also, the tests are failing using the command
```
cmake --build . --target check-openmp
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to