Add gpu dialect to the dependency of CUDA target (#6988) Also remove gpu dialect loading from Vulkan Dialect and register it in Vulkan target instead
diff --git a/iree/compiler/Dialect/HAL/Target/CUDA/BUILD b/iree/compiler/Dialect/HAL/Target/CUDA/BUILD index 41236c5..b68b448 100644 --- a/iree/compiler/Dialect/HAL/Target/CUDA/BUILD +++ b/iree/compiler/Dialect/HAL/Target/CUDA/BUILD
@@ -55,6 +55,7 @@ "@llvm-project//llvm:NVPTXCodeGen", "@llvm-project//llvm:Support", "@llvm-project//llvm:Target", + "@llvm-project//mlir:GPUDialect", "@llvm-project//mlir:LLVMDialect", "@llvm-project//mlir:LLVMToLLVMIRTranslation", "@llvm-project//mlir:NVVMDialect",
diff --git a/iree/compiler/Dialect/HAL/Target/CUDA/CMakeLists.txt b/iree/compiler/Dialect/HAL/Target/CUDA/CMakeLists.txt index c290659..41e5302 100644 --- a/iree/compiler/Dialect/HAL/Target/CUDA/CMakeLists.txt +++ b/iree/compiler/Dialect/HAL/Target/CUDA/CMakeLists.txt
@@ -47,6 +47,7 @@ LLVMNVPTXCodeGen LLVMSupport LLVMTarget + MLIRGPUOps MLIRLLVMIR MLIRLLVMToLLVMIRTranslation MLIRNVVMIR
diff --git a/iree/compiler/Dialect/HAL/Target/CUDA/CUDATarget.cpp b/iree/compiler/Dialect/HAL/Target/CUDA/CUDATarget.cpp index f5cf691..8d63e0a 100644 --- a/iree/compiler/Dialect/HAL/Target/CUDA/CUDATarget.cpp +++ b/iree/compiler/Dialect/HAL/Target/CUDA/CUDATarget.cpp
@@ -23,6 +23,7 @@ #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/IPO/Internalize.h" #include "llvm/Transforms/IPO/PassManagerBuilder.h" +#include "mlir/Dialect/GPU/GPUDialect.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/Pass/PassManager.h" #include "mlir/Support/LogicalResult.h" @@ -141,6 +142,7 @@ std::string name() const override { return "cuda"; } void getDependentDialects(DialectRegistry ®istry) const override { + registry.insert<gpu::GPUDialect>(); mlir::registerLLVMDialectTranslation(registry); mlir::registerNVVMDialectTranslation(registry); }
diff --git a/iree/compiler/Dialect/HAL/Target/MetalSPIRV/MetalSPIRVTarget.cpp b/iree/compiler/Dialect/HAL/Target/MetalSPIRV/MetalSPIRVTarget.cpp index 4e91e1c..ed74c70 100644 --- a/iree/compiler/Dialect/HAL/Target/MetalSPIRV/MetalSPIRVTarget.cpp +++ b/iree/compiler/Dialect/HAL/Target/MetalSPIRV/MetalSPIRVTarget.cpp
@@ -44,7 +44,7 @@ std::string name() const override { return "metal"; } void getDependentDialects(DialectRegistry ®istry) const override { - registry.insert<spirv::SPIRVDialect>(); + registry.insert<spirv::SPIRVDialect, gpu::GPUDialect>(); } IREE::HAL::DeviceTargetAttr getDefaultDeviceTarget(
diff --git a/iree/compiler/Dialect/HAL/Target/VulkanSPIRV/VulkanSPIRVTarget.cpp b/iree/compiler/Dialect/HAL/Target/VulkanSPIRV/VulkanSPIRVTarget.cpp index b95257e..49b983d 100644 --- a/iree/compiler/Dialect/HAL/Target/VulkanSPIRV/VulkanSPIRVTarget.cpp +++ b/iree/compiler/Dialect/HAL/Target/VulkanSPIRV/VulkanSPIRVTarget.cpp
@@ -119,7 +119,8 @@ std::string name() const override { return "vulkan"; } void getDependentDialects(DialectRegistry ®istry) const override { - registry.insert<Vulkan::VulkanDialect, spirv::SPIRVDialect>(); + registry + .insert<Vulkan::VulkanDialect, spirv::SPIRVDialect, gpu::GPUDialect>(); } IREE::HAL::DeviceTargetAttr getDefaultDeviceTarget(
diff --git a/iree/compiler/Dialect/Vulkan/IR/BUILD b/iree/compiler/Dialect/Vulkan/IR/BUILD index e9b0cae..94ff990 100644 --- a/iree/compiler/Dialect/Vulkan/IR/BUILD +++ b/iree/compiler/Dialect/Vulkan/IR/BUILD
@@ -46,7 +46,6 @@ ":VulkanEnumsGen", "//iree/compiler/Dialect/Util/IR", "@llvm-project//llvm:Support", - "@llvm-project//mlir:GPUDialect", "@llvm-project//mlir:IR", "@llvm-project//mlir:SPIRVDialect", "@llvm-project//mlir:Support",
diff --git a/iree/compiler/Dialect/Vulkan/IR/CMakeLists.txt b/iree/compiler/Dialect/Vulkan/IR/CMakeLists.txt index 24522ea..00108a7 100644 --- a/iree/compiler/Dialect/Vulkan/IR/CMakeLists.txt +++ b/iree/compiler/Dialect/Vulkan/IR/CMakeLists.txt
@@ -29,7 +29,6 @@ ::VulkanAttrsGen ::VulkanEnumsGen LLVMSupport - MLIRGPUOps MLIRIR MLIRSPIRV MLIRSupport
diff --git a/iree/compiler/Dialect/Vulkan/IR/VulkanDialect.cpp b/iree/compiler/Dialect/Vulkan/IR/VulkanDialect.cpp index 23d011e..1bf5081 100644 --- a/iree/compiler/Dialect/Vulkan/IR/VulkanDialect.cpp +++ b/iree/compiler/Dialect/Vulkan/IR/VulkanDialect.cpp
@@ -10,7 +10,6 @@ #include "iree/compiler/Dialect/Vulkan/IR/VulkanTypes.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/SMLoc.h" -#include "mlir/Dialect/GPU/GPUDialect.h" #include "mlir/Dialect/SPIRV/IR/SPIRVAttributes.h" #include "mlir/IR/Builders.h" #include "mlir/IR/DialectImplementation.h" @@ -22,7 +21,6 @@ VulkanDialect::VulkanDialect(MLIRContext *context) : Dialect(getDialectNamespace(), context, TypeID::get<VulkanDialect>()) { - context->loadDialect<gpu::GPUDialect>(); registerAttributes(); }