Skip to content

[Flang][OpenMP] assumed-shape array of character type with allocatable attribute in task private construct in parallel private construct does not execute correctly #113106

Closed
@ohno-fj

Description

@ohno-fj
Version of flang-new : 20.0.0(77f8297c6fdaa62121ddb108043dcaad5c45c7ad)/AArch64

assumed-shape array of character type with allocatable attribute in task private construct in parallel private construct does not execute correctly.
The above program is dw2_007_tsk_231.f90.

Correct execution results are obtained in the following cases.

  • The length of the character type is a constant instead of *
    The above program is dw2_007_tsk_232.f90.
  • Remove task private construct
  • Do not specify compilation options (-fopenmp)

The following are the test program, Flang-new, Gfortran and ifx compilation/execution result.

dw2_007_tsk_231.f90:

subroutine sub01(arg01)
  character(*),allocatable :: arg01(:)
  allocate(arg01(1))
  arg01(1) = "abcde12345"
  write(6,*) "1:len(arg01) = ", len(arg01)
!  if ( 10 .ne. len(arg01)) print *,'ng1'
!$omp parallel private(arg01)
!$omp task private(arg01)
  write(6,*) "2:len(arg01) = ", len(arg01)
!  if ( 10 .ne. len(arg01)) print *,'ng2',len(arg01)
!$omp end task
!$omp end parallel
end subroutine sub01

program main
  interface
     subroutine sub01(arg01)
       character(*),allocatable :: arg01(:)
     end subroutine sub01
  end interface

  character(10),allocatable :: cha01(:)
  call sub01(cha01)
end program main
$ export OMP_NUM_THREADS=2; flang-new -fopenmp dw2_007_tsk_231.f90; ./a.out
 1:len(arg01) =  10
 2:len(arg01) =  0
 2:len(arg01) =  0
$
$ export OMP_NUM_THREADS=2; gfortran -fopenmp dw2_007_tsk_231.f90; ./a.out
 1:len(arg01) =           10
 2:len(arg01) =           10
 2:len(arg01) =           10
$
$ export OMP_NUM_THREADS=2; ifx -qopenmp dw2_007_tsk_231.f90; ./a.out
 1:len(arg01) =           10
 2:len(arg01) =           10
 2:len(arg01) =           10
$

dw2_007_tsk_232.f90:

subroutine sub01(arg01)
  character(10),allocatable :: arg01(:)
  allocate(arg01(1))
  arg01(1) = "abcde12345"
  write(6,*) "1:len(arg01) = ", len(arg01)
!  if ( 10 .ne. len(arg01)) print *,'ng1'
!$omp parallel private(arg01)
!$omp task private(arg01)
  write(6,*) "2:len(arg01) = ", len(arg01)
!  if ( 10 .ne. len(arg01)) print *,'ng2',len(arg01)
!$omp end task
!$omp end parallel
end subroutine sub01

program main
  interface
     subroutine sub01(arg01)
       character(10),allocatable :: arg01(:)
     end subroutine sub01
  end interface

  character(10),allocatable :: cha01(:)
  call sub01(cha01)
end program main
$ export OMP_NUM_THREADS=2; flang-new -fopenmp dw2_007_tsk_232.f90; ./a.out
 1:len(arg01) =  10
 2:len(arg01) =  10
 2:len(arg01) =  10
$
$ export OMP_NUM_THREADS=2; gfortran -fopenmp dw2_007_tsk_232.f90; ./a.out
 1:len(arg01) =           10
 2:len(arg01) =           10
 2:len(arg01) =           10
$
$ export OMP_NUM_THREADS=2; ifx -qopenmp dw2_007_tsk_232.f90; ./a.out
 1:len(arg01) =           10
 2:len(arg01) =           10
 2:len(arg01) =           10
$

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions