[flang-commits] [flang] [flang][cuda] Implicitly load cudadevice module in device/global subprogram (PR #91668)

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Thu May 9 16:22:42 PDT 2024


================
@@ -3797,6 +3797,17 @@ bool SubprogramVisitor::Pre(const parser::PrefixSpec::Attributes &attrs) {
         subp->set_cudaSubprogramAttrs(attr);
       }
     }
+    if (auto attrs{subp->cudaSubprogramAttrs()}) {
+      if (*attrs == common::CUDASubprogramAttrs::Global ||
+          *attrs == common::CUDASubprogramAttrs::Device) {
+        // Implicitly USE the cudadevice module by copying its symbol in the
+        // current scope.
----------------
klausler wrote:

So the semantics of these names are not really what you get from either a USE statement or from intrinsics.

There is already precedence here with names like `threadIdx` that are automatically imported into device subprogram scopes, so I guess this isn't making things any worse.

https://github.com/llvm/llvm-project/pull/91668


More information about the flang-commits mailing list