FLANG
CUDA.h
1//===-- Lower/CUDA.h -- CUDA Fortran utilities ------------------*- C++ -*-===//
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// Coding style: https://mlir.llvm.org/getting_started/DeveloperGuide/
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef FORTRAN_LOWER_CUDA_H
14#define FORTRAN_LOWER_CUDA_H
15
16#include "flang/Optimizer/Builder/FIRBuilder.h"
17#include "flang/Optimizer/Builder/MutableBox.h"
18#include "flang/Optimizer/Dialect/CUF/CUFOps.h"
19#include "flang/Runtime/allocator-registry-consts.h"
20#include "flang/Semantics/tools.h"
21#include "mlir/Dialect/Func/IR/FuncOps.h"
22#include "mlir/Dialect/OpenACC/OpenACC.h"
23
24namespace mlir {
25class Value;
26class Location;
27class MLIRContext;
28} // namespace mlir
29
30namespace Fortran::lower {
31
33
34static inline unsigned getAllocatorIdx(const Fortran::semantics::Symbol &sym) {
35 std::optional<Fortran::common::CUDADataAttr> cudaAttr =
36 Fortran::semantics::GetCUDADataAttr(&sym.GetUltimate());
37 if (cudaAttr) {
38 if (*cudaAttr == Fortran::common::CUDADataAttr::Pinned)
39 return kPinnedAllocatorPos;
40 if (*cudaAttr == Fortran::common::CUDADataAttr::Device)
41 return kDeviceAllocatorPos;
42 if (*cudaAttr == Fortran::common::CUDADataAttr::Managed)
43 return kManagedAllocatorPos;
44 if (*cudaAttr == Fortran::common::CUDADataAttr::Unified)
45 return kUnifiedAllocatorPos;
46 }
47 return kDefaultAllocator;
48}
49
50mlir::Type gatherDeviceComponentCoordinatesAndType(
51 fir::FirOpBuilder &builder, mlir::Location loc,
52 const Fortran::semantics::Symbol &sym, fir::RecordType recTy,
53 llvm::SmallVector<mlir::Value> &coordinates);
54
57cuf::DataAttributeAttr
58translateSymbolCUFDataAttribute(mlir::MLIRContext *mlirContext,
59 const Fortran::semantics::Symbol &sym);
60
61bool isTransferWithConversion(mlir::Value rhs);
62
63} // end namespace Fortran::lower
64
65#endif // FORTRAN_LOWER_CUDA_H
Definition AbstractConverter.h:85
Definition ParserActions.h:24
cuf::DataAttributeAttr translateSymbolCUFDataAttribute(mlir::MLIRContext *mlirContext, const Fortran::semantics::Symbol &sym)
Definition CUDA.cpp:64
Definition AbstractConverter.h:29