Files
TheRock/compiler/amd-llvm/flang/test/Lower/OpenMP/declare-reduction-no-initializer-target-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

57 lines
1.8 KiB
Fortran

! RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
! Test declare reduction without initializer clause for derived type with
! default component values, used in a target offload region.
! The init region must initialize components using the type's default values.
! CHECK-LABEL: omp.declare_reduction @add_pts
! CHECK-SAME: : !fir.ref<!fir.type<_QFTpoint{x:f32,y:f32}>>
! CHECK: init {
! CHECK: ^bb0(%{{.*}}: !fir.ref<!fir.type<_QFTpoint{{.*}}>>,
! CHECK-SAME: %[[PRIV:.*]]: !fir.ref<!fir.type<_QFTpoint{{.*}}>>):
! CHECK-NOT: fir.call @_FortranAInitialize
! CHECK: %[[UNDEF:.*]] = fir.undefined !fir.type<_QFTpoint{{.*}}>
! CHECK: fir.zero_bits f32
! CHECK: fir.insert_value %[[UNDEF]], {{.*}}["x"
! CHECK: arith.constant 0.000000e+00 : f32
! CHECK: fir.insert_value {{.*}}["y"
! CHECK: fir.store {{.*}} to %[[PRIV]]
! CHECK: omp.yield(%[[PRIV]]
! CHECK: } combiner {
program main
implicit none
type :: Point
real :: x
real :: y = 0.0
end type Point
integer :: i
type(Point) :: total
!$omp declare reduction(add_pts : Point : &
!$omp& merge_points(omp_out, omp_in))
total = Point(0.0, 0.0)
!$omp target teams distribute parallel do reduction(add_pts: total) map(tofrom: total)
do i = 1, 100
total%x = total%x + 1.0
total%y = total%y + 2.0
end do
!$omp end target teams distribute parallel do
print *, "Final Point X:", total%x
print *, "Final Point Y:", total%y
contains
subroutine merge_points(out_p, in_p)
!$omp declare target
type(Point), intent(inout) :: out_p
type(Point), intent(in) :: in_p
out_p%x = out_p%x + in_p%x
out_p%y = out_p%y + in_p%y
end subroutine
end program main