MLIR 23.0.0git
OpenACCUtilsGPU.h
Go to the documentation of this file.
1//===- OpenACCUtilsGPU.h - OpenACC GPU 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// This file defines utility functions for OpenACC that depend on the GPU
10// dialect.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef MLIR_DIALECT_OPENACC_OPENACCUTILSGPU_H_
15#define MLIR_DIALECT_OPENACC_OPENACCUTILSGPU_H_
16
18#include "mlir/IR/BuiltinOps.h"
19#include <optional>
20
21namespace mlir {
22namespace acc {
23
24/// Default GPU module name used by OpenACC.
25constexpr llvm::StringLiteral kDefaultGPUModuleName = "acc_gpu_module";
26
27/// Get or create a GPU module in the given module.
28///
29/// If a GPU module with the specified name already exists, it is returned.
30/// If `create` is true and no GPU module exists, one is created.
31/// If `create` is false and no GPU module exists, std::nullopt is returned.
32///
33/// \param mod The module to search or create the GPU module in.
34/// \param create If true (default), create the GPU module if it doesn't exist.
35/// \param name The name for the GPU module. If empty, uses
36/// kDefaultGPUModuleName.
37/// \return The GPU module if found or created, std::nullopt otherwise.
38std::optional<gpu::GPUModuleOp>
39getOrCreateGPUModule(ModuleOp mod, bool create = true,
40 llvm::StringRef name = kDefaultGPUModuleName);
41
42} // namespace acc
43} // namespace mlir
44
45#endif // MLIR_DIALECT_OPENACC_OPENACCUTILSGPU_H_
std::optional< gpu::GPUModuleOp > getOrCreateGPUModule(ModuleOp mod, bool create=true, llvm::StringRef name=kDefaultGPUModuleName)
Get or create a GPU module in the given module.
constexpr llvm::StringLiteral kDefaultGPUModuleName
Default GPU module name used by OpenACC.
Include the generated interface declarations.