[Bug libgomp/95150] Some offloaded programs crash with openmp

mehdi.chinoune at hotmail dot com gcc-bugzilla@gcc.gnu.org
Sun Dec 13 04:21:48 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95150

Chinoune <mehdi.chinoune at hotmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |WONTFIX

--- Comment #8 from Chinoune <mehdi.chinoune at hotmail dot com> ---
Adding "parallel do" to openmp directive solves the problem.
The crash reappears with "collapse(2)" with both OpenMP and OpenACC.

program main
  implicit none
  integer, parameter :: sp = selected_real_kind(6,37)
  real(sp), allocatable :: a(:,:), b(:,:), c(:,:)
  character( len=5 ) :: val
  integer :: n, l, m
  integer :: i, j, k
  integer :: t1, t2
  real(sp) :: tic
  !
  call get_command_argument( 1, val )
  read( val, *) n
  l = n
  m = n
  !
  call system_clock( t1, tic)
  !
  allocate( a(l,m), b(m,n), c(l,n) )
  !
  call random_number(a)
  call random_number(b)
  c = 0._sp
  !
  !$acc data copyin(a,b) copy(c)
  !$acc parallel loop collapse(3)
  !$omp target teams distribute parallel do collapse(3) map( to:a,b ) map(
tofrom:c )
  do j = 1, n
    do k = 1, m
      do i = 1, l
        c(i,j) = a(i,k)*b(k,j) + c(i,j)
      end do
    end do
  end do
  !$acc end data
  !
  call system_clock(t2)
  print*, n, (t2-t1)/tic, sum(c)
  !
end program main

$ gfortran -O3 -fopenmp -foffload=nvptx-none matmul.f90 -o test.x
$ for i in {1..5}; do ./test.x $((512*2**$i)); done
        1024  0.287999988       268377424.
        2048   7.40000010E-02   0.00000000
        4096  0.170000002       0.00000000
        8192  0.574000001       0.00000000
       16384   2.10400009       0.00000000


More information about the Gcc-bugs mailing list