From 1b773a94fe346ebc0ed43eab87b4c01f43de1211 Mon Sep 17 00:00:00 2001 From: "Lee, Sang Ik" Date: Wed, 6 Dec 2023 10:02:39 -0800 Subject: [PATCH] Update LLVM SHA to 7fc792cba7663b2aa54f259515319d74a5625be0 and update LLVM patches. --- build_tools/llvm_version.txt | 2 +- ...upport-for-VectorAnyINTEL-capability.patch | 48 +++++++++---------- ...n-and-de-serialization-support-for-s.patch | 46 +++++++----------- ...int-Matrix-support-to-match-IGC-spec.patch | 43 +++++++++-------- lib/Conversion/GPUXToLLVM/GPUXToLLVMPass.cpp | 30 +++++------- .../XeTile/Transforms/XeTileTiling.cpp | 4 +- lib/Utils/XeCommon.cpp | 2 +- .../alloc-dealloc-to-gpu-runtime.mlir | 10 ++-- .../GPUXToLLVM/create-destroy-stream.mlir | 8 ++-- .../launch-func-to-gpu-runtime.mlir | 16 +++---- 10 files changed, 94 insertions(+), 115 deletions(-) diff --git a/build_tools/llvm_version.txt b/build_tools/llvm_version.txt index 3eba2629b..bf0dd8c7e 100644 --- a/build_tools/llvm_version.txt +++ b/build_tools/llvm_version.txt @@ -1 +1 @@ -49af6502c6dcb4a7f7520178bd14df396f78240c +7fc792cba7663b2aa54f259515319d74a5625be0 diff --git a/build_tools/patches/0001-Add-support-for-VectorAnyINTEL-capability.patch b/build_tools/patches/0001-Add-support-for-VectorAnyINTEL-capability.patch index d1ef51362..59a08520e 100644 --- a/build_tools/patches/0001-Add-support-for-VectorAnyINTEL-capability.patch +++ b/build_tools/patches/0001-Add-support-for-VectorAnyINTEL-capability.patch @@ -41,10 +41,10 @@ requirement initially, then do the check for capability inferred extension. 14 files changed, 311 insertions(+), 61 deletions(-) diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td -index 1e61aa747967..6f0f728f811e 100644 +index ee1fbba1e284..ee112b3b0099 100644 --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td -@@ -4126,7 +4126,12 @@ def SPIRV_Int32 : TypeAlias; +@@ -4146,7 +4146,12 @@ def SPIRV_Int32 : TypeAlias; def SPIRV_Float32 : TypeAlias; def SPIRV_Float : FloatOfWidths<[16, 32, 64]>; def SPIRV_Float16or32 : FloatOfWidths<[16, 32]>; @@ -58,21 +58,17 @@ index 1e61aa747967..6f0f728f811e 100644 [SPIRV_Bool, SPIRV_Integer, SPIRV_Float]>; // Component type check is done in the type parser for the following SPIR-V // dialect-specific types so we use "Any" here. -@@ -4186,10 +4191,10 @@ class SPIRV_JointMatrixOfType allowedTypes> : +@@ -4206,7 +4211,7 @@ class SPIRV_JointMatrixOfType allowedTypes> : "Joint Matrix">; - class SPIRV_ScalarOrVectorOf : -- AnyTypeOf<[type, VectorOfLengthAndType<[2, 3, 4, 8, 16], [type]>]>; -+ AnyTypeOf<[type, VectorOfLengthRangeAndType<[2, 0x7FFFFFFFFFFFFFFF], [type]>]>; - - class SPIRV_ScalarOrVectorOrCoopMatrixOf : -- AnyTypeOf<[type, VectorOfLengthAndType<[2, 3, 4, 8, 16], [type]>, -+ AnyTypeOf<[type, VectorOfLengthRangeAndType<[2, 0x7FFFFFFFFFFFFFFF], [type]>, - SPIRV_CoopMatrixOfType<[type]>, SPIRV_CoopMatrixNVOfType<[type]>]>; + class SPIRV_VectorOf : +- VectorOfLengthAndType<[2, 3, 4, 8,16], [type]>; ++ VectorOfLengthRangeAndType<[2, 0x7FFFFFFFFFFFFFFF], [type]>; - class SPIRV_MatrixOrCoopMatrixOf : + class SPIRV_ScalarOrVectorOf : + AnyTypeOf<[type, SPIRV_VectorOf]>; diff --git a/mlir/include/mlir/IR/CommonTypeConstraints.td b/mlir/include/mlir/IR/CommonTypeConstraints.td -index b0b5348baaad..2c569a651f8b 100644 +index 03180a687523..e4f2d5562ed7 100644 --- a/mlir/include/mlir/IR/CommonTypeConstraints.td +++ b/mlir/include/mlir/IR/CommonTypeConstraints.td @@ -604,6 +604,92 @@ class ScalableVectorOfRankAndLengthAndType allowedRanks, @@ -169,10 +165,10 @@ index b0b5348baaad..2c569a651f8b 100644 // Negative values for `n` index in reverse. class ShapedTypeWithNthDimOfSize allowedSizes> : Type< diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp -index 124d4ed6e8e6..9188f8b699b4 100644 +index 8a68decc5878..c6789315ba06 100644 --- a/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp -@@ -183,9 +183,12 @@ static Type parseAndVerifyType(SPIRVDialect const &dialect, +@@ -185,9 +185,12 @@ static Type parseAndVerifyType(SPIRVDialect const &dialect, parser.emitError(typeLoc, "only 1-D vector allowed but found ") << t; return Type(); } @@ -188,7 +184,7 @@ index 124d4ed6e8e6..9188f8b699b4 100644 return Type(); } diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp -index 39d6603a46f9..741d8069471d 100644 +index f1bac6490837..4db2c8c5c5d0 100644 --- a/mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp @@ -101,9 +101,11 @@ bool CompositeType::classof(Type type) { @@ -230,7 +226,7 @@ index 39d6603a46f9..741d8069471d 100644 capabilities.push_back(ref); } diff --git a/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp b/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp -index c75d217663a9..f7a8a2a3d281 100644 +index 2b79c8022b8e..b778e4f4daf9 100644 --- a/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp @@ -43,9 +43,13 @@ using namespace mlir; @@ -389,7 +385,7 @@ index c75d217663a9..f7a8a2a3d281 100644 } static Type -@@ -1150,16 +1236,18 @@ bool SPIRVConversionTarget::isLegalOp(Operation *op) { +@@ -1162,16 +1248,18 @@ bool SPIRVConversionTarget::isLegalOp(Operation *op) { SmallVector, 4> typeExtensions; SmallVector, 8> typeCapabilities; for (Type valueType : valueTypes) { @@ -434,7 +430,7 @@ index 0d92a8e676d8..d61ace8d6876 100644 } diff --git a/mlir/test/Conversion/ArithToSPIRV/arith-to-spirv.mlir b/mlir/test/Conversion/ArithToSPIRV/arith-to-spirv.mlir -index aa2cd649ecd7..b951d7490d64 100644 +index 0221e4815a93..9693f96a3300 100644 --- a/mlir/test/Conversion/ArithToSPIRV/arith-to-spirv.mlir +++ b/mlir/test/Conversion/ArithToSPIRV/arith-to-spirv.mlir @@ -29,6 +29,7 @@ func.func @int32_scalar(%lhs: i32, %rhs: i32) { @@ -445,7 +441,7 @@ index aa2cd649ecd7..b951d7490d64 100644 func.func @int32_scalar_srem(%lhs: i32, %rhs: i32) { // CHECK: %[[LABS:.+]] = spirv.GL.SAbs %[[LHS]] : i32 // CHECK: %[[RABS:.+]] = spirv.GL.SAbs %[[RHS]] : i32 -@@ -1362,3 +1363,35 @@ func.func @float_scalar(%arg0: f16) { +@@ -1407,3 +1408,35 @@ func.func @float_scalar(%arg0: f16) { } } // end module @@ -510,10 +506,10 @@ index 82d750755ffe..6f364c5b0875 100644 } // end module diff --git a/mlir/test/Dialect/SPIRV/IR/bit-ops.mlir b/mlir/test/Dialect/SPIRV/IR/bit-ops.mlir -index eeaa607b5604..78e2fffda755 100644 +index 82a2316f6c78..b3ad053baa3a 100644 --- a/mlir/test/Dialect/SPIRV/IR/bit-ops.mlir +++ b/mlir/test/Dialect/SPIRV/IR/bit-ops.mlir -@@ -97,7 +97,7 @@ func.func @bitwise_or_vector(%arg: vector<4xi32>) -> vector<4xi32> { +@@ -137,7 +137,7 @@ func.func @bitwise_or_all_ones_vector(%arg: vector<3xi8>) -> vector<3xi8> { // ----- func.func @bitwise_or_float(%arg0: f16, %arg1: f16) -> f16 { @@ -522,7 +518,7 @@ index eeaa607b5604..78e2fffda755 100644 %0 = spirv.BitwiseOr %arg0, %arg1 : f16 return %0 : f16 } -@@ -123,7 +123,7 @@ func.func @bitwise_xor_vector(%arg: vector<4xi32>) -> vector<4xi32> { +@@ -163,7 +163,7 @@ func.func @bitwise_xor_vector(%arg: vector<4xi32>) -> vector<4xi32> { // ----- func.func @bitwise_xor_float(%arg0: f16, %arg1: f16) -> f16 { @@ -531,7 +527,7 @@ index eeaa607b5604..78e2fffda755 100644 %0 = spirv.BitwiseXor %arg0, %arg1 : f16 return %0 : f16 } -@@ -149,7 +149,7 @@ func.func @bitwise_and_vector(%arg: vector<4xi32>) -> vector<4xi32> { +@@ -272,7 +272,7 @@ func.func @bitwise_and_zext_vector(%arg: vector<2xi8>) -> vector<2xi32> { // ----- func.func @bitwise_and_float(%arg0: f16, %arg1: f16) -> f16 { @@ -567,7 +563,7 @@ index 7dc0bd99f54b..5dd9901828cd 100644 return } diff --git a/mlir/test/Dialect/SPIRV/IR/ocl-ops.mlir b/mlir/test/Dialect/SPIRV/IR/ocl-ops.mlir -index 29a4a4613615..869de34c83b1 100644 +index 81ba471d3f51..2dbebb2db98e 100644 --- a/mlir/test/Dialect/SPIRV/IR/ocl-ops.mlir +++ b/mlir/test/Dialect/SPIRV/IR/ocl-ops.mlir @@ -27,7 +27,7 @@ func.func @exp(%arg0 : i32) -> () { @@ -682,4 +678,4 @@ index 9a2e4cf62e37..31a7f616d648 100644 // CHECK: spirv.CL.fma {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : f32 %13 = spirv.CL.fma %arg0, %arg1, %arg2 : f32 -- -2.42.0 +2.34.1 diff --git a/build_tools/patches/0002-Add-serialization-and-de-serialization-support-for-s.patch b/build_tools/patches/0002-Add-serialization-and-de-serialization-support-for-s.patch index 5bf2146f1..25f7a118e 100644 --- a/build_tools/patches/0002-Add-serialization-and-de-serialization-support-for-s.patch +++ b/build_tools/patches/0002-Add-serialization-and-de-serialization-support-for-s.patch @@ -4,12 +4,10 @@ Date: Mon, 24 Jul 2023 18:25:05 +0000 Subject: [PATCH 2/2] Add serialization and de-serialization support for several decorations. -Added decoratios: +Added decorations: - Alignment - DescriptorSet - FuncParamIOKindINTEL -- NoSignedWrap -- NoUnsignedWrap - SingleElementVectorINTEL - VectorComputeCallableFunctionINTEL - VectorComputeFunctionINTEL @@ -20,13 +18,13 @@ Added decoratios: 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp b/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp -index b84d1d9c2187..90416289134b 100644 +index 89e2e7ad52fa..f6bdc646f384 100644 --- a/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp +++ b/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp -@@ -242,8 +242,9 @@ LogicalResult spirv::Deserializer::processDecoration(ArrayRef words) { - auto attrName = llvm::convertToSnakeFromCamelCase(decorationName); - auto symbol = opBuilder.getStringAttr(attrName); - switch (static_cast(words[1])) { +@@ -251,8 +251,9 @@ LogicalResult spirv::Deserializer::processDecoration(ArrayRef words) { + symbol, FPFastMathModeAttr::get(opBuilder.getContext(), + static_cast(words[2]))); + break; - case spirv::Decoration::DescriptorSet: + case spirv::Decoration::Alignment: case spirv::Decoration::Binding: @@ -34,14 +32,10 @@ index b84d1d9c2187..90416289134b 100644 if (words.size() != 3) { return emitError(unknownLoc, "OpDecorate with ") << decorationName << " needs a single integer literal"; -@@ -295,8 +296,14 @@ LogicalResult spirv::Deserializer::processDecoration(ArrayRef words) { - case spirv::Decoration::NonReadable: - case spirv::Decoration::NonWritable: - case spirv::Decoration::NoPerspective: -+ case spirv::Decoration::NoSignedWrap: -+ case spirv::Decoration::NoUnsignedWrap: - case spirv::Decoration::Restrict: +@@ -308,6 +309,10 @@ LogicalResult spirv::Deserializer::processDecoration(ArrayRef words) { + case spirv::Decoration::NoUnsignedWrap: case spirv::Decoration::RelaxedPrecision: + case spirv::Decoration::Restrict: + case spirv::Decoration::SingleElementVectorINTEL: + case spirv::Decoration::VectorComputeCallableFunctionINTEL: + case spirv::Decoration::VectorComputeFunctionINTEL: @@ -49,7 +43,7 @@ index b84d1d9c2187..90416289134b 100644 if (words.size() != 2) { return emitError(unknownLoc, "OpDecoration with ") << decorationName << "needs a single target "; -@@ -307,6 +314,7 @@ LogicalResult spirv::Deserializer::processDecoration(ArrayRef words) { +@@ -318,6 +323,7 @@ LogicalResult spirv::Deserializer::processDecoration(ArrayRef words) { // it is needed for many validation rules. decorations[words[0]].set(symbol, opBuilder.getUnitAttr()); break; @@ -58,13 +52,13 @@ index b84d1d9c2187..90416289134b 100644 case spirv::Decoration::SpecId: if (words.size() != 3) { diff --git a/mlir/lib/Target/SPIRV/Serialization/Serializer.cpp b/mlir/lib/Target/SPIRV/Serialization/Serializer.cpp -index 1ef8ff043e69..988e60d08edf 100644 +index 9e9a16456cc1..b4d467f6656c 100644 --- a/mlir/lib/Target/SPIRV/Serialization/Serializer.cpp +++ b/mlir/lib/Target/SPIRV/Serialization/Serializer.cpp -@@ -231,8 +231,10 @@ LogicalResult Serializer::processDecoration(Location loc, uint32_t resultID, - args.push_back(static_cast(linkageType)); - break; - } +@@ -247,8 +247,10 @@ LogicalResult Serializer::processDecoration(Location loc, uint32_t resultID, + } + return emitError(loc, "expected FPFastMathModeAttr attribute for ") + << attrName; + case spirv::Decoration::Alignment: case spirv::Decoration::Binding: case spirv::Decoration::DescriptorSet: @@ -72,14 +66,10 @@ index 1ef8ff043e69..988e60d08edf 100644 case spirv::Decoration::Location: if (auto intAttr = dyn_cast(attr.getValue())) { args.push_back(intAttr.getValue().getZExtValue()); -@@ -255,8 +257,14 @@ LogicalResult Serializer::processDecoration(Location loc, uint32_t resultID, - case spirv::Decoration::NonReadable: - case spirv::Decoration::NonWritable: - case spirv::Decoration::NoPerspective: -+ case spirv::Decoration::NoSignedWrap: -+ case spirv::Decoration::NoUnsignedWrap: - case spirv::Decoration::Restrict: +@@ -275,6 +277,10 @@ LogicalResult Serializer::processDecoration(Location loc, uint32_t resultID, + case spirv::Decoration::NoUnsignedWrap: case spirv::Decoration::RelaxedPrecision: + case spirv::Decoration::Restrict: + case spirv::Decoration::SingleElementVectorINTEL: + case spirv::Decoration::VectorComputeCallableFunctionINTEL: + case spirv::Decoration::VectorComputeFunctionINTEL: diff --git a/build_tools/patches/0003-Update-the-Joint-Matrix-support-to-match-IGC-spec.patch b/build_tools/patches/0003-Update-the-Joint-Matrix-support-to-match-IGC-spec.patch index b659a2d33..c633b167a 100644 --- a/build_tools/patches/0003-Update-the-Joint-Matrix-support-to-match-IGC-spec.patch +++ b/build_tools/patches/0003-Update-the-Joint-Matrix-support-to-match-IGC-spec.patch @@ -16,7 +16,7 @@ https://github.com/MrSidims/llvm/blob/private/MrSidims/add-matrix-use/sycl/doc/d 7 files changed, 70 insertions(+), 28 deletions(-) diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td -index 1013cbc8ca56..4a374e713e3c 100644 +index ee1fbba1e284..d3e756c31889 100644 --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td @@ -4038,15 +4038,28 @@ def SPIRV_SamplerUseAttr: SPIRV_I32EnumAttr< @@ -58,11 +58,11 @@ index 1013cbc8ca56..4a374e713e3c 100644 // Cooperative Matrix Use for the SPV_KHR_cooperative_matrix extension. def SPIRV_KHR_CMU_MatrixA : I32EnumAttrCase<"MatrixA", 0>; diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVTypes.h b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVTypes.h -index 07f2f158ecab..e0b3c5448a44 100644 +index d946d936d4e6..0c08d7c083e5 100644 --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVTypes.h +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVTypes.h -@@ -459,7 +459,8 @@ public: - using Base::Base; +@@ -457,7 +457,8 @@ public: + static constexpr StringLiteral name = "spirv.jointmatrix"; static JointMatrixINTELType get(Type elementType, Scope scope, unsigned rows, - unsigned columns, MatrixLayout matrixLayout); @@ -71,7 +71,7 @@ index 07f2f158ecab..e0b3c5448a44 100644 Type getElementType() const; /// Return the scope of the joint matrix. -@@ -472,6 +473,9 @@ public: +@@ -470,6 +471,9 @@ public: /// return the layout of the matrix MatrixLayout getMatrixLayout() const; @@ -82,10 +82,10 @@ index 07f2f158ecab..e0b3c5448a44 100644 std::optional storage = std::nullopt); void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp -index a51d77dda78b..fa4cd8dc8447 100644 +index 8a68decc5878..00905c32f98a 100644 --- a/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp -@@ -392,7 +392,8 @@ static Type parseCooperativeMatrixNVType(SPIRVDialect const &dialect, +@@ -393,7 +393,8 @@ static Type parseCooperativeMatrixNVType(SPIRVDialect const &dialect, // joint-matrix-type ::= `!spirv.jointmatrix` `<`rows `x` columns `x` // element-type @@ -95,7 +95,7 @@ index a51d77dda78b..fa4cd8dc8447 100644 static Type parseJointMatrixType(SPIRVDialect const &dialect, DialectAsmParser &parser) { if (parser.parseLess()) -@@ -419,10 +420,14 @@ static Type parseJointMatrixType(SPIRVDialect const &dialect, +@@ -420,10 +421,14 @@ static Type parseJointMatrixType(SPIRVDialect const &dialect, if (parser.parseComma() || spirv::parseEnumKeywordAttr(scope, parser, "scope ")) return Type(); @@ -111,7 +111,7 @@ index a51d77dda78b..fa4cd8dc8447 100644 } // TODO: Reorder methods to be utilities first and parse*Type -@@ -926,7 +931,8 @@ static void print(JointMatrixINTELType type, DialectAsmPrinter &os) { +@@ -927,7 +932,8 @@ static void print(JointMatrixINTELType type, DialectAsmPrinter &os) { os << "jointmatrix<" << type.getRows() << "x" << type.getColumns() << "x"; os << type.getElementType() << ", " << stringifyMatrixLayout(type.getMatrixLayout()); @@ -122,7 +122,7 @@ index a51d77dda78b..fa4cd8dc8447 100644 static void print(MatrixType type, DialectAsmPrinter &os) { diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp -index 39d6603a46f9..57e4d5c8fb81 100644 +index f1bac6490837..7890f292a50a 100644 --- a/mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp @@ -336,7 +336,8 @@ void CooperativeMatrixNVType::getCapabilities( @@ -182,10 +182,10 @@ index 39d6603a46f9..57e4d5c8fb81 100644 SPIRVType::ExtensionArrayRefVector &extensions, std::optional storage) { diff --git a/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp b/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp -index ce8b3ab38946..a253d69c5267 100644 +index 89e2e7ad52fa..84e43ae858a6 100644 --- a/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp +++ b/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp -@@ -977,7 +977,7 @@ LogicalResult spirv::Deserializer::processCooperativeMatrixTypeNV( +@@ -988,7 +988,7 @@ LogicalResult spirv::Deserializer::processCooperativeMatrixTypeNV( LogicalResult spirv::Deserializer::processJointMatrixType(ArrayRef operands) { @@ -194,7 +194,7 @@ index ce8b3ab38946..a253d69c5267 100644 return emitError(unknownLoc, "OpTypeJointMatrix must have element " "type and row x column parameters"); } -@@ -988,6 +988,14 @@ spirv::Deserializer::processJointMatrixType(ArrayRef operands) { +@@ -999,6 +999,14 @@ spirv::Deserializer::processJointMatrixType(ArrayRef operands) { << operands[1]; } @@ -209,7 +209,7 @@ index ce8b3ab38946..a253d69c5267 100644 auto scope = spirv::symbolizeScope(getConstantInt(operands[5]).getInt()); if (!scope) { return emitError(unknownLoc, -@@ -998,14 +1006,15 @@ spirv::Deserializer::processJointMatrixType(ArrayRef operands) { +@@ -1009,14 +1017,15 @@ spirv::Deserializer::processJointMatrixType(ArrayRef operands) { spirv::symbolizeMatrixLayout(getConstantInt(operands[4]).getInt()); if (!matrixLayout) { return emitError(unknownLoc, @@ -229,20 +229,21 @@ index ce8b3ab38946..a253d69c5267 100644 } diff --git a/mlir/lib/Target/SPIRV/Serialization/Serializer.cpp b/mlir/lib/Target/SPIRV/Serialization/Serializer.cpp -index dad085e21b42..e030eb3767ad 100644 +index 9e9a16456cc1..412be6ac208d 100644 --- a/mlir/lib/Target/SPIRV/Serialization/Serializer.cpp +++ b/mlir/lib/Target/SPIRV/Serialization/Serializer.cpp -@@ -653,6 +653,8 @@ LogicalResult Serializer::prepareBasicType( - static_cast(jointMatrixType.getMatrixLayout()))); - operands.push_back( - getConstantOp(static_cast(jointMatrixType.getScope()))); -+ operands.push_back( +@@ -667,7 +667,8 @@ LogicalResult Serializer::prepareBasicType( + operands, elementTypeID, getConstantOp(jointMatrixType.getRows()), + getConstantOp(jointMatrixType.getColumns()), + getConstantOp(static_cast(jointMatrixType.getMatrixLayout())), +- getConstantOp(static_cast(jointMatrixType.getScope()))); ++ getConstantOp(static_cast(jointMatrixType.getScope())), + getConstantOp(static_cast(jointMatrixType.getMatrixUse()))); return success(); } diff --git a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp -index 9aeb14d14eec..4b273aa0f04a 100644 +index 9aeb14d14eec..d54b267bea47 100644 --- a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp +++ b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp @@ -523,7 +523,7 @@ static mlir::GenRegistration diff --git a/lib/Conversion/GPUXToLLVM/GPUXToLLVMPass.cpp b/lib/Conversion/GPUXToLLVM/GPUXToLLVMPass.cpp index 18f1efd9e..396a01185 100644 --- a/lib/Conversion/GPUXToLLVM/GPUXToLLVMPass.cpp +++ b/lib/Conversion/GPUXToLLVM/GPUXToLLVMPass.cpp @@ -98,22 +98,16 @@ class ConvertOpToGpuRuntimeCallPattern mlir::MLIRContext *context = &this->getTypeConverter()->getContext(); mlir::Type llvmVoidType = mlir::LLVM::LLVMVoidType::get(context); - mlir::Type llvmPointerType = - mlir::LLVM::LLVMPointerType::get(mlir::IntegerType::get(context, 8)); - mlir::Type llvmPointerPointerType = - mlir::LLVM::LLVMPointerType::get(llvmPointerType); + mlir::Type llvmPointerType = mlir::LLVM::LLVMPointerType::get(context); mlir::Type llvmInt8Type = mlir::IntegerType::get(context, 8); mlir::Type llvmInt32Type = mlir::IntegerType::get(context, 32); mlir::Type llvmInt64Type = mlir::IntegerType::get(context, 64); mlir::Type llvmIndexType = mlir::IntegerType::get( context, this->getTypeConverter()->getPointerBitwidth(0)); - mlir::Type llvmI32PtrType = mlir::LLVM::LLVMPointerType::get(llvmIndexType); - mlir::Type llvmRangeType = mlir::LLVM::LLVMStructType::getLiteral( context, {llvmPointerType, llvmIndexType}); - mlir::Type llvmRangePointerType = - mlir::LLVM::LLVMPointerType::get(llvmRangeType); + mlir::Type llvmRangePointerType = mlir::LLVM::LLVMPointerType::get(context); FunctionCallBuilder moduleLoadCallBuilder = { "gpuModuleLoad", @@ -346,7 +340,7 @@ class ConvertLaunchFuncOpToGpuRuntimeCallPattern return mlir::LLVM::createGlobalString( loc, builder, globalName, mlir::StringRef(kernelName.data(), kernelName.size()), - mlir::LLVM::Linkage::Internal, false); + mlir::LLVM::Linkage::Internal); } mlir::LogicalResult @@ -375,7 +369,7 @@ class ConvertLaunchFuncOpToGpuRuntimeCallPattern nameBuffer.append(kGpuBinaryStorageSuffix); mlir::Value data = mlir::LLVM::createGlobalString( loc, rewriter, nameBuffer.str(), binaryAttr.getValue(), - mlir::LLVM::Linkage::Internal, false); + mlir::LLVM::Linkage::Internal); auto size = rewriter.create( loc, llvmIndexType, @@ -414,7 +408,6 @@ class ConvertLaunchFuncOpToGpuRuntimeCallPattern auto paramsCount = static_cast(kernelParams.size()); auto paramsArrayType = mlir::LLVM::LLVMArrayType::get(llvmRangeType, paramsCount + 1); - auto paramsArrayPtrType = mlir::LLVM::LLVMPointerType::get(paramsArrayType); auto getKernelParamType = [&](unsigned i) -> mlir::Type { if (launchOp.getKernelOperands()[i].getType().isa()) { @@ -430,19 +423,19 @@ class ConvertLaunchFuncOpToGpuRuntimeCallPattern auto size = rewriter.create( loc, llvmInt64Type, rewriter.getI64IntegerAttr(1)); for (auto i : llvm::seq(0u, paramsCount)) { - auto ptrType = mlir::LLVM::LLVMPointerType::get(getKernelParamType(i)); - paramsStorage[i] = - rewriter.create(loc, ptrType, size, 0); + paramsStorage[i] = rewriter.create( + loc, llvmPointerType, getKernelParamType(i), size, 0); } - return rewriter.create(loc, paramsArrayPtrType, - size, 0); + return rewriter.create(loc, llvmPointerType, + paramsArrayType, size, 0); }); mlir::Value one = rewriter.create( loc, llvmInt32Type, rewriter.getI32IntegerAttr(1)); auto computeTypeSize = [&](mlir::Type type) -> mlir::Value { auto nullPtr = rewriter.create(loc, type); - auto gep = rewriter.create(loc, type, nullPtr, one); + auto gep = rewriter.create(loc, type, llvmPointerType, + nullPtr, one); return rewriter.create(loc, llvmIndexType, gep); }; @@ -615,8 +608,7 @@ void imex::populateGpuxToLLVMPatternsAndLegality( mlir::LLVMTypeConverter &converter, mlir::RewritePatternSet &patterns, mlir::ConversionTarget &target) { auto context = patterns.getContext(); - auto llvmPointerType = - mlir::LLVM::LLVMPointerType::get(mlir::IntegerType::get(context, 8)); + auto llvmPointerType = mlir::LLVM::LLVMPointerType::get(context); converter.addConversion( [llvmPointerType](imex::gpux::OpaqueType) -> mlir::Type { return llvmPointerType; diff --git a/lib/Dialect/XeTile/Transforms/XeTileTiling.cpp b/lib/Dialect/XeTile/Transforms/XeTileTiling.cpp index 2f60fd90c..eede559be 100644 --- a/lib/Dialect/XeTile/Transforms/XeTileTiling.cpp +++ b/lib/Dialect/XeTile/Transforms/XeTileTiling.cpp @@ -119,7 +119,7 @@ struct ArithConstantOpPattern // the direct user is an scf::ForOp, but the corresponding argument // is used by an xetile operator if (auto forOp = llvm::dyn_cast(owner)) { - auto arg = forOp.getRegionIterArgForOpOperand(op); + auto arg = forOp.getTiedLoopRegionIterArg(&op); auto haveXeTileUsers = std::any_of( arg.user_begin(), arg.user_end(), [&](mlir::Operation *op) { @@ -128,7 +128,7 @@ struct ArithConstantOpPattern if (auto yieldOp = llvm::dyn_cast( forOp.getRegion().front().getTerminator())) { - auto idx = forOp.getResultForOpOperand(op).getResultNumber(); + auto idx = forOp.getTiedLoopResult(&op).getResultNumber(); auto definingOp = yieldOp.getResults()[idx].getDefiningOp(); haveXeTileUsers |= llvm::isa(definingOp->getDialect()); diff --git a/lib/Utils/XeCommon.cpp b/lib/Utils/XeCommon.cpp index 4c47381ea..c86be8a78 100644 --- a/lib/Utils/XeCommon.cpp +++ b/lib/Utils/XeCommon.cpp @@ -70,7 +70,7 @@ static mlir::Value getOperandForArg(mlir::scf::ForOp &forOp, mlir::Value &value) { auto arg = llvm::dyn_cast_or_null(value); if (arg && arg.getArgNumber() >= forOp.getNumInductionVars()) { - auto &iterOperand = forOp.getOpOperandForRegionIterArg(arg); + auto &iterOperand = *forOp.getTiedLoopInit(arg); auto numCtrlOperands = forOp.getNumControlOperands(); auto operandIdx = iterOperand.getOperandNumber(); return forOp.getInitArgs()[operandIdx - numCtrlOperands]; diff --git a/test/Conversion/GPUXToLLVM/alloc-dealloc-to-gpu-runtime.mlir b/test/Conversion/GPUXToLLVM/alloc-dealloc-to-gpu-runtime.mlir index a0816f6cc..1c4aa55d9 100644 --- a/test/Conversion/GPUXToLLVM/alloc-dealloc-to-gpu-runtime.mlir +++ b/test/Conversion/GPUXToLLVM/alloc-dealloc-to-gpu-runtime.mlir @@ -3,13 +3,13 @@ module attributes {gpu.container_module}{ // CHECK-LABEL: llvm.func @main func.func @main() attributes {llvm.emit_c_interface} { - // CHECK: %[[DEVICE:.*]] = llvm.mlir.zero : !llvm.ptr - // CHECK: %[[CONTEXT:.*]] = llvm.mlir.zero : !llvm.ptr - // CHECK: %[[STREAM:.*]] = llvm.call @gpuCreateStream(%[[DEVICE:.*]], %[[CONTEXT:.*]]) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + // CHECK: %[[DEVICE:.*]] = llvm.mlir.zero : !llvm.ptr + // CHECK: %[[CONTEXT:.*]] = llvm.mlir.zero : !llvm.ptr + // CHECK: %[[STREAM:.*]] = llvm.call @gpuCreateStream(%[[DEVICE:.*]], %[[CONTEXT:.*]]) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr %0 = "gpux.create_stream"() : () -> !gpux.StreamType - // CHECK: llvm.call @gpuMemAlloc(%[[stream:.*]], %{{.*}}, %{{.*}}, %{{.*}}) : (!llvm.ptr, i64, i64, i32) -> !llvm.ptr + // CHECK: llvm.call @gpuMemAlloc(%[[stream:.*]], %{{.*}}, %{{.*}}, %{{.*}}) : (!llvm.ptr, i64, i64, i32) -> !llvm.ptr %memref = "gpux.alloc"(%0) {operandSegmentSizes = array} : (!gpux.StreamType) -> memref<8xf32> - // CHECK: llvm.call @gpuMemFree(%[[stream:.*]], %{{.*}}) : (!llvm.ptr, !llvm.ptr) -> () + // CHECK: llvm.call @gpuMemFree(%[[stream:.*]], %{{.*}}) : (!llvm.ptr, !llvm.ptr) -> () "gpux.dealloc"(%0, %memref) : (!gpux.StreamType, memref<8xf32>) -> () "gpux.destroy_stream"(%0) : (!gpux.StreamType) -> () return diff --git a/test/Conversion/GPUXToLLVM/create-destroy-stream.mlir b/test/Conversion/GPUXToLLVM/create-destroy-stream.mlir index eb09f2ef1..1c5d8696b 100644 --- a/test/Conversion/GPUXToLLVM/create-destroy-stream.mlir +++ b/test/Conversion/GPUXToLLVM/create-destroy-stream.mlir @@ -3,11 +3,11 @@ module attributes {gpu.container_module}{ // CHECK-LABEL: llvm.func @main func.func @main() attributes {llvm.emit_c_interface} { - // CHECK: %[[DEVICE:.*]] = llvm.mlir.zero : !llvm.ptr - // CHECK: %[[CONTEXT:.*]] = llvm.mlir.zero : !llvm.ptr - // CHECK: %[[STREAM:.*]] = llvm.call @gpuCreateStream(%[[DEVICE:.*]], %[[CONTEXT:.*]]) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + // CHECK: %[[DEVICE:.*]] = llvm.mlir.zero : !llvm.ptr + // CHECK: %[[CONTEXT:.*]] = llvm.mlir.zero : !llvm.ptr + // CHECK: %[[STREAM:.*]] = llvm.call @gpuCreateStream(%[[DEVICE:.*]], %[[CONTEXT:.*]]) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr %0 = "gpux.create_stream"() : () -> !gpux.StreamType - // CHECK: llvm.call @gpuStreamDestroy(%[[STREAM:.*]]) : (!llvm.ptr) -> () + // CHECK: llvm.call @gpuStreamDestroy(%[[STREAM:.*]]) : (!llvm.ptr) "gpux.destroy_stream"(%0) : (!gpux.StreamType) -> () return } diff --git a/test/Conversion/GPUXToLLVM/launch-func-to-gpu-runtime.mlir b/test/Conversion/GPUXToLLVM/launch-func-to-gpu-runtime.mlir index f582a169d..f5ae9d357 100644 --- a/test/Conversion/GPUXToLLVM/launch-func-to-gpu-runtime.mlir +++ b/test/Conversion/GPUXToLLVM/launch-func-to-gpu-runtime.mlir @@ -6,19 +6,19 @@ module attributes {gpu.container_module, spirv.target_env = #spirv.target_env<#s func.func @main() attributes {llvm.emit_c_interface} { %c1 = arith.constant 1 : index %c8 = arith.constant 8 : index - // CHECK: %[[DEVICE:.*]] = llvm.mlir.zero : !llvm.ptr - // CHECK: %[[CONTEXT:.*]] = llvm.mlir.zero : !llvm.ptr - // CHECK: %[[STREAM:.*]] = llvm.call @gpuCreateStream(%[[DEVICE:.*]], %[[CONTEXT:.*]]) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr + // CHECK: %[[DEVICE:.*]] = llvm.mlir.zero : !llvm.ptr + // CHECK: %[[CONTEXT:.*]] = llvm.mlir.zero : !llvm.ptr + // CHECK: %[[STREAM:.*]] = llvm.call @gpuCreateStream(%[[DEVICE:.*]], %[[CONTEXT:.*]]) : (!llvm.ptr, !llvm.ptr) -> !llvm.ptr %0 = "gpux.create_stream"() : () -> !gpux.StreamType %memref = "gpux.alloc"(%0) {operandSegmentSizes = array} : (!gpux.StreamType) -> memref<8xf32> %memref_0 = "gpux.alloc"(%0) {operandSegmentSizes = array} : (!gpux.StreamType) -> memref<8xf32> %memref_1 = "gpux.alloc"(%0) {operandSegmentSizes = array} : (!gpux.StreamType) -> memref<8xf32> - // CHECK: llvm.mlir.addressof @Kernels_spirv_binary : !llvm.ptr> - // CHECK: %[[MODULE:.*]] = llvm.call @gpuModuleLoad(%[[STREAM:.*]], %{{.*}}, %{{.*}}) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr - // CHECK: llvm.mlir.addressof @Kernels_kernel_1_kernel_name : !llvm.ptr> - // CHECK: %[[KERNEL:.*]] = llvm.call @gpuKernelGet(%[[STREAM:.*]], %[[MODULE:.*]], %{{.*}}) : (!llvm.ptr, !llvm.ptr, !llvm.ptr) -> !llvm.ptr - // CHECK: llvm.call @gpuLaunchKernel(%[[STREAM:.*]], %[[KERNEL:.*]], %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) : (!llvm.ptr, !llvm.ptr, i64, i64, i64, i64, i64, i64, i32, !llvm.ptr, i64)>>) -> () + // CHECK: llvm.mlir.addressof @Kernels_spirv_binary : !llvm.ptr + // CHECK: %[[MODULE:.*]] = llvm.call @gpuModuleLoad(%[[STREAM:.*]], %{{.*}}, %{{.*}}) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr + // CHECK: llvm.mlir.addressof @Kernels_kernel_1_kernel_name : !llvm.ptr + // CHECK: %[[KERNEL:.*]] = llvm.call @gpuKernelGet(%[[STREAM:.*]], %[[MODULE:.*]], %{{.*}}) : (!llvm.ptr, !llvm.ptr, !llvm.ptr) -> !llvm.ptr + // CHECK: llvm.call @gpuLaunchKernel(%[[STREAM:.*]], %[[KERNEL:.*]], %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) : (!llvm.ptr, !llvm.ptr, i64, i64, i64, i64, i64, i64, i32, !llvm.ptr) -> () "gpux.launch_func"(%0, %c8, %c1, %c1, %c1, %c1, %c1, %memref, %memref_0, %memref_1) {kernel = @Kernels::@kernel_1, operandSegmentSizes = array} : (!gpux.StreamType, index, index, index, index, index, index, memref<8xf32>, memref<8xf32>, memref<8xf32>) -> () "gpux.dealloc"(%0, %memref) : (!gpux.StreamType, memref<8xf32>) -> () "gpux.dealloc"(%0, %memref_0) : (!gpux.StreamType, memref<8xf32>) -> ()