diff --git a/buildbot/configure.py b/buildbot/configure.py index 283ffbd5dd91b..5a8820d7ac495 100644 --- a/buildbot/configure.py +++ b/buildbot/configure.py @@ -31,9 +31,6 @@ def do_configure(args): llvm_enable_projects = 'clang;' + llvm_external_projects libclc_targets_to_build = '' libclc_gen_remangled_variants = 'OFF' - sycl_build_pi_cuda = 'OFF' - sycl_build_pi_esimd_emulator = 'OFF' - sycl_build_pi_hip = 'OFF' sycl_build_pi_hip_platform = 'AMD' sycl_clang_extra_flags = '' sycl_werror = 'ON' @@ -42,6 +39,7 @@ def do_configure(args): llvm_enable_sphinx = 'OFF' llvm_build_shared_libs = 'OFF' llvm_enable_lld = 'OFF' + sycl_enabled_plugins = ["opencl", "level_zero"] sycl_enable_xpti_tracing = 'ON' xpti_enable_werror = 'ON' @@ -51,7 +49,7 @@ def do_configure(args): llvm_targets_to_build = 'ARM;AArch64' if args.enable_esimd_emulator: - sycl_build_pi_esimd_emulator = 'ON' + sycl_enabled_plugins.append("esimd_emulator") if args.cuda or args.hip: llvm_enable_projects += ';libclc' @@ -60,7 +58,7 @@ def do_configure(args): llvm_targets_to_build += ';NVPTX' libclc_targets_to_build = libclc_nvidia_target_names libclc_gen_remangled_variants = 'ON' - sycl_build_pi_cuda = 'ON' + sycl_enabled_plugins.append("cuda") if args.hip: if args.hip_platform == 'AMD': @@ -75,7 +73,7 @@ def do_configure(args): libclc_gen_remangled_variants = 'ON' sycl_build_pi_hip_platform = args.hip_platform - sycl_build_pi_hip = 'ON' + sycl_enabled_plugins.append("hip") if args.no_werror: sycl_werror = 'OFF' @@ -115,6 +113,9 @@ def do_configure(args): if libclc_nvidia_target_names not in libclc_targets_to_build: libclc_targets_to_build += libclc_nvidia_target_names + if args.enable_plugin: + sycl_enabled_plugins += args.enable_plugin + install_dir = os.path.join(abs_obj_dir, "install") cmake_cmd = [ @@ -133,8 +134,6 @@ def do_configure(args): "-DLLVM_ENABLE_PROJECTS={}".format(llvm_enable_projects), "-DLIBCLC_TARGETS_TO_BUILD={}".format(libclc_targets_to_build), "-DLIBCLC_GENERATE_REMANGLED_VARIANTS={}".format(libclc_gen_remangled_variants), - "-DSYCL_BUILD_PI_CUDA={}".format(sycl_build_pi_cuda), - "-DSYCL_BUILD_PI_HIP={}".format(sycl_build_pi_hip), "-DSYCL_BUILD_PI_HIP_PLATFORM={}".format(sycl_build_pi_hip_platform), "-DLLVM_BUILD_TOOLS=ON", "-DSYCL_ENABLE_WERROR={}".format(sycl_werror), @@ -145,9 +144,9 @@ def do_configure(args): "-DBUILD_SHARED_LIBS={}".format(llvm_build_shared_libs), "-DSYCL_ENABLE_XPTI_TRACING={}".format(sycl_enable_xpti_tracing), "-DLLVM_ENABLE_LLD={}".format(llvm_enable_lld), - "-DSYCL_BUILD_PI_ESIMD_EMULATOR={}".format(sycl_build_pi_esimd_emulator), "-DXPTI_ENABLE_WERROR={}".format(xpti_enable_werror), - "-DSYCL_CLANG_EXTRA_FLAGS={}".format(sycl_clang_extra_flags) + "-DSYCL_CLANG_EXTRA_FLAGS={}".format(sycl_clang_extra_flags), + "-DSYCL_ENABLE_PLUGINS={}".format(';'.join(set(sycl_enabled_plugins))) ] if args.l0_headers and args.l0_loader: @@ -223,6 +222,7 @@ def main(): parser.add_argument("--use-lld", action="store_true", help="Use LLD linker for build") parser.add_argument("--llvm-external-projects", help="Add external projects to build. Add as comma seperated list.") parser.add_argument("--ci-defaults", action="store_true", help="Enable default CI parameters") + parser.add_argument("--enable-plugin", action='append', help="Enable SYCL plugin") args = parser.parse_args() print("args:{}".format(args)) diff --git a/sycl/CMakeLists.txt b/sycl/CMakeLists.txt index cdebb1b9fb71b..b51a7010e6a15 100644 --- a/sycl/CMakeLists.txt +++ b/sycl/CMakeLists.txt @@ -16,6 +16,7 @@ endif() list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") include(AddSYCLExecutable) +include(AddSYCL) include(SYCLUtils) set(SYCL_MAJOR_VERSION 5) @@ -27,6 +28,11 @@ if (SYCL_ADD_DEV_VERSION_POSTFIX) endif() set(SYCL_VERSION_STRING "${SYCL_MAJOR_VERSION}.${SYCL_MINOR_VERSION}.${SYCL_PATCH_VERSION}${SYCL_VERSION_POSTFIX}") +define_property(GLOBAL PROPERTY SYCL_TOOLCHAIN_INSTALL_COMPONENTS + BRIEF_DOCS "List of components to deploy with SYCL toolchain" + FULL_DOCS "List of components to deploy with SYCL toolchain" +) + # enable all warnings by default if (MSVC) set(CMAKE_CXX_FLAGS "/W4 ${CMAKE_CXX_FLAGS}") @@ -126,11 +132,16 @@ install(DIRECTORY ${OpenCL_INCLUDE_DIR}/CL DESTINATION ${SYCL_INCLUDE_DIR}/sycl COMPONENT OpenCL-Headers) -option(SYCL_BUILD_PI_CUDA - "Enables the CUDA backend for the Plugin Interface" OFF) - -option(SYCL_BUILD_PI_HIP - "Enables the HIP backend for the Plugin Interface" OFF) +# Needed for feature_test.hpp +if ("cuda" IN_LIST SYCL_ENABLE_PLUGINS) + set(SYCL_BUILD_PI_CUDA ON) +endif() +if ("hip" IN_LIST SYCL_ENABLE_PLUGINS) + set(SYCL_BUILD_PI_HIP ON) +endif() +if ("esimd_emulator" IN_LIST SYCL_ENABLE_PLUGINS) + set(SYCL_BUILD_PI_HIP ON) +endif() # Configure SYCL version macro set(sycl_inc_dir ${CMAKE_CURRENT_SOURCE_DIR}/include) @@ -315,6 +326,7 @@ if(SYCL_INCLUDE_TESTS) add_subdirectory(test) endif() +get_property(SYCL_TOOLCHAIN_DEPS GLOBAL PROPERTY SYCL_TOOLCHAIN_INSTALL_COMPONENTS) # Package deploy support # Listed here are component names contributing the package set( SYCL_TOOLCHAIN_DEPLOY_COMPONENTS @@ -344,10 +356,9 @@ set( SYCL_TOOLCHAIN_DEPLOY_COMPONENTS sycl-headers sycl-headers-extras sycl - pi_opencl - pi_level_zero libsycldevice ${XPTIFW_LIBS} + ${SYCL_TOOLCHAIN_DEPS} ) if (TARGET sycl-prof) @@ -364,7 +375,7 @@ if(OpenCL_INSTALL_KHRONOS_ICD_LOADER AND TARGET OpenCL-ICD) list(APPEND SYCL_TOOLCHAIN_DEPLOY_COMPONENTS OpenCL-ICD) endif() -if(SYCL_BUILD_PI_CUDA) +if("cuda" IN_LIST SYCL_ENABLE_PLUGINS) # Ensure that libclc is enabled. list(FIND LLVM_ENABLE_PROJECTS libclc LIBCLC_FOUND) if( LIBCLC_FOUND EQUAL -1 ) @@ -376,7 +387,7 @@ if(SYCL_BUILD_PI_CUDA) list(APPEND SYCL_TOOLCHAIN_DEPLOY_COMPONENTS libspirv-builtins pi_cuda) endif() -if(SYCL_BUILD_PI_HIP) +if("hip" IN_LIST SYCL_ENABLE_PLUGINS) # Ensure that libclc is enabled. list(FIND LLVM_ENABLE_PROJECTS libclc LIBCLC_FOUND) if( LIBCLC_FOUND EQUAL -1 ) @@ -388,7 +399,7 @@ if(SYCL_BUILD_PI_HIP) list(APPEND SYCL_TOOLCHAIN_DEPLOY_COMPONENTS libspirv-builtins pi_hip) endif() -if(SYCL_BUILD_PI_ESIMD_EMULATOR) +if("esimd_emulator" IN_LIST SYCL_ENABLE_PLUGINS) list(APPEND SYCL_TOOLCHAIN_DEPLOY_COMPONENTS pi_esimd_emulator libcmrt-headers) if (MSVC) list(APPEND SYCL_TOOLCHAIN_DEPLOY_COMPONENTS libcmrt-libs libcmrt-dlls) diff --git a/sycl/cmake/modules/AddSYCL.cmake b/sycl/cmake/modules/AddSYCL.cmake new file mode 100644 index 0000000000000..aa0cfcadda92d --- /dev/null +++ b/sycl/cmake/modules/AddSYCL.cmake @@ -0,0 +1,73 @@ +function(add_sycl_library LIB_NAME TYPE) + cmake_parse_arguments("ARG" + "TOOLCHAIN" + "LINKER_SCRIPT" + "SOURCES;INCLUDE_DIRS;LIBRARIES" + ${ARGN} + ) + add_library(${LIB_NAME} ${TYPE} ${ARG_SOURCES}) + target_include_directories(${LIB_NAME} PRIVATE ${ARG_INCLUDE_DIRS}) + target_link_libraries(${LIB_NAME} PRIVATE ${ARG_LIBRARIES}) + + if (ARG_TOOLCHAIN) + add_dependencies(sycl-toolchain ${LIB_NAME}) + endif() + + if (ARG_LINKER_SCRIPT AND UNIX) + target_link_libraries(${LIB_NAME} PRIVATE + "-Wl,--version-script=${ARG_LINKER_SCRIPT}") + endif() + + target_compile_definitions(${LIB_NAME} PRIVATE __SYCL_BUILD_SYCL_DLL) + + if (UNIX) + target_compile_options(${LIB_NAME} PRIVATE -fvisibility=hidden) + else() + add_stripped_pdb(${LIB_NAME}) + endif() + + # TODO remove add_common_options + add_common_options(${LIB_NAME}) +endfunction() + +function(add_sycl_plugin PLUGIN_NAME) + cmake_parse_arguments("ARG" + "" + "" + "SOURCES;INCLUDE_DIRS;LIBRARIES" + ${ARGN} + ) + + add_sycl_library("pi_${PLUGIN_NAME}" SHARED + TOOLCHAIN + LINKER_SCRIPT "${PROJECT_SOURCE_DIR}/plugins/ld-version-script.txt" + SOURCES ${ARG_SOURCES} + INCLUDE_DIRS + ${ARG_INCLUDE_DIRS} + ${sycl_inc_dir} + LIBRARIES + ${ARG_LIBRARIES} + OpenCL-Headers + ) + + install(TARGETS pi_${PLUGIN_NAME} + LIBRARY DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" COMPONENT pi_${PLUGIN_NAME} + RUNTIME DESTINATION "bin" COMPONENT pi_${PLUGIN_NAME}) + + set (manifest_file + ${CMAKE_CURRENT_BINARY_DIR}/install_manifest_pi_${PLUGIN_NAME}.txt) + add_custom_command(OUTPUT ${manifest_file} + COMMAND "${CMAKE_COMMAND}" + "-DCMAKE_INSTALL_COMPONENT=pi_${PLUGIN_NAME}" + -P "${CMAKE_BINARY_DIR}/cmake_install.cmake" + COMMENT "Deploying component pi_${PLUGIN_NAME}" + USES_TERMINAL + ) + add_custom_target(install-sycl-plugin-${PLUGIN_NAME} + DEPENDS + ${manifest_file} pi_${PLUGIN_NAME} + ) + + set_property(GLOBAL APPEND PROPERTY SYCL_TOOLCHAIN_INSTALL_COMPONENTS + pi_${PLUGIN_NAME}) +endfunction() diff --git a/sycl/doc/GetStartedGuide.md b/sycl/doc/GetStartedGuide.md index 1f53b9f4697c8..5018d3decc83a 100644 --- a/sycl/doc/GetStartedGuide.md +++ b/sycl/doc/GetStartedGuide.md @@ -689,7 +689,7 @@ The SYCL host device executes the SYCL application directly in the host, without using any low-level API. **NOTE**: `nvptx64-nvidia-cuda` is usable with `-fsycl-targets` -if clang was built with the cmake option `SYCL_BUILD_PI_CUDA=ON`. +if clang was built with the cmake option `SYCL_ENABLE_PLUGINS=cuda`. **Linux & Windows (64-bit)**: diff --git a/sycl/plugins/CMakeLists.txt b/sycl/plugins/CMakeLists.txt index 12fd21881f158..091b7d6b57fa1 100644 --- a/sycl/plugins/CMakeLists.txt +++ b/sycl/plugins/CMakeLists.txt @@ -4,21 +4,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang|IntelLLVM" ) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-covered-switch-default") endif() -if(SYCL_BUILD_PI_CUDA) - add_subdirectory(cuda) -endif() - -if(SYCL_BUILD_PI_HIP) - add_subdirectory(hip) -endif() +foreach(plugin ${SYCL_ENABLE_PLUGINS}) + add_subdirectory(${plugin}) +endforeach() -add_subdirectory(opencl) -add_subdirectory(level_zero) - -if(SYCL_BUILD_PI_ESIMD_EMULATOR) - # TODO : Remove 'if (NOT MSVC)' when CM_EMU supports Windows - # environment - if (NOT MSVC) - add_subdirectory(esimd_emulator) - endif() -endif() diff --git a/sycl/plugins/cuda/CMakeLists.txt b/sycl/plugins/cuda/CMakeLists.txt index 8b8b40b2f7861..4e66a582cd3d5 100644 --- a/sycl/plugins/cuda/CMakeLists.txt +++ b/sycl/plugins/cuda/CMakeLists.txt @@ -1,4 +1,3 @@ - message(STATUS "Including the PI API CUDA backend.") # cannot rely on cmake support for CUDA; it assumes runtime API is being used. @@ -24,51 +23,15 @@ else() ) endif() -add_library(pi_cuda SHARED - "${sycl_inc_dir}/CL/sycl/detail/pi.h" - "${sycl_inc_dir}/CL/sycl/detail/pi.hpp" - "pi_cuda.hpp" - "pi_cuda.cpp" -) - -add_dependencies(sycl-toolchain pi_cuda) - -set_target_properties(pi_cuda PROPERTIES LINKER_LANGUAGE CXX) - -target_include_directories(pi_cuda - PRIVATE - ${sycl_inc_dir} -) - -target_link_libraries(pi_cuda - PRIVATE - OpenCL-Headers +add_sycl_plugin(cuda + SOURCES + "${sycl_inc_dir}/CL/sycl/detail/pi.h" + "${sycl_inc_dir}/CL/sycl/detail/pi.hpp" + "pi_cuda.hpp" + "pi_cuda.cpp" + LIBRARIES cudadrv ) -if (MSVC) - # by defining __SYCL_BUILD_SYCL_DLL, we can use __declspec(dllexport) - # which are individually tagged for all pi* symbols in pi.h - target_compile_definitions(pi_cuda PRIVATE __SYCL_BUILD_SYCL_DLL) - # Install stripped PDB - add_stripped_pdb(pi_cuda) -else() - # we set the visibility of all symbols 'hidden' by default. - # In pi.h file, we set exported symbols with visibility==default individually - target_compile_options(pi_cuda PUBLIC -fvisibility=hidden) - - # This script file is used to allow exporting pi* symbols only. - # All other symbols are regarded as local (hidden) - set(linker_script "${CMAKE_CURRENT_SOURCE_DIR}/../ld-version-script.txt") - - # Filter symbols based on the scope defined in the script file, - # and export pi* function symbols in the library. - target_link_libraries(pi_cuda PRIVATE "-Wl,--version-script=${linker_script}") -endif() - -add_common_options(pi_cuda) +set_target_properties(pi_cuda PROPERTIES LINKER_LANGUAGE CXX) -install(TARGETS pi_cuda - LIBRARY DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" COMPONENT pi_cuda - RUNTIME DESTINATION "bin" COMPONENT pi_cuda -) diff --git a/sycl/plugins/esimd_emulator/CMakeLists.txt b/sycl/plugins/esimd_emulator/CMakeLists.txt index 367a1a07da7b6..fa398f0b6cb29 100755 --- a/sycl/plugins/esimd_emulator/CMakeLists.txt +++ b/sycl/plugins/esimd_emulator/CMakeLists.txt @@ -103,46 +103,22 @@ else() string(REPLACE "-pedantic" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") endif() -add_library(pi_esimd_emulator SHARED - "${sycl_inc_dir}/CL/sycl/detail/pi.h" - "pi_esimd_emulator.cpp" +add_sycl_plugin(esimd_emulator + SOURCES + "${sycl_inc_dir}/CL/sycl/detail/pi.h" + "pi_esimd_emulator.cpp" + LIBRARIES + "${LEVEL_ZERO_LOADER}" + ${LIBCM} + ${LIBIGFXCMRT_EMU} + #TODO remove cyclic dependency + sycl ) -if (MSVC) - # by defining __SYCL_BUILD_SYCL_DLL, we can use __declspec(dllexport) - # which are individually tagged for all pi* symbols in pi.h - target_compile_definitions(pi_esimd_emulator PRIVATE __SYCL_BUILD_SYCL_DLL) - # Install stripped PDB - add_stripped_pdb(pi_esimd_emulator) -else() - # we set the visibility of all symbols 'hidden' by default. - # In pi.h file, we set exported symbols with visibility==default individually - target_compile_options(pi_esimd_emulator PUBLIC -fvisibility=hidden) - - # This script file is used to allow exporting pi* symbols only. - # All other symbols are regarded as local (hidden) - set(linker_script "${CMAKE_CURRENT_SOURCE_DIR}/../ld-version-script.txt") - - # Filter symbols based on the scope defined in the script file, - # and export pi* function symbols in the library. - target_link_libraries( pi_esimd_emulator - PRIVATE "-Wl,--version-script=${linker_script}" - ) -endif() - -add_dependencies(pi_esimd_emulator OpenCL-Headers) add_dependencies(pi_esimd_emulator cm-emu) -add_dependencies(sycl-toolchain pi_esimd_emulator) -target_link_libraries(pi_esimd_emulator PRIVATE sycl ${LIBCM} ${LIBIGFXCMRT_EMU}) set_target_properties(pi_esimd_emulator PROPERTIES LINKER_LANGUAGE CXX) -add_common_options(pi_esimd_emulator) - -install(TARGETS pi_esimd_emulator - LIBRARY DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" COMPONENT pi_esimd_emulator - RUNTIME DESTINATION "bin" COMPONENT pi_esimd_emulator) - # Copy CM Header files to $(INSTALL)/include/sycl/CL/ install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/cm-emu_install/include/libcm/cm/ DESTINATION ${SYCL_INCLUDE_DIR}/sycl/CL diff --git a/sycl/plugins/hip/CMakeLists.txt b/sycl/plugins/hip/CMakeLists.txt index 9ed4b40f61cd0..a03d1c8683098 100644 --- a/sycl/plugins/hip/CMakeLists.txt +++ b/sycl/plugins/hip/CMakeLists.txt @@ -10,22 +10,16 @@ set(SYCL_BUILD_PI_HIP_HSA_INCLUDE_DIR "/opt/rocm/hsa/include" CACHE STRING "HSA set(HIP_HEADERS "${SYCL_BUILD_PI_HIP_INCLUDE_DIR};${SYCL_BUILD_PI_HIP_HSA_INCLUDE_DIR}") # Create pi_hip library -add_library(pi_hip SHARED - "${sycl_inc_dir}/CL/sycl/detail/pi.h" - "${sycl_inc_dir}/CL/sycl/detail/pi.hpp" - "pi_hip.hpp" - "pi_hip.cpp" +add_sycl_plugin(hip + SOURCES + "${sycl_inc_dir}/CL/sycl/detail/pi.h" + "${sycl_inc_dir}/CL/sycl/detail/pi.hpp" + "pi_hip.hpp" + "pi_hip.cpp" + INCLUDE_DIRS + ${sycl_plugin_dir} ) -add_dependencies(sycl-toolchain pi_hip) set_target_properties(pi_hip PROPERTIES LINKER_LANGUAGE CXX) -target_link_libraries(pi_hip PUBLIC OpenCL-Headers) - -# Setup include directories -target_include_directories(pi_hip - PRIVATE - ${sycl_inc_dir} - ${sycl_plugin_dir} -) if("${SYCL_BUILD_PI_HIP_PLATFORM}" STREQUAL "AMD") # Import HIP runtime library @@ -76,9 +70,3 @@ else() message(FATAL_ERROR "Unspecified PI HIP platform please set SYCL_BUILD_PI_HIP_PLATFORM to 'AMD' or 'NVIDIA'") endif() -add_common_options(pi_hip) - -install(TARGETS pi_hip - LIBRARY DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" COMPONENT pi_hip - RUNTIME DESTINATION "bin" COMPONENT pi_hip -) diff --git a/sycl/plugins/level_zero/CMakeLists.txt b/sycl/plugins/level_zero/CMakeLists.txt index f4e6a48bc7688..950d60394f7e2 100755 --- a/sycl/plugins/level_zero/CMakeLists.txt +++ b/sycl/plugins/level_zero/CMakeLists.txt @@ -99,56 +99,20 @@ target_include_directories(LevelZeroLoader-Headers INTERFACE "${LEVEL_ZERO_INCLUDE_DIR}" ) - -include_directories("${sycl_inc_dir}") - -add_library(pi_level_zero SHARED - "${sycl_inc_dir}/CL/sycl/detail/pi.h" - "${CMAKE_CURRENT_SOURCE_DIR}/pi_level_zero.cpp" - "${CMAKE_CURRENT_SOURCE_DIR}/pi_level_zero.hpp" - "${CMAKE_CURRENT_SOURCE_DIR}/usm_allocator.cpp" - "${CMAKE_CURRENT_SOURCE_DIR}/usm_allocator.hpp" +find_package(Threads REQUIRED) +add_sycl_plugin(level_zero + SOURCES + "${sycl_inc_dir}/CL/sycl/detail/pi.h" + "${CMAKE_CURRENT_SOURCE_DIR}/pi_level_zero.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/pi_level_zero.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/usm_allocator.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/usm_allocator.hpp" + LIBRARIES + "${LEVEL_ZERO_LOADER}" + Threads::Threads ) -if (MSVC) - # by defining __SYCL_BUILD_SYCL_DLL, we can use __declspec(dllexport) - # which are individually tagged for all pi* symbols in pi.h - target_compile_definitions(pi_level_zero PRIVATE __SYCL_BUILD_SYCL_DLL) - # Install stripped PDB - add_stripped_pdb(pi_level_zero) -else() - # we set the visibility of all symbols 'hidden' by default. - # In pi.h file, we set exported symbols with visibility==default individually - target_compile_options(pi_level_zero PUBLIC -fvisibility=hidden) - - # This script file is used to allow exporting pi* symbols only. - # All other symbols are regarded as local (hidden) - set(linker_script "${CMAKE_CURRENT_SOURCE_DIR}/../ld-version-script.txt") - - # Filter symbols based on the scope defined in the script file, - # and export pi* function symbols in the library. - target_link_libraries( pi_level_zero - PRIVATE "-Wl,--version-script=${linker_script}" - ) -endif() - if (TARGET level-zero-loader) add_dependencies(pi_level_zero level-zero-loader) endif() -add_dependencies(sycl-toolchain pi_level_zero) -target_link_libraries(pi_level_zero - PRIVATE - "${LEVEL_ZERO_LOADER}" - OpenCL-Headers -) - -if (UNIX) - target_link_libraries(pi_level_zero PRIVATE pthread) -endif() - -add_common_options(pi_level_zero) - -install(TARGETS pi_level_zero - LIBRARY DESTINATION "lib" COMPONENT pi_level_zero - RUNTIME DESTINATION "bin" COMPONENT pi_level_zero) diff --git a/sycl/plugins/opencl/CMakeLists.txt b/sycl/plugins/opencl/CMakeLists.txt index d3d5c3a4cefe7..80e16f55c6fe3 100644 --- a/sycl/plugins/opencl/CMakeLists.txt +++ b/sycl/plugins/opencl/CMakeLists.txt @@ -10,48 +10,12 @@ #TODO: Currently, the pi.h header is common between sycl and plugin library sources. #This can be changed by copying the pi.h file in the plugins project. -add_library(pi_opencl SHARED - "${sycl_inc_dir}/CL/sycl/detail/pi.h" - "pi_opencl.cpp" - ) - -add_dependencies(sycl-toolchain pi_opencl) - -set_target_properties(pi_opencl PROPERTIES LINKER_LANGUAGE CXX) - -#preprocessor definitions for compiling a target's sources. We do not need it for pi_opencl -target_include_directories(pi_opencl PRIVATE "${sycl_inc_dir}") - -#link pi_opencl with OpenCL headers and ICD Loader. -target_link_libraries(pi_opencl - PRIVATE - OpenCL-Headers +add_sycl_plugin(opencl + SOURCES + "${sycl_inc_dir}/CL/sycl/detail/pi.h" + "pi_opencl.cpp" + LIBRARIES OpenCL-ICD ) -if (MSVC) - # by defining __SYCL_BUILD_SYCL_DLL, we can use __declspec(dllexport) - # which are individually tagged for all pi* symbols in pi.h - target_compile_definitions(pi_opencl PRIVATE __SYCL_BUILD_SYCL_DLL) - # Install stripped PDB - add_stripped_pdb(pi_opencl) -else() - # we set the visibility of all symbols 'hidden' by default. - # In pi.h file, we set exported symbols with visibility==default individually - target_compile_options(pi_opencl PUBLIC -fvisibility=hidden) - # This script file is used to allow exporting pi* symbols only. - # All other symbols are regarded as local (hidden) - set(linker_script "${CMAKE_CURRENT_SOURCE_DIR}/../ld-version-script.txt") - - # Filter symbols based on the scope defined in the script file, - # and export pi* function symbols in the library. - target_link_libraries( pi_opencl - PRIVATE "-Wl,--version-script=${linker_script}" - ) -endif() - -add_common_options(pi_opencl) - -install(TARGETS pi_opencl - LIBRARY DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" COMPONENT pi_opencl - RUNTIME DESTINATION "bin" COMPONENT pi_opencl) +set_target_properties(pi_opencl PROPERTIES LINKER_LANGUAGE CXX) diff --git a/sycl/tools/CMakeLists.txt b/sycl/tools/CMakeLists.txt index 8ed657ed94b12..eb62c48e1adff 100644 --- a/sycl/tools/CMakeLists.txt +++ b/sycl/tools/CMakeLists.txt @@ -29,6 +29,13 @@ else() "${LLVM_LIBRARY_OUTPUT_INTDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}ze_loader${CMAKE_SHARED_LIBRARY_SUFFIX}") endif() +if ("cuda" IN_LIST SYCL_ENABLE_PLUGINS) + set(SYCL_BUILD_PI_CUDA ON) +endif() +if ("hip" IN_LIST SYCL_ENABLE_PLUGINS) + set(SYCL_BUILD_PI_HIP ON) +endif() + target_link_libraries(get_device_count_by_type PRIVATE OpenCL-Headers diff --git a/sycl/unittests/pi/CMakeLists.txt b/sycl/unittests/pi/CMakeLists.txt index f475b0f28d60e..327b52ed504ec 100644 --- a/sycl/unittests/pi/CMakeLists.txt +++ b/sycl/unittests/pi/CMakeLists.txt @@ -12,6 +12,6 @@ add_dependencies(PiTests sycl) target_include_directories(PiTests PRIVATE SYSTEM ${sycl_inc_dir}) target_include_directories(PiTests PRIVATE ${sycl_src_dir}/../tools/xpti_helpers) -if(SYCL_BUILD_PI_CUDA) +if("cuda" IN_LIST SYCL_ENABLE_PLUGINS) add_subdirectory(cuda) endif()