-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[MLIR][GPU][XeVM] Add XeVM target and XeVM dialect integration tests. #148286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 18 commits
e6bcef6
717bdf9
6fef03f
421363b
a850e6e
6e160df
b1f6bc3
415166e
dcefcc6
14c9208
260a456
6d2e1ee
b102c1b
ddfa982
eca1d2a
4c72cff
8952cf6
1e7fb15
91665e0
ee50e45
09694b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//===-- Target.h - MLIR XeVM target registration ----------------*- C++ -*-===// | ||
// | ||
// This file is licensed under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This provides registration calls for attaching the XeVM target interface. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef MLIR_TARGET_LLVM_XEVM_TARGET_H | ||
#define MLIR_TARGET_LLVM_XEVM_TARGET_H | ||
|
||
namespace mlir { | ||
class DialectRegistry; | ||
class MLIRContext; | ||
namespace xevm { | ||
/// Registers the `TargetAttrInterface` for the `#xevm.target` attribute in | ||
/// the given registry. | ||
void registerXeVMTargetInterfaceExternalModels(mlir::DialectRegistry ®istry); | ||
|
||
/// Registers the `TargetAttrInterface` for the `#xevm.target` attribute in | ||
/// the registry associated with the given context. | ||
void registerXeVMTargetInterfaceExternalModels(mlir::MLIRContext &context); | ||
} // namespace xevm | ||
} // namespace mlir | ||
|
||
#endif // MLIR_TARGET_LLVM_XEVM_TARGET_H |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
//===-- Utils.h - MLIR XeVM target utils ------------------------*- C++ -*-===// | ||
// | ||
// This file is licensed under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This files declares XeVM target related utility classes and functions. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef MLIR_TARGET_LLVM_XEVM_UTILS_H | ||
#define MLIR_TARGET_LLVM_XEVM_UTILS_H | ||
|
||
#include "mlir/Dialect/GPU/IR/CompilationInterfaces.h" | ||
#include "mlir/Dialect/LLVMIR/XeVMDialect.h" | ||
#include "mlir/IR/Attributes.h" | ||
#include "mlir/Target/LLVM/ModuleToObject.h" | ||
|
||
namespace mlir { | ||
namespace xevm { | ||
|
||
/// Base class for all XeVM serializations from GPU modules into binary strings. | ||
/// By default this class serializes into LLVM bitcode. | ||
class SerializeGPUModuleBase : public LLVM::ModuleToObject { | ||
public: | ||
SerializeGPUModuleBase(Operation &module, XeVMTargetAttr target, | ||
const gpu::TargetOptions &targetOptions = {}); | ||
|
||
/// Returns the target attribute. | ||
XeVMTargetAttr getTarget() const; | ||
|
||
/// Loads the bitcode files in `librariesToLink`. | ||
std::optional<SmallVector<std::unique_ptr<llvm::Module>>> | ||
loadBitcodeFiles(llvm::Module &module) override; | ||
|
||
/// Returns the gpu module being serialized. | ||
gpu::GPUModuleOp getGPUModuleOp(); | ||
|
||
/// Compiles to native code using `ocloc`. | ||
std::optional<SmallVector<char, 0>> compileToBinary(const std::string &asmStr, | ||
StringRef inputFormat); | ||
|
||
protected: | ||
/// XeVM Target attribute. | ||
XeVMTargetAttr xeTarget; | ||
/// List of LLVM bitcode to link into after translation to LLVM IR. | ||
/// The attributes can be StringAttr pointing to a file path, or | ||
/// a Resource blob pointing to the LLVM bitcode in-memory. | ||
SmallVector<Attribute> librariesToLink; | ||
|
||
/// Returns the path to the tool used for serialization. | ||
std::optional<std::string> findTool(StringRef tool); | ||
|
||
/// GPU compilation target options. | ||
gpu::TargetOptions targetOptions; | ||
adam-smnk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
} // namespace xevm | ||
} // namespace mlir | ||
|
||
#endif // MLIR_TARGET_LLVM_XEVM_UTILS_H |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -210,3 +210,26 @@ if(MLIR_ENABLE_ROCM_CONVERSIONS) | |
) | ||
endif() | ||
|
||
if ("SPIRV" IN_LIST LLVM_TARGETS_TO_BUILD) | ||
set(SPIRV_LIBS | ||
SPIRVCodeGen | ||
|
||
) | ||
endif() | ||
|
||
add_mlir_dialect_library(MLIRXeVMTarget | ||
XeVM/Target.cpp | ||
|
||
OBJECT | ||
|
||
LINK_COMPONENTS | ||
${SPIRV_LIBS} | ||
|
||
LINK_LIBS PUBLIC | ||
MLIRIR | ||
MLIRExecutionEngineUtils | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need to depend on ExeuctionEngine and GPUDialect? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. XeVM target needs to access things like gpu::TargetAttrInterface and gpu::TargetOptions There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And base ModuleToObject requires makeOptimizingTransformer from ExecutionEngine |
||
MLIRSupport | ||
MLIRGPUDialect | ||
MLIRTargetLLVM | ||
MLIRXeVMToLLVMIRTranslation | ||
) |
Uh oh!
There was an error while loading. Please reload this page.