summaryrefslogtreecommitdiff
path: root/offload/test/offloading/fortran/dtype-array-constant-index-map.f90
blob: e120c95019c602ab1daa12a0e4e6f13f6e1b4488 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
! Offloading test which maps a specific element of a derived type to the device
! and then accesses the element alongside an individual element of an array
! that the derived type contains. In particular, this test helps to check that
! we can replace the constants within the kernel with instructions and then
! replace these instructions with the kernel parameters.
! REQUIRES: flang, amdgpu

! RUN: %libomptarget-compile-fortran-run-and-check-generic
module test_0
    type dtype
      integer elements(20)
      integer value
    end type dtype

    type (dtype) array_dtype(5)
  contains

  subroutine assign()
    implicit none
!$omp target map(tofrom: array_dtype(5))
    array_dtype(5)%elements(5) = 500
!$omp end target
  end subroutine

  subroutine add()
    implicit none

!$omp target map(tofrom: array_dtype(5))
    array_dtype(5)%elements(5) = array_dtype(5)%elements(5) + 500
!$omp end target
  end subroutine
end module test_0

program main
   use test_0

  call assign()
  call add()

  print *, array_dtype(5)%elements(5)
end program

! CHECK: 1000