Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flang][cuda][NFC] Add test for attributes on procedure #83044

Merged
merged 1 commit into from
Feb 27, 2024

Conversation

clementval
Copy link
Contributor

Similar to #82844. Test that CUDA attributes on procedure are correctly imported.

@llvmbot llvmbot added flang Flang issues not falling into any other category flang:fir-hlfir labels Feb 26, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Feb 26, 2024

@llvm/pr-subscribers-flang-fir-hlfir

Author: Valentin Clement (バレンタイン クレメン) (clementval)

Changes

Similar to #82844. Test that CUDA attributes on procedure are correctly imported.


Full diff: https://github.com/llvm/llvm-project/pull/83044.diff

2 Files Affected:

  • (modified) flang/test/Lower/CUDA/cuda-mod.cuf (+6)
  • (modified) flang/test/Lower/CUDA/cuda-module-use.cuf (+12-2)
diff --git a/flang/test/Lower/CUDA/cuda-mod.cuf b/flang/test/Lower/CUDA/cuda-mod.cuf
index 2cc6439789a279..ae5bf63d2da49b 100644
--- a/flang/test/Lower/CUDA/cuda-mod.cuf
+++ b/flang/test/Lower/CUDA/cuda-mod.cuf
@@ -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>}
diff --git a/flang/test/Lower/CUDA/cuda-module-use.cuf b/flang/test/Lower/CUDA/cuda-module-use.cuf
index 43ab0f6ff8d68e..f54083b026ee88 100644
--- a/flang/test/Lower/CUDA/cuda-module-use.cuf
+++ b/flang/test/Lower/CUDA/cuda-module-use.cuf
@@ -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
@@ -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>}

Copy link
Contributor

@wangzpgi wangzpgi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. Thanks for adding this test.

@clementval clementval merged commit c1c2c92 into llvm:main Feb 27, 2024
6 of 7 checks passed
@clementval clementval deleted the cuda_attr_module_function_test branch February 27, 2024 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:fir-hlfir flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants