Skip to content

Commit 3287c1c

Browse files
committed
[XeGPU] Move targetinfo constants to their own header file
This breaks the dependency from Dialect to Utils, which would be cyclic.
1 parent b77114b commit 3287c1c

File tree

6 files changed

+37
-23
lines changed

6 files changed

+37
-23
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//===- XeGPUTargetInfo.h - Target constants ---------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef MLIR_DIALECT_XEGPU_IR_XEGPUTARGETINFO_H_
10+
#define MLIR_DIALECT_XEGPU_IR_XEGPUTARGETINFO_H_
11+
12+
namespace mlir {
13+
namespace xegpu {
14+
/// HW dependent constants.
15+
/// TODO: These constants should be queried from the target information.
16+
namespace targetinfo {
17+
constexpr unsigned subgroupSize = 16; // How many lanes in a subgroup.
18+
/// If DPAS A or B operands have low precision element types they must be packed
19+
/// according to the following sizes.
20+
constexpr unsigned packedSizeInBitsForDefault =
21+
16; // Minimum packing size per register for DPAS A.
22+
constexpr unsigned packedSizeInBitsForDpasB =
23+
32; // Minimum packing size per register for DPAS B.
24+
constexpr unsigned packedSizeInBitsForGatherScatter =
25+
32; // Minimum packing size per register for Gather and Scatter ops.
26+
} // namespace targetinfo
27+
} // namespace xegpu
28+
} // namespace mlir
29+
30+
#endif // MLIR_DIALECT_XEGPU_IR_XEGPUTARGETINFO_H_

mlir/include/mlir/Dialect/XeGPU/Utils/XeGPUUtils.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,6 @@ class LayoutAttr;
2424
class TensorDescType;
2525
} // namespace xegpu
2626

27-
namespace xegpu {
28-
/// HW dependent constants.
29-
/// TODO: These constants should be queried from the target information.
30-
namespace targetinfo {
31-
constexpr unsigned subgroupSize = 16; // How many lanes in a subgroup.
32-
/// If DPAS A or B operands have low precision element types they must be packed
33-
/// according to the following sizes.
34-
constexpr unsigned packedSizeInBitsForDefault =
35-
16; // Minimum packing size per register for DPAS A.
36-
constexpr unsigned packedSizeInBitsForDpasB =
37-
32; // Minimum packing size per register for DPAS B.
38-
constexpr unsigned packedSizeInBitsForGatherScatter =
39-
32; // Minimum packing size per register for Gather and Scatter ops.
40-
} // namespace targetinfo
41-
} // namespace xegpu
42-
4327
namespace xegpu {
4428

4529
/// Flatten a set of ValueRange into a single SmallVector<Value>

mlir/lib/Dialect/XeGPU/IR/XeGPUDialect.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include "mlir/Dialect/Utils/IndexingUtils.h"
1010
#include "mlir/Dialect/XeGPU/IR/XeGPU.h"
11-
#include "mlir/Dialect/XeGPU/Utils/XeGPUUtils.h"
11+
#include "mlir/Dialect/XeGPU/IR/XeGPUTargetInfo.h"
1212
#include "mlir/IR/Builders.h"
1313
#include "mlir/IR/DialectImplementation.h"
1414
#include "llvm/ADT/TypeSwitch.h"

mlir/lib/Dialect/XeGPU/Transforms/XeGPUPropagateLayout.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "mlir/Dialect/MemRef/IR/MemRef.h"
1616
#include "mlir/Dialect/Vector/IR/VectorOps.h"
1717
#include "mlir/Dialect/XeGPU/IR/XeGPU.h"
18+
#include "mlir/Dialect/XeGPU/IR/XeGPUTargetInfo.h"
1819
#include "mlir/Dialect/XeGPU/Transforms/Passes.h"
1920
#include "mlir/Dialect/XeGPU/Utils/XeGPUUtils.h"
2021
#include "mlir/IR/Attributes.h"

mlir/lib/Dialect/XeGPU/Transforms/XeGPUSubgroupDistribute.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "mlir/Dialect/Vector/IR/VectorOps.h"
1212
#include "mlir/Dialect/Vector/Transforms/VectorDistribution.h"
1313
#include "mlir/Dialect/XeGPU/IR/XeGPU.h"
14+
#include "mlir/Dialect/XeGPU/IR/XeGPUTargetInfo.h"
1415
#include "mlir/Dialect/XeGPU/Transforms/Passes.h"
1516
#include "mlir/Dialect/XeGPU/Transforms/Transforms.h"
1617
#include "mlir/Dialect/XeGPU/Utils/XeGPUUtils.h"

utils/bazel/llvm-project-overlay/mlir/BUILD.bazel

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3519,11 +3519,8 @@ gentbl_cc_library(
35193519

35203520
cc_library(
35213521
name = "XeGPUDialect",
3522-
srcs = [
3523-
"lib/Dialect/XeGPU/IR/XeGPUDialect.cpp",
3524-
"lib/Dialect/XeGPU/IR/XeGPUOps.cpp",
3525-
],
3526-
hdrs = ["include/mlir/Dialect/XeGPU/IR/XeGPU.h"],
3522+
srcs = glob(["lib/Dialect/XeGPU/IR/*.cpp"]),
3523+
hdrs = glob(["include/mlir/Dialect/XeGPU/IR/*.h"]),
35273524
includes = ["include"],
35283525
deps = [
35293526
":ArithDialect",
@@ -4845,7 +4842,8 @@ cc_library(
48454842
]),
48464843
hdrs = glob(["include/mlir/Support/*.h"]),
48474844
includes = ["include"],
4848-
deps = ["//llvm:Support"],)
4845+
deps = ["//llvm:Support"],
4846+
)
48494847

48504848
cc_library(
48514849
name = "Debug",

0 commit comments

Comments
 (0)