Can't build simple OpenMP offloading programs (needs -no-pie)

Bug #1907812 reported by Mehdi Chinoune
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gcc-10 (Ubuntu)
Invalid
Undecided
Unassigned
gcc-9 (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

$cat prod.f90
program main
  implicit none
  integer, parameter :: sp = selected_real_kind(6,37)
  integer, parameter :: n = 4096
  real(sp), allocatable :: a(:), b(:), c(:), c2(:)
  integer :: i

  allocate( a(n), b(n), c(n) )

  c = 0._sp
  call random_number(a)
  call random_number(b)

  !$omp target teams map(to: a, b) map(from: c)
  !$omp distribute parallel do
  do i = 1, n
    c(i) = a(i)*b(i)
  end do
  !$omp end target teams

  c2 = a*b

  print*, maxval( abs(c2-c) )

end program

$ gfortran -O3 -flto -fopenmp -foffload=nvptx-none prod.f90 -o test.x
/usr/bin/ld: /tmp/ccyvMF16.crtoffloadtable.o: warning: relocation against `__offload_vars_end' in read-only section `.rodata'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE

Ubuntu 20.10 x86_64
Xeon E3-1505m-v6
Nvidia Quadro M2200

That doesn't happen on Ubuntu 20.04

Revision history for this message
Mehdi Chinoune (mchinoune) wrote :

Building with "-no-pie" resolves the problem.

Matthias Klose (doko)
summary: - Can't build simple OpenMP offloading programs on Ubuntu 20.10
+ Can't build simple OpenMP offloading programs (needs -no-pie)
Revision history for this message
Mehdi Chinoune (mchinoune) wrote :

It's getting worse on Ubuntu 21.04

$ gfortran -fopenmp matmul.f90 -o test.x
lto-wrapper: fatal error: could not find accel/amdgcn-amdhsa/mkoffload in /usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/ (consider using ‘-B’)
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status

I reported that before but someone has closed it.

$ gfortran -fopenmp -foffload=nvptx-none matmul.f90 -o test.x
/usr/bin/ld: /tmp/ccvGeRgU.crtoffloadtable.o: warning: relocation against `__offload_vars_end' in read-only section `.rodata'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE

$ gfortran -fopenmp -foffload=nvptx-none -no-pie matmul.f90 -o test.x
$ ./test.x 1024
 dim1 = dim2 = 1024
 MATMUL Time = 6.80000037E-02

libgomp: while loading libgomp-plugin-gcn.so.1: libgomp-plugin-gcn.so.1: cannot open shared object file: No such file or directory
 Offloading Time = 11.8520002
 Max(|C2-C1|) = 5.79833984E-04
$ ./test.x 1024
 dim1 = dim2 = 1024
 MATMUL Time = 6.30000010E-02

libgomp: while loading libgomp-plugin-gcn.so.1: libgomp-plugin-gcn.so.1: cannot open shared object file: No such file or directory

libgomp: cuCtxSynchronize error: the launch timed out and was terminated

libgomp: cuMemFree_v2 error: the launch timed out and was terminated

libgomp: device finalization failed

Revision history for this message
Mehdi Chinoune (mchinoune) wrote (last edit ):

No need to pass -no-pie with gcc-11 on Ubuntu 21.10, but still throwing some warnings:

/usr/bin/ld: /tmp/ccpIxsYV.crtoffloadtable.o: warning: relocation against `__offload_vars_end' in read-only section `.rodata'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE

Still stop running with big size matrices:

 ./test.x 1024
 dim1 = dim2 = 1024
 MATMUL Time = 0.12400000000000000

libgomp: cuCtxSynchronize error: the launch timed out and was terminated

libgomp: cuMemFree_v2 error: the launch timed out and was terminated

libgomp: device finalization failed

Revision history for this message
Mehdi Chinoune (mchinoune) wrote :

No will to fix it.
Close

Changed in gcc-9 (Ubuntu):
status: New → Invalid
Revision history for this message
Mehdi Chinoune (mchinoune) wrote :

No will to fix it
Close

Changed in gcc-10 (Ubuntu):
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.