[Mlir-commits] [mlir] [MLIR][GPUToLLVMSPV] Update ConvertGpuOpsToLLVMSPVOps's option (PR #118818)
Jefferson Le Quellec
llvmlistbot at llvm.org
Thu Dec 5 07:09:08 PST 2024
https://github.com/jle-quel created https://github.com/llvm/llvm-project/pull/118818
## Description
This PR updates the ConvertGpuOpsToLLVMSPVOps's option by replacing the `index-bitwidth` with a boolean option `use-64bit-index` (similar to the `ConvertGPUToSPIRV` option).
The reason for this modification is because the `ConvertGpuOpsToLLVMSPVOps`:
> Generate LLVM operations to be ingested by a SPIR-V backend for gpu operations
In the context of SPIR-V specifications only two physical addressing models are allowed: `Physical32` and `Physical64`.
This change guarantees output sanity by preventing invalid or unsupported index bitwidths from being specified.
>From af6dab159d31e4916402cf0a998b99b940fe0cc8 Mon Sep 17 00:00:00 2001
From: Jefferson Le Quellec <jefferson.lequellec at codeplay.com>
Date: Thu, 5 Dec 2024 15:15:47 +0100
Subject: [PATCH 1/3] Replace indexBitwidth by use64bitIndex for
ConvertGpuOpsToLLVMSPVOps
---
mlir/include/mlir/Conversion/Passes.td | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/mlir/include/mlir/Conversion/Passes.td b/mlir/include/mlir/Conversion/Passes.td
index d722bd1f3e296a..8835e0a9099fdd 100644
--- a/mlir/include/mlir/Conversion/Passes.td
+++ b/mlir/include/mlir/Conversion/Passes.td
@@ -553,9 +553,9 @@ def ConvertGpuOpsToLLVMSPVOps : Pass<"convert-gpu-to-llvm-spv", "gpu::GPUModuleO
"Generate LLVM operations to be ingested by a SPIR-V backend for gpu operations";
let dependentDialects = ["LLVM::LLVMDialect"];
let options = [
- Option<"indexBitwidth", "index-bitwidth", "unsigned",
- /*default=kDeriveIndexBitwidthFromDataLayout*/"0",
- "Bitwidth of the index type, 0 to use size of machine word">,
+ Option<"use64bitIndex", "use-64bit-index",
+ "bool", /*default=*/"false",
+ "Use 64-bit integers to convert index types">,
];
}
>From cb8793366d7cef275cb920035e5cab948d4d2535 Mon Sep 17 00:00:00 2001
From: Jefferson Le Quellec <jefferson.lequellec at codeplay.com>
Date: Thu, 5 Dec 2024 15:15:58 +0100
Subject: [PATCH 2/3] Override indexBitwidth with use64bitIndex
---
mlir/lib/Conversion/GPUToLLVMSPV/GPUToLLVMSPV.cpp | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/mlir/lib/Conversion/GPUToLLVMSPV/GPUToLLVMSPV.cpp b/mlir/lib/Conversion/GPUToLLVMSPV/GPUToLLVMSPV.cpp
index 03745f4537e99e..a68c0153df4432 100644
--- a/mlir/lib/Conversion/GPUToLLVMSPV/GPUToLLVMSPV.cpp
+++ b/mlir/lib/Conversion/GPUToLLVMSPV/GPUToLLVMSPV.cpp
@@ -409,9 +409,7 @@ struct GPUToLLVMSPVConversionPass final
RewritePatternSet patterns(context);
LowerToLLVMOptions options(context);
- if (indexBitwidth != kDeriveIndexBitwidthFromDataLayout)
- options.overrideIndexBitwidth(indexBitwidth);
-
+ options.overrideIndexBitwidth(this->use64bitIndex ? 64 : 32);
LLVMTypeConverter converter(context, options);
LLVMConversionTarget target(*context);
>From e3b0df5b6cf556304c1a3ebab28bc92323f11a04 Mon Sep 17 00:00:00 2001
From: Jefferson Le Quellec <jefferson.lequellec at codeplay.com>
Date: Thu, 5 Dec 2024 15:16:06 +0100
Subject: [PATCH 3/3] Update gpu-to-llvm-spv tests
---
mlir/test/Conversion/GPUToLLVMSPV/gpu-to-llvm-spv.mlir | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/mlir/test/Conversion/GPUToLLVMSPV/gpu-to-llvm-spv.mlir b/mlir/test/Conversion/GPUToLLVMSPV/gpu-to-llvm-spv.mlir
index 16b692b9689398..e75225d6d54f55 100644
--- a/mlir/test/Conversion/GPUToLLVMSPV/gpu-to-llvm-spv.mlir
+++ b/mlir/test/Conversion/GPUToLLVMSPV/gpu-to-llvm-spv.mlir
@@ -1,6 +1,8 @@
-// RUN: mlir-opt -pass-pipeline="builtin.module(gpu.module(convert-gpu-to-llvm-spv))" -split-input-file -verify-diagnostics %s \
+// RUN: mlir-opt -pass-pipeline="builtin.module(gpu.module(convert-gpu-to-llvm-spv{use-64bit-index=true}))" -split-input-file -verify-diagnostics %s \
// RUN: | FileCheck --check-prefixes=CHECK-64,CHECK %s
-// RUN: mlir-opt -pass-pipeline="builtin.module(gpu.module(convert-gpu-to-llvm-spv{index-bitwidth=32}))" -split-input-file -verify-diagnostics %s \
+// RUN: mlir-opt -pass-pipeline="builtin.module(gpu.module(convert-gpu-to-llvm-spv))" -split-input-file -verify-diagnostics %s \
+// RUN: | FileCheck --check-prefixes=CHECK-32,CHECK %s
+// RUN: mlir-opt -pass-pipeline="builtin.module(gpu.module(convert-gpu-to-llvm-spv{use-64bit-index=false}))" -split-input-file -verify-diagnostics %s \
// RUN: | FileCheck --check-prefixes=CHECK-32,CHECK %s
gpu.module @builtins {
More information about the Mlir-commits
mailing list