[flang-commits] [flang] [flang][cuda] Allow compiler directive in cuda code (PR #141991)
via flang-commits
flang-commits at lists.llvm.org
Thu May 29 10:22:13 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-semantics
Author: Valentin Clement (バレンタイン クレメン) (clementval)
<details>
<summary>Changes</summary>
---
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
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
``````````
</details>
https://github.com/llvm/llvm-project/pull/141991
More information about the flang-commits
mailing list