-
Notifications
You must be signed in to change notification settings - Fork 11.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MLIR] XeGPU dialect for Intel GPU - core definitions and base classes (
#78483) This PR follows our previous [RFC ](https://discourse.llvm.org/t/rfc-add-xegpu-dialect-for-intel-gpus/75723) to add XeGPU dialect definition for Intel GPUs. It contains dialect, type, attributes and operators definitions, as well as testcases for semantic checks. The lowering and optimization passes will be issued with separated passes. --------- Co-authored-by: Mehdi Amini <joker.eph@gmail.com>
- Loading branch information
Showing
15 changed files
with
250 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
add_subdirectory(IR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
add_mlir_dialect(XeGPU xegpu) | ||
add_mlir_doc(XeGPU XeGPU Dialects/ -gen-dialect-doc -dialect=xegpu) | ||
|
||
set(LLVM_TARGET_DEFINITIONS XeGPU.td) | ||
mlir_tablegen(XeGPUAttrs.h.inc -gen-attrdef-decls) | ||
mlir_tablegen(XeGPUAttrs.cpp.inc -gen-attrdef-defs) | ||
add_public_tablegen_target(MLIRXeGPUAttrsIncGen) | ||
add_dependencies(mlir-headers MLIRXeGPUAttrsIncGen) | ||
|
||
set(LLVM_TARGET_DEFINITIONS XeGPU.td) | ||
mlir_tablegen(XeGPUEnums.h.inc -gen-enum-decls) | ||
mlir_tablegen(XeGPUEnums.cpp.inc -gen-enum-defs) | ||
add_public_tablegen_target(MLIRXeGPUEnumsIncGen) | ||
add_dependencies(mlir-headers MLIRXeGPUEnumsIncGen) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//===- XeGPU.h - MLIR dialect for XeGPU -------------------------*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, 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_XEGPU_IR_XEGPU_H | ||
#define MLIR_DIALECT_XEGPU_IR_XEGPU_H | ||
|
||
#include <mlir/IR/Dialect.h> | ||
|
||
namespace mlir { | ||
namespace xegpu { | ||
// placeholder | ||
} // namespace xegpu | ||
} // namespace mlir | ||
|
||
#include <mlir/Dialect/XeGPU/IR/XeGPUDialect.h.inc> | ||
#include <mlir/Dialect/XeGPU/IR/XeGPUEnums.h.inc> | ||
#define GET_ATTRDEF_CLASSES | ||
#include <mlir/Dialect/XeGPU/IR/XeGPUAttrs.h.inc> | ||
#define GET_TYPEDEF_CLASSES | ||
#include <mlir/Dialect/XeGPU/IR/XeGPUTypes.h.inc> | ||
#define GET_OP_CLASSES | ||
#include <mlir/Dialect/XeGPU/IR/XeGPU.h.inc> | ||
|
||
#endif // MLIR_DIALECT_XEGPU_IR_XEGPU_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//===- XeGPU.td - XeGPU dialect definition ------------------*- tablegen -*-===// | ||
// | ||
// Part of the LLVM Project, 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_XEGPU_IR_XEGPU_TD | ||
#define MLIR_DIALECT_XEGPU_IR_XEGPU_TD | ||
|
||
include "mlir/Dialect/XeGPU/IR/XeGPUOps.td" | ||
|
||
#endif // MLIR_DIALECT_XEGPU_IR_XEGPU_TD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//===- XeGPUAttrs.td - XeGPU dialect attributes definition --*- tablegen -*-===// | ||
// | ||
// Part of the LLVM Project, 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_XEGPU_IR_XEGPUATTRS_TD | ||
#define MLIR_DIALECT_XEGPU_IR_XEGPUATTRS_TD | ||
|
||
include "mlir/Dialect/XeGPU/IR/XeGPUDialect.td" | ||
|
||
class XeGPUAttr<string name, string attrMnemonic, list<Trait> traits = [], | ||
string baseCppClass = "::mlir::Attribute"> | ||
: AttrDef<XeGPU_Dialect, name, traits, baseCppClass> { | ||
let mnemonic = attrMnemonic; | ||
} | ||
|
||
#endif // MLIR_DIALECT_XEGPU_IR_XEGPUATTRS_TD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//===- XeGPUDialect.td - XeGPU dialect definition -----------*- tablegen -*-===// | ||
// | ||
// Part of the LLVM Project, 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_XEGPU_IR_XEGPUDIALECT_TD | ||
#define MLIR_DIALECT_XEGPU_IR_XEGPUDIALECT_TD | ||
|
||
include "mlir/IR/OpBase.td" | ||
|
||
def XeGPU_Dialect : Dialect { | ||
let name = "xegpu"; | ||
let cppNamespace = "::mlir::xegpu"; | ||
let summary = "The XeGPU dialect that models Intel GPU's ISA"; | ||
let description = [{ | ||
The XeGPU dialect models Intel Xe ISA semantics but works at vector and | ||
TensorDesc data type. It provides 1:1 mappings to match Xe instructions | ||
like DPAS and 2D block load. The matrix size being processed at this level | ||
exactly matches the hardware instructions or the intrinsic supported by | ||
the lower-level GPU compiler. | ||
}]; | ||
|
||
// let useDefaultTypePrinterParser = true; | ||
// let useDefaultAttributePrinterParser = true; | ||
} | ||
|
||
#endif // MLIR_DIALECT_XEGPU_IR_XEGPUDIALECT_TD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//===- XeGPUOps.td - XeGPU dialect operations definition ----*- tablegen -*-===// | ||
// | ||
// Part of the LLVM Project, 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_XEGPU_IR_XEGPUOPS_TD | ||
#define MLIR_DIALECT_XEGPU_IR_XEGPUOPS_TD | ||
|
||
include "mlir/Dialect/XeGPU/IR/XeGPUAttrs.td" | ||
include "mlir/Dialect/XeGPU/IR/XeGPUDialect.td" | ||
include "mlir/Dialect/XeGPU/IR/XeGPUTypes.td" | ||
|
||
|
||
// Base class for dialect operations. This operation inherits from the base | ||
// `Op` class in OpBase.td, and provides: | ||
// * The parent dialect of the operation. | ||
// * The mnemonic for the operation, or the name without the dialect prefix. | ||
// * A list of traits for the operation. | ||
class XeGPU_Op<string mnemonic, list<Trait> traits = []>: | ||
Op<XeGPU_Dialect, mnemonic, traits>; | ||
|
||
|
||
#endif // MLIR_DIALECT_XEGPU_IR_XEGPUOPS_TD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//===- XeGPUTypes.td - XeGPU dialect types definition -------*- tablegen -*-===// | ||
// | ||
// Part of the LLVM Project, 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_XEGPU_IR_XEGPUTYPES_TD | ||
#define MLIR_DIALECT_XEGPU_IR_XEGPUTYPES_TD | ||
|
||
include "mlir/IR/BuiltinTypes.td" | ||
include "mlir/Dialect/XeGPU/IR/XeGPUAttrs.td" | ||
include "mlir/Dialect/XeGPU/IR/XeGPUDialect.td" | ||
|
||
def XeGPU_IntType: AnyTypeOf<[I1, I8, I16, I32, I64, SI1, SI8, SI16, SI32, SI64, UI1, UI8, UI16, UI32, UI64]>; | ||
def XeGPU_FloatType: AnyTypeOf<[F16, F32, F64, BF16, TF32]>; | ||
def XeGPU_ScalarType: AnyTypeOf<[XeGPU_IntType, XeGPU_FloatType]>; | ||
def XeGPU_BaseAddrType: AnyTypeOf<[MemRefRankOf<[XeGPU_ScalarType], [1, 2]>, UI64, UI32, I64, I32]>; | ||
def XeGPU_DpasOpType: VectorOfRankAndType<[2, 3], [XeGPU_ScalarType]>; | ||
def XeGPU_OffsetType: VectorOfRankAndType<[1], [Index]>; | ||
def XeGPU_MaskType: AnyTypeOf<[VectorOfRankAndType<[1,2], [I1]>, I1]>; | ||
def XeGPU_ValueType: AnyTypeOf<[VectorOfRankAndType<[1,2,3,4], [XeGPU_ScalarType]>, XeGPU_ScalarType]>; | ||
def XeGPU_Vector2DType: VectorOfRankAndType<[2], [XeGPU_ScalarType]>; | ||
|
||
// common base class for types in XeGPU dialect | ||
class XeGPUTypeDef<string name, string typeMnemonic, list<Trait> traits = [], | ||
string baseCppClass = "::mlir::Type"> | ||
: TypeDef<XeGPU_Dialect, name, traits, baseCppClass> { | ||
let mnemonic = typeMnemonic; | ||
} | ||
|
||
#endif // MLIR_DIALECT_XEGPU_IR_XEGPUTYPES_TD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
add_subdirectory(IR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
add_mlir_dialect_library(MLIRXeGPUDialect | ||
XeGPUDialect.cpp | ||
XeGPUOps.cpp | ||
|
||
ADDITIONAL_HEADER_DIRS | ||
${PROJECT_SOURCE_DIR}/include/mlir/Dialect/XeGPU | ||
|
||
DEPENDS | ||
MLIRXeGPUIncGen | ||
MLIRXeGPUAttrsIncGen | ||
MLIRXeGPUEnumsIncGen | ||
|
||
LINK_LIBS PUBLIC | ||
MLIRIR | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//===- XeGPUDialect.cpp - MLIR XeGPU dialect implementation -----*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, 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 <mlir/Dialect/XeGPU/IR/XeGPU.h> | ||
|
||
namespace mlir { | ||
namespace xegpu { | ||
|
||
void XeGPUDialect::initialize() { | ||
addTypes< | ||
#define GET_TYPEDEF_LIST | ||
#include <mlir/Dialect/XeGPU/IR/XeGPUTypes.cpp.inc> | ||
>(); | ||
addOperations< | ||
#define GET_OP_LIST | ||
#include <mlir/Dialect/XeGPU/IR/XeGPU.cpp.inc> | ||
>(); | ||
addAttributes< | ||
#define GET_ATTRDEF_LIST | ||
#include <mlir/Dialect/XeGPU/IR/XeGPUAttrs.cpp.inc> | ||
>(); | ||
} | ||
|
||
// this file is for position occupation, | ||
// we will add functions in following PRs. | ||
|
||
} // namespace xegpu | ||
} // namespace mlir | ||
|
||
#include <mlir/Dialect/XeGPU/IR/XeGPUDialect.cpp.inc> | ||
#define GET_ATTRDEF_CLASSES | ||
#include <mlir/Dialect/XeGPU/IR/XeGPUAttrs.cpp.inc> | ||
#define GET_TYPEDEF_CLASSES | ||
#include <mlir/Dialect/XeGPU/IR/XeGPUTypes.cpp.inc> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//===- XeGPUOps.cpp - MLIR XeGPU ops implementation -------------*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, 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 <mlir/Dialect/XeGPU/IR/XeGPU.h> | ||
|
||
#define DEBUG_TYPE "xegpu" | ||
|
||
namespace mlir { | ||
namespace xegpu { | ||
// this file is for position occupation, | ||
// we will add functions in following PRs. | ||
|
||
} // namespace xegpu | ||
} // namespace mlir | ||
|
||
#include <mlir/Dialect/XeGPU/IR/XeGPUEnums.cpp.inc> | ||
#define GET_OP_CLASSES | ||
#include <mlir/Dialect/XeGPU/IR/XeGPU.cpp.inc> |