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
74 lines
2.2 KiB
Fortran
74 lines
2.2 KiB
Fortran
! RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s
|
|
|
|
! Test user-defined declare reduction with intrinsic types on target device.
|
|
! These should generate inline constant initialization (no runtime calls),
|
|
! so they work on GPU targets without requiring the device Fortran runtime.
|
|
|
|
! CHECK-LABEL: omp.declare_reduction @addc : complex<f32> init {
|
|
! CHECK: %[[CZERO:.*]] = fir.zero_bits complex<f32>
|
|
! CHECK: omp.yield(%[[CZERO]] : complex<f32>)
|
|
! CHECK: } combiner {
|
|
! CHECK: fir.addc
|
|
! CHECK: }
|
|
|
|
! CHECK-LABEL: omp.declare_reduction @addr : f32 init {
|
|
! CHECK: %[[FZERO:.*]] = fir.zero_bits f32
|
|
! CHECK: omp.yield(%[[FZERO]] : f32)
|
|
! CHECK: } combiner {
|
|
! CHECK: arith.addf
|
|
! CHECK: }
|
|
|
|
! CHECK-LABEL: omp.declare_reduction @addi : i32 init {
|
|
! CHECK: %[[IZERO:.*]] = fir.zero_bits i32
|
|
! CHECK: omp.yield(%[[IZERO]] : i32)
|
|
! CHECK: } combiner {
|
|
! CHECK: arith.addi
|
|
! CHECK: }
|
|
|
|
! CHECK: omp.target
|
|
! CHECK: omp.teams reduction(@addi
|
|
! CHECK: omp.wsloop reduction(@addi
|
|
|
|
! CHECK: omp.target
|
|
! CHECK: omp.teams reduction(@addr
|
|
! CHECK: omp.wsloop reduction(@addr
|
|
|
|
! CHECK: omp.target
|
|
! CHECK: omp.teams reduction(@addc
|
|
! CHECK: omp.wsloop reduction(@addc
|
|
|
|
program test_target_named_reduction
|
|
implicit none
|
|
integer :: a, i
|
|
real :: r
|
|
complex :: c
|
|
|
|
!$omp declare reduction(addi: integer: omp_out = omp_out + omp_in)
|
|
!$omp declare reduction(addr: real: omp_out = omp_out + omp_in)
|
|
!$omp declare reduction(addc: complex: omp_out = omp_out + omp_in)
|
|
|
|
a = 0
|
|
r = 0.0
|
|
c = (0.0, 0.0)
|
|
|
|
!$omp target teams distribute parallel do reduction(addi: a) map(tofrom: a)
|
|
do i = 1, 10
|
|
a = a + i
|
|
end do
|
|
!$omp end target teams distribute parallel do
|
|
|
|
!$omp target teams distribute parallel do reduction(addr: r) map(tofrom: r)
|
|
do i = 1, 10
|
|
r = r + real(i)
|
|
end do
|
|
!$omp end target teams distribute parallel do
|
|
|
|
!$omp target teams distribute parallel do reduction(addc: c) map(tofrom: c)
|
|
do i = 1, 10
|
|
c = c + cmplx(real(i), 0.0)
|
|
end do
|
|
!$omp end target teams distribute parallel do
|
|
|
|
print *, "Int:", a, " Real:", r, " Complex:", c
|
|
end program
|