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 when the variables used in an update-statement in atomic construct are declared with different types #91929

Closed
ohno-fj opened this issue May 13, 2024 · 1 comment · Fixed by #92165

Comments

@ohno-fj
Copy link

ohno-fj commented May 13, 2024

Version of flang-new : 19.0.0(1a498103ee5c4d101e70dc49db11938d8b87b518)/AArch64

When the variables (x and expr) used in an update-statement in atomic construct are declared with different types, a compilation terminates abnormally.
When both variables are declared of the same type, a compilation terminates normally.

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

OMP_3_O_007_4_atm_expr_027_up_323.f90:

program main
  integer(kind=4) :: s_x, i
! integer(kind=4) :: s_expr
  real(kind=4)    :: s_expr
  s_x    = 3
  s_expr = 3.0
!$omp atomic ! update
  s_x = s_x + s_expr
!$omp end atomic
  write(6,*) 's_x = ', s_x, ', s_expr = ', s_expr
end program main
$ flang-new -fopenmp -L${LLVM_DIR}/lib OMP_3_O_007_4_atm_expr_027_up_323.f90; ./a.out
error: loc("/work/home/ohno/CT/test/fort/tp/reproducerJ/fomp_omp40/OMP_3_O_007_4_atm_expr_027_up_323.f90":6:3): no atomic update operation with region argument as operand found inside atomic.update region
error: loc("/work/home/ohno/CT/test/fort/tp/reproducerJ/fomp_omp40/OMP_3_O_007_4_atm_expr_027_up_323.f90":6:3): LLVM Translation failed for operation: omp.atomic.update
error: failed to create the LLVM module
$
$ export OMP_NUM_THREADS=2; gfortran -fopenmp OMP_3_O_007_4_atm_expr_027_up_323.f90; ./a.out
 s_x =            6 , s_expr =    3.00000000
$
$ export OMP_NUM_THREADS=2; ifort -qopenmp OMP_3_O_007_4_atm_expr_027_up_323.f90; ./a.out
 s_x =            6 , s_expr =    3.000000
$
@ohno-fj ohno-fj added openmp flang Flang issues not falling into any other category labels May 13, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented May 13, 2024

@llvm/issue-subscribers-openmp

Author: None (ohno-fj)

``` Version of flang-new : 19.0.0(1a49810)/AArch64 ```

When the variables (x and expr) used in an update-statement in atomic construct are declared with different types, a compilation terminates abnormally.
When both variables are declared of the same type, a compilation terminates normally.

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

OMP_3_O_007_4_atm_expr_027_up_323.f90:

program main
  integer(kind=4) :: s_x, i
! integer(kind=4) :: s_expr
  real(kind=4)    :: s_expr
  s_x    = 3
  s_expr = 3.0
!$omp atomic ! update
  s_x = s_x + s_expr
!$omp end atomic
  write(6,*) 's_x = ', s_x, ', s_expr = ', s_expr
end program main
$ flang-new -fopenmp -L${LLVM_DIR}/lib OMP_3_O_007_4_atm_expr_027_up_323.f90; ./a.out
error: loc("/work/home/ohno/CT/test/fort/tp/reproducerJ/fomp_omp40/OMP_3_O_007_4_atm_expr_027_up_323.f90":6:3): no atomic update operation with region argument as operand found inside atomic.update region
error: loc("/work/home/ohno/CT/test/fort/tp/reproducerJ/fomp_omp40/OMP_3_O_007_4_atm_expr_027_up_323.f90":6:3): LLVM Translation failed for operation: omp.atomic.update
error: failed to create the LLVM module
$
$ export OMP_NUM_THREADS=2; gfortran -fopenmp OMP_3_O_007_4_atm_expr_027_up_323.f90; ./a.out
 s_x =            6 , s_expr =    3.00000000
$
$ export OMP_NUM_THREADS=2; ifort -qopenmp OMP_3_O_007_4_atm_expr_027_up_323.f90; ./a.out
 s_x =            6 , s_expr =    3.000000
$

kiranchandramohan added a commit to kiranchandramohan/llvm-project that referenced this issue May 14, 2024
If there is only one non-terminator operation in the update region
then the update operation can be found and we can try to generate
an atomicrmw instruction. Otherwise use the cmpxchg loop.

Fixes llvm#91929
kiranchandramohan added a commit that referenced this issue May 16, 2024
If there is only one non-terminator operation in the update region then
the update operation can be found and we can try to generate an
atomicrmw instruction. Otherwise use the cmpxchg loop.

Fixes #91929
@EugeneZelenko EugeneZelenko added mlir:openmp and removed openmp flang Flang issues not falling into any other category labels May 16, 2024
mub-at-arm pushed a commit to mub-at-arm/llvm-project that referenced this issue May 16, 2024
If there is only one non-terminator operation in the update region then
the update operation can be found and we can try to generate an
atomicrmw instruction. Otherwise use the cmpxchg loop.

Fixes llvm#91929
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.

3 participants