[flang-commits] [flang] [flang][cuda] Allow compiler directive in cuda code (PR #141991)
Valentin Clement バレンタイン クレメン via flang-commits
flang-commits at lists.llvm.org
Thu May 29 10:21:37 PDT 2025
https://github.com/clementval created https://github.com/llvm/llvm-project/pull/141991
None
>From 6433cf5650c06739e382f789ab735c8bfdae1d62 Mon Sep 17 00:00:00 2001
From: Valentin Clement <clementval at gmail.com>
Date: Thu, 29 May 2025 10:20:53 -0700
Subject: [PATCH] [flang][cuda] Allow compiler directive in cuda code
---
flang/lib/Semantics/check-cuda.cpp | 3 +++
flang/test/Semantics/cuf09.cuf | 11 +++++++++++
2 files changed, 14 insertions(+)
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
More information about the flang-commits
mailing list