Skip to content

Commit

Permalink
[flang][cuda][NFC] Add test for attributes on procedure (#83044)
Browse files Browse the repository at this point in the history
Similar to #82844. Test that CUDA attributes on procedure are correctly
imported.
  • Loading branch information
clementval committed Feb 27, 2024
1 parent a6b4e29 commit c1c2c92
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 6 additions & 0 deletions flang/test/Lower/CUDA/cuda-mod.cuf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

module cuf_mod
real, device :: md

contains
attributes(device) subroutine devsub()
end
end module

! CHECK: fir.global @_QMcuf_modEmd {cuda_attr = #fir.cuda<device>} : f32

! CHECK: func.func @_QMcuf_modPdevsub() attributes {fir.cuda_attr = #fir.cuda_proc<device>}
14 changes: 12 additions & 2 deletions flang/test/Lower/CUDA/cuda-module-use.cuf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
! RUN: bbc -emit-hlfir -fcuda %S/cuda-mod.cuf
! RUN: bbc -emit-hlfir -fcuda %s -o - | FileCheck %s

! Test importing module with variable with CUDA attributes.
! Test importing module containing variable and subroutine with CUDA attributes.

subroutine sub1()
use cuf_mod
Expand All @@ -12,4 +12,14 @@ end
! CHECK: %[[ADDR:.*]] = fir.address_of(@_QMcuf_modEmd) : !fir.ref<f32>
! CHECK: %{{.*}}:2 = hlfir.declare %[[ADDR]] {cuda_attr = #fir.cuda<device>, uniq_name = "_QMcuf_modEmd"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)

! CHECK: fir.global @_QMcuf_modEmd {cuda_attr = #fir.cuda<device>} : f32
attributes(device) subroutine sub2()
use cuf_mod
call devsub()
end

! CHECK-LABEL: func.func @_QPsub2() attributes {fir.cuda_attr = #fir.cuda_proc<device>}
! CHECK: fir.call @_QMcuf_modPdevsub()

! CHECK-LABEL: fir.global @_QMcuf_modEmd {cuda_attr = #fir.cuda<device>} : f32

! CHECK-LABEL: func.func private @_QMcuf_modPdevsub() attributes {fir.cuda_attr = #fir.cuda_proc<device>}

0 comments on commit c1c2c92

Please sign in to comment.