Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Lower / OpenACC / acc-update.f90
blob1b3aef2dc674b29c5c32f549a9db006e0b30d73c
1 ! This test checks lowering of OpenACC update directive.
3 ! RUN: bbc -fopenacc -emit-fir %s -o - | FileCheck %s
5 subroutine acc_update
6 integer :: async = 1
7 real, dimension(10, 10) :: a, b, c
8 logical :: ifCondition = .TRUE.
10 !CHECK: [[A:%.*]] = fir.alloca !fir.array<10x10xf32> {{{.*}}uniq_name = "{{.*}}Ea"}
11 !CHECK: [[B:%.*]] = fir.alloca !fir.array<10x10xf32> {{{.*}}uniq_name = "{{.*}}Eb"}
12 !CHECK: [[C:%.*]] = fir.alloca !fir.array<10x10xf32> {{{.*}}uniq_name = "{{.*}}Ec"}
14 !$acc update host(a)
15 !CHECK: acc.update host([[A]] : !fir.ref<!fir.array<10x10xf32>>){{$}}
17 !$acc update host(a) if(.true.)
18 !CHECK: [[IF1:%.*]] = arith.constant true
19 !CHECK: acc.update if([[IF1]]) host([[A]] : !fir.ref<!fir.array<10x10xf32>>){{$}}
21 !$acc update host(a) if(ifCondition)
22 !CHECK: [[IFCOND:%.*]] = fir.load %{{.*}} : !fir.ref<!fir.logical<4>>
23 !CHECK: [[IF2:%.*]] = fir.convert [[IFCOND]] : (!fir.logical<4>) -> i1
24 !CHECK: acc.update if([[IF2]]) host([[A]] : !fir.ref<!fir.array<10x10xf32>>){{$}}
26 !$acc update host(a) host(b) host(c)
27 !CHECK: acc.update host([[A]], [[B]], [[C]] : !fir.ref<!fir.array<10x10xf32>>, !fir.ref<!fir.array<10x10xf32>>, !fir.ref<!fir.array<10x10xf32>>){{$}}
29 !$acc update host(a) host(b) device(c)
30 !CHECK: acc.update host([[A]], [[B]] : !fir.ref<!fir.array<10x10xf32>>, !fir.ref<!fir.array<10x10xf32>>) device([[C]] : !fir.ref<!fir.array<10x10xf32>>){{$}}
32 !$acc update host(a) async
33 !CHECK: acc.update host([[A]] : !fir.ref<!fir.array<10x10xf32>>) attributes {async}
35 !$acc update host(a) wait
36 !CHECK: acc.update host([[A]] : !fir.ref<!fir.array<10x10xf32>>) attributes {wait}
38 !$acc update host(a) async wait
39 !CHECK: acc.update host([[A]] : !fir.ref<!fir.array<10x10xf32>>) attributes {async, wait}
41 !$acc update host(a) async(1)
42 !CHECK: [[ASYNC1:%.*]] = arith.constant 1 : i32
43 !CHECK: acc.update async([[ASYNC1]] : i32) host([[A]] : !fir.ref<!fir.array<10x10xf32>>)
45 !$acc update host(a) async(async)
46 !CHECK: [[ASYNC2:%.*]] = fir.load %{{.*}} : !fir.ref<i32>
47 !CHECK: acc.update async([[ASYNC2]] : i32) host([[A]] : !fir.ref<!fir.array<10x10xf32>>)
49 !$acc update host(a) wait(1)
50 !CHECK: [[WAIT1:%.*]] = arith.constant 1 : i32
51 !CHECK: acc.update wait([[WAIT1]] : i32) host([[A]] : !fir.ref<!fir.array<10x10xf32>>)
53 !$acc update host(a) wait(queues: 1, 2)
54 !CHECK: [[WAIT2:%.*]] = arith.constant 1 : i32
55 !CHECK: [[WAIT3:%.*]] = arith.constant 2 : i32
56 !CHECK: acc.update wait([[WAIT2]], [[WAIT3]] : i32, i32) host([[A]] : !fir.ref<!fir.array<10x10xf32>>)
58 !$acc update host(a) wait(devnum: 1: queues: 1, 2)
59 !CHECK: [[WAIT4:%.*]] = arith.constant 1 : i32
60 !CHECK: [[WAIT5:%.*]] = arith.constant 2 : i32
61 !CHECK: [[WAIT6:%.*]] = arith.constant 1 : i32
62 !CHECK: acc.update wait_devnum([[WAIT6]] : i32) wait([[WAIT4]], [[WAIT5]] : i32, i32) host([[A]] : !fir.ref<!fir.array<10x10xf32>>)
64 !$acc update host(a) device_type(1, 2)
65 !CHECK: [[DEVTYPE1:%.*]] = arith.constant 1 : i32
66 !CHECK: [[DEVTYPE2:%.*]] = arith.constant 2 : i32
67 !CHECK: acc.update device_type([[DEVTYPE1]], [[DEVTYPE2]] : i32, i32) host([[A]] : !fir.ref<!fir.array<10x10xf32>>){{$}}
69 !$acc update host(a) device_type(*)
70 !CHECK: [[DEVTYPE3:%.*]] = arith.constant -1 : index
71 !CHECK: acc.update device_type([[DEVTYPE3]] : index) host([[A]] : !fir.ref<!fir.array<10x10xf32>>){{$}}
72 end subroutine acc_update