9#ifndef FORTRAN_OPTIMIZER_TRANSFORMS_CUFCOMMON_H_
10#define FORTRAN_OPTIMIZER_TRANSFORMS_CUFCOMMON_H_
12#include "flang/Optimizer/Dialect/FIROps.h"
13#include "mlir/Dialect/Func/IR/FuncOps.h"
14#include "mlir/Dialect/GPU/IR/GPUDialect.h"
15#include "mlir/IR/BuiltinOps.h"
16#include "llvm/ADT/DenseMap.h"
17#include "llvm/ADT/SetVector.h"
19static constexpr llvm::StringRef cudaDeviceModuleName =
"cuda_device_mod";
20static constexpr llvm::StringRef cudaSharedMemSuffix =
"__shared_mem__";
24static constexpr llvm::StringRef cudaDeviceCopySuffix =
".device";
35 mlir::SymbolTable &symTab);
37bool isCUDADeviceContext(mlir::Operation *op);
38bool isCUDADeviceContext(mlir::Region &,
39 bool isDoConcurrentOffloadEnabled =
false);
47bool isRegisteredDeviceGlobal(fir::GlobalOp op);
48bool isRegisteredDeviceAttr(std::optional<cuf::DataAttribute> attr);
74 bool rejectDynamicDispatch =
false);
79 mlir::Operation *root,
80 const llvm::DenseMap<mlir::StringAttr, mlir::FlatSymbolRefAttr> &map);
89int computeElementByteSize(mlir::Location loc, mlir::Type type,
91 bool emitErrorOnFailure =
true);
93mlir::Value computeElementCount(mlir::PatternRewriter &rewriter,
94 mlir::Location loc, mlir::Value shapeOperand,
95 mlir::Type seqType, mlir::Type targetType);
Definition FIRBuilder.h:66
Definition KindMapping.h:48
Definition ConvertVariable.h:28
bool isDeviceProcedure(mlir::func::FuncOp funcOp)
Definition CUFCommon.cpp:190
bool isExecutingOnDevice(mlir::Operation *op)
Definition CUFCommon.cpp:74
void remapProcedureSymbols(mlir::Operation *root, const llvm::DenseMap< mlir::StringAttr, mlir::FlatSymbolRefAttr > &map)
Definition CUFCommon.cpp:278
void setDeviceAllocationPolicy(mlir::Operation *func)
Definition CUFCommon.cpp:298
DeviceCodeSet collectDeviceCode(mlir::ModuleOp mod, mlir::SymbolTable &symTab, bool rejectDynamicDispatch=false)
Definition CUFCommon.cpp:210
mlir::gpu::GPUModuleOp getOrCreateGPUModule(mlir::ModuleOp mod, mlir::SymbolTable &symTab)
Retrieve or create the CUDA Fortran GPU module in the given mod.
Definition CUFCommon.cpp:24
Definition AbstractConverter.h:37
The device code of a module, as gathered by collectDeviceCode.
Definition CUFCommon.h:56
llvm::SetVector< mlir::func::FuncOp > deviceFuncs
Procedures with a device proc attribute (see isDeviceProcedure).
Definition CUFCommon.h:58
llvm::SetVector< mlir::func::FuncOp > calledFromDevice
Definition CUFCommon.h:63
llvm::SetVector< mlir::func::FuncOp > keepInModule
Definition CUFCommon.h:66