forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
[SYCL] Add libsycl, a SYCL RT library implementation project #1
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
Closed
Closed
Changes from 9 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
60239fb
[SYCL] Add libsycl, a SYCL RT library implementation project
sergey-semenov 6a8fba6
Apply some comments
sergey-semenov 8a6463f
A few missed changes
sergey-semenov 998fb9b
Fix path
sergey-semenov 43a1bc2
Merge branch 'main' into addlibsycl
KseniyaTikhomirova ca41e90
code-review comments fix 1
KseniyaTikhomirova 6ba565a
update header to llvm standards
KseniyaTikhomirova 7610d78
fix comments part 2
KseniyaTikhomirova 6b688ad
fix comments part 3
KseniyaTikhomirova 0d930ef
modify versioning
KseniyaTikhomirova 2acca61
fix build
KseniyaTikhomirova 737a405
tiny text updates
KseniyaTikhomirova abda611
fix comment
KseniyaTikhomirova 9f3093c
remove 2nd build for Win
KseniyaTikhomirova 5157163
fix comments, formating
KseniyaTikhomirova d7f006c
remove extra PDB handling
KseniyaTikhomirova 56848ac
fix names of macro
KseniyaTikhomirova 0414f6d
fix src files
KseniyaTikhomirova 59f8e25
fix generated files location
KseniyaTikhomirova 05723f7
fix more comments
KseniyaTikhomirova d60c7a0
fix last comments
KseniyaTikhomirova 813cfc3
fix install dir
KseniyaTikhomirova 3a023e4
Merge branch 'main' into addlibsycl
KseniyaTikhomirova File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| BasedOnStyle: LLVM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| Checks: > | ||
| -*, | ||
| clang-analyzer-*, | ||
| clang-diagnostic-*, | ||
| cppcoreguidelines-*, | ||
| -cppcoreguidelines-pro-bounds-array-to-pointer-decay, | ||
| -cppcoreguidelines-pro-bounds-constant-array-index, | ||
| -cppcoreguidelines-pro-bounds-pointer-arithmetic, | ||
| -cppcoreguidelines-pro-type-member-init, | ||
| -cppcoreguidelines-pro-type-union-access, | ||
| google-*, | ||
| -google-build-using-namespace, | ||
| -google-explicit-constructor, | ||
| -google-runtime-references, | ||
| misc-*, | ||
| -misc-macro-parentheses, | ||
| -misc-unused-parameters |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,156 @@ | ||
| #=============================================================================== | ||
| # Setup Project | ||
| #=============================================================================== | ||
| cmake_minimum_required(VERSION 3.20.0) | ||
|
|
||
| set(LLVM_SUBPROJECT_TITLE "libsycl") | ||
|
|
||
| set(LIBSYCL_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) | ||
| set(LIBSYCL_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) | ||
|
|
||
| set(CMAKE_CXX_STANDARD 17) | ||
| set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
KseniyaTikhomirova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| set(CMAKE_CXX_EXTENSIONS OFF) | ||
|
|
||
| #=============================================================================== | ||
| # Setup CMake Options | ||
| #=============================================================================== | ||
|
|
||
| option(LIBSYCL_ENABLE_WERROR "Treat all warnings as errors in the libsycl project" OFF) | ||
KseniyaTikhomirova marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| #=============================================================================== | ||
| # Configure System | ||
| #=============================================================================== | ||
|
|
||
| set(LIBSYCL_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}" CACHE STRING | ||
| "Path where libsycl headers should be installed.") | ||
|
|
||
| set(LIBSYCL_SHARED_OUTPUT_NAME "sycl" CACHE STRING "Output name for the shared libsycl runtime library.") | ||
|
|
||
| if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) | ||
| set(LIBSYCL_TARGET_SUBDIR ${LLVM_DEFAULT_TARGET_TRIPLE}) | ||
| if(LIBSYCL_LIBDIR_SUBDIR) | ||
| string(APPEND LIBSYCL_TARGET_SUBDIR /${LIBSYCL_LIBDIR_SUBDIR}) | ||
| endif() | ||
| set(LIBSYCL_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LIBSYCL_TARGET_SUBDIR}) | ||
KseniyaTikhomirova marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| set(LIBSYCL_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LIBSYCL_TARGET_SUBDIR} CACHE STRING | ||
| "Path where built libsycl libraries should be installed.") | ||
| unset(LIBSYCL_TARGET_SUBDIR) | ||
| else() | ||
| if(LLVM_LIBRARY_OUTPUT_INTDIR) | ||
| set(LIBSYCL_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) | ||
| else() | ||
| set(LIBSYCL_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBSYCL_LIBDIR_SUFFIX}) | ||
| endif() | ||
| set(LIBSYCL_INSTALL_LIBRARY_DIR lib${LIBSYCL_LIBDIR_SUFFIX} CACHE STRING | ||
| "Path where built libsycl libraries should be installed.") | ||
| endif() | ||
|
|
||
| set(LIBSYCL_INCLUDE_DIR ${LIBSYCL_SOURCE_DIR}/include) | ||
| set(LIBSYCL_BUILD_INCLUDE_DIR ${LLVM_BINARY_DIR}/include) | ||
|
|
||
| set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBSYCL_LIBRARY_DIR}) | ||
| set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBSYCL_LIBRARY_DIR}) | ||
| set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIBSYCL_LIBRARY_DIR}) | ||
|
|
||
| # The change in LIBSYCL_MAJOR_VERSION must be accompanied with the same update in | ||
| # clang/lib/Driver/CMakeLists.txt. | ||
KseniyaTikhomirova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # | ||
| # See doc/developer/ABIPolicyGuide.md for the meaning when in the middle of | ||
| # development cycle. | ||
KseniyaTikhomirova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| set(LIBSYCL_MAJOR_VERSION 0) | ||
| set(LIBSYCL_MINOR_VERSION 1) | ||
| set(LIBSYCL_PATCH_VERSION 0) | ||
| set(LIBSYCL_VERSION_STRING "${LIBSYCL_MAJOR_VERSION}.${LIBSYCL_MINOR_VERSION}.${LIBSYCL_PATCH_VERSION}") | ||
|
|
||
| #=============================================================================== | ||
| # Setup Compiler Flags | ||
| #=============================================================================== | ||
|
|
||
| if(MSVC) | ||
| set_property(GLOBAL PROPERTY USE_FOLDERS ON) | ||
| # Skip asynchronous C++ exceptions catching and assume "extern C" functions | ||
| # never throw C++ exceptions. | ||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") | ||
|
|
||
| # Add PDB debug information | ||
| list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}") | ||
| include(CheckLinkerFlag) | ||
| check_linker_flag(CXX "LINKER:/DEBUG" LINKER_SUPPORTS_DEBUG) | ||
| if(LINKER_SUPPORTS_DEBUG) | ||
| # sccache is not compatible with /Zi flag | ||
| if (CMAKE_CXX_COMPILER_LAUNCHER STREQUAL "sccache") | ||
| # CMake may put /Zi by default | ||
KseniyaTikhomirova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if(CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
| string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") | ||
| string(REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") | ||
| elseif(CMAKE_BUILD_TYPE STREQUAL "Release") | ||
| string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") | ||
| string(REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") | ||
| elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") | ||
| string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") | ||
| string(REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}") | ||
| endif() | ||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Z7") | ||
KseniyaTikhomirova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| else() | ||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zi") | ||
KseniyaTikhomirova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| endif() | ||
| add_link_options("LINKER:/DEBUG") | ||
|
|
||
| # Enable unreferenced removal and ICF in Release mode. | ||
| check_linker_flag(CXX "LINKER:/OPT:REF,/OPT:ICF" LINKER_SUPPORTS_OPTS) | ||
| if (LINKER_SUPPORTS_OPTS AND uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE") | ||
| add_link_options("LINKER:/OPT:REF" "LINKER:/OPT:ICF") | ||
| endif() | ||
KseniyaTikhomirova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| endif() | ||
| endif() | ||
KseniyaTikhomirova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| # Enable all warnings by default | ||
| if (MSVC) | ||
KseniyaTikhomirova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| set(CMAKE_CXX_FLAGS "/W4 ${CMAKE_CXX_FLAGS}") | ||
KseniyaTikhomirova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| else () | ||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") | ||
KseniyaTikhomirova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| endif() | ||
|
|
||
| if(LIBSYCL_ENABLE_WERROR) | ||
| if(MSVC) | ||
| set(CMAKE_CXX_FLAGS "/WX ${CMAKE_CXX_FLAGS}") | ||
KseniyaTikhomirova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| else() | ||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") | ||
KseniyaTikhomirova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| endif() | ||
| endif() | ||
|
|
||
| # This is a workaround to detect changes (add or modify) in subtree which | ||
| # are not detected by copy_directory command. | ||
| # TODO: Detect removal in the source tree and reflect in the install directory. | ||
KseniyaTikhomirova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| file(GLOB_RECURSE HEADERS_IN_SYCL_DIR CONFIGURE_DEPENDS "${LIBSYCL_INCLUDE_DIR}/sycl/*") | ||
|
|
||
| string(REPLACE "${LIBSYCL_INCLUDE_DIR}" "${LIBSYCL_BUILD_INCLUDE_DIR}" | ||
| OUT_HEADERS_IN_SYCL_DIR "${HEADERS_IN_SYCL_DIR}") | ||
|
|
||
| # Copy SYCL headers from sources to build directory | ||
| add_custom_target(sycl-headers | ||
| DEPENDS ${OUT_HEADERS_IN_SYCL_DIR}) | ||
|
|
||
| add_custom_command( | ||
| OUTPUT ${OUT_HEADERS_IN_SYCL_DIR} | ||
| DEPENDS ${HEADERS_IN_SYCL_DIR} | ||
| COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBSYCL_INCLUDE_DIR}/sycl ${LIBSYCL_BUILD_INCLUDE_DIR}/sycl | ||
| COMMENT "Copying SYCL headers...") | ||
KseniyaTikhomirova marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| install(DIRECTORY "${LIBSYCL_INCLUDE_DIR}/sycl" DESTINATION ${LIBSYCL_INSTALL_INCLUDE_DIR} COMPONENT sycl-headers) | ||
|
|
||
| if (WIN32) | ||
| set(LIBSYCL_RT_LIBS ${LIBSYCL_SHARED_OUTPUT_NAME}${LIBSYCL_MAJOR_VERSION}) | ||
| if (MSVC) | ||
| list(APPEND LIBSYCL_RT_LIBS ${LIBSYCL_SHARED_OUTPUT_NAME}${LIBSYCL_MAJOR_VERSION}d) | ||
| endif() | ||
| else() | ||
| set(LIBSYCL_RT_LIBS ${LIBSYCL_SHARED_OUTPUT_NAME}) | ||
| endif() | ||
|
|
||
| add_subdirectory(src) | ||
|
|
||
| add_custom_target(libsycl-runtime-libraries | ||
| DEPENDS ${LIBSYCL_RT_LIBS} | ||
| ) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.