Valentin Clement 39157b98fd
[flang][OpenACC] Lower init/shutdown directive
This patch adds lowering for the `!$acc init` and `!$acc shutdown`
from the PFT to OpenACC dialect.

This patch is part of the upstreaming effort from fir-dev branch.

Depends on D122384

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D122387
2022-03-24 15:18:09 +01:00

30 lines
954 B
Fortran

! This test checks lowering of OpenACC init directive.
! RUN: bbc -fopenacc -emit-fir %s -o - | FileCheck %s
subroutine acc_init
logical :: ifCondition = .TRUE.
!$acc init
!CHECK: acc.init{{$}}
!$acc init if(.true.)
!CHECK: [[IF1:%.*]] = arith.constant true
!CHECK: acc.init if([[IF1]]){{$}}
!$acc init if(ifCondition)
!CHECK: [[IFCOND:%.*]] = fir.load %{{.*}} : !fir.ref<!fir.logical<4>>
!CHECK: [[IF2:%.*]] = fir.convert [[IFCOND]] : (!fir.logical<4>) -> i1
!CHECK: acc.init if([[IF2]]){{$}}
!$acc init device_num(1)
!CHECK: [[DEVNUM:%.*]] = arith.constant 1 : i32
!CHECK: acc.init device_num([[DEVNUM]] : i32){{$}}
!$acc init device_num(1) device_type(1, 2)
!CHECK: [[DEVNUM:%.*]] = arith.constant 1 : i32
!CHECK: [[DEVTYPE1:%.*]] = arith.constant 1 : i32
!CHECK: [[DEVTYPE2:%.*]] = arith.constant 2 : i32
!CHECK: acc.init device_type([[DEVTYPE1]], [[DEVTYPE2]] : i32, i32) device_num([[DEVNUM]] : i32){{$}}
end subroutine acc_init