[Mlir-commits] [mlir] [mlir][gpu] Clean GPU `Passes.h` from external SPIRV includes (PR #71331)
Fabian Mora
llvmlistbot at llvm.org
Sun Nov 5 13:03:06 PST 2023
https://github.com/fabianmcg created https://github.com/llvm/llvm-project/pull/71331
Removes the `SPIRVAttributes.h` header from `GPU/Transforms/Passes.h`
>From 0ae07040cedf9c17ef6e811ac9434fc014187e6e Mon Sep 17 00:00:00 2001
From: Fabian Mora <fmora.dev at gmail.com>
Date: Sun, 5 Nov 2023 20:56:35 +0000
Subject: [PATCH] [mlir][gpu] Clean GPU `Passes.h` from external includes
Removes the `SPIRVAttributes.h` header from `gpu/Passes.h`.
---
mlir/include/mlir/Dialect/GPU/Transforms/Passes.h | 1 -
mlir/include/mlir/Dialect/GPU/Transforms/Passes.td | 2 +-
.../lib/Dialect/GPU/Transforms/SPIRVAttachTarget.cpp | 3 +++
mlir/test/Dialect/GPU/spirv-attach-targets.mlir | 12 ++++++------
4 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/mlir/include/mlir/Dialect/GPU/Transforms/Passes.h b/mlir/include/mlir/Dialect/GPU/Transforms/Passes.h
index 42fa46b0a57bdee..2a891a7d24f809a 100644
--- a/mlir/include/mlir/Dialect/GPU/Transforms/Passes.h
+++ b/mlir/include/mlir/Dialect/GPU/Transforms/Passes.h
@@ -15,7 +15,6 @@
#include "Utils.h"
#include "mlir/Dialect/GPU/IR/GPUDialect.h"
-#include "mlir/Dialect/SPIRV/IR/SPIRVAttributes.h"
#include "mlir/Pass/Pass.h"
#include <optional>
diff --git a/mlir/include/mlir/Dialect/GPU/Transforms/Passes.td b/mlir/include/mlir/Dialect/GPU/Transforms/Passes.td
index b22d26d49dbdb0e..059893127295bf5 100644
--- a/mlir/include/mlir/Dialect/GPU/Transforms/Passes.td
+++ b/mlir/include/mlir/Dialect/GPU/Transforms/Passes.td
@@ -227,7 +227,7 @@ def GpuSPIRVAttachTarget: Pass<"spirv-attach-target", ""> {
/*default=*/ "\"Unknown\"",
"Device Type">,
Option<"deviceId", "device_id", "uint32_t",
- /*default=*/ "mlir::spirv::TargetEnvAttr::kUnknownDeviceID",
+ /*default=*/ "",
"Device ID">,
];
}
diff --git a/mlir/lib/Dialect/GPU/Transforms/SPIRVAttachTarget.cpp b/mlir/lib/Dialect/GPU/Transforms/SPIRVAttachTarget.cpp
index eece62b9c6cb9c8..a099a44f3dc6aa6 100644
--- a/mlir/lib/Dialect/GPU/Transforms/SPIRVAttachTarget.cpp
+++ b/mlir/lib/Dialect/GPU/Transforms/SPIRVAttachTarget.cpp
@@ -57,6 +57,9 @@ void SPIRVAttachTarget::runOnOperation() {
auto deviceTypeSymbol = symbolizeDeviceType(deviceType);
if (!deviceTypeSymbol)
return signalPassFailure();
+ // Set the default device ID if none was given
+ if (!deviceId.hasValue())
+ deviceId = mlir::spirv::TargetEnvAttr::kUnknownDeviceID;
Version version = versionSymbol.value();
SmallVector<Capability, 4> capabilities;
diff --git a/mlir/test/Dialect/GPU/spirv-attach-targets.mlir b/mlir/test/Dialect/GPU/spirv-attach-targets.mlir
index 2ab748834e49fac..766a1bae8abc239 100644
--- a/mlir/test/Dialect/GPU/spirv-attach-targets.mlir
+++ b/mlir/test/Dialect/GPU/spirv-attach-targets.mlir
@@ -1,16 +1,16 @@
-// RUN: mlir-opt %s --spirv-attach-target='module=spirv.* ver=v1.0 caps=Kernel' | FileCheck %s
-// RUN: mlir-opt %s --spirv-attach-target='module=spirv_warm.* ver=v1.0 caps=Kernel' | FileCheck %s --check-prefix=CHECK_WARM
+// RUN: mlir-opt %s --spirv-attach-target='module=spirv.* ver=v1.0 caps=Kernel vendor=Intel device_type=Other' | FileCheck %s
+// RUN: mlir-opt %s --spirv-attach-target='module=spirv_warm.* ver=v1.0 caps=Kernel vendor=Intel device_type=Other device_id=0' | FileCheck %s --check-prefix=CHECK_WARM
module attributes {gpu.container_module} {
-// CHECK: @spirv_hot_module [#spirv.target_env<#spirv.vce<v1.0, [Kernel], []>, #spirv.resource_limits<>>]
+// CHECK: @spirv_hot_module [#spirv.target_env<#spirv.vce<v1.0, [Kernel], []>, Intel:Other, #spirv.resource_limits<>>]
// CHECK_WARM: @spirv_hot_module {
gpu.module @spirv_hot_module {
}
-// CHECK: @spirv_warm_module [#spirv.target_env<#spirv.vce<v1.0, [Kernel], []>, #spirv.resource_limits<>>]
-// CHECK_WARM: @spirv_warm_module [#spirv.target_env<#spirv.vce<v1.0, [Kernel], []>, #spirv.resource_limits<>>]
+// CHECK: @spirv_warm_module [#spirv.target_env<#spirv.vce<v1.0, [Kernel], []>, Intel:Other, #spirv.resource_limits<>>]
+// CHECK_WARM: @spirv_warm_module [#spirv.target_env<#spirv.vce<v1.0, [Kernel], []>, Intel:Other:0, #spirv.resource_limits<>>]
gpu.module @spirv_warm_module {
}
-// CHECK: @spirv_cold_module [#spirv.target_env<#spirv.vce<v1.0, [Kernel], []>, #spirv.resource_limits<>>]
+// CHECK: @spirv_cold_module [#spirv.target_env<#spirv.vce<v1.0, [Kernel], []>, Intel:Other, #spirv.resource_limits<>>]
// CHECK_WARM: @spirv_cold_module {
gpu.module @spirv_cold_module {
}
More information about the Mlir-commits
mailing list