From a89edc69bb89f19a51afa83fc4ab73d9b27f68f9 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Fri, 24 Jan 2025 02:48:16 -0800 Subject: [PATCH 1/8] [SYCL] Link and include LLVM utility headers in SYCL library These changes propose that the SYCL runtime library privately links against LLVM to avoid the need for replicating common utility code. In the initial version we can use this to remove the property-set names, making it more safely consistent. These changes intend to aid the implementation of loading SYCL-based kernel binary files at runtime. Signed-off-by: Larsen, Steffen --- sycl/source/CMakeLists.txt | 8 +++- sycl/source/detail/compiler.hpp | 34 ---------------- sycl/source/detail/device_binary_image.cpp | 39 ++++++++++++------- sycl/source/detail/jit_compiler.cpp | 9 +++-- sycl/test/CMakeLists.txt | 1 + sycl/unittests/Extensions/DeviceGlobal.cpp | 6 ++- .../VirtualFunctions/RuntimeLinking.cpp | 5 ++- sycl/unittests/helpers/MockDeviceImage.hpp | 22 +++++++---- .../pipes/host_pipe_registration.cpp | 4 +- .../program_manager/CompileTarget.cpp | 4 +- .../DynamicLinking/DynamicLinking.cpp | 6 ++- .../arg_mask/EliminatedArgMask.cpp | 8 +++- .../passing_link_and_compile_options.cpp | 5 ++- 13 files changed, 81 insertions(+), 70 deletions(-) diff --git a/sycl/source/CMakeLists.txt b/sycl/source/CMakeLists.txt index d9f8801d45ba5..83107de1c3688 100644 --- a/sycl/source/CMakeLists.txt +++ b/sycl/source/CMakeLists.txt @@ -30,9 +30,7 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) if (SYCL_ENABLE_STACK_PRINTING) if(NOT MSVC OR (CMAKE_BUILD_TYPE STREQUAL "Debug" AND ARG_COMPILE_OPTIONS MATCHES ".*MDd.*") OR (NOT CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT ARG_COMPILE_OPTIONS MATCHES ".*MDd.*")) - add_dependencies(${LIB_NAME} LLVMSupport) target_compile_definitions(${LIB_OBJ_NAME} PUBLIC ENABLE_STACK_TRACE) - target_link_libraries(${LIB_NAME} PRIVATE LLVMSupport) endif() endif() @@ -147,6 +145,12 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) PRIVATE OpenCL-Headers ) + # Link with LLVMSupport and LLVMObject for shared utilities. + add_dependencies(${LIB_NAME} LLVMSupport LLVMObject) + target_include_directories(${LIB_NAME} PRIVATE ${LLVM_MAIN_INCLUDE_DIR}) + target_link_libraries(${LIB_NAME} PRIVATE LLVMSupport LLVMObject) + target_compile_definitions(${LIB_NAME} PRIVATE LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1) + if(SYCL_ENABLE_EXTENSION_JIT) if(NOT DEFINED LLVM_EXTERNAL_SYCL_JIT_SOURCE_DIR) message(FATAL_ERROR "Undefined LLVM_EXTERNAL_SYCL_JIT_SOURCE_DIR variable: Must be set when extension to JIT SYCL kernels is enabled") diff --git a/sycl/source/detail/compiler.hpp b/sycl/source/detail/compiler.hpp index 40bf97299138f..c6c16cc086e4c 100644 --- a/sycl/source/detail/compiler.hpp +++ b/sycl/source/detail/compiler.hpp @@ -35,40 +35,6 @@ #define __SYCL_DEVICE_BINARY_TARGET_LLVM_NVPTX64 "llvm_nvptx64" #define __SYCL_DEVICE_BINARY_TARGET_LLVM_AMDGCN "llvm_amdgcn" -/// Device binary image property set names recognized by the SYCL runtime. -/// Name must be consistent with -/// PropertySetRegistry::SYCL_SPECIALIZATION_CONSTANTS defined in -/// PropertySetIO.h -#define __SYCL_PROPERTY_SET_SPEC_CONST_MAP "SYCL/specialization constants" -/// PropertySetRegistry::SYCL_SPEC_CONSTANTS_DEFAULT_VALUES defined in -/// PropertySetIO.h -#define __SYCL_PROPERTY_SET_SPEC_CONST_DEFAULT_VALUES_MAP \ - "SYCL/specialization constants default values" -/// PropertySetRegistry::SYCL_DEVICELIB_REQ_MASK defined in PropertySetIO.h -#define __SYCL_PROPERTY_SET_DEVICELIB_REQ_MASK "SYCL/devicelib req mask" -/// PropertySetRegistry::SYCL_KERNEL_PARAM_OPT_INFO defined in PropertySetIO.h -#define __SYCL_PROPERTY_SET_KERNEL_PARAM_OPT_INFO "SYCL/kernel param opt" -/// PropertySetRegistry::SYCL_KERNEL_PROGRAM_METADATA defined in PropertySetIO.h -#define __SYCL_PROPERTY_SET_PROGRAM_METADATA "SYCL/program metadata" -/// PropertySetRegistry::SYCL_MISC_PROP defined in PropertySetIO.h -#define __SYCL_PROPERTY_SET_SYCL_MISC_PROP "SYCL/misc properties" -/// PropertySetRegistry::SYCL_ASSERT_USED defined in PropertySetIO.h -#define __SYCL_PROPERTY_SET_SYCL_ASSERT_USED "SYCL/assert used" -/// PropertySetRegistry::SYCL_EXPORTED_SYMBOLS defined in PropertySetIO.h -#define __SYCL_PROPERTY_SET_SYCL_EXPORTED_SYMBOLS "SYCL/exported symbols" -/// PropertySetRegistry::SYCL_IMPORTED_SYMBOLS defined in PropertySetIO.h -#define __SYCL_PROPERTY_SET_SYCL_IMPORTED_SYMBOLS "SYCL/imported symbols" -/// PropertySetRegistry::SYCL_DEVICE_GLOBALS defined in PropertySetIO.h -#define __SYCL_PROPERTY_SET_SYCL_DEVICE_GLOBALS "SYCL/device globals" -/// PropertySetRegistry::SYCL_DEVICE_REQUIREMENTS defined in PropertySetIO.h -#define __SYCL_PROPERTY_SET_SYCL_DEVICE_REQUIREMENTS "SYCL/device requirements" -/// PropertySetRegistry::SYCL_HOST_PIPES defined in PropertySetIO.h -#define __SYCL_PROPERTY_SET_SYCL_HOST_PIPES "SYCL/host pipes" -/// PropertySetRegistry::SYCL_VIRTUAL_FUNCTIONS defined in PropertySetIO.h -#define __SYCL_PROPERTY_SET_SYCL_VIRTUAL_FUNCTIONS "SYCL/virtual functions" -/// PropertySetRegistry::SYCL_IMPLICIT_LOCAL_ARG defined in PropertySetIO.h -#define __SYCL_PROPERTY_SET_SYCL_IMPLICIT_LOCAL_ARG "SYCL/implicit local arg" - /// Program metadata tags recognized by the PI backends. For kernels the tag /// must appear after the kernel name. #define __SYCL_PROGRAM_METADATA_TAG_REQD_WORK_GROUP_SIZE "@reqd_work_group_size" diff --git a/sycl/source/detail/device_binary_image.cpp b/sycl/source/detail/device_binary_image.cpp index 633a4269e1e78..c967216f753be 100644 --- a/sycl/source/detail/device_binary_image.cpp +++ b/sycl/source/detail/device_binary_image.cpp @@ -12,6 +12,8 @@ // For device image compression. #include +#include + #include #include #include @@ -147,7 +149,7 @@ void RTDeviceBinaryImage::dump(std::ostream &Out) const { sycl_device_binary_property RTDeviceBinaryImage::getProperty(const char *PropName) const { RTDeviceBinaryImage::PropertyRange BoolProp; - BoolProp.init(Bin, __SYCL_PROPERTY_SET_SYCL_MISC_PROP); + BoolProp.init(Bin, llvm::util::PropertySetRegistry::SYCL_MISC_PROP); if (!BoolProp.isAvailable()) return nullptr; auto It = std::find_if(BoolProp.begin(), BoolProp.end(), @@ -176,25 +178,34 @@ void RTDeviceBinaryImage::init(sycl_device_binary Bin) { // try to determine the format; may remain "NONE" Format = ur::getBinaryImageFormat(Bin->BinaryStart, getSize()); - SpecConstIDMap.init(Bin, __SYCL_PROPERTY_SET_SPEC_CONST_MAP); + SpecConstIDMap.init( + Bin, llvm::util::PropertySetRegistry::SYCL_SPECIALIZATION_CONSTANTS); SpecConstDefaultValuesMap.init( - Bin, __SYCL_PROPERTY_SET_SPEC_CONST_DEFAULT_VALUES_MAP); - DeviceLibReqMask.init(Bin, __SYCL_PROPERTY_SET_DEVICELIB_REQ_MASK); - KernelParamOptInfo.init(Bin, __SYCL_PROPERTY_SET_KERNEL_PARAM_OPT_INFO); - AssertUsed.init(Bin, __SYCL_PROPERTY_SET_SYCL_ASSERT_USED); - ImplicitLocalArg.init(Bin, __SYCL_PROPERTY_SET_SYCL_IMPLICIT_LOCAL_ARG); - ProgramMetadata.init(Bin, __SYCL_PROPERTY_SET_PROGRAM_METADATA); + Bin, llvm::util::PropertySetRegistry::SYCL_SPEC_CONSTANTS_DEFAULT_VALUES); + DeviceLibReqMask.init( + Bin, llvm::util::PropertySetRegistry::SYCL_DEVICELIB_REQ_MASK); + KernelParamOptInfo.init( + Bin, llvm::util::PropertySetRegistry::SYCL_KERNEL_PARAM_OPT_INFO); + AssertUsed.init(Bin, llvm::util::PropertySetRegistry::SYCL_ASSERT_USED); + ImplicitLocalArg.init( + Bin, llvm::util::PropertySetRegistry::SYCL_IMPLICIT_LOCAL_ARG); + ProgramMetadata.init(Bin, + llvm::util::PropertySetRegistry::SYCL_PROGRAM_METADATA); // Convert ProgramMetadata into the UR format for (const auto &Prop : ProgramMetadata) { ProgramMetadataUR.push_back( ur::mapDeviceBinaryPropertyToProgramMetadata(Prop)); } - ExportedSymbols.init(Bin, __SYCL_PROPERTY_SET_SYCL_EXPORTED_SYMBOLS); - ImportedSymbols.init(Bin, __SYCL_PROPERTY_SET_SYCL_IMPORTED_SYMBOLS); - DeviceGlobals.init(Bin, __SYCL_PROPERTY_SET_SYCL_DEVICE_GLOBALS); - DeviceRequirements.init(Bin, __SYCL_PROPERTY_SET_SYCL_DEVICE_REQUIREMENTS); - HostPipes.init(Bin, __SYCL_PROPERTY_SET_SYCL_HOST_PIPES); - VirtualFunctions.init(Bin, __SYCL_PROPERTY_SET_SYCL_VIRTUAL_FUNCTIONS); + ExportedSymbols.init(Bin, + llvm::util::PropertySetRegistry::SYCL_EXPORTED_SYMBOLS); + ImportedSymbols.init(Bin, + llvm::util::PropertySetRegistry::SYCL_IMPORTED_SYMBOLS); + DeviceGlobals.init(Bin, llvm::util::PropertySetRegistry::SYCL_DEVICE_GLOBALS); + DeviceRequirements.init( + Bin, llvm::util::PropertySetRegistry::SYCL_DEVICE_REQUIREMENTS); + HostPipes.init(Bin, llvm::util::PropertySetRegistry::SYCL_HOST_PIPES); + VirtualFunctions.init( + Bin, llvm::util::PropertySetRegistry::SYCL_VIRTUAL_FUNCTIONS); ImageId = ImageCounter++; } diff --git a/sycl/source/detail/jit_compiler.cpp b/sycl/source/detail/jit_compiler.cpp index e95b3ab2e58b8..c241b21b0761f 100644 --- a/sycl/source/detail/jit_compiler.cpp +++ b/sycl/source/detail/jit_compiler.cpp @@ -19,6 +19,8 @@ #include #include +#include + namespace sycl { inline namespace _V1 { namespace detail { @@ -1083,7 +1085,7 @@ sycl_device_binaries jit_compiler::createPIDeviceBinary( // Create a property set for the argument usage masks of all kernels // (currently only one). PropertySetContainer ArgMaskPropSet{ - __SYCL_PROPERTY_SET_KERNEL_PARAM_OPT_INFO}; + llvm::util::PropertySetRegistry::SYCL_KERNEL_PARAM_OPT_INFO}; ArgMaskPropSet.addProperty(std::move(ArgMaskProp)); @@ -1108,7 +1110,7 @@ sycl_device_binaries jit_compiler::createPIDeviceBinary( PropName.str(), Encoded.data(), Encoded.size(), sycl_property_type::SYCL_PROPERTY_TYPE_BYTE_ARRAY}; PropertySetContainer ProgramMetadata{ - __SYCL_PROPERTY_SET_PROGRAM_METADATA}; + llvm::util::PropertySetRegistry::SYCL_PROGRAM_METADATA}; ProgramMetadata.addProperty(std::move(ReqdWorkGroupSizeProp)); Binary.addProperty(std::move(ProgramMetadata)); } @@ -1116,7 +1118,8 @@ sycl_device_binaries jit_compiler::createPIDeviceBinary( if (Format == ::jit_compiler::BinaryFormat::AMDGCN) { PropertyContainer NeedFinalization{ __SYCL_PROGRAM_METADATA_TAG_NEED_FINALIZATION, 1}; - PropertySetContainer ProgramMetadata{__SYCL_PROPERTY_SET_PROGRAM_METADATA}; + PropertySetContainer ProgramMetadata{ + llvm::util::PropertySetRegistry::SYCL_PROGRAM_METADATA}; ProgramMetadata.addProperty(std::move(NeedFinalization)); Binary.addProperty(std::move(ProgramMetadata)); } diff --git a/sycl/test/CMakeLists.txt b/sycl/test/CMakeLists.txt index c0a02a874b962..5ec912eb29635 100644 --- a/sycl/test/CMakeLists.txt +++ b/sycl/test/CMakeLists.txt @@ -16,6 +16,7 @@ set(SYCL_THREADS_LIB ${CMAKE_THREAD_LIBS_INIT}) # TEST_INCLUDE_PATH is used for syntax-only verification of type information. list(APPEND test_includes ${SYCL_INCLUDE}) list(APPEND test_includes ${SYCL_SOURCE_DIR}/source) +list(APPEND test_includes ${LLVM_MAIN_INCLUDE_DIR}) list(APPEND test_includes ${BOOST_UNORDERED_INCLUDE_DIRS}) if(SYCL_ENABLE_EXTENSION_JIT) list(APPEND test_includes ${LLVM_EXTERNAL_SYCL_JIT_SOURCE_DIR}/jit-compiler/include) diff --git a/sycl/unittests/Extensions/DeviceGlobal.cpp b/sycl/unittests/Extensions/DeviceGlobal.cpp index 222970aa1d959..9c6af0db977ee 100644 --- a/sycl/unittests/Extensions/DeviceGlobal.cpp +++ b/sycl/unittests/Extensions/DeviceGlobal.cpp @@ -8,6 +8,8 @@ #include +#include + #include "detail/context_impl.hpp" #include "detail/kernel_program_cache.hpp" @@ -64,7 +66,7 @@ static sycl::unittest::MockDeviceImage generateDeviceGlobalImage() { MockPropertySet PropSet; MockProperty DevGlobInfo = makeDeviceGlobalInfo(DeviceGlobalName, sizeof(int) * 2, 0); - PropSet.insert(__SYCL_PROPERTY_SET_SYCL_DEVICE_GLOBALS, + PropSet.insert(llvm::util::PropertySetRegistry::SYCL_DEVICE_GLOBALS, std::vector{std::move(DevGlobInfo)}); std::vector Entries = @@ -87,7 +89,7 @@ static sycl::unittest::MockDeviceImage generateDeviceGlobalImgScopeImage() { MockPropertySet PropSet; MockProperty DevGlobInfo = makeDeviceGlobalInfo(DeviceGlobalImgScopeName, sizeof(int) * 2, 1); - PropSet.insert(__SYCL_PROPERTY_SET_SYCL_DEVICE_GLOBALS, + PropSet.insert(llvm::util::PropertySetRegistry::SYCL_DEVICE_GLOBALS, std::vector{std::move(DevGlobInfo)}); std::vector Entries = diff --git a/sycl/unittests/Extensions/VirtualFunctions/RuntimeLinking.cpp b/sycl/unittests/Extensions/VirtualFunctions/RuntimeLinking.cpp index 61e0c5f5f32a5..4c6c8b4c59c03 100644 --- a/sycl/unittests/Extensions/VirtualFunctions/RuntimeLinking.cpp +++ b/sycl/unittests/Extensions/VirtualFunctions/RuntimeLinking.cpp @@ -2,6 +2,8 @@ #include "ur_mock_helpers.hpp" #include +#include + #include #include #include @@ -65,7 +67,8 @@ generateImage(std::initializer_list KernelNames, SYCL_PROPERTY_TYPE_BYTE_ARRAY); Props.push_back(Prop); - PropSet.insert(__SYCL_PROPERTY_SET_SYCL_VIRTUAL_FUNCTIONS, std::move(Props)); + PropSet.insert(llvm::util::PropertySetRegistry::SYCL_VIRTUAL_FUNCTIONS, + std::move(Props)); std::vector Bin{Magic}; diff --git a/sycl/unittests/helpers/MockDeviceImage.hpp b/sycl/unittests/helpers/MockDeviceImage.hpp index fea80d6b08c3e..f56ffa5470e91 100644 --- a/sycl/unittests/helpers/MockDeviceImage.hpp +++ b/sycl/unittests/helpers/MockDeviceImage.hpp @@ -20,6 +20,8 @@ #include +#include + namespace sycl { inline namespace _V1 { namespace unittest { @@ -179,7 +181,8 @@ class MockPropertySet { // Value must be an all-zero 32-bit mask, which would mean that no fallback // libraries are needed to be loaded. MockProperty DeviceLibReqMask("", Data, SYCL_PROPERTY_TYPE_UINT32); - insert(__SYCL_PROPERTY_SET_DEVICELIB_REQ_MASK, std::move(DeviceLibReqMask)); + insert(llvm::util::PropertySetRegistry::SYCL_DEVICELIB_REQ_MASK, + std::move(DeviceLibReqMask)); } /// Adds a new property to the set. @@ -448,7 +451,8 @@ inline void setKernelUsesAssert(const std::vector &Names, std::vector Value; for (const std::string &N : Names) Value.push_back({N, {0, 0, 0, 0}, SYCL_PROPERTY_TYPE_UINT32}); - Set.insert(__SYCL_PROPERTY_SET_SYCL_ASSERT_USED, std::move(Value)); + Set.insert(llvm::util::PropertySetRegistry::SYCL_ASSERT_USED, + std::move(Value)); } /// Utility function to add specialization constants to property set. @@ -457,12 +461,14 @@ inline void setKernelUsesAssert(const std::vector &Names, inline void addSpecConstants(std::vector &&SpecConstants, std::vector ValData, MockPropertySet &Props) { - Props.insert(__SYCL_PROPERTY_SET_SPEC_CONST_MAP, std::move(SpecConstants)); + Props.insert(llvm::util::PropertySetRegistry::SYCL_SPECIALIZATION_CONSTANTS, + std::move(SpecConstants)); MockProperty Prop{"all", std::move(ValData), SYCL_PROPERTY_TYPE_BYTE_ARRAY}; - Props.insert(__SYCL_PROPERTY_SET_SPEC_CONST_DEFAULT_VALUES_MAP, - std::move(Prop)); + Props.insert( + llvm::util::PropertySetRegistry::SYCL_SPEC_CONSTANTS_DEFAULT_VALUES, + std::move(Prop)); } /// Utility function to add ESIMD kernel flag to property set. @@ -471,7 +477,8 @@ inline void addESIMDFlag(MockPropertySet &Props) { ValData[0] = 1; MockProperty Prop{"isEsimdImage", ValData, SYCL_PROPERTY_TYPE_UINT32}; - Props.insert(__SYCL_PROPERTY_SET_SYCL_MISC_PROP, std::move(Prop)); + Props.insert(llvm::util::PropertySetRegistry::SYCL_MISC_PROP, + std::move(Prop)); } /// Utility function to generate offload entries for kernels without arguments. @@ -584,7 +591,8 @@ addDeviceRequirementsProps(MockPropertySet &Props, std::vector Value{makeAspectsProp(Aspects)}; if (!ReqdWGSize.empty()) Value.push_back(makeReqdWGSizeProp(ReqdWGSize)); - Props.insert(__SYCL_PROPERTY_SET_SYCL_DEVICE_REQUIREMENTS, std::move(Value)); + Props.insert(llvm::util::PropertySetRegistry::SYCL_DEVICE_REQUIREMENTS, + std::move(Value)); } inline MockDeviceImage diff --git a/sycl/unittests/pipes/host_pipe_registration.cpp b/sycl/unittests/pipes/host_pipe_registration.cpp index c821ddf4e09e9..12054c5321b26 100644 --- a/sycl/unittests/pipes/host_pipe_registration.cpp +++ b/sycl/unittests/pipes/host_pipe_registration.cpp @@ -9,6 +9,8 @@ #include #include +#include + #include #include #include @@ -38,7 +40,7 @@ static sycl::unittest::MockDeviceImage generateDefaultImage() { MockPropertySet PropSet; MockProperty HostPipeInfo = makeHostPipeInfo("test_host_pipe_unique_id", sizeof(int)); - PropSet.insert(__SYCL_PROPERTY_SET_SYCL_HOST_PIPES, + PropSet.insert(llvm::util::PropertySetRegistry::SYCL_HOST_PIPES, std::vector{std::move(HostPipeInfo)}); std::vector Entries = makeEmptyKernels({"TestKernel"}); diff --git a/sycl/unittests/program_manager/CompileTarget.cpp b/sycl/unittests/program_manager/CompileTarget.cpp index f39e4d717c59e..e25e079770fa5 100644 --- a/sycl/unittests/program_manager/CompileTarget.cpp +++ b/sycl/unittests/program_manager/CompileTarget.cpp @@ -12,6 +12,8 @@ #include #include +#include + #include using namespace sycl; @@ -27,7 +29,7 @@ generateImageWithCompileTarget(std::string KernelName, MockProperty CompileTargetProperty("compile_target", Data, SYCL_PROPERTY_TYPE_BYTE_ARRAY); MockPropertySet PropSet; - PropSet.insert(__SYCL_PROPERTY_SET_SYCL_DEVICE_REQUIREMENTS, + PropSet.insert(llvm::util::PropertySetRegistry::SYCL_DEVICE_REQUIREMENTS, std::move(CompileTargetProperty)); std::vector Bin(CompileTarget.begin(), CompileTarget.end()); diff --git a/sycl/unittests/program_manager/DynamicLinking/DynamicLinking.cpp b/sycl/unittests/program_manager/DynamicLinking/DynamicLinking.cpp index c48a5c1626c69..8b278a0e18c89 100644 --- a/sycl/unittests/program_manager/DynamicLinking/DynamicLinking.cpp +++ b/sycl/unittests/program_manager/DynamicLinking/DynamicLinking.cpp @@ -1,5 +1,7 @@ #include +#include + #include #include #include @@ -76,10 +78,10 @@ generateImage(std::initializer_list KernelNames, const char *DeviceTargetSpec, sycl::unittest::MockPropertySet PropSet) { if (!ExportedSymbols.empty()) - PropSet.insert(__SYCL_PROPERTY_SET_SYCL_EXPORTED_SYMBOLS, + PropSet.insert(llvm::util::PropertySetRegistry::SYCL_EXPORTED_SYMBOLS, createPropertySet(ExportedSymbols)); if (!ImportedSymbols.empty()) - PropSet.insert(__SYCL_PROPERTY_SET_SYCL_IMPORTED_SYMBOLS, + PropSet.insert(llvm::util::PropertySetRegistry::SYCL_IMPORTED_SYMBOLS, createPropertySet(ImportedSymbols)); std::vector Bin{Magic}; diff --git a/sycl/unittests/program_manager/arg_mask/EliminatedArgMask.cpp b/sycl/unittests/program_manager/arg_mask/EliminatedArgMask.cpp index 74e5dc5fecf42..68f6db9d6d5a5 100644 --- a/sycl/unittests/program_manager/arg_mask/EliminatedArgMask.cpp +++ b/sycl/unittests/program_manager/arg_mask/EliminatedArgMask.cpp @@ -14,6 +14,8 @@ #include #include +#include + #include #include #include @@ -64,7 +66,8 @@ static sycl::unittest::MockDeviceImage generateEAMTestKernelImage() { std::vector ImgKPOI{std::move(EAMKernelPOI)}; MockPropertySet PropSet; - PropSet.insert(__SYCL_PROPERTY_SET_KERNEL_PARAM_OPT_INFO, std::move(ImgKPOI)); + PropSet.insert(llvm::util::PropertySetRegistry::SYCL_KERNEL_PARAM_OPT_INFO, + std::move(ImgKPOI)); std::vector Entries = makeEmptyKernels({EAMTestKernelName}); @@ -83,7 +86,8 @@ static sycl::unittest::MockDeviceImage generateEAMTestKernel3Image() { std::vector ImgKPOI{std::move(EAMKernelPOI)}; MockPropertySet PropSet; - PropSet.insert(__SYCL_PROPERTY_SET_KERNEL_PARAM_OPT_INFO, std::move(ImgKPOI)); + PropSet.insert(llvm::util::PropertySetRegistry::SYCL_KERNEL_PARAM_OPT_INFO, + std::move(ImgKPOI)); std::vector Entries = makeEmptyKernels({EAMTestKernel3Name}); diff --git a/sycl/unittests/program_manager/passing_link_and_compile_options.cpp b/sycl/unittests/program_manager/passing_link_and_compile_options.cpp index 4deac120a133e..c743a7da77017 100644 --- a/sycl/unittests/program_manager/passing_link_and_compile_options.cpp +++ b/sycl/unittests/program_manager/passing_link_and_compile_options.cpp @@ -14,6 +14,8 @@ #include #include +#include + #include std::string current_link_options, current_compile_options, current_build_opts; @@ -67,7 +69,8 @@ generateEAMTestKernelImage(std::string _cmplOptions, std::string _lnkOptions) { std::vector ImgKPOI{std::move(EAMKernelPOI)}; MockPropertySet PropSet; - PropSet.insert(__SYCL_PROPERTY_SET_KERNEL_PARAM_OPT_INFO, std::move(ImgKPOI)); + PropSet.insert(llvm::util::PropertySetRegistry::SYCL_KERNEL_PARAM_OPT_INFO, + std::move(ImgKPOI)); std::vector Bin{0, 1, 2, 3, 4, 5}; // Random data From 4b479b209c5a5674a016d33cf585bb7919947650 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Fri, 24 Jan 2025 03:55:45 -0800 Subject: [PATCH 2/8] Disable unused parameter warnings in library Signed-off-by: Larsen, Steffen --- sycl/source/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sycl/source/CMakeLists.txt b/sycl/source/CMakeLists.txt index 83107de1c3688..3e989790f95e4 100644 --- a/sycl/source/CMakeLists.txt +++ b/sycl/source/CMakeLists.txt @@ -150,6 +150,9 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) target_include_directories(${LIB_NAME} PRIVATE ${LLVM_MAIN_INCLUDE_DIR}) target_link_libraries(${LIB_NAME} PRIVATE LLVMSupport LLVMObject) target_compile_definitions(${LIB_NAME} PRIVATE LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1) + # LLVM headers are not as pedantic about unused parameters, so we forcefully + # disable warnings about these. + target_compile_options(${LIB_NAME} private -Wno-unused-parameter) if(SYCL_ENABLE_EXTENSION_JIT) if(NOT DEFINED LLVM_EXTERNAL_SYCL_JIT_SOURCE_DIR) From cb78c5e701e1a008e5a9b80cc452ddcbaceb4963 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Fri, 24 Jan 2025 04:06:03 -0800 Subject: [PATCH 3/8] Fix lowercase private Signed-off-by: Larsen, Steffen --- sycl/source/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/source/CMakeLists.txt b/sycl/source/CMakeLists.txt index 3e989790f95e4..251f6faa1c9a4 100644 --- a/sycl/source/CMakeLists.txt +++ b/sycl/source/CMakeLists.txt @@ -152,7 +152,7 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) target_compile_definitions(${LIB_NAME} PRIVATE LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1) # LLVM headers are not as pedantic about unused parameters, so we forcefully # disable warnings about these. - target_compile_options(${LIB_NAME} private -Wno-unused-parameter) + target_compile_options(${LIB_NAME} PRIVATE -Wno-unused-parameter) if(SYCL_ENABLE_EXTENSION_JIT) if(NOT DEFINED LLVM_EXTERNAL_SYCL_JIT_SOURCE_DIR) From 8eedefa102b5e8685236a242a8a06b61b885944d Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Fri, 24 Jan 2025 04:26:00 -0800 Subject: [PATCH 4/8] Change to LIB_OBJ_NAME Signed-off-by: Larsen, Steffen --- sycl/source/CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sycl/source/CMakeLists.txt b/sycl/source/CMakeLists.txt index 251f6faa1c9a4..c0951250c8b72 100644 --- a/sycl/source/CMakeLists.txt +++ b/sycl/source/CMakeLists.txt @@ -146,13 +146,13 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) ) # Link with LLVMSupport and LLVMObject for shared utilities. - add_dependencies(${LIB_NAME} LLVMSupport LLVMObject) - target_include_directories(${LIB_NAME} PRIVATE ${LLVM_MAIN_INCLUDE_DIR}) - target_link_libraries(${LIB_NAME} PRIVATE LLVMSupport LLVMObject) - target_compile_definitions(${LIB_NAME} PRIVATE LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1) + add_dependencies(${LIB_OBJ_NAME} LLVMSupport LLVMObject) + target_include_directories(${LIB_OBJ_NAME} PRIVATE ${LLVM_MAIN_INCLUDE_DIR}) + target_link_libraries(${LIB_OBJ_NAME} PRIVATE LLVMSupport LLVMObject) + target_compile_definitions(${LIB_OBJ_NAME} PRIVATE LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1) # LLVM headers are not as pedantic about unused parameters, so we forcefully # disable warnings about these. - target_compile_options(${LIB_NAME} PRIVATE -Wno-unused-parameter) + target_compile_options(${LIB_OBJ_NAME} PRIVATE -Wno-unused-parameter) if(SYCL_ENABLE_EXTENSION_JIT) if(NOT DEFINED LLVM_EXTERNAL_SYCL_JIT_SOURCE_DIR) From c8a5bf94e216ed235f61b5ce9ed7244d38a3e55b Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Fri, 24 Jan 2025 05:03:55 -0800 Subject: [PATCH 5/8] Exclude warning flag on MSVC Signed-off-by: Larsen, Steffen --- sycl/source/CMakeLists.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sycl/source/CMakeLists.txt b/sycl/source/CMakeLists.txt index c0951250c8b72..bdce4bf74bdbb 100644 --- a/sycl/source/CMakeLists.txt +++ b/sycl/source/CMakeLists.txt @@ -150,9 +150,12 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) target_include_directories(${LIB_OBJ_NAME} PRIVATE ${LLVM_MAIN_INCLUDE_DIR}) target_link_libraries(${LIB_OBJ_NAME} PRIVATE LLVMSupport LLVMObject) target_compile_definitions(${LIB_OBJ_NAME} PRIVATE LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1) - # LLVM headers are not as pedantic about unused parameters, so we forcefully - # disable warnings about these. - target_compile_options(${LIB_OBJ_NAME} PRIVATE -Wno-unused-parameter) + + if (NOT MSVC) + # LLVM headers are not as pedantic about unused parameters, so we forcefully + # disable warnings about these. + target_compile_options(${LIB_OBJ_NAME} PRIVATE -Wno-unused-parameter) + endif() if(SYCL_ENABLE_EXTENSION_JIT) if(NOT DEFINED LLVM_EXTERNAL_SYCL_JIT_SOURCE_DIR) From a1c5055661e40052362ae2c089c48611ec505c3c Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Mon, 27 Jan 2025 05:45:45 -0800 Subject: [PATCH 6/8] Address binary size on non-MSVC Signed-off-by: Larsen, Steffen --- sycl/source/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sycl/source/CMakeLists.txt b/sycl/source/CMakeLists.txt index bdce4bf74bdbb..98b8f48d8cd65 100644 --- a/sycl/source/CMakeLists.txt +++ b/sycl/source/CMakeLists.txt @@ -155,6 +155,9 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) # LLVM headers are not as pedantic about unused parameters, so we forcefully # disable warnings about these. target_compile_options(${LIB_OBJ_NAME} PRIVATE -Wno-unused-parameter) + # LLVM library increases the size of the SYCL library quite significantly + # without the following link options. + target_link_options(${LIB_NAME} PRIVATE -Wl,--gc-sections) endif() if(SYCL_ENABLE_EXTENSION_JIT) From 524e9610a421d76518cd4b3f348323727f1b3d31 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Mon, 27 Jan 2025 05:46:10 -0800 Subject: [PATCH 7/8] Fix to use LIB_NAME instead of LIB_OBJ_NAME Signed-off-by: Larsen, Steffen --- sycl/source/CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sycl/source/CMakeLists.txt b/sycl/source/CMakeLists.txt index 98b8f48d8cd65..3f7fa9f722f43 100644 --- a/sycl/source/CMakeLists.txt +++ b/sycl/source/CMakeLists.txt @@ -146,15 +146,15 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) ) # Link with LLVMSupport and LLVMObject for shared utilities. - add_dependencies(${LIB_OBJ_NAME} LLVMSupport LLVMObject) - target_include_directories(${LIB_OBJ_NAME} PRIVATE ${LLVM_MAIN_INCLUDE_DIR}) - target_link_libraries(${LIB_OBJ_NAME} PRIVATE LLVMSupport LLVMObject) - target_compile_definitions(${LIB_OBJ_NAME} PRIVATE LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1) + add_dependencies(${LIB_NAME} LLVMSupport LLVMObject) + target_include_directories(${LIB_NAME} PRIVATE ${LLVM_MAIN_INCLUDE_DIR}) + target_link_libraries(${LIB_NAME} PRIVATE LLVMSupport LLVMObject) + target_compile_definitions(${LIB_NAME} PRIVATE LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1) if (NOT MSVC) # LLVM headers are not as pedantic about unused parameters, so we forcefully # disable warnings about these. - target_compile_options(${LIB_OBJ_NAME} PRIVATE -Wno-unused-parameter) + target_compile_options(${LIB_NAME} PRIVATE -Wno-unused-parameter) # LLVM library increases the size of the SYCL library quite significantly # without the following link options. target_link_options(${LIB_NAME} PRIVATE -Wl,--gc-sections) From 0a5c2506b72e82e3f93ee0c7a0ba43891a757163 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Mon, 27 Jan 2025 05:46:36 -0800 Subject: [PATCH 8/8] Avoid need for disabling warnings from LLVM headers Signed-off-by: Larsen, Steffen --- sycl/source/CMakeLists.txt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/sycl/source/CMakeLists.txt b/sycl/source/CMakeLists.txt index 3f7fa9f722f43..681a260fec1a1 100644 --- a/sycl/source/CMakeLists.txt +++ b/sycl/source/CMakeLists.txt @@ -147,14 +147,11 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) # Link with LLVMSupport and LLVMObject for shared utilities. add_dependencies(${LIB_NAME} LLVMSupport LLVMObject) - target_include_directories(${LIB_NAME} PRIVATE ${LLVM_MAIN_INCLUDE_DIR}) + target_include_directories(${LIB_NAME} SYSTEM PRIVATE ${LLVM_MAIN_INCLUDE_DIR}) target_link_libraries(${LIB_NAME} PRIVATE LLVMSupport LLVMObject) target_compile_definitions(${LIB_NAME} PRIVATE LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1) if (NOT MSVC) - # LLVM headers are not as pedantic about unused parameters, so we forcefully - # disable warnings about these. - target_compile_options(${LIB_NAME} PRIVATE -Wno-unused-parameter) # LLVM library increases the size of the SYCL library quite significantly # without the following link options. target_link_options(${LIB_NAME} PRIVATE -Wl,--gc-sections)