Skip to content

[flang][cuda] Allow compiler directive in cuda code #141991

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

Merged
merged 1 commit into from
May 29, 2025

Conversation

clementval
Copy link
Contributor

No description provided.

@clementval clementval requested a review from wangzpgi May 29, 2025 17:21
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:semantics labels May 29, 2025
@llvmbot
Copy link
Member

llvmbot commented May 29, 2025

@llvm/pr-subscribers-flang-semantics

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

Changes

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

2 Files Affected:

  • (modified) flang/lib/Semantics/check-cuda.cpp (+3)
  • (modified) flang/test/Semantics/cuf09.cuf (+11)
diff --git a/flang/lib/Semantics/check-cuda.cpp b/flang/lib/Semantics/check-cuda.cpp
index fd1ec2b2c69f8..c024640af1220 100644
--- a/flang/lib/Semantics/check-cuda.cpp
+++ b/flang/lib/Semantics/check-cuda.cpp
@@ -321,6 +321,9 @@ template <bool IsCUFKernelDo> class DeviceContextChecker {
                 Check(std::get<parser::Block>(c.t));
               }
             },
+            [&](const common::Indirection<parser::CompilerDirective> &x) {
+              // TODO(CUDA): Check for unsupported compiler directive here.
+            },
             [&](const auto &x) {
               if (auto source{parser::GetSource(x)}) {
                 context_.Say(*source,
diff --git a/flang/test/Semantics/cuf09.cuf b/flang/test/Semantics/cuf09.cuf
index 4a6d9ab09387d..1e23819f9afe8 100644
--- a/flang/test/Semantics/cuf09.cuf
+++ b/flang/test/Semantics/cuf09.cuf
@@ -18,6 +18,17 @@ module m
     !WARNING: I/O statement might not be supported on device
     write(12,'(10F4.1)'), x
   end
+  attributes(global) subroutine devsub3(n)
+    implicit none
+    integer :: n
+    integer :: i, ig, iGrid
+    iGrid = gridDim%x*blockDim%x
+    ig = (blockIdx%x-1)*blockDim%x + threadIdx%x
+ 
+    !dir$ nounroll
+    do i = ig, n, iGrid
+    end do
+  end subroutine
   attributes(global) subroutine hostglobal(a)
     integer :: a(*)
     i = threadIdx%x

@clementval clementval requested a review from klausler May 29, 2025 17:41
@clementval clementval merged commit ef11bdc into llvm:main May 29, 2025
10 of 12 checks passed
@clementval clementval deleted the cuf_directive branch May 29, 2025 17:46
google-yfyang pushed a commit to google-yfyang/llvm-project that referenced this pull request May 29, 2025
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Jun 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:semantics flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants