Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Flang][OpenMP] Compilation error of combining select type construct and task construct with depend clause #132647

Open
ohno-fj opened this issue Mar 23, 2025 · 2 comments · May be fixed by #132994

Comments

@ohno-fj
Copy link

ohno-fj commented Mar 23, 2025

Version of flang : 21.0.0(3e6f618e86f5fbad2c2d5802416ec3d3366a2837)/AArch64

Combining select type construct and task construct with depend clause results in a compilation error.
Compilation ends normally in the following cases:

  • Do not specify the compilation option (-fopenmp)
  • Remove depend clause

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

sngg362t_2.f90:

program main
  type ty
     character(len=5)::i(3)
  end type ty

  type,extends(ty)::tt
     integer(kind=2),allocatable::n(:)
  end type tt
  class(ty),allocatable::obj

  allocate(tt::obj)
  obj%i = "AAAAA"

  select type (obj)
  type is (tt)
     allocate(obj%n(4))
     obj%n = 10
     associate(p2=>obj%n(1:4:2))
!$omp task depend(in:p2)
       obj%n(1:4:2) = 11
!$omp end task
       print *,'pass'
     endassociate
  class default
     print*,"912"
  end select
end program main
$ flang -fopenmp sngg362t_2.f90
flang-20: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
error: loc("/work/home/ohno/CT/test/fort/tp/reproducerJ/FFE_2022_PH19703_08/sngg362t_2.f90":19:7): 'omp.task' op operand #0 must be variadic of OpenMP-compatible variable type, but got '!fir.box<!fir.array<2xi16>>'
error: verification of lowering to FIR failed
$
$ export OMP_NUM_THREADS=2; flang sngg362t_2.f90; ./a.out
 pass
$
$ export OMP_NUM_THREADS=2; gfortran -fopenmp sngg362t_2.f90; ./a.out
 pass
$
$ export OMP_NUM_THREADS=2; ifx -qopenmp sngg362t_2.f90; ./a.out
 pass
$
@llvmbot
Copy link
Member

llvmbot commented Mar 24, 2025

@llvm/issue-subscribers-flang-ir

Author: None (ohno-fj)

``` Version of flang : 21.0.0(3e6f618)/AArch64 ```

Combining select type construct and task construct with depend clause results in a compilation error.
Compilation ends normally in the following cases:

  • Do not specify the compilation option (-fopenmp)
  • Remove depend clause

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

sngg362t_2.f90:

program main
  type ty
     character(len=5)::i(3)
  end type ty

  type,extends(ty)::tt
     integer(kind=2),allocatable::n(:)
  end type tt
  class(ty),allocatable::obj

  allocate(tt::obj)
  obj%i = "AAAAA"

  select type (obj)
  type is (tt)
     allocate(obj%n(4))
     obj%n = 10
     associate(p2=&gt;obj%n(1:4:2))
!$omp task depend(in:p2)
       obj%n(1:4:2) = 11
!$omp end task
       print *,'pass'
     endassociate
  class default
     print*,"912"
  end select
end program main
$ flang -fopenmp sngg362t_2.f90
flang-20: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
error: loc("/work/home/ohno/CT/test/fort/tp/reproducerJ/FFE_2022_PH19703_08/sngg362t_2.f90":19:7): 'omp.task' op operand #<!-- -->0 must be variadic of OpenMP-compatible variable type, but got '!fir.box&lt;!fir.array&lt;2xi16&gt;&gt;'
error: verification of lowering to FIR failed
$
$ export OMP_NUM_THREADS=2; flang sngg362t_2.f90; ./a.out
 pass
$
$ export OMP_NUM_THREADS=2; gfortran -fopenmp sngg362t_2.f90; ./a.out
 pass
$
$ export OMP_NUM_THREADS=2; ifx -qopenmp sngg362t_2.f90; ./a.out
 pass
$

@tblah tblah self-assigned this Mar 24, 2025
@tblah
Copy link
Contributor

tblah commented Mar 24, 2025

Thanks for reporting the issue. I am working on supporting array sections with task depend and will have to support task dependencies of type !fir.box<!fir.array< >> as part of that.

tblah added a commit to tblah/llvm-project that referenced this issue Mar 25, 2025
The OpenMP standard says that all dependencies in the same set of
inter-dependent tasks must be non-overlapping. This simplification means
that the OpenMP only needs to keep track of the base addresses of
dependency variables. This can be seen in kmp_taskdeps.cpp, which stores
task dependency information in a hash table, using the base address as a
key.

This patch generates a rebox operation to slice boxed arrays, but only
the box data address is used for the task dependency. The extra box is
optimized away by LLVM at O3.

Vector subscripts are TODO (I will address in my next patch).

This also fixes a bug for ordinary subscripts when the symbol was mapped
to a box:

Fixes llvm#132647
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

4 participants