From 35ec8261c6e1a32ac1da8e21ab08804c245a31f3 Mon Sep 17 00:00:00 2001 From: Alexey Sachkov Date: Thu, 26 Sep 2024 01:45:53 -0700 Subject: [PATCH 1/2] [SYCL][NFC] Move more UR-related declarations into library This patch also cleaned up some `#include` directives --- sycl/include/sycl/detail/array.hpp | 1 - sycl/include/sycl/detail/cg_types.hpp | 1 - sycl/include/sycl/detail/ur.hpp | 13 ------ .../ext/oneapi/accessor_property_list.hpp | 1 - sycl/include/sycl/kernel_handler.hpp | 1 - sycl/source/backend.cpp | 3 +- sycl/source/backend/level_zero.cpp | 2 +- sycl/source/context.cpp | 2 +- sycl/source/detail/global_handler.cpp | 2 +- sycl/source/detail/platform_impl.cpp | 4 +- .../program_manager/program_manager.cpp | 2 +- sycl/source/detail/sycl_mem_obj_i.hpp | 3 +- sycl/source/detail/sycl_mem_obj_t.hpp | 1 + sycl/source/detail/ur.cpp | 3 +- sycl/source/detail/ur.hpp | 41 +++++++++++++++++++ sycl/source/device.cpp | 2 +- sycl/source/kernel.cpp | 2 +- sycl/source/platform.cpp | 2 +- sycl/test/include_deps/sycl_accessor.hpp.cpp | 2 +- sycl/test/include_deps/sycl_buffer.hpp.cpp | 2 +- .../include_deps/sycl_detail_core.hpp.cpp | 2 +- sycl/unittests/helpers/UrMock.hpp | 1 + 22 files changed, 61 insertions(+), 32 deletions(-) create mode 100644 sycl/source/detail/ur.hpp diff --git a/sycl/include/sycl/detail/array.hpp b/sycl/include/sycl/detail/array.hpp index f0602c52885d8..30dc6311b2105 100644 --- a/sycl/include/sycl/detail/array.hpp +++ b/sycl/include/sycl/detail/array.hpp @@ -10,7 +10,6 @@ #include // for __SYCL_ALWAYS_INLINE #include -#include // for UR_RESULT_ERROR_INVALID_VALUE #include // for size_t #include // for enable_if_t diff --git a/sycl/include/sycl/detail/cg_types.hpp b/sycl/include/sycl/detail/cg_types.hpp index cb7b066a256b1..e9bc38e0e1e87 100644 --- a/sycl/include/sycl/detail/cg_types.hpp +++ b/sycl/include/sycl/detail/cg_types.hpp @@ -23,7 +23,6 @@ #include // for nd_item #include // for nd_range #include // for range, operator* -#include // for UR_RESULT_ERROR_INVALID_WORK_GROUP_SIZE #include // for function #include // for size_t diff --git a/sycl/include/sycl/detail/ur.hpp b/sycl/include/sycl/detail/ur.hpp index fe797853212fc..70b6517b43748 100644 --- a/sycl/include/sycl/detail/ur.hpp +++ b/sycl/include/sycl/detail/ur.hpp @@ -19,7 +19,6 @@ #include #include -#include #include #include @@ -103,9 +102,6 @@ __SYCL_EXPORT void contextSetExtendedDeleter(const sycl::context &constext, void *user_data); } -class Adapter; -using AdapterPtr = std::shared_ptr; - // TODO: To be removed as this was only introduced for esimd which was removed. template __SYCL_EXPORT void *getPluginOpaqueData(void *opaquedata_arg); @@ -123,15 +119,6 @@ int unloadOsLibrary(void *Library); // library, implementation is OS dependent. void *getOsLibraryFuncAddress(void *Library, const std::string &FunctionName); -void *getURLoaderLibrary(); - -// Performs UR one-time initialization. -std::vector & -initializeUr(ur_loader_config_handle_t LoaderConfig = nullptr); - -// Get the adapter serving given backend. -template const AdapterPtr &getAdapter(); - // The SYCL_UR_TRACE sets what we will trace. // This is a bit-mask of various things we'd want to trace. enum TraceLevel { TRACE_BASIC = 0x1, TRACE_CALLS = 0x2, TRACE_ALL = -1 }; diff --git a/sycl/include/sycl/ext/oneapi/accessor_property_list.hpp b/sycl/include/sycl/ext/oneapi/accessor_property_list.hpp index 7a1ce1119dbbd..3fd3648671cb4 100644 --- a/sycl/include/sycl/ext/oneapi/accessor_property_list.hpp +++ b/sycl/include/sycl/ext/oneapi/accessor_property_list.hpp @@ -14,7 +14,6 @@ #include // for PropertyListBase #include #include // for property_list -#include // for UR_RESULT_ERROR_INVALID_VALUE #include // for bitset #include // for shared_ptr diff --git a/sycl/include/sycl/kernel_handler.hpp b/sycl/include/sycl/kernel_handler.hpp index 1c59400cdc273..20e89abdf14dd 100644 --- a/sycl/include/sycl/kernel_handler.hpp +++ b/sycl/include/sycl/kernel_handler.hpp @@ -11,7 +11,6 @@ #include // for __SYCL_TYPE #include // for __SYCL_ALWAYS_INLINE #include // for feature_not_supported -#include // for UR_RESULT_ERROR_INVALID_OPERATION #ifdef __SYCL_DEVICE_ONLY__ #include diff --git a/sycl/source/backend.cpp b/sycl/source/backend.cpp index a6e422264178b..2c876a570e3c6 100644 --- a/sycl/source/backend.cpp +++ b/sycl/source/backend.cpp @@ -13,10 +13,11 @@ #include "detail/kernel_id_impl.hpp" #include "detail/platform_impl.hpp" #include "detail/queue_impl.hpp" -#include "sycl/detail/impl_utils.hpp" +#include #include #include #include +#include #include #include #include diff --git a/sycl/source/backend/level_zero.cpp b/sycl/source/backend/level_zero.cpp index 1fe93c27ee866..e6b42c366243c 100644 --- a/sycl/source/backend/level_zero.cpp +++ b/sycl/source/backend/level_zero.cpp @@ -9,8 +9,8 @@ #include #include #include +#include #include -#include namespace sycl { inline namespace _V1 { diff --git a/sycl/source/context.cpp b/sycl/source/context.cpp index 63b3c2350e45d..a5ef6c89afe0f 100644 --- a/sycl/source/context.cpp +++ b/sycl/source/context.cpp @@ -8,9 +8,9 @@ #include #include +#include #include #include -#include #include #include #include diff --git a/sycl/source/detail/global_handler.cpp b/sycl/source/detail/global_handler.cpp index a13d81b54daca..5669fbdaacc50 100644 --- a/sycl/source/detail/global_handler.cpp +++ b/sycl/source/detail/global_handler.cpp @@ -18,10 +18,10 @@ #include #include #include +#include #include #include #include -#include #ifdef _WIN32 #include diff --git a/sycl/source/detail/platform_impl.cpp b/sycl/source/detail/platform_impl.cpp index 652e47a5be997..b02d098cbcaac 100644 --- a/sycl/source/detail/platform_impl.cpp +++ b/sycl/source/detail/platform_impl.cpp @@ -6,19 +6,19 @@ // //===----------------------------------------------------------------------===// -#include "sycl/detail/ur.hpp" -#include "sycl/info/info_desc.hpp" #include #include #include #include #include #include +#include #include #include #include #include #include +#include #include #include diff --git a/sycl/source/detail/program_manager/program_manager.cpp b/sycl/source/detail/program_manager/program_manager.cpp index 2fa9e75be6f0c..3eef77f6b8e03 100644 --- a/sycl/source/detail/program_manager/program_manager.cpp +++ b/sycl/source/detail/program_manager/program_manager.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -26,7 +27,6 @@ #include #include #include -#include #include #include #include diff --git a/sycl/source/detail/sycl_mem_obj_i.hpp b/sycl/source/detail/sycl_mem_obj_i.hpp index 4d1e84d2ef836..776b74a85e03a 100644 --- a/sycl/source/detail/sycl_mem_obj_i.hpp +++ b/sycl/source/detail/sycl_mem_obj_i.hpp @@ -8,9 +8,10 @@ #pragma once -#include #include +#include + namespace sycl { inline namespace _V1 { diff --git a/sycl/source/detail/sycl_mem_obj_t.hpp b/sycl/source/detail/sycl_mem_obj_t.hpp index 5082597ce14f8..cd3a717fdb8cf 100644 --- a/sycl/source/detail/sycl_mem_obj_t.hpp +++ b/sycl/source/detail/sycl_mem_obj_t.hpp @@ -34,6 +34,7 @@ namespace detail { class context_impl; class event_impl; class Adapter; +using AdapterPtr = std::shared_ptr; using ContextImplPtr = std::shared_ptr; using EventImplPtr = std::shared_ptr; diff --git a/sycl/source/detail/ur.cpp b/sycl/source/detail/ur.cpp index 867cc7a899b90..bc941673fd6c6 100644 --- a/sycl/source/detail/ur.cpp +++ b/sycl/source/detail/ur.cpp @@ -12,9 +12,10 @@ /// /// \ingroup sycl_ur -#include "context_impl.hpp" +#include "ur.hpp" #include #include +#include #include #include #include diff --git a/sycl/source/detail/ur.hpp b/sycl/source/detail/ur.hpp new file mode 100644 index 0000000000000..e0014866ebeb8 --- /dev/null +++ b/sycl/source/detail/ur.hpp @@ -0,0 +1,41 @@ +//==---------- ur.hpp - Unified Runtime integration helpers ----------------==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +/// \file +/// +/// C++ utilities for Unified Runtime integration. +/// +/// \ingroup sycl_ur + +#pragma once + +#include +#include + +#include +#include + +namespace sycl { +inline namespace _V1 { +namespace detail { +class Adapter; +using AdapterPtr = std::shared_ptr; + +namespace ur { +void *getURLoaderLibrary(); + +// Performs UR one-time initialization. +std::vector & +initializeUr(ur_loader_config_handle_t LoaderConfig = nullptr); + +// Get the adapter serving given backend. +template const AdapterPtr &getAdapter(); +} // namespace ur +} // namespace detail +} // namespace _V1 +} // namespace sycl diff --git a/sycl/source/device.cpp b/sycl/source/device.cpp index fe83f60585f2e..e1abad8af7927 100644 --- a/sycl/source/device.cpp +++ b/sycl/source/device.cpp @@ -10,9 +10,9 @@ #include #include #include +#include #include #include -#include #include #include #include diff --git a/sycl/source/kernel.cpp b/sycl/source/kernel.cpp index 45da7d87270e9..634f22b09bafb 100644 --- a/sycl/source/kernel.cpp +++ b/sycl/source/kernel.cpp @@ -9,8 +9,8 @@ #include #include #include +#include #include -#include #include namespace sycl { diff --git a/sycl/source/platform.cpp b/sycl/source/platform.cpp index 965a8625c1ebf..090d7b27c7ddd 100644 --- a/sycl/source/platform.cpp +++ b/sycl/source/platform.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sycl/test/include_deps/sycl_accessor.hpp.cpp b/sycl/test/include_deps/sycl_accessor.hpp.cpp index ae896a3987e85..c1f3ad24514ca 100644 --- a/sycl/test/include_deps/sycl_accessor.hpp.cpp +++ b/sycl/test/include_deps/sycl_accessor.hpp.cpp @@ -65,7 +65,6 @@ // CHECK-NEXT: CL/cl_platform.h // CHECK-NEXT: CL/cl_ext.h // CHECK-NEXT: detail/string.hpp -// CHECK-NEXT: ur_api.h // CHECK-NEXT: detail/common.hpp // CHECK-NEXT: detail/is_device_copyable.hpp // CHECK-NEXT: detail/owner_less_base.hpp @@ -82,6 +81,7 @@ // CHECK-NEXT: properties/property_traits.hpp // CHECK-NEXT: id.hpp // CHECK-NEXT: range.hpp +// CHECK-NEXT: ur_api.h // CHECK-NEXT: detail/accessor_iterator.hpp // CHECK-NEXT: detail/generic_type_traits.hpp // CHECK-NEXT: ext/oneapi/bfloat16.hpp diff --git a/sycl/test/include_deps/sycl_buffer.hpp.cpp b/sycl/test/include_deps/sycl_buffer.hpp.cpp index 7002e5b07c60f..4fe4cf52c77c7 100644 --- a/sycl/test/include_deps/sycl_buffer.hpp.cpp +++ b/sycl/test/include_deps/sycl_buffer.hpp.cpp @@ -20,7 +20,6 @@ // CHECK-NEXT: CL/cl_platform.h // CHECK-NEXT: CL/cl_ext.h // CHECK-NEXT: detail/string.hpp -// CHECK-NEXT: ur_api.h // CHECK-NEXT: detail/common.hpp // CHECK-NEXT: stl_wrappers/cassert // CHECK-NEXT: stl_wrappers/assert.h @@ -43,4 +42,5 @@ // CHECK-NEXT: properties/property_traits.hpp // CHECK-NEXT: id.hpp // CHECK-NEXT: range.hpp +// CHECK-NEXT: ur_api.h // CHECK-EMPTY: diff --git a/sycl/test/include_deps/sycl_detail_core.hpp.cpp b/sycl/test/include_deps/sycl_detail_core.hpp.cpp index 6ed467969333d..d13f28aee6b14 100644 --- a/sycl/test/include_deps/sycl_detail_core.hpp.cpp +++ b/sycl/test/include_deps/sycl_detail_core.hpp.cpp @@ -66,7 +66,6 @@ // CHECK-NEXT: CL/cl_platform.h // CHECK-NEXT: CL/cl_ext.h // CHECK-NEXT: detail/string.hpp -// CHECK-NEXT: ur_api.h // CHECK-NEXT: detail/common.hpp // CHECK-NEXT: detail/is_device_copyable.hpp // CHECK-NEXT: detail/owner_less_base.hpp @@ -83,6 +82,7 @@ // CHECK-NEXT: properties/property_traits.hpp // CHECK-NEXT: id.hpp // CHECK-NEXT: range.hpp +// CHECK-NEXT: ur_api.h // CHECK-NEXT: detail/accessor_iterator.hpp // CHECK-NEXT: detail/generic_type_traits.hpp // CHECK-NEXT: ext/oneapi/bfloat16.hpp diff --git a/sycl/unittests/helpers/UrMock.hpp b/sycl/unittests/helpers/UrMock.hpp index 71c9962155b2a..3bbd37833693c 100644 --- a/sycl/unittests/helpers/UrMock.hpp +++ b/sycl/unittests/helpers/UrMock.hpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include From 6003a791ec8882a9a3de9967f70780c5136596ae Mon Sep 17 00:00:00 2001 From: Alexey Sachkov Date: Thu, 26 Sep 2024 03:50:24 -0700 Subject: [PATCH 2/2] Blind attempt to fix Win build --- sycl/source/detail/adapter.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/source/detail/adapter.hpp b/sycl/source/detail/adapter.hpp index 1f8ce18e3eb54..ef2ce4f513773 100644 --- a/sycl/source/detail/adapter.hpp +++ b/sycl/source/detail/adapter.hpp @@ -9,11 +9,11 @@ #pragma once #include +#include #include #include #include #include -#include #include #ifdef XPTI_ENABLE_INSTRUMENTATION