Skip to content

[Issue]: Issues with Rocm/flang using 'reduction' with an array #93

@Yan-44

Description

@Yan-44

Problem Description

Hi,
I am new on Rocm/flang github and I hope this is the correct place to post Rocm/flang issues. The simple code below reproduces issues that I experience with a very large Fortran code that I have developed when attempting to offload it:

  1. Compilation (/opt/rocm-6.1.0/llvm/bin/flang -O2 -fopenmp test31b_reduction.f90 --offload-arch=gfx1030 -o test31b) yields the following error message:

    F90-F-0000-Internal compiler error. gen_sptr(): unexpected storage type 6 (test31b_reduction.f90: 23)

  2. However, multi-threaded compilation (/opt/rocm-6.1.0/llvm/bin/flang -O2 -fopenmp test31b_reduction.f90 -o test31b) and execution work fine:

    toto(1) = 1000., correct answer is: toto(1) = 1000
    tata = 5.000000000000284 , correct answer is: tata = 5.000000000000284

  3. Furthermore, upon commenting any occurrence of 'reduction(max: tata)', compilation (/opt/rocm-6.1.0/llvm/bin/flang -O2 -fopenmp test31b_reduction.f90 --offload-arch=gfx1030 -o test31b) works fine but execution yields the following error:

    0: ALLOCATE: array already allocated
    
  4. Last, as expected, when commenting any occurrence of 'reduction', compilation (/opt/rocm-6.1.0/llvm/bin/flang -O2 -fopenmp test31b_reduction.f90 --offload-arch=gfx1030 -o test31b) works fine but execution yields erroneous results:

    toto(1) = 18., correct answer is: toto(1) = 1000
    tata = 6.3291139240506278E-002 , correct answer is: tata = 5.000000000000284

Could anyone help me fix issue 1?

Thanks for your help.

  Program test31b_reduction
  implicit none

  integer, parameter :: N=1000
  integer :: i
  double precision,dimension(:),allocatable :: toto
  double precision :: tata

  allocate(toto(2))
  toto=0._8
  tata=0._8  

  !$OMP TARGET map(toto,tata)
  !$OMP TEAMS reduction(+: toto) reduction(max: tata)
  !$OMP DISTRIBUTE PARALLEL DO reduction(+: toto) reduction(max: tata)
  do i = 1, N
     toto(1)=toto(1)+1._8
     if (tata<abs(1._8/(128.2_8-real(i,8)))) tata=abs(1._8/(128.2_8-real(i,8)))
  end do
  !$OMP END DISTRIBUTE PARALLEL DO
  !$OMP END TEAMS
  !$OMP END TARGET
  
  print*,'toto(1) = ',toto(1),', correct answer is: toto(1) = ',N
  print*,'tata = ',tata, ', correct answer is: tata = ',abs(1._8/(128.2_8-real(128,8)))
  deallocate(toto)

  end program test31b_reduction

Operating System

Ubuntu 20.04.6 LTS (Focal Fossa)

CPU

Intel(R) Xeon(R) Gold 5218 CPU @ 2.30GHz

GPU

AMD Radeon PRO W6800 (amdgcn-amd-amdhsa--gfx1030)

ROCm Version

ROCm 6.1.0

ROCm Component

No response

Steps to Reproduce

No response

(Optional for Linux users) Output of /opt/rocm/bin/rocminfo --support

No response

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions