From 51425ea0678d51b24b394b55ab7037180b02fb56 Mon Sep 17 00:00:00 2001 From: "Levytskyy, Vyacheslav" Date: Wed, 29 Jan 2025 06:19:07 -0800 Subject: [PATCH] apply code review suggestions --- .../intel/lib/Target/SPIRV/CMakeLists.txt | 34 +++++++++---------- .../lib/Target/SPIRV/SPIRVTranslation.cpp | 15 ++++++++ 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/third_party/intel/lib/Target/SPIRV/CMakeLists.txt b/third_party/intel/lib/Target/SPIRV/CMakeLists.txt index ebd011bb3f..2179f3cab8 100644 --- a/third_party/intel/lib/Target/SPIRV/CMakeLists.txt +++ b/third_party/intel/lib/Target/SPIRV/CMakeLists.txt @@ -8,30 +8,30 @@ if(spirv_present_result) message(STATUS "Found SPIR-V Backend") add_compile_definitions(LLVM_SPIRV_BACKEND_TARGET_PRESENT) add_mlir_translation_library(TritonSPIRV - SPIRVTranslation.cpp + SPIRVTranslation.cpp - LINK_COMPONENTS - Core - # spirv backend - SPIRVCodeGen + LINK_COMPONENTS + Core + # spirv backend + SPIRVCodeGen - LINK_LIBS PUBLIC - TritonLLVMIR - # spirv tools - LLVMSPIRVLib + LINK_LIBS PUBLIC + TritonLLVMIR + # spirv tools + LLVMSPIRVLib ) else() add_mlir_translation_library(TritonSPIRV - SPIRVTranslation.cpp + SPIRVTranslation.cpp - LINK_COMPONENTS - Core + LINK_COMPONENTS + Core - LINK_LIBS PUBLIC - TritonLLVMIR - # spirv tools - LLVMSPIRVLib -) + LINK_LIBS PUBLIC + TritonLLVMIR + # spirv tools + LLVMSPIRVLib + ) endif() # Add SPIRV-LLVM-Translator include directory. diff --git a/third_party/intel/lib/Target/SPIRV/SPIRVTranslation.cpp b/third_party/intel/lib/Target/SPIRV/SPIRVTranslation.cpp index 7d96c70710..f1ef4f717e 100644 --- a/third_party/intel/lib/Target/SPIRV/SPIRVTranslation.cpp +++ b/third_party/intel/lib/Target/SPIRV/SPIRVTranslation.cpp @@ -19,6 +19,21 @@ namespace llvm { using namespace llvm; using namespace SPIRV; +// TODO: The LLVM SPIR-V backend API has changed in +// https://github.com/llvm/llvm-project/pull/124745 to improve the way SPIR-V +// Backend API works with user facing options and allow for multithreading +// within the host application. This PR in llvm-project breaks existing API +// contract in how options are being interpreted inside the call, and we need to +// update this file accordingly. After this change is visible in the LLVM +// version from cmake/llvm-hash.txt we will need to update the call to +// SPIRVTranslateModule(M, Result, ErrMsg, AllowExtNames, Opts) in a style of +// SPIRVTranslate(M, Result, ErrMsg, {"all"}, CodeGenOptLevel::Aggressive, +// Triple("spirv64v1.6-unknown-unknown")). + +// The LLVM SPIR-V backend exposes an API call that translates LLVM module to +// SPIR-V and writes results into a string as binary SPIR-V output, providing +// diagnostics on fail and means of configuring translation +// (https://github.com/llvm/llvm-project/pull/107216). extern "C" bool SPIRVTranslateModule(Module *M, std::string &SpirvObj, std::string &ErrMsg, const std::vector &AllowExtNames,