Skip to content

[GPU] Add XeVM dialect declaration #387

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

Merged
merged 2 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/gc/Dialect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ add_subdirectory(CPURuntime)
add_subdirectory(OneDNNGraph)
add_subdirectory(Microkernel)
add_subdirectory(Linalgx)
add_subdirectory(LLVMIR)
8 changes: 8 additions & 0 deletions include/gc/Dialect/LLVMIR/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
add_mlir_dialect(XeVMOps xevm)
add_mlir_doc(XeVMOps XeVMDialect Dialects/ -gen-dialect-doc -dialect=xevm)
set(LLVM_TARGET_DEFINITIONS XeVMOps.td)
mlir_tablegen(XeVMOpsEnums.h.inc -gen-enum-decls)
mlir_tablegen(XeVMOpsEnums.cpp.inc -gen-enum-defs)
mlir_tablegen(XeVMOpsAttributes.h.inc -gen-attrdef-decls -attrdefs-dialect=xevm)
mlir_tablegen(XeVMOpsAttributes.cpp.inc -gen-attrdef-defs -attrdefs-dialect=xevm)
add_public_tablegen_target(MLIRXeVMConversionsIncGen)
25 changes: 25 additions & 0 deletions include/gc/Dialect/LLVMIR/XeVMDialect.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//===-- XeVMDialect.h - MLIR XeVM target definitions ------------*- 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
//
//===----------------------------------------------------------------------===//

#ifndef MLIR_DIALECT_LLVMIR_XEVMDIALECT_H_
#define MLIR_DIALECT_LLVMIR_XEVMDIALECT_H_

#include "mlir/Bytecode/BytecodeOpInterface.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/OpDefinition.h"

#define GET_ATTRDEF_CLASSES
#include "gc/Dialect/LLVMIR/XeVMOpsAttributes.h.inc"

#define GET_OP_CLASSES
#include "gc/Dialect/LLVMIR/XeVMOps.h.inc"

#include "gc/Dialect/LLVMIR/XeVMOpsDialect.h.inc"

#endif /* MLIR_DIALECT_LLVMIR_XEVMDIALECT_H_ */
29 changes: 29 additions & 0 deletions include/gc/Dialect/LLVMIR/XeVMOps.td
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//===-- XeVMOps.td - XeVM dialect definition ---------------*- tablegen -*-===//
//
// 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
//
//===----------------------------------------------------------------------===//
#ifndef XEVMIR_OPS
#define XEVMIR_OPS

include "mlir/Dialect/GPU/IR/CompilationAttrInterfaces.td"
include "mlir/Dialect/LLVMIR/LLVMOpBase.td"
include "mlir/Interfaces/SideEffectInterfaces.td"

def XeVM_Dialect : Dialect {
let name = "xevm";
let cppNamespace = "::mlir::xevm";
let dependentDialects = ["LLVM::LLVMDialect"];
let useDefaultAttributePrinterParser = 1;
}

class XeVM_Attr<string attrName, string attrMnemonic, list<Trait> traits = []>
: AttrDef<XeVM_Dialect, attrName, traits> {
let mnemonic = attrMnemonic;
}

def XeVM_TargettAttr : XeVM_Attr<"XeVMTarget", "target"> {}

#endif // XEVMIR_OPS
1 change: 1 addition & 0 deletions lib/gc/Dialect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ add_subdirectory(CPURuntime)
add_subdirectory(Linalgx)
add_subdirectory(Microkernel)
add_subdirectory(OneDNNGraph)
add_subdirectory(LLVMIR)
20 changes: 20 additions & 0 deletions lib/gc/Dialect/LLVMIR/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
gc_add_mlir_dialect_library(MLIRXeVMDialect
IR/XeVMDialect.cpp

ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/LLVMIR
${PROJECT_SOURCE_DIR}/include/gc/Dialect/LLVMIR

DEPENDS
MLIRXeVMConversionsIncGen

LINK_COMPONENTS
AsmParser
Core

LINK_LIBS PUBLIC
MLIRIR
MLIRLLVMDialect
MLIRSideEffectInterfaces
GcInterface
)
38 changes: 38 additions & 0 deletions lib/gc/Dialect/LLVMIR/IR/XeVMDialect.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//===-- XeVMDialect.cpp - XeVM dialect 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
//
//===----------------------------------------------------------------------===//
#include "gc/Dialect/LLVMIR/XeVMDialect.h"

#include "mlir/Dialect/GPU/IR/CompilationInterfaces.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/IR/DialectImplementation.h"
#include "llvm/ADT/TypeSwitch.h"

using namespace mlir;
using namespace xevm;

#include "gc/Dialect/LLVMIR/XeVMOpsDialect.cpp.inc"

void XeVMDialect::initialize() {
// NOLINTBEGIN
addOperations<
#define GET_OP_LIST
#include "gc/Dialect/LLVMIR/XeVMOps.cpp.inc"
>();

addAttributes<
#define GET_ATTRDEF_LIST
#include "gc/Dialect/LLVMIR/XeVMOpsAttributes.cpp.inc"
>();
// NOLINTEND
}

#define GET_OP_CLASSES
#include "gc/Dialect/LLVMIR/XeVMOps.cpp.inc"

#define GET_ATTRDEF_CLASSES
#include "gc/Dialect/LLVMIR/XeVMOpsAttributes.cpp.inc"
2 changes: 2 additions & 0 deletions src/gc-opt/gc-opt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

#include "gc/Dialect/CPURuntime/Transforms/CPURuntimePasses.h"
#include "gc/Dialect/LLVMIR/XeVMDialect.h"
#include "gc/Dialect/Linalgx/LinalgxDialect.h"
#include "gc/Dialect/Microkernel/MicrokernelDialect.h"
#ifdef GC_HAS_ONEDNN_DIALECT
Expand Down Expand Up @@ -65,6 +66,7 @@ int main(int argc, char *argv[]) {
registry.insert<mlir::cpuruntime::CPURuntimeDialect>();
registry.insert<mlir::linalgx::LinalgxDialect>();
registry.insert<mlir::microkernel::MicrokernelDialect>();
registry.insert<mlir::xevm::XeVMDialect>();
mlir::registerAllDialects(registry);
#ifdef GC_USE_IMEX
registry.insert<::imex::xetile::XeTileDialect, ::imex::gpux::GPUXDialect>();
Expand Down