Skip to content

Commit 2080340

Browse files
committed
[mlir][mlir-vulkan-runner] Move part of device pass pipeline to mlir-opt
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 290a111 commit 2080340

File tree

17 files changed

+86
-52
lines changed

17 files changed

+86
-52
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: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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 {
40+
namespace test {
41+
void registerTestVulkanRunnerPipeline() {
42+
PassPipelineRegistration<>(
43+
"test-vulkan-runner-pipeline",
44+
"Runs a series of passes for lowering GPU-dialect MLIR to "
45+
"SPIR-V-dialect MLIR intended for mlir-vulkan-runner.",
46+
buildTestVulkanRunnerPipeline);
47+
}
48+
} // namespace test
49+
} // namespace mlir

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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
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 \
4+
// RUN: mlir-opt %s -test-vulkan-runner-pipeline \
5+
// RUN: | mlir-vulkan-runner - \
56
// RUN: --shared-libs=%vulkan-runtime-wrappers,%mlir_runner_utils \
67
// RUN: --entry-point-result=void | FileCheck %s
78

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

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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
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 \
4+
// RUN: mlir-opt %s -test-vulkan-runner-pipeline \
5+
// RUN: | mlir-vulkan-runner - \
56
// RUN: --shared-libs=%vulkan-runtime-wrappers,%mlir_runner_utils \
67
// RUN: --entry-point-result=void | FileCheck %s
78

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

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)