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 hlfir {
31class ElementalOp;
32} // namespace hlfir
33
34namespace Fortran::lower {
35
37
38static inline unsigned getAllocatorIdx(const Fortran::semantics::Symbol &sym) {
39 std::optional<Fortran::common::CUDADataAttr> cudaAttr =
40 Fortran::semantics::GetCUDADataAttr(&sym.GetUltimate());
41 if (cudaAttr) {
42 if (*cudaAttr == Fortran::common::CUDADataAttr::Pinned)
43 return kPinnedAllocatorPos;
44 if (*cudaAttr == Fortran::common::CUDADataAttr::Device)
45 return kDeviceAllocatorPos;
46 if (*cudaAttr == Fortran::common::CUDADataAttr::Managed)
47 return kManagedAllocatorPos;
48 if (*cudaAttr == Fortran::common::CUDADataAttr::Unified)
49 return kUnifiedAllocatorPos;
50 }
51 return kDefaultAllocator;
52}
53
54mlir::Type gatherDeviceComponentCoordinatesAndType(
55 fir::FirOpBuilder &builder, mlir::Location loc,
56 const Fortran::semantics::Symbol &sym, fir::RecordType recTy,
57 llvm::SmallVector<mlir::Value> &coordinates);
58
61cuf::DataAttributeAttr
62translateSymbolCUFDataAttribute(mlir::MLIRContext *mlirContext,
63 const Fortran::semantics::Symbol &sym);
64
67hlfir::ElementalOp isTransferWithConversion(mlir::Value rhs);
68
69} // end namespace Fortran::lower
70
71#endif // FORTRAN_LOWER_CUDA_H
Definition AbstractConverter.h:85
Definition ParserActions.h:24
hlfir::ElementalOp isTransferWithConversion(mlir::Value rhs)
Definition CUDA.cpp:71
cuf::DataAttributeAttr translateSymbolCUFDataAttribute(mlir::MLIRContext *mlirContext, const Fortran::semantics::Symbol &sym)
Definition CUDA.cpp:64
Definition AbstractConverter.h:29