MLIR
22.0.0git
|
Base class for all XeVM serializations from GPU modules into binary strings. More...
#include "mlir/Target/LLVM/XeVM/Utils.h"
Public Member Functions | |
SerializeGPUModuleBase (Operation &module, XeVMTargetAttr target, const gpu::TargetOptions &targetOptions={}) | |
XeVMTargetAttr | getTarget () const |
Returns the target attribute. More... | |
std::optional< SmallVector< std::unique_ptr< llvm::Module > > > | loadBitcodeFiles (llvm::Module &module) override |
Loads the bitcode files in librariesToLink . More... | |
gpu::GPUModuleOp | getGPUModuleOp () |
Returns the gpu module being serialized. More... | |
std::optional< SmallVector< char, 0 > > | compileToBinary (const std::string &asmStr, StringRef inputFormat) |
Compiles to native code using ocloc . More... | |
![]() | |
ModuleToObject (Operation &module, StringRef triple, StringRef chip, StringRef features={}, int optLevel=3, function_ref< void(llvm::Module &)> initialLlvmIRCallback={}, function_ref< void(llvm::Module &)> linkedLlvmIRCallback={}, function_ref< void(llvm::Module &)> optimizedLlvmIRCallback={}, function_ref< void(StringRef)> isaCallback={}) | |
virtual | ~ModuleToObject () |
Operation & | getOperation () |
Returns the operation being serialized. More... | |
virtual std::optional< SmallVector< char, 0 > > | run () |
Runs the serialization pipeline, returning std::nullopt on error. More... | |
Protected Member Functions | |
std::optional< std::string > | findTool (StringRef tool) |
Returns the path to the tool used for serialization. More... | |
![]() | |
virtual void | setDataLayoutAndTriple (llvm::Module &module) |
Hook for computing the Datalayout. More... | |
virtual LogicalResult | handleBitcodeFile (llvm::Module &module) |
Hook for performing additional actions on a loaded bitcode file. More... | |
virtual void | handleModulePreLink (llvm::Module &module) |
Hook for performing additional actions on the llvmModule pre linking. More... | |
virtual void | handleModulePostLink (llvm::Module &module) |
Hook for performing additional actions on the llvmModule post linking. More... | |
virtual std::optional< SmallVector< char, 0 > > | moduleToObject (llvm::Module &llvmModule) |
Serializes the LLVM IR bitcode to an object file, by default it serializes to LLVM bitcode. More... | |
std::optional< llvm::TargetMachine * > | getOrCreateTargetMachine () |
Create the target machine based on the target triple and chip. More... | |
std::unique_ptr< llvm::Module > | loadBitcodeFile (llvm::LLVMContext &context, StringRef path) |
Loads a bitcode file from path. More... | |
LogicalResult | loadBitcodeFilesFromList (llvm::LLVMContext &context, ArrayRef< Attribute > librariesToLink, SmallVector< std::unique_ptr< llvm::Module >> &llvmModules, bool failureOnError=true) |
Loads multiple bitcode files. More... | |
std::unique_ptr< llvm::Module > | translateToLLVMIR (llvm::LLVMContext &llvmContext) |
Translates the operation to LLVM IR. More... | |
LogicalResult | linkFiles (llvm::Module &module, SmallVector< std::unique_ptr< llvm::Module >> &&libs) |
Link the llvmModule to other bitcode file. More... | |
virtual LogicalResult | optimizeModule (llvm::Module &module, int optL) |
Optimize the module. More... | |
Protected Attributes | |
XeVMTargetAttr | xeTarget |
XeVM Target attribute. More... | |
SmallVector< Attribute > | librariesToLink |
List of LLVM bitcode to link into after translation to LLVM IR. More... | |
gpu::TargetOptions | targetOptions |
GPU compilation target options. More... | |
![]() | |
Operation & | module |
Module to transform to a binary object. More... | |
StringRef | triple |
Target triple. More... | |
StringRef | chip |
Target chip. More... | |
StringRef | features |
Target features. More... | |
int | optLevel |
Optimization level. More... | |
function_ref< void(llvm::Module &)> | initialLlvmIRCallback |
Callback invoked with the initial LLVM IR for the device module. More... | |
function_ref< void(llvm::Module &)> | linkedLlvmIRCallback |
Callback invoked with LLVM IR for the device module after linking the device libraries. More... | |
function_ref< void(llvm::Module &)> | optimizedLlvmIRCallback |
Callback invoked with LLVM IR for the device module after LLVM optimizations but before codegen. More... | |
function_ref< void(StringRef)> | isaCallback |
Callback invoked with the target ISA for the device, for example PTX assembly. More... | |
Additional Inherited Members | |
![]() | |
static std::optional< std::string > | translateToISA (llvm::Module &llvmModule, llvm::TargetMachine &targetMachine) |
Utility function for translating to ISA, returns std::nullopt on failure. More... | |
Base class for all XeVM serializations from GPU modules into binary strings.
By default this class serializes into LLVM bitcode.
SerializeGPUModuleBase::SerializeGPUModuleBase | ( | Operation & | module, |
XeVMTargetAttr | target, | ||
const gpu::TargetOptions & | targetOptions = {} |
||
) |
Definition at line 78 of file Target.cpp.
std::optional< SmallVector< char, 0 > > SerializeGPUModuleBase::compileToBinary | ( | const std::string & | asmStr, |
StringRef | inputFormat | ||
) |
Compiles to native code using ocloc
.
Definition at line 111 of file Target.cpp.
References mlir::emitError(), findTool(), getGPUModuleOp(), getTarget(), targetOptions, and mlir::gpu::TargetOptions::tokenizeCmdOptions().
|
protected |
Returns the path to the tool used for serialization.
Definition at line 215 of file Target.cpp.
References getGPUModuleOp(), mlir::gpu::TargetOptions::getToolkitPath(), and targetOptions.
Referenced by compileToBinary().
gpu::GPUModuleOp SerializeGPUModuleBase::getGPUModuleOp | ( | ) |
Returns the gpu module being serialized.
Definition at line 102 of file Target.cpp.
References mlir::LLVM::ModuleToObject::getOperation().
Referenced by compileToBinary(), and findTool().
XeVMTargetAttr SerializeGPUModuleBase::getTarget | ( | ) | const |
Returns the target attribute.
Definition at line 89 of file Target.cpp.
References xeTarget.
Referenced by compileToBinary().
|
overridevirtual |
Loads the bitcode files in librariesToLink
.
Reimplemented from mlir::LLVM::ModuleToObject.
Definition at line 92 of file Target.cpp.
References mlir::remark::failed(), mlir::Operation::getContext(), librariesToLink, mlir::LLVM::ModuleToObject::loadBitcodeFilesFromList(), and mlir::LLVM::ModuleToObject::module.
|
protected |
|
protected |
GPU compilation target options.
Definition at line 58 of file Utils.h.
Referenced by compileToBinary(), and findTool().
|
protected |