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
54 lines
1.4 KiB
Fortran
54 lines
1.4 KiB
Fortran
! Offloading test checking lowering of arrays with dynamic extents.
|
|
! REQUIRES: flang, amdgpu
|
|
|
|
! RUN: %libomptarget-compile-fortran-run-and-check-generic
|
|
|
|
program test_openmp_mapper
|
|
implicit none
|
|
integer, parameter :: n = 1024
|
|
type :: mytype
|
|
integer :: data(n)
|
|
end type mytype
|
|
|
|
type :: mytype2
|
|
type(mytype) :: my_data
|
|
end type mytype2
|
|
|
|
! Declare custom mappers for the derived type `mytype`
|
|
!$omp declare mapper(my_mapper1 : mytype :: t) map(to: t%data(1 : n))
|
|
|
|
! Declare custom mappers for the derived type `mytype2`
|
|
!$omp declare mapper(my_mapper2 : mytype2 :: t) map(mapper(my_mapper1): t%my_data)
|
|
|
|
type(mytype2) :: obj
|
|
integer :: i, sum_host, sum_device
|
|
|
|
! Initialize the host data
|
|
do i = 1, n
|
|
obj%my_data%data(i) = 1
|
|
end do
|
|
|
|
! Compute the sum on the host for verification
|
|
sum_host = sum(obj%my_data%data)
|
|
|
|
! Offload computation to the device using the named mapper `my_mapper2`
|
|
sum_device = 0
|
|
!$omp target map(tofrom: sum_device) map(mapper(my_mapper2) : obj)
|
|
do i = 1, n
|
|
sum_device = sum_device + obj%my_data%data(i)
|
|
end do
|
|
!$omp end target
|
|
|
|
! Check results
|
|
print *, "Sum on host: ", sum_host
|
|
print *, "Sum on device: ", sum_device
|
|
|
|
if (sum_device == sum_host) then
|
|
print *, "Test passed!"
|
|
else
|
|
print *, "Test failed!"
|
|
end if
|
|
end program test_openmp_mapper
|
|
|
|
! CHECK: Test passed!
|