From 9f53a78e4b67b2514e911ec62d183530882c251c Mon Sep 17 00:00:00 2001 From: premanandrao Date: Fri, 20 Sep 2024 13:34:15 -0400 Subject: [PATCH 1/8] [SYCL] Fix diagnostic about non-external function/variable (#15372) We were issuing a diagnostic when applying attributes like [[sycl_device]] or [[intel::device_indirectly_callable]] on functions/variables without external linkage - but the diagnostic text assumed that this occurred only with static entities or entities within unnamed namespaces. The following example demonstrates a case where the previous diagnostic text was misleading: ``` namespace { struct S {}; } [[sycl_device]] void foo(S); ``` --- clang/include/clang/Basic/DiagnosticSemaKinds.td | 5 ++--- clang/test/SemaSYCL/device-indirectly-callable-attr.cpp | 9 +++++++-- clang/test/SemaSYCL/device_global_external.cpp | 9 +++++++-- clang/test/SemaSYCL/sycl-device.cpp | 9 +++++++-- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 1e94b129fc387..f9ad5e54f2939 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -12486,9 +12486,8 @@ def err_sycl_function_attribute_mismatch : Error< def err_sycl_x_y_z_arguments_must_be_one : Error< "all %0 attribute arguments must be '1' when the %1 attribute argument is '0'">; def err_sycl_attribute_internal_decl - : Error<"%0 attribute cannot be applied to a " - "static %select{function|variable}1 or %select{function|variable}1 " - "in an anonymous namespace">; + : Error<"%0 attribute cannot be applied to a %select{function|variable}1" + " without external linkage">; def err_sycl_attribute_not_device_global : Error<"%0 attribute can only be applied to 'device_global' variables">; def err_fpga_attribute_incorrect_variable diff --git a/clang/test/SemaSYCL/device-indirectly-callable-attr.cpp b/clang/test/SemaSYCL/device-indirectly-callable-attr.cpp index a79f3f8eae244..80cf6fc602b5c 100644 --- a/clang/test/SemaSYCL/device-indirectly-callable-attr.cpp +++ b/clang/test/SemaSYCL/device-indirectly-callable-attr.cpp @@ -12,16 +12,21 @@ int N; void bar() {} -[[intel::device_indirectly_callable]] // expected-error {{'device_indirectly_callable' attribute cannot be applied to a static function or function in an anonymous namespace}} +[[intel::device_indirectly_callable]] // expected-error {{'device_indirectly_callable' attribute cannot be applied to a function without external linkage}} static void func1() {} namespace { -[[intel::device_indirectly_callable]] // expected-error {{'device_indirectly_callable' attribute cannot be applied to a static function or function in an anonymous namespace}} +[[intel::device_indirectly_callable]] // expected-error {{'device_indirectly_callable' attribute cannot be applied to a function without external linkage}} void func2() {} + +struct UnnX {}; } +[[intel::device_indirectly_callable]] // expected-error {{'device_indirectly_callable' attribute cannot be applied to a function without external linkage}} +void func4(UnnX) {} + class A { [[intel::device_indirectly_callable]] A() {} diff --git a/clang/test/SemaSYCL/device_global_external.cpp b/clang/test/SemaSYCL/device_global_external.cpp index a4824d2453e0e..5b95102096489 100644 --- a/clang/test/SemaSYCL/device_global_external.cpp +++ b/clang/test/SemaSYCL/device_global_external.cpp @@ -5,7 +5,7 @@ using namespace sycl::ext::oneapi; SYCL_EXTERNAL device_global glob; -// expected-error@+1{{'sycl_device' attribute cannot be applied to a static variable or variable in an anonymous namespace}} +// expected-error@+1{{'sycl_device' attribute cannot be applied to a variable without external linkage}} SYCL_EXTERNAL static device_global static_glob; namespace foo { @@ -20,10 +20,15 @@ struct RandomStruct { SYCL_EXTERNAL RandomStruct S; namespace { -// expected-error@+1{{'sycl_device' attribute cannot be applied to a static variable or variable in an anonymous namespace}} +// expected-error@+1{{'sycl_device' attribute cannot be applied to a variable without external linkage}} SYCL_EXTERNAL device_global same_name; + +struct UnnX {}; } // namespace +// expected-error@+1{{'sycl_device' attribute cannot be applied to a variable without external linkage}} +SYCL_EXTERNAL device_global dg_x; + // expected-error@+1{{'sycl_device' attribute can only be applied to 'device_global' variables}} SYCL_EXTERNAL int AAA; diff --git a/clang/test/SemaSYCL/sycl-device.cpp b/clang/test/SemaSYCL/sycl-device.cpp index 4d4004338166d..2e7e1d0f7f51d 100644 --- a/clang/test/SemaSYCL/sycl-device.cpp +++ b/clang/test/SemaSYCL/sycl-device.cpp @@ -12,14 +12,19 @@ int N; __attribute__((sycl_device(3))) // expected-error {{'sycl_device' attribute takes no arguments}} void bar() {} -__attribute__((sycl_device)) // expected-error {{'sycl_device' attribute cannot be applied to a static function or function in an anonymous namespace}} +__attribute__((sycl_device)) // expected-error {{'sycl_device' attribute cannot be applied to a function without external linkage}} static void func1() {} namespace { - __attribute__((sycl_device)) // expected-error {{'sycl_device' attribute cannot be applied to a static function or function in an anonymous namespace}} + __attribute__((sycl_device)) // expected-error {{'sycl_device' attribute cannot be applied to a function without external linkage}} void func2() {} + + struct UnnX {}; } +__attribute__((sycl_device)) // expected-error {{'sycl_device' attribute cannot be applied to a function without external linkage}} + void func4(UnnX) {} + class A { __attribute__((sycl_device)) A() {} From c0b49db62a17549bd93e8b83bea20ea79eebe708 Mon Sep 17 00:00:00 2001 From: Michael Toguchi Date: Fri, 20 Sep 2024 11:19:32 -0700 Subject: [PATCH 2/8] [SYCL][NFC] Re-enable sycl.c test on Windows (#15433) The issue dealt with the resetting of the PATH environment variable. This was masking potential runtime dependencies (DLLs and such) for other tools being used when running the test. The solution is to append the PATH for the dummy `aoc` instead of overwriting. --- clang/test/Driver/sycl.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/clang/test/Driver/sycl.c b/clang/test/Driver/sycl.c index c248829ce1fcb..322315673b4e1 100644 --- a/clang/test/Driver/sycl.c +++ b/clang/test/Driver/sycl.c @@ -1,6 +1,3 @@ -// Failing on Windows - temporarily disable -// REQUIRES: system-linux - // RUN: %clang -### -fsycl -c %s 2>&1 | FileCheck %s --check-prefix=ENABLED // RUN: %clang -### -fsycl %s 2>&1 | FileCheck %s --check-prefix=ENABLED // RUN: %clang -### -fno-sycl -fsycl %s 2>&1 | FileCheck %s --check-prefix=ENABLED @@ -107,7 +104,7 @@ // Test with a bad argument is expected to fail // RUN: not %clang -fsycl-help=foo %s 2>&1 | FileCheck %s --check-prefix=SYCL-HELP-BADARG // RUN: %clang -### -fsycl-help=gen %s 2>&1 | FileCheck %s --check-prefix=SYCL-HELP-GEN -// RUN: env PATH=%t-sycl-dir %clang -### -fsycl-help=fpga %s 2>&1 | FileCheck %s --check-prefixes=SYCL-HELP-FPGA,SYCL-HELP-FPGA-OUT -DDIR=%t-sycl-dir +// RUN: env "PATH=%t-sycl-dir%{pathsep}%PATH%" %clang -### -fsycl-help=fpga %s 2>&1 | FileCheck %s --check-prefixes=SYCL-HELP-FPGA,SYCL-HELP-FPGA-OUT -DDIR=%t-sycl-dir // RUN: %clang -### -fsycl-help=x86_64 %s 2>&1 | FileCheck %s --check-prefix=SYCL-HELP-CPU // RUN: %clang -### -fsycl-help %s 2>&1 | FileCheck %s --check-prefixes=SYCL-HELP-GEN,SYCL-HELP-FPGA,SYCL-HELP-CPU // SYCL-HELP-BADARG: unsupported argument 'foo' to option '-fsycl-help=' From 6dcc82626735cf48537f1862419a23e13f532219 Mon Sep 17 00:00:00 2001 From: Yury Plyakhin Date: Fri, 20 Sep 2024 11:59:23 -0700 Subject: [PATCH 3/8] [SYCL][E2E][Joint Matrix] Make half tests UNSUPPORTED on some arch (#15447) Add UNSUPPORTED for SPR for Joint Matrix fp16 tests in SPVCooperativeMatrix folder to avoid unexpected pass. --- .../SPVCooperativeMatrix/SG32/element_wise_all_ops_half.cpp | 4 +++- .../Matrix/SPVCooperativeMatrix/SG32/joint_matrix_half.cpp | 4 +++- .../Matrix/SPVCooperativeMatrix/element_wise_all_ops_half.cpp | 3 +++ .../Matrix/SPVCooperativeMatrix/joint_matrix_half.cpp | 3 +++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/sycl/test-e2e/Matrix/SPVCooperativeMatrix/SG32/element_wise_all_ops_half.cpp b/sycl/test-e2e/Matrix/SPVCooperativeMatrix/SG32/element_wise_all_ops_half.cpp index a922c241e6677..4acd374a74211 100644 --- a/sycl/test-e2e/Matrix/SPVCooperativeMatrix/SG32/element_wise_all_ops_half.cpp +++ b/sycl/test-e2e/Matrix/SPVCooperativeMatrix/SG32/element_wise_all_ops_half.cpp @@ -6,7 +6,9 @@ // //===----------------------------------------------------------------------===// // SG size = 32 is not currently supported for SYCL Joint Matrix by IGC on DG2 -// UNSUPPORTED: gpu-intel-dg2 +// SYCL Joint Matrix fp16 operations are not supported on SPR +// UNSUPPORTED: gpu-intel-dg2, arch-intel_cpu_spr + // REQUIRES: aspect-fp16 // REQUIRES: aspect-ext_intel_matrix // REQUIRES-INTEL-DRIVER: lin: 27501, win: 101.4943 diff --git a/sycl/test-e2e/Matrix/SPVCooperativeMatrix/SG32/joint_matrix_half.cpp b/sycl/test-e2e/Matrix/SPVCooperativeMatrix/SG32/joint_matrix_half.cpp index 3d82602130459..a0acb935699de 100644 --- a/sycl/test-e2e/Matrix/SPVCooperativeMatrix/SG32/joint_matrix_half.cpp +++ b/sycl/test-e2e/Matrix/SPVCooperativeMatrix/SG32/joint_matrix_half.cpp @@ -6,7 +6,9 @@ // //===----------------------------------------------------------------------===// // SG size = 32 is not currently supported for SYCL Joint Matrix by IGC on DG2 -// UNSUPPORTED: gpu-intel-dg2 +// SYCL Joint Matrix fp16 operations are not supported on SPR +// UNSUPPORTED: gpu-intel-dg2, arch-intel_cpu_spr + // REQUIRES: aspect-fp16 // REQUIRES: aspect-ext_intel_matrix // REQUIRES-INTEL-DRIVER: lin: 27501, win: 101.4943 diff --git a/sycl/test-e2e/Matrix/SPVCooperativeMatrix/element_wise_all_ops_half.cpp b/sycl/test-e2e/Matrix/SPVCooperativeMatrix/element_wise_all_ops_half.cpp index f907360c25f5f..f1873f848ac72 100644 --- a/sycl/test-e2e/Matrix/SPVCooperativeMatrix/element_wise_all_ops_half.cpp +++ b/sycl/test-e2e/Matrix/SPVCooperativeMatrix/element_wise_all_ops_half.cpp @@ -8,6 +8,9 @@ // REQUIRES: aspect-fp16 // REQUIRES: aspect-ext_intel_matrix +// SYCL Joint Matrix fp16 operations are not supported on SPR +// UNSUPPORTED: arch-intel_cpu_spr + // RUN: %{build} -D__SPIRV_USE_COOPERATIVE_MATRIX -o %t.out // RUN: %{run} %t.out diff --git a/sycl/test-e2e/Matrix/SPVCooperativeMatrix/joint_matrix_half.cpp b/sycl/test-e2e/Matrix/SPVCooperativeMatrix/joint_matrix_half.cpp index 6dab4c8445baa..52a6f6165a355 100644 --- a/sycl/test-e2e/Matrix/SPVCooperativeMatrix/joint_matrix_half.cpp +++ b/sycl/test-e2e/Matrix/SPVCooperativeMatrix/joint_matrix_half.cpp @@ -8,6 +8,9 @@ // REQUIRES: aspect-fp16 // REQUIRES: aspect-ext_intel_matrix +// SYCL Joint Matrix fp16 operations are not supported on SPR +// UNSUPPORTED: arch-intel_cpu_spr + // RUN: %{build} -D__SPIRV_USE_COOPERATIVE_MATRIX -o %t.out // RUN: %{run} %t.out From 2fd879e98b41c19e5daf19426e45bb0c88f1b131 Mon Sep 17 00:00:00 2001 From: Piotr Balcer Date: Fri, 20 Sep 2024 21:30:08 +0200 Subject: [PATCH 4/8] [UR] fix perf regression in tracing layer (#15457) --- sycl/cmake/modules/FetchUnifiedRuntime.cmake | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sycl/cmake/modules/FetchUnifiedRuntime.cmake b/sycl/cmake/modules/FetchUnifiedRuntime.cmake index 1c245a91ca59d..5a95f16ed5060 100644 --- a/sycl/cmake/modules/FetchUnifiedRuntime.cmake +++ b/sycl/cmake/modules/FetchUnifiedRuntime.cmake @@ -117,13 +117,13 @@ if(SYCL_UR_USE_FETCH_CONTENT) endfunction() set(UNIFIED_RUNTIME_REPO "https://github.com/oneapi-src/unified-runtime.git") - # commit 897bcfb10a7e13b8e413278550e845322f6bd560 (HEAD, origin/main, origin/HEAD) - # Merge: 18514924 71cdf253 + # commit 7384e2d7b908de0b2bca9f3c57827ea84698864e + # Merge: ed85c3e2 a32549b4 # Author: Omar Ahmed - # Date: Thu Sep 19 14:35:55 2024 +0100 - # Merge pull request #2022 from nrspruit/add_3_channel_image_support - # [L0] Add 3-channel image support - set(UNIFIED_RUNTIME_TAG 897bcfb10a7e13b8e413278550e845322f6bd560) + # Date: Fri Sep 20 14:56:40 2024 +0100 + # Merge pull request #2108 from pbalcer/fix-perf-tracing-logs + # fix perf regression in tracing layer + set(UNIFIED_RUNTIME_TAG 7384e2d7b908de0b2bca9f3c57827ea84698864e) set(UMF_BUILD_EXAMPLES OFF CACHE INTERNAL "EXAMPLES") # Due to the use of dependentloadflag and no installer for UMF and hwloc we need From b081c36b09b173930b242f2c51b986c3b4325b06 Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Sun, 22 Sep 2024 23:37:57 -0700 Subject: [PATCH 5/8] [SYCL] Fix uncaught exception reported by analysis (#15448) This PR fixes the uncuahgt exception in dllMain() reported by static analysis tool by adding a try-catch block. --- sycl/source/detail/global_handler.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sycl/source/detail/global_handler.cpp b/sycl/source/detail/global_handler.cpp index 0623be269edaf..9f0d6df7282d1 100644 --- a/sycl/source/detail/global_handler.cpp +++ b/sycl/source/detail/global_handler.cpp @@ -381,7 +381,12 @@ extern "C" __SYCL_EXPORT BOOL WINAPI DllMain(HINSTANCE hinstDLL, // release. #endif - shutdown_win(); + try { + shutdown_win(); + } catch (std::exception &e) { + __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in shutdown_win", e); + return FALSE; + } break; case DLL_PROCESS_ATTACH: if (PrintUrTrace) From 5cd9de100f8df3692b492e22d056e88798873ceb Mon Sep 17 00:00:00 2001 From: aarongreig Date: Mon, 23 Sep 2024 01:58:20 -0700 Subject: [PATCH 6/8] [SYCL] Rename Plugin object -> Adapter. (#15363) Also fix a few references to "plugin" in source files and a unittest script. --- sycl/include/sycl/detail/ur.hpp | 10 +- sycl/include/sycl/handler.hpp | 8 +- sycl/source/backend.cpp | 88 +++---- sycl/source/backend/level_zero.cpp | 8 +- sycl/source/backend/opencl.cpp | 38 +-- sycl/source/context.cpp | 10 +- .../source/detail/{plugin.hpp => adapter.hpp} | 48 ++-- sycl/source/detail/allowlist.cpp | 11 +- sycl/source/detail/allowlist.hpp | 4 +- sycl/source/detail/bindless_images.cpp | 108 ++++----- sycl/source/detail/buffer_impl.cpp | 16 +- sycl/source/detail/context_impl.cpp | 51 ++-- sycl/source/detail/context_impl.hpp | 10 +- sycl/source/detail/context_info.hpp | 6 +- .../source/detail/device_global_map_entry.cpp | 14 +- .../source/detail/device_global_map_entry.hpp | 2 +- sycl/source/detail/device_image_impl.hpp | 21 +- sycl/source/detail/device_impl.cpp | 149 ++++++------ sycl/source/detail/device_impl.hpp | 10 +- sycl/source/detail/device_info.hpp | 96 ++++---- .../detail/error_handling/error_handling.cpp | 48 ++-- .../detail/error_handling/error_handling.hpp | 2 +- sycl/source/detail/event_impl.cpp | 42 ++-- sycl/source/detail/event_impl.hpp | 8 +- sycl/source/detail/event_info.hpp | 14 +- sycl/source/detail/global_handler.cpp | 38 +-- sycl/source/detail/global_handler.hpp | 10 +- sycl/source/detail/graph_impl.cpp | 30 +-- sycl/source/detail/image_impl.cpp | 12 +- sycl/source/detail/kernel_bundle_impl.hpp | 28 +-- sycl/source/detail/kernel_impl.cpp | 10 +- sycl/source/detail/kernel_impl.hpp | 26 +- sycl/source/detail/kernel_info.hpp | 44 ++-- sycl/source/detail/kernel_program_cache.cpp | 6 +- sycl/source/detail/kernel_program_cache.hpp | 24 +- sycl/source/detail/mem_alloc_helper.hpp | 8 +- sycl/source/detail/memory_manager.cpp | 225 +++++++++--------- .../detail/persistent_device_code_cache.cpp | 14 +- sycl/source/detail/physical_mem_impl.hpp | 18 +- sycl/source/detail/platform_impl.cpp | 120 +++++----- sycl/source/detail/platform_impl.hpp | 49 ++-- sycl/source/detail/platform_info.hpp | 20 +- sycl/source/detail/posix_ur.cpp | 2 +- .../program_manager/program_manager.cpp | 185 +++++++------- sycl/source/detail/queue_impl.cpp | 16 +- sycl/source/detail/queue_impl.hpp | 34 +-- sycl/source/detail/sampler_impl.cpp | 20 +- sycl/source/detail/scheduler/commands.cpp | 147 ++++++------ sycl/source/detail/scheduler/commands.hpp | 2 +- .../source/detail/scheduler/graph_builder.cpp | 2 +- sycl/source/detail/sycl_mem_obj_t.cpp | 41 ++-- sycl/source/detail/sycl_mem_obj_t.hpp | 4 +- sycl/source/detail/ur.cpp | 76 +++--- sycl/source/detail/ur_utils.hpp | 18 +- sycl/source/detail/usm/usm_impl.cpp | 32 +-- sycl/source/device.cpp | 41 ++-- sycl/source/event.cpp | 2 +- sycl/source/handler.cpp | 10 +- sycl/source/interop_handle.cpp | 4 +- sycl/source/kernel.cpp | 6 +- sycl/source/platform.cpp | 8 +- sycl/source/virtual_mem.cpp | 28 +-- sycl/test/Unit/lit.cfg.py | 6 +- sycl/tools/sycl-ls/sycl-ls.cpp | 2 +- .../Extensions/CommandGraph/InOrderQueue.cpp | 4 +- .../SYCL2020/DeviceGetInfoAspects.cpp | 2 +- sycl/unittests/SYCL2020/HasExtension.cpp | 2 +- sycl/unittests/SYCL2020/KernelBundle.cpp | 4 +- sycl/unittests/assert/assert.cpp | 9 +- sycl/unittests/helpers/UrMock.hpp | 9 +- sycl/unittests/scheduler/Commands.cpp | 2 +- .../scheduler/LeafLimitDiffContexts.cpp | 3 +- sycl/unittests/xpti_trace/NodeCreation.cpp | 2 +- .../unittests/xpti_trace/QueueApiFailures.cpp | 2 +- sycl/unittests/xpti_trace/QueueIDCheck.cpp | 2 +- .../ur_win_proxy_loader.cpp | 45 ++-- xpti/doc/SYCL_Tracing_Implementation.md | 2 +- 77 files changed, 1144 insertions(+), 1134 deletions(-) rename sycl/source/detail/{plugin.hpp => adapter.hpp} (86%) diff --git a/sycl/include/sycl/detail/ur.hpp b/sycl/include/sycl/detail/ur.hpp index 1320cf5e82449..fe797853212fc 100644 --- a/sycl/include/sycl/detail/ur.hpp +++ b/sycl/include/sycl/detail/ur.hpp @@ -103,8 +103,8 @@ __SYCL_EXPORT void contextSetExtendedDeleter(const sycl::context &constext, void *user_data); } -class plugin; -using PluginPtr = std::shared_ptr; +class Adapter; +using AdapterPtr = std::shared_ptr; // TODO: To be removed as this was only introduced for esimd which was removed. template @@ -126,11 +126,11 @@ void *getOsLibraryFuncAddress(void *Library, const std::string &FunctionName); void *getURLoaderLibrary(); // Performs UR one-time initialization. -std::vector & +std::vector & initializeUr(ur_loader_config_handle_t LoaderConfig = nullptr); -// Get the plugin serving given backend. -template const PluginPtr &getPlugin(); +// 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. diff --git a/sycl/include/sycl/handler.hpp b/sycl/include/sycl/handler.hpp index 6181a41e6ef8c..a81a85c63b816 100644 --- a/sycl/include/sycl/handler.hpp +++ b/sycl/include/sycl/handler.hpp @@ -768,16 +768,16 @@ class __SYCL_EXPORT handler { int ArgIndex); /* The kernel passed to StoreLambda can take an id, an item or an nd_item as - * its argument. Since esimd plugin directly invokes the kernel (doesn’t use - * piKernelSetArg), the kernel argument type must be known to the plugin. - * However, passing kernel argument type to the plugin requires changing ABI + * its argument. Since esimd adapter directly invokes the kernel (doesn’t use + * urKernelSetArg), the kernel argument type must be known to the adapter. + * However, passing kernel argument type to the adapter requires changing ABI * in HostKernel class. To overcome this problem, helpers below wrap the * “original” kernel with a functor that always takes an nd_item as argument. * A functor is used instead of a lambda because extractArgsAndReqsFromLambda * needs access to the “original” kernel and keeps references to its internal * data, i.e. the kernel passed as argument cannot be local in scope. The * functor itself is again encapsulated in a std::function since functor’s - * type is unknown to the plugin. + * type is unknown to the adapter. */ // For 'id, item w/wo offset, nd_item' kernel arguments diff --git a/sycl/source/backend.cpp b/sycl/source/backend.cpp index e8d2d23f5fbce..a6e422264178b 100644 --- a/sycl/source/backend.cpp +++ b/sycl/source/backend.cpp @@ -6,12 +6,12 @@ // //===----------------------------------------------------------------------===// +#include "detail/adapter.hpp" #include "detail/context_impl.hpp" #include "detail/event_impl.hpp" #include "detail/kernel_bundle_impl.hpp" #include "detail/kernel_id_impl.hpp" #include "detail/platform_impl.hpp" -#include "detail/plugin.hpp" #include "detail/queue_impl.hpp" #include "sycl/detail/impl_utils.hpp" #include @@ -29,20 +29,20 @@ namespace sycl { inline namespace _V1 { namespace detail { -static const PluginPtr &getPlugin(backend Backend) { +static const AdapterPtr &getAdapter(backend Backend) { switch (Backend) { case backend::opencl: - return ur::getPlugin(); + return ur::getAdapter(); case backend::ext_oneapi_level_zero: - return ur::getPlugin(); + return ur::getAdapter(); case backend::ext_oneapi_cuda: - return ur::getPlugin(); + return ur::getAdapter(); case backend::ext_oneapi_hip: - return ur::getPlugin(); + return ur::getAdapter(); default: throw sycl::exception( sycl::make_error_code(sycl::errc::runtime), - "getPlugin: Unsupported backend " + + "getAdapter: Unsupported backend " + detail::codeToString(UR_RESULT_ERROR_INVALID_OPERATION)); } } @@ -68,34 +68,34 @@ backend convertUrBackend(ur_platform_backend_t UrBackend) { } platform make_platform(ur_native_handle_t NativeHandle, backend Backend) { - const auto &Plugin = getPlugin(Backend); + const auto &Adapter = getAdapter(Backend); // Create UR platform first. ur_platform_handle_t UrPlatform = nullptr; - Plugin->call( - NativeHandle, Plugin->getUrAdapter(), nullptr, &UrPlatform); + Adapter->call( + NativeHandle, Adapter->getUrAdapter(), nullptr, &UrPlatform); return detail::createSyclObjFromImpl( - platform_impl::getOrMakePlatformImpl(UrPlatform, Plugin)); + platform_impl::getOrMakePlatformImpl(UrPlatform, Adapter)); } __SYCL_EXPORT device make_device(ur_native_handle_t NativeHandle, backend Backend) { - const auto &Plugin = getPlugin(Backend); + const auto &Adapter = getAdapter(Backend); ur_device_handle_t UrDevice = nullptr; - Plugin->call( - NativeHandle, Plugin->getUrAdapter(), nullptr, &UrDevice); + Adapter->call( + NativeHandle, Adapter->getUrAdapter(), nullptr, &UrDevice); // Construct the SYCL device from UR device. return detail::createSyclObjFromImpl( - std::make_shared(UrDevice, Plugin)); + std::make_shared(UrDevice, Adapter)); } __SYCL_EXPORT context make_context(ur_native_handle_t NativeHandle, const async_handler &Handler, backend Backend, bool KeepOwnership, const std::vector &DeviceList) { - const auto &Plugin = getPlugin(Backend); + const auto &Adapter = getAdapter(Backend); ur_context_handle_t UrContext = nullptr; ur_context_native_properties_t Properties{}; @@ -105,12 +105,12 @@ __SYCL_EXPORT context make_context(ur_native_handle_t NativeHandle, for (const auto &Dev : DeviceList) { DeviceHandles.push_back(detail::getSyclObjImpl(Dev)->getHandleRef()); } - Plugin->call( - NativeHandle, Plugin->getUrAdapter(), DeviceHandles.size(), + Adapter->call( + NativeHandle, Adapter->getUrAdapter(), DeviceHandles.size(), DeviceHandles.data(), &Properties, &UrContext); // Construct the SYCL context from UR context. return detail::createSyclObjFromImpl(std::make_shared( - UrContext, Handler, Plugin, DeviceList, !KeepOwnership)); + UrContext, Handler, Adapter, DeviceList, !KeepOwnership)); } __SYCL_EXPORT queue make_queue(ur_native_handle_t NativeHandle, @@ -120,7 +120,7 @@ __SYCL_EXPORT queue make_queue(ur_native_handle_t NativeHandle, const async_handler &Handler, backend Backend) { ur_device_handle_t UrDevice = Device ? getSyclObjImpl(*Device)->getHandleRef() : nullptr; - const auto &Plugin = getPlugin(Backend); + const auto &Adapter = getAdapter(Backend); const auto &ContextImpl = getSyclObjImpl(Context); if (PropList.has_property()) { @@ -150,7 +150,7 @@ __SYCL_EXPORT queue make_queue(ur_native_handle_t NativeHandle, // Create UR queue first. ur_queue_handle_t UrQueue = nullptr; - Plugin->call( + Adapter->call( NativeHandle, ContextImpl->getHandleRef(), UrDevice, &NativeProperties, &UrQueue); // Construct the SYCL queue from UR queue. @@ -166,7 +166,7 @@ __SYCL_EXPORT event make_event(ur_native_handle_t NativeHandle, __SYCL_EXPORT event make_event(ur_native_handle_t NativeHandle, const context &Context, bool KeepOwnership, backend Backend) { - const auto &Plugin = getPlugin(Backend); + const auto &Adapter = getAdapter(Backend); const auto &ContextImpl = getSyclObjImpl(Context); ur_event_handle_t UrEvent = nullptr; @@ -174,13 +174,13 @@ __SYCL_EXPORT event make_event(ur_native_handle_t NativeHandle, Properties.stype = UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES; Properties.isNativeHandleOwned = !KeepOwnership; - Plugin->call( + Adapter->call( NativeHandle, ContextImpl->getHandleRef(), &Properties, &UrEvent); event Event = detail::createSyclObjFromImpl( std::make_shared(UrEvent, Context)); if (Backend == backend::opencl) - Plugin->call(UrEvent); + Adapter->call(UrEvent); return Event; } @@ -188,7 +188,7 @@ std::shared_ptr make_kernel_bundle(ur_native_handle_t NativeHandle, const context &TargetContext, bool KeepOwnership, bundle_state State, backend Backend) { - const auto &Plugin = getPlugin(Backend); + const auto &Adapter = getAdapter(Backend); const auto &ContextImpl = getSyclObjImpl(TargetContext); ur_program_handle_t UrProgram = nullptr; @@ -196,7 +196,7 @@ make_kernel_bundle(ur_native_handle_t NativeHandle, Properties.stype = UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES; Properties.isNativeHandleOwned = !KeepOwnership; - Plugin->call( + Adapter->call( NativeHandle, ContextImpl->getHandleRef(), &Properties, &UrProgram); if (UrProgram == nullptr) throw sycl::exception( @@ -204,44 +204,44 @@ make_kernel_bundle(ur_native_handle_t NativeHandle, "urProgramCreateWithNativeHandle resulted in a null program handle."); if (ContextImpl->getBackend() == backend::opencl) - Plugin->call(UrProgram); + Adapter->call(UrProgram); std::vector ProgramDevices; uint32_t NumDevices = 0; - Plugin->call( + Adapter->call( UrProgram, UR_PROGRAM_INFO_NUM_DEVICES, sizeof(NumDevices), &NumDevices, nullptr); ProgramDevices.resize(NumDevices); - Plugin->call( + Adapter->call( UrProgram, UR_PROGRAM_INFO_DEVICES, sizeof(ur_device_handle_t) * NumDevices, ProgramDevices.data(), nullptr); for (auto &Dev : ProgramDevices) { ur_program_binary_type_t BinaryType; - Plugin->call( + Adapter->call( UrProgram, Dev, UR_PROGRAM_BUILD_INFO_BINARY_TYPE, sizeof(ur_program_binary_type_t), &BinaryType, nullptr); switch (BinaryType) { case (UR_PROGRAM_BINARY_TYPE_NONE): if (State == bundle_state::object) { - auto Res = Plugin->call_nocheck( + auto Res = Adapter->call_nocheck( UrProgram, 1, &Dev, nullptr); if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { - Res = Plugin->call_nocheck( + Res = Adapter->call_nocheck( ContextImpl->getHandleRef(), UrProgram, nullptr); } - Plugin->checkUrResult(Res); + Adapter->checkUrResult(Res); } else if (State == bundle_state::executable) { - auto Res = Plugin->call_nocheck( + auto Res = Adapter->call_nocheck( UrProgram, 1, &Dev, nullptr); if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { - Res = Plugin->call_nocheck( + Res = Adapter->call_nocheck( ContextImpl->getHandleRef(), UrProgram, nullptr); } - Plugin->checkUrResult(Res); + Adapter->checkUrResult(Res); } break; @@ -254,15 +254,15 @@ make_kernel_bundle(ur_native_handle_t NativeHandle, detail::codeToString(UR_RESULT_ERROR_INVALID_VALUE)); if (State == bundle_state::executable) { ur_program_handle_t UrLinkedProgram = nullptr; - auto Res = Plugin->call_nocheck( + auto Res = Adapter->call_nocheck( ContextImpl->getHandleRef(), 1, &Dev, 1, &UrProgram, nullptr, &UrLinkedProgram); if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { - Res = Plugin->call_nocheck( + Res = Adapter->call_nocheck( ContextImpl->getHandleRef(), 1, &UrProgram, nullptr, &UrLinkedProgram); } - Plugin->checkUrResult(Res); + Adapter->checkUrResult(Res); if (UrLinkedProgram != nullptr) { UrProgram = UrLinkedProgram; } @@ -284,9 +284,9 @@ make_kernel_bundle(ur_native_handle_t NativeHandle, Devices.reserve(ProgramDevices.size()); std::transform( ProgramDevices.begin(), ProgramDevices.end(), std::back_inserter(Devices), - [&Plugin](const auto &Dev) { + [&Adapter](const auto &Dev) { auto Platform = - detail::platform_impl::getPlatformFromUrDevice(Dev, Plugin); + detail::platform_impl::getPlatformFromUrDevice(Dev, Adapter); auto DeviceImpl = Platform->getOrMakeDeviceImpl(Dev, Platform); return createSyclObjFromImpl(DeviceImpl); }); @@ -316,7 +316,7 @@ kernel make_kernel(const context &TargetContext, const kernel_bundle &KernelBundle, ur_native_handle_t NativeHandle, bool KeepOwnership, backend Backend) { - const auto &Plugin = getPlugin(Backend); + const auto &Adapter = getAdapter(Backend); const auto &ContextImpl = getSyclObjImpl(TargetContext); const auto KernelBundleImpl = getSyclObjImpl(KernelBundle); @@ -346,12 +346,12 @@ kernel make_kernel(const context &TargetContext, ur_kernel_native_properties_t Properties{}; Properties.stype = UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES; Properties.isNativeHandleOwned = !KeepOwnership; - Plugin->call( + Adapter->call( NativeHandle, ContextImpl->getHandleRef(), UrProgram, &Properties, &UrKernel); if (Backend == backend::opencl) - Plugin->call(UrKernel); + Adapter->call(UrKernel); // Construct the SYCL queue from UR queue. return detail::createSyclObjFromImpl( diff --git a/sycl/source/backend/level_zero.cpp b/sycl/source/backend/level_zero.cpp index 74c860b136028..1fe93c27ee866 100644 --- a/sycl/source/backend/level_zero.cpp +++ b/sycl/source/backend/level_zero.cpp @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// +#include #include -#include #include #include #include @@ -19,12 +19,12 @@ using namespace sycl::detail; __SYCL_EXPORT device make_device(const platform &Platform, ur_native_handle_t NativeHandle) { - const auto &Plugin = ur::getPlugin(); + const auto &Adapter = ur::getAdapter(); const auto &PlatformImpl = getSyclObjImpl(Platform); // Create UR device first. ur_device_handle_t UrDevice; - Plugin->call( - NativeHandle, Plugin->getUrAdapter(), nullptr, &UrDevice); + Adapter->call( + NativeHandle, Adapter->getUrAdapter(), nullptr, &UrDevice); return detail::createSyclObjFromImpl( PlatformImpl->getOrMakeDeviceImpl(UrDevice, PlatformImpl)); diff --git a/sycl/source/backend/opencl.cpp b/sycl/source/backend/opencl.cpp index 491a167656f58..56627a22dbb56 100644 --- a/sycl/source/backend/opencl.cpp +++ b/sycl/source/backend/opencl.cpp @@ -6,9 +6,9 @@ // //===----------------------------------------------------------------------===// +#include #include #include -#include #include #include @@ -32,23 +32,23 @@ __SYCL_EXPORT bool has_extension(const sycl::platform &SyclPlatform, std::shared_ptr PlatformImpl = getSyclObjImpl(SyclPlatform); - ur_platform_handle_t PluginPlatform = PlatformImpl->getHandleRef(); - const PluginPtr &Plugin = PlatformImpl->getPlugin(); + ur_platform_handle_t AdapterPlatform = PlatformImpl->getHandleRef(); + const AdapterPtr &Adapter = PlatformImpl->getAdapter(); - // Manual invocation of plugin API to avoid using deprecated + // Manual invocation of UR API to avoid using deprecated // info::platform::extensions call. size_t ResultSize = 0; - Plugin->call( - PluginPlatform, UR_PLATFORM_INFO_EXTENSIONS, + Adapter->call( + AdapterPlatform, UR_PLATFORM_INFO_EXTENSIONS, /*propSize=*/0, /*pPropValue=*/nullptr, &ResultSize); if (ResultSize == 0) return false; std::unique_ptr Result(new char[ResultSize]); - Plugin->call(PluginPlatform, - UR_PLATFORM_INFO_EXTENSIONS, - ResultSize, Result.get(), nullptr); + Adapter->call( + AdapterPlatform, UR_PLATFORM_INFO_EXTENSIONS, ResultSize, Result.get(), + nullptr); std::string_view ExtensionsString(Result.get()); return ExtensionsString.find(Extension) != std::string::npos; @@ -64,23 +64,23 @@ __SYCL_EXPORT bool has_extension(const sycl::device &SyclDevice, std::shared_ptr DeviceImpl = getSyclObjImpl(SyclDevice); - ur_device_handle_t PluginDevice = DeviceImpl->getHandleRef(); - const PluginPtr &Plugin = DeviceImpl->getPlugin(); + ur_device_handle_t AdapterDevice = DeviceImpl->getHandleRef(); + const AdapterPtr &Adapter = DeviceImpl->getAdapter(); - // Manual invocation of plugin API to avoid using deprecated + // Manual invocation of UR API to avoid using deprecated // info::device::extensions call. size_t ResultSize = 0; - Plugin->call(PluginDevice, - UR_DEVICE_INFO_EXTENSIONS, - /*propSize=*/0, - /*pPropValue=*/nullptr, &ResultSize); + Adapter->call( + AdapterDevice, UR_DEVICE_INFO_EXTENSIONS, + /*propSize=*/0, + /*pPropValue=*/nullptr, &ResultSize); if (ResultSize == 0) return false; std::unique_ptr Result(new char[ResultSize]); - Plugin->call(PluginDevice, - UR_DEVICE_INFO_EXTENSIONS, - ResultSize, Result.get(), nullptr); + Adapter->call(AdapterDevice, + UR_DEVICE_INFO_EXTENSIONS, + ResultSize, Result.get(), nullptr); std::string_view ExtensionsString(Result.get()); return ExtensionsString.find(Extension) != std::string::npos; diff --git a/sycl/source/context.cpp b/sycl/source/context.cpp index a60be1251bcba..63b3c2350e45d 100644 --- a/sycl/source/context.cpp +++ b/sycl/source/context.cpp @@ -72,16 +72,16 @@ context::context(const std::vector &DeviceList, PropList); } context::context(cl_context ClContext, async_handler AsyncHandler) { - const auto &Plugin = sycl::detail::ur::getPlugin(); + const auto &Adapter = sycl::detail::ur::getAdapter(); ur_context_handle_t hContext = nullptr; ur_native_handle_t nativeHandle = reinterpret_cast(ClContext); - Plugin->call( - nativeHandle, Plugin->getUrAdapter(), 0, nullptr, nullptr, &hContext); + Adapter->call( + nativeHandle, Adapter->getUrAdapter(), 0, nullptr, nullptr, &hContext); - impl = std::make_shared( - hContext, AsyncHandler, Plugin); + impl = + std::make_shared(hContext, AsyncHandler, Adapter); } template diff --git a/sycl/source/detail/plugin.hpp b/sycl/source/detail/adapter.hpp similarity index 86% rename from sycl/source/detail/plugin.hpp rename to sycl/source/detail/adapter.hpp index 22f9ed96cb589..1f8ce18e3eb54 100644 --- a/sycl/source/detail/plugin.hpp +++ b/sycl/source/detail/adapter.hpp @@ -1,4 +1,4 @@ -//==- plugin.hpp -----------------------------------------------------------==// +//==- adapter.hpp ----------------------------------------------------------==// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -37,18 +37,18 @@ namespace sycl { inline namespace _V1 { namespace detail { -/// The plugin class provides a unified interface to the underlying low-level +/// The adapter class provides a unified interface to the underlying low-level /// runtimes for the device-agnostic SYCL runtime. /// /// \ingroup sycl_ur -class plugin { +class Adapter { public: - plugin() = delete; + Adapter() = delete; - plugin(ur_adapter_handle_t adapter, backend UseBackend) + Adapter(ur_adapter_handle_t adapter, backend UseBackend) : MAdapter(adapter), MBackend(UseBackend), TracingMutex(std::make_shared()), - MPluginMutex(std::make_shared()) { + MAdapterMutex(std::make_shared()) { #ifdef _WIN32 UrLoaderHandle = ur::getURLoaderLibrary(); @@ -56,13 +56,13 @@ class plugin { #endif } - // Disallow accidental copies of plugins - plugin &operator=(const plugin &) = delete; - plugin(const plugin &) = delete; - plugin &operator=(plugin &&other) noexcept = delete; - plugin(plugin &&other) noexcept = delete; + // Disallow accidental copies of adapters + Adapter &operator=(const Adapter &) = delete; + Adapter(const Adapter &) = delete; + Adapter &operator=(Adapter &&other) noexcept = delete; + Adapter(Adapter &&other) noexcept = delete; - ~plugin() = default; + ~Adapter() = default; /// \throw SYCL 2020 exception(errc) if ur_result is not UR_RESULT_SUCCESS template @@ -114,12 +114,12 @@ class plugin { /// /// Usage: /// \code{cpp} - /// ur_result_t Err = Plugin->call(Args); - /// Plugin->checkUrResult(Err); // Checks Result and throws a runtime_error + /// ur_result_t Err = Adapter->call(Args); + /// Adapter->checkUrResult(Err); // Checks Result and throws a runtime_error /// // exception. /// \endcode /// - /// \sa plugin::checkUrResult + /// \sa adapter::checkUrResult template ur_result_t call_nocheck(ArgsT... Args) const { ur_result_t R = UR_RESULT_SUCCESS; @@ -147,9 +147,9 @@ class plugin { checkUrResult(Err); } - /// Tells if this plugin can serve specified backend. - /// For example, Unified Runtime plugin will be able to serve - /// multiple backends as determined by the platforms reported by the plugin. + /// Tells if this adapter can serve specified backend. + /// For example, Unified Runtime adapter will be able to serve + /// multiple backends as determined by the platforms reported by the adapter. bool hasBackend(backend Backend) const { return Backend == MBackend; } void release() { @@ -170,7 +170,7 @@ class plugin { return UrPlatforms.size() - 1; } - // Device ids are consecutive across platforms within a plugin. + // Device ids are consecutive across platforms within a adapter. // We need to return the same starting index for the given platform. // So, instead of returing the last device id of the given platform, // return the last device id of the predecessor platform. @@ -204,7 +204,7 @@ class plugin { return It != UrPlatforms.end(); } - std::shared_ptr getPluginMutex() { return MPluginMutex; } + std::shared_ptr getAdapterMutex() { return MAdapterMutex; } bool adapterReleased = false; private: @@ -214,8 +214,8 @@ class plugin { // Mutex to guard UrPlatforms and LastDeviceIds. // Note that this is a temporary solution until we implement the global // Device/Platform cache later. - std::shared_ptr MPluginMutex; - // vector of UrPlatforms that belong to this plugin + std::shared_ptr MAdapterMutex; + // vector of UrPlatforms that belong to this adapter std::once_flag PlatformsPopulated; std::vector UrPlatforms; // represents the unique ids of the last device of each platform @@ -225,9 +225,9 @@ class plugin { void *UrLoaderHandle = nullptr; #endif UrFuncPtrMapT UrFuncPtrs; -}; // class plugin +}; // class Adapter -using PluginPtr = std::shared_ptr; +using AdapterPtr = std::shared_ptr; } // namespace detail } // namespace _V1 diff --git a/sycl/source/detail/allowlist.cpp b/sycl/source/detail/allowlist.cpp index 2aee3418f536a..a6113130aabda 100644 --- a/sycl/source/detail/allowlist.cpp +++ b/sycl/source/detail/allowlist.cpp @@ -345,7 +345,8 @@ bool deviceIsAllowed(const DeviceDescT &DeviceDesc, } void applyAllowList(std::vector &UrDevices, - ur_platform_handle_t UrPlatform, const PluginPtr &Plugin) { + ur_platform_handle_t UrPlatform, + const AdapterPtr &Adapter) { AllowListParsedT AllowListParsed = parseAllowList(SYCLConfig::get()); @@ -354,7 +355,7 @@ void applyAllowList(std::vector &UrDevices, // Get platform's backend and put it to DeviceDesc DeviceDescT DeviceDesc; - auto PlatformImpl = platform_impl::getOrMakePlatformImpl(UrPlatform, Plugin); + auto PlatformImpl = platform_impl::getOrMakePlatformImpl(UrPlatform, Adapter); backend Backend = PlatformImpl->getBackend(); for (const auto &SyclBe : getSyclBeMap()) { @@ -366,18 +367,18 @@ void applyAllowList(std::vector &UrDevices, // get PlatformVersion value and put it to DeviceDesc DeviceDesc.emplace(PlatformVersionKeyName, sycl::detail::get_platform_info( - UrPlatform, Plugin)); + UrPlatform, Adapter)); // get PlatformName value and put it to DeviceDesc DeviceDesc.emplace(PlatformNameKeyName, sycl::detail::get_platform_info( - UrPlatform, Plugin)); + UrPlatform, Adapter)); int InsertIDx = 0; for (ur_device_handle_t Device : UrDevices) { auto DeviceImpl = PlatformImpl->getOrMakeDeviceImpl(Device, PlatformImpl); // get DeviceType value and put it to DeviceDesc ur_device_type_t UrDevType = UR_DEVICE_TYPE_ALL; - Plugin->call( + Adapter->call( Device, UR_DEVICE_INFO_TYPE, sizeof(UrDevType), &UrDevType, nullptr); // TODO need mechanism to do these casts, there's a bunch of this sort of // thing diff --git a/sycl/source/detail/allowlist.hpp b/sycl/source/detail/allowlist.hpp index aa29bd59e4551..8f3d204033e9c 100644 --- a/sycl/source/detail/allowlist.hpp +++ b/sycl/source/detail/allowlist.hpp @@ -8,7 +8,7 @@ #pragma once -#include +#include #include #include @@ -28,7 +28,7 @@ bool deviceIsAllowed(const DeviceDescT &DeviceDesc, const AllowListParsedT &AllowListParsed); void applyAllowList(std::vector &UrDevices, - ur_platform_handle_t UrPlatform, const PluginPtr &Plugin); + ur_platform_handle_t UrPlatform, const AdapterPtr &Adapter); } // namespace detail } // namespace _V1 diff --git a/sycl/source/detail/bindless_images.cpp b/sycl/source/detail/bindless_images.cpp index 78e1235df74df..e8568dc9f1f5e 100644 --- a/sycl/source/detail/bindless_images.cpp +++ b/sycl/source/detail/bindless_images.cpp @@ -117,9 +117,9 @@ __SYCL_EXPORT void destroy_image_handle(unsampled_image_handle &imageHandle, std::shared_ptr DevImpl = sycl::detail::getSyclObjImpl(syclDevice); ur_device_handle_t Device = DevImpl->getHandleRef(); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); - Plugin->call< + Adapter->call< sycl::errc::runtime, sycl::detail::UrApiKind::urBindlessImagesUnsampledImageHandleDestroyExp>( C, Device, imageHandle.raw_handle); @@ -140,9 +140,9 @@ __SYCL_EXPORT void destroy_image_handle(sampled_image_handle &imageHandle, std::shared_ptr DevImpl = sycl::detail::getSyclObjImpl(syclDevice); ur_device_handle_t Device = DevImpl->getHandleRef(); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); - Plugin->call< + Adapter->call< sycl::errc::runtime, sycl::detail::UrApiKind::urBindlessImagesSampledImageHandleDestroyExp>( C, Device, imageHandle.raw_handle); @@ -165,7 +165,7 @@ alloc_image_mem(const image_descriptor &desc, const sycl::device &syclDevice, std::shared_ptr DevImpl = sycl::detail::getSyclObjImpl(syclDevice); ur_device_handle_t Device = DevImpl->getHandleRef(); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); ur_image_desc_t urDesc; ur_image_format_t urFormat; @@ -174,8 +174,8 @@ alloc_image_mem(const image_descriptor &desc, const sycl::device &syclDevice, image_mem_handle retHandle; // Call impl. - Plugin->call( + Adapter->call( C, Device, &urFormat, &urDesc, reinterpret_cast( &retHandle.raw_handle)); @@ -198,12 +198,12 @@ __SYCL_EXPORT image_mem_handle get_mip_level_mem_handle( std::shared_ptr DevImpl = sycl::detail::getSyclObjImpl(syclDevice); ur_device_handle_t Device = DevImpl->getHandleRef(); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); // Call impl. image_mem_handle individual_image; - Plugin->call( + Adapter->call( C, Device, mipMem.raw_handle, level, &individual_image.raw_handle); return individual_image; @@ -226,18 +226,18 @@ __SYCL_EXPORT void free_image_mem(image_mem_handle memHandle, std::shared_ptr DevImpl = sycl::detail::getSyclObjImpl(syclDevice); ur_device_handle_t Device = DevImpl->getHandleRef(); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); if (memHandle.raw_handle != 0) { if (imageType == image_type::mipmap) { - Plugin->call( + Adapter->call( C, Device, memHandle.raw_handle); } else if (imageType == image_type::standard || imageType == image_type::array || imageType == image_type::cubemap) { - Plugin->call( + Adapter->call( C, Device, memHandle.raw_handle); } else { throw sycl::exception(sycl::make_error_code(sycl::errc::invalid), @@ -277,7 +277,7 @@ create_image(image_mem_handle memHandle, const image_descriptor &desc, std::shared_ptr DevImpl = sycl::detail::getSyclObjImpl(syclDevice); ur_device_handle_t Device = DevImpl->getHandleRef(); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); ur_image_desc_t urDesc; ur_image_format_t urFormat; @@ -285,7 +285,7 @@ create_image(image_mem_handle memHandle, const image_descriptor &desc, // Call impl. ur_exp_image_mem_native_handle_t urImageHandle; - Plugin + Adapter ->call( C, Device, memHandle.raw_handle, &urFormat, &urDesc, &urImageHandle); @@ -382,7 +382,7 @@ create_image(void *devPtr, size_t pitch, const bindless_image_sampler &sampler, std::shared_ptr DevImpl = sycl::detail::getSyclObjImpl(syclDevice); ur_device_handle_t Device = DevImpl->getHandleRef(); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); ur_sampler_desc_t UrSamplerProps{ UR_STRUCTURE_TYPE_SAMPLER_DESC, nullptr, @@ -413,7 +413,7 @@ create_image(void *devPtr, size_t pitch, const bindless_image_sampler &sampler, UrAddrModes.pNext = &UrCubemapProps; ur_sampler_handle_t urSampler = nullptr; - Plugin->call( + Adapter->call( C, &UrSamplerProps, &urSampler); ur_image_desc_t urDesc; @@ -422,8 +422,8 @@ create_image(void *devPtr, size_t pitch, const bindless_image_sampler &sampler, // Call impl. ur_exp_image_mem_native_handle_t urImageHandle; - Plugin->call( + Adapter->call( C, Device, reinterpret_cast(devPtr), &urFormat, &urDesc, urSampler, &urImageHandle); @@ -447,7 +447,7 @@ __SYCL_EXPORT external_mem import_external_memory( std::shared_ptr DevImpl = sycl::detail::getSyclObjImpl(syclDevice); ur_device_handle_t Device = DevImpl->getHandleRef(); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); ur_exp_external_mem_handle_t urExternalMem = nullptr; ur_exp_file_descriptor_t urFileDescriptor = {}; @@ -460,7 +460,7 @@ __SYCL_EXPORT external_mem import_external_memory( // For `resource_fd` external memory type, the handle type is always // `OPAQUE_FD`. No need for a switch statement like we have for win32 // resources. - Plugin + Adapter ->call( C, Device, externalMemDesc.size_in_bytes, @@ -488,7 +488,7 @@ __SYCL_EXPORT external_mem import_external_memory( std::shared_ptr DevImpl = sycl::detail::getSyclObjImpl(syclDevice); ur_device_handle_t Device = DevImpl->getHandleRef(); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); ur_exp_external_mem_handle_t urExternalMem = nullptr; ur_exp_win32_handle_t urWin32Handle = {}; @@ -512,7 +512,7 @@ __SYCL_EXPORT external_mem import_external_memory( "Invalid memory handle type"); } - Plugin + Adapter ->call( C, Device, externalMemDesc.size_in_bytes, urHandleType, @@ -542,7 +542,7 @@ image_mem_handle map_external_image_memory(external_mem extMem, std::shared_ptr DevImpl = sycl::detail::getSyclObjImpl(syclDevice); ur_device_handle_t Device = DevImpl->getHandleRef(); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); ur_image_desc_t urDesc; ur_image_format_t urFormat; @@ -551,8 +551,8 @@ image_mem_handle map_external_image_memory(external_mem extMem, ur_exp_external_mem_handle_t urExternalMem{extMem.raw_handle}; image_mem_handle retHandle; - Plugin->call( + Adapter->call( C, Device, &urFormat, &urDesc, urExternalMem, &retHandle.raw_handle); return image_mem_handle{retHandle}; @@ -576,12 +576,12 @@ void *map_external_linear_memory(external_mem extMem, uint64_t offset, std::shared_ptr DevImpl = sycl::detail::getSyclObjImpl(syclDevice); ur_device_handle_t Device = DevImpl->getHandleRef(); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); ur_exp_external_mem_handle_t urExternalMem{extMem.raw_handle}; void *retMemory; - Plugin->call< + Adapter->call< sycl::errc::invalid, sycl::detail::UrApiKind::urBindlessImagesMapExternalLinearMemoryExp>( C, Device, offset, size, urExternalMem, &retMemory); @@ -605,9 +605,9 @@ __SYCL_EXPORT void release_external_memory(external_mem extMem, std::shared_ptr DevImpl = sycl::detail::getSyclObjImpl(syclDevice); ur_device_handle_t Device = DevImpl->getHandleRef(); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); - Plugin + Adapter ->call( C, Device, extMem.raw_handle); @@ -625,7 +625,7 @@ __SYCL_EXPORT external_semaphore import_external_semaphore( const sycl::device &syclDevice, const sycl::context &syclContext) { std::shared_ptr CtxImpl = sycl::detail::getSyclObjImpl(syclContext); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); ur_context_handle_t C = CtxImpl->getHandleRef(); std::shared_ptr DevImpl = sycl::detail::getSyclObjImpl(syclDevice); @@ -641,7 +641,7 @@ __SYCL_EXPORT external_semaphore import_external_semaphore( // For this specialization of `import_external_semaphore` the handleType is // always `OPAQUE_FD`. - Plugin->call< + Adapter->call< sycl::errc::invalid, sycl::detail::UrApiKind::urBindlessImagesImportExternalSemaphoreExp>( C, Device, UR_EXP_EXTERNAL_SEMAPHORE_TYPE_OPAQUE_FD, &urExternalSemDesc, @@ -665,7 +665,7 @@ __SYCL_EXPORT external_semaphore import_external_semaphore( const sycl::device &syclDevice, const sycl::context &syclContext) { std::shared_ptr CtxImpl = sycl::detail::getSyclObjImpl(syclContext); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); ur_context_handle_t C = CtxImpl->getHandleRef(); std::shared_ptr DevImpl = sycl::detail::getSyclObjImpl(syclDevice); @@ -693,7 +693,7 @@ __SYCL_EXPORT external_semaphore import_external_semaphore( "Invalid semaphore handle type"); } - Plugin->call< + Adapter->call< sycl::errc::invalid, sycl::detail::UrApiKind::urBindlessImagesImportExternalSemaphoreExp>( C, Device, urHandleType, &urExternalSemDesc, &urExternalSemaphore); @@ -716,13 +716,13 @@ release_external_semaphore(external_semaphore externalSemaphore, const sycl::context &syclContext) { std::shared_ptr CtxImpl = sycl::detail::getSyclObjImpl(syclContext); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); ur_context_handle_t C = CtxImpl->getHandleRef(); std::shared_ptr DevImpl = sycl::detail::getSyclObjImpl(syclDevice); ur_device_handle_t Device = DevImpl->getHandleRef(); - Plugin->call< + Adapter->call< sycl::errc::invalid, sycl::detail::UrApiKind::urBindlessImagesReleaseExternalSemaphoreExp>( C, Device, externalSemaphore.raw_handle); @@ -741,22 +741,22 @@ __SYCL_EXPORT sycl::range<3> get_image_range(const image_mem_handle memHandle, std::ignore = syclDevice; std::shared_ptr CtxImpl = sycl::detail::getSyclObjImpl(syclContext); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); size_t Width = 0, Height = 0, Depth = 0; - Plugin->call( + Adapter->call( CtxImpl->getHandleRef(), memHandle.raw_handle, UR_IMAGE_INFO_WIDTH, &Width, nullptr); - Plugin->call( + Adapter->call( CtxImpl->getHandleRef(), memHandle.raw_handle, UR_IMAGE_INFO_HEIGHT, &Height, nullptr); - Plugin->call( + Adapter->call( CtxImpl->getHandleRef(), memHandle.raw_handle, UR_IMAGE_INFO_DEPTH, &Depth, nullptr); @@ -776,12 +776,12 @@ get_image_channel_type(const image_mem_handle memHandle, std::ignore = syclDevice; std::shared_ptr CtxImpl = sycl::detail::getSyclObjImpl(syclContext); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); ur_image_format_t URFormat; - Plugin->call( + Adapter->call( CtxImpl->getHandleRef(), memHandle.raw_handle, UR_IMAGE_INFO_FORMAT, &URFormat, nullptr); @@ -813,12 +813,12 @@ __SYCL_EXPORT void *pitched_alloc_device(size_t *resultPitch, sycl::detail::getSyclObjImpl(syclContext); ur_context_handle_t UrContext = CtxImpl->getHandleRef(); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); ur_device_handle_t UrDevice = sycl::detail::getSyclObjImpl(syclDevice)->getHandleRef(); - Plugin->call( + Adapter->call( UrContext, UrDevice, nullptr, nullptr, widthInBytes, height, elementSizeBytes, &RetVal, resultPitch); @@ -863,11 +863,11 @@ get_image_num_channels(const image_mem_handle memHandle, std::shared_ptr CtxImpl = sycl::detail::getSyclObjImpl(syclContext); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); ur_image_format_t URFormat = {}; - Plugin->call( + Adapter->call( CtxImpl->getHandleRef(), memHandle.raw_handle, UR_IMAGE_INFO_FORMAT, &URFormat, nullptr); diff --git a/sycl/source/detail/buffer_impl.cpp b/sycl/source/detail/buffer_impl.cpp index 3aa0e06ee7ced..1746cf85159ef 100644 --- a/sycl/source/detail/buffer_impl.cpp +++ b/sycl/source/detail/buffer_impl.cpp @@ -51,12 +51,12 @@ void buffer_impl::addInteropObject( if (std::find(Handles.begin(), Handles.end(), ur::cast(MInteropMemObject)) == Handles.end()) { - const PluginPtr &Plugin = getPlugin(); - Plugin->call( + const AdapterPtr &Adapter = getAdapter(); + Adapter->call( ur::cast(MInteropMemObject)); ur_native_handle_t NativeHandle = 0; - Plugin->call(MInteropMemObject, nullptr, - &NativeHandle); + Adapter->call(MInteropMemObject, nullptr, + &NativeHandle); Handles.push_back(NativeHandle); } } @@ -83,18 +83,18 @@ buffer_impl::getNativeVector(backend BackendName) const { if (Platform->getBackend() != BackendName) continue; - auto Plugin = Platform->getPlugin(); + auto Adapter = Platform->getAdapter(); if (Platform->getBackend() == backend::opencl) { - Plugin->call(NativeMem); + Adapter->call(NativeMem); } ur_native_handle_t Handle = 0; // When doing buffer interop we don't know what device the memory should be // resident on, so pass nullptr for Device param. Buffer interop may not be // supported by all backends. - Plugin->call(NativeMem, /*Dev*/ nullptr, - &Handle); + Adapter->call(NativeMem, /*Dev*/ nullptr, + &Handle); Handles.push_back(Handle); } diff --git a/sycl/source/detail/context_impl.cpp b/sycl/source/detail/context_impl.cpp index 36d7b1b6b8904..698d0680728b1 100644 --- a/sycl/source/detail/context_impl.cpp +++ b/sycl/source/detail/context_impl.cpp @@ -59,14 +59,15 @@ context_impl::context_impl(const std::vector Devices, DeviceIds.push_back(getSyclObjImpl(D)->getHandleRef()); } - getPlugin()->call( + getAdapter()->call( DeviceIds.size(), DeviceIds.data(), nullptr, &MContext); MKernelProgramCache.setContextPtr(this); } context_impl::context_impl(ur_context_handle_t UrContext, - async_handler AsyncHandler, const PluginPtr &Plugin, + async_handler AsyncHandler, + const AdapterPtr &Adapter, const std::vector &DeviceList, bool OwnedByRuntime) : MOwnedByRuntime(OwnedByRuntime), MAsyncHandler(AsyncHandler), @@ -78,12 +79,12 @@ context_impl::context_impl(ur_context_handle_t UrContext, std::vector DeviceIds; uint32_t DevicesNum = 0; // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call( + Adapter->call( MContext, UR_CONTEXT_INFO_NUM_DEVICES, sizeof(DevicesNum), &DevicesNum, nullptr); DeviceIds.resize(DevicesNum); // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call( + Adapter->call( MContext, UR_CONTEXT_INFO_DEVICES, sizeof(ur_device_handle_t) * DevicesNum, &DeviceIds[0], nullptr); @@ -93,7 +94,7 @@ context_impl::context_impl(ur_context_handle_t UrContext, "No devices in the provided device list and native context."); std::shared_ptr Platform = - platform_impl::getPlatformFromUrDevice(DeviceIds[0], Plugin); + platform_impl::getPlatformFromUrDevice(DeviceIds[0], Adapter); for (ur_device_handle_t Dev : DeviceIds) { MDevices.emplace_back(createSyclObjFromImpl( Platform->getOrMakeDeviceImpl(Dev, Platform))); @@ -101,23 +102,23 @@ context_impl::context_impl(ur_context_handle_t UrContext, MPlatform = Platform; } // TODO catch an exception and put it to list of asynchronous exceptions - // getPlugin() will be the same as the Plugin passed. This should be taken + // getAdapter() will be the same as the Adapter passed. This should be taken // care of when creating device object. // // TODO: Move this backend-specific retain of the context to SYCL-2020 style // make_context interop, when that is created. if (getBackend() == sycl::backend::opencl) { - getPlugin()->call(MContext); + getAdapter()->call(MContext); } MKernelProgramCache.setContextPtr(this); } cl_context context_impl::get() const { // TODO catch an exception and put it to list of asynchronous exceptions - getPlugin()->call(MContext); + getAdapter()->call(MContext); ur_native_handle_t nativeHandle = 0; - getPlugin()->call(MContext, - &nativeHandle); + getAdapter()->call(MContext, + &nativeHandle); return ur::cast(nativeHandle); } @@ -125,7 +126,7 @@ context_impl::~context_impl() { try { // Free all events associated with the initialization of device globals. for (auto &DeviceGlobalInitializer : MDeviceGlobalInitializers) - DeviceGlobalInitializer.second.ClearEvents(getPlugin()); + DeviceGlobalInitializer.second.ClearEvents(getAdapter()); // Free all device_global USM allocations associated with this context. for (const void *DeviceGlobal : MAssociatedDeviceGlobals) { DeviceGlobalMapEntry *DGEntry = @@ -135,10 +136,10 @@ context_impl::~context_impl() { } for (auto LibProg : MCachedLibPrograms) { assert(LibProg.second && "Null program must not be kept in the cache"); - getPlugin()->call(LibProg.second); + getAdapter()->call(LibProg.second); } // TODO catch an exception and put it to list of asynchronous exceptions - getPlugin()->call_nocheck(MContext); + getAdapter()->call_nocheck(MContext); } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~context_impl", e); } @@ -151,7 +152,7 @@ const async_handler &context_impl::get_async_handler() const { template <> uint32_t context_impl::get_info() const { return get_context_info(this->getHandleRef(), - this->getPlugin()); + this->getAdapter()); } template <> platform context_impl::get_info() const { return createSyclObjFromImpl(MPlatform); @@ -292,11 +293,11 @@ context_impl::findMatchingDeviceImpl(ur_device_handle_t &DeviceUR) const { } ur_native_handle_t context_impl::getNative() const { - const auto &Plugin = getPlugin(); + const auto &Adapter = getAdapter(); if (getBackend() == backend::opencl) - Plugin->call(getHandleRef()); + Adapter->call(getHandleRef()); ur_native_handle_t Handle; - Plugin->call(getHandleRef(), &Handle); + Adapter->call(getHandleRef(), &Handle); return Handle; } @@ -332,7 +333,7 @@ void context_impl::addDeviceGlobalInitializer( std::vector context_impl::initializeDeviceGlobals( ur_program_handle_t NativePrg, const std::shared_ptr &QueueImpl) { - const PluginPtr &Plugin = getPlugin(); + const AdapterPtr &Adapter = getAdapter(); const DeviceImplPtr &DeviceImpl = QueueImpl->getDeviceImplPtr(); std::lock_guard NativeProgramLock(MDeviceGlobalInitializersMutex); auto ImgIt = MDeviceGlobalInitializers.find( @@ -350,14 +351,14 @@ std::vector context_impl::initializeDeviceGlobals( // Initialization has begun but we do not know if the events are done. auto NewEnd = std::remove_if( InitEventsRef.begin(), InitEventsRef.end(), - [&Plugin](const ur_event_handle_t &Event) { + [&Adapter](const ur_event_handle_t &Event) { return get_event_info( - Event, Plugin) == info::event_command_status::complete; + Event, Adapter) == info::event_command_status::complete; return false; }); // Release the removed events. for (auto EventIt = NewEnd; EventIt != InitEventsRef.end(); ++EventIt) - Plugin->call(*EventIt); + Adapter->call(*EventIt); // Remove them from the collection. InitEventsRef.erase(NewEnd, InitEventsRef.end()); // If there are no more events, we can mark it as fully initialized. @@ -407,14 +408,14 @@ std::vector context_impl::initializeDeviceGlobals( // are cleaned up separately from cleaning up the device global USM memory // this must retain the event. { - if (OwnedUrEvent ZIEvent = DeviceGlobalUSM.getInitEvent(Plugin)) + if (OwnedUrEvent ZIEvent = DeviceGlobalUSM.getInitEvent(Adapter)) InitEventsRef.push_back(ZIEvent.TransferOwnership()); } // Write the pointer to the device global and store the event in the // initialize events list. ur_event_handle_t InitEvent; void *const &USMPtr = DeviceGlobalUSM.getPtr(); - Plugin->call( + Adapter->call( QueueImpl->getHandleRef(), NativePrg, DeviceGlobalEntry->MUniqueId.c_str(), false, sizeof(void *), 0, &USMPtr, 0, nullptr, &InitEvent); @@ -426,9 +427,9 @@ std::vector context_impl::initializeDeviceGlobals( } void context_impl::DeviceGlobalInitializer::ClearEvents( - const PluginPtr &Plugin) { + const AdapterPtr &Adapter) { for (const ur_event_handle_t &Event : MDeviceGlobalInitEvents) - Plugin->call(Event); + Adapter->call(Event); MDeviceGlobalInitEvents.clear(); } diff --git a/sycl/source/detail/context_impl.hpp b/sycl/source/detail/context_impl.hpp index 48fb83f5807d9..2013ab1c73df6 100644 --- a/sycl/source/detail/context_impl.hpp +++ b/sycl/source/detail/context_impl.hpp @@ -65,11 +65,11 @@ class context_impl { /// /// \param UrContext is an instance of a valid plug-in context handle. /// \param AsyncHandler is an instance of async_handler. - /// \param Plugin is the reference to the underlying Plugin that this + /// \param Adapter is the reference to the underlying Adapter that this /// \param OwnedByRuntime is the flag if ownership is kept by user or /// transferred to runtime context_impl(ur_context_handle_t UrContext, async_handler AsyncHandler, - const PluginPtr &Plugin, + const AdapterPtr &Adapter, const std::vector &DeviceList = {}, bool OwnedByRuntime = true); @@ -85,8 +85,8 @@ class context_impl { /// \return an instance of SYCL async_handler. const async_handler &get_async_handler() const; - /// \return the Plugin associated with the platform of this context. - const PluginPtr &getPlugin() const { return MPlatform->getPlugin(); } + /// \return the Adapter associated with the platform of this context. + const AdapterPtr &getAdapter() const { return MPlatform->getAdapter(); } /// \return the PlatformImpl associated with this context. PlatformImplPtr getPlatformImpl() const { return MPlatform; } @@ -269,7 +269,7 @@ class context_impl { } /// Clears all events of the initializer. This will not acquire the lock. - void ClearEvents(const PluginPtr &Plugin); + void ClearEvents(const AdapterPtr &Adapter); /// The binary image of the program. const RTDeviceBinaryImage *MBinImage = nullptr; diff --git a/sycl/source/detail/context_info.hpp b/sycl/source/detail/context_info.hpp index 75e1b64580e83..3d86e7bb54a79 100644 --- a/sycl/source/detail/context_info.hpp +++ b/sycl/source/detail/context_info.hpp @@ -19,13 +19,13 @@ namespace detail { template typename Param::return_type get_context_info(ur_context_handle_t Ctx, - const PluginPtr &Plugin) { + const AdapterPtr &Adapter) { static_assert(is_context_info_desc::value, "Invalid context information descriptor"); typename Param::return_type Result = 0; // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call(Ctx, UrInfoCode::value, - sizeof(Result), &Result, nullptr); + Adapter->call(Ctx, UrInfoCode::value, + sizeof(Result), &Result, nullptr); return Result; } diff --git a/sycl/source/detail/device_global_map_entry.cpp b/sycl/source/detail/device_global_map_entry.cpp index aceb1437660a4..a097c778f034c 100644 --- a/sycl/source/detail/device_global_map_entry.cpp +++ b/sycl/source/detail/device_global_map_entry.cpp @@ -25,20 +25,20 @@ DeviceGlobalUSMMem::~DeviceGlobalUSMMem() { assert(!MInitEvent.has_value() && "MInitEvent has not been cleaned up."); } -OwnedUrEvent DeviceGlobalUSMMem::getInitEvent(const PluginPtr &Plugin) { +OwnedUrEvent DeviceGlobalUSMMem::getInitEvent(const AdapterPtr &Adapter) { std::lock_guard Lock(MInitEventMutex); // If there is a init event we can remove it if it is done. if (MInitEvent.has_value()) { if (get_event_info( - *MInitEvent, Plugin) == info::event_command_status::complete) { - Plugin->call(*MInitEvent); + *MInitEvent, Adapter) == info::event_command_status::complete) { + Adapter->call(*MInitEvent); MInitEvent = {}; - return OwnedUrEvent(Plugin); + return OwnedUrEvent(Adapter); } else { - return OwnedUrEvent(*MInitEvent, Plugin); + return OwnedUrEvent(*MInitEvent, Adapter); } } - return OwnedUrEvent(Plugin); + return OwnedUrEvent(Adapter); } DeviceGlobalUSMMem &DeviceGlobalMapEntry::getOrAllocateDeviceGlobalUSM( @@ -100,7 +100,7 @@ void DeviceGlobalMapEntry::removeAssociatedResources( DeviceGlobalUSMMem &USMMem = USMPtrIt->second; detail::usm::freeInternal(USMMem.MPtr, CtxImpl); if (USMMem.MInitEvent.has_value()) - CtxImpl->getPlugin()->call( + CtxImpl->getAdapter()->call( *USMMem.MInitEvent); #ifndef NDEBUG // For debugging we set the event and memory to some recognizable values diff --git a/sycl/source/detail/device_global_map_entry.hpp b/sycl/source/detail/device_global_map_entry.hpp index f507b2d9b8060..fc4bae13161ed 100644 --- a/sycl/source/detail/device_global_map_entry.hpp +++ b/sycl/source/detail/device_global_map_entry.hpp @@ -39,7 +39,7 @@ struct DeviceGlobalUSMMem { // Gets the initialization event if it exists. If not the OwnedUrEvent // will contain no event. - OwnedUrEvent getInitEvent(const PluginPtr &Plugin); + OwnedUrEvent getInitEvent(const AdapterPtr &Adapter); private: void *MPtr; diff --git a/sycl/source/detail/device_image_impl.hpp b/sycl/source/detail/device_image_impl.hpp index 285d3c6103daa..ac58b7b80f467 100644 --- a/sycl/source/detail/device_image_impl.hpp +++ b/sycl/source/detail/device_image_impl.hpp @@ -8,12 +8,12 @@ #pragma once +#include #include #include #include #include #include -#include #include #include #include @@ -266,7 +266,7 @@ class device_image_impl { ur_mem_handle_t &get_spec_const_buffer_ref() noexcept { std::lock_guard Lock{MSpecConstAccessMtx}; if (nullptr == MSpecConstsBuffer && !MSpecConstsBlob.empty()) { - const PluginPtr &Plugin = getSyclObjImpl(MContext)->getPlugin(); + const AdapterPtr &Adapter = getSyclObjImpl(MContext)->getAdapter(); // Uses UR_MEM_FLAGS_HOST_PTR_COPY instead of UR_MEM_FLAGS_HOST_PTR_USE // since post-enqueue cleanup might trigger destruction of // device_image_impl and, as a result, destruction of MSpecConstsBlob @@ -276,7 +276,7 @@ class device_image_impl { nullptr, MSpecConstsBlob.data()}; try { memBufferCreateHelper( - Plugin, detail::getSyclObjImpl(MContext)->getHandleRef(), + Adapter, detail::getSyclObjImpl(MContext)->getHandleRef(), UR_MEM_FLAG_READ_WRITE | UR_MEM_FLAG_ALLOC_COPY_HOST_POINTER, MSpecConstsBlob.size(), &MSpecConstsBuffer, &Properties); } catch (std::exception &e) { @@ -298,12 +298,13 @@ class device_image_impl { ur_native_handle_t getNative() const { assert(MProgram); const auto &ContextImplPtr = detail::getSyclObjImpl(MContext); - const PluginPtr &Plugin = ContextImplPtr->getPlugin(); + const AdapterPtr &Adapter = ContextImplPtr->getAdapter(); if (ContextImplPtr->getBackend() == backend::opencl) - Plugin->call(MProgram); + Adapter->call(MProgram); ur_native_handle_t NativeProgram = 0; - Plugin->call(MProgram, &NativeProgram); + Adapter->call(MProgram, + &NativeProgram); return NativeProgram; } @@ -311,13 +312,13 @@ class device_image_impl { ~device_image_impl() { try { if (MProgram) { - const PluginPtr &Plugin = getSyclObjImpl(MContext)->getPlugin(); - Plugin->call(MProgram); + const AdapterPtr &Adapter = getSyclObjImpl(MContext)->getAdapter(); + Adapter->call(MProgram); } if (MSpecConstsBuffer) { std::lock_guard Lock{MSpecConstAccessMtx}; - const PluginPtr &Plugin = getSyclObjImpl(MContext)->getPlugin(); - memReleaseHelper(Plugin, MSpecConstsBuffer); + const AdapterPtr &Adapter = getSyclObjImpl(MContext)->getAdapter(); + memReleaseHelper(Adapter, MSpecConstsBuffer); } } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~device_image_impl", e); diff --git a/sycl/source/detail/device_impl.cpp b/sycl/source/detail/device_impl.cpp index ff5db2ec19531..084cb5a6ec2a7 100644 --- a/sycl/source/detail/device_impl.cpp +++ b/sycl/source/detail/device_impl.cpp @@ -19,22 +19,22 @@ inline namespace _V1 { namespace detail { device_impl::device_impl(ur_native_handle_t InteropDeviceHandle, - const PluginPtr &Plugin) - : device_impl(InteropDeviceHandle, nullptr, nullptr, Plugin) {} + const AdapterPtr &Adapter) + : device_impl(InteropDeviceHandle, nullptr, nullptr, Adapter) {} /// Constructs a SYCL device instance using the provided /// UR device instance. device_impl::device_impl(ur_device_handle_t Device, PlatformImplPtr Platform) - : device_impl(0, Device, Platform, Platform->getPlugin()) {} + : device_impl(0, Device, Platform, Platform->getAdapter()) {} /// Constructs a SYCL device instance using the provided /// UR device instance. -device_impl::device_impl(ur_device_handle_t Device, const PluginPtr &Plugin) - : device_impl(0, Device, nullptr, Plugin) {} +device_impl::device_impl(ur_device_handle_t Device, const AdapterPtr &Adapter) + : device_impl(0, Device, nullptr, Adapter) {} device_impl::device_impl(ur_native_handle_t InteropDeviceHandle, ur_device_handle_t Device, PlatformImplPtr Platform, - const PluginPtr &Plugin) + const AdapterPtr &Adapter) : MDevice(Device), MDeviceHostBaseTime(std::make_pair(0, 0)) { bool InteroperabilityConstructor = false; if (Device == nullptr) { @@ -42,19 +42,19 @@ device_impl::device_impl(ur_native_handle_t InteropDeviceHandle, // Get UR device from the raw device handle. // NOTE: this is for OpenCL interop only (and should go away). // With SYCL-2020 BE generalization "make" functions are used instead. - Plugin->call( - InteropDeviceHandle, Plugin->getUrAdapter(), nullptr, &MDevice); + Adapter->call( + InteropDeviceHandle, Adapter->getUrAdapter(), nullptr, &MDevice); InteroperabilityConstructor = true; } // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call( + Adapter->call( MDevice, UR_DEVICE_INFO_TYPE, sizeof(ur_device_type_t), &MType, nullptr); // No need to set MRootDevice when MAlwaysRootDevice is true if ((Platform == nullptr) || !Platform->MAlwaysRootDevice) { // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call( + Adapter->call( MDevice, UR_DEVICE_INFO_PARENT_DEVICE, sizeof(ur_device_handle_t), &MRootDevice, nullptr); } @@ -63,12 +63,12 @@ device_impl::device_impl(ur_native_handle_t InteropDeviceHandle, // TODO catch an exception and put it to list of asynchronous exceptions // Interoperability Constructor already calls DeviceRetain in // urDeviceCreateWithNativeHandle. - Plugin->call(MDevice); + Adapter->call(MDevice); } // set MPlatform if (!Platform) { - Platform = platform_impl::getPlatformFromUrDevice(MDevice, Plugin); + Platform = platform_impl::getPlatformFromUrDevice(MDevice, Adapter); } MPlatform = Platform; @@ -79,8 +79,9 @@ device_impl::device_impl(ur_native_handle_t InteropDeviceHandle, device_impl::~device_impl() { try { // TODO catch an exception and put it to list of asynchronous exceptions - const PluginPtr &Plugin = getPlugin(); - ur_result_t Err = Plugin->call_nocheck(MDevice); + const AdapterPtr &Adapter = getAdapter(); + ur_result_t Err = + Adapter->call_nocheck(MDevice); __SYCL_CHECK_UR_CODE_NO_EXC(Err); } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~device_impl", e); @@ -96,7 +97,7 @@ bool device_impl::is_affinity_supported( cl_device_id device_impl::get() const { // TODO catch an exception and put it to list of asynchronous exceptions - getPlugin()->call(MDevice); + getAdapter()->call(MDevice); return ur::cast(getNative()); } @@ -182,8 +183,8 @@ std::vector device_impl::create_sub_devices( size_t SubDevicesCount) const { std::vector SubDevices(SubDevicesCount); uint32_t ReturnedSubDevices = 0; - const PluginPtr &Plugin = getPlugin(); - Plugin->call( + const AdapterPtr &Adapter = getAdapter(); + Adapter->call( MDevice, Properties, SubDevicesCount, SubDevices.data(), &ReturnedSubDevices); if (ReturnedSubDevices != SubDevicesCount) { @@ -303,8 +304,8 @@ std::vector device_impl::create_sub_devices( Properties.pProperties = &Prop; uint32_t SubDevicesCount = 0; - const PluginPtr &Plugin = getPlugin(); - Plugin->call( + const AdapterPtr &Adapter = getAdapter(); + Adapter->call( MDevice, &Properties, 0, nullptr, &SubDevicesCount); return create_sub_devices(&Properties, SubDevicesCount); @@ -328,19 +329,19 @@ std::vector device_impl::create_sub_devices() const { Properties.PropCount = 1; uint32_t SubDevicesCount = 0; - const PluginPtr &Plugin = getPlugin(); - Plugin->call(MDevice, &Properties, 0, nullptr, - &SubDevicesCount); + const AdapterPtr &Adapter = getAdapter(); + Adapter->call(MDevice, &Properties, 0, nullptr, + &SubDevicesCount); return create_sub_devices(&Properties, SubDevicesCount); } ur_native_handle_t device_impl::getNative() const { - auto Plugin = getPlugin(); + auto Adapter = getAdapter(); if (getBackend() == backend::opencl) - Plugin->call(getHandleRef()); + Adapter->call(getHandleRef()); ur_native_handle_t Handle; - Plugin->call(getHandleRef(), &Handle); + Adapter->call(getHandleRef(), &Handle); return Handle; } @@ -407,51 +408,51 @@ bool device_impl::has(aspect Aspect) const { case aspect::usm_system_allocations: return get_info(); case aspect::ext_intel_device_id: - return getPlugin()->call_nocheck( + return getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_DEVICE_ID, 0, nullptr, &return_size) == UR_RESULT_SUCCESS; case aspect::ext_intel_pci_address: - return getPlugin()->call_nocheck( + return getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_PCI_ADDRESS, 0, nullptr, &return_size) == UR_RESULT_SUCCESS; case aspect::ext_intel_gpu_eu_count: - return getPlugin()->call_nocheck( + return getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_GPU_EU_COUNT, 0, nullptr, &return_size) == UR_RESULT_SUCCESS; case aspect::ext_intel_gpu_eu_simd_width: - return getPlugin()->call_nocheck( + return getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH, 0, nullptr, &return_size) == UR_RESULT_SUCCESS; case aspect::ext_intel_gpu_slices: - return getPlugin()->call_nocheck( + return getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_GPU_EU_SLICES, 0, nullptr, &return_size) == UR_RESULT_SUCCESS; case aspect::ext_intel_gpu_subslices_per_slice: - return getPlugin()->call_nocheck( + return getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE, 0, nullptr, &return_size) == UR_RESULT_SUCCESS; case aspect::ext_intel_gpu_eu_count_per_subslice: - return getPlugin()->call_nocheck( + return getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE, 0, nullptr, &return_size) == UR_RESULT_SUCCESS; case aspect::ext_intel_gpu_hw_threads_per_eu: - return getPlugin()->call_nocheck( + return getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU, 0, nullptr, &return_size) == UR_RESULT_SUCCESS; case aspect::ext_intel_free_memory: - return getPlugin()->call_nocheck( + return getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_GLOBAL_MEM_FREE, 0, nullptr, &return_size) == UR_RESULT_SUCCESS; case aspect::ext_intel_memory_clock_rate: - return getPlugin()->call_nocheck( + return getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_MEMORY_CLOCK_RATE, 0, nullptr, &return_size) == UR_RESULT_SUCCESS; case aspect::ext_intel_memory_bus_width: - return getPlugin()->call_nocheck( + return getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_MEMORY_BUS_WIDTH, 0, nullptr, &return_size) == UR_RESULT_SUCCESS; case aspect::ext_intel_device_info_uuid: { - auto Result = getPlugin()->call_nocheck( + auto Result = getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_UUID, 0, nullptr, &return_size); if (Result != UR_RESULT_SUCCESS) { return false; @@ -460,7 +461,7 @@ bool device_impl::has(aspect Aspect) const { assert(return_size <= 16); unsigned char UUID[16]; - return getPlugin()->call_nocheck( + return getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_UUID, 16 * sizeof(unsigned char), UUID, nullptr) == UR_RESULT_SUCCESS; } @@ -474,7 +475,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_cuda_async_barrier: { int async_barrier_supported; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_ASYNC_BARRIER, sizeof(int), &async_barrier_supported, nullptr) == UR_RESULT_SUCCESS; return call_successful && async_barrier_supported; @@ -482,7 +483,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_intel_legacy_image: { ur_bool_t legacy_image_support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_IMAGE_SUPPORTED, sizeof(ur_bool_t), &legacy_image_support, nullptr) == UR_RESULT_SUCCESS; return call_successful && legacy_image_support; @@ -490,7 +491,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_bindless_images: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -498,7 +499,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_bindless_images_shared_usm: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_BINDLESS_IMAGES_SHARED_USM_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -506,7 +507,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_bindless_images_1d_usm: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_BINDLESS_IMAGES_1D_USM_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -514,7 +515,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_bindless_images_2d_usm: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_BINDLESS_IMAGES_2D_USM_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -522,7 +523,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_external_memory_import: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_EXTERNAL_MEMORY_IMPORT_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -530,7 +531,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_external_semaphore_import: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_EXTERNAL_SEMAPHORE_IMPORT_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -538,7 +539,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_mipmap: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_MIPMAP_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -546,7 +547,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_mipmap_anisotropy: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_MIPMAP_ANISOTROPY_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -554,7 +555,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_mipmap_level_reference: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_MIPMAP_LEVEL_REFERENCE_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -562,7 +563,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_bindless_sampled_image_fetch_1d_usm: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_1D_USM_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -570,7 +571,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_bindless_sampled_image_fetch_1d: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_1D_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -578,7 +579,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_bindless_sampled_image_fetch_2d_usm: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_2D_USM_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -586,7 +587,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_bindless_sampled_image_fetch_2d: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_2D_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -594,7 +595,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_bindless_sampled_image_fetch_3d: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_3D_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -602,7 +603,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_cubemap: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_CUBEMAP_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -610,7 +611,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_cubemap_seamless_filtering: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_CUBEMAP_SEAMLESS_FILTERING_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -618,7 +619,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_image_array: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_IMAGE_ARRAY_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -626,7 +627,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_unique_addressing_per_dim: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_BINDLESS_UNIQUE_ADDRESSING_PER_DIM_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -634,7 +635,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_bindless_images_sample_1d_usm: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_1D_USM_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -642,7 +643,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_bindless_images_sample_2d_usm: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_2D_USM_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -650,7 +651,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_intel_esimd: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_ESIMD_SUPPORT, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -694,7 +695,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_is_component: { typename sycl_to_ur::type Result; bool CallSuccessful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( getHandleRef(), UrInfoCode::value, @@ -705,7 +706,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_graph: { bool SupportsCommandBufferUpdate = false; bool CallSuccessful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_COMMAND_BUFFER_UPDATE_SUPPORT_EXP, sizeof(SupportsCommandBufferUpdate), &SupportsCommandBufferUpdate, nullptr) == UR_RESULT_SUCCESS; @@ -718,7 +719,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_limited_graph: { bool SupportsCommandBuffers = false; bool CallSuccessful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP, sizeof(SupportsCommandBuffers), &SupportsCommandBuffers, nullptr) == UR_RESULT_SUCCESS; @@ -737,7 +738,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_queue_profiling_tag: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_TIMESTAMP_RECORDING_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -745,7 +746,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_virtual_mem: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -807,14 +808,14 @@ uint64_t device_impl::getCurrentDeviceTime() { // If getCurrentDeviceTime is called for the first time or we have to refresh. if (!MDeviceHostBaseTime.second || Diff > TimeTillRefresh) { - const auto &Plugin = getPlugin(); - auto Result = Plugin->call_nocheck( + const auto &Adapter = getAdapter(); + auto Result = Adapter->call_nocheck( MDevice, &MDeviceHostBaseTime.first, &MDeviceHostBaseTime.second); // We have to remember base host timestamp right after UR call and it is // going to be used for calculation of the device timestamp at the next - // getCurrentDeviceTime() call. We need to do it here because getPlugin() - // and urDeviceGetGlobalTimestamps calls may take significant amount of time, - // for example on the first call to getPlugin plugins may need to be + // getCurrentDeviceTime() call. We need to do it here because getAdapter() + // and urDeviceGetGlobalTimestamps calls may take significant amount of + // time, for example on the first call to getAdapter adapters may need to be // initialized. If we use timestamp from the beginning of the function then // the difference between host timestamps of the current // getCurrentDeviceTime and the next getCurrentDeviceTime will be incorrect @@ -833,7 +834,7 @@ uint64_t device_impl::getCurrentDeviceTime() { "Device and/or backend does not support querying timestamp."), UR_RESULT_ERROR_INVALID_OPERATION); } else { - Plugin->checkUrResult(Result); + Adapter->checkUrResult(Result); } // Until next sync we will compute device time based on the host time // returned in HostTime, so make this our base host time. @@ -844,9 +845,9 @@ uint64_t device_impl::getCurrentDeviceTime() { } bool device_impl::isGetDeviceAndHostTimerSupported() { - const auto &Plugin = getPlugin(); + const auto &Adapter = getAdapter(); uint64_t DeviceTime = 0, HostTime = 0; - auto Result = Plugin->call_nocheck( + auto Result = Adapter->call_nocheck( MDevice, &DeviceTime, &HostTime); return Result != UR_RESULT_ERROR_INVALID_OPERATION; } diff --git a/sycl/source/detail/device_impl.hpp b/sycl/source/detail/device_impl.hpp index 92c55a30b41b9..b38b7582f3f28 100644 --- a/sycl/source/detail/device_impl.hpp +++ b/sycl/source/detail/device_impl.hpp @@ -39,7 +39,7 @@ class device_impl { device_impl(); /// Constructs a SYCL device instance using the provided raw device handle. - explicit device_impl(ur_native_handle_t, const PluginPtr &Plugin); + explicit device_impl(ur_native_handle_t, const AdapterPtr &Adapter); /// Constructs a SYCL device instance using the provided /// UR device instance. @@ -47,7 +47,7 @@ class device_impl { /// Constructs a SYCL device instance using the provided /// UR device instance. - explicit device_impl(ur_device_handle_t Device, const PluginPtr &Plugin); + explicit device_impl(ur_device_handle_t Device, const AdapterPtr &Adapter); ~device_impl(); @@ -103,8 +103,8 @@ class device_impl { /// \return The associated SYCL platform. platform get_platform() const; - /// \return the associated plugin with this device. - const PluginPtr &getPlugin() const { return MPlatform->getPlugin(); } + /// \return the associated adapter with this device. + const AdapterPtr &getAdapter() const { return MPlatform->getAdapter(); } /// Check SYCL extension support by device /// @@ -296,7 +296,7 @@ class device_impl { private: explicit device_impl(ur_native_handle_t InteropDevice, ur_device_handle_t Device, PlatformImplPtr Platform, - const PluginPtr &Plugin); + const AdapterPtr &Adapter); ur_device_handle_t MDevice = 0; ur_device_type_t MType; diff --git a/sycl/source/detail/device_info.hpp b/sycl/source/detail/device_info.hpp index 88f079eec1b5d..11daf34ae14c8 100644 --- a/sycl/source/detail/device_info.hpp +++ b/sycl/source/detail/device_info.hpp @@ -7,11 +7,11 @@ //===----------------------------------------------------------------------===// #pragma once +#include #include #include #include #include -#include #include #include #include @@ -142,7 +142,7 @@ template <> struct check_fp_support { template struct get_device_info_impl { static ReturnT get(const DeviceImplPtr &Dev) { typename sycl_to_ur::type result; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); return ReturnT(result); @@ -153,14 +153,14 @@ template struct get_device_info_impl { template struct get_device_info_impl { static platform get(const DeviceImplPtr &Dev) { typename sycl_to_ur::type result; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); // TODO: Change UrDevice to device_impl. - // Use the Plugin from the device_impl class after plugin details + // Use the Adapter from the device_impl class after adapter details // are added to the class. return createSyclObjFromImpl( - platform_impl::getOrMakePlatformImpl(result, Dev->getPlugin())); + platform_impl::getOrMakePlatformImpl(result, Dev->getAdapter())); } }; @@ -169,13 +169,13 @@ template struct get_device_info_impl { inline std::string device_impl::get_device_info_string(ur_device_info_t InfoCode) const { size_t resultSize = 0; - getPlugin()->call(getHandleRef(), InfoCode, 0, - nullptr, &resultSize); + getAdapter()->call(getHandleRef(), InfoCode, 0, + nullptr, &resultSize); if (resultSize == 0) { return std::string(); } std::unique_ptr result(new char[resultSize]); - getPlugin()->call( + getAdapter()->call( getHandleRef(), InfoCode, resultSize, result.get(), nullptr); return std::string(result.get()); @@ -205,7 +205,7 @@ struct get_device_info_impl, Param> { return {}; } ur_device_fp_capability_flags_t result; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); return read_fp_bitfield(result); @@ -226,7 +226,7 @@ struct get_device_info_impl, info::device::single_fp_config> { static std::vector get(const DeviceImplPtr &Dev) { ur_device_fp_capability_flags_t result; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); return read_fp_bitfield(result); @@ -239,7 +239,7 @@ struct get_device_info_impl, template <> struct get_device_info_impl { static bool get(const DeviceImplPtr &Dev) { ur_queue_flags_t Properties; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(Properties), &Properties, nullptr); return Properties & UR_QUEUE_FLAG_PROFILING_ENABLE; @@ -252,7 +252,7 @@ struct get_device_info_impl, info::device::atomic_memory_order_capabilities> { static std::vector get(const DeviceImplPtr &Dev) { ur_memory_order_capability_flag_t result; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); @@ -266,7 +266,7 @@ struct get_device_info_impl, info::device::atomic_fence_order_capabilities> { static std::vector get(const DeviceImplPtr &Dev) { ur_memory_order_capability_flag_t result; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); @@ -280,7 +280,7 @@ struct get_device_info_impl, info::device::atomic_memory_scope_capabilities> { static std::vector get(const DeviceImplPtr &Dev) { size_t result; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); @@ -294,7 +294,7 @@ struct get_device_info_impl, info::device::atomic_fence_scope_capabilities> { static std::vector get(const DeviceImplPtr &Dev) { size_t result; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); @@ -308,7 +308,7 @@ struct get_device_info_impl { static bool get(const DeviceImplPtr &Dev) { bool result = false; if (Dev->getBackend() == backend::ext_oneapi_cuda) { - auto Err = Dev->getPlugin()->call_nocheck( + auto Err = Dev->getAdapter()->call_nocheck( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); @@ -326,7 +326,7 @@ struct get_device_info_impl, info::device::execution_capabilities> { static std::vector get(const DeviceImplPtr &Dev) { ur_device_exec_capability_flag_t result; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); @@ -392,10 +392,10 @@ struct get_device_info_impl, info::device::partition_properties> { static std::vector get(const DeviceImplPtr &Dev) { auto info_partition = UrInfoCode::value; - const auto &Plugin = Dev->getPlugin(); + const auto &Adapter = Dev->getAdapter(); size_t resultSize; - Plugin->call( + Adapter->call( Dev->getHandleRef(), info_partition, 0, nullptr, &resultSize); size_t arrayLength = resultSize / sizeof(ur_device_partition_t); @@ -404,9 +404,9 @@ struct get_device_info_impl, } std::unique_ptr arrayResult( new ur_device_partition_t[arrayLength]); - Plugin->call(Dev->getHandleRef(), - info_partition, resultSize, - arrayResult.get(), nullptr); + Adapter->call(Dev->getHandleRef(), + info_partition, resultSize, + arrayResult.get(), nullptr); std::vector result; for (size_t i = 0; i < arrayLength; ++i) { @@ -428,7 +428,7 @@ struct get_device_info_impl, static std::vector get(const DeviceImplPtr &Dev) { ur_device_affinity_domain_flags_t result; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); @@ -444,7 +444,7 @@ struct get_device_info_impl PartitionProperties; size_t PropertiesSize = 0; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, 0, nullptr, &PropertiesSize); @@ -454,7 +454,7 @@ struct get_device_info_implgetPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, PropertiesSize, PartitionProperties.data(), nullptr); @@ -476,7 +476,7 @@ struct get_device_info_impl PartitionProperties; size_t PropertiesSize = 0; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, 0, nullptr, &PropertiesSize); @@ -486,7 +486,7 @@ struct get_device_info_implgetPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, PropertiesSize, PartitionProperties.data(), nullptr); @@ -502,12 +502,12 @@ struct get_device_info_impl, info::device::sub_group_sizes> { static std::vector get(const DeviceImplPtr &Dev) { size_t resultSize = 0; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, 0, nullptr, &resultSize); std::vector result32(resultSize / sizeof(uint32_t)); - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, resultSize, result32.data(), nullptr); @@ -563,7 +563,7 @@ struct get_device_info_impl, info::device::max_work_item_sizes> { static range get(const DeviceImplPtr &Dev) { size_t result[3]; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode>::value, sizeof(result), &result, nullptr); @@ -693,7 +693,7 @@ struct get_device_info_impl< -> std::optional { uint32_t DeviceIp; ur_result_t Err = - Dev->getPlugin()->call_nocheck( + Dev->getAdapter()->call_nocheck( Dev->getHandleRef(), UrInfoCode< ext::oneapi::experimental::info::device::architecture>::value, @@ -702,7 +702,7 @@ struct get_device_info_impl< // Not all devices support this device info query return std::nullopt; } - Dev->getPlugin()->checkUrResult(Err); + Dev->getAdapter()->checkUrResult(Err); for (const auto &Item : ArchList) { if (Item.first == static_cast(DeviceIp)) @@ -725,11 +725,11 @@ struct get_device_info_impl< return ext::oneapi::experimental::architecture::unknown; }; size_t ResultSize = 0; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, 0, nullptr, &ResultSize); std::unique_ptr DeviceArch(new char[ResultSize]); - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, ResultSize, DeviceArch.get(), nullptr); std::string DeviceArchCopy(DeviceArch.get()); @@ -975,7 +975,7 @@ struct get_device_info_impl< size_t Limit = get_device_info_impl::get(Dev); - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode< ext::oneapi::experimental::info::device::max_work_groups<3>>::value, @@ -992,7 +992,7 @@ struct get_device_info_impl< size_t Limit = get_device_info_impl::get(Dev); - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode< ext::oneapi::experimental::info::device::max_work_groups<3>>::value, @@ -1009,7 +1009,7 @@ struct get_device_info_impl< size_t Limit = get_device_info_impl::get(Dev); - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode< ext::oneapi::experimental::info::device::max_work_groups<3>>::value, @@ -1071,7 +1071,7 @@ struct get_device_info_impl, template <> struct get_device_info_impl { static device get(const DeviceImplPtr &Dev) { typename sycl_to_ur::type result; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); if (result == nullptr) @@ -1101,7 +1101,7 @@ struct get_device_info_impl { static bool get(const DeviceImplPtr &Dev) { ur_device_usm_access_capability_flags_t caps; ur_result_t Err = - Dev->getPlugin()->call_nocheck( + Dev->getAdapter()->call_nocheck( Dev->getHandleRef(), UrInfoCode::value, sizeof(ur_device_usm_access_capability_flags_t), &caps, nullptr); @@ -1119,7 +1119,7 @@ struct get_device_info_impl { static bool get(const DeviceImplPtr &Dev) { ur_device_usm_access_capability_flags_t caps; ur_result_t Err = - Dev->getPlugin()->call_nocheck( + Dev->getAdapter()->call_nocheck( Dev->getHandleRef(), UrInfoCode::value, sizeof(ur_device_usm_access_capability_flags_t), &caps, nullptr); @@ -1136,7 +1136,7 @@ struct get_device_info_impl { static bool get(const DeviceImplPtr &Dev) { ur_device_usm_access_capability_flags_t caps; ur_result_t Err = - Dev->getPlugin()->call_nocheck( + Dev->getAdapter()->call_nocheck( Dev->getHandleRef(), UrInfoCode::value, sizeof(ur_device_usm_access_capability_flags_t), &caps, nullptr); @@ -1153,7 +1153,7 @@ struct get_device_info_implgetPlugin()->call_nocheck( + Dev->getAdapter()->call_nocheck( Dev->getHandleRef(), UrInfoCode::value, sizeof(ur_device_usm_access_capability_flags_t), &caps, nullptr); @@ -1172,7 +1172,7 @@ struct get_device_info_impl { static bool get(const DeviceImplPtr &Dev) { ur_device_usm_access_capability_flags_t caps; ur_result_t Err = - Dev->getPlugin()->call_nocheck( + Dev->getAdapter()->call_nocheck( Dev->getHandleRef(), UrInfoCode::value, sizeof(ur_device_usm_access_capability_flags_t), &caps, nullptr); @@ -1200,7 +1200,7 @@ struct get_device_info_impl< ext::codeplay::experimental::info::device::max_registers_per_work_group> { static uint32_t get(const DeviceImplPtr &Dev) { uint32_t maxRegsPerWG; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, @@ -1218,7 +1218,7 @@ struct get_device_info_impl< size_t ResultSize = 0; // First call to get DevCount. ur_result_t Err = - Dev->getPlugin()->call_nocheck( + Dev->getAdapter()->call_nocheck( Dev->getHandleRef(), UrInfoCode::value, @@ -1232,13 +1232,13 @@ struct get_device_info_impl< // Otherwise, if there was an error from UR it is unexpected and we should // handle it accordingly. - Dev->getPlugin()->checkUrResult(Err); + Dev->getAdapter()->checkUrResult(Err); size_t DevCount = ResultSize / sizeof(ur_device_handle_t); // Second call to get the list. std::vector Devs(DevCount); - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode< ext::oneapi::experimental::info::device::component_devices>::value, @@ -1263,7 +1263,7 @@ struct get_device_info_impl< "can call this function."); typename sycl_to_ur::type Result; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode< ext::oneapi::experimental::info::device::composite_device>::value, diff --git a/sycl/source/detail/error_handling/error_handling.cpp b/sycl/source/detail/error_handling/error_handling.cpp index 7c609adcfcd82..46b291e4c2147 100644 --- a/sycl/source/detail/error_handling/error_handling.cpp +++ b/sycl/source/detail/error_handling/error_handling.cpp @@ -12,7 +12,7 @@ #include "error_handling.hpp" -#include +#include #include #include @@ -36,11 +36,11 @@ void handleOutOfResources(const device_impl &DeviceImpl, const size_t TotalNumberOfWIs = NDRDesc.LocalSize[0] * NDRDesc.LocalSize[1] * NDRDesc.LocalSize[2]; - const PluginPtr &Plugin = DeviceImpl.getPlugin(); + const AdapterPtr &Adapter = DeviceImpl.getAdapter(); uint32_t NumRegisters = 0; - Plugin->call(Kernel, UR_KERNEL_INFO_NUM_REGS, - sizeof(NumRegisters), - &NumRegisters, nullptr); + Adapter->call(Kernel, UR_KERNEL_INFO_NUM_REGS, + sizeof(NumRegisters), + &NumRegisters, nullptr); uint32_t MaxRegistersPerBlock = DeviceImpl.get_infocall( + Adapter->call( Kernel, Device, UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE, sizeof(size_t) * 3, CompileWGSize, nullptr); size_t MaxWGSize = 0; - Plugin->call(Device, - UR_DEVICE_INFO_MAX_WORK_GROUP_SIZE, - sizeof(size_t), &MaxWGSize, nullptr); + Adapter->call( + Device, UR_DEVICE_INFO_MAX_WORK_GROUP_SIZE, sizeof(size_t), &MaxWGSize, + nullptr); const bool HasLocalSize = (NDRDesc.LocalSize[0] != 0); @@ -149,7 +149,7 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, if (HasLocalSize) { size_t MaxThreadsPerBlock[3] = {}; - Plugin->call( + Adapter->call( Device, UR_DEVICE_INFO_MAX_WORK_ITEM_SIZES, sizeof(MaxThreadsPerBlock), MaxThreadsPerBlock, nullptr); @@ -188,7 +188,7 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, // than the value specified by UR_KERNEL_GROUP_INFO_WORK_GROUP_SIZE in // table 5.21. size_t KernelWGSize = 0; - Plugin->call( + Adapter->call( Kernel, Device, UR_KERNEL_GROUP_INFO_WORK_GROUP_SIZE, sizeof(size_t), &KernelWGSize, nullptr); const size_t TotalNumberOfWIs = @@ -242,15 +242,15 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, // work-group given by local_work_size ur_program_handle_t Program = nullptr; - Plugin->call( + Adapter->call( Kernel, UR_KERNEL_INFO_PROGRAM, sizeof(ur_program_handle_t), &Program, nullptr); size_t OptsSize = 0; - Plugin->call( + Adapter->call( Program, Device, UR_PROGRAM_BUILD_INFO_OPTIONS, 0, nullptr, &OptsSize); std::string Opts(OptsSize, '\0'); - Plugin->call( + Adapter->call( Program, Device, UR_PROGRAM_BUILD_INFO_OPTIONS, OptsSize, &Opts.front(), nullptr); const bool HasStd20 = Opts.find("-cl-std=CL2.0") != std::string::npos; @@ -309,12 +309,12 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, void handleInvalidWorkItemSize(const device_impl &DeviceImpl, const NDRDescT &NDRDesc) { - const PluginPtr &Plugin = DeviceImpl.getPlugin(); + const AdapterPtr &Adapter = DeviceImpl.getAdapter(); ur_device_handle_t Device = DeviceImpl.getHandleRef(); size_t MaxWISize[] = {0, 0, 0}; - Plugin->call( + Adapter->call( Device, UR_DEVICE_INFO_MAX_WORK_ITEM_SIZES, sizeof(MaxWISize), &MaxWISize, nullptr); for (unsigned I = 0; I < NDRDesc.Dims; I++) { @@ -329,13 +329,13 @@ void handleInvalidWorkItemSize(const device_impl &DeviceImpl, void handleInvalidValue(const device_impl &DeviceImpl, const NDRDescT &NDRDesc) { - const PluginPtr &Plugin = DeviceImpl.getPlugin(); + const AdapterPtr &Adapter = DeviceImpl.getAdapter(); ur_device_handle_t Device = DeviceImpl.getHandleRef(); size_t MaxNWGs[] = {0, 0, 0}; - Plugin->call(Device, - UR_DEVICE_INFO_MAX_WORK_GROUPS_3D, - sizeof(MaxNWGs), &MaxNWGs, nullptr); + Adapter->call(Device, + UR_DEVICE_INFO_MAX_WORK_GROUPS_3D, + sizeof(MaxNWGs), &MaxNWGs, nullptr); for (unsigned int I = 0; I < NDRDesc.Dims; I++) { size_t NWgs = NDRDesc.GlobalSize[I] / NDRDesc.LocalSize[I]; if (NWgs > MaxNWGs[I]) @@ -418,7 +418,7 @@ void handleErrorOrWarning(ur_result_t Error, const device_impl &DeviceImpl, // an error or a warning. It also ensures that the contents of the error // message buffer (used only by UR_RESULT_ERROR_ADAPTER_SPECIFIC_ERROR) get // handled correctly. - return DeviceImpl.getPlugin()->checkUrResult(Error); + return DeviceImpl.getAdapter()->checkUrResult(Error); // TODO: Handle other error codes @@ -432,7 +432,7 @@ void handleErrorOrWarning(ur_result_t Error, const device_impl &DeviceImpl, namespace detail::kernel_get_group_info { void handleErrorOrWarning(ur_result_t Error, ur_kernel_group_info_t Descriptor, - const PluginPtr &Plugin) { + const AdapterPtr &Adapter) { assert(Error != UR_RESULT_SUCCESS && "Success is expected to be handled on caller side"); switch (Error) { @@ -446,7 +446,7 @@ void handleErrorOrWarning(ur_result_t Error, ur_kernel_group_info_t Descriptor, break; // TODO: Handle other error codes default: - Plugin->checkUrResult(Error); + Adapter->checkUrResult(Error); break; } } diff --git a/sycl/source/detail/error_handling/error_handling.hpp b/sycl/source/detail/error_handling/error_handling.hpp index 3583eb773e764..f6e6ffde09f10 100644 --- a/sycl/source/detail/error_handling/error_handling.hpp +++ b/sycl/source/detail/error_handling/error_handling.hpp @@ -32,7 +32,7 @@ void handleErrorOrWarning(ur_result_t, const device_impl &, ur_kernel_handle_t, namespace kernel_get_group_info { /// Analyzes error code of urKernelGetGroupInfo. void handleErrorOrWarning(ur_result_t, ur_kernel_group_info_t, - const PluginPtr &); + const AdapterPtr &); } // namespace kernel_get_group_info } // namespace detail diff --git a/sycl/source/detail/event_impl.cpp b/sycl/source/detail/event_impl.cpp index 7ca70acc6ae4b..f6e5edfc92e74 100644 --- a/sycl/source/detail/event_impl.cpp +++ b/sycl/source/detail/event_impl.cpp @@ -6,9 +6,9 @@ // //===----------------------------------------------------------------------===// +#include #include #include -#include #include #include #include @@ -46,7 +46,7 @@ event_impl::~event_impl() { try { auto Handle = this->getHandle(); if (Handle) - getPlugin()->call(Handle); + getAdapter()->call(Handle); } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~event_impl", e); } @@ -57,7 +57,7 @@ void event_impl::waitInternal(bool *Success) { if (!MIsHostEvent && Handle) { // Wait for the native event ur_result_t Err = - getPlugin()->call_nocheck(1, &Handle); + getAdapter()->call_nocheck(1, &Handle); // TODO drop the UR_RESULT_ERROR_UKNOWN from here (this was waiting for // https://github.com/oneapi-src/unified-runtime/issues/1459 which is now // closed). @@ -66,7 +66,7 @@ void event_impl::waitInternal(bool *Success) { Err == UR_RESULT_ERROR_IN_EVENT_LIST_EXEC_STATUS)) *Success = false; else { - getPlugin()->checkUrResult(Err); + getAdapter()->checkUrResult(Err); if (Success != nullptr) *Success = true; } @@ -130,9 +130,9 @@ const ContextImplPtr &event_impl::getContextImpl() { return MContext; } -const PluginPtr &event_impl::getPlugin() { +const AdapterPtr &event_impl::getAdapter() { initContextIfNeeded(); - return MContext->getPlugin(); + return MContext->getAdapter(); } void event_impl::setStateIncomplete() { MState = HES_NotComplete; } @@ -147,7 +147,7 @@ event_impl::event_impl(ur_event_handle_t Event, const context &SyclContext) MIsFlushed(true), MState(HES_Complete) { ur_context_handle_t TempContext; - getPlugin()->call( + getAdapter()->call( this->getHandle(), UR_EVENT_INFO_CONTEXT, sizeof(ur_context_handle_t), &TempContext, nullptr); @@ -302,7 +302,7 @@ event_impl::get_profiling_info() { // For profiling tag events we rely on the submission time reported as // the start time has undefined behavior. return get_event_profiling_info( - this->getHandle(), this->getPlugin()); + this->getHandle(), this->getAdapter()); } // The delay between the submission and the actual start of a CommandBuffer @@ -323,7 +323,7 @@ event_impl::get_profiling_info() { if (MEventFromSubmittedExecCommandBuffer && !MIsHostEvent && Handle) { uint64_t StartTime = get_event_profiling_info( - Handle, this->getPlugin()); + Handle, this->getAdapter()); if (StartTime < MSubmitTime) MSubmitTime = StartTime; } @@ -339,13 +339,13 @@ event_impl::get_profiling_info() { if (Handle) { auto StartTime = get_event_profiling_info( - Handle, this->getPlugin()); + Handle, this->getAdapter()); if (!MFallbackProfiling) { return StartTime; } else { auto DeviceBaseTime = get_event_profiling_info( - Handle, this->getPlugin()); + Handle, this->getAdapter()); return MHostBaseTime - DeviceBaseTime + StartTime; } } @@ -367,13 +367,13 @@ uint64_t event_impl::get_profiling_info() { if (Handle) { auto EndTime = get_event_profiling_info( - Handle, this->getPlugin()); + Handle, this->getAdapter()); if (!MFallbackProfiling) { return EndTime; } else { auto DeviceBaseTime = get_event_profiling_info( - Handle, this->getPlugin()); + Handle, this->getAdapter()); return MHostBaseTime - DeviceBaseTime + EndTime; } } @@ -391,7 +391,7 @@ template <> uint32_t event_impl::get_info() { auto Handle = this->getHandle(); if (!MIsHostEvent && Handle) { return get_event_info(Handle, - this->getPlugin()); + this->getAdapter()); } return 0; } @@ -407,7 +407,7 @@ event_impl::get_info() { auto Handle = this->getHandle(); if (Handle) return get_event_info( - Handle, this->getPlugin()); + Handle, this->getAdapter()); // Command is blocked and not enqueued, UrEvent is not assigned yet else if (MCommand) return sycl::info::event_command_status::submitted; @@ -483,21 +483,21 @@ ur_native_handle_t event_impl::getNative() { return {}; initContextIfNeeded(); - auto Plugin = getPlugin(); + auto Adapter = getAdapter(); auto Handle = getHandle(); if (MIsDefaultConstructed && !Handle) { auto TempContext = MContext.get()->getHandleRef(); ur_event_native_properties_t NativeProperties{}; ur_event_handle_t UREvent = nullptr; - Plugin->call( + Adapter->call( 0, TempContext, &NativeProperties, &UREvent); this->setHandle(UREvent); Handle = UREvent; } if (MContext->getBackend() == backend::opencl) - Plugin->call(Handle); + Adapter->call(Handle); ur_native_handle_t OutHandle; - Plugin->call(Handle, &OutHandle); + Adapter->call(Handle, &OutHandle); return OutHandle; } @@ -538,11 +538,11 @@ void event_impl::flushIfNeeded(const QueueImplPtr &UserQueue) { // Check if the task for this event has already been submitted. ur_event_status_t Status = UR_EVENT_STATUS_QUEUED; - getPlugin()->call( + getAdapter()->call( Handle, UR_EVENT_INFO_COMMAND_EXECUTION_STATUS, sizeof(ur_event_status_t), &Status, nullptr); if (Status == UR_EVENT_STATUS_QUEUED) { - getPlugin()->call(Queue->getHandleRef()); + getAdapter()->call(Queue->getHandleRef()); } MIsFlushed = true; } diff --git a/sycl/source/detail/event_impl.hpp b/sycl/source/detail/event_impl.hpp index 312bb589760b7..f92d198d259d6 100644 --- a/sycl/source/detail/event_impl.hpp +++ b/sycl/source/detail/event_impl.hpp @@ -8,7 +8,7 @@ #pragma once -#include +#include #include #include #include @@ -27,7 +27,7 @@ class graph_impl; } class context; namespace detail { -class plugin; +class Adapter; class context_impl; using ContextImplPtr = std::shared_ptr; class queue_impl; @@ -137,9 +137,9 @@ class event_impl { /// \return a shared pointer to a valid context_impl. const ContextImplPtr &getContextImpl(); - /// \return the Plugin associated with the context of this event. + /// \return the Adapter associated with the context of this event. /// Should be called when this is not a Host Event. - const PluginPtr &getPlugin(); + const AdapterPtr &getAdapter(); /// Associate event with the context. /// diff --git a/sycl/source/detail/event_info.hpp b/sycl/source/detail/event_info.hpp index 119862e08941e..ed47e101e08de 100644 --- a/sycl/source/detail/event_info.hpp +++ b/sycl/source/detail/event_info.hpp @@ -8,8 +8,8 @@ #pragma once +#include #include -#include #include #include #include @@ -19,26 +19,26 @@ inline namespace _V1 { namespace detail { template -typename Param::return_type get_event_profiling_info(ur_event_handle_t Event, - const PluginPtr &Plugin) { +typename Param::return_type +get_event_profiling_info(ur_event_handle_t Event, const AdapterPtr &Adapter) { static_assert(is_event_profiling_info_desc::value, "Unexpected event profiling info descriptor"); typename Param::return_type Result{0}; // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call( + Adapter->call( Event, UrInfoCode::value, sizeof(Result), &Result, nullptr); return Result; } template typename Param::return_type get_event_info(ur_event_handle_t Event, - const PluginPtr &Plugin) { + const AdapterPtr &Adapter) { static_assert(is_event_info_desc::value, "Unexpected event info descriptor"); typename Param::return_type Result{0}; // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call(Event, UrInfoCode::value, - sizeof(Result), &Result, nullptr); + Adapter->call(Event, UrInfoCode::value, + sizeof(Result), &Result, nullptr); // If the status is UR_EVENT_STATUS_QUEUED We need to change it since QUEUE is // not a valid status in sycl. diff --git a/sycl/source/detail/global_handler.cpp b/sycl/source/detail/global_handler.cpp index 9f0d6df7282d1..a13d81b54daca 100644 --- a/sycl/source/detail/global_handler.cpp +++ b/sycl/source/detail/global_handler.cpp @@ -11,10 +11,10 @@ #include "llvm/Support/Signals.h" #endif +#include #include #include #include -#include #include #include #include @@ -170,7 +170,7 @@ Scheduler &GlobalHandler::getScheduler() { // work. So, registering signal handler here because: // 1) getScheduler is likely to be called for any non-trivial application; // 2) first call to getScheduler is likely to be done after main starts. - // The same is done in getPlugins. + // The same is done in getAdapters. enableOnCrashStackPrinting(); return *MScheduler.Inst; } @@ -208,9 +208,9 @@ std::mutex &GlobalHandler::getFilterMutex() { return getOrCreate(MFilterMutex); } -std::vector &GlobalHandler::getPlugins() { +std::vector &GlobalHandler::getAdapters() { enableOnCrashStackPrinting(); - return getOrCreate(MPlugins); + return getOrCreate(MAdapters); } ods_target_list & @@ -262,14 +262,14 @@ bool GlobalHandler::isOkToDefer() const { return OkToDefer; } void GlobalHandler::endDeferredRelease() { OkToDefer = false; } // Note: Split from shutdown so it is available to the unittests for ensuring -// that the mock plugin is the lone plugin. -void GlobalHandler::unloadPlugins() { - // Call to GlobalHandler::instance().getPlugins() initializes plugins. If +// that the mock adapter is the lone adapter. +void GlobalHandler::unloadAdapters() { + // Call to GlobalHandler::instance().getAdapters() initializes adapters. If // user application has loaded SYCL runtime, and never called any APIs, - // there's no need to load and unload plugins. - if (MPlugins.Inst) { - for (const auto &Plugin : getPlugins()) { - Plugin->release(); + // there's no need to load and unload adapters. + if (MAdapters.Inst) { + for (const auto &Adapter : getAdapters()) { + Adapter->release(); } } @@ -280,7 +280,7 @@ void GlobalHandler::unloadPlugins() { // urLoaderTearDown(); // Clear after unload to avoid uses after unload. - getPlugins().clear(); + getAdapters().clear(); } void GlobalHandler::prepareSchedulerToRelease(bool Blocking) { @@ -303,11 +303,11 @@ void GlobalHandler::drainThreadPool() { // threads may be shutdown once the end of main() is reached // making an orderly shutdown difficult. Fortunately, Windows // itself is very aggressive about reclaiming memory. Thus, -// we focus solely on unloading the plugins, so as to not +// we focus solely on unloading the adapters, so as to not // accidentally retain device handles. etc void shutdown_win() { GlobalHandler *&Handler = GlobalHandler::getInstancePtr(); - Handler->unloadPlugins(); + Handler->unloadAdapters(); } #else void shutdown_early() { @@ -337,15 +337,15 @@ void shutdown_late() { if (!Handler) return; - // First, release resources, that may access plugins. + // First, release resources, that may access adapters. Handler->MPlatformCache.Inst.reset(nullptr); Handler->MScheduler.Inst.reset(nullptr); Handler->MProgramManager.Inst.reset(nullptr); - // Clear the plugins and reset the instance if it was there. - Handler->unloadPlugins(); - if (Handler->MPlugins.Inst) - Handler->MPlugins.Inst.reset(nullptr); + // Clear the adapters and reset the instance if it was there. + Handler->unloadAdapters(); + if (Handler->MAdapters.Inst) + Handler->MAdapters.Inst.reset(nullptr); Handler->MXPTIRegistry.Inst.reset(nullptr); diff --git a/sycl/source/detail/global_handler.hpp b/sycl/source/detail/global_handler.hpp index 069fff3dbcdd5..4b834927e3832 100644 --- a/sycl/source/detail/global_handler.hpp +++ b/sycl/source/detail/global_handler.hpp @@ -22,14 +22,14 @@ class context_impl; class Scheduler; class ProgramManager; class Sync; -class plugin; +class Adapter; class ods_target_list; class XPTIRegistry; class ThreadPool; using PlatformImplPtr = std::shared_ptr; using ContextImplPtr = std::shared_ptr; -using PluginPtr = std::shared_ptr; +using AdapterPtr = std::shared_ptr; /// Wrapper class for global data structures with non-trivial destructors. /// @@ -68,7 +68,7 @@ class GlobalHandler { std::mutex &getPlatformToDefaultContextCacheMutex(); std::mutex &getPlatformMapMutex(); std::mutex &getFilterMutex(); - std::vector &getPlugins(); + std::vector &getAdapters(); ods_target_list &getOneapiDeviceSelectorTargets(const std::string &InitValue); XPTIRegistry &getXPTIRegistry(); ThreadPool &getHostTaskThreadPool(); @@ -77,7 +77,7 @@ class GlobalHandler { bool isOkToDefer() const; void endDeferredRelease(); - void unloadPlugins(); + void unloadAdapters(); void releaseDefaultContexts(); void drainThreadPool(); void prepareSchedulerToRelease(bool Blocking); @@ -124,7 +124,7 @@ class GlobalHandler { InstWithLock MPlatformToDefaultContextCacheMutex; InstWithLock MPlatformMapMutex; InstWithLock MFilterMutex; - InstWithLock> MPlugins; + InstWithLock> MAdapters; InstWithLock MOneapiDeviceSelectorTargets; InstWithLock MXPTIRegistry; // Thread pool for host task and event callbacks execution diff --git a/sycl/source/detail/graph_impl.cpp b/sycl/source/detail/graph_impl.cpp index 53d032d5f7672..acdf6baf50475 100644 --- a/sycl/source/detail/graph_impl.cpp +++ b/sycl/source/detail/graph_impl.cpp @@ -718,10 +718,10 @@ void exec_graph_impl::createCommandBuffers( UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC, nullptr, MIsUpdatable, Partition->MIsInOrderGraph && !MEnableProfiling, MEnableProfiling}; auto ContextImpl = sycl::detail::getSyclObjImpl(MContext); - const sycl::detail::PluginPtr &Plugin = ContextImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = ContextImpl->getAdapter(); auto DeviceImpl = sycl::detail::getSyclObjImpl(Device); ur_result_t Res = - Plugin->call_nocheck( + Adapter->call_nocheck( ContextImpl->getHandleRef(), DeviceImpl->getHandleRef(), &Desc, &OutCommandBuffer); if (Res != UR_RESULT_SUCCESS) { @@ -763,9 +763,9 @@ void exec_graph_impl::createCommandBuffers( Node->MCommandGroup->getAccStorage().end()); } - Res = - Plugin->call_nocheck( - OutCommandBuffer); + Res = Adapter + ->call_nocheck( + OutCommandBuffer); if (Res != UR_RESULT_SUCCESS) { throw sycl::exception(errc::invalid, "Failed to finalize UR command-buffer"); @@ -798,8 +798,8 @@ exec_graph_impl::exec_graph_impl(sycl::context Context, exec_graph_impl::~exec_graph_impl() { try { - const sycl::detail::PluginPtr &Plugin = - sycl::detail::getSyclObjImpl(MContext)->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = + sycl::detail::getSyclObjImpl(MContext)->getAdapter(); MSchedule.clear(); // We need to wait on all command buffer executions before we can release // them. @@ -811,7 +811,7 @@ exec_graph_impl::~exec_graph_impl() { Partition->MSchedule.clear(); for (const auto &Iter : Partition->MCommandBuffers) { if (auto CmdBuf = Iter.second; CmdBuf) { - ur_result_t Res = Plugin->call_nocheck< + ur_result_t Res = Adapter->call_nocheck< sycl::detail::UrApiKind::urCommandBufferReleaseExp>(CmdBuf); (void)Res; assert(Res == UR_RESULT_SUCCESS); @@ -821,7 +821,7 @@ exec_graph_impl::~exec_graph_impl() { for (auto &Iter : MCommandMap) { if (auto Command = Iter.second; Command) { - ur_result_t Res = Plugin->call_nocheck< + ur_result_t Res = Adapter->call_nocheck< sycl::detail::UrApiKind::urCommandBufferReleaseCommandExp>(Command); (void)Res; assert(Res == UR_RESULT_SUCCESS); @@ -925,7 +925,7 @@ exec_graph_impl::enqueue(const std::shared_ptr &Queue, NewEvent->setHostEnqueueTime(); } ur_result_t Res = - Queue->getPlugin() + Queue->getAdapter() ->call_nocheck< sycl::detail::UrApiKind::urCommandBufferEnqueueExp>( CommandBuffer, Queue->getHandleRef(), 0, nullptr, &UREvent); @@ -1339,7 +1339,7 @@ void exec_graph_impl::updateImpl(std::shared_ptr Node) { return; } auto ContextImpl = sycl::detail::getSyclObjImpl(MContext); - const sycl::detail::PluginPtr &Plugin = ContextImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = ContextImpl->getAdapter(); auto DeviceImpl = sycl::detail::getSyclObjImpl(MGraphImpl->getDevice()); // Gather arg information from Node @@ -1399,7 +1399,7 @@ void exec_graph_impl::updateImpl(std::shared_ptr Node) { if (NDRDesc.LocalSize[0] != 0) LocalSize = &NDRDesc.LocalSize[0]; else { - Plugin->call( + Adapter->call( UrKernel, DeviceImpl->getHandleRef(), UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE, sizeof(RequiredWGSize), RequiredWGSize, @@ -1500,14 +1500,14 @@ void exec_graph_impl::updateImpl(std::shared_ptr Node) { ur_exp_command_buffer_command_handle_t Command = MCommandMap[ExecNode->second]; - ur_result_t Res = Plugin->call_nocheck< + ur_result_t Res = Adapter->call_nocheck< sycl::detail::UrApiKind::urCommandBufferUpdateKernelLaunchExp>( Command, &UpdateDesc); if (UrProgram) { // We retained these objects by calling getOrCreateKernel() - Plugin->call(UrKernel); - Plugin->call(UrProgram); + Adapter->call(UrKernel); + Adapter->call(UrProgram); } if (Res != UR_RESULT_SUCCESS) { diff --git a/sycl/source/detail/image_impl.cpp b/sycl/source/detail/image_impl.cpp index f02c7f594a057..76479463a92ef 100644 --- a/sycl/source/detail/image_impl.cpp +++ b/sycl/source/detail/image_impl.cpp @@ -261,9 +261,9 @@ image_channel_type convertChannelType(ur_image_channel_type_t Type) { template static void getImageInfo(const ContextImplPtr Context, ur_image_info_t Info, T &Dest, ur_mem_handle_t InteropMemObject) { - const PluginPtr &Plugin = Context->getPlugin(); - Plugin->call(InteropMemObject, Info, sizeof(T), - &Dest, nullptr); + const AdapterPtr &Adapter = Context->getAdapter(); + Adapter->call(InteropMemObject, Info, sizeof(T), + &Dest, nullptr); } image_impl::image_impl(cl_mem MemObject, const context &SyclContext, @@ -275,9 +275,9 @@ image_impl::image_impl(cl_mem MemObject, const context &SyclContext, MDimensions(Dimensions), MRange({0, 0, 0}) { ur_mem_handle_t Mem = ur::cast(BaseT::MInteropMemObject); const ContextImplPtr Context = getSyclObjImpl(SyclContext); - const PluginPtr &Plugin = Context->getPlugin(); - Plugin->call(Mem, UR_MEM_INFO_SIZE, sizeof(size_t), - &(BaseT::MSizeInBytes), nullptr); + const AdapterPtr &Adapter = Context->getAdapter(); + Adapter->call(Mem, UR_MEM_INFO_SIZE, sizeof(size_t), + &(BaseT::MSizeInBytes), nullptr); ur_image_format_t Format; getImageInfo(Context, UR_IMAGE_INFO_FORMAT, Format, Mem); diff --git a/sycl/source/detail/kernel_bundle_impl.hpp b/sycl/source/detail/kernel_bundle_impl.hpp index 2a128ba9a901e..38b6bb1deb920 100644 --- a/sycl/source/detail/kernel_bundle_impl.hpp +++ b/sycl/source/detail/kernel_bundle_impl.hpp @@ -406,7 +406,7 @@ class kernel_bundle_impl { using ContextImplPtr = std::shared_ptr; ContextImplPtr ContextImpl = getSyclObjImpl(MContext); - const PluginPtr &Plugin = ContextImpl->getPlugin(); + const AdapterPtr &Adapter = ContextImpl->getAdapter(); std::vector DeviceVec; DeviceVec.reserve(Devices.size()); @@ -424,7 +424,7 @@ class kernel_bundle_impl { std::transform(DeviceVec.begin(), DeviceVec.end(), IPVersionVec.begin(), [&](ur_device_handle_t d) { uint32_t ipVersion = 0; - Plugin->call( + Adapter->call( d, UR_DEVICE_INFO_IP_VERSION, sizeof(uint32_t), &ipVersion, nullptr); return ipVersion; @@ -452,9 +452,9 @@ class kernel_bundle_impl { }(); ur_program_handle_t UrProgram = nullptr; - Plugin->call(ContextImpl->getHandleRef(), - spirv.data(), spirv.size(), - nullptr, &UrProgram); + Adapter->call(ContextImpl->getHandleRef(), + spirv.data(), spirv.size(), + nullptr, &UrProgram); // program created by urProgramCreateWithIL is implicitly retained. if (UrProgram == nullptr) throw sycl::exception( @@ -462,28 +462,28 @@ class kernel_bundle_impl { "urProgramCreateWithIL resulted in a null program handle."); std::string XsFlags = extractXsFlags(BuildOptions); - auto Res = Plugin->call_nocheck( + auto Res = Adapter->call_nocheck( UrProgram, DeviceVec.size(), DeviceVec.data(), XsFlags.c_str()); if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { - Res = Plugin->call_nocheck( + Res = Adapter->call_nocheck( ContextImpl->getHandleRef(), UrProgram, XsFlags.c_str()); } - Plugin->checkUrResult(Res); + Adapter->checkUrResult(Res); // Get the number of kernels in the program. size_t NumKernels; - Plugin->call( + Adapter->call( UrProgram, UR_PROGRAM_INFO_NUM_KERNELS, sizeof(size_t), &NumKernels, nullptr); // Get the kernel names. size_t KernelNamesSize; - Plugin->call( + Adapter->call( UrProgram, UR_PROGRAM_INFO_KERNEL_NAMES, 0, nullptr, &KernelNamesSize); // semi-colon delimited list of kernel names. std::string KernelNamesStr(KernelNamesSize, ' '); - Plugin->call( + Adapter->call( UrProgram, UR_PROGRAM_INFO_KERNEL_NAMES, KernelNamesStr.size(), &KernelNamesStr[0], nullptr); std::vector KernelNames = @@ -535,10 +535,10 @@ class kernel_bundle_impl { detail::getSyclObjImpl(MDeviceImages[0]); ur_program_handle_t UrProgram = DeviceImageImpl->get_ur_program_ref(); ContextImplPtr ContextImpl = getSyclObjImpl(MContext); - const PluginPtr &Plugin = ContextImpl->getPlugin(); + const AdapterPtr &Adapter = ContextImpl->getAdapter(); ur_kernel_handle_t UrKernel = nullptr; - Plugin->call(UrProgram, AdjustedName.c_str(), - &UrKernel); + Adapter->call(UrProgram, AdjustedName.c_str(), + &UrKernel); // Kernel created by urKernelCreate is implicitly retained. std::shared_ptr KernelImpl = std::make_shared( diff --git a/sycl/source/detail/kernel_impl.cpp b/sycl/source/detail/kernel_impl.cpp index 50af09831f207..986e78aa21530 100644 --- a/sycl/source/detail/kernel_impl.cpp +++ b/sycl/source/detail/kernel_impl.cpp @@ -25,8 +25,8 @@ kernel_impl::kernel_impl(ur_kernel_handle_t Kernel, ContextImplPtr Context, MCreatedFromSource(true), MKernelBundleImpl(std::move(KernelBundleImpl)), MIsInterop(true), MKernelArgMaskPtr{ArgMask} { ur_context_handle_t UrContext = nullptr; - // Using the plugin from the passed ContextImpl - getPlugin()->call( + // Using the adapter from the passed ContextImpl + getAdapter()->call( MKernel, UR_KERNEL_INFO_CONTEXT, sizeof(UrContext), &UrContext, nullptr); if (Context->getHandleRef() != UrContext) throw sycl::exception( @@ -34,11 +34,11 @@ kernel_impl::kernel_impl(ur_kernel_handle_t Kernel, ContextImplPtr Context, "Input context must be the same as the context of cl_kernel"); // Enable USM indirect access for interoperability kernels. - // Some UR Plugins (like OpenCL) require this call to enable USM + // Some UR Adapters (like OpenCL) require this call to enable USM // For others, UR will turn this into a NOP. if (Context->getPlatformImpl()->supports_usm()) { bool EnableAccess = true; - getPlugin()->call( + getAdapter()->call( MKernel, UR_KERNEL_EXEC_INFO_USM_INDIRECT_ACCESS, sizeof(ur_bool_t), nullptr, &EnableAccess); } @@ -59,7 +59,7 @@ kernel_impl::kernel_impl(ur_kernel_handle_t Kernel, ContextImplPtr ContextImpl, kernel_impl::~kernel_impl() { try { // TODO catch an exception and put it to list of asynchronous exceptions - getPlugin()->call(MKernel); + getAdapter()->call(MKernel); } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~kernel_impl", e); } diff --git a/sycl/source/detail/kernel_impl.hpp b/sycl/source/detail/kernel_impl.hpp index 040b5cbccf965..1b71eb3e659ad 100644 --- a/sycl/source/detail/kernel_impl.hpp +++ b/sycl/source/detail/kernel_impl.hpp @@ -74,14 +74,14 @@ class kernel_impl { /// /// \return a valid cl_kernel instance cl_kernel get() const { - getPlugin()->call(MKernel); + getAdapter()->call(MKernel); ur_native_handle_t nativeHandle = 0; - getPlugin()->call(MKernel, - &nativeHandle); + getAdapter()->call(MKernel, + &nativeHandle); return ur::cast(nativeHandle); } - const PluginPtr &getPlugin() const { return MContext->getPlugin(); } + const AdapterPtr &getAdapter() const { return MContext->getAdapter(); } /// Query information from the kernel object using the info::kernel_info /// descriptor. @@ -150,13 +150,13 @@ class kernel_impl { const DeviceImageImplPtr &getDeviceImage() const { return MDeviceImageImpl; } ur_native_handle_t getNative() const { - const PluginPtr &Plugin = MContext->getPlugin(); + const AdapterPtr &Adapter = MContext->getAdapter(); if (MContext->getBackend() == backend::opencl) - Plugin->call(MKernel); + Adapter->call(MKernel); ur_native_handle_t NativeKernel = 0; - Plugin->call(MKernel, &NativeKernel); + Adapter->call(MKernel, &NativeKernel); return NativeKernel; } @@ -204,7 +204,7 @@ inline typename Param::return_type kernel_impl::get_info() const { if constexpr (std::is_same_v) checkIfValidForNumArgsInfoQuery(); - return get_kernel_info(this->getHandleRef(), getPlugin()); + return get_kernel_info(this->getHandleRef(), getAdapter()); } template <> @@ -229,7 +229,7 @@ kernel_impl::get_info(const device &Device) const { return get_kernel_device_specific_info( this->getHandleRef(), getSyclObjImpl(Device)->getHandleRef(), - getPlugin()); + getAdapter()); } template @@ -238,7 +238,7 @@ kernel_impl::get_info(const device &Device, const sycl::range<3> &WGSize) const { return get_kernel_device_specific_info_with_input( this->getHandleRef(), getSyclObjImpl(Device)->getHandleRef(), WGSize, - getPlugin()); + getAdapter()); } namespace syclex = ext::oneapi::experimental; @@ -254,17 +254,17 @@ inline typename syclex::info::kernel_queue_specific::max_num_work_groups:: throw exception(sycl::make_error_code(errc::invalid), "The launch work-group size cannot be zero."); - const auto &Plugin = getPlugin(); + const auto &Adapter = getAdapter(); const auto &Handle = getHandleRef(); auto Device = Queue.get_device(); uint32_t GroupCount{0}; - if (auto Result = Plugin->call_nocheck< + if (auto Result = Adapter->call_nocheck< UrApiKind::urKernelSuggestMaxCooperativeGroupCountExp>( Handle, WorkGroupSize.size(), DynamicLocalMemorySize, &GroupCount); Result != UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { // The feature is supported. Check for other errors and throw if any. - Plugin->checkUrResult(Result); + Adapter->checkUrResult(Result); return GroupCount; } diff --git a/sycl/source/detail/kernel_info.hpp b/sycl/source/detail/kernel_info.hpp index 809a9dd25510e..c40af1a728ccd 100644 --- a/sycl/source/detail/kernel_info.hpp +++ b/sycl/source/detail/kernel_info.hpp @@ -25,33 +25,33 @@ template typename std::enable_if< std::is_same::value, std::string>::type -get_kernel_info(ur_kernel_handle_t Kernel, const PluginPtr &Plugin) { +get_kernel_info(ur_kernel_handle_t Kernel, const AdapterPtr &Adapter) { static_assert(detail::is_kernel_info_desc::value, "Invalid kernel information descriptor"); size_t ResultSize = 0; // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call(Kernel, UrInfoCode::value, 0, - nullptr, &ResultSize); + Adapter->call(Kernel, UrInfoCode::value, 0, + nullptr, &ResultSize); if (ResultSize == 0) { return ""; } std::vector Result(ResultSize); // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call(Kernel, UrInfoCode::value, - ResultSize, Result.data(), nullptr); + Adapter->call(Kernel, UrInfoCode::value, + ResultSize, Result.data(), nullptr); return std::string(Result.data()); } template typename std::enable_if< std::is_same::value, uint32_t>::type -get_kernel_info(ur_kernel_handle_t Kernel, const PluginPtr &Plugin) { +get_kernel_info(ur_kernel_handle_t Kernel, const AdapterPtr &Adapter) { ur_result_t Result = UR_RESULT_SUCCESS; // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call(Kernel, UrInfoCode::value, - sizeof(uint32_t), &Result, nullptr); + Adapter->call(Kernel, UrInfoCode::value, + sizeof(uint32_t), &Result, nullptr); return Result; } @@ -60,9 +60,9 @@ template typename std::enable_if::value>::type get_kernel_device_specific_info_helper(ur_kernel_handle_t Kernel, ur_device_handle_t Device, - const PluginPtr &Plugin, void *Result, + const AdapterPtr &Adapter, void *Result, size_t Size) { - Plugin->call( + Adapter->call( Kernel, Device, UrInfoCode::value, Size, Result, nullptr); } @@ -70,9 +70,9 @@ template typename std::enable_if::value>::type get_kernel_device_specific_info_helper( ur_kernel_handle_t Kernel, [[maybe_unused]] ur_device_handle_t Device, - const PluginPtr &Plugin, void *Result, size_t Size) { - Plugin->call(Kernel, UrInfoCode::value, - Size, Result, nullptr); + const AdapterPtr &Adapter, void *Result, size_t Size) { + Adapter->call(Kernel, UrInfoCode::value, + Size, Result, nullptr); } template @@ -80,13 +80,13 @@ typename std::enable_if::value && !IsKernelInfo::value>::type get_kernel_device_specific_info_helper(ur_kernel_handle_t Kernel, ur_device_handle_t Device, - const PluginPtr &Plugin, void *Result, + const AdapterPtr &Adapter, void *Result, size_t Size) { - ur_result_t Error = Plugin->call_nocheck( + ur_result_t Error = Adapter->call_nocheck( Kernel, Device, UrInfoCode::value, Size, Result, nullptr); if (Error != UR_RESULT_SUCCESS) kernel_get_group_info::handleErrorOrWarning(Error, UrInfoCode::value, - Plugin); + Adapter); } template @@ -95,13 +95,13 @@ typename std::enable_if< typename Param::return_type>::type get_kernel_device_specific_info(ur_kernel_handle_t Kernel, ur_device_handle_t Device, - const PluginPtr &Plugin) { + const AdapterPtr &Adapter) { static_assert(is_kernel_device_specific_info_desc::value, "Unexpected kernel_device_specific information descriptor"); typename Param::return_type Result = {}; // TODO catch an exception and put it to list of asynchronous exceptions get_kernel_device_specific_info_helper( - Kernel, Device, Plugin, &Result, sizeof(typename Param::return_type)); + Kernel, Device, Adapter, &Result, sizeof(typename Param::return_type)); return Result; } @@ -111,12 +111,12 @@ typename std::enable_if< sycl::range<3>>::type get_kernel_device_specific_info(ur_kernel_handle_t Kernel, ur_device_handle_t Device, - const PluginPtr &Plugin) { + const AdapterPtr &Adapter) { static_assert(is_kernel_device_specific_info_desc::value, "Unexpected kernel_device_specific information descriptor"); size_t Result[3] = {0, 0, 0}; // TODO catch an exception and put it to list of asynchronous exceptions - get_kernel_device_specific_info_helper(Kernel, Device, Plugin, Result, + get_kernel_device_specific_info_helper(Kernel, Device, Adapter, Result, sizeof(size_t) * 3); return sycl::range<3>(Result[0], Result[1], Result[2]); } @@ -128,7 +128,7 @@ template uint32_t get_kernel_device_specific_info_with_input(ur_kernel_handle_t Kernel, ur_device_handle_t Device, sycl::range<3>, - const PluginPtr &Plugin) { + const AdapterPtr &Adapter) { static_assert(is_kernel_device_specific_info_desc::value, "Unexpected kernel_device_specific information descriptor"); static_assert(std::is_same::value, @@ -139,7 +139,7 @@ uint32_t get_kernel_device_specific_info_with_input(ur_kernel_handle_t Kernel, uint32_t Result = 0; // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call( + Adapter->call( Kernel, Device, UrInfoCode::value, sizeof(uint32_t), &Result, nullptr); diff --git a/sycl/source/detail/kernel_program_cache.cpp b/sycl/source/detail/kernel_program_cache.cpp index 6916f425ca50f..b5c9dbc3fa342 100644 --- a/sycl/source/detail/kernel_program_cache.cpp +++ b/sycl/source/detail/kernel_program_cache.cpp @@ -6,15 +6,15 @@ // //===----------------------------------------------------------------------===// +#include #include #include -#include namespace sycl { inline namespace _V1 { namespace detail { -const PluginPtr &KernelProgramCache::getPlugin() { - return MParentContext->getPlugin(); +const AdapterPtr &KernelProgramCache::getAdapter() { + return MParentContext->getAdapter(); } } // namespace detail } // namespace _V1 diff --git a/sycl/source/detail/kernel_program_cache.hpp b/sycl/source/detail/kernel_program_cache.hpp index 44dfd84751afd..0e6323b74e3ef 100644 --- a/sycl/source/detail/kernel_program_cache.hpp +++ b/sycl/source/detail/kernel_program_cache.hpp @@ -90,12 +90,12 @@ class KernelProgramCache { }; struct ProgramBuildResult : public BuildResult { - PluginPtr Plugin; - ProgramBuildResult(const PluginPtr &Plugin) : Plugin(Plugin) { + AdapterPtr Adapter; + ProgramBuildResult(const AdapterPtr &Adapter) : Adapter(Adapter) { Val = nullptr; } - ProgramBuildResult(const PluginPtr &Plugin, BuildState InitialState) - : Plugin(Plugin) { + ProgramBuildResult(const AdapterPtr &Adapter, BuildState InitialState) + : Adapter(Adapter) { Val = nullptr; this->State.store(InitialState); } @@ -103,7 +103,7 @@ class KernelProgramCache { try { if (Val) { ur_result_t Err = - Plugin->call_nocheck(Val); + Adapter->call_nocheck(Val); __SYCL_CHECK_UR_CODE_NO_EXC(Err); } } catch (std::exception &e) { @@ -134,15 +134,15 @@ class KernelProgramCache { using KernelArgMaskPairT = std::pair; struct KernelBuildResult : public BuildResult { - PluginPtr Plugin; - KernelBuildResult(const PluginPtr &Plugin) : Plugin(Plugin) { + AdapterPtr Adapter; + KernelBuildResult(const AdapterPtr &Adapter) : Adapter(Adapter) { Val.first = nullptr; } ~KernelBuildResult() { try { if (Val.first) { ur_result_t Err = - Plugin->call_nocheck(Val.first); + Adapter->call_nocheck(Val.first); __SYCL_CHECK_UR_CODE_NO_EXC(Err); } } catch (std::exception &e) { @@ -188,7 +188,7 @@ class KernelProgramCache { auto &ProgCache = LockedCache.get(); auto [It, DidInsert] = ProgCache.Cache.try_emplace(CacheKey, nullptr); if (DidInsert) { - It->second = std::make_shared(getPlugin()); + It->second = std::make_shared(getAdapter()); // Save reference between the common key and the full key. CommonProgramKeyT CommonKey = std::make_pair(CacheKey.first.second, CacheKey.second); @@ -208,7 +208,7 @@ class KernelProgramCache { auto &ProgCache = LockedCache.get(); auto [It, DidInsert] = ProgCache.Cache.try_emplace(CacheKey, nullptr); if (DidInsert) { - It->second = std::make_shared(getPlugin(), + It->second = std::make_shared(getAdapter(), BuildState::BS_Done); It->second->Val = Program; // Save reference between the common key and the full key. @@ -226,7 +226,7 @@ class KernelProgramCache { auto &Cache = LockedCache.get()[Program]; auto [It, DidInsert] = Cache.try_emplace(KernelName, nullptr); if (DidInsert) - It->second = std::make_shared(getPlugin()); + It->second = std::make_shared(getAdapter()); return std::make_pair(It->second, DidInsert); } @@ -357,7 +357,7 @@ class KernelProgramCache { KernelFastCacheT MKernelFastCache; friend class ::MockKernelProgramCache; - const PluginPtr &getPlugin(); + const AdapterPtr &getAdapter(); }; } // namespace detail } // namespace _V1 diff --git a/sycl/source/detail/mem_alloc_helper.hpp b/sycl/source/detail/mem_alloc_helper.hpp index 69759709c0b47..88e4d742fcec6 100644 --- a/sycl/source/detail/mem_alloc_helper.hpp +++ b/sycl/source/detail/mem_alloc_helper.hpp @@ -13,19 +13,19 @@ namespace sycl { inline namespace _V1 { namespace detail { -void memBufferCreateHelper(const PluginPtr &Plugin, ur_context_handle_t Ctx, +void memBufferCreateHelper(const AdapterPtr &Adapter, ur_context_handle_t Ctx, ur_mem_flags_t Flags, size_t Size, ur_mem_handle_t *RetMem, const ur_buffer_properties_t *Props = nullptr); -void memReleaseHelper(const PluginPtr &Plugin, ur_mem_handle_t Mem); -void memBufferMapHelper(const PluginPtr &Plugin, +void memReleaseHelper(const AdapterPtr &Adapter, ur_mem_handle_t Mem); +void memBufferMapHelper(const AdapterPtr &Adapter, ur_queue_handle_t command_queue, ur_mem_handle_t buffer, bool blocking_map, ur_map_flags_t map_flags, size_t offset, size_t size, uint32_t num_events_in_wait_list, const ur_event_handle_t *event_wait_list, ur_event_handle_t *event, void **ret_map); -void memUnmapHelper(const PluginPtr &Plugin, ur_queue_handle_t command_queue, +void memUnmapHelper(const AdapterPtr &Adapter, ur_queue_handle_t command_queue, ur_mem_handle_t memobj, void *mapped_ptr, uint32_t num_events_in_wait_list, const ur_event_handle_t *event_wait_list, diff --git a/sycl/source/detail/memory_manager.cpp b/sycl/source/detail/memory_manager.cpp index c4281e8df0013..5c86e5e21d216 100644 --- a/sycl/source/detail/memory_manager.cpp +++ b/sycl/source/detail/memory_manager.cpp @@ -122,18 +122,18 @@ static void waitForEvents(const std::vector &Events) { // Assuming all events will be on the same device or // devices associated with the same Backend. if (!Events.empty()) { - const PluginPtr &Plugin = Events[0]->getPlugin(); + const AdapterPtr &Adapter = Events[0]->getAdapter(); std::vector UrEvents(Events.size()); std::transform( Events.begin(), Events.end(), UrEvents.begin(), [](const EventImplPtr &EventImpl) { return EventImpl->getHandle(); }); if (!UrEvents.empty() && UrEvents[0]) { - Plugin->call(UrEvents.size(), &UrEvents[0]); + Adapter->call(UrEvents.size(), &UrEvents[0]); } } } -void memBufferCreateHelper(const PluginPtr &Plugin, ur_context_handle_t Ctx, +void memBufferCreateHelper(const AdapterPtr &Adapter, ur_context_handle_t Ctx, ur_mem_flags_t Flags, size_t Size, ur_mem_handle_t *RetMem, const ur_buffer_properties_t *Props) { @@ -155,19 +155,19 @@ void memBufferCreateHelper(const PluginPtr &Plugin, ur_context_handle_t Ctx, // When doing buffer interop we don't know what device the memory should // be resident on, so pass nullptr for Device param. Buffer interop may // not be supported by all backends. - Plugin->call_nocheck( + Adapter->call_nocheck( *RetMem, /*Dev*/ nullptr, &Ptr); emitMemAllocEndTrace(MemObjID, (uintptr_t)(Ptr), Size, 0 /* guard zone */, CorrID); }}; #endif if (Size) - Plugin->call(Ctx, Flags, Size, Props, - RetMem); + Adapter->call(Ctx, Flags, Size, Props, + RetMem); } } -void memReleaseHelper(const PluginPtr &Plugin, ur_mem_handle_t Mem) { +void memReleaseHelper(const AdapterPtr &Adapter, ur_mem_handle_t Mem) { // FIXME urMemRelease does not guarante memory release. It is only true if // reference counter is 1. However, SYCL runtime currently only calls // urMemRetain only for OpenCL interop @@ -182,8 +182,8 @@ void memReleaseHelper(const PluginPtr &Plugin, ur_mem_handle_t Mem) { // When doing buffer interop we don't know what device the memory should be // resident on, so pass nullptr for Device param. Buffer interop may not be // supported by all backends. - Plugin->call_nocheck(Mem, /*Dev*/ nullptr, - &PtrHandle); + Adapter->call_nocheck(Mem, /*Dev*/ nullptr, + &PtrHandle); Ptr = (uintptr_t)(PtrHandle); } #endif @@ -194,11 +194,11 @@ void memReleaseHelper(const PluginPtr &Plugin, ur_mem_handle_t Mem) { xpti::utils::finally _{ [&] { emitMemReleaseEndTrace(MemObjID, Ptr, CorrID); }}; #endif - Plugin->call(Mem); + Adapter->call(Mem); } } -void memBufferMapHelper(const PluginPtr &Plugin, ur_queue_handle_t Queue, +void memBufferMapHelper(const AdapterPtr &Adapter, ur_queue_handle_t Queue, ur_mem_handle_t Buffer, bool Blocking, ur_map_flags_t Flags, size_t Offset, size_t Size, uint32_t NumEvents, const ur_event_handle_t *WaitList, @@ -216,12 +216,12 @@ void memBufferMapHelper(const PluginPtr &Plugin, ur_queue_handle_t Queue, 0 /* guard zone */, CorrID); }}; #endif - Plugin->call(Queue, Buffer, Blocking, Flags, - Offset, Size, NumEvents, - WaitList, Event, RetMap); + Adapter->call( + Queue, Buffer, Blocking, Flags, Offset, Size, NumEvents, WaitList, Event, + RetMap); } -void memUnmapHelper(const PluginPtr &Plugin, ur_queue_handle_t Queue, +void memUnmapHelper(const AdapterPtr &Adapter, ur_queue_handle_t Queue, ur_mem_handle_t Mem, void *MappedPtr, uint32_t NumEvents, const ur_event_handle_t *WaitList, ur_event_handle_t *Event) { @@ -241,12 +241,12 @@ void memUnmapHelper(const PluginPtr &Plugin, ur_queue_handle_t Queue, // Always use call_nocheck here, because call may throw an exception, // and this lambda will be called from destructor, which in combination // rewards us with UB. - Plugin->call_nocheck(1, Event); + Adapter->call_nocheck(1, Event); emitMemReleaseEndTrace(MemObjID, Ptr, CorrID); }}; #endif - Plugin->call(Queue, Mem, MappedPtr, NumEvents, - WaitList, Event); + Adapter->call(Queue, Mem, MappedPtr, + NumEvents, WaitList, Event); } } @@ -275,8 +275,8 @@ void MemoryManager::releaseMemObj(ContextImplPtr TargetContext, return; } - const PluginPtr &Plugin = TargetContext->getPlugin(); - memReleaseHelper(Plugin, ur::cast(MemAllocation)); + const AdapterPtr &Adapter = TargetContext->getAdapter(); + memReleaseHelper(Adapter, ur::cast(MemAllocation)); } void *MemoryManager::allocate(ContextImplPtr TargetContext, SYCLMemObjI *MemObj, @@ -318,8 +318,8 @@ void *MemoryManager::allocateInteropMemObject( // Retain the event since it will be released during alloca command // destruction if (nullptr != OutEventToWait) { - const PluginPtr &Plugin = InteropEvent->getPlugin(); - Plugin->call(OutEventToWait); + const AdapterPtr &Adapter = InteropEvent->getAdapter(); + Adapter->call(OutEventToWait); } return UserPtr; } @@ -343,10 +343,10 @@ void *MemoryManager::allocateImageObject(ContextImplPtr TargetContext, getMemObjCreationFlags(UserPtr, HostPtrReadOnly); ur_mem_handle_t NewMem = nullptr; - const PluginPtr &Plugin = TargetContext->getPlugin(); - Plugin->call(TargetContext->getHandleRef(), - CreationFlags, &Format, &Desc, - UserPtr, &NewMem); + const AdapterPtr &Adapter = TargetContext->getAdapter(); + Adapter->call(TargetContext->getHandleRef(), + CreationFlags, &Format, &Desc, + UserPtr, &NewMem); return NewMem; } @@ -361,7 +361,7 @@ MemoryManager::allocateBufferObject(ContextImplPtr TargetContext, void *UserPtr, CreationFlags |= UR_MEM_FLAG_ALLOC_HOST_POINTER; ur_mem_handle_t NewMem = nullptr; - const PluginPtr &Plugin = TargetContext->getPlugin(); + const AdapterPtr &Adapter = TargetContext->getAdapter(); ur_buffer_properties_t AllocProps = {UR_STRUCTURE_TYPE_BUFFER_PROPERTIES, nullptr, UserPtr}; @@ -386,7 +386,7 @@ MemoryManager::allocateBufferObject(ContextImplPtr TargetContext, void *UserPtr, *Next = &ChannelProperties; } - memBufferCreateHelper(Plugin, TargetContext->getHandleRef(), CreationFlags, + memBufferCreateHelper(Adapter, TargetContext->getHandleRef(), CreationFlags, Size, &NewMem, &AllocProps); return NewMem; } @@ -448,8 +448,8 @@ void *MemoryManager::allocateMemSubBuffer(ContextImplPtr TargetContext, ur_buffer_region_t Region = {UR_STRUCTURE_TYPE_BUFFER_REGION, nullptr, Offset, SizeInBytes}; ur_mem_handle_t NewMem; - const PluginPtr &Plugin = TargetContext->getPlugin(); - Error = Plugin->call_nocheck( + const AdapterPtr &Adapter = TargetContext->getAdapter(); + Error = Adapter->call_nocheck( ur::cast(ParentMemObj), UR_MEM_FLAG_READ_WRITE, UR_BUFFER_CREATE_TYPE_REGION, &Region, &NewMem); if (Error == UR_RESULT_ERROR_MISALIGNED_SUB_BUFFER_OFFSET) @@ -459,7 +459,7 @@ void *MemoryManager::allocateMemSubBuffer(ContextImplPtr TargetContext, "a multiple of the memory base address alignment"), Error); - Plugin->checkUrResult(Error); + Adapter->checkUrResult(Error); return NewMem; } @@ -508,7 +508,7 @@ void copyH2D(SYCLMemObjI *SYCLMemObj, char *SrcMem, QueueImplPtr, assert(TgtQueue && "Destination mem object queue must be not nullptr"); const ur_queue_handle_t Queue = TgtQueue->getHandleRef(); - const PluginPtr &Plugin = TgtQueue->getPlugin(); + const AdapterPtr &Adapter = TgtQueue->getAdapter(); detail::SYCLMemObjI::MemObjType MemType = SYCLMemObj->getType(); TermPositions SrcPos, DstPos; @@ -525,7 +525,7 @@ void copyH2D(SYCLMemObjI *SYCLMemObj, char *SrcMem, QueueImplPtr, if (1 == DimDst && 1 == DimSrc) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call( + Adapter->call( Queue, DstMem, /*blocking_write=*/false, DstXOffBytes, DstAccessRangeWidthBytes, SrcMem + SrcXOffBytes, DepEvents.size(), DepEvents.data(), &OutEvent); @@ -546,7 +546,7 @@ void copyH2D(SYCLMemObjI *SYCLMemObj, char *SrcMem, QueueImplPtr, DstAccessRange[DstPos.ZTerm]}; if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call( + Adapter->call( Queue, DstMem, /*blocking_write=*/false, BufferOffset, HostOffset, RectRegion, BufferRowPitch, BufferSlicePitch, HostRowPitch, HostSlicePitch, @@ -564,7 +564,7 @@ void copyH2D(SYCLMemObjI *SYCLMemObj, char *SrcMem, QueueImplPtr, DstAccessRange[DstPos.ZTerm]}; if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call( + Adapter->call( Queue, DstMem, /*blocking_write=*/false, Origin, Region, InputRowPitch, InputSlicePitch, SrcMem, DepEvents.size(), DepEvents.data(), &OutEvent); @@ -585,7 +585,7 @@ void copyD2H(SYCLMemObjI *SYCLMemObj, ur_mem_handle_t SrcMem, assert(SrcQueue && "Source mem object queue is expected to be not nullptr"); const ur_queue_handle_t Queue = SrcQueue->getHandleRef(); - const PluginPtr &Plugin = SrcQueue->getPlugin(); + const AdapterPtr &Adapter = SrcQueue->getAdapter(); detail::SYCLMemObjI::MemObjType MemType = SYCLMemObj->getType(); TermPositions SrcPos, DstPos; @@ -608,7 +608,7 @@ void copyD2H(SYCLMemObjI *SYCLMemObj, ur_mem_handle_t SrcMem, if (1 == DimDst && 1 == DimSrc) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call( + Adapter->call( Queue, SrcMem, /*blocking_read=*/false, SrcXOffBytes, SrcAccessRangeWidthBytes, DstMem + DstXOffBytes, DepEvents.size(), DepEvents.data(), &OutEvent); @@ -629,7 +629,7 @@ void copyD2H(SYCLMemObjI *SYCLMemObj, ur_mem_handle_t SrcMem, SrcAccessRange[SrcPos.ZTerm]}; if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call( + Adapter->call( Queue, SrcMem, /*blocking_read=*/false, BufferOffset, HostOffset, RectRegion, BufferRowPitch, BufferSlicePitch, HostRowPitch, HostSlicePitch, @@ -647,7 +647,7 @@ void copyD2H(SYCLMemObjI *SYCLMemObj, ur_mem_handle_t SrcMem, SrcAccessRange[SrcPos.ZTerm]}; if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call( + Adapter->call( Queue, SrcMem, false, Offset, Region, RowPitch, SlicePitch, DstMem, DepEvents.size(), DepEvents.data(), &OutEvent); } @@ -667,7 +667,7 @@ void copyD2D(SYCLMemObjI *SYCLMemObj, ur_mem_handle_t SrcMem, "expected to be not nullptr"); const ur_queue_handle_t Queue = SrcQueue->getHandleRef(); - const PluginPtr &Plugin = SrcQueue->getPlugin(); + const AdapterPtr &Adapter = SrcQueue->getAdapter(); detail::SYCLMemObjI::MemObjType MemType = SYCLMemObj->getType(); TermPositions SrcPos, DstPos; @@ -684,7 +684,7 @@ void copyD2D(SYCLMemObjI *SYCLMemObj, ur_mem_handle_t SrcMem, if (1 == DimDst && 1 == DimSrc) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call( + Adapter->call( Queue, SrcMem, DstMem, SrcXOffBytes, DstXOffBytes, SrcAccessRangeWidthBytes, DepEvents.size(), DepEvents.data(), &OutEvent); @@ -710,7 +710,7 @@ void copyD2D(SYCLMemObjI *SYCLMemObj, ur_mem_handle_t SrcMem, SrcAccessRange[SrcPos.ZTerm]}; if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call( + Adapter->call( Queue, SrcMem, DstMem, SrcOrigin, DstOrigin, Region, SrcRowPitch, SrcSlicePitch, DstRowPitch, DstSlicePitch, DepEvents.size(), DepEvents.data(), &OutEvent); @@ -725,7 +725,7 @@ void copyD2D(SYCLMemObjI *SYCLMemObj, ur_mem_handle_t SrcMem, SrcAccessRange[SrcPos.ZTerm]}; if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call( + Adapter->call( Queue, SrcMem, DstMem, SrcOrigin, DstOrigin, Region, DepEvents.size(), DepEvents.data(), &OutEvent); } @@ -807,7 +807,7 @@ void MemoryManager::fill(SYCLMemObjI *SYCLMemObj, void *Mem, QueueImplPtr Queue, assert(SYCLMemObj && "The SYCLMemObj is nullptr"); assert(Queue && "Fill should be called only with a valid device queue"); - const PluginPtr &Plugin = Queue->getPlugin(); + const AdapterPtr &Adapter = Queue->getAdapter(); if (SYCLMemObj->getType() == detail::SYCLMemObjI::MemObjType::Buffer) { if (OutEventImpl != nullptr) @@ -822,7 +822,7 @@ void MemoryManager::fill(SYCLMemObjI *SYCLMemObj, void *Mem, QueueImplPtr Queue, size_t RangeMultiplier = AccRange[0] * AccRange[1] * AccRange[2]; if (RangesUsable && OffsetUsable) { - Plugin->call( + Adapter->call( Queue->getHandleRef(), ur::cast(Mem), Pattern, PatternSize, Offset[0] * ElementSize, RangeMultiplier * ElementSize, DepEvents.size(), DepEvents.data(), &OutEvent); @@ -881,8 +881,8 @@ void *MemoryManager::map(SYCLMemObjI *, void *Mem, QueueImplPtr Queue, void *MappedPtr = nullptr; const size_t BytesToMap = AccessRange[0] * AccessRange[1] * AccessRange[2]; - const PluginPtr &Plugin = Queue->getPlugin(); - memBufferMapHelper(Plugin, Queue->getHandleRef(), + const AdapterPtr &Adapter = Queue->getAdapter(); + memBufferMapHelper(Adapter, Queue->getHandleRef(), ur::cast(Mem), false, Flags, AccessOffset[0], BytesToMap, DepEvents.size(), DepEvents.data(), &OutEvent, &MappedPtr); @@ -900,10 +900,10 @@ void MemoryManager::unmap(SYCLMemObjI *, void *Mem, QueueImplPtr Queue, "Not supported configuration of unmap requested"); } // All DepEvents are to the same Context. - // Using the plugin of the Queue. + // Using the adapter of the Queue. - const PluginPtr &Plugin = Queue->getPlugin(); - memUnmapHelper(Plugin, Queue->getHandleRef(), ur::cast(Mem), + const AdapterPtr &Adapter = Queue->getAdapter(); + memUnmapHelper(Adapter, Queue->getHandleRef(), ur::cast(Mem), MappedPtr, DepEvents.size(), DepEvents.data(), &OutEvent); } @@ -917,7 +917,7 @@ void MemoryManager::copy_usm(const void *SrcMem, QueueImplPtr SrcQueue, if (!DepEvents.empty()) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - SrcQueue->getPlugin()->call( + SrcQueue->getAdapter()->call( SrcQueue->getHandleRef(), DepEvents.size(), DepEvents.data(), OutEvent); } @@ -928,13 +928,13 @@ void MemoryManager::copy_usm(const void *SrcMem, QueueImplPtr SrcQueue, throw exception(make_error_code(errc::invalid), "NULL pointer argument in memory copy operation."); - const PluginPtr &Plugin = SrcQueue->getPlugin(); + const AdapterPtr &Adapter = SrcQueue->getAdapter(); if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call(SrcQueue->getHandleRef(), - /* blocking */ false, DstMem, - SrcMem, Len, DepEvents.size(), - DepEvents.data(), OutEvent); + Adapter->call(SrcQueue->getHandleRef(), + /* blocking */ false, DstMem, + SrcMem, Len, DepEvents.size(), + DepEvents.data(), OutEvent); } void MemoryManager::fill_usm(void *Mem, QueueImplPtr Queue, size_t Length, @@ -947,7 +947,7 @@ void MemoryManager::fill_usm(void *Mem, QueueImplPtr Queue, size_t Length, if (!DepEvents.empty()) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Queue->getPlugin()->call( + Queue->getAdapter()->call( Queue->getHandleRef(), DepEvents.size(), DepEvents.data(), OutEvent); } return; @@ -958,8 +958,8 @@ void MemoryManager::fill_usm(void *Mem, QueueImplPtr Queue, size_t Length, "NULL pointer argument in memory fill operation."); if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - const PluginPtr &Plugin = Queue->getPlugin(); - Plugin->call( + const AdapterPtr &Adapter = Queue->getAdapter(); + Adapter->call( Queue->getHandleRef(), Mem, Pattern.size(), Pattern.data(), Length, DepEvents.size(), DepEvents.data(), OutEvent); } @@ -969,12 +969,12 @@ void MemoryManager::prefetch_usm(void *Mem, QueueImplPtr Queue, size_t Length, ur_event_handle_t *OutEvent, const detail::EventImplPtr &OutEventImpl) { assert(Queue && "USM prefetch must be called with a valid device queue"); - const PluginPtr &Plugin = Queue->getPlugin(); + const AdapterPtr &Adapter = Queue->getAdapter(); if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call(Queue->getHandleRef(), Mem, - Length, 0, DepEvents.size(), - DepEvents.data(), OutEvent); + Adapter->call(Queue->getHandleRef(), Mem, + Length, 0, DepEvents.size(), + DepEvents.data(), OutEvent); } void MemoryManager::advise_usm(const void *Mem, QueueImplPtr Queue, @@ -983,11 +983,11 @@ void MemoryManager::advise_usm(const void *Mem, QueueImplPtr Queue, ur_event_handle_t *OutEvent, const detail::EventImplPtr &OutEventImpl) { assert(Queue && "USM advise must be called with a valid device queue"); - const PluginPtr &Plugin = Queue->getPlugin(); + const AdapterPtr &Adapter = Queue->getAdapter(); if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call(Queue->getHandleRef(), Mem, - Length, Advice, OutEvent); + Adapter->call(Queue->getHandleRef(), Mem, + Length, Advice, OutEvent); } void MemoryManager::copy_2d_usm(const void *SrcMem, size_t SrcPitch, @@ -1002,7 +1002,7 @@ void MemoryManager::copy_2d_usm(const void *SrcMem, size_t SrcPitch, if (!DepEvents.empty()) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Queue->getPlugin()->call( + Queue->getAdapter()->call( Queue->getHandleRef(), DepEvents.size(), DepEvents.data(), OutEvent); } return; @@ -1012,10 +1012,10 @@ void MemoryManager::copy_2d_usm(const void *SrcMem, size_t SrcPitch, throw sycl::exception(sycl::make_error_code(errc::invalid), "NULL pointer argument in 2D memory copy operation."); - const PluginPtr &Plugin = Queue->getPlugin(); + const AdapterPtr &Adapter = Queue->getAdapter(); bool SupportsUSMMemcpy2D = false; - Plugin->call( + Adapter->call( Queue->getContextImplPtr()->getHandleRef(), UR_CONTEXT_INFO_USM_MEMCPY2D_SUPPORT, sizeof(bool), &SupportsUSMMemcpy2D, nullptr); @@ -1024,7 +1024,7 @@ void MemoryManager::copy_2d_usm(const void *SrcMem, size_t SrcPitch, if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); // Direct memcpy2D is supported so we use this function. - Plugin->call( + Adapter->call( Queue->getHandleRef(), /*blocking=*/false, DstMem, DstPitch, SrcMem, SrcPitch, Width, Height, DepEvents.size(), DepEvents.data(), OutEvent); @@ -1055,17 +1055,17 @@ void MemoryManager::copy_2d_usm(const void *SrcMem, size_t SrcPitch, for (size_t I = 0; I < Height; ++I) { char *DstItBegin = static_cast(DstMem) + I * DstPitch; const char *SrcItBegin = static_cast(SrcMem) + I * SrcPitch; - Plugin->call( + Adapter->call( Queue->getHandleRef(), /* blocking */ false, DstItBegin, SrcItBegin, Width, DepEvents.size(), DepEvents.data(), CopyEvents.data() + I); - CopyEventsManaged.emplace_back(CopyEvents[I], Plugin, + CopyEventsManaged.emplace_back(CopyEvents[I], Adapter, /*TakeOwnership=*/true); } if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); // Then insert a wait to coalesce the copy events. - Queue->getPlugin()->call( + Queue->getAdapter()->call( Queue->getHandleRef(), CopyEvents.size(), CopyEvents.data(), OutEvent); } @@ -1081,7 +1081,7 @@ void MemoryManager::fill_2d_usm(void *DstMem, QueueImplPtr Queue, size_t Pitch, if (!DepEvents.empty()) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Queue->getPlugin()->call( + Queue->getAdapter()->call( Queue->getHandleRef(), DepEvents.size(), DepEvents.data(), OutEvent); } return; @@ -1092,8 +1092,8 @@ void MemoryManager::fill_2d_usm(void *DstMem, QueueImplPtr Queue, size_t Pitch, "NULL pointer argument in 2D memory fill operation."); if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - const PluginPtr &Plugin = Queue->getPlugin(); - Plugin->call( + const AdapterPtr &Adapter = Queue->getAdapter(); + Adapter->call( Queue->getHandleRef(), DstMem, Pitch, Pattern.size(), Pattern.data(), Width, Height, DepEvents.size(), DepEvents.data(), OutEvent); } @@ -1110,7 +1110,7 @@ void MemoryManager::memset_2d_usm(void *DstMem, QueueImplPtr Queue, if (!DepEvents.empty()) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Queue->getPlugin()->call( + Queue->getAdapter()->call( Queue->getHandleRef(), DepEvents.size(), DepEvents.data(), OutEvent); } return; @@ -1141,7 +1141,7 @@ static void memcpyToDeviceGlobalUSM( // OwnedPiEvent will keep the initialization event alive for the duration // of this function call. - OwnedUrEvent ZIEvent = DeviceGlobalUSM.getInitEvent(Queue->getPlugin()); + OwnedUrEvent ZIEvent = DeviceGlobalUSM.getInitEvent(Queue->getAdapter()); // We may need addtional events, so create a non-const dependency events list // to use if we need to modify it. @@ -1176,7 +1176,7 @@ static void memcpyFromDeviceGlobalUSM( // OwnedPiEvent will keep the initialization event alive for the duration // of this function call. - OwnedUrEvent ZIEvent = DeviceGlobalUSM.getInitEvent(Queue->getPlugin()); + OwnedUrEvent ZIEvent = DeviceGlobalUSM.getInitEvent(Queue->getAdapter()); // We may need addtional events, so create a non-const dependency events list // to use if we need to modify it. @@ -1242,8 +1242,8 @@ memcpyToDeviceGlobalDirect(QueueImplPtr Queue, "Direct copy to device global must be called with a valid device queue"); ur_program_handle_t Program = getOrBuildProgramForDeviceGlobal(Queue, DeviceGlobalEntry); - const PluginPtr &Plugin = Queue->getPlugin(); - Plugin->call( + const AdapterPtr &Adapter = Queue->getAdapter(); + Adapter->call( Queue->getHandleRef(), Program, DeviceGlobalEntry->MUniqueId.c_str(), false, NumBytes, Offset, Src, DepEvents.size(), DepEvents.data(), OutEvent); @@ -1259,8 +1259,8 @@ memcpyFromDeviceGlobalDirect(QueueImplPtr Queue, "device queue"); ur_program_handle_t Program = getOrBuildProgramForDeviceGlobal(Queue, DeviceGlobalEntry); - const PluginPtr &Plugin = Queue->getPlugin(); - Plugin->call( + const AdapterPtr &Adapter = Queue->getAdapter(); + Adapter->call( Queue->getHandleRef(), Program, DeviceGlobalEntry->MUniqueId.c_str(), false, NumBytes, Offset, Dest, DepEvents.size(), DepEvents.data(), OutEvent); @@ -1324,7 +1324,7 @@ void MemoryManager::ext_oneapi_copyD2D_cmd_buffer( assert(SYCLMemObj && "The SYCLMemObj is nullptr"); (void)DstAccessRange; - const PluginPtr &Plugin = Context->getPlugin(); + const AdapterPtr &Adapter = Context->getAdapter(); detail::SYCLMemObjI::MemObjType MemType = SYCLMemObj->getType(); TermPositions SrcPos, DstPos; @@ -1343,7 +1343,7 @@ void MemoryManager::ext_oneapi_copyD2D_cmd_buffer( } if (1 == DimDst && 1 == DimSrc) { - Plugin->call( + Adapter->call( CommandBuffer, sycl::detail::ur::cast(SrcMem), sycl::detail::ur::cast(DstMem), SrcXOffBytes, DstXOffBytes, SrcAccessRangeWidthBytes, Deps.size(), Deps.data(), @@ -1369,7 +1369,7 @@ void MemoryManager::ext_oneapi_copyD2D_cmd_buffer( SrcAccessRange[SrcPos.YTerm], SrcAccessRange[SrcPos.ZTerm]}; - Plugin->call( + Adapter->call( CommandBuffer, sycl::detail::ur::cast(SrcMem), sycl::detail::ur::cast(DstMem), SrcOrigin, DstOrigin, Region, SrcRowPitch, SrcSlicePitch, DstRowPitch, DstSlicePitch, @@ -1388,7 +1388,7 @@ void MemoryManager::ext_oneapi_copyD2H_cmd_buffer( ur_exp_command_buffer_sync_point_t *OutSyncPoint) { assert(SYCLMemObj && "The SYCLMemObj is nullptr"); - const PluginPtr &Plugin = Context->getPlugin(); + const AdapterPtr &Adapter = Context->getAdapter(); detail::SYCLMemObjI::MemObjType MemType = SYCLMemObj->getType(); TermPositions SrcPos, DstPos; @@ -1408,7 +1408,7 @@ void MemoryManager::ext_oneapi_copyD2H_cmd_buffer( if (1 == DimDst && 1 == DimSrc) { ur_result_t Result = - Plugin->call_nocheck( + Adapter->call_nocheck( CommandBuffer, sycl::detail::ur::cast(SrcMem), SrcXOffBytes, SrcAccessRangeWidthBytes, DstMem + DstXOffBytes, Deps.size(), Deps.data(), OutSyncPoint); @@ -1418,7 +1418,7 @@ void MemoryManager::ext_oneapi_copyD2H_cmd_buffer( sycl::make_error_code(sycl::errc::feature_not_supported), "Device-to-host buffer copy command not supported by graph backend"); } else { - Plugin->checkUrResult(Result); + Adapter->checkUrResult(Result); } } else { size_t BufferRowPitch = (1 == DimSrc) ? 0 : SrcSzWidthBytes; @@ -1436,7 +1436,7 @@ void MemoryManager::ext_oneapi_copyD2H_cmd_buffer( SrcAccessRange[SrcPos.YTerm], SrcAccessRange[SrcPos.ZTerm]}; - ur_result_t Result = Plugin->call_nocheck< + ur_result_t Result = Adapter->call_nocheck< UrApiKind::urCommandBufferAppendMemBufferReadRectExp>( CommandBuffer, sycl::detail::ur::cast(SrcMem), BufferOffset, HostOffset, RectRegion, BufferRowPitch, BufferSlicePitch, @@ -1447,7 +1447,7 @@ void MemoryManager::ext_oneapi_copyD2H_cmd_buffer( sycl::make_error_code(sycl::errc::feature_not_supported), "Device-to-host buffer copy command not supported by graph backend"); } else { - Plugin->checkUrResult(Result); + Adapter->checkUrResult(Result); } } } @@ -1463,7 +1463,7 @@ void MemoryManager::ext_oneapi_copyH2D_cmd_buffer( ur_exp_command_buffer_sync_point_t *OutSyncPoint) { assert(SYCLMemObj && "The SYCLMemObj is nullptr"); - const PluginPtr &Plugin = Context->getPlugin(); + const AdapterPtr &Adapter = Context->getAdapter(); detail::SYCLMemObjI::MemObjType MemType = SYCLMemObj->getType(); TermPositions SrcPos, DstPos; @@ -1483,17 +1483,18 @@ void MemoryManager::ext_oneapi_copyH2D_cmd_buffer( if (1 == DimDst && 1 == DimSrc) { ur_result_t Result = - Plugin->call_nocheck( - CommandBuffer, sycl::detail::ur::cast(DstMem), - DstXOffBytes, DstAccessRangeWidthBytes, SrcMem + SrcXOffBytes, - Deps.size(), Deps.data(), OutSyncPoint); + Adapter + ->call_nocheck( + CommandBuffer, sycl::detail::ur::cast(DstMem), + DstXOffBytes, DstAccessRangeWidthBytes, SrcMem + SrcXOffBytes, + Deps.size(), Deps.data(), OutSyncPoint); if (Result == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { throw sycl::exception( sycl::make_error_code(sycl::errc::feature_not_supported), "Host-to-device buffer copy command not supported by graph backend"); } else { - Plugin->checkUrResult(Result); + Adapter->checkUrResult(Result); } } else { size_t BufferRowPitch = (1 == DimDst) ? 0 : DstSzWidthBytes; @@ -1511,7 +1512,7 @@ void MemoryManager::ext_oneapi_copyH2D_cmd_buffer( DstAccessRange[DstPos.YTerm], DstAccessRange[DstPos.ZTerm]}; - ur_result_t Result = Plugin->call_nocheck< + ur_result_t Result = Adapter->call_nocheck< UrApiKind::urCommandBufferAppendMemBufferWriteRectExp>( CommandBuffer, sycl::detail::ur::cast(DstMem), BufferOffset, HostOffset, RectRegion, BufferRowPitch, BufferSlicePitch, @@ -1523,7 +1524,7 @@ void MemoryManager::ext_oneapi_copyH2D_cmd_buffer( sycl::make_error_code(sycl::errc::feature_not_supported), "Host-to-device buffer copy command not supported by graph backend"); } else { - Plugin->checkUrResult(Result); + Adapter->checkUrResult(Result); } } } @@ -1537,9 +1538,9 @@ void MemoryManager::ext_oneapi_copy_usm_cmd_buffer( throw exception(make_error_code(errc::invalid), "NULL pointer argument in memory copy operation."); - const PluginPtr &Plugin = Context->getPlugin(); + const AdapterPtr &Adapter = Context->getAdapter(); ur_result_t Result = - Plugin->call_nocheck( + Adapter->call_nocheck( CommandBuffer, DstMem, SrcMem, Len, Deps.size(), Deps.data(), OutSyncPoint); if (Result == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { @@ -1547,7 +1548,7 @@ void MemoryManager::ext_oneapi_copy_usm_cmd_buffer( sycl::make_error_code(sycl::errc::feature_not_supported), "USM copy command not supported by graph backend"); } else { - Plugin->checkUrResult(Result); + Adapter->checkUrResult(Result); } } @@ -1562,8 +1563,8 @@ void MemoryManager::ext_oneapi_fill_usm_cmd_buffer( throw exception(make_error_code(errc::invalid), "NULL pointer argument in memory fill operation."); - const PluginPtr &Plugin = Context->getPlugin(); - Plugin->call( + const AdapterPtr &Adapter = Context->getAdapter(); + Adapter->call( CommandBuffer, DstMem, Pattern.data(), Pattern.size(), Len, Deps.size(), Deps.data(), OutSyncPoint); } @@ -1578,7 +1579,7 @@ void MemoryManager::ext_oneapi_fill_cmd_buffer( ur_exp_command_buffer_sync_point_t *OutSyncPoint) { assert(SYCLMemObj && "The SYCLMemObj is nullptr"); - const PluginPtr &Plugin = Context->getPlugin(); + const AdapterPtr &Adapter = Context->getAdapter(); if (SYCLMemObj->getType() != detail::SYCLMemObjI::MemObjType::Buffer) { throw sycl::exception(sycl::make_error_code(sycl::errc::invalid), "Images are not supported in Graphs"); @@ -1593,7 +1594,7 @@ void MemoryManager::ext_oneapi_fill_cmd_buffer( size_t RangeMultiplier = AccessRange[0] * AccessRange[1] * AccessRange[2]; if (RangesUsable && OffsetUsable) { - Plugin->call( + Adapter->call( CommandBuffer, ur::cast(Mem), Pattern, PatternSize, AccessOffset[0] * ElementSize, RangeMultiplier * ElementSize, Deps.size(), Deps.data(), OutSyncPoint); @@ -1610,8 +1611,8 @@ void MemoryManager::ext_oneapi_prefetch_usm_cmd_buffer( ur_exp_command_buffer_handle_t CommandBuffer, void *Mem, size_t Length, std::vector Deps, ur_exp_command_buffer_sync_point_t *OutSyncPoint) { - const PluginPtr &Plugin = Context->getPlugin(); - Plugin->call( + const AdapterPtr &Adapter = Context->getAdapter(); + Adapter->call( CommandBuffer, Mem, Length, ur_usm_migration_flags_t(0), Deps.size(), Deps.data(), OutSyncPoint); } @@ -1622,8 +1623,8 @@ void MemoryManager::ext_oneapi_advise_usm_cmd_buffer( size_t Length, ur_usm_advice_flags_t Advice, std::vector Deps, ur_exp_command_buffer_sync_point_t *OutSyncPoint) { - const PluginPtr &Plugin = Context->getPlugin(); - Plugin->call( + const AdapterPtr &Adapter = Context->getAdapter(); + Adapter->call( CommandBuffer, Mem, Length, Advice, Deps.size(), Deps.data(), OutSyncPoint); } @@ -1647,7 +1648,7 @@ void MemoryManager::copy_image_bindless( sycl::make_error_code(errc::invalid), "NULL pointer argument in bindless image copy operation."); - const detail::PluginPtr &Plugin = Queue->getPlugin(); + const detail::AdapterPtr &Adapter = Queue->getAdapter(); ur_exp_image_copy_region_t CopyRegion{}; CopyRegion.stype = UR_STRUCTURE_TYPE_EXP_IMAGE_COPY_REGION; @@ -1655,7 +1656,7 @@ void MemoryManager::copy_image_bindless( CopyRegion.srcOffset = SrcOffset; CopyRegion.dstOffset = DstOffset; - Plugin->call( + Adapter->call( Queue->getHandleRef(), Src, Dst, &SrcDesc, &DstDesc, &SrcFormat, &DstFormat, &CopyRegion, Flags, DepEvents.size(), DepEvents.data(), OutEvent); diff --git a/sycl/source/detail/persistent_device_code_cache.cpp b/sycl/source/detail/persistent_device_code_cache.cpp index 7484ed00150e2..0023b47c80174 100644 --- a/sycl/source/detail/persistent_device_code_cache.cpp +++ b/sycl/source/detail/persistent_device_code_cache.cpp @@ -6,9 +6,9 @@ // //===----------------------------------------------------------------------===// +#include #include #include -#include #include #include @@ -127,16 +127,16 @@ void PersistentDeviceCodeCache::putItemToDisc( if (DirName.empty()) return; - auto Plugin = detail::getSyclObjImpl(Device)->getPlugin(); + auto Adapter = detail::getSyclObjImpl(Device)->getAdapter(); unsigned int DeviceNum = 0; - Plugin->call( + Adapter->call( NativePrg, UR_PROGRAM_INFO_NUM_DEVICES, sizeof(DeviceNum), &DeviceNum, nullptr); std::vector BinarySizes(DeviceNum); - Plugin->call( + Adapter->call( NativePrg, UR_PROGRAM_INFO_BINARY_SIZES, sizeof(size_t) * BinarySizes.size(), BinarySizes.data(), nullptr); @@ -147,9 +147,9 @@ void PersistentDeviceCodeCache::putItemToDisc( Pointers.push_back(Result[I].data()); } - Plugin->call(NativePrg, UR_PROGRAM_INFO_BINARIES, - sizeof(char *) * Pointers.size(), - Pointers.data(), nullptr); + Adapter->call( + NativePrg, UR_PROGRAM_INFO_BINARIES, sizeof(char *) * Pointers.size(), + Pointers.data(), nullptr); size_t i = 0; std::string FileName; do { diff --git a/sycl/source/detail/physical_mem_impl.hpp b/sycl/source/detail/physical_mem_impl.hpp index e31b5c36bfab8..a648a5596d4ee 100644 --- a/sycl/source/detail/physical_mem_impl.hpp +++ b/sycl/source/detail/physical_mem_impl.hpp @@ -41,9 +41,9 @@ class physical_mem_impl { size_t NumBytes) : MDevice(getSyclObjImpl(SyclDevice)), MContext(getSyclObjImpl(SyclContext)), MNumBytes(NumBytes) { - const PluginPtr &Plugin = MContext->getPlugin(); + const AdapterPtr &Adapter = MContext->getAdapter(); - auto Err = Plugin->call_nocheck( + auto Err = Adapter->call_nocheck( MContext->getHandleRef(), MDevice->getHandleRef(), MNumBytes, nullptr, &MPhysicalMem); @@ -51,23 +51,23 @@ class physical_mem_impl { Err == UR_RESULT_ERROR_OUT_OF_HOST_MEMORY) throw sycl::exception(make_error_code(errc::memory_allocation), "Failed to allocate physical memory."); - Plugin->checkUrResult(Err); + Adapter->checkUrResult(Err); } ~physical_mem_impl() noexcept(false) { - const PluginPtr &Plugin = MContext->getPlugin(); - Plugin->call(MPhysicalMem); + const AdapterPtr &Adapter = MContext->getAdapter(); + Adapter->call(MPhysicalMem); } void *map(uintptr_t Ptr, size_t NumBytes, ext::oneapi::experimental::address_access_mode Mode, size_t Offset) const { auto AccessFlags = AccessModeToVirtualAccessFlags(Mode); - const PluginPtr &Plugin = MContext->getPlugin(); + const AdapterPtr &Adapter = MContext->getAdapter(); void *ResultPtr = reinterpret_cast(Ptr); - Plugin->call(MContext->getHandleRef(), - ResultPtr, NumBytes, MPhysicalMem, - Offset, AccessFlags); + Adapter->call(MContext->getHandleRef(), + ResultPtr, NumBytes, MPhysicalMem, + Offset, AccessFlags); return ResultPtr; } diff --git a/sycl/source/detail/platform_impl.cpp b/sycl/source/detail/platform_impl.cpp index fea1abbf3a01e..652e47a5be997 100644 --- a/sycl/source/detail/platform_impl.cpp +++ b/sycl/source/detail/platform_impl.cpp @@ -35,7 +35,7 @@ using PlatformImplPtr = std::shared_ptr; PlatformImplPtr platform_impl::getOrMakePlatformImpl(ur_platform_handle_t UrPlatform, - const PluginPtr &Plugin) { + const AdapterPtr &Adapter) { PlatformImplPtr Result; { const std::lock_guard Guard( @@ -51,7 +51,7 @@ platform_impl::getOrMakePlatformImpl(ur_platform_handle_t UrPlatform, } // Otherwise make the impl - Result = std::make_shared(UrPlatform, Plugin); + Result = std::make_shared(UrPlatform, Adapter); PlatformCache.emplace_back(Result); } @@ -60,13 +60,13 @@ platform_impl::getOrMakePlatformImpl(ur_platform_handle_t UrPlatform, PlatformImplPtr platform_impl::getPlatformFromUrDevice(ur_device_handle_t UrDevice, - const PluginPtr &Plugin) { + const AdapterPtr &Adapter) { ur_platform_handle_t Plt = nullptr; // TODO catch an exception and put it to list // of asynchronous exceptions - Plugin->call(UrDevice, UR_DEVICE_INFO_PLATFORM, - sizeof(Plt), &Plt, nullptr); - return getOrMakePlatformImpl(Plt, Plugin); + Adapter->call(UrDevice, UR_DEVICE_INFO_PLATFORM, + sizeof(Plt), &Plt, nullptr); + return getOrMakePlatformImpl(Plt, Adapter); } static bool IsBannedPlatform(platform Platform) { @@ -96,15 +96,15 @@ static bool IsBannedPlatform(platform Platform) { IsMatchingOpenCL(Platform, "AMD Accelerated Parallel Processing"); } -// Get the vector of platforms supported by a given UR plugin -// replace uses of this with a helper in plugin object, the plugin +// Get the vector of platforms supported by a given UR adapter +// replace uses of this with a helper in adapter object, the adapter // objects will own the ur adapter handles and they'll need to pass them to // urPlatformsGet - so urPlatformsGet will need to be wrapped with a helper -std::vector platform_impl::getPluginPlatforms(PluginPtr &Plugin, - bool Supported) { +std::vector platform_impl::getAdapterPlatforms(AdapterPtr &Adapter, + bool Supported) { std::vector Platforms; - auto UrPlatforms = Plugin->getUrPlatforms(); + auto UrPlatforms = Adapter->getUrPlatforms(); if (UrPlatforms.empty()) { return Platforms; @@ -112,7 +112,7 @@ std::vector platform_impl::getPluginPlatforms(PluginPtr &Plugin, for (const auto &UrPlatform : UrPlatforms) { platform Platform = detail::createSyclObjFromImpl( - getOrMakePlatformImpl(UrPlatform, Plugin)); + getOrMakePlatformImpl(UrPlatform, Adapter)); const bool IsBanned = IsBannedPlatform(Platform); const bool HasAnyDevices = !Platform.get_devices(info::device_type::all).empty(); @@ -141,15 +141,15 @@ std::vector platform_impl::getPluginPlatforms(PluginPtr &Plugin, std::vector platform_impl::get_unsupported_platforms() { std::vector UnsupportedPlatforms; - std::vector &Plugins = sycl::detail::ur::initializeUr(); + std::vector &Adapters = sycl::detail::ur::initializeUr(); // Ignore UR as it has to be supported. - for (auto &Plugin : Plugins) { - if (Plugin->hasBackend(backend::all)) { + for (auto &Adapter : Adapters) { + if (Adapter->hasBackend(backend::all)) { continue; // skip UR } - std::vector PluginPlatforms = - getPluginPlatforms(Plugin, /*Supported=*/false); - std::copy(PluginPlatforms.begin(), PluginPlatforms.end(), + std::vector AdapterPlatforms = + getAdapterPlatforms(Adapter, /*Supported=*/false); + std::copy(AdapterPlatforms.begin(), AdapterPlatforms.end(), std::back_inserter(UnsupportedPlatforms)); } @@ -157,28 +157,28 @@ std::vector platform_impl::get_unsupported_platforms() { } // This routine has the side effect of registering each platform's last device -// id into each plugin, which is used for device counting. +// id into each adapter, which is used for device counting. std::vector platform_impl::get_platforms() { - // See which platform we want to be served by which plugin. - // There should be just one plugin serving each backend. - std::vector &Plugins = sycl::detail::ur::initializeUr(); - std::vector> PlatformsWithPlugin; + // See which platform we want to be served by which adapter. + // There should be just one adapter serving each backend. + std::vector &Adapters = sycl::detail::ur::initializeUr(); + std::vector> PlatformsWithAdapter; - // Then check backend-specific plugins - for (auto &Plugin : Plugins) { - const auto &PluginPlatforms = getPluginPlatforms(Plugin); - for (const auto &P : PluginPlatforms) { - PlatformsWithPlugin.push_back({P, Plugin}); + // Then check backend-specific adapters + for (auto &Adapter : Adapters) { + const auto &AdapterPlatforms = getAdapterPlatforms(Adapter); + for (const auto &P : AdapterPlatforms) { + PlatformsWithAdapter.push_back({P, Adapter}); } } - // For the selected platforms register them with their plugins + // For the selected platforms register them with their adapters std::vector Platforms; - for (auto &Platform : PlatformsWithPlugin) { - auto &Plugin = Platform.second; - std::lock_guard Guard(*Plugin->getPluginMutex()); - Plugin->getPlatformId(getSyclObjImpl(Platform.first)->getHandleRef()); + for (auto &Platform : PlatformsWithAdapter) { + auto &Adapter = Platform.second; + std::lock_guard Guard(*Adapter->getAdapterMutex()); + Adapter->getPlatformId(getSyclObjImpl(Platform.first)->getHandleRef()); Platforms.push_back(Platform.first); } @@ -227,7 +227,7 @@ platform_impl::filterDeviceFilter(std::vector &UrDevices, // Find out backend of the platform ur_platform_backend_t UrBackend = UR_PLATFORM_BACKEND_UNKNOWN; - MPlugin->call( + MAdapter->call( MPlatform, UR_PLATFORM_INFO_BACKEND, sizeof(ur_platform_backend_t), &UrBackend, nullptr); backend Backend = convertUrBackend(UrBackend); @@ -235,13 +235,13 @@ platform_impl::filterDeviceFilter(std::vector &UrDevices, int InsertIDx = 0; // DeviceIds should be given consecutive numbers across platforms in the same // backend - std::lock_guard Guard(*MPlugin->getPluginMutex()); - int DeviceNum = MPlugin->getStartingDeviceId(MPlatform); + std::lock_guard Guard(*MAdapter->getAdapterMutex()); + int DeviceNum = MAdapter->getStartingDeviceId(MPlatform); for (ur_device_handle_t Device : UrDevices) { ur_device_type_t UrDevType = UR_DEVICE_TYPE_ALL; - MPlugin->call(Device, UR_DEVICE_INFO_TYPE, - sizeof(ur_device_type_t), - &UrDevType, nullptr); + MAdapter->call(Device, UR_DEVICE_INFO_TYPE, + sizeof(ur_device_type_t), + &UrDevType, nullptr); // Assumption here is that there is 1-to-1 mapping between UrDevType and // Sycl device type for GPU, CPU, and ACC. info::device_type DeviceType = info::device_type::all; @@ -300,7 +300,7 @@ platform_impl::filterDeviceFilter(std::vector &UrDevices, // remember the last backend that has gone through this filter function // to assign a unique device id number across platforms that belong to // the same backend. For example, opencl:cpu:0, opencl:acc:1, opencl:gpu:2 - MPlugin->setLastDeviceId(MPlatform, DeviceNum); + MAdapter->setLastDeviceId(MPlatform, DeviceNum); return original_indices; } @@ -491,9 +491,9 @@ platform_impl::get_devices(info::device_type DeviceType) const { } uint32_t NumDevices = 0; - MPlugin->call(MPlatform, UrDeviceType, - 0, // CP info::device_type::all - nullptr, &NumDevices); + MAdapter->call(MPlatform, UrDeviceType, + 0, // CP info::device_type::all + nullptr, &NumDevices); const backend Backend = getBackend(); if (NumDevices == 0) { @@ -501,23 +501,23 @@ platform_impl::get_devices(info::device_type DeviceType) const { // LastDeviceIds[PlatformId] stay 0 that affects next platform devices num // analysis. Doing adjustment by simple copy of last device num from // previous platform. - // Needs non const plugin reference. - std::vector &Plugins = sycl::detail::ur::initializeUr(); - auto It = std::find_if(Plugins.begin(), Plugins.end(), - [&Platform = MPlatform](PluginPtr &Plugin) { - return Plugin->containsUrPlatform(Platform); + // Needs non const adapter reference. + std::vector &Adapters = sycl::detail::ur::initializeUr(); + auto It = std::find_if(Adapters.begin(), Adapters.end(), + [&Platform = MPlatform](AdapterPtr &Adapter) { + return Adapter->containsUrPlatform(Platform); }); - if (It != Plugins.end()) { - PluginPtr &Plugin = *It; - std::lock_guard Guard(*Plugin->getPluginMutex()); - Plugin->adjustLastDeviceId(MPlatform); + if (It != Adapters.end()) { + AdapterPtr &Adapter = *It; + std::lock_guard Guard(*Adapter->getAdapterMutex()); + Adapter->adjustLastDeviceId(MPlatform); } return Res; } std::vector UrDevices(NumDevices); // TODO catch an exception and put it to list of asynchronous exceptions - MPlugin->call( + MAdapter->call( MPlatform, UrDeviceType, // CP info::device_type::all NumDevices, UrDevices.data(), nullptr); @@ -528,7 +528,7 @@ platform_impl::get_devices(info::device_type DeviceType) const { // Filter out devices that are not present in the SYCL_DEVICE_ALLOWLIST if (SYCLConfig::get()) - applyAllowList(UrDevices, MPlatform, MPlugin); + applyAllowList(UrDevices, MPlatform, MAdapter); // The first step is to filter out devices that are not compatible with // ONEAPI_DEVICE_SELECTOR. This is also the mechanism by which top level @@ -541,7 +541,7 @@ platform_impl::get_devices(info::device_type DeviceType) const { // The next step is to inflate the filtered UrDevices into SYCL Device // objects. - PlatformImplPtr PlatformImpl = getOrMakePlatformImpl(MPlatform, MPlugin); + PlatformImplPtr PlatformImpl = getOrMakePlatformImpl(MPlatform, MAdapter); std::transform( UrDevices.begin(), UrDevices.end(), std::back_inserter(Res), [PlatformImpl](const ur_device_handle_t UrDevice) -> device { @@ -552,7 +552,7 @@ platform_impl::get_devices(info::device_type DeviceType) const { // The reference counter for handles, that we used to create sycl objects, is // incremented, so we need to call release here. for (ur_device_handle_t &UrDev : UrDevicesToCleanUp) - MPlugin->call(UrDev); + MAdapter->call(UrDev); // If we aren't using ONEAPI_DEVICE_SELECTOR, then we are done. // and if there are no devices so far, there won't be any need to replace them @@ -568,7 +568,7 @@ platform_impl::get_devices(info::device_type DeviceType) const { bool platform_impl::has_extension(const std::string &ExtensionName) const { std::string AllExtensionNames = get_platform_info_string_impl( - MPlatform, getPlugin(), + MPlatform, getAdapter(), detail::UrInfoCode::value); return (AllExtensionNames.find(ExtensionName) != std::string::npos); } @@ -579,15 +579,15 @@ bool platform_impl::supports_usm() const { } ur_native_handle_t platform_impl::getNative() const { - const auto &Plugin = getPlugin(); + const auto &Adapter = getAdapter(); ur_native_handle_t Handle = 0; - Plugin->call(getHandleRef(), &Handle); + Adapter->call(getHandleRef(), &Handle); return Handle; } template typename Param::return_type platform_impl::get_info() const { - return get_platform_info(this->getHandleRef(), getPlugin()); + return get_platform_info(this->getHandleRef(), getAdapter()); } template <> diff --git a/sycl/source/detail/platform_impl.hpp b/sycl/source/detail/platform_impl.hpp index 41be819e0e133..130018417eebf 100644 --- a/sycl/source/detail/platform_impl.hpp +++ b/sycl/source/detail/platform_impl.hpp @@ -8,8 +8,8 @@ #pragma once +#include #include -#include #include #include #include @@ -36,13 +36,13 @@ class platform_impl { /// handle. /// /// \param APlatform is a raw plug-in platform handle. - /// \param APlugin is a plug-in handle. + /// \param AAdapter is a plug-in handle. explicit platform_impl(ur_platform_handle_t APlatform, - const std::shared_ptr &APlugin) - : MPlatform(APlatform), MPlugin(APlugin) { + const std::shared_ptr &AAdapter) + : MPlatform(APlatform), MAdapter(AAdapter) { // Find out backend of the platform ur_platform_backend_t UrBackend = UR_PLATFORM_BACKEND_UNKNOWN; - APlugin->call_nocheck( + AAdapter->call_nocheck( APlatform, UR_PLATFORM_INFO_BACKEND, sizeof(ur_platform_backend_t), &UrBackend, nullptr); MBackend = convertUrBackend(UrBackend); @@ -91,18 +91,18 @@ class platform_impl { /// Get backend option. void getBackendOption(const char *frontend_option, const char **backend_option) const { - const auto &Plugin = getPlugin(); + const auto &Adapter = getAdapter(); ur_result_t Err = - Plugin->call_nocheck( + Adapter->call_nocheck( MPlatform, frontend_option, backend_option); - Plugin->checkUrResult(Err); + Adapter->checkUrResult(Err); } /// \return an instance of OpenCL cl_platform_id. cl_platform_id get() const { ur_native_handle_t nativeHandle = 0; - getPlugin()->call(MPlatform, - &nativeHandle); + getAdapter()->call(MPlatform, + &nativeHandle); return ur::cast(nativeHandle); } @@ -129,15 +129,15 @@ class platform_impl { /// \return a vector of all unsupported (non-SYCL) platforms. static std::vector get_unsupported_platforms(); - // \return the Plugin associated with this platform. - const PluginPtr &getPlugin() const { return MPlugin; } + // \return the Adapter associated with this platform. + const AdapterPtr &getAdapter() const { return MAdapter; } - /// Sets the platform implementation to use another plugin. + /// Sets the platform implementation to use another adapter. /// - /// \param PluginPtr is a pointer to a plugin instance + /// \param AdapterPtr is a pointer to a adapter instance /// \param Backend is the backend that we want this platform to use - void setPlugin(PluginPtr &PluginPtr, backend Backend) { - MPlugin = PluginPtr; + void setAdapter(AdapterPtr &AdapterPtr, backend Backend) { + MAdapter = AdapterPtr; MBackend = Backend; } @@ -182,11 +182,11 @@ class platform_impl { /// one and cache it. /// /// \param UrPlatform is the UR Platform handle representing the platform - /// \param Plugin is the UR plugin providing the backend for the platform + /// \param Adapter is the UR adapter providing the backend for the platform /// \return the platform_impl representing the UR platform static std::shared_ptr getOrMakePlatformImpl(ur_platform_handle_t UrPlatform, - const PluginPtr &Plugin); + const AdapterPtr &Adapter); /// Queries the cache for the specified platform based on an input device. /// If found, returns the the cached platform_impl, otherwise creates a new @@ -194,11 +194,12 @@ class platform_impl { /// /// \param UrDevice is the UR device handle for the device whose platform is /// desired - /// \param Plugin is the UR plugin providing the backend for the device and + /// \param Adapter is the UR adapter providing the backend for the device and /// platform /// \return the platform_impl that contains the input device static std::shared_ptr - getPlatformFromUrDevice(ur_device_handle_t UrDevice, const PluginPtr &Plugin); + getPlatformFromUrDevice(ur_device_handle_t UrDevice, + const AdapterPtr &Adapter); // when getting sub-devices for ONEAPI_DEVICE_SELECTOR we may temporarily // ensure every device is a root one. @@ -207,9 +208,9 @@ class platform_impl { private: std::shared_ptr getDeviceImplHelper(ur_device_handle_t UrDevice); - // Helper to get the vector of platforms supported by a given UR plugin - static std::vector getPluginPlatforms(PluginPtr &Plugin, - bool Supported = true); + // Helper to get the vector of platforms supported by a given UR adapter + static std::vector getAdapterPlatforms(AdapterPtr &Adapter, + bool Supported = true); // Helper to filter reportable devices in the platform template @@ -220,7 +221,7 @@ class platform_impl { ur_platform_handle_t MPlatform = 0; backend MBackend; - PluginPtr MPlugin; + AdapterPtr MAdapter; std::vector> MDeviceCache; std::mutex MDeviceMapMutex; diff --git a/sycl/source/detail/platform_info.hpp b/sycl/source/detail/platform_info.hpp index 11a7636c3f597..429f2024e2bed 100644 --- a/sycl/source/detail/platform_info.hpp +++ b/sycl/source/detail/platform_info.hpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #pragma once -#include +#include #include #include #include @@ -20,19 +20,19 @@ inline namespace _V1 { namespace detail { inline std::string get_platform_info_string_impl(ur_platform_handle_t Plt, - const PluginPtr &Plugin, + const AdapterPtr &Adapter, ur_platform_info_t UrCode) { size_t ResultSize = 0; // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call(Plt, UrCode, 0, nullptr, - &ResultSize); + Adapter->call(Plt, UrCode, 0, nullptr, + &ResultSize); if (ResultSize == 0) { return ""; } std::unique_ptr Result(new char[ResultSize]); // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call(Plt, UrCode, ResultSize, - Result.get(), nullptr); + Adapter->call(Plt, UrCode, ResultSize, + Result.get(), nullptr); return Result.get(); } // The platform information methods @@ -40,21 +40,21 @@ template typename std::enable_if< std::is_same::value, std::string>::type -get_platform_info(ur_platform_handle_t Plt, const PluginPtr &Plugin) { +get_platform_info(ur_platform_handle_t Plt, const AdapterPtr &Adapter) { static_assert(is_platform_info_desc::value, "Invalid platform information descriptor"); - return get_platform_info_string_impl(Plt, Plugin, + return get_platform_info_string_impl(Plt, Adapter, detail::UrInfoCode::value); } template typename std::enable_if::value, std::vector>::type -get_platform_info(ur_platform_handle_t Plt, const PluginPtr &Plugin) { +get_platform_info(ur_platform_handle_t Plt, const AdapterPtr &Adapter) { static_assert(is_platform_info_desc::value, "Invalid platform information descriptor"); std::string Result = get_platform_info_string_impl( - Plt, Plugin, detail::UrInfoCode::value); + Plt, Adapter, detail::UrInfoCode::value); return split_string(Result, ' '); } diff --git a/sycl/source/detail/posix_ur.cpp b/sycl/source/detail/posix_ur.cpp index 07b829c6a035b..18ffeed1cc60e 100644 --- a/sycl/source/detail/posix_ur.cpp +++ b/sycl/source/detail/posix_ur.cpp @@ -19,7 +19,7 @@ namespace detail::ur { void *loadOsLibrary(const std::string &LibraryPath) { // TODO: Check if the option RTLD_NOW is correct. Explore using - // RTLD_DEEPBIND option when there are multiple plugins. + // RTLD_DEEPBIND option when there are multiple adapters. void *so = dlopen(LibraryPath.c_str(), RTLD_NOW); if (!so && trace(TraceLevel::TRACE_ALL)) { char *Error = dlerror(); diff --git a/sycl/source/detail/program_manager/program_manager.cpp b/sycl/source/detail/program_manager/program_manager.cpp index d6f063e5fada6..2fa9e75be6f0c 100644 --- a/sycl/source/detail/program_manager/program_manager.cpp +++ b/sycl/source/detail/program_manager/program_manager.cpp @@ -58,12 +58,12 @@ static constexpr char UseSpvEnv[]("SYCL_USE_KERNEL_SPV"); /// This function enables ITT annotations in SPIR-V module by setting /// a specialization constant if INTEL_LIBITTNOTIFY64 env variable is set. static void enableITTAnnotationsIfNeeded(const ur_program_handle_t &Prog, - const PluginPtr &Plugin) { + const AdapterPtr &Adapter) { if (SYCLConfig::get() != nullptr) { constexpr char SpecValue = 1; ur_specialization_constant_info_t SpecConstInfo = { ITTSpecConstId, sizeof(char), &SpecValue}; - Plugin->call( + Adapter->call( Prog, 1, &SpecConstInfo); } } @@ -76,13 +76,13 @@ static ur_program_handle_t createBinaryProgram(const ContextImplPtr Context, const device &Device, const unsigned char *Data, size_t DataLen, const std::vector Metadata) { - const PluginPtr &Plugin = Context->getPlugin(); + const AdapterPtr &Adapter = Context->getAdapter(); #ifndef _NDEBUG uint32_t NumDevices = 0; - Plugin->call(Context->getHandleRef(), - UR_CONTEXT_INFO_NUM_DEVICES, - sizeof(NumDevices), &NumDevices, - /*param_value_size_ret=*/nullptr); + Adapter->call(Context->getHandleRef(), + UR_CONTEXT_INFO_NUM_DEVICES, + sizeof(NumDevices), &NumDevices, + /*param_value_size_ret=*/nullptr); assert(NumDevices > 0 && "Only a single device is supported for AOT compilation"); #endif @@ -95,7 +95,7 @@ createBinaryProgram(const ContextImplPtr Context, const device &Device, Properties.pNext = nullptr; Properties.count = Metadata.size(); Properties.pMetadatas = Metadata.data(); - Plugin->call( + Adapter->call( Context->getHandleRef(), UrDevice, DataLen, Data, &Properties, &Program); if (BinaryStatus != UR_RESULT_SUCCESS) { @@ -112,9 +112,9 @@ static ur_program_handle_t createSpirvProgram(const ContextImplPtr Context, const unsigned char *Data, size_t DataLen) { ur_program_handle_t Program = nullptr; - const PluginPtr &Plugin = Context->getPlugin(); - Plugin->call(Context->getHandleRef(), Data, - DataLen, nullptr, &Program); + const AdapterPtr &Adapter = Context->getAdapter(); + Adapter->call(Context->getHandleRef(), Data, + DataLen, nullptr, &Program); return Program; } @@ -323,7 +323,7 @@ appendCompileOptionsForGRFSizeProperties(std::string &CompileOpts, static void appendCompileOptionsFromImage(std::string &CompileOpts, const RTDeviceBinaryImage &Img, const std::vector &Devs, - const PluginPtr &) { + const AdapterPtr &) { // Build options are overridden if environment variables are present. // Environment variables are not changed during program lifecycle so it // is reasonable to use static here to read them only once. @@ -457,8 +457,8 @@ static void applyOptionsFromImage(std::string &CompileOpts, std::string &LinkOpts, const RTDeviceBinaryImage &Img, const std::vector &Devices, - const PluginPtr &Plugin) { - appendCompileOptionsFromImage(CompileOpts, Img, Devices, Plugin); + const AdapterPtr &Adapter) { + appendCompileOptionsFromImage(CompileOpts, Img, Devices, Adapter); appendLinkOptionsFromImage(LinkOpts, Img); } @@ -555,7 +555,7 @@ static bool compatibleWithDevice(RTDeviceBinaryImage *BinImage, const device &Dev) { const std::shared_ptr &DeviceImpl = detail::getSyclObjImpl(Dev); - auto &Plugin = DeviceImpl->getPlugin(); + auto &Adapter = DeviceImpl->getAdapter(); const ur_device_handle_t &URDeviceHandle = DeviceImpl->getHandleRef(); @@ -569,7 +569,7 @@ static bool compatibleWithDevice(RTDeviceBinaryImage *BinImage, ur_device_binary_t UrBinary{}; UrBinary.pDeviceTargetSpec = getUrDeviceTarget(DevBin->DeviceTargetSpec); - ur_result_t Error = Plugin->call_nocheck( + ur_result_t Error = Adapter->call_nocheck( URDeviceHandle, &UrBinary, /*num bin images = */ (uint32_t)1, &SuitableImageID); if (Error != UR_RESULT_SUCCESS && Error != UR_RESULT_ERROR_INVALID_BINARY) @@ -707,9 +707,10 @@ ProgramManager::collectDependentDeviceImagesForVirtualFunctions( static void setSpecializationConstants(const std::shared_ptr &InputImpl, - ur_program_handle_t Prog, const PluginPtr &Plugin) { + ur_program_handle_t Prog, + const AdapterPtr &Adapter) { // Set ITT annotation specialization constant if needed. - enableITTAnnotationsIfNeeded(Prog, Plugin); + enableITTAnnotationsIfNeeded(Prog, Adapter); std::lock_guard Lock{InputImpl->get_spec_const_data_lock()}; const std::map> @@ -724,7 +725,7 @@ setSpecializationConstants(const std::shared_ptr &InputImpl, ur_specialization_constant_info_t SpecConstInfo = { SpecIDDesc.ID, SpecIDDesc.Size, SpecConsts.data() + SpecIDDesc.BlobOffset}; - Plugin->call( + Adapter->call( Prog, 1, &SpecConstInfo); } } @@ -759,7 +760,7 @@ ur_program_handle_t ProgramManager::getBuiltURProgram( } ur_bool_t MustBuildOnSubdevice = true; - ContextImpl->getPlugin()->call( + ContextImpl->getAdapter()->call( RootDevImpl->getHandleRef(), UR_DEVICE_INFO_BUILD_ON_SUBDEVICE, sizeof(ur_bool_t), &MustBuildOnSubdevice, nullptr); @@ -790,8 +791,8 @@ ur_program_handle_t ProgramManager::getBuiltURProgram( auto BuildF = [this, &Img, &Context, &ContextImpl, &Device, &CompileOpts, &LinkOpts, SpecConsts, &DeviceImagesToLink, &AllImages] { - const PluginPtr &Plugin = ContextImpl->getPlugin(); - applyOptionsFromImage(CompileOpts, LinkOpts, Img, {Device}, Plugin); + const AdapterPtr &Adapter = ContextImpl->getAdapter(); + applyOptionsFromImage(CompileOpts, LinkOpts, Img, {Device}, Adapter); // Should always come last! appendCompileEnvironmentVariablesThatAppend(CompileOpts); appendLinkEnvironmentVariablesThatAppend(LinkOpts); @@ -800,7 +801,7 @@ ur_program_handle_t ProgramManager::getBuiltURProgram( if (!DeviceCodeWasInCache) { if (Img.supportsSpecConstants()) - enableITTAnnotationsIfNeeded(NativePrg, Plugin); + enableITTAnnotationsIfNeeded(NativePrg, Adapter); } UrFuncInfo programReleaseInfo; @@ -837,7 +838,7 @@ ur_program_handle_t ProgramManager::getBuiltURProgram( createURProgram(*BinImg, Context, Device); if (BinImg->supportsSpecConstants()) - setSpecializationConstants(DeviceImageImpl, NativePrg, Plugin); + setSpecializationConstants(DeviceImageImpl, NativePrg, Adapter); ProgramsToLink.push_back(NativePrg); } @@ -849,7 +850,7 @@ ur_program_handle_t ProgramManager::getBuiltURProgram( SYCL_DEVICE_BINARY_TYPE_SPIRV); // Those extra programs won't be used anymore, just the final linked result for (ur_program_handle_t Prg : ProgramsToLink) - Plugin->call(Prg); + Adapter->call(Prg); emitBuiltProgramInfo(BuiltProgram.get(), ContextImpl); @@ -889,7 +890,7 @@ ur_program_handle_t ProgramManager::getBuiltURProgram( assert(BuildResult != nullptr && "Invalid build result"); ur_program_handle_t ResProgram = BuildResult->Val; - auto Plugin = ContextImpl->getPlugin(); + auto Adapter = ContextImpl->getAdapter(); // If we linked any extra device images, then we need to // cache them as well. @@ -900,7 +901,7 @@ ur_program_handle_t ProgramManager::getBuiltURProgram( bool DidInsert = Cache.insertBuiltProgram(CacheKey, ResProgram); if (DidInsert) { // For every cached copy of the program, we need to increment its refcount - Plugin->call(ResProgram); + Adapter->call(ResProgram); } } @@ -908,7 +909,7 @@ ur_program_handle_t ProgramManager::getBuiltURProgram( // stored in the cache, and one handle is returned to the // caller. In that case, we need to increase the ref count of the // program. - ContextImpl->getPlugin()->call(ResProgram); + ContextImpl->getAdapter()->call(ResProgram); return ResProgram; } @@ -946,9 +947,9 @@ ProgramManager::getOrCreateKernel(const ContextImplPtr &ContextImpl, if (std::get(ret_tuple)) { // Pulling a copy of a kernel and program from the cache, // so we need to retain those resources. - ContextImpl->getPlugin()->call( + ContextImpl->getAdapter()->call( std::get(ret_tuple)); - ContextImpl->getPlugin()->call( + ContextImpl->getAdapter()->call( std::get(ret_tuple)); return ret_tuple; } @@ -960,16 +961,16 @@ ProgramManager::getOrCreateKernel(const ContextImplPtr &ContextImpl, auto BuildF = [this, &Program, &KernelName, &ContextImpl] { ur_kernel_handle_t Kernel = nullptr; - const PluginPtr &Plugin = ContextImpl->getPlugin(); - Plugin->call( + const AdapterPtr &Adapter = ContextImpl->getAdapter(); + Adapter->call( Program, KernelName.c_str(), &Kernel); // Only set UR_USM_INDIRECT_ACCESS if the platform can handle it. if (ContextImpl->getPlatformImpl()->supports_usm()) { - // Some UR Plugins (like OpenCL) require this call to enable USM + // Some UR Adapters (like OpenCL) require this call to enable USM // For others, UR will turn this into a NOP. const ur_bool_t UrTrue = true; - Plugin->call( + Adapter->call( Kernel, UR_KERNEL_EXEC_INFO_USM_INDIRECT_ACCESS, sizeof(ur_bool_t), nullptr, &UrTrue); } @@ -1003,7 +1004,7 @@ ProgramManager::getOrCreateKernel(const ContextImplPtr &ContextImpl, // stored in the cache, and one handle is returned to the // caller. In that case, we need to increase the ref count of the // kernel. - ContextImpl->getPlugin()->call( + ContextImpl->getAdapter()->call( KernelArgMaskPair.first); Cache.saveKernel(key, ret_val); return ret_val; @@ -1013,10 +1014,10 @@ ur_program_handle_t ProgramManager::getUrProgramFromUrKernel(ur_kernel_handle_t Kernel, const ContextImplPtr Context) { ur_program_handle_t Program; - const PluginPtr &Plugin = Context->getPlugin(); - Plugin->call(Kernel, UR_KERNEL_INFO_PROGRAM, - sizeof(ur_program_handle_t), - &Program, nullptr); + const AdapterPtr &Adapter = Context->getAdapter(); + Adapter->call(Kernel, UR_KERNEL_INFO_PROGRAM, + sizeof(ur_program_handle_t), + &Program, nullptr); return Program; } @@ -1024,25 +1025,25 @@ std::string ProgramManager::getProgramBuildLog(const ur_program_handle_t &Program, const ContextImplPtr Context) { size_t URDevicesSize = 0; - const PluginPtr &Plugin = Context->getPlugin(); - Plugin->call(Program, UR_PROGRAM_INFO_DEVICES, 0, - nullptr, &URDevicesSize); + const AdapterPtr &Adapter = Context->getAdapter(); + Adapter->call(Program, UR_PROGRAM_INFO_DEVICES, + 0, nullptr, &URDevicesSize); std::vector URDevices(URDevicesSize / sizeof(ur_device_handle_t)); - Plugin->call(Program, UR_PROGRAM_INFO_DEVICES, - URDevicesSize, URDevices.data(), - nullptr); + Adapter->call(Program, UR_PROGRAM_INFO_DEVICES, + URDevicesSize, URDevices.data(), + nullptr); std::string Log = "The program was built for " + std::to_string(URDevices.size()) + " devices"; for (ur_device_handle_t &Device : URDevices) { std::string DeviceBuildInfoString; size_t DeviceBuildInfoStrSize = 0; - Plugin->call( + Adapter->call( Program, Device, UR_PROGRAM_BUILD_INFO_LOG, 0, nullptr, &DeviceBuildInfoStrSize); if (DeviceBuildInfoStrSize > 0) { std::vector DeviceBuildInfo(DeviceBuildInfoStrSize); - Plugin->call( + Adapter->call( Program, Device, UR_PROGRAM_BUILD_INFO_LOG, DeviceBuildInfoStrSize, DeviceBuildInfo.data(), nullptr); DeviceBuildInfoString = std::string(DeviceBuildInfo.data()); @@ -1050,13 +1051,13 @@ ProgramManager::getProgramBuildLog(const ur_program_handle_t &Program, std::string DeviceNameString; size_t DeviceNameStrSize = 0; - Plugin->call(Device, UR_DEVICE_INFO_NAME, 0, - nullptr, &DeviceNameStrSize); + Adapter->call(Device, UR_DEVICE_INFO_NAME, 0, + nullptr, &DeviceNameStrSize); if (DeviceNameStrSize > 0) { std::vector DeviceName(DeviceNameStrSize); - Plugin->call(Device, UR_DEVICE_INFO_NAME, - DeviceNameStrSize, - DeviceName.data(), nullptr); + Adapter->call(Device, UR_DEVICE_INFO_NAME, + DeviceNameStrSize, + DeviceName.data(), nullptr); DeviceNameString = std::string(DeviceName.data()); } Log += "\nBuild program log for '" + DeviceNameString + "':\n" + @@ -1151,17 +1152,17 @@ static const char *getDeviceLibExtensionStr(DeviceLibExt Extension) { return Ext->second; } -static ur_result_t doCompile(const PluginPtr &Plugin, +static ur_result_t doCompile(const AdapterPtr &Adapter, ur_program_handle_t Program, uint32_t NumDevs, ur_device_handle_t *Devs, ur_context_handle_t Ctx, const char *Opts) { // Try to compile with given devices, fall back to compiling with the program // context if unsupported by the adapter - auto Result = Plugin->call_nocheck( + auto Result = Adapter->call_nocheck( Program, NumDevs, Devs, Opts); if (Result == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { - return Plugin->call_nocheck(Ctx, Program, - Opts); + return Adapter->call_nocheck(Ctx, Program, + Opts); } return Result; } @@ -1190,13 +1191,13 @@ static ur_program_handle_t loadDeviceLibFallback(const ContextImplPtr Context, std::string("Failed to load ") + LibFileName); } - const PluginPtr &Plugin = Context->getPlugin(); + const AdapterPtr &Adapter = Context->getAdapter(); // TODO no spec constants are used in the std libraries, support in the future // Do not use compile options for library programs: it is not clear if user // options (image options) are supposed to be applied to library program as // well, and what actually happens to a SPIR-V program if we apply them. ur_result_t Error = - doCompile(Plugin, LibProg, 1, &Device, Context->getHandleRef(), ""); + doCompile(Adapter, LibProg, 1, &Device, Context->getHandleRef(), ""); if (Error != UR_RESULT_SUCCESS) { CachedLibPrograms.erase(LibProgIt); throw detail::set_ur_error( @@ -1347,7 +1348,7 @@ RTDeviceBinaryImage *getBinImageFromMultiMap( uint32_t ImgInd = 0; // Ask the native runtime under the given context to choose the device image // it prefers. - getSyclObjImpl(Context)->getPlugin()->call( + getSyclObjImpl(Context)->getAdapter()->call( getSyclObjImpl(Device)->getHandleRef(), UrBinaries.data(), UrBinaries.size(), &ImgInd); return DeviceFilteredImgs[ImgInd]; @@ -1432,7 +1433,7 @@ RTDeviceBinaryImage &ProgramManager::getDeviceImage( getUrDeviceTarget(RawImgs[BinaryCount]->DeviceTargetSpec); } - getSyclObjImpl(Context)->getPlugin()->call( + getSyclObjImpl(Context)->getAdapter()->call( getSyclObjImpl(Device)->getHandleRef(), UrBinaries.data(), UrBinaries.size(), &ImgInd); @@ -1557,16 +1558,16 @@ ProgramManager::ProgramPtr ProgramManager::build( static const char *ForceLinkEnv = std::getenv("SYCL_FORCE_LINK"); static bool ForceLink = ForceLinkEnv && (*ForceLinkEnv == '1'); - const PluginPtr &Plugin = Context->getPlugin(); + const AdapterPtr &Adapter = Context->getAdapter(); if (LinkPrograms.empty() && ExtraProgramsToLink.empty() && !ForceLink) { const std::string &Options = LinkOptions.empty() ? CompileOptions : (CompileOptions + " " + LinkOptions); - ur_result_t Error = Plugin->call_nocheck( + ur_result_t Error = Adapter->call_nocheck( Program.get(), /*num devices =*/1, &Device, Options.c_str()); if (Error == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { - Error = Plugin->call_nocheck( + Error = Adapter->call_nocheck( Context->getHandleRef(), Program.get(), Options.c_str()); } @@ -1581,29 +1582,29 @@ ProgramManager::ProgramPtr ProgramManager::build( // Include the main program and compile/link everything together if (!CreatedFromBinary) { - auto Res = doCompile(Plugin, Program.get(), /*num devices =*/1, &Device, + auto Res = doCompile(Adapter, Program.get(), /*num devices =*/1, &Device, Context->getHandleRef(), CompileOptions.c_str()); - Plugin->checkUrResult(Res); + Adapter->checkUrResult(Res); } LinkPrograms.push_back(Program.get()); for (ur_program_handle_t Prg : ExtraProgramsToLink) { if (!CreatedFromBinary) { - auto Res = doCompile(Plugin, Prg, /*num devices =*/1, &Device, + auto Res = doCompile(Adapter, Prg, /*num devices =*/1, &Device, Context->getHandleRef(), CompileOptions.c_str()); - Plugin->checkUrResult(Res); + Adapter->checkUrResult(Res); } LinkPrograms.push_back(Prg); } ur_program_handle_t LinkedProg = nullptr; auto doLink = [&] { - auto Res = Plugin->call_nocheck( + auto Res = Adapter->call_nocheck( Context->getHandleRef(), /*num devices =*/1, &Device, LinkPrograms.size(), LinkPrograms.data(), LinkOptions.c_str(), &LinkedProg); if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { - Res = Plugin->call_nocheck( + Res = Adapter->call_nocheck( Context->getHandleRef(), LinkPrograms.size(), LinkPrograms.data(), LinkOptions.c_str(), &LinkedProg); } @@ -1629,7 +1630,7 @@ ProgramManager::ProgramPtr ProgramManager::build( getProgramBuildLog(LinkedProg, Context)), Error); } - Plugin->checkUrResult(Error); + Adapter->checkUrResult(Error); } return Program; } @@ -2338,8 +2339,8 @@ ProgramManager::compile(const device_image_plain &DeviceImage, const std::shared_ptr &InputImpl = getSyclObjImpl(DeviceImage); - const PluginPtr &Plugin = - getSyclObjImpl(InputImpl->get_context())->getPlugin(); + const AdapterPtr &Adapter = + getSyclObjImpl(InputImpl->get_context())->getAdapter(); // TODO: Add support for creating non-SPIRV programs from multiple devices. if (InputImpl->get_bin_image_ref()->getFormat() != @@ -2358,7 +2359,7 @@ ProgramManager::compile(const device_image_plain &DeviceImage, InputImpl->get_context(), Devs[0]); if (InputImpl->get_bin_image_ref()->supportsSpecConstants()) - setSpecializationConstants(InputImpl, Prog, Plugin); + setSpecializationConstants(InputImpl, Prog, Adapter); DeviceImageImplPtr ObjectImpl = std::make_shared( InputImpl->get_bin_image_ref(), InputImpl->get_context(), Devs, @@ -2375,11 +2376,11 @@ ProgramManager::compile(const device_image_plain &DeviceImage, std::string CompileOptions; applyCompileOptionsFromEnvironment(CompileOptions); appendCompileOptionsFromImage( - CompileOptions, *(InputImpl->get_bin_image_ref()), Devs, Plugin); + CompileOptions, *(InputImpl->get_bin_image_ref()), Devs, Adapter); // Should always come last! appendCompileEnvironmentVariablesThatAppend(CompileOptions); ur_result_t Error = doCompile( - Plugin, ObjectImpl->get_ur_program_ref(), Devs.size(), URDevices.data(), + Adapter, ObjectImpl->get_ur_program_ref(), Devs.size(), URDevices.data(), getSyclObjImpl(InputImpl->get_context()).get()->getHandleRef(), CompileOptions.c_str()); if (Error != UR_RESULT_SUCCESS) @@ -2417,16 +2418,16 @@ ProgramManager::link(const device_image_plain &DeviceImage, appendLinkEnvironmentVariablesThatAppend(LinkOptionsStr); const context &Context = getSyclObjImpl(DeviceImage)->get_context(); const ContextImplPtr ContextImpl = getSyclObjImpl(Context); - const PluginPtr &Plugin = ContextImpl->getPlugin(); + const AdapterPtr &Adapter = ContextImpl->getAdapter(); ur_program_handle_t LinkedProg = nullptr; auto doLink = [&] { - auto Res = Plugin->call_nocheck( + auto Res = Adapter->call_nocheck( ContextImpl->getHandleRef(), URDevices.size(), URDevices.data(), URPrograms.size(), URPrograms.data(), LinkOptionsStr.c_str(), &LinkedProg); if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { - Res = Plugin->call_nocheck( + Res = Adapter->call_nocheck( ContextImpl->getHandleRef(), URPrograms.size(), URPrograms.data(), LinkOptionsStr.c_str(), &LinkedProg); } @@ -2536,8 +2537,8 @@ device_image_plain ProgramManager::build(const device_image_plain &DeviceImage, auto BuildF = [this, &Context, &Img, &Devs, &CompileOpts, &LinkOpts, &InputImpl, SpecConsts] { ContextImplPtr ContextImpl = getSyclObjImpl(Context); - const PluginPtr &Plugin = ContextImpl->getPlugin(); - applyOptionsFromImage(CompileOpts, LinkOpts, Img, Devs, Plugin); + const AdapterPtr &Adapter = ContextImpl->getAdapter(); + applyOptionsFromImage(CompileOpts, LinkOpts, Img, Devs, Adapter); // Should always come last! appendCompileEnvironmentVariablesThatAppend(CompileOpts); appendLinkEnvironmentVariablesThatAppend(LinkOpts); @@ -2559,7 +2560,7 @@ device_image_plain ProgramManager::build(const device_image_plain &DeviceImage, if (!DeviceCodeWasInCache && InputImpl->get_bin_image_ref()->supportsSpecConstants()) - setSpecializationConstants(InputImpl, NativePrg, Plugin); + setSpecializationConstants(InputImpl, NativePrg, Adapter); UrFuncInfo programReleaseInfo; auto programRelease = @@ -2632,9 +2633,9 @@ device_image_plain ProgramManager::build(const device_image_plain &DeviceImage, // Cache supports key with once device only, but here we have multiple // devices a program is built for, so add the program to the cache for all // other devices. - const PluginPtr &Plugin = ContextImpl->getPlugin(); - auto CacheOtherDevices = [ResProgram, &Plugin]() { - Plugin->call(ResProgram); + const AdapterPtr &Adapter = ContextImpl->getAdapter(); + auto CacheOtherDevices = [ResProgram, &Adapter]() { + Adapter->call(ResProgram); return ResProgram; }; @@ -2654,7 +2655,7 @@ device_image_plain ProgramManager::build(const device_image_plain &DeviceImage, // devive_image_impl shares ownership of PIProgram with, at least, program // cache. The ref counter will be descremented in the destructor of // device_image_impl - Plugin->call(ResProgram); + Adapter->call(ResProgram); DeviceImageImplPtr ExecImpl = std::make_shared( InputImpl->get_bin_image_ref(), Context, Devs, bundle_state::executable, @@ -2682,14 +2683,14 @@ ProgramManager::getOrCreateKernel(const context &Context, auto BuildF = [this, &Program, &KernelName, &Ctx] { ur_kernel_handle_t Kernel = nullptr; - const PluginPtr &Plugin = Ctx->getPlugin(); - Plugin->call(Program, KernelName.c_str(), - &Kernel); + const AdapterPtr &Adapter = Ctx->getAdapter(); + Adapter->call(Program, KernelName.c_str(), + &Kernel); // Only set UR_USM_INDIRECT_ACCESS if the platform can handle it. if (Ctx->getPlatformImpl()->supports_usm()) { bool EnableAccess = true; - Plugin->call( + Adapter->call( Kernel, UR_KERNEL_EXEC_INFO_USM_INDIRECT_ACCESS, sizeof(ur_bool_t), nullptr, &EnableAccess); } @@ -2721,7 +2722,7 @@ ProgramManager::getOrCreateKernel(const context &Context, // stored in the cache, and one handle is returned to the // caller. In that case, we need to increase the ref count of the // kernel. - Ctx->getPlugin()->call(BuildResult->Val.first); + Ctx->getAdapter()->call(BuildResult->Val.first); return std::make_tuple(BuildResult->Val.first, &(BuildResult->MBuildResultMutex), BuildResult->Val.second); @@ -2774,7 +2775,7 @@ ur_kernel_handle_t ProgramManager::getOrCreateMaterializedKernel( std::cerr << ">>> Adding the kernel to the cache.\n"; auto Program = createURProgram(Img, Context, Device); auto DeviceImpl = detail::getSyclObjImpl(Device); - auto &Plugin = DeviceImpl->getPlugin(); + auto &Adapter = DeviceImpl->getAdapter(); UrFuncInfo programReleaseInfo; auto programRelease = programReleaseInfo.getFuncPtrFromModule(ur::getURLoaderLibrary()); @@ -2791,7 +2792,7 @@ ur_kernel_handle_t ProgramManager::getOrCreateMaterializedKernel( /*For non SPIR-V devices DeviceLibReqdMask is always 0*/ 0, ExtraProgramsToLink); ur_kernel_handle_t UrKernel{nullptr}; - Plugin->call( + Adapter->call( BuildProgram.get(), KernelName.c_str(), &UrKernel); { std::lock_guard KernelIDsGuard(m_KernelIDsMutex); diff --git a/sycl/source/detail/queue_impl.cpp b/sycl/source/detail/queue_impl.cpp index d340d0ecd9c17..869529bb75162 100644 --- a/sycl/source/detail/queue_impl.cpp +++ b/sycl/source/detail/queue_impl.cpp @@ -59,7 +59,7 @@ getUrEvents(const std::vector &DepEvents) { template <> uint32_t queue_impl::get_info() const { ur_result_t result = UR_RESULT_SUCCESS; - getPlugin()->call( + getAdapter()->call( MQueues[0], UR_QUEUE_INFO_REFERENCE_COUNT, sizeof(result), &result, nullptr); return result; @@ -613,8 +613,8 @@ void queue_impl::wait(const detail::code_location &CodeLoc) { } } if (SupportsPiFinish) { - const PluginPtr &Plugin = getPlugin(); - Plugin->call(getHandleRef()); + const AdapterPtr &Adapter = getAdapter(); + Adapter->call(getHandleRef()); assert(SharedEvents.empty() && "Queues that support calling piQueueFinish " "shouldn't have shared events"); } else { @@ -694,16 +694,16 @@ void queue_impl::destructorNotification() { } ur_native_handle_t queue_impl::getNative(int32_t &NativeHandleDesc) const { - const PluginPtr &Plugin = getPlugin(); + const AdapterPtr &Adapter = getAdapter(); if (getContextImplPtr()->getBackend() == backend::opencl) - Plugin->call(MQueues[0]); + Adapter->call(MQueues[0]); ur_native_handle_t Handle{}; ur_queue_native_desc_t UrNativeDesc{UR_STRUCTURE_TYPE_QUEUE_NATIVE_DESC, nullptr, nullptr}; UrNativeDesc.pNativeData = &NativeHandleDesc; - Plugin->call(MQueues[0], &UrNativeDesc, - &Handle); + Adapter->call(MQueues[0], &UrNativeDesc, + &Handle); return Handle; } @@ -727,7 +727,7 @@ bool queue_impl::ext_oneapi_empty() const { // Check the status of the backend queue if this is not a host queue. ur_bool_t IsReady = false; - getPlugin()->call( + getAdapter()->call( MQueues[0], UR_QUEUE_INFO_EMPTY, sizeof(IsReady), &IsReady, nullptr); if (!IsReady) return false; diff --git a/sycl/source/detail/queue_impl.hpp b/sycl/source/detail/queue_impl.hpp index e943c7afe4198..6bf9c338e6f3f 100644 --- a/sycl/source/detail/queue_impl.hpp +++ b/sycl/source/detail/queue_impl.hpp @@ -8,6 +8,7 @@ #pragma once +#include #include #include #include @@ -16,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -185,9 +185,9 @@ class queue_impl { MQueues.push_back(UrQueue); ur_device_handle_t DeviceUr{}; - const PluginPtr &Plugin = getPlugin(); + const AdapterPtr &Adapter = getAdapter(); // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call( + Adapter->call( MQueues[0], UR_QUEUE_INFO_DEVICE, sizeof(DeviceUr), &DeviceUr, nullptr); MDevice = MContext->findMatchingDeviceImpl(DeviceUr); if (MDevice == nullptr) { @@ -208,7 +208,7 @@ class queue_impl { } public: - /// Constructs a SYCL queue from plugin interoperability handle. + /// Constructs a SYCL queue from adapter interoperability handle. /// /// \param UrQueue is a raw UR queue handle. /// \param Context is a SYCL context to associate with the queue being @@ -226,7 +226,7 @@ class queue_impl { queue_impl_interop(UrQueue); } - /// Constructs a SYCL queue from plugin interoperability handle. + /// Constructs a SYCL queue from adapter interoperability handle. /// /// \param UrQueue is a raw UR queue handle. /// \param Context is a SYCL context to associate with the queue being @@ -254,7 +254,7 @@ class queue_impl { destructorNotification(); #endif throw_asynchronous(); - getPlugin()->call(MQueues[0]); + getAdapter()->call(MQueues[0]); } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~queue_impl", e); } @@ -263,10 +263,10 @@ class queue_impl { /// \return an OpenCL interoperability queue handle. cl_command_queue get() { - getPlugin()->call(MQueues[0]); + getAdapter()->call(MQueues[0]); ur_native_handle_t nativeHandle = 0; - getPlugin()->call(MQueues[0], nullptr, - &nativeHandle); + getAdapter()->call(MQueues[0], nullptr, + &nativeHandle); return ur::cast(nativeHandle); } @@ -275,7 +275,7 @@ class queue_impl { return createSyclObjFromImpl(MContext); } - const PluginPtr &getPlugin() const { return MContext->getPlugin(); } + const AdapterPtr &getAdapter() const { return MContext->getAdapter(); } const ContextImplPtr &getContextImplPtr() const { return MContext; } @@ -313,7 +313,7 @@ class queue_impl { "recording to a command graph."); } for (const auto &queue : MQueues) { - getPlugin()->call(queue); + getAdapter()->call(queue); } } @@ -433,7 +433,7 @@ class queue_impl { CreationFlags |= UR_QUEUE_FLAG_USE_DEFAULT_STREAM; } if (PropList.has_property()) { - // Pass this flag to the Level Zero plugin to be able to check it from + // Pass this flag to the Level Zero adapter to be able to check it from // queue property. CreationFlags |= UR_QUEUE_FLAG_DISCARD_EVENTS; } @@ -489,7 +489,7 @@ class queue_impl { ur_queue_handle_t Queue{}; ur_context_handle_t Context = MContext->getHandleRef(); ur_device_handle_t Device = MDevice->getHandleRef(); - const PluginPtr &Plugin = getPlugin(); + const AdapterPtr &Adapter = getAdapter(); /* sycl::detail::pi::PiQueueProperties Properties[] = { PI_QUEUE_FLAGS, createPiQueueProperties(MPropList, Order), 0, 0, 0}; @@ -505,7 +505,7 @@ class queue_impl { .get_index(); Properties.pNext = &IndexProperties; } - ur_result_t Error = Plugin->call_nocheck( + ur_result_t Error = Adapter->call_nocheck( Context, Device, &Properties, &Queue); // If creating out-of-order queue failed and this property is not @@ -516,7 +516,7 @@ class queue_impl { MEmulateOOO = true; Queue = createQueue(QueueOrder::Ordered); } else { - Plugin->checkUrResult(Error); + Adapter->checkUrResult(Error); } return Queue; @@ -548,7 +548,7 @@ class queue_impl { if (!ReuseQueue) *PIQ = createQueue(QueueOrder::Ordered); else - getPlugin()->call(*PIQ); + getAdapter()->call(*PIQ); return *PIQ; } @@ -713,7 +713,7 @@ class queue_impl { EventImplPtr insertHelperBarrier(const HandlerType &Handler) { auto ResEvent = std::make_shared(Handler.MQueue); ur_event_handle_t UREvent = nullptr; - getPlugin()->call( + getAdapter()->call( Handler.MQueue->getHandleRef(), 0, nullptr, &UREvent); ResEvent->setHandle(UREvent); return ResEvent; diff --git a/sycl/source/detail/sampler_impl.cpp b/sycl/source/detail/sampler_impl.cpp index cb3e69b6a9a1a..77f151b69c1dd 100644 --- a/sycl/source/detail/sampler_impl.cpp +++ b/sycl/source/detail/sampler_impl.cpp @@ -22,16 +22,16 @@ sampler_impl::sampler_impl(coordinate_normalization_mode normalizationMode, MFiltMode(filteringMode), MPropList(propList) {} sampler_impl::sampler_impl(cl_sampler clSampler, const context &syclContext) { - const PluginPtr &Plugin = getSyclObjImpl(syclContext)->getPlugin(); + const AdapterPtr &Adapter = getSyclObjImpl(syclContext)->getAdapter(); ur_sampler_handle_t Sampler{}; - Plugin->call( + Adapter->call( reinterpret_cast(clSampler), getSyclObjImpl(syclContext)->getHandleRef(), nullptr, &Sampler); MContextToSampler[syclContext] = Sampler; bool NormalizedCoords; - Plugin->call( + Adapter->call( Sampler, UR_SAMPLER_INFO_NORMALIZED_COORDS, sizeof(ur_bool_t), &NormalizedCoords, nullptr); MCoordNormMode = NormalizedCoords @@ -39,7 +39,7 @@ sampler_impl::sampler_impl(cl_sampler clSampler, const context &syclContext) { : coordinate_normalization_mode::unnormalized; ur_sampler_addressing_mode_t AddrMode; - Plugin->call( + Adapter->call( Sampler, UR_SAMPLER_INFO_ADDRESSING_MODE, sizeof(ur_sampler_addressing_mode_t), &AddrMode, nullptr); switch (AddrMode) { @@ -62,7 +62,7 @@ sampler_impl::sampler_impl(cl_sampler clSampler, const context &syclContext) { } ur_sampler_filter_mode_t FiltMode; - Plugin->call( + Adapter->call( Sampler, UR_SAMPLER_INFO_FILTER_MODE, sizeof(ur_sampler_filter_mode_t), &FiltMode, nullptr); switch (FiltMode) { @@ -82,8 +82,8 @@ sampler_impl::~sampler_impl() { for (auto &Iter : MContextToSampler) { // TODO catch an exception and add it to the list of asynchronous // exceptions - const PluginPtr &Plugin = getSyclObjImpl(Iter.first)->getPlugin(); - Plugin->call(Iter.second); + const AdapterPtr &Adapter = getSyclObjImpl(Iter.first)->getAdapter(); + Adapter->call(Iter.second); } } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~sample_impl", e); @@ -130,16 +130,16 @@ ur_sampler_handle_t sampler_impl::getOrCreateSampler(const context &Context) { ur_result_t errcode_ret = UR_RESULT_SUCCESS; ur_sampler_handle_t resultSampler = nullptr; - const PluginPtr &Plugin = getSyclObjImpl(Context)->getPlugin(); + const AdapterPtr &Adapter = getSyclObjImpl(Context)->getAdapter(); - errcode_ret = Plugin->call_nocheck( + errcode_ret = Adapter->call_nocheck( getSyclObjImpl(Context)->getHandleRef(), &desc, &resultSampler); if (errcode_ret == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) throw sycl::exception(sycl::errc::feature_not_supported, "Images are not supported by this device."); - Plugin->checkUrResult(errcode_ret); + Adapter->checkUrResult(errcode_ret); std::lock_guard Lock(MMutex); MContextToSampler[Context] = resultSampler; diff --git a/sycl/source/detail/scheduler/commands.cpp b/sycl/source/detail/scheduler/commands.cpp index 5174fc966e905..133f55992f356 100644 --- a/sycl/source/detail/scheduler/commands.cpp +++ b/sycl/source/detail/scheduler/commands.cpp @@ -340,12 +340,12 @@ class DispatchHostTask { std::vector MReqUrMem; bool waitForEvents() const { - std::map> - RequiredEventsPerPlugin; + std::map> + RequiredEventsPerAdapter; for (const EventImplPtr &Event : MThisCmd->MPreparedDepsEvents) { - const PluginPtr &Plugin = Event->getPlugin(); - RequiredEventsPerPlugin[Plugin].push_back(Event); + const AdapterPtr &Adapter = Event->getAdapter(); + RequiredEventsPerAdapter[Adapter].push_back(Event); } // wait for dependency device events @@ -353,14 +353,14 @@ class DispatchHostTask { // 'sleep' until all of dependency events are complete. We need a bit more // sophisticated waiting mechanism to allow to utilize this thread for any // other available job and resume once all required events are ready. - for (auto &PluginWithEvents : RequiredEventsPerPlugin) { + for (auto &AdapterWithEvents : RequiredEventsPerAdapter) { std::vector RawEvents = - MThisCmd->getUrEvents(PluginWithEvents.second); + MThisCmd->getUrEvents(AdapterWithEvents.second); if (RawEvents.size() == 0) continue; try { - PluginWithEvents.first->call(RawEvents.size(), - RawEvents.data()); + AdapterWithEvents.first->call(RawEvents.size(), + RawEvents.data()); } catch (const sycl::exception &) { MThisCmd->MEvent->getSubmittedQueue()->reportAsyncException( std::current_exception()); @@ -429,7 +429,7 @@ class DispatchHostTask { // for host task? auto &Queue = HostTask.MQueue; bool NativeCommandSupport = false; - Queue->getPlugin()->call( + Queue->getAdapter()->call( detail::getSyclObjImpl(Queue->get_device())->getHandleRef(), UR_DEVICE_INFO_ENQUEUE_NATIVE_COMMAND_SUPPORT_EXP, sizeof(NativeCommandSupport), &NativeCommandSupport, nullptr); @@ -444,7 +444,7 @@ class DispatchHostTask { // // This entry point is needed in order to migrate memory across // devices in the same context for CUDA and HIP backends - Queue->getPlugin()->call( + Queue->getAdapter()->call( HostTask.MQueue->getHandleRef(), InteropFreeFunc, &CustomOpData, MReqUrMem.size(), MReqUrMem.data(), nullptr, 0, nullptr, nullptr); } else { @@ -538,18 +538,18 @@ void Command::waitForEvents(QueueImplPtr Queue, std::vector RawEvents = getUrEvents(CtxWithEvents.second); if (!RawEvents.empty()) { - CtxWithEvents.first->getPlugin()->call( + CtxWithEvents.first->getAdapter()->call( RawEvents.size(), RawEvents.data()); } } } else { std::vector RawEvents = getUrEvents(EventImpls); flushCrossQueueDeps(EventImpls, MWorkerQueue); - const PluginPtr &Plugin = Queue->getPlugin(); + const AdapterPtr &Adapter = Queue->getAdapter(); if (MEvent != nullptr) MEvent->setHostEnqueueTime(); - Plugin->call( + Adapter->call( Queue->getHandleRef(), RawEvents.size(), &RawEvents[0], &Event); } } @@ -1427,7 +1427,7 @@ void UnMapMemObject::emitInstrumentationData() { bool UnMapMemObject::producesPiEvent() const { // TODO remove this workaround once the batching issue is addressed in Level - // Zero plugin. + // Zero adapter. // Consider the following scenario on Level Zero: // 1. Kernel A, which uses buffer A, is submitted to queue A. // 2. Kernel B, which uses buffer B, is submitted to queue B. @@ -1435,10 +1435,10 @@ bool UnMapMemObject::producesPiEvent() const { // 4. queueB.wait(). // DPCPP runtime used to treat unmap/write commands for buffer A/B as host // dependencies (i.e. they were waited for prior to enqueueing any command - // that's dependent on them). This allowed Level Zero plugin to detect that + // that's dependent on them). This allowed Level Zero adapter to detect that // each queue is idle on steps 1/2 and submit the command list right away. // This is no longer the case since we started passing these dependencies in - // an event waitlist and Level Zero plugin attempts to batch these commands, + // an event waitlist and Level Zero adapter attempts to batch these commands, // so the execution of kernel B starts only on step 4. This workaround // restores the old behavior in this case until this is resolved. return MQueue && (MQueue->getDeviceImplPtr()->getBackend() != @@ -1529,7 +1529,7 @@ ContextImplPtr MemCpyCommand::getWorkerContext() const { bool MemCpyCommand::producesPiEvent() const { // TODO remove this workaround once the batching issue is addressed in Level - // Zero plugin. + // Zero adapter. // Consider the following scenario on Level Zero: // 1. Kernel A, which uses buffer A, is submitted to queue A. // 2. Kernel B, which uses buffer B, is submitted to queue B. @@ -1537,10 +1537,10 @@ bool MemCpyCommand::producesPiEvent() const { // 4. queueB.wait(). // DPCPP runtime used to treat unmap/write commands for buffer A/B as host // dependencies (i.e. they were waited for prior to enqueueing any command - // that's dependent on them). This allowed Level Zero plugin to detect that + // that's dependent on them). This allowed Level Zero adapter to detect that // each queue is idle on steps 1/2 and submit the command list right away. // This is no longer the case since we started passing these dependencies in - // an event waitlist and Level Zero plugin attempts to batch these commands, + // an event waitlist and Level Zero adapter attempts to batch these commands, // so the execution of kernel B starts only on step 4. This workaround // restores the old behavior in this case until this is resolved. return !MQueue || @@ -2229,7 +2229,7 @@ static void adjustNDRangePerKernel(NDRDescT &NDR, ur_kernel_handle_t Kernel, // avoid get_kernel_work_group_info on every kernel run range<3> WGSize = get_kernel_device_specific_info< sycl::info::kernel_device_specific::compile_work_group_size>( - Kernel, DeviceImpl.getHandleRef(), DeviceImpl.getPlugin()); + Kernel, DeviceImpl.getHandleRef(), DeviceImpl.getAdapter()); if (WGSize[0] == 0) { WGSize = {1, 1, 1}; @@ -2268,7 +2268,7 @@ ur_mem_flags_t AccessModeToUr(access::mode AccessorMode) { } void SetArgBasedOnType( - const PluginPtr &Plugin, ur_kernel_handle_t Kernel, + const AdapterPtr &Adapter, ur_kernel_handle_t Kernel, const std::shared_ptr &DeviceImageImpl, const std::function &getMemAllocationFunc, const sycl::context &Context, detail::ArgDesc &Arg, size_t NextTrueIndex) { @@ -2289,17 +2289,17 @@ void SetArgBasedOnType( ur_kernel_arg_mem_obj_properties_t MemObjData{}; MemObjData.stype = UR_STRUCTURE_TYPE_KERNEL_ARG_MEM_OBJ_PROPERTIES; MemObjData.memoryAccess = AccessModeToUr(Req->MAccessMode); - Plugin->call(Kernel, NextTrueIndex, - &MemObjData, MemArg); + Adapter->call(Kernel, NextTrueIndex, + &MemObjData, MemArg); break; } case kernel_param_kind_t::kind_std_layout: { if (Arg.MPtr) { - Plugin->call( + Adapter->call( Kernel, NextTrueIndex, Arg.MSize, nullptr, Arg.MPtr); } else { - Plugin->call(Kernel, NextTrueIndex, - Arg.MSize, nullptr); + Adapter->call(Kernel, NextTrueIndex, + Arg.MSize, nullptr); } break; @@ -2309,16 +2309,16 @@ void SetArgBasedOnType( ur_sampler_handle_t Sampler = (ur_sampler_handle_t)detail::getSyclObjImpl(*SamplerPtr) ->getOrCreateSampler(Context); - Plugin->call(Kernel, NextTrueIndex, - nullptr, Sampler); + Adapter->call(Kernel, NextTrueIndex, + nullptr, Sampler); break; } case kernel_param_kind_t::kind_pointer: { // We need to de-rerence this to get the actual USM allocation - that's the // pointer UR is expecting. const void *Ptr = *static_cast(Arg.MPtr); - Plugin->call(Kernel, NextTrueIndex, - nullptr, Ptr); + Adapter->call(Kernel, NextTrueIndex, + nullptr, Ptr); break; } case kernel_param_kind_t::kind_specialization_constants_buffer: { @@ -2330,7 +2330,7 @@ void SetArgBasedOnType( MemObjProps.pNext = nullptr; MemObjProps.stype = UR_STRUCTURE_TYPE_KERNEL_ARG_MEM_OBJ_PROPERTIES; MemObjProps.memoryAccess = UR_MEM_FLAG_READ_ONLY; - Plugin->call( + Adapter->call( Kernel, NextTrueIndex, &MemObjProps, SpecConstsBuffer); break; } @@ -2353,7 +2353,7 @@ static ur_result_t SetKernelParamsAndLaunch( bool IsCooperative, bool KernelUsesClusterLaunch, const RTDeviceBinaryImage *BinImage, const std::string &KernelName) { assert(Queue && "Kernel submissions should have an associated queue"); - const PluginPtr &Plugin = Queue->getPlugin(); + const AdapterPtr &Adapter = Queue->getAdapter(); if (SYCLConfig::get()) { std::vector Empty; @@ -2363,9 +2363,9 @@ static ur_result_t SetKernelParamsAndLaunch( : Empty); } - auto setFunc = [&Plugin, Kernel, &DeviceImageImpl, &getMemAllocationFunc, + auto setFunc = [&Adapter, Kernel, &DeviceImageImpl, &getMemAllocationFunc, &Queue](detail::ArgDesc &Arg, size_t NextTrueIndex) { - SetArgBasedOnType(Plugin, Kernel, DeviceImageImpl, getMemAllocationFunc, + SetArgBasedOnType(Adapter, Kernel, DeviceImageImpl, getMemAllocationFunc, Queue->get_context(), Arg, NextTrueIndex); }; @@ -2384,7 +2384,7 @@ static ur_result_t SetKernelParamsAndLaunch( if (HasLocalSize) LocalSize = &NDRDesc.LocalSize[0]; else { - Plugin->call( + Adapter->call( Kernel, Queue->getDeviceImplPtr()->getHandleRef(), UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE, sizeof(RequiredWGSize), RequiredWGSize, @@ -2421,7 +2421,7 @@ static ur_result_t SetKernelParamsAndLaunch( ur_event_handle_t UREvent = nullptr; ur_result_t Error = - Plugin->call_nocheck( + Adapter->call_nocheck( Queue->getHandleRef(), Kernel, NDRDesc.Dims, &NDRDesc.GlobalSize[0], LocalSize, property_list.size(), property_list.data(), RawEvents.size(), RawEvents.empty() ? nullptr : &RawEvents[0], @@ -2435,11 +2435,11 @@ static ur_result_t SetKernelParamsAndLaunch( ur_result_t Error = [&](auto... Args) { if (IsCooperative) { - return Plugin + return Adapter ->call_nocheck( Args...); } - return Plugin->call_nocheck(Args...); + return Adapter->call_nocheck(Args...); }(Queue->getHandleRef(), Kernel, NDRDesc.Dims, &NDRDesc.GlobalOffset[0], &NDRDesc.GlobalSize[0], LocalSize, RawEvents.size(), RawEvents.empty() ? nullptr : &RawEvents[0], @@ -2460,7 +2460,7 @@ ur_result_t enqueueImpCommandBufferKernel( ur_exp_command_buffer_command_handle_t *OutCommand, const std::function &getMemAllocationFunc) { auto ContextImpl = sycl::detail::getSyclObjImpl(Ctx); - const sycl::detail::PluginPtr &Plugin = ContextImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = ContextImpl->getAdapter(); ur_kernel_handle_t UrKernel = nullptr; ur_program_handle_t UrProgram = nullptr; std::shared_ptr SyclKernelImpl = nullptr; @@ -2496,10 +2496,10 @@ ur_result_t enqueueImpCommandBufferKernel( ContextImpl, DeviceImpl, CommandGroup.MKernelName); } - auto SetFunc = [&Plugin, &UrKernel, &DeviceImageImpl, &Ctx, + auto SetFunc = [&Adapter, &UrKernel, &DeviceImageImpl, &Ctx, &getMemAllocationFunc](sycl::detail::ArgDesc &Arg, size_t NextTrueIndex) { - sycl::detail::SetArgBasedOnType(Plugin, UrKernel, DeviceImageImpl, + sycl::detail::SetArgBasedOnType(Adapter, UrKernel, DeviceImageImpl, getMemAllocationFunc, Ctx, Arg, NextTrueIndex); }; @@ -2521,7 +2521,7 @@ ur_result_t enqueueImpCommandBufferKernel( if (HasLocalSize) LocalSize = &NDRDesc.LocalSize[0]; else { - Plugin->call( + Adapter->call( UrKernel, DeviceImpl->getHandleRef(), UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE, sizeof(RequiredWGSize), RequiredWGSize, @@ -2535,15 +2535,15 @@ ur_result_t enqueueImpCommandBufferKernel( } ur_result_t Res = - Plugin->call_nocheck( + Adapter->call_nocheck( CommandBuffer, UrKernel, NDRDesc.Dims, &NDRDesc.GlobalOffset[0], &NDRDesc.GlobalSize[0], LocalSize, SyncPoints.size(), SyncPoints.size() ? SyncPoints.data() : nullptr, OutSyncPoint, OutCommand); if (!SyclKernelImpl && !Kernel) { - Plugin->call(UrKernel); - Plugin->call(UrProgram); + Adapter->call(UrKernel); + Adapter->call(UrProgram); } if (Res != UR_RESULT_SUCCESS) { @@ -2646,8 +2646,8 @@ void enqueueImpKernel( // provided. if (KernelCacheConfig == UR_KERNEL_CACHE_CONFIG_LARGE_SLM || KernelCacheConfig == UR_KERNEL_CACHE_CONFIG_LARGE_DATA) { - const PluginPtr &Plugin = Queue->getPlugin(); - Plugin->call( + const AdapterPtr &Adapter = Queue->getAdapter(); + Adapter->call( Kernel, UR_KERNEL_EXEC_INFO_CACHE_CONFIG, sizeof(ur_kernel_cache_config_t), nullptr, &KernelCacheConfig); } @@ -2657,10 +2657,10 @@ void enqueueImpKernel( OutEventImpl, EliminatedArgMask, getMemAllocationFunc, KernelIsCooperative, KernelUsesClusterLaunch, BinImage, KernelName); - const PluginPtr &Plugin = Queue->getPlugin(); + const AdapterPtr &Adapter = Queue->getAdapter(); if (!SyclKernelImpl && !MSyclKernel) { - Plugin->call(Kernel); - Plugin->call(Program); + Adapter->call(Kernel); + Adapter->call(Program); } } if (UR_RESULT_SUCCESS != Error) { @@ -2702,7 +2702,7 @@ ur_result_t enqueueReadWriteHostPipe(const QueueImplPtr &Queue, } assert(Program && "Program for this hostpipe is not compiled."); - const PluginPtr &Plugin = Queue->getPlugin(); + const AdapterPtr &Adapter = Queue->getAdapter(); ur_queue_handle_t ur_q = Queue->getHandleRef(); ur_result_t Error; @@ -2712,11 +2712,11 @@ ur_result_t enqueueReadWriteHostPipe(const QueueImplPtr &Queue, if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); if (read) { - Error = Plugin->call_nocheck( + Error = Adapter->call_nocheck( ur_q, Program, PipeName.c_str(), blocking, ptr, size, RawEvents.size(), RawEvents.empty() ? nullptr : &RawEvents[0], OutEvent); } else { - Error = Plugin->call_nocheck( + Error = Adapter->call_nocheck( ur_q, Program, PipeName.c_str(), blocking, ptr, size, RawEvents.size(), RawEvents.empty() ? nullptr : &RawEvents[0], OutEvent); } @@ -2738,8 +2738,8 @@ ur_result_t ExecCGCommand::enqueueImpCommandBuffer() { flushCrossQueueDeps(EventImpls, MWorkerQueue); std::vector RawEvents = getUrEvents(EventImpls); if (!RawEvents.empty()) { - MQueue->getPlugin()->call(RawEvents.size(), - &RawEvents[0]); + MQueue->getAdapter()->call(RawEvents.size(), + &RawEvents[0]); } ur_exp_command_buffer_sync_point_t OutSyncPoint; @@ -3193,13 +3193,13 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { ur_bool_t NativeCommandSupport = false; assert(MQueue && "Native command should have an associated queue"); - MQueue->getPlugin()->call( + MQueue->getAdapter()->call( detail::getSyclObjImpl(MQueue->get_device())->getHandleRef(), UR_DEVICE_INFO_ENQUEUE_NATIVE_COMMAND_SUPPORT_EXP, sizeof(NativeCommandSupport), &NativeCommandSupport, nullptr); assert(NativeCommandSupport && "ext_codeplay_enqueue_native_command is not " "supported on this device"); - MQueue->getPlugin()->call( + MQueue->getAdapter()->call( MQueue->getHandleRef(), InteropFreeFunc, &CustomOpData, ReqMems.size(), ReqMems.data(), nullptr, RawEvents.size(), RawEvents.data(), Event); if (Event) @@ -3208,10 +3208,10 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { } case CGType::Barrier: { assert(MQueue && "Barrier submission should have an associated queue"); - const PluginPtr &Plugin = MQueue->getPlugin(); + const AdapterPtr &Adapter = MQueue->getAdapter(); if (MEvent != nullptr) MEvent->setHostEnqueueTime(); - Plugin->call( + Adapter->call( MQueue->getHandleRef(), 0, nullptr, Event); if (Event) MEvent->setHandle(*Event); @@ -3226,10 +3226,10 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { // If Events is empty, then the barrier has no effect. return UR_RESULT_SUCCESS; } - const PluginPtr &Plugin = MQueue->getPlugin(); + const AdapterPtr &Adapter = MQueue->getAdapter(); if (MEvent != nullptr) MEvent->setHostEnqueueTime(); - Plugin->call( + Adapter->call( MQueue->getHandleRef(), UrEvents.size(), &UrEvents[0], Event); if (Event) MEvent->setHandle(*Event); @@ -3237,7 +3237,7 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { } case CGType::ProfilingTag: { assert(MQueue && "Profiling tag requires a valid queue"); - const auto &Plugin = MQueue->getPlugin(); + const auto &Adapter = MQueue->getAdapter(); // If the queue is not in-order, we need to insert a barrier. This barrier // does not need output events as it will implicitly enforce the following // enqueue is blocked until it finishes. @@ -3246,14 +3246,14 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { // not pass an output event to the UR call. Once that is fixed, // this immediately-deleted event can be removed. ur_event_handle_t PreTimestampBarrierEvent{}; - Plugin->call( + Adapter->call( MQueue->getHandleRef(), /*num_events_in_wait_list=*/0, /*event_wait_list=*/nullptr, &PreTimestampBarrierEvent); - Plugin->call(PreTimestampBarrierEvent); + Adapter->call(PreTimestampBarrierEvent); } - Plugin->call( + Adapter->call( MQueue->getHandleRef(), /*blocking=*/false, /*num_events_in_wait_list=*/0, /*event_wait_list=*/nullptr, Event); @@ -3305,10 +3305,11 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { if (MEvent != nullptr) MEvent->setHostEnqueueTime(); ur_result_t Err = - MQueue->getPlugin()->call_nocheck( - CmdBufferCG->MCommandBuffer, MQueue->getHandleRef(), - RawEvents.size(), RawEvents.empty() ? nullptr : &RawEvents[0], - Event); + MQueue->getAdapter() + ->call_nocheck( + CmdBufferCG->MCommandBuffer, MQueue->getHandleRef(), + RawEvents.size(), RawEvents.empty() ? nullptr : &RawEvents[0], + Event); if (Event) MEvent->setHandle(*Event); @@ -3331,10 +3332,10 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { assert(MQueue && "Semaphore wait submissions should have an associated queue"); CGSemaphoreWait *SemWait = (CGSemaphoreWait *)MCommandGroup.get(); - const detail::PluginPtr &Plugin = MQueue->getPlugin(); + const detail::AdapterPtr &Adapter = MQueue->getAdapter(); auto OptWaitValue = SemWait->getWaitValue(); uint64_t WaitValue = OptWaitValue.has_value() ? OptWaitValue.value() : 0; - Plugin->call( + Adapter->call( MQueue->getHandleRef(), SemWait->getExternalSemaphore(), OptWaitValue.has_value(), WaitValue, 0, nullptr, nullptr); @@ -3344,11 +3345,11 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { assert(MQueue && "Semaphore signal submissions should have an associated queue"); CGSemaphoreSignal *SemSignal = (CGSemaphoreSignal *)MCommandGroup.get(); - const detail::PluginPtr &Plugin = MQueue->getPlugin(); + const detail::AdapterPtr &Adapter = MQueue->getAdapter(); auto OptSignalValue = SemSignal->getSignalValue(); uint64_t SignalValue = OptSignalValue.has_value() ? OptSignalValue.value() : 0; - Plugin->call( + Adapter->call( MQueue->getHandleRef(), SemSignal->getExternalSemaphore(), OptSignalValue.has_value(), SignalValue, 0, nullptr, nullptr); diff --git a/sycl/source/detail/scheduler/commands.hpp b/sycl/source/detail/scheduler/commands.hpp index 66283cb56bb16..8324c1d13fb30 100644 --- a/sycl/source/detail/scheduler/commands.hpp +++ b/sycl/source/detail/scheduler/commands.hpp @@ -741,7 +741,7 @@ ur_result_t enqueueImpCommandBufferKernel( // Refactored from SetKernelParamsAndLaunch to allow it to be used in the graphs // extension. void SetArgBasedOnType( - const detail::PluginPtr &Plugin, ur_kernel_handle_t Kernel, + const detail::AdapterPtr &Adapter, ur_kernel_handle_t Kernel, const std::shared_ptr &DeviceImageImpl, const std::function &getMemAllocationFunc, const sycl::context &Context, detail::ArgDesc &Arg, size_t NextTrueIndex); diff --git a/sycl/source/detail/scheduler/graph_builder.cpp b/sycl/source/detail/scheduler/graph_builder.cpp index 2afed97140448..5f95995e279d7 100644 --- a/sycl/source/detail/scheduler/graph_builder.cpp +++ b/sycl/source/detail/scheduler/graph_builder.cpp @@ -754,7 +754,7 @@ AllocaCommandBase *Scheduler::GraphBuilder::getOrCreateAllocaForReq( // Can setup link between cl and host allocations only if ((Context == nullptr) != (Record->MCurContext == nullptr)) { // Linked commands assume that the host allocation is reused by the - // plugin runtime and that can lead to unnecessary copy overhead on + // unified runtime and that can lead to unnecessary copy overhead on // devices that do not support host unified memory. Do not link the // allocations in this case. // However, if the user explicitly requests use of pinned host diff --git a/sycl/source/detail/sycl_mem_obj_t.cpp b/sycl/source/detail/sycl_mem_obj_t.cpp index 6d5e9f7712de3..25e092232ae7f 100644 --- a/sycl/source/detail/sycl_mem_obj_t.cpp +++ b/sycl/source/detail/sycl_mem_obj_t.cpp @@ -6,10 +6,10 @@ // //===----------------------------------------------------------------------===// +#include #include #include #include -#include #include #include @@ -36,20 +36,21 @@ SYCLMemObjT::SYCLMemObjT(ur_native_handle_t MemObject, MSharedPtrStorage(nullptr), MHostPtrProvided(true), MOwnNativeHandle(OwnNativeHandle) { ur_context_handle_t Context = nullptr; - const PluginPtr &Plugin = getPlugin(); + const AdapterPtr &Adapter = getAdapter(); ur_mem_native_properties_t MemProperties = { UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES, nullptr, OwnNativeHandle}; - Plugin->call( + Adapter->call( MemObject, MInteropContext->getHandleRef(), &MemProperties, &MInteropMemObject); // Get the size of the buffer in bytes - Plugin->call(MInteropMemObject, UR_MEM_INFO_SIZE, - sizeof(size_t), &MSizeInBytes, nullptr); + Adapter->call(MInteropMemObject, UR_MEM_INFO_SIZE, + sizeof(size_t), &MSizeInBytes, + nullptr); - Plugin->call(MInteropMemObject, UR_MEM_INFO_CONTEXT, - sizeof(Context), &Context, nullptr); + Adapter->call(MInteropMemObject, UR_MEM_INFO_CONTEXT, + sizeof(Context), &Context, nullptr); if (MInteropContext->getHandleRef() != Context) throw sycl::exception( @@ -57,7 +58,7 @@ SYCLMemObjT::SYCLMemObjT(ur_native_handle_t MemObject, "Input context must be the same as the context of cl_mem"); if (MInteropContext->getBackend() == backend::opencl) - Plugin->call(MInteropMemObject); + Adapter->call(MInteropMemObject); } ur_mem_type_t getImageType(int Dimensions) { @@ -82,7 +83,7 @@ SYCLMemObjT::SYCLMemObjT(ur_native_handle_t MemObject, MSharedPtrStorage(nullptr), MHostPtrProvided(true), MOwnNativeHandle(OwnNativeHandle) { ur_context_handle_t Context = nullptr; - const PluginPtr &Plugin = getPlugin(); + const AdapterPtr &Adapter = getAdapter(); ur_image_desc_t Desc = {}; Desc.stype = UR_STRUCTURE_TYPE_IMAGE_DESC; @@ -99,12 +100,12 @@ SYCLMemObjT::SYCLMemObjT(ur_native_handle_t MemObject, ur_mem_native_properties_t NativeProperties = { UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES, nullptr, OwnNativeHandle}; - Plugin->call( + Adapter->call( MemObject, MInteropContext->getHandleRef(), &Format, &Desc, &NativeProperties, &MInteropMemObject); - Plugin->call(MInteropMemObject, UR_MEM_INFO_CONTEXT, - sizeof(Context), &Context, nullptr); + Adapter->call(MInteropMemObject, UR_MEM_INFO_CONTEXT, + sizeof(Context), &Context, nullptr); if (MInteropContext->getHandleRef() != Context) throw sycl::exception( @@ -112,7 +113,7 @@ SYCLMemObjT::SYCLMemObjT(ur_native_handle_t MemObject, "Input context must be the same as the context of cl_mem"); if (MInteropContext->getBackend() == backend::opencl) - Plugin->call(MInteropMemObject); + Adapter->call(MInteropMemObject); } void SYCLMemObjT::releaseMem(ContextImplPtr Context, void *MemAllocation) { @@ -154,22 +155,22 @@ void SYCLMemObjT::updateHostMemory() { releaseHostMem(MShadowCopy); if (MOpenCLInterop) { - const PluginPtr &Plugin = getPlugin(); - Plugin->call(MInteropMemObject); + const AdapterPtr &Adapter = getAdapter(); + Adapter->call(MInteropMemObject); } } -const PluginPtr &SYCLMemObjT::getPlugin() const { +const AdapterPtr &SYCLMemObjT::getAdapter() const { assert((MInteropContext != nullptr) && - "Trying to get Plugin from SYCLMemObjT with nullptr ContextImpl."); - return (MInteropContext->getPlugin()); + "Trying to get Adapter from SYCLMemObjT with nullptr ContextImpl."); + return (MInteropContext->getAdapter()); } size_t SYCLMemObjT::getBufSizeForContext(const ContextImplPtr &Context, ur_native_handle_t MemObject) { size_t BufSize = 0; - const PluginPtr &Plugin = Context->getPlugin(); + const AdapterPtr &Adapter = Context->getAdapter(); // TODO is there something required to support non-OpenCL backends? - Plugin->call( + Adapter->call( detail::ur::cast(MemObject), UR_MEM_INFO_SIZE, sizeof(size_t), &BufSize, nullptr); return BufSize; diff --git a/sycl/source/detail/sycl_mem_obj_t.hpp b/sycl/source/detail/sycl_mem_obj_t.hpp index 358d7dcc7d214..5082597ce14f8 100644 --- a/sycl/source/detail/sycl_mem_obj_t.hpp +++ b/sycl/source/detail/sycl_mem_obj_t.hpp @@ -33,7 +33,7 @@ namespace detail { // Forward declarations class context_impl; class event_impl; -class plugin; +class Adapter; using ContextImplPtr = std::shared_ptr; using EventImplPtr = std::shared_ptr; @@ -90,7 +90,7 @@ class SYCLMemObjT : public SYCLMemObjI { virtual ~SYCLMemObjT() = default; - const PluginPtr &getPlugin() const; + const AdapterPtr &getAdapter() const; size_t getSizeInBytes() const noexcept override { return MSizeInBytes; } __SYCL2020_DEPRECATED("get_count() is deprecated, please use size() instead") diff --git a/sycl/source/detail/ur.cpp b/sycl/source/detail/ur.cpp index fb70b92e3b29f..867cc7a899b90 100644 --- a/sycl/source/detail/ur.cpp +++ b/sycl/source/detail/ur.cpp @@ -13,9 +13,9 @@ /// \ingroup sycl_ur #include "context_impl.hpp" +#include #include #include -#include #include #include #include @@ -49,8 +49,8 @@ void contextSetExtendedDeleter(const sycl::context &context, pi_context_extended_deleter func, void *user_data) { auto impl = getSyclObjImpl(context); - const auto &Plugin = impl->getPlugin(); - Plugin->call( + const auto &Adapter = impl->getAdapter(); + Adapter->call( impl->getHandleRef(), reinterpret_cast(func), user_data); } @@ -64,11 +64,11 @@ xpti_td *GSYCLGraphEvent = nullptr; #endif // XPTI_ENABLE_INSTRUMENTATION template -void *getPluginOpaqueData([[maybe_unused]] void *OpaqueDataParam) { - // This was formerly a call to piextPluginGetOpaqueData, a deprecated PI entry - // point introduced for the now deleted ESIMD plugin. All calls to this entry - // point returned a similar error code to INVALID_OPERATION and would have - // resulted in a similar throw to this one +void *getAdapterOpaqueData([[maybe_unused]] void *OpaqueDataParam) { + // This was formerly a call to piextAdapterGetOpaqueData, a deprecated PI + // entry point introduced for the now deleted ESIMD adapter. All calls to this + // entry point returned a similar error code to INVALID_OPERATION and would + // have resulted in a similar throw to this one throw exception( make_error_code(errc::feature_not_supported), "This operation is not supported by any existing backends."); @@ -83,13 +83,13 @@ bool trace(TraceLevel Level) { return (TraceLevelMask & Level) == Level; } -static void initializePlugins(std::vector &Plugins, - ur_loader_config_handle_t LoaderConfig); +static void initializeAdapters(std::vector &Adapters, + ur_loader_config_handle_t LoaderConfig); bool XPTIInitDone = false; -// Initializes all available Plugins. -std::vector &initializeUr(ur_loader_config_handle_t LoaderConfig) { +// Initializes all available Adapters. +std::vector &initializeUr(ur_loader_config_handle_t LoaderConfig) { // This uses static variable initialization to work around a gcc bug with // std::call_once and exceptions. // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66146 @@ -101,17 +101,17 @@ std::vector &initializeUr(ur_loader_config_handle_t LoaderConfig) { std::exit(1); } - initializePlugins(GlobalHandler::instance().getPlugins(), LoaderConfig); + initializeAdapters(GlobalHandler::instance().getAdapters(), LoaderConfig); return true; }; static bool Initialized = initializeHelper(); std::ignore = Initialized; - return GlobalHandler::instance().getPlugins(); + return GlobalHandler::instance().getAdapters(); } -static void initializePlugins(std::vector &Plugins, - ur_loader_config_handle_t LoaderConfig) { +static void initializeAdapters(std::vector &Adapters, + ur_loader_config_handle_t LoaderConfig) { #define CHECK_UR_SUCCESS(Call) __SYCL_CHECK_UR_CODE_NO_EXC(Call) UrFuncInfo loaderConfigCreateInfo; @@ -217,13 +217,13 @@ static void initializePlugins(std::vector &Plugins, } }; - for (const auto &adapter : adapters) { + for (const auto &UrAdapter : adapters) { ur_adapter_backend_t adapterBackend = UR_ADAPTER_BACKEND_UNKNOWN; - CHECK_UR_SUCCESS(adapterGetInfo(adapter, UR_ADAPTER_INFO_BACKEND, + CHECK_UR_SUCCESS(adapterGetInfo(UrAdapter, UR_ADAPTER_INFO_BACKEND, sizeof(adapterBackend), &adapterBackend, nullptr)); auto syclBackend = UrToSyclBackend(adapterBackend); - Plugins.emplace_back(std::make_shared(adapter, syclBackend)); + Adapters.emplace_back(std::make_shared(UrAdapter, syclBackend)); } #ifdef XPTI_ENABLE_INSTRUMENTATION @@ -238,12 +238,12 @@ static void initializePlugins(std::vector &Plugins, // Initialize the global events just once, in the case ur::initialize() is // called multiple times XPTIInitDone = true; - // Registers a new stream for 'sycl' and any plugin that wants to listen to - // this stream will register itself using this string or stream ID for this - // string. + // Registers a new stream for 'sycl' and any application that wants to listen + // to this stream will register itself using this string or stream ID for + // this string. uint8_t StreamID = xptiRegisterStream(SYCL_STREAM_NAME); - // Let all tool plugins know that a stream by the name of 'sycl' has been - // initialized and will be generating the trace stream. + // Let all tool applications know that a stream by the name of 'sycl' has + // been initialized and will be generating the trace stream. GlobalHandler::instance().getXPTIRegistry().initializeStream( SYCL_STREAM_NAME, GMajVer, GMinVer, GVerStr); // Create a tracepoint to indicate the graph creation @@ -262,26 +262,26 @@ static void initializePlugins(std::vector &Plugins, #undef CHECK_UR_SUCCESS } -// Get the plugin serving given backend. -template const PluginPtr &getPlugin() { - static PluginPtr *Plugin = nullptr; - if (Plugin) - return *Plugin; +// Get the adapter serving given backend. +template const AdapterPtr &getAdapter() { + static AdapterPtr *Adapter = nullptr; + if (Adapter) + return *Adapter; - std::vector &Plugins = ur::initializeUr(); - for (auto &P : Plugins) + std::vector &Adapters = ur::initializeUr(); + for (auto &P : Adapters) if (P->hasBackend(BE)) { - Plugin = &P; - return *Plugin; + Adapter = &P; + return *Adapter; } - throw exception(errc::runtime, "ur::getPlugin couldn't find plugin"); + throw exception(errc::runtime, "ur::getAdapter couldn't find adapter"); } -template const PluginPtr &getPlugin(); -template const PluginPtr &getPlugin(); -template const PluginPtr &getPlugin(); -template const PluginPtr &getPlugin(); +template const AdapterPtr &getAdapter(); +template const AdapterPtr &getAdapter(); +template const AdapterPtr &getAdapter(); +template const AdapterPtr &getAdapter(); // Reads an integer value from ELF data. template diff --git a/sycl/source/detail/ur_utils.hpp b/sycl/source/detail/ur_utils.hpp index e15e5c97a1472..020f20d718a45 100644 --- a/sycl/source/detail/ur_utils.hpp +++ b/sycl/source/detail/ur_utils.hpp @@ -8,8 +8,8 @@ #pragma once +#include #include -#include #include #include @@ -21,21 +21,21 @@ namespace detail { // RAII object for keeping ownership of a UR event. struct OwnedUrEvent { - OwnedUrEvent(const PluginPtr &Plugin) - : MEvent{std::nullopt}, MPlugin{Plugin} {} - OwnedUrEvent(ur_event_handle_t Event, const PluginPtr &Plugin, + OwnedUrEvent(const AdapterPtr &Adapter) + : MEvent{std::nullopt}, MAdapter{Adapter} {} + OwnedUrEvent(ur_event_handle_t Event, const AdapterPtr &Adapter, bool TakeOwnership = false) - : MEvent(Event), MPlugin(Plugin) { + : MEvent(Event), MAdapter(Adapter) { // If it is not instructed to take ownership, retain the event to share // ownership of it. if (!TakeOwnership) - MPlugin->call(*MEvent); + MAdapter->call(*MEvent); } ~OwnedUrEvent() { try { // Release the event if the ownership was not transferred. if (MEvent.has_value()) - MPlugin->call(*MEvent); + MAdapter->call(*MEvent); } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~OwnedUrEvent", e); @@ -43,7 +43,7 @@ struct OwnedUrEvent { } OwnedUrEvent(OwnedUrEvent &&Other) - : MEvent(Other.MEvent), MPlugin(Other.MPlugin) { + : MEvent(Other.MEvent), MAdapter(Other.MAdapter) { Other.MEvent = std::nullopt; } @@ -65,7 +65,7 @@ struct OwnedUrEvent { private: std::optional MEvent; - const PluginPtr &MPlugin; + const AdapterPtr &MAdapter; }; namespace ur { diff --git a/sycl/source/detail/usm/usm_impl.cpp b/sycl/source/detail/usm/usm_impl.cpp index f9f4ebf7beb07..74a54197e7640 100644 --- a/sycl/source/detail/usm/usm_impl.cpp +++ b/sycl/source/detail/usm/usm_impl.cpp @@ -65,7 +65,7 @@ void *alignedAllocHost(size_t Alignment, size_t Size, const sycl::context &Ctxt, std::shared_ptr CtxImpl = sycl::detail::getSyclObjImpl(Ctxt); ur_context_handle_t C = CtxImpl->getHandleRef(); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); ur_result_t Error = UR_RESULT_ERROR_INVALID_VALUE; ur_usm_desc_t UsmDesc{}; @@ -86,7 +86,7 @@ void *alignedAllocHost(size_t Alignment, size_t Size, const sycl::context &Ctxt, UsmDesc.pNext = &UsmLocationDesc; } - Error = Plugin->call_nocheck( + Error = Adapter->call_nocheck( C, &UsmDesc, /* pool= */ nullptr, Size, &RetVal); @@ -132,7 +132,7 @@ void *alignedAllocInternal(size_t Alignment, size_t Size, return nullptr; ur_context_handle_t C = CtxImpl->getHandleRef(); - const PluginPtr &Plugin = CtxImpl->getPlugin(); + const AdapterPtr &Adapter = CtxImpl->getAdapter(); ur_result_t Error = UR_RESULT_ERROR_INVALID_VALUE; ur_device_handle_t Dev; @@ -158,7 +158,7 @@ void *alignedAllocInternal(size_t Alignment, size_t Size, UsmDesc.pNext = &UsmLocationDesc; } - Error = Plugin->call_nocheck( + Error = Adapter->call_nocheck( C, Dev, &UsmDesc, /*pool=*/nullptr, Size, &RetVal); @@ -195,7 +195,7 @@ void *alignedAllocInternal(size_t Alignment, size_t Size, UsmDeviceDesc.pNext = &UsmLocationDesc; } - Error = Plugin->call_nocheck( + Error = Adapter->call_nocheck( C, Dev, &UsmDesc, /*pool=*/nullptr, Size, &RetVal); @@ -252,8 +252,8 @@ void freeInternal(void *Ptr, const context_impl *CtxImpl) { if (Ptr == nullptr) return; ur_context_handle_t C = CtxImpl->getHandleRef(); - const PluginPtr &Plugin = CtxImpl->getPlugin(); - Plugin->call(C, Ptr); + const AdapterPtr &Adapter = CtxImpl->getAdapter(); + Adapter->call(C, Ptr); } void free(void *Ptr, const context &Ctxt, @@ -531,9 +531,9 @@ alloc get_pointer_type(const void *Ptr, const context &Ctxt) { ur_usm_type_t AllocTy; // query type using UR function - const detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); ur_result_t Err = - Plugin->call_nocheck( + Adapter->call_nocheck( URCtx, Ptr, UR_USM_ALLOC_INFO_TYPE, sizeof(ur_usm_type_t), &AllocTy, nullptr); @@ -593,8 +593,8 @@ device get_pointer_device(const void *Ptr, const context &Ctxt) { ur_device_handle_t DeviceId; // query device using UR function - const detail::PluginPtr &Plugin = CtxImpl->getPlugin(); - Plugin->call( + const detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); + Adapter->call( URCtx, Ptr, UR_USM_ALLOC_INFO_DEVICE, sizeof(ur_device_handle_t), &DeviceId, nullptr); @@ -616,8 +616,8 @@ static void prepare_for_usm_device_copy(const void *Ptr, size_t Size, std::shared_ptr CtxImpl = detail::getSyclObjImpl(Ctxt); ur_context_handle_t URCtx = CtxImpl->getHandleRef(); // Call the UR function - const detail::PluginPtr &Plugin = CtxImpl->getPlugin(); - Plugin->call( + const detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); + Adapter->call( URCtx, const_cast(Ptr), Size); } @@ -625,9 +625,9 @@ static void release_from_usm_device_copy(const void *Ptr, const context &Ctxt) { std::shared_ptr CtxImpl = detail::getSyclObjImpl(Ctxt); ur_context_handle_t URCtx = CtxImpl->getHandleRef(); // Call the UR function - const detail::PluginPtr &Plugin = CtxImpl->getPlugin(); - Plugin->call(URCtx, - const_cast(Ptr)); + const detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); + Adapter->call(URCtx, + const_cast(Ptr)); } namespace ext::oneapi::experimental { diff --git a/sycl/source/device.cpp b/sycl/source/device.cpp index 1a4d1cb9c4a75..fe83f60585f2e 100644 --- a/sycl/source/device.cpp +++ b/sycl/source/device.cpp @@ -33,17 +33,17 @@ void force_type(info::device_type &t, const info::device_type &ft) { device::device() : device(default_selector_v) {} device::device(cl_device_id DeviceId) { - auto Plugin = sycl::detail::ur::getPlugin(); + auto Adapter = sycl::detail::ur::getAdapter(); // The implementation constructor takes ownership of the native handle so we // must retain it in order to adhere to SYCL 1.2.1 spec (Rev6, section 4.3.1.) ur_device_handle_t Device; - Plugin->call( - detail::ur::cast(DeviceId), Plugin->getUrAdapter(), + Adapter->call( + detail::ur::cast(DeviceId), Adapter->getUrAdapter(), nullptr, &Device); auto Platform = - detail::platform_impl::getPlatformFromUrDevice(Device, Plugin); + detail::platform_impl::getPlatformFromUrDevice(Device, Adapter); impl = Platform->getOrMakeDeviceImpl(Device, Platform); - Plugin->call(impl->getHandleRef()); + Adapter->call(impl->getHandleRef()); } device::device(const device_selector &deviceSelector) { @@ -210,8 +210,8 @@ void device::ext_oneapi_enable_peer_access(const device &peer) { ur_device_handle_t Device = impl->getHandleRef(); ur_device_handle_t Peer = peer.impl->getHandleRef(); if (Device != Peer) { - auto Plugin = impl->getPlugin(); - Plugin->call(Device, Peer); + auto Adapter = impl->getAdapter(); + Adapter->call(Device, Peer); } } @@ -219,8 +219,9 @@ void device::ext_oneapi_disable_peer_access(const device &peer) { ur_device_handle_t Device = impl->getHandleRef(); ur_device_handle_t Peer = peer.impl->getHandleRef(); if (Device != Peer) { - auto Plugin = impl->getPlugin(); - Plugin->call(Device, Peer); + auto Adapter = impl->getAdapter(); + Adapter->call(Device, + Peer); } } @@ -246,11 +247,11 @@ bool device::ext_oneapi_can_access_peer(const device &peer, throw sycl::exception(make_error_code(errc::invalid), "Unrecognized peer access attribute."); }(); - auto Plugin = impl->getPlugin(); - Plugin->call( + auto Adapter = impl->getAdapter(); + Adapter->call( Device, Peer, UrAttr, 0, nullptr, &returnSize); - Plugin->call( + Adapter->call( Device, Peer, UrAttr, returnSize, &value, nullptr); return value == 1; @@ -274,9 +275,9 @@ bool device::ext_oneapi_can_compile( bool device::ext_oneapi_supports_cl_c_feature(detail::string_view Feature) { ur_device_handle_t Device = impl->getHandleRef(); - auto Plugin = impl->getPlugin(); + auto Adapter = impl->getAdapter(); uint32_t ipVersion = 0; - auto res = Plugin->call_nocheck( + auto res = Adapter->call_nocheck( Device, UR_DEVICE_INFO_IP_VERSION, sizeof(uint32_t), &ipVersion, nullptr); if (res != UR_RESULT_SUCCESS) return false; @@ -288,9 +289,9 @@ bool device::ext_oneapi_supports_cl_c_feature(detail::string_view Feature) { bool device::ext_oneapi_supports_cl_c_version( const ext::oneapi::experimental::cl_version &Version) const { ur_device_handle_t Device = impl->getHandleRef(); - auto Plugin = impl->getPlugin(); + auto Adapter = impl->getAdapter(); uint32_t ipVersion = 0; - auto res = Plugin->call_nocheck( + auto res = Adapter->call_nocheck( Device, UR_DEVICE_INFO_IP_VERSION, sizeof(uint32_t), &ipVersion, nullptr); if (res != UR_RESULT_SUCCESS) return false; @@ -303,9 +304,9 @@ bool device::ext_oneapi_supports_cl_extension( detail::string_view Name, ext::oneapi::experimental::cl_version *VersionPtr) const { ur_device_handle_t Device = impl->getHandleRef(); - auto Plugin = impl->getPlugin(); + auto Adapter = impl->getAdapter(); uint32_t ipVersion = 0; - auto res = Plugin->call_nocheck( + auto res = Adapter->call_nocheck( Device, UR_DEVICE_INFO_IP_VERSION, sizeof(uint32_t), &ipVersion, nullptr); if (res != UR_RESULT_SUCCESS) return false; @@ -316,9 +317,9 @@ bool device::ext_oneapi_supports_cl_extension( detail::string device::ext_oneapi_cl_profile_impl() const { ur_device_handle_t Device = impl->getHandleRef(); - auto Plugin = impl->getPlugin(); + auto Adapter = impl->getAdapter(); uint32_t ipVersion = 0; - auto res = Plugin->call_nocheck( + auto res = Adapter->call_nocheck( Device, UR_DEVICE_INFO_IP_VERSION, sizeof(uint32_t), &ipVersion, nullptr); if (res != UR_RESULT_SUCCESS) return detail::string{""}; diff --git a/sycl/source/event.cpp b/sycl/source/event.cpp index c1cd030f68412..df68777ca6df4 100644 --- a/sycl/source/event.cpp +++ b/sycl/source/event.cpp @@ -30,7 +30,7 @@ event::event(cl_event ClEvent, const context &SyclContext) // This is a special interop constructor for OpenCL, so the event must be // retained. // TODO(pi2ur): Don't just cast from cl_event above - impl->getPlugin()->call( + impl->getAdapter()->call( detail::ur::cast(ClEvent)); } diff --git a/sycl/source/handler.cpp b/sycl/source/handler.cpp index 6be86b9696436..a7b66235b6653 100644 --- a/sycl/source/handler.cpp +++ b/sycl/source/handler.cpp @@ -1628,11 +1628,11 @@ void handler::depends_on(const std::vector &Events) { static bool checkContextSupports(const std::shared_ptr &ContextImpl, ur_context_info_t InfoQuery) { - auto &Plugin = ContextImpl->getPlugin(); + auto &Adapter = ContextImpl->getAdapter(); ur_bool_t SupportsOp = false; - Plugin->call(ContextImpl->getHandleRef(), - InfoQuery, sizeof(ur_bool_t), - &SupportsOp, nullptr); + Adapter->call(ContextImpl->getHandleRef(), + InfoQuery, sizeof(ur_bool_t), + &SupportsOp, nullptr); return SupportsOp; } @@ -1866,7 +1866,7 @@ void handler::setUserFacingNodeType(ext::oneapi::experimental::node_type Type) { std::optional> handler::getMaxWorkGroups() { auto Dev = detail::getSyclObjImpl(detail::getDeviceFromHandler(*this)); std::array UrResult = {}; - auto Ret = Dev->getPlugin()->call_nocheck( + auto Ret = Dev->getAdapter()->call_nocheck( Dev->getHandleRef(), UrInfoCode< ext::oneapi::experimental::info::device::max_work_groups<3>>::value, diff --git a/sycl/source/interop_handle.cpp b/sycl/source/interop_handle.cpp index fa5f5910a2e6a..aabf22702ef5f 100644 --- a/sycl/source/interop_handle.cpp +++ b/sycl/source/interop_handle.cpp @@ -33,9 +33,9 @@ interop_handle::getNativeMem(detail::Requirement *Req) const { "Invalid memory object used inside interop"); } - auto Plugin = MQueue->getPlugin(); + auto Adapter = MQueue->getAdapter(); ur_native_handle_t Handle; - Plugin->call( + Adapter->call( Iter->second, MDevice->getHandleRef(), &Handle); return Handle; } diff --git a/sycl/source/kernel.cpp b/sycl/source/kernel.cpp index a4aae60bece08..45da7d87270e9 100644 --- a/sycl/source/kernel.cpp +++ b/sycl/source/kernel.cpp @@ -18,11 +18,11 @@ inline namespace _V1 { // TODO(pi2ur): Don't cast straight from cl_kernel below kernel::kernel(cl_kernel ClKernel, const context &SyclContext) { - auto Plugin = sycl::detail::ur::getPlugin(); + auto Adapter = sycl::detail::ur::getAdapter(); ur_kernel_handle_t hKernel = nullptr; ur_native_handle_t nativeHandle = reinterpret_cast(ClKernel); - Plugin->call( + Adapter->call( nativeHandle, detail::getSyclObjImpl(SyclContext)->getHandleRef(), nullptr, nullptr, &hKernel); impl = std::make_shared( @@ -30,7 +30,7 @@ kernel::kernel(cl_kernel ClKernel, const context &SyclContext) { // This is a special interop constructor for OpenCL, so the kernel must be // retained. if (get_backend() == backend::opencl) { - impl->getPlugin()->call(hKernel); + impl->getAdapter()->call(hKernel); } } diff --git a/sycl/source/platform.cpp b/sycl/source/platform.cpp index b9ec5073fb7ea..965a8625c1ebf 100644 --- a/sycl/source/platform.cpp +++ b/sycl/source/platform.cpp @@ -23,12 +23,12 @@ inline namespace _V1 { platform::platform() : platform(default_selector_v) {} platform::platform(cl_platform_id PlatformId) { - auto Plugin = sycl::detail::ur::getPlugin(); + auto Adapter = sycl::detail::ur::getAdapter(); ur_platform_handle_t UrPlatform = nullptr; - Plugin->call( - detail::ur::cast(PlatformId), Plugin->getUrAdapter(), + Adapter->call( + detail::ur::cast(PlatformId), Adapter->getUrAdapter(), /* pProperties = */ nullptr, &UrPlatform); - impl = detail::platform_impl::getOrMakePlatformImpl(UrPlatform, Plugin); + impl = detail::platform_impl::getOrMakePlatformImpl(UrPlatform, Adapter); } // protected constructor for internal use diff --git a/sycl/source/virtual_mem.cpp b/sycl/source/virtual_mem.cpp index 5a9a88f884b60..5519a27ed0d19 100644 --- a/sycl/source/virtual_mem.cpp +++ b/sycl/source/virtual_mem.cpp @@ -45,17 +45,17 @@ __SYCL_EXPORT size_t get_mem_granularity(const device &SyclDevice, sycl::detail::getSyclObjImpl(SyclDevice); std::shared_ptr ContextImpl = sycl::detail::getSyclObjImpl(SyclContext); - const sycl::detail::PluginPtr &Plugin = ContextImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = ContextImpl->getAdapter(); #ifndef NDEBUG size_t InfoOutputSize; - Plugin->call( + Adapter->call( ContextImpl->getHandleRef(), DeviceImpl->getHandleRef(), GranularityQuery, 0, nullptr, &InfoOutputSize); assert(InfoOutputSize == sizeof(size_t) && "Unexpected output size of granularity info query."); #endif // NDEBUG size_t Granularity = 0; - Plugin->call( + Adapter->call( ContextImpl->getHandleRef(), DeviceImpl->getHandleRef(), GranularityQuery, sizeof(size_t), &Granularity, nullptr); if (Granularity == 0) @@ -117,9 +117,9 @@ __SYCL_EXPORT uintptr_t reserve_virtual_mem(uintptr_t Start, size_t NumBytes, std::shared_ptr ContextImpl = sycl::detail::getSyclObjImpl(SyclContext); - const sycl::detail::PluginPtr &Plugin = ContextImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = ContextImpl->getAdapter(); void *OutPtr = nullptr; - Plugin->call( + Adapter->call( ContextImpl->getHandleRef(), reinterpret_cast(Start), NumBytes, &OutPtr); return reinterpret_cast(OutPtr); @@ -129,8 +129,8 @@ __SYCL_EXPORT void free_virtual_mem(uintptr_t Ptr, size_t NumBytes, const context &SyclContext) { std::shared_ptr ContextImpl = sycl::detail::getSyclObjImpl(SyclContext); - const sycl::detail::PluginPtr &Plugin = ContextImpl->getPlugin(); - Plugin->call( + const sycl::detail::AdapterPtr &Adapter = ContextImpl->getAdapter(); + Adapter->call( ContextImpl->getHandleRef(), reinterpret_cast(Ptr), NumBytes); } @@ -140,8 +140,8 @@ __SYCL_EXPORT void set_access_mode(const void *Ptr, size_t NumBytes, auto AccessFlags = sycl::detail::AccessModeToVirtualAccessFlags(Mode); std::shared_ptr ContextImpl = sycl::detail::getSyclObjImpl(SyclContext); - const sycl::detail::PluginPtr &Plugin = ContextImpl->getPlugin(); - Plugin->call( + const sycl::detail::AdapterPtr &Adapter = ContextImpl->getAdapter(); + Adapter->call( ContextImpl->getHandleRef(), Ptr, NumBytes, AccessFlags); } @@ -150,17 +150,17 @@ __SYCL_EXPORT address_access_mode get_access_mode(const void *Ptr, const context &SyclContext) { std::shared_ptr ContextImpl = sycl::detail::getSyclObjImpl(SyclContext); - const sycl::detail::PluginPtr &Plugin = ContextImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = ContextImpl->getAdapter(); #ifndef NDEBUG size_t InfoOutputSize = 0; - Plugin->call( + Adapter->call( ContextImpl->getHandleRef(), Ptr, NumBytes, UR_VIRTUAL_MEM_INFO_ACCESS_MODE, 0, nullptr, &InfoOutputSize); assert(InfoOutputSize == sizeof(ur_virtual_mem_access_flags_t) && "Unexpected output size of access mode info query."); #endif // NDEBUG ur_virtual_mem_access_flags_t AccessFlags; - Plugin->call( + Adapter->call( ContextImpl->getHandleRef(), Ptr, NumBytes, UR_VIRTUAL_MEM_INFO_ACCESS_MODE, sizeof(ur_virtual_mem_access_flags_t), &AccessFlags, nullptr); @@ -176,8 +176,8 @@ __SYCL_EXPORT void unmap(const void *Ptr, size_t NumBytes, const context &SyclContext) { std::shared_ptr ContextImpl = sycl::detail::getSyclObjImpl(SyclContext); - const sycl::detail::PluginPtr &Plugin = ContextImpl->getPlugin(); - Plugin->call( + const sycl::detail::AdapterPtr &Adapter = ContextImpl->getAdapter(); + Adapter->call( ContextImpl->getHandleRef(), Ptr, NumBytes); } diff --git a/sycl/test/Unit/lit.cfg.py b/sycl/test/Unit/lit.cfg.py index 3bdfc3189ce6b..3bf9aefeeaabc 100644 --- a/sycl/test/Unit/lit.cfg.py +++ b/sycl/test/Unit/lit.cfg.py @@ -84,11 +84,11 @@ def find_shlibpath_var(): "unable to inject shared library path on '{}'".format(platform.system()) ) -# The mock plugin currently appears as an opencl plugin, but could be changed in -# the future. To avoid it being filtered out we set the filter to use the * +# The mock adapter currently appears as an opencl adapter, but could be changed +# in the future. To avoid it being filtered out we set the filter to use the * # wildcard. config.environment["ONEAPI_DEVICE_SELECTOR"] = "*:*" -lit_config.note("Using Mock Plugin.") +lit_config.note("Using Mock Adapter.") config.environment["SYCL_CACHE_DIR"] = config.llvm_obj_root + "/sycl_cache" lit_config.note("SYCL cache directory: {}".format(config.environment["SYCL_CACHE_DIR"])) diff --git a/sycl/tools/sycl-ls/sycl-ls.cpp b/sycl/tools/sycl-ls/sycl-ls.cpp index c062c26b96fb3..0ab8d7bec456b 100644 --- a/sycl/tools/sycl-ls/sycl-ls.cpp +++ b/sycl/tools/sycl-ls/sycl-ls.cpp @@ -409,7 +409,7 @@ int main(int argc, char **argv) { // the device counting done here should have the same result as the // counting done by SYCL itself. But technically, it is not the same // method, as SYCL keeps a table of platforms:start_dev_index in each - // plugin. + // adapter. for (const auto &Device : Devices) { std::cout << "[" << detail::get_backend_name_no_vendor(Backend) << ":" diff --git a/sycl/unittests/Extensions/CommandGraph/InOrderQueue.cpp b/sycl/unittests/Extensions/CommandGraph/InOrderQueue.cpp index 2c581e46a4e45..f65018d63fb35 100644 --- a/sycl/unittests/Extensions/CommandGraph/InOrderQueue.cpp +++ b/sycl/unittests/Extensions/CommandGraph/InOrderQueue.cpp @@ -419,7 +419,7 @@ TEST_F(CommandGraphTest, InOrderQueueMemsetAndGraph) { experimental::command_graph InOrderGraph{InOrderQueue.get_context(), InOrderQueue.get_device()}; - // The mock plugin should return true for shared USM allocation support by + // The mock adapter should return true for shared USM allocation support by // default. If this fails it means this test needs to redefine the device info // query. ASSERT_TRUE( @@ -497,7 +497,7 @@ TEST_F(CommandGraphTest, InOrderQueueMemcpyAndGraph) { experimental::command_graph InOrderGraph{InOrderQueue.get_context(), InOrderQueue.get_device()}; - // The mock plugin should return true for shared USM allocation support by + // The mock adapter should return true for shared USM allocation support by // default. If this fails it means this test needs to redefine the device info // query. ASSERT_TRUE( diff --git a/sycl/unittests/SYCL2020/DeviceGetInfoAspects.cpp b/sycl/unittests/SYCL2020/DeviceGetInfoAspects.cpp index 42ff1c6eceabf..b3b9741266898 100644 --- a/sycl/unittests/SYCL2020/DeviceGetInfoAspects.cpp +++ b/sycl/unittests/SYCL2020/DeviceGetInfoAspects.cpp @@ -33,7 +33,7 @@ TEST(DeviceGetInfo, SupportedDeviceAspects) { Dev.get_info(); // Tests to examine aspects of default mock device, as defined in - // helpers/UrMockPlugin.hpp so these tests all need to be kept in sync with + // helpers/UrMockAdapter.hpp so these tests all need to be kept in sync with // changes to that file. EXPECT_TRUE(containsAspect(DeviceAspects, aspect::gpu)); EXPECT_TRUE(containsAspect(DeviceAspects, aspect::fp16)); diff --git a/sycl/unittests/SYCL2020/HasExtension.cpp b/sycl/unittests/SYCL2020/HasExtension.cpp index 636c363f28616..92f99b7fce7f3 100644 --- a/sycl/unittests/SYCL2020/HasExtension.cpp +++ b/sycl/unittests/SYCL2020/HasExtension.cpp @@ -15,7 +15,7 @@ using namespace sycl; -TEST(HasExtensionID, HasExtensionCallsCorrectPluginMethods) { +TEST(HasExtensionID, HasExtensionCallsCorrectAdapterMethods) { sycl::unittest::UrMock<> Mock; sycl::platform Plt = sycl::platform(); diff --git a/sycl/unittests/SYCL2020/KernelBundle.cpp b/sycl/unittests/SYCL2020/KernelBundle.cpp index 9829f746ac819..6e25c4a86a147 100644 --- a/sycl/unittests/SYCL2020/KernelBundle.cpp +++ b/sycl/unittests/SYCL2020/KernelBundle.cpp @@ -488,8 +488,8 @@ ur_result_t redefinedDevicePartitionAfter(void *pParams) { } TEST(KernelBundle, DescendentDevice) { - // Mock a non-OpenCL plugin since use of descendent devices of context members - // is not supported there yet. + // Mock a non-OpenCL adapter since use of descendent devices of context + // members is not supported there yet. sycl::unittest::UrMock Mock; sycl::platform Plt = sycl::platform(); diff --git a/sycl/unittests/assert/assert.cpp b/sycl/unittests/assert/assert.cpp index 33048f3433932..0e79bae77dea0 100644 --- a/sycl/unittests/assert/assert.cpp +++ b/sycl/unittests/assert/assert.cpp @@ -470,9 +470,9 @@ void ParentProcess(int ChildPID, int ChildStdErrFD) { #endif // _WIN32 TEST(Assert, TestPositive) { - // Ensure that the mock plugin is initialized before spawning work. Since the + // Ensure that the mock adapter is initialized before spawning work. Since the // test needs no redefinitions we do not need to create a UrMock<> instance, - // but the mock plugin is still needed to have a valid platform available. + // but the mock adapter is still needed to have a valid platform available. // sycl::unittest::UrMock::InitUr(); #ifndef _WIN32 @@ -526,8 +526,9 @@ TEST(Assert, TestInteropKernelNegative) { auto URKernel = mock::createDummyHandle(); - // TODO use make_kernel. This requires a fix in backend.cpp to get plugin - // from context instead of free getPlugin to alllow for mocking of its methods + // TODO use make_kernel. This requires a fix in backend.cpp to get adapter + // from context instead of free getAdapter to allow for mocking of its + // methods sycl::kernel KInterop((cl_kernel)URKernel, Ctx); Queue.submit([&](sycl::handler &H) { H.single_task(KInterop); }); diff --git a/sycl/unittests/helpers/UrMock.hpp b/sycl/unittests/helpers/UrMock.hpp index e4e525a274dbc..71c9962155b2a 100644 --- a/sycl/unittests/helpers/UrMock.hpp +++ b/sycl/unittests/helpers/UrMock.hpp @@ -8,11 +8,12 @@ // // This mini-library provides facilities to test the DPC++ Runtime behavior upon // specific results of the underlying low-level API calls. By exploiting the -// Plugin Interface API, the stored addresses of the actual plugin-specific +// Adapter Interface API, the stored addresses of the actual adapter-specific // implementations can be overwritten to point at user-defined mock functions. // -// To make testing independent of existing plugins and devices, all plugins are -// forcefully unloaded and the mock plugin is registered as the only plugin. +// To make testing independent of existing adapters and devices, all adapters +// are forcefully unloaded and the mock adapter is registered as the only +// adapter. // // While this could be done manually for each unit-testing scenario, the library // aims to rule out the boilerplate, providing helper APIs which can be re-used @@ -30,9 +31,9 @@ #pragma once +#include #include #include -#include #include #include #include diff --git a/sycl/unittests/scheduler/Commands.cpp b/sycl/unittests/scheduler/Commands.cpp index 0732d9e5ecde8..9ebd256a2f587 100644 --- a/sycl/unittests/scheduler/Commands.cpp +++ b/sycl/unittests/scheduler/Commands.cpp @@ -37,7 +37,7 @@ ur_result_t redefineUrEventGetInfo(void *pParams) { // // This test checks a handling of empty events in WaitWithBarrier command. -// Original reproducer for l0 plugin led to segfault(nullptr dereference): +// Original reproducer for l0 adapter led to segfault(nullptr dereference): // // #include // int main() { diff --git a/sycl/unittests/scheduler/LeafLimitDiffContexts.cpp b/sycl/unittests/scheduler/LeafLimitDiffContexts.cpp index 456dec8f0b5cb..9f6c0bd7691bb 100644 --- a/sycl/unittests/scheduler/LeafLimitDiffContexts.cpp +++ b/sycl/unittests/scheduler/LeafLimitDiffContexts.cpp @@ -36,8 +36,7 @@ TEST_F(SchedulerTest, LeafLimitDiffContexts) { DisableCleanupName, "1", detail::SYCLConfig::reset}; - // Ensure the mock plugin has been initialized prior to selecting a device. - // unittest::UrMock::EnsureMockPluginInitialized(); + // Ensure the mock adapter has been initialized prior to selecting a device. sycl::unittest::UrMock<> Mock; device Device; diff --git a/sycl/unittests/xpti_trace/NodeCreation.cpp b/sycl/unittests/xpti_trace/NodeCreation.cpp index 257000e3ec2f4..6b963bc8563af 100644 --- a/sycl/unittests/xpti_trace/NodeCreation.cpp +++ b/sycl/unittests/xpti_trace/NodeCreation.cpp @@ -42,7 +42,7 @@ class NodeCreation : public ::testing::Test { "libxptifw.so", [] {}}; unittest::ScopedEnvVar XPTISubscriber{"XPTI_SUBSCRIBERS", "libxptitest_subscriber.so", [] {}}; - sycl::unittest::UrMock<> MockPlugin; + sycl::unittest::UrMock<> MockAdapter; static constexpr char FileName[] = "NodeCreation.cpp"; static constexpr char FunctionName[] = "TestCaseExecution"; diff --git a/sycl/unittests/xpti_trace/QueueApiFailures.cpp b/sycl/unittests/xpti_trace/QueueApiFailures.cpp index a250f213cb998..d2756f3b5fb56 100644 --- a/sycl/unittests/xpti_trace/QueueApiFailures.cpp +++ b/sycl/unittests/xpti_trace/QueueApiFailures.cpp @@ -66,7 +66,7 @@ class QueueApiFailures : public ::testing::Test { "libxptifw.so", [] {}}; unittest::ScopedEnvVar XPTISubscriber{"XPTI_SUBSCRIBERS", "libxptitest_subscriber.so", [] {}}; - sycl::unittest::UrMock<> MockPlugin; + sycl::unittest::UrMock<> MockAdapter; static constexpr char FileName[] = "QueueApiFailures.cpp"; static constexpr char FunctionName[] = "TestCaseExecution"; diff --git a/sycl/unittests/xpti_trace/QueueIDCheck.cpp b/sycl/unittests/xpti_trace/QueueIDCheck.cpp index 3824d433d6057..5dab29a603b3c 100644 --- a/sycl/unittests/xpti_trace/QueueIDCheck.cpp +++ b/sycl/unittests/xpti_trace/QueueIDCheck.cpp @@ -46,7 +46,7 @@ class QueueID : public ::testing::Test { "libxptifw.so", [] {}}; unittest::ScopedEnvVar XPTISubscriber{"XPTI_SUBSCRIBERS", "libxptitest_subscriber.so", [] {}}; - sycl::unittest::UrMock<> MockPlugin; + sycl::unittest::UrMock<> MockAdapter; static constexpr size_t KernelSize = 1; diff --git a/sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp b/sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp index d99312a6600b0..455f271f1d2d4 100644 --- a/sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp +++ b/sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp @@ -15,12 +15,11 @@ // The workaround is this proxy_loader. It is statically linked by the SYCL // library and thus is a real dependency and is not unloaded from memory until // after SYCL itself is unloaded. It calls LoadLibrary on all the UR adapters -// that SYCL will use during its initialization, which ensures that those plugin -// DLLs are not unloaded until after. -// Note that this property is not transitive. If any of the UR DLLs in turn -// dynamically load some other DLL during their lifecycle there is no guarantee -// that the "grandchild" won't be unloaded early. They would need to employ a -// similar approach. +// that SYCL will use during its initialization, which ensures that those +// adapter DLLs are not unloaded until after. Note that this property is not +// transitive. If any of the UR DLLs in turn dynamically load some other DLL +// during their lifecycle there is no guarantee that the "grandchild" won't be +// unloaded early. They would need to employ a similar approach. #include #include @@ -84,7 +83,7 @@ std::wstring getCurrentDSODir() { } // these are cribbed from include/sycl/detail/ur.hpp -// a new plugin must be added to both places. +// a new adapter must be added to both places. #ifdef _MSC_VER #define __SYCL_UNIFIED_RUNTIME_LOADER_NAME "ur_loader.dll" #define __SYCL_OPENCL_ADAPTER_NAME "ur_adapter_opencl.dll" @@ -108,12 +107,12 @@ void *&getDllHandle() { return dllHandle; } -/// Load the plugin libraries +/// Load the adapter libraries void preloadLibraries() { // Suppress system errors. // Tells the system to not display the critical-error-handler message box. // Instead, the system sends the error to the calling process. - // This is crucial for graceful handling of plugins that couldn't be + // This is crucial for graceful handling of adapters that couldn't be // loaded, e.g. due to missing native run-times. // Sometimes affects L0 or the unified runtime. // TODO: add reporting in case of an error. @@ -125,27 +124,27 @@ void preloadLibraries() { assert(false && "Failed to update DLL search path"); } - // this path duplicates sycl/detail/ur.cpp:initializePlugins + // this path duplicates sycl/detail/ur.cpp:initializeAdapters std::filesystem::path LibSYCLDir(getCurrentDSODir()); - // When searching for dependencies of the plugins limit the + // When searching for dependencies of the adapters limit the // list of directories to %windows%\system32 and the directory that contains - // the loaded DLL (the plugin). This is necessary to avoid loading dlls from + // the loaded DLL (the adapter). This is necessary to avoid loading dlls from // current directory and some other directories which are considered unsafe. - auto loadPlugin = [&](auto pluginName, - DWORD flags = LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | - LOAD_LIBRARY_SEARCH_SYSTEM32) { - auto path = LibSYCLDir / pluginName; + auto loadAdapter = [&](auto adapterName, + DWORD flags = LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | + LOAD_LIBRARY_SEARCH_SYSTEM32) { + auto path = LibSYCLDir / adapterName; return LoadLibraryEx(path.wstring().c_str(), NULL, flags); }; // We keep the UR Loader handle so it can be fetched by the runtime, but the // adapter libraries themselves won't be used. - getDllHandle() = loadPlugin(__SYCL_UNIFIED_RUNTIME_LOADER_NAME); - loadPlugin(__SYCL_OPENCL_ADAPTER_NAME); - loadPlugin(__SYCL_LEVEL_ZERO_ADAPTER_NAME); - loadPlugin(__SYCL_CUDA_ADAPTER_NAME); - loadPlugin(__SYCL_HIP_ADAPTER_NAME); - loadPlugin(__SYCL_NATIVE_CPU_ADAPTER_NAME); + getDllHandle() = loadAdapter(__SYCL_UNIFIED_RUNTIME_LOADER_NAME); + loadAdapter(__SYCL_OPENCL_ADAPTER_NAME); + loadAdapter(__SYCL_LEVEL_ZERO_ADAPTER_NAME); + loadAdapter(__SYCL_CUDA_ADAPTER_NAME); + loadAdapter(__SYCL_HIP_ADAPTER_NAME); + loadAdapter(__SYCL_NATIVE_CPU_ADAPTER_NAME); // Restore system error handling. (void)SetErrorMode(SavedMode); @@ -154,7 +153,7 @@ void preloadLibraries() { } } -/// windows_pi.cpp:loadOsPluginLibrary() calls this to get the DLL loaded +/// windows_ur.cpp:getURLoaderLibrary() calls this to get the DLL loaded /// earlier. __declspec(dllexport) void *getPreloadedURLib() { return getDllHandle(); } diff --git a/xpti/doc/SYCL_Tracing_Implementation.md b/xpti/doc/SYCL_Tracing_Implementation.md index c004c12cdee12..89c2456bd983f 100644 --- a/xpti/doc/SYCL_Tracing_Implementation.md +++ b/xpti/doc/SYCL_Tracing_Implementation.md @@ -63,7 +63,7 @@ and all kernel executions in the applications are added as nodes in this global graph. In the SYCL runtime, there is no obvious location where the creation of the global graph can be inserted as many objects are instantiated statically. Currently, we embed the graph creation in the -Unified Runtime (UR) layer `initializePlugins()` call. In this call, we will +Unified Runtime (UR) layer `initializeAdapters()` call. In this call, we will perform two operations: 1. Initialize all listeners and create a trace event to represent the graph. From ea03f46dbb291521f01b38548bdb6de2ab722fd3 Mon Sep 17 00:00:00 2001 From: Piotr Balcer Date: Mon, 23 Sep 2024 12:46:04 +0200 Subject: [PATCH 7/8] [UR] revert "Phase 2 of Counter-Based Event" (#15466) This should fix flaky e2e tests on gen12. --- sycl/cmake/modules/FetchUnifiedRuntime.cmake | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sycl/cmake/modules/FetchUnifiedRuntime.cmake b/sycl/cmake/modules/FetchUnifiedRuntime.cmake index 5a95f16ed5060..25bcc0a97d18c 100644 --- a/sycl/cmake/modules/FetchUnifiedRuntime.cmake +++ b/sycl/cmake/modules/FetchUnifiedRuntime.cmake @@ -117,13 +117,13 @@ if(SYCL_UR_USE_FETCH_CONTENT) endfunction() set(UNIFIED_RUNTIME_REPO "https://github.com/oneapi-src/unified-runtime.git") - # commit 7384e2d7b908de0b2bca9f3c57827ea84698864e - # Merge: ed85c3e2 a32549b4 - # Author: Omar Ahmed - # Date: Fri Sep 20 14:56:40 2024 +0100 - # Merge pull request #2108 from pbalcer/fix-perf-tracing-logs - # fix perf regression in tracing layer - set(UNIFIED_RUNTIME_TAG 7384e2d7b908de0b2bca9f3c57827ea84698864e) + # commit 9ca3ec7a9c1d2f4a362d7e5add103b30271a8a55 + # Merge: 7384e2d7 59e5e405 + # Author: Piotr Balcer + # Date: Mon Sep 23 10:58:51 2024 +0200 + # Merge pull request #2113 from oneapi-src/revert-1698-counter-based-2 + # Revert "[L0] Phase 2 of Counter-Based Event Implementation" + set(UNIFIED_RUNTIME_TAG 9ca3ec7a9c1d2f4a362d7e5add103b30271a8a55) set(UMF_BUILD_EXAMPLES OFF CACHE INTERNAL "EXAMPLES") # Due to the use of dependentloadflag and no installer for UMF and hwloc we need From 9fd767d1da66529587bc5f6f10d7065cbd76e19a Mon Sep 17 00:00:00 2001 From: Georgi Mirazchiyski Date: Mon, 23 Sep 2024 16:52:28 +0100 Subject: [PATCH 8/8] [SYCL][Driver] Fix regression that enabled Cuda-mode in cc1 and defined __CUDA_ARCH__ (#15441) The `CudaToolChain` set `-fcuda-is-device` unconditionally which made `InitializePredefinedMacros` (called from `clang::InitializePreprocessor`) to define `__CUDA_ARCH__` (default-init to 1). As such, the driver assumed Cuda mode while in also SYCL mode, but we don't properly support Cuda device-code compatibility and we want to avoid having the `__CUDA_ARCH__` macro defined altogether for SYCL offload. --- clang/lib/Driver/ToolChains/Cuda.cpp | 27 +++++++++++++------------- clang/test/Preprocessor/sycl-macro.cpp | 11 ++++++++--- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp b/clang/lib/Driver/ToolChains/Cuda.cpp index 5a61fd250f3fd..a2b6db69b9284 100644 --- a/clang/lib/Driver/ToolChains/Cuda.cpp +++ b/clang/lib/Driver/ToolChains/Cuda.cpp @@ -938,8 +938,17 @@ void CudaToolChain::addClangTargetOptions( DeviceOffloadingKind == Action::OFK_Cuda) && "Only OpenMP, SYCL or CUDA offloading kinds are supported for NVIDIA GPUs."); - CC1Args.append( - {"-fcuda-is-device", "-mllvm", "-enable-memcpyopt-without-libcalls"}); + // If we are compiling SYCL kernels for Nvidia GPUs, we do not support Cuda + // device code compatability, hence we do not set Cuda mode in that instance. + if (DeviceOffloadingKind == Action::OFK_SYCL) { + toolchains::SYCLToolChain::AddSYCLIncludeArgs(getDriver(), DriverArgs, + CC1Args); + + if (DriverArgs.hasArg(options::OPT_fsycl_fp32_prec_sqrt)) + CC1Args.push_back("-fcuda-prec-sqrt"); + } else { + CC1Args.append( + {"-fcuda-is-device", "-mllvm", "-enable-memcpyopt-without-libcalls"}); // Unsized function arguments used for variadics were introduced in CUDA-9.0 // We still do not support generating code that actually uses variadic @@ -948,18 +957,10 @@ void CudaToolChain::addClangTargetOptions( if (CudaInstallation.version() >= CudaVersion::CUDA_90) CC1Args.push_back("-fcuda-allow-variadic-functions"); - if (DriverArgs.hasArg(options::OPT_fsycl)) { - // Add these flags for .cu SYCL compilation. + // Add these flags for .cu SYCL compilation. + if (DeviceOffloadingKind == Action::OFK_Cuda && + DriverArgs.hasArg(options::OPT_fsycl)) CC1Args.append({"-std=c++17", "-fsycl-is-host"}); - } - - if (DeviceOffloadingKind == Action::OFK_SYCL) { - toolchains::SYCLToolChain::AddSYCLIncludeArgs(getDriver(), DriverArgs, - CC1Args); - - if (DriverArgs.hasArg(options::OPT_fsycl_fp32_prec_sqrt)) { - CC1Args.push_back("-fcuda-prec-sqrt"); - } } auto NoLibSpirv = DriverArgs.hasArg(options::OPT_fno_sycl_libspirv) || diff --git a/clang/test/Preprocessor/sycl-macro.cpp b/clang/test/Preprocessor/sycl-macro.cpp index 347fa670982e8..934c20a776915 100644 --- a/clang/test/Preprocessor/sycl-macro.cpp +++ b/clang/test/Preprocessor/sycl-macro.cpp @@ -6,7 +6,10 @@ // RUNx: %clang_cc1 %s -fsycl-id-queries-fit-in-int -fsycl-is-device -E -dM -fms-compatibility | FileCheck --check-prefix=CHECK-MSVC %s // RUN: %clang_cc1 -fno-sycl-id-queries-fit-in-int %s -E -dM | FileCheck \ // RUN: --check-prefix=CHECK-NO-SYCL_FIT_IN_INT %s -// RUN: %clang_cc1 %s -triple nvptx64-nvidia-cuda -target-cpu sm_80 -fsycl-is-device -E -dM | FileCheck --check-prefix=CHECK-CUDA %s +// RUN: %clang_cc1 %s -triple nvptx64-nvidia-cuda -target-cpu sm_80 -fsycl-is-device -E -dM | FileCheck \ +// RUN: --check-prefix=CHECK-CUDA %s -DARCH_CODE=800 +// RUN: %clangxx %s -fsycl -nocudalib -fsycl-targets=nvptx64-nvidia-cuda -Xsycl-target-backend --offload-arch=sm_80 -E -dM | FileCheck \ +// RUN: --check-prefix=CHECK-CUDA-SYCL-DRIVER %s // RUN: %clang_cc1 %s -triple amdgcn-amd-amdhsa -target-cpu gfx906 -fsycl-is-device -E -dM | FileCheck --check-prefix=CHECK-HIP %s // RUN: %clang_cc1 %s -triple nvptx64-nvidia-cuda -target-cpu sm_90a -fsycl-is-device -E -dM | FileCheck --check-prefix=CHECK-CUDA-FEATURE %s @@ -32,8 +35,10 @@ // CHECK-NO-SYCL_FIT_IN_INT-NOT:#define __SYCL_ID_QUERIES_FIT_IN_INT__ 1 // CHECK-SYCL-ID:#define __SYCL_ID_QUERIES_FIT_IN_INT__ 1 -// CHECK-CUDA:#define __SYCL_CUDA_ARCH__ 800 -// CHECK-CUDA-NOT:#define __CUDA_ARCH__ 800 +// CHECK-CUDA:#define __SYCL_CUDA_ARCH__ [[ARCH_CODE]] +// CHECK-CUDA-NOT:#define __CUDA_ARCH__ {{[0-9]+}} + +// CHECK-CUDA-SYCL-DRIVER-NOT: #define __CUDA_ARCH__ {{[0-9]+}} // CHECK-HIP:#define __CUDA_ARCH__ 0