-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[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
base: main
Are you sure you want to change the base?
Changes from all commits
e6bcef6
717bdf9
6fef03f
421363b
a850e6e
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,31 @@ | ||
//===-- 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_XEVM_TARGET_H | ||
#define MLIR_TARGET_XEVM_TARGET_H | ||
|
||
namespace mlir { | ||
class DialectRegistry; | ||
class MLIRContext; | ||
} // namespace mlir | ||
|
||
namespace mlir::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 mlir::xevm | ||
|
||
#endif // MLIR_TARGET_XEVM_TARGET_H |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//===-- 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/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 mlir::LLVM::ModuleToObject { | ||
public: | ||
SerializeGPUModuleBase(mlir::Operation &module, XeVMTargetAttr target, | ||
const mlir::gpu::TargetOptions &targetOptions = {}); | ||
|
||
static void init(); | ||
XeVMTargetAttr getTarget() const; | ||
|
||
protected: | ||
XeVMTargetAttr target; | ||
}; | ||
} // namespace xevm | ||
} // namespace mlir | ||
|
||
#endif // MLIR_TARGET_LLVM_XEVM_UTILS_H |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -210,3 +210,35 @@ 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 | ||
|
||
ADDITIONAL_HEADER_DIRS | ||
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/LLVMIR | ||
|
||
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? |
||
MLIRSupport | ||
MLIRGPUDialect | ||
MLIRTargetLLVM | ||
MLIRXeVMToLLVMIRTranslation | ||
) | ||
|
||
# Ensure SPIRV headers are included. Warning: references build directory! | ||
target_include_directories(MLIRXeVMTarget PRIVATE | ||
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. CI may not like it. This workaround relies on |
||
${LLVM_MAIN_SRC_DIR}/lib/Target/SPIRV | ||
${LLVM_BINARY_DIR}/lib/Target/SPIRV | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: consider target => xeTarget