Skip to content

Commit 9735873

Browse files
authored
[mlir][mlir-vulkan-runner] Move part of device pass pipeline to mlir-opt (#119372)
Adds a new mlir-opt test-only pass, -test-vulkan-runner-pipeline, which runs a set of passes needed for mlir-vulkan-runner, and removes them from the runner. The tests are changed to invoke mlir-opt with this flag before invoking the runner. The passes moved are ones concerned with lowering of the device code prior to serialization to SPIR-V. This is an incremental step towards moving the entire pipeline to mlir-opt, to align with other runners (see #73457).
1 parent 8ca4aa5 commit 9735873

17 files changed

+102
-70
lines changed

mlir/test/lib/Pass/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ add_mlir_library(MLIRTestPass
44
TestDynamicPipeline.cpp
55
TestPassManager.cpp
66
TestSPIRVCPURunnerPipeline.cpp
7+
TestVulkanRunnerPipeline.cpp
78

89
EXCLUDE_FROM_LIBMLIR
910

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//===------------------ TestVulkanRunnerPipeline.cpp --------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// Implements a pipeline for use by mlir-vulkan-runner tests.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#include "mlir/Conversion/ConvertToSPIRV/ConvertToSPIRVPass.h"
14+
#include "mlir/Conversion/GPUToSPIRV/GPUToSPIRVPass.h"
15+
#include "mlir/Dialect/GPU/Transforms/Passes.h"
16+
#include "mlir/Dialect/MemRef/Transforms/Passes.h"
17+
#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
18+
#include "mlir/Dialect/SPIRV/Transforms/Passes.h"
19+
#include "mlir/Pass/PassManager.h"
20+
21+
using namespace mlir;
22+
23+
namespace {
24+
25+
void buildTestVulkanRunnerPipeline(OpPassManager &passManager) {
26+
passManager.addPass(createGpuKernelOutliningPass());
27+
passManager.addPass(memref::createFoldMemRefAliasOpsPass());
28+
29+
ConvertToSPIRVPassOptions convertToSPIRVOptions{};
30+
convertToSPIRVOptions.convertGPUModules = true;
31+
passManager.addPass(createConvertToSPIRVPass(convertToSPIRVOptions));
32+
OpPassManager &modulePM = passManager.nest<spirv::ModuleOp>();
33+
modulePM.addPass(spirv::createSPIRVLowerABIAttributesPass());
34+
modulePM.addPass(spirv::createSPIRVUpdateVCEPass());
35+
}
36+
37+
} // namespace
38+
39+
namespace mlir::test {
40+
void registerTestVulkanRunnerPipeline() {
41+
PassPipelineRegistration<>(
42+
"test-vulkan-runner-pipeline",
43+
"Runs a series of passes for lowering GPU-dialect MLIR to "
44+
"SPIR-V-dialect MLIR intended for mlir-vulkan-runner.",
45+
buildTestVulkanRunnerPipeline);
46+
}
47+
} // namespace mlir::test

mlir/test/mlir-vulkan-runner/addf.mlir

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: mlir-vulkan-runner %s --shared-libs=%vulkan-runtime-wrappers,%mlir_runner_utils --entry-point-result=void | FileCheck %s
1+
// RUN: mlir-opt %s -test-vulkan-runner-pipeline \
2+
// RUN: | mlir-vulkan-runner - --shared-libs=%vulkan-runtime-wrappers,%mlir_runner_utils --entry-point-result=void | FileCheck %s
23

34
// CHECK: [3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3]
45
module attributes {

mlir/test/mlir-vulkan-runner/addf_if.mlir

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: mlir-vulkan-runner %s --shared-libs=%vulkan-runtime-wrappers,%mlir_runner_utils --entry-point-result=void | FileCheck %s
1+
// RUN: mlir-opt %s -test-vulkan-runner-pipeline \
2+
// RUN: | mlir-vulkan-runner - --shared-libs=%vulkan-runtime-wrappers,%mlir_runner_utils --entry-point-result=void | FileCheck %s
23

34
// CHECK: [3.3, 3.3, 3.3, 3.3, 0, 0, 0, 0]
45
module attributes {

mlir/test/mlir-vulkan-runner/addi.mlir

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: mlir-vulkan-runner %s --shared-libs=%vulkan-runtime-wrappers,%mlir_runner_utils --entry-point-result=void | FileCheck %s
1+
// RUN: mlir-opt %s -test-vulkan-runner-pipeline \
2+
// RUN: | mlir-vulkan-runner - --shared-libs=%vulkan-runtime-wrappers,%mlir_runner_utils --entry-point-result=void | FileCheck %s
23

34
// CHECK-COUNT-64: [3, 3, 3, 3, 3, 3, 3, 3]
45
module attributes {

mlir/test/mlir-vulkan-runner/addi8.mlir

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: mlir-vulkan-runner %s --shared-libs=%vulkan-runtime-wrappers,%mlir_runner_utils --entry-point-result=void | FileCheck %s
1+
// RUN: mlir-opt %s -test-vulkan-runner-pipeline \
2+
// RUN: | mlir-vulkan-runner - --shared-libs=%vulkan-runtime-wrappers,%mlir_runner_utils --entry-point-result=void | FileCheck %s
23

34
// CHECK-COUNT-64: [3, 3, 3, 3, 3, 3, 3, 3]
45
module attributes {

mlir/test/mlir-vulkan-runner/addui_extended.mlir

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
// Make sure that addition with carry produces expected results
22
// with and without expansion to primitive add/cmp ops for WebGPU.
33

4-
// RUN: mlir-vulkan-runner %s \
5-
// RUN: --shared-libs=%vulkan-runtime-wrappers,%mlir_runner_utils \
6-
// RUN: --entry-point-result=void | FileCheck %s
4+
// RUN: mlir-opt %s -test-vulkan-runner-pipeline \
5+
// RUN: | mlir-vulkan-runner - \
6+
// RUN: --shared-libs=%vulkan-runtime-wrappers,%mlir_runner_utils \
7+
// RUN: --entry-point-result=void | FileCheck %s
78

8-
// RUN: mlir-vulkan-runner %s --vulkan-runner-spirv-webgpu-prepare \
9-
// RUN: --shared-libs=%vulkan-runtime-wrappers,%mlir_runner_utils \
10-
// RUN: --entry-point-result=void | FileCheck %s
9+
// RUN: mlir-opt %s -test-vulkan-runner-pipeline -spirv-webgpu-prepare \
10+
// RUN: | mlir-vulkan-runner - \
11+
// RUN: --shared-libs=%vulkan-runtime-wrappers,%mlir_runner_utils \
12+
// RUN: --entry-point-result=void | FileCheck %s
1113

1214
// CHECK: [0, 42, 0, 42]
1315
// CHECK: [1, 0, 1, 1]

mlir/test/mlir-vulkan-runner/mulf.mlir

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: mlir-vulkan-runner %s --shared-libs=%vulkan-runtime-wrappers,%mlir_runner_utils --entry-point-result=void | FileCheck %s
1+
// RUN: mlir-opt %s -test-vulkan-runner-pipeline \
2+
// RUN: | mlir-vulkan-runner - --shared-libs=%vulkan-runtime-wrappers,%mlir_runner_utils --entry-point-result=void | FileCheck %s
23

34
// CHECK-COUNT-4: [6, 6, 6, 6]
45
module attributes {

mlir/test/mlir-vulkan-runner/smul_extended.mlir

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
// Make sure that signed extended multiplication produces expected results
22
// with and without expansion to primitive mul/add ops for WebGPU.
33

4-
// RUN: mlir-vulkan-runner %s \
5-
// RUN: --shared-libs=%vulkan-runtime-wrappers,%mlir_runner_utils \
6-
// RUN: --entry-point-result=void | FileCheck %s
4+
// RUN: mlir-opt %s -test-vulkan-runner-pipeline \
5+
// RUN: | mlir-vulkan-runner - \
6+
// RUN: --shared-libs=%vulkan-runtime-wrappers,%mlir_runner_utils \
7+
// RUN: --entry-point-result=void | FileCheck %s
78

8-
// RUN: mlir-vulkan-runner %s --vulkan-runner-spirv-webgpu-prepare \
9-
// RUN: --shared-libs=%vulkan-runtime-wrappers,%mlir_runner_utils \
10-
// RUN: --entry-point-result=void | FileCheck %s
9+
// RUN: mlir-opt %s -test-vulkan-runner-pipeline -spirv-webgpu-prepare \
10+
// RUN: | mlir-vulkan-runner - \
11+
// RUN: --shared-libs=%vulkan-runtime-wrappers,%mlir_runner_utils \
12+
// RUN: --entry-point-result=void | FileCheck %s
1113

1214
// CHECK: [0, 1, -2, 1, 1048560, -87620295, -131071, 560969770]
1315
// CHECK: [0, 0, -1, 0, 0, -1, 0, -499807318]

mlir/test/mlir-vulkan-runner/subf.mlir

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: mlir-vulkan-runner %s --shared-libs=%vulkan-runtime-wrappers,%mlir_runner_utils --entry-point-result=void | FileCheck %s
1+
// RUN: mlir-opt %s -test-vulkan-runner-pipeline \
2+
// RUN: | mlir-vulkan-runner - --shared-libs=%vulkan-runtime-wrappers,%mlir_runner_utils --entry-point-result=void | FileCheck %s
23

34
// CHECK-COUNT-32: [2.2, 2.2, 2.2, 2.2]
45
module attributes {

0 commit comments

Comments
 (0)