Files
TheRock/compiler/amd-llvm/flang/test/Lower/OpenMP/declare-reduction-no-initializer-derived.f90
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

98 lines
3.0 KiB
Fortran

! RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
! Test declare reduction without initializer clause for derived types
! with default component initialization.
! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_rec__QMtypesTshape
! CHECK-SAME: : !fir.ref<!fir.type<_QMtypesTshape{center:!fir.type<_QMtypesTpoint{x:f32,y:f32}>,radius:f32}>>
! CHECK: init {
! CHECK: ^bb0(%{{.*}}: !fir.ref<!fir.type<_QMtypesTshape{{.*}}>>, %[[PRIV:.*]]: !fir.ref<!fir.type<_QMtypesTshape{{.*}}>>):
! CHECK: %[[UNDEF:.*]] = fir.undefined !fir.type<_QMtypesTshape{{.*}}>
! CHECK: fir.zero_bits !fir.type<_QMtypesTpoint{x:f32,y:f32}>
! CHECK: fir.insert_value %[[UNDEF]], {{.*}}["center"
! CHECK: arith.constant 0.000000e+00 : f32
! CHECK: fir.insert_value {{.*}}["radius"
! CHECK: fir.store {{.*}} to %[[PRIV]]
! CHECK: omp.yield(%[[PRIV]]
! CHECK: } combiner {
! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_rec__QMtypesTpoint
! CHECK-SAME: : !fir.ref<!fir.type<_QMtypesTpoint{x:f32,y:f32}>>
! CHECK: init {
! CHECK: ^bb0(%{{.*}}: !fir.ref<!fir.type<_QMtypesTpoint{{.*}}>>, %[[PRIV2:.*]]: !fir.ref<!fir.type<_QMtypesTpoint{{.*}}>>):
! CHECK: fir.zero_bits !fir.type<_QMtypesTpoint{x:f32,y:f32}>
! CHECK: fir.store
! CHECK: omp.yield(%[[PRIV2]]
! CHECK: } combiner {
! CHECK-LABEL: func.func @_QQmain
! CHECK: omp.wsloop {{.*}} reduction(byref @add_reduction_byref_rec__QMtypesTpoint
! CHECK: omp.wsloop {{.*}} reduction(byref @add_reduction_byref_rec__QMtypesTshape
module types
implicit none
type :: point
real :: x , y
end type point
! Nested derived type — tests recursive isSimpleReductionType
type :: shape
type(point) :: center
real :: radius = 0.0
end type shape
interface operator(+)
module procedure add_points, add_shapes
end interface
contains
pure function add_points(a, b) result(res)
type(point), intent(in) :: a, b
type(point) :: res
res%x = a%x + b%x
res%y = a%y + b%y
end function
pure function add_shapes(a, b) result(res)
type(shape), intent(in) :: a, b
type(shape) :: res
res%center = add_points(a%center, b%center)
res%radius = a%radius + b%radius
end function
end module types
program test_no_init_derived
use types
implicit none
type(point) :: p
type(shape) :: s
integer :: i
!$omp declare reduction(+: point: omp_out = omp_out + omp_in)
!$omp declare reduction(+: shape: omp_out = omp_out + omp_in)
p = point(0.0, 0.0)
s = shape(point(0.0, 0.0), 0.0)
! Test point reduction without initializer
!$omp parallel do reduction(+: p)
do i = 1, 10
p = p + point(1.0, 2.0)
end do
!$omp end parallel do
! Test nested shape reduction without initializer
!$omp parallel do reduction(+: s)
do i = 1, 10
s = s + shape(point(1.0, 2.0), 3.0)
end do
!$omp end parallel do
print *, p%x, p%y
print *, s%center%x, s%center%y, s%radius
end program