FLANG
CUFCommon.h
1//===-- CUFCommon.h -------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef FORTRAN_OPTIMIZER_TRANSFORMS_CUFCOMMON_H_
10#define FORTRAN_OPTIMIZER_TRANSFORMS_CUFCOMMON_H_
11
12#include "flang/Optimizer/Dialect/FIROps.h"
13#include "mlir/Dialect/GPU/IR/GPUDialect.h"
14#include "mlir/IR/BuiltinOps.h"
15
16static constexpr llvm::StringRef cudaDeviceModuleName = "cuda_device_mod";
17static constexpr llvm::StringRef cudaSharedMemSuffix = "__shared_mem";
18
19namespace fir {
20class FirOpBuilder;
21class KindMapping;
22} // namespace fir
23
24namespace cuf {
25
27mlir::gpu::GPUModuleOp getOrCreateGPUModule(mlir::ModuleOp mod,
28 mlir::SymbolTable &symTab);
29
30bool isCUDADeviceContext(mlir::Operation *op);
31bool isCUDADeviceContext(mlir::Region &,
32 bool isDoConcurrentOffloadEnabled = false);
33bool isRegisteredDeviceGlobal(fir::GlobalOp op);
34bool isRegisteredDeviceAttr(std::optional<cuf::DataAttribute> attr);
35
36void genPointerSync(const mlir::Value box, fir::FirOpBuilder &builder);
37
38int computeElementByteSize(mlir::Location loc, mlir::Type type,
39 fir::KindMapping &kindMap,
40 bool emitErrorOnFailure = true);
41
42mlir::Value computeElementCount(mlir::PatternRewriter &rewriter,
43 mlir::Location loc, mlir::Value shapeOperand,
44 mlir::Type seqType, mlir::Type targetType);
45
46} // namespace cuf
47
48#endif // FORTRAN_OPTIMIZER_TRANSFORMS_CUFCOMMON_H_
Definition FIRBuilder.h:55
Definition KindMapping.h:48
Definition ConvertVariable.h:26
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:19
Definition AbstractConverter.h:34