MLIR 23.0.0git
Utils.h
Go to the documentation of this file.
1//===- Utils.h - OpenMP dialect 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 header file defines prototypes for various OpenMP utilities.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef MLIR_DIALECT_OPENMP_UTILS_UTILS_H_
14#define MLIR_DIALECT_OPENMP_UTILS_UTILS_H_
15
16#include "mlir/IR/Operation.h"
17#include "mlir/IR/Value.h"
18
19namespace mlir {
20namespace omp {
21
22/// Check whether the value representing an allocation, assumed to have been
23/// defined in a shared device context, is used in a manner that would require
24/// device shared memory for correctness.
25///
26/// When a use takes place inside an omp.parallel region and it's not as a
27/// private clause argument, or when it is a reduction argument passed to
28/// omp.parallel or a function call argument, then the defining allocation is
29/// eligible for replacement with shared memory.
30///
31/// \see mlir::omp::opInSharedDeviceContext().
32bool allocaUsesRequireSharedMem(Value alloc);
33
34/// Check whether the given operation is located in a context where an
35/// allocation to be used by multiple threads in a parallel region would have to
36/// be placed in device shared memory to be accessible.
37///
38/// That means that it is inside of a target device module, it is a non-SPMD
39/// target region, is inside of one or it's located in a device function, and it
40/// is not not inside of a parallel region.
41///
42/// This represents a necessary but not sufficient set of conditions to use
43/// device shared memory in place of regular allocas. For some variables, the
44/// associated OpenMP construct or their uses might also need to be taken into
45/// account.
46///
47/// \see mlir::omp::allocaUsesRequireSharedMem().
48bool opInSharedDeviceContext(Operation &op);
49
50} // namespace omp
51} // namespace mlir
52
53#endif // MLIR_DIALECT_OPENMP_UTILS_UTILS_H_
bool opInSharedDeviceContext(Operation &op)
Check whether the given operation is located in a context where an allocation to be used by multiple ...
Definition Utils.cpp:66
bool allocaUsesRequireSharedMem(Value alloc)
Check whether the value representing an allocation, assumed to have been defined in a shared device c...
Definition Utils.cpp:51
Include the generated interface declarations.