MLIR 24.0.0git
HostOpFiltering.cpp File Reference
#include "mlir/Dialect/OpenMP/Transforms/Passes.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
#include "mlir/Interfaces/FunctionInterfaces.h"
#include "mlir/Dialect/OpenMP/Transforms/Passes.h.inc"

Go to the source code of this file.

Namespaces

namespace  mlir
 Include the generated interface declarations.
namespace  mlir::omp

Macros

#define GEN_PASS_DEF_HOSTOPFILTERINGPASS

Functions

static bool keepHostOpInDevice (Operation &op)
 Some host operations, like llvm.mlir.addressof and constants, must remain in the device module because they impact how device code is generated when attached to an omp.target operation.
static void collectRewrite (omp::MapInfoOp mapOp, llvm::SetVector< omp::MapInfoOp > &rewrites)
 Add an omp.map.info operation and all its members recursively to the output set to be later rewritten.
static void collectRewrite (Value value, llvm::SetVector< Value > &rewrites)
 Add the given value to a sorted set if it should be replaced by a placeholder when used as an operand that must remain for the device.
static std::optional< omp::DeclareTargetDeviceType > getDeclareTargetDevice (Operation &op)
 Provide the device_type of an omp.declare_target attribute, if defined.

Macro Definition Documentation

◆ GEN_PASS_DEF_HOSTOPFILTERINGPASS

#define GEN_PASS_DEF_HOSTOPFILTERINGPASS

Definition at line 22 of file HostOpFiltering.cpp.

Function Documentation

◆ collectRewrite() [1/2]

void collectRewrite ( omp::MapInfoOp mapOp,
llvm::SetVector< omp::MapInfoOp > & rewrites )
static

Add an omp.map.info operation and all its members recursively to the output set to be later rewritten.

Dependencies across omp.map.info are maintained by ensuring dependencies are added to the output sets before operations based on them.

Definition at line 47 of file HostOpFiltering.cpp.

References collectRewrite().

Referenced by collectRewrite(), and collectRewrite().

◆ collectRewrite() [2/2]

void collectRewrite ( Value value,
llvm::SetVector< Value > & rewrites )
static

Add the given value to a sorted set if it should be replaced by a placeholder when used as an operand that must remain for the device.

Values that are block arguments of function operations are skipped, since they will still be available after all rewrites are completed, and operands of operations that need to remain on the host are recursively collected.

Definition at line 61 of file HostOpFiltering.cpp.

References collectRewrite(), mlir::Value::getDefiningOp(), mlir::Operation::getOperands(), and keepHostOpInDevice().

◆ getDeclareTargetDevice()

std::optional< omp::DeclareTargetDeviceType > getDeclareTargetDevice ( Operation & op)
static

Provide the device_type of an omp.declare_target attribute, if defined.

Definition at line 79 of file HostOpFiltering.cpp.

◆ keepHostOpInDevice()

bool keepHostOpInDevice ( Operation & op)
static

Some host operations, like llvm.mlir.addressof and constants, must remain in the device module because they impact how device code is generated when attached to an omp.target operation.

This function identifies the operations that need this special handling. This includes cast-style operations to avoid losing information about the original source of an operand.

Definition at line 36 of file HostOpFiltering.cpp.

References mlir::Operation::getContext(), mlir::Operation::getDialect(), mlir::MLIRContext::getLoadedDialect(), and mlir::isPure().

Referenced by collectRewrite().