[Mlir-commits] [mlir] 4263068 - [mlir][gpu] Clean GPU `Passes.h` from external SPIRV includes (#71331)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sun Nov 5 17:06:07 PST 2023


Author: Fabian Mora
Date: 2023-11-05T17:06:04-08:00
New Revision: 42630689e2b8366769e7dd2e0ec9801d230065a2

URL: https://github.com/llvm/llvm-project/commit/42630689e2b8366769e7dd2e0ec9801d230065a2
DIFF: https://github.com/llvm/llvm-project/commit/42630689e2b8366769e7dd2e0ec9801d230065a2.diff

LOG: [mlir][gpu] Clean GPU `Passes.h` from external SPIRV includes (#71331)

Removes the `SPIRVAttributes.h` header from `GPU/Transforms/Passes.h`

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/GPU/Transforms/Passes.h
    mlir/include/mlir/Dialect/GPU/Transforms/Passes.td
    mlir/lib/Dialect/GPU/Transforms/SPIRVAttachTarget.cpp
    mlir/test/Dialect/GPU/spirv-attach-targets.mlir

Removed: 
    


################################################################################
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