[llvm-branch-commits] [mlir] [MLIR][OpenMP] Support allocations of device shared memory (PR #150924)
Michael Kruse via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Jul 30 01:53:16 PDT 2025
================
@@ -1102,12 +1102,64 @@ struct DeferredStore {
};
} // namespace
+/// Check whether allocations for the given operation might potentially have to
+/// be done in device shared memory. That means we're compiling for a offloading
+/// target, the operation is an `omp::TargetOp` or nested inside of one and that
+/// target region represents a Generic (non-SPMD) kernel.
+///
+/// This represents a necessary but not sufficient set of conditions to use
+/// device shared memory in place of regular allocas. Depending on the variable,
+/// its uses or the associated OpenMP construct might also need to be taken into
+/// account.
+static bool
+mightAllocInDeviceSharedMemory(Operation &op,
+ const llvm::OpenMPIRBuilder &ompBuilder) {
+ if (!ompBuilder.Config.isTargetDevice())
+ return false;
+
+ auto targetOp = dyn_cast<omp::TargetOp>(op);
----------------
Meinersbur wrote:
```suggestion
auto *targetOp = dyn_cast<omp::TargetOp>(op);
```
https://github.com/llvm/llvm-project/pull/150924
More information about the llvm-branch-commits
mailing list