flang icon indicating copy to clipboard operation
flang copied to clipboard

Compiler segmentation fault when using host OpenMP reduction and fopenmp-targets=nvptx64-nvidia-cuda

Open cdaley opened this issue 6 years ago • 1 comments

The compiler segfaults when compiling for the GPU.

$ flang -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda bug2.F90 -o bug2 && ./bug2
clang-7: error: unable to execute command: Segmentation fault
clang-7: error: unable to execute command: Segmentation fault
clang-7: error: Fortran frontend to LLVM command failed due to signal (use -v to see invocation)
clang-7: error: Fortran frontend to LLVM command failed due to signal (use -v to see invocation)
clang version 7.0.1 (https://github.com/flang-compiler/flang-driver.git 24bd54da5c41af04838bbe7b68f830840d47fc03) (https://github.com/flang-compiler/llvm.git 84335cded2f2cf9de26a77194835094fc75f7bb7)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/chrisdaley/software/llvm-flang/7.0.1-git_20190106/bin
clang-7: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
clang-7: note: diagnostic msg: Error generating preprocessed source(s).
$ cat bug2.F90 
Program bug2
  implicit none
  integer, parameter :: n = 2
  real, dimension(n) :: a
  a(1) = 1
  a(2) = 2
  call showsum(a, n)
  !$omp target enter data map(to:a)
  !$omp target exit data map(from:a)
End Program bug2

subroutine showsum(a,n)
  implicit none
  real, dimension(n), intent(in) :: a
  integer, intent(in) :: n
  real :: sum
  integer :: i

  sum = 0.0
  !$omp parallel do reduction(+:sum)
  do i = 1,n
     sum = sum + a(i)
  end do
  !$omp end parallel do
  print *, "sum=", sum
end subroutine showsum

I am using a version of Flang from Jan 6 2019.

$ flang -v
clang version 7.0.1 (https://github.com/flang-compiler/flang-driver.git 24bd54da5c41af04838bbe7b68f830840d47fc03) (https://github.com/flang-compiler/llvm.git 84335cded2f2cf9de26a77194835094fc75f7bb7)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/chrisdaley/software/llvm-flang/7.0.1-git_20190106/bin
Found candidate GCC installation: /cm/extra/apps/GCC/7.3.0/GCC-4.8.5_GMP-6.1.2_MPFR-4.0.0_MPC-1.1.0/lib/gcc/x86_64-pc-linux-gnu/7.3.0
Selected GCC installation: /cm/extra/apps/GCC/7.3.0/GCC-4.8.5_GMP-6.1.2_MPFR-4.0.0_MPC-1.1.0/lib/gcc/x86_64-pc-linux-gnu/7.3.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
Found CUDA installation: /cm/extra/apps/CUDA.linux86-64/9.2.88.1_396.26, version 9.2
$ gfortran -fopenmp bug2.F90 -o bug2 && ./bug2
 sum=   3.00000000
$ flang bug2.F90 -o bug2 && ./bug2
 sum=    3.000000
$ flang -fopenmp bug2.F90 -o bug2 && ./bug2
F90-W-0547-OpenMP feature, MAP, not yet implemented in this version of the compiler. (bug2.F90: 8)
F90-W-0547-OpenMP feature, MAP, not yet implemented in this version of the compiler. (bug2.F90: 9)
  0 inform,   2 warnings,   0 severes, 0 fatal for bug2

 sum=    3.000000    

cdaley avatar Jan 17 '19 16:01 cdaley