Skip to content

Commit 19b23a2

Browse files
[MLIR][AMDGPU] Replace isGfx940Series with an equality check for gfx942,
since gfx940 and gfx941 are no longer supported. Signed-off-by: Mirza Halilcevic <[email protected]>
1 parent 5bace46 commit 19b23a2

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

mlir/include/mlir/Dialect/AMDGPU/Utils/Chipset.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ struct Chipset {
4949
#undef DEFINE_COMP_OPERATOR
5050
};
5151

52-
inline bool isGfx940Series(const Chipset &chipset) {
53-
return chipset.majorVersion == 9 && chipset.minorVersion == 4;
54-
}
5552
inline bool hasOcpFp8(const Chipset &chipset) {
5653
return (chipset.majorVersion == 9 && chipset.minorVersion >= 5) ||
5754
chipset.majorVersion >= 12;

mlir/lib/Conversion/AMDGPUToROCDL/AMDGPUToROCDL.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -477,14 +477,14 @@ static void wmmaPushOutputOperand(ConversionPatternRewriter &rewriter,
477477
/// Return true if `type` is the E5M2 variant of an 8-bit float that is
478478
/// supported by the `_bf8` instructions on the given `chipset`.
479479
static bool typeIsExpectedBf8ForChipset(Chipset chipset, Type type) {
480-
return (isGfx940Series(chipset) && isa<Float8E5M2FNUZType>(type)) ||
480+
return (chipset == kGfx942 && isa<Float8E5M2FNUZType>(type)) ||
481481
(hasOcpFp8(chipset) && isa<Float8E5M2Type>(type));
482482
}
483483

484484
/// Return true if `type` is the E4M3FN variant of an 8-bit float that is
485485
/// supported by the `_fp8` instructions on the given `chipset`.
486486
static bool typeIsExpectedFp8ForChipset(Chipset chipset, Type type) {
487-
return (isGfx940Series(chipset) && isa<Float8E4M3FNUZType>(type)) ||
487+
return (chipset == kGfx942 && isa<Float8E4M3FNUZType>(type)) ||
488488
(hasOcpFp8(chipset) && isa<Float8E4M3FNType>(type));
489489
}
490490

@@ -793,7 +793,7 @@ LogicalResult ExtPackedFp8OpLowering::matchAndRewrite(
793793
ExtPackedFp8Op op, ExtPackedFp8OpAdaptor adaptor,
794794
ConversionPatternRewriter &rewriter) const {
795795
Location loc = op.getLoc();
796-
if (!(isGfx940Series(chipset) || hasOcpFp8(chipset)))
796+
if (!(chipset == kGfx942 || hasOcpFp8(chipset)))
797797
return rewriter.notifyMatchFailure(
798798
loc, "Fp8 conversion instructions are not available on target "
799799
"architecture and their emulation is not implemented");
@@ -837,7 +837,7 @@ LogicalResult PackedTrunc2xFp8OpLowering::matchAndRewrite(
837837
PackedTrunc2xFp8Op op, PackedTrunc2xFp8OpAdaptor adaptor,
838838
ConversionPatternRewriter &rewriter) const {
839839
Location loc = op.getLoc();
840-
if (!(isGfx940Series(chipset) || hasOcpFp8(chipset)))
840+
if (!(chipset == kGfx942 || hasOcpFp8(chipset)))
841841
return rewriter.notifyMatchFailure(
842842
loc, "Fp8 conversion instructions are not available on target "
843843
"architecture and their emulation is not implemented");
@@ -874,7 +874,7 @@ LogicalResult PackedStochRoundFp8OpLowering::matchAndRewrite(
874874
PackedStochRoundFp8Op op, PackedStochRoundFp8OpAdaptor adaptor,
875875
ConversionPatternRewriter &rewriter) const {
876876
Location loc = op.getLoc();
877-
if (!(isGfx940Series(chipset) || hasOcpFp8(chipset)))
877+
if (!(chipset == kGfx942 || hasOcpFp8(chipset)))
878878
return rewriter.notifyMatchFailure(
879879
loc, "Fp8 conversion instructions are not available on target "
880880
"architecture and their emulation is not implemented");

mlir/lib/Conversion/ArithToAMDGPU/ArithToAMDGPU.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ using namespace mlir;
3030
using namespace mlir::amdgpu;
3131

3232
namespace {
33+
// Define commonly used chipsets versions for convenience.
34+
constexpr Chipset kGfx942 = Chipset(9, 4, 2);
35+
3336
struct ArithToAMDGPUConversionPass final
3437
: impl::ArithToAMDGPUConversionPassBase<ArithToAMDGPUConversionPass> {
3538
using impl::ArithToAMDGPUConversionPassBase<
@@ -73,7 +76,7 @@ struct TruncfToFloat16RewritePattern final
7376
} // end namespace
7477

7578
static LogicalResult isSupportedF8(Type elementType, Chipset chipset) {
76-
if (isGfx940Series(chipset))
79+
if (chipset == kGfx942)
7780
return success(isa<Float8E4M3FNUZType, Float8E5M2FNUZType>(elementType));
7881
if (hasOcpFp8(chipset))
7982
return success(isa<Float8E4M3FNType, Float8E5M2Type>(elementType));
@@ -397,7 +400,7 @@ void ArithToAMDGPUConversionPass::runOnOperation() {
397400
}
398401

399402
bool convertFP8Arithmetic =
400-
isGfx940Series(*maybeChipset) || hasOcpFp8(*maybeChipset);
403+
*maybeChipset == kGfx942 || hasOcpFp8(*maybeChipset);
401404
arith::populateArithToAMDGPUConversionPatterns(
402405
patterns, convertFP8Arithmetic, saturateFP8Truncf, allowPackedF16Rtz,
403406
*maybeChipset);

0 commit comments

Comments
 (0)