From 7533255899de52f08282458d38f186e210090371 Mon Sep 17 00:00:00 2001 From: PietroGhg Date: Wed, 6 Mar 2024 11:38:42 +0000 Subject: [PATCH 1/8] [wip] use ock main branch --- sycl/doc/design/SYCLNativeCPU.md | 3 ++ sycl/plugins/native_cpu/CMakeLists.txt | 62 ++++++++++++++++++-------- 2 files changed, 47 insertions(+), 18 deletions(-) diff --git a/sycl/doc/design/SYCLNativeCPU.md b/sycl/doc/design/SYCLNativeCPU.md index 91ad393df7f62..9a9989b6a62e7 100644 --- a/sycl/doc/design/SYCLNativeCPU.md +++ b/sycl/doc/design/SYCLNativeCPU.md @@ -46,6 +46,9 @@ python3 buildbot/configure.py \ --cmake-opt=-DNATIVECPU_USE_OCK=Off ``` +By default the oneAPI Construction Kit is pulled at the project's configure time using CMake `FetchContent`. This behaviour can be overridden by setting `NATIVECPU_OCK_USE_FETCHCONTENT=Off` and `OCK_SOURCE_DIR=` +in order to use a local checkout of the oneAPI Construction Kit. + The SYCL Native CPU device needs to be selected at runtime by setting the environment variable `ONEAPI_DEVICE_SELECTOR=native_cpu:cpu`. # Supported features and current limitations diff --git a/sycl/plugins/native_cpu/CMakeLists.txt b/sycl/plugins/native_cpu/CMakeLists.txt index b602f7cfc4c3d..1d224d3198d28 100644 --- a/sycl/plugins/native_cpu/CMakeLists.txt +++ b/sycl/plugins/native_cpu/CMakeLists.txt @@ -23,27 +23,53 @@ add_sycl_plugin(native_cpu UnifiedRuntimeCommon ) +option(OCK_SOURCE_DIR "Root to a local checkout of the oneAPI Construction Kit" "") +option(NATIVECPU_OCK_USE_FETCHCONTENT "Use FetchContent to acquire oneAPI Construction Kit source code" On) if(NATIVECPU_USE_OCK) - include(FetchContent) - FetchContent_Declare(oneapi-ck - GIT_REPOSITORY https://github.com/codeplaysoftware/oneapi-construction-kit.git - # commit 62090f9d469a30e0595f445ff664ea2ecfe77b44 - # Merge: 6151546a af33ddfb - # Author: PietroGhg - # Date: Thu Feb 29 12:46:49 2024 +0100 - # Merge pull request #385 from PietroGhg/pietro/multi_llvm_include - # [NATIVECPU] Avoid specifying include path manually for multi_llvm and Native CPU - GIT_TAG 62090f9d469a30e0595f445ff664ea2ecfe77b44 - ) - FetchContent_GetProperties(oneapi-ck) - if(NOT oneapi-ck_POPULATED) - message(STATUS "Cloning oneAPI Construction Kit") - FetchContent_Populate(oneapi-ck) - message(STATUS "oneAPI Construction Kit cloned in ${oneapi-ck_SOURCE_DIR}") - set(CA_NATIVE_CPU 1) - add_subdirectory(${oneapi-ck_SOURCE_DIR} ${oneapi-ck_BINARY_DIR} EXCLUDE_FROM_ALL) + if(NATIVECPU_OCK_USE_FETCHCONTENT) + include(FetchContent) + FetchContent_Declare(oneapi-ck + GIT_REPOSITORY https://github.com/codeplaysoftware/oneapi-construction-kit.git + # commit 7cd729ba2212fc99c7d113648e18e9ab5e3d7163 + # Merge: f0588dac a6984456 + # Author: Fraser Cormack + # Date: Thu Feb 29 11:12:23 2024 +0000 + # Merge pull request #384 from frasercrmck/refactor-relocs + # [loader] Refactor common relocation code into helper + GIT_TAG 7cd729ba2212fc99c7d113648e18e9ab5e3d7163 + ) + FetchContent_GetProperties(oneapi-ck) + if(NOT oneapi-ck_POPULATED) + message(STATUS "Cloning oneAPI Construction Kit") + FetchContent_Populate(oneapi-ck) + message(STATUS "oneAPI Construction Kit cloned in ${oneapi-ck_SOURCE_DIR}") + set(OCK_SOURCE_DIR_INTERNAL ${oneapi-ci_SOURCE_DIR}) + add_subdirectory(${oneapi-ck_SOURCE_DIR} ${oneapi-ck_BINARY_DIR} EXCLUDE_FROM_ALL) + endif() + elseif(OCK_SOURCE_DIR) + set(OCK_SOURCE_DIR_INTERNAL ${OCK_SOURCE_DIR}) + else() + message(FATAL_ERROR "NATIVECPU_OCK_USE_FETCHCONTENT is Off and OCK_SOURCE_DIR not set") endif() + + set(CA_ENABLE_API "cl" CACHE STRING "" FORCE) + add_subdirectory( + ${OCK_SOURCE_DIR_INTERNAL} + ${CMAKE_CURRENT_BINARY_DIR}/oneapi-construction-kit EXCLUDE_FROM_ALL) + + install(TARGETS compiler-pipeline + EXPORT;LLVMExports + LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT compiler-pipeline + ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT compiler-pipeline + RUNTIME DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT compiler-pipeline) + set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS compiler-pipeline) + install(TARGETS vecz + EXPORT;LLVMExports + LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT vecz + ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT vecz + RUNTIME DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT vecz) + set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS vecz) install(TARGETS multi_llvm EXPORT;LLVMExports LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT multi_llvm From 8122f57ae9c93608884add6d352306bb40fa3a8f Mon Sep 17 00:00:00 2001 From: PietroGhg Date: Wed, 6 Mar 2024 12:29:46 +0000 Subject: [PATCH 2/8] update ock tag --- sycl/plugins/native_cpu/CMakeLists.txt | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/sycl/plugins/native_cpu/CMakeLists.txt b/sycl/plugins/native_cpu/CMakeLists.txt index 1d224d3198d28..bc0ae6016a998 100644 --- a/sycl/plugins/native_cpu/CMakeLists.txt +++ b/sycl/plugins/native_cpu/CMakeLists.txt @@ -31,24 +31,25 @@ if(NATIVECPU_USE_OCK) include(FetchContent) FetchContent_Declare(oneapi-ck GIT_REPOSITORY https://github.com/codeplaysoftware/oneapi-construction-kit.git - # commit 7cd729ba2212fc99c7d113648e18e9ab5e3d7163 - # Merge: f0588dac a6984456 - # Author: Fraser Cormack - # Date: Thu Feb 29 11:12:23 2024 +0000 - # Merge pull request #384 from frasercrmck/refactor-relocs - # [loader] Refactor common relocation code into helper - GIT_TAG 7cd729ba2212fc99c7d113648e18e9ab5e3d7163 + # commit 9a53d126cba574fadab3bef513b1c6d9c1ebc0fd + # Merge: f211f428 b0678100 + # Author: PietroGhg + # Date: Wed Mar 6 13:13:47 2024 +0100 + # Merge pull request #389 from PietroGhg/pietro/skip_spirv_fetchcontent + # Skip FetchContent for SPIRV-Headers if building llvm-spirv + GIT_TAG 9a53d126cba574fadab3bef513b1c6d9c1ebc0fd ) FetchContent_GetProperties(oneapi-ck) if(NOT oneapi-ck_POPULATED) message(STATUS "Cloning oneAPI Construction Kit") FetchContent_Populate(oneapi-ck) message(STATUS "oneAPI Construction Kit cloned in ${oneapi-ck_SOURCE_DIR}") - set(OCK_SOURCE_DIR_INTERNAL ${oneapi-ci_SOURCE_DIR}) - add_subdirectory(${oneapi-ck_SOURCE_DIR} ${oneapi-ck_BINARY_DIR} EXCLUDE_FROM_ALL) + set(OCK_SOURCE_DIR_INTERNAL ${oneapi-ck_SOURCE_DIR}) + set(OCK_BINARY_DIR_INTERNAL ${oneapi-ck_BINARY_DIR}) endif() elseif(OCK_SOURCE_DIR) - set(OCK_SOURCE_DIR_INTERNAL ${OCK_SOURCE_DIR}) + set(OCK_SOURCE_DIR_INTERNAL "${OCK_SOURCE_DIR}") + set(OCK_BINARY_DIR_INTERNAL "${CMAKE_CURRENT_BINARY_DIR}/oneapi-construction-kit") else() message(FATAL_ERROR "NATIVECPU_OCK_USE_FETCHCONTENT is Off and OCK_SOURCE_DIR not set") endif() @@ -56,7 +57,7 @@ if(NATIVECPU_USE_OCK) set(CA_ENABLE_API "cl" CACHE STRING "" FORCE) add_subdirectory( ${OCK_SOURCE_DIR_INTERNAL} - ${CMAKE_CURRENT_BINARY_DIR}/oneapi-construction-kit EXCLUDE_FROM_ALL) + ${OCK_BINARY_DIR_INTERNAL} EXCLUDE_FROM_ALL) install(TARGETS compiler-pipeline EXPORT;LLVMExports From 1a17161b9cbec2677a447ac14d7bec2c58742cd4 Mon Sep 17 00:00:00 2001 From: PietroGhg Date: Wed, 6 Mar 2024 14:02:44 +0000 Subject: [PATCH 3/8] Add cmake variables for repo/tag --- sycl/doc/design/SYCLNativeCPU.md | 2 +- sycl/plugins/native_cpu/CMakeLists.txt | 29 ++++++++++++++++++-------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/sycl/doc/design/SYCLNativeCPU.md b/sycl/doc/design/SYCLNativeCPU.md index 9a9989b6a62e7..d2fc7d3b484e8 100644 --- a/sycl/doc/design/SYCLNativeCPU.md +++ b/sycl/doc/design/SYCLNativeCPU.md @@ -47,7 +47,7 @@ python3 buildbot/configure.py \ ``` By default the oneAPI Construction Kit is pulled at the project's configure time using CMake `FetchContent`. This behaviour can be overridden by setting `NATIVECPU_OCK_USE_FETCHCONTENT=Off` and `OCK_SOURCE_DIR=` -in order to use a local checkout of the oneAPI Construction Kit. +in order to use a local checkout of the oneAPI Construction Kit. The CMake variables `OCK_GIT_TAG` and `OCK_GIT_REPO` can be used to override the default git tag and repository used by `FetchContent`. The SYCL Native CPU device needs to be selected at runtime by setting the environment variable `ONEAPI_DEVICE_SELECTOR=native_cpu:cpu`. diff --git a/sycl/plugins/native_cpu/CMakeLists.txt b/sycl/plugins/native_cpu/CMakeLists.txt index bc0ae6016a998..1462e109a0e53 100644 --- a/sycl/plugins/native_cpu/CMakeLists.txt +++ b/sycl/plugins/native_cpu/CMakeLists.txt @@ -24,24 +24,35 @@ add_sycl_plugin(native_cpu ) option(OCK_SOURCE_DIR "Root to a local checkout of the oneAPI Construction Kit" "") +option(OCK_GIT_REPO "Git repository for the oneAPI Construction Kit FetchContent" "") +option(OCK_GIT_TAG "Git tag for the oneAPI Construction Kit FetchContent" "") option(NATIVECPU_OCK_USE_FETCHCONTENT "Use FetchContent to acquire oneAPI Construction Kit source code" On) if(NATIVECPU_USE_OCK) if(NATIVECPU_OCK_USE_FETCHCONTENT) + set(OCK_GIT_INTERNAL_REPO "https://github.com/codeplaysoftware/oneapi-construction-kit.git") + # commit 9a53d126cba574fadab3bef513b1c6d9c1ebc0fd + # Merge: f211f428 b0678100 + # Author: PietroGhg + # Date: Wed Mar 6 13:13:47 2024 +0100 + # Merge pull request #389 from PietroGhg/pietro/skip_spirv_fetchcontent + # Skip FetchContent for SPIRV-Headers if building llvm-spirv + set(OCK_GIT_INTERNAL_TAG 9a53d126cba574fadab3bef513b1c6d9c1ebc0fd) + # Overwrite OCK_GIT_INTERNAL_REPO/OCK_GIT_INTERNAL_TAG if the corresponding options are set + if(OCK_GIT_REPO) + set(OCK_GIT_INTERNAL_REPO "${OCK_GIT_REPO}") + endif() + if(OCK_GIT_TAG) + set(OCK_GIT_INTERNAL_TAG "${OCK_GIT_TAG}") + endif() include(FetchContent) FetchContent_Declare(oneapi-ck - GIT_REPOSITORY https://github.com/codeplaysoftware/oneapi-construction-kit.git - # commit 9a53d126cba574fadab3bef513b1c6d9c1ebc0fd - # Merge: f211f428 b0678100 - # Author: PietroGhg - # Date: Wed Mar 6 13:13:47 2024 +0100 - # Merge pull request #389 from PietroGhg/pietro/skip_spirv_fetchcontent - # Skip FetchContent for SPIRV-Headers if building llvm-spirv - GIT_TAG 9a53d126cba574fadab3bef513b1c6d9c1ebc0fd + GIT_REPOSITORY "${OCK_GIT_INTERNAL_REPO}" + GIT_TAG "${OCK_GIT_INTERNAL_TAG}" ) FetchContent_GetProperties(oneapi-ck) if(NOT oneapi-ck_POPULATED) - message(STATUS "Cloning oneAPI Construction Kit") + message(STATUS "Cloning oneAPI Construction Kit from ${OCK_GIT_INTERNAL_REPO}, tag ${OCK_GIT_INTERNAL_TAG}") FetchContent_Populate(oneapi-ck) message(STATUS "oneAPI Construction Kit cloned in ${oneapi-ck_SOURCE_DIR}") set(OCK_SOURCE_DIR_INTERNAL ${oneapi-ck_SOURCE_DIR}) From 9c869b6f6e3962f1d839473ee1a117ac7753a543 Mon Sep 17 00:00:00 2001 From: PietroGhg Date: Wed, 6 Mar 2024 15:04:37 +0000 Subject: [PATCH 4/8] add newline --- sycl/plugins/native_cpu/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/sycl/plugins/native_cpu/CMakeLists.txt b/sycl/plugins/native_cpu/CMakeLists.txt index 1462e109a0e53..d8e09c60414dd 100644 --- a/sycl/plugins/native_cpu/CMakeLists.txt +++ b/sycl/plugins/native_cpu/CMakeLists.txt @@ -38,6 +38,7 @@ if(NATIVECPU_USE_OCK) # Merge pull request #389 from PietroGhg/pietro/skip_spirv_fetchcontent # Skip FetchContent for SPIRV-Headers if building llvm-spirv set(OCK_GIT_INTERNAL_TAG 9a53d126cba574fadab3bef513b1c6d9c1ebc0fd) + # Overwrite OCK_GIT_INTERNAL_REPO/OCK_GIT_INTERNAL_TAG if the corresponding options are set if(OCK_GIT_REPO) set(OCK_GIT_INTERNAL_REPO "${OCK_GIT_REPO}") From 9896047c41c2c6096b505f66ea55acfd224acc1f Mon Sep 17 00:00:00 2001 From: PietroGhg Date: Thu, 7 Mar 2024 10:41:22 +0000 Subject: [PATCH 5/8] simplify install for multi_llvm --- sycl/plugins/native_cpu/CMakeLists.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/sycl/plugins/native_cpu/CMakeLists.txt b/sycl/plugins/native_cpu/CMakeLists.txt index d8e09c60414dd..14829a5a6f33a 100644 --- a/sycl/plugins/native_cpu/CMakeLists.txt +++ b/sycl/plugins/native_cpu/CMakeLists.txt @@ -83,11 +83,7 @@ if(NATIVECPU_USE_OCK) ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT vecz RUNTIME DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT vecz) set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS vecz) - install(TARGETS multi_llvm - EXPORT;LLVMExports - LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT multi_llvm - ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT multi_llvm - RUNTIME DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT multi_llvm) + install(TARGETS multi_llvm EXPORT;LLVMExports) set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS multi_llvm) target_compile_definitions(LLVMSYCLLowerIR PRIVATE NATIVECPU_USE_OCK) target_include_directories(LLVMSYCLLowerIR PRIVATE From 54d11dd06a933bd8fc481d66c7414983afa528b2 Mon Sep 17 00:00:00 2001 From: PietroGhg Date: Thu, 7 Mar 2024 16:11:29 +0000 Subject: [PATCH 6/8] use set() for string options --- sycl/plugins/native_cpu/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sycl/plugins/native_cpu/CMakeLists.txt b/sycl/plugins/native_cpu/CMakeLists.txt index 14829a5a6f33a..2428b8efe1ae8 100644 --- a/sycl/plugins/native_cpu/CMakeLists.txt +++ b/sycl/plugins/native_cpu/CMakeLists.txt @@ -23,9 +23,9 @@ add_sycl_plugin(native_cpu UnifiedRuntimeCommon ) -option(OCK_SOURCE_DIR "Root to a local checkout of the oneAPI Construction Kit" "") -option(OCK_GIT_REPO "Git repository for the oneAPI Construction Kit FetchContent" "") -option(OCK_GIT_TAG "Git tag for the oneAPI Construction Kit FetchContent" "") +set(OCK_SOURCE_DIR "" CACHE PATH "Root to a local checkout of the oneAPI Construction Kit") +set(OCK_GIT_REPO "" CACHE STRING "Git repository for the oneAPI Construction Kit FetchContent") +set(OCK_GIT_TAG "" CACHE STRING "Git tag for the oneAPI Construction Kit FetchContent") option(NATIVECPU_OCK_USE_FETCHCONTENT "Use FetchContent to acquire oneAPI Construction Kit source code" On) if(NATIVECPU_USE_OCK) From abee76fdd49195f1c96e2727af5516e0f8d75598 Mon Sep 17 00:00:00 2001 From: PietroGhg Date: Thu, 7 Mar 2024 16:15:10 +0000 Subject: [PATCH 7/8] Fix typo --- sycl/plugins/native_cpu/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/plugins/native_cpu/CMakeLists.txt b/sycl/plugins/native_cpu/CMakeLists.txt index 2428b8efe1ae8..f28f82c088eba 100644 --- a/sycl/plugins/native_cpu/CMakeLists.txt +++ b/sycl/plugins/native_cpu/CMakeLists.txt @@ -23,7 +23,7 @@ add_sycl_plugin(native_cpu UnifiedRuntimeCommon ) -set(OCK_SOURCE_DIR "" CACHE PATH "Root to a local checkout of the oneAPI Construction Kit") +set(OCK_SOURCE_DIR "" CACHE PATH "Root of the local checkout of the oneAPI Construction Kit") set(OCK_GIT_REPO "" CACHE STRING "Git repository for the oneAPI Construction Kit FetchContent") set(OCK_GIT_TAG "" CACHE STRING "Git tag for the oneAPI Construction Kit FetchContent") option(NATIVECPU_OCK_USE_FETCHCONTENT "Use FetchContent to acquire oneAPI Construction Kit source code" On) From 88050ef98fe9a6f1700cfdf8391eda1b4bb89dee Mon Sep 17 00:00:00 2001 From: PietroGhg Date: Fri, 8 Mar 2024 09:44:15 +0000 Subject: [PATCH 8/8] update ock tag --- sycl/plugins/native_cpu/CMakeLists.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sycl/plugins/native_cpu/CMakeLists.txt b/sycl/plugins/native_cpu/CMakeLists.txt index f28f82c088eba..aeebb3e6b2cb4 100644 --- a/sycl/plugins/native_cpu/CMakeLists.txt +++ b/sycl/plugins/native_cpu/CMakeLists.txt @@ -31,13 +31,13 @@ option(NATIVECPU_OCK_USE_FETCHCONTENT "Use FetchContent to acquire oneAPI Constr if(NATIVECPU_USE_OCK) if(NATIVECPU_OCK_USE_FETCHCONTENT) set(OCK_GIT_INTERNAL_REPO "https://github.com/codeplaysoftware/oneapi-construction-kit.git") - # commit 9a53d126cba574fadab3bef513b1c6d9c1ebc0fd - # Merge: f211f428 b0678100 - # Author: PietroGhg - # Date: Wed Mar 6 13:13:47 2024 +0100 - # Merge pull request #389 from PietroGhg/pietro/skip_spirv_fetchcontent - # Skip FetchContent for SPIRV-Headers if building llvm-spirv - set(OCK_GIT_INTERNAL_TAG 9a53d126cba574fadab3bef513b1c6d9c1ebc0fd) + # commit 342f06e2bba2ad5c3bb3773505fce1d0e3f872d9 + # Merge: 51c1b31c d74b3e1a + # Author: Harald van Dijk + # Date: Thu Mar 7 14:19:58 2024 +0000 + # Merge pull request #397 from hvdijk/ignore-gl_test + # Ignore test_gl test. + set(OCK_GIT_INTERNAL_TAG 342f06e2bba2ad5c3bb3773505fce1d0e3f872d9) # Overwrite OCK_GIT_INTERNAL_REPO/OCK_GIT_INTERNAL_TAG if the corresponding options are set if(OCK_GIT_REPO)