Skip to content

[SYCL-MLIR]: Add convert-spirv-builtin-to-nvvm Pass #19101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: sycl-mlir
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//===- SPIRVBuiltInToNVVM.h - SPIRVBuiltIn to NVVM Patterns
//-----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// Provides patterns to convert SPIRVBuiltIn dialect to NVVM dialect.
//
//===----------------------------------------------------------------------===//

#ifndef MLIR_CONVERSION_SPIRVBUILTINTONVVM_SPIRVBUILTINTONVVM_H
#define MLIR_CONVERSION_SPIRVBUILTINTONVVM_SPIRVBUILTINTONVVM_H

#include <memory>

namespace mlir {
class Pass;

#define GEN_PASS_DECL_CONVERTSPIRVBUILTINTONVVM
#include "mlir/Conversion/SYCLPasses.h.inc"
#undef GEN_PASS_DECL_CONVERTSPIRVBUILTINTONVVM

} // namespace mlir

#endif // MLIR_CONVERSION_SPIRVBUILTINTONVVM_SPIRVBUILTINTONVVM_H
1 change: 1 addition & 0 deletions mlir-sycl/include/mlir/Conversion/SYCLPasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef MLIR_CONVERSION_SYCLPASSES_H
#define MLIR_CONVERSION_SYCLPASSES_H

#include "mlir/Conversion/SPIRVBuiltInToNVVM/SPIRVBuiltInToNVVM.h"
#include "mlir/Conversion/SYCLToGPU/SYCLToGPU.h"
#include "mlir/Conversion/SYCLToLLVM/SYCLToLLVM.h"
#include "mlir/Conversion/SYCLToMath/SYCLToMath.h"
Expand Down
19 changes: 19 additions & 0 deletions mlir-sycl/include/mlir/Conversion/SYCLPasses.td
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,23 @@ def ConvertSYCLToMath : Pass<"convert-sycl-to-math", "ModuleOp"> {
];
}

//===----------------------------------------------------------------------===//
// SPIRVBuiltInToNVVM
//===----------------------------------------------------------------------===//

def ConvertSPIRVBuiltInToNVVM : Pass<"convert-spirv-builtin-to-nvvm", "ModuleOp"> {
let summary = "convert __spirv_BuiltIn access to NVVM intrinsics";
let description = [{
Pass to support SYCL-MLIR running on nvidia gpus.

This Pass will be used to modify the final mlir which only contains llvm dialect.
It enables the final MLIR to be converted into LLVM IR that can run on NVIDIA GPUs, mainly by doing two things:
1.Mark the kernel function
2.Replaces SPIR-V builtin global variables and accessor logic with direct NVVM intrinsic calls.
}];
let dependentDialects = [
"LLVM::LLVMDialect"
];
}

#endif // MLIR_CONVERSION_SYCLPASSES
1 change: 1 addition & 0 deletions mlir-sycl/lib/Conversion/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ add_subdirectory(SYCLToGPU)
add_subdirectory(SYCLToLLVM)
add_subdirectory(SYCLToMath)
add_subdirectory(SYCLToSPIRV)
add_subdirectory(SPIRVBuiltInToNVVM)
17 changes: 17 additions & 0 deletions mlir-sycl/lib/Conversion/SPIRVBuiltInToNVVM/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
add_mlir_conversion_library(MLIRSPIRVBuiltInToNVVM
SPIRVBuiltInToNVVM.cpp

ADDITIONAL_HEADER_DIRS
${MLIR_SYCL_SOURCE_DIR}/mlir/Conversion/SPIRVBuiltInToNVVM

DEPENDS
MLIRSYCLConversionPassIncGen

LINK_LIBS PUBLIC
MLIRLLVMDialect
MLIRIR
MLIRSYCLDialect
MLIRTransforms
MLIRVectorDialect
)

Loading