Skip to content

Commit 4c816f8

Browse files
authored
[Pipeline][GPUToSPIRV][LevelZeroRuntimeWrappers] Use upstream pipeline for VC path. (#1124)
[Pipeline][GPUToSPIRV][LevelZeroRuntimeWrappers] Use upstream pipeline for VC path. - Add a one-shot SPIR-V conversion pass (ConvertToSPIRV). It combines upstream and downstream patterns. - Modify pass pipeline to for host and gpu code lowering. - Modify test cases to use upstream level-zero-runtime. Remove `spirv.target_env` from individual test cases. Use SPIRVAttatchTarget pass to set `targetEnv`. More details are available in internal issue: 1205, 1206, 1239.
1 parent 0f7569d commit 4c816f8

File tree

157 files changed

+9328
-11959
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+9328
-11959
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//===- ConvertToSPIRV.h - Converts everything to SPIR-V dialect - *-C++ -*-===//
2+
//
3+
// Copyright 2025 Intel Corporation
4+
// Part of the IMEX Project, under the Apache License v2.0 with LLVM Exceptions.
5+
// See https://llvm.org/LICENSE.txt for license information.
6+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
#ifndef IMEX_CONVERSION_CONVERTTOSPIRV_H
11+
#define IMEX_CONVERSION_CONVERTTOSPIRV_H
12+
13+
#include "imex/Utils/XeCommon.h"
14+
#include "mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h"
15+
#include "mlir/IR/Operation.h"
16+
#include "mlir/Pass/Pass.h"
17+
#include "mlir/Transforms/DialectConversion.h"
18+
19+
namespace mlir {
20+
class ConversionTarget;
21+
class SPIRVTypeConverter;
22+
class Pass;
23+
class Operation;
24+
class RewritePatternSet;
25+
template <typename T> class OperationPass;
26+
} // namespace mlir
27+
28+
namespace imex {
29+
#define GEN_PASS_DECL_CONVERTTOSPIRV
30+
#include "imex/Conversion/Passes.h.inc"
31+
32+
std::unique_ptr<::mlir::OperationPass<::mlir::ModuleOp>>
33+
createConvertToSPIRVPass();
34+
35+
} // namespace imex
36+
#endif

include/imex/Conversion/Passes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "mlir/Pass/Pass.h"
1919

2020
#include <imex/Conversion/ArithToVC/ArithToVC.h>
21+
#include <imex/Conversion/ConvertToSPIRV/ConvertToSPIRV.h>
2122
#include <imex/Conversion/DropRegions/DropRegions.h>
2223
#include <imex/Conversion/GPUToGPUX/GPUToGPUX.h>
2324
#include <imex/Conversion/GPUToSPIRV/GPUToSPIRVPass.h>

include/imex/Conversion/Passes.td

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,43 @@ memref, arith and math.
258258
let dependentDialects = ["::mlir::spirv::SPIRVDialect"];
259259
}
260260

261+
262+
//===----------------------------------------------------------------------===//
263+
// ConvertToSPIRV
264+
//===----------------------------------------------------------------------===//
265+
266+
def ConvertToSPIRV : Pass<"imex-convert-to-spirv", "::mlir::ModuleOp"> {
267+
let summary = "Convert to SPIR-V dialect by using all the 'to SPIR-V' conversion patterns from all the dialect conversions";
268+
let description = [{
269+
This is a one-shot pass to convert to SPIR-V dialect by using all the 'to SPIR-V' conversion patterns from all the dialect conversions.
270+
It includes the GPU to SPIR-V conversion as well as other dialects like SCF, Math, Arith etc.
271+
272+
}];
273+
let dependentDialects = ["::mlir::spirv::SPIRVDialect"];
274+
let constructor = "imex::createConvertToSPIRVPass()";
275+
let options = [
276+
// arith, cf, func, tensor to SPIR-V options
277+
Option<"emulateLT32BitScalarTypes", "emulate-lt-32-bit-scalar-types",
278+
"bool", /*default=*/"true",
279+
"Emulate narrower scalar types with 32-bit ones if not supported by "
280+
"the target">,
281+
Option<"emulateUnsupportedFloatTypes", "emulate-unsupported-float-types",
282+
"bool", /*default=*/"true",
283+
"Emulate unsupported float types by representing them with integer "
284+
"types of same bit width">,
285+
// gpu, Index to SPIR-V options
286+
Option<"use64bitIndex", "use-64bit-index",
287+
"bool", /*default=*/"false",
288+
"Use 64-bit integers to convert index types">,
289+
// memref to SPIR-V options
290+
Option<"boolNumBits", "bool-num-bits",
291+
"int", /*default=*/"8",
292+
"The number of bits to store a boolean value">,
293+
294+
];
295+
}
296+
297+
261298
//===----------------------------------------------------------------------===//
262299
// GPUToGPUX
263300
//===----------------------------------------------------------------------===//

lib/Conversion/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
add_subdirectory(ArithToVC)
2+
add_subdirectory(ConvertToSPIRV)
23
add_subdirectory(NDArrayToLinalg)
34
add_subdirectory(DropRegions)
45
add_subdirectory(RegionParallelLoopToGpu)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
add_imex_conversion_library(IMEXConvertToSPIRV
2+
ConvertToSPIRVPass.cpp
3+
4+
ADDITIONAL_HEADER_DIRS
5+
${MLIR_MAIN_INCLUDE_DIR}/imex/Conversion/ConvertToSPIRV
6+
7+
DEPENDS
8+
IMEXConversionPassIncGen
9+
10+
LINK_LIBS PUBLIC
11+
MLIRArithToSPIRV
12+
MLIRControlFlowToSPIRV
13+
MLIRFuncToSPIRV
14+
MLIRGPUDialect
15+
MLIRGPUToSPIRV
16+
MLIRIR
17+
MLIRMathToSPIRV
18+
MLIRPass
19+
MLIRSCFToSPIRV
20+
MLIRSPIRVDialect
21+
MLIRSPIRVConversion
22+
MLIRSupport
23+
MLIRTransforms
24+
)

0 commit comments

Comments
 (0)