From 13b72b365da9626d3a9ba2c694e27065c07eb866 Mon Sep 17 00:00:00 2001 From: aelovikov-intel Date: Thu, 4 Apr 2024 13:04:01 -0700 Subject: [PATCH] [SYCL] Move `sycl::detail::split_string` to sycl/source/detail (#13271) It doesn't need to be part of ABI - only used internally under `sycl/source/`. Make it `inline` and operate on `std::string_view` while on it. --- sycl/include/sycl/detail/common_info.hpp | 24 ----------- sycl/source/detail/common.cpp | 23 ----------- sycl/source/detail/device_info.hpp | 3 +- sycl/source/detail/kernel_bundle_impl.hpp | 3 +- .../kernel_compiler_opencl.cpp | 2 +- sycl/source/detail/kernel_info.hpp | 1 - sycl/source/detail/platform_info.hpp | 3 +- sycl/source/detail/program_impl.hpp | 1 - sycl/source/detail/split_string.hpp | 41 +++++++++++++++++++ sycl/test/abi/sycl_symbols_linux.dump | 1 - sycl/test/abi/sycl_symbols_windows.dump | 1 - 11 files changed, 48 insertions(+), 55 deletions(-) delete mode 100644 sycl/include/sycl/detail/common_info.hpp create mode 100644 sycl/source/detail/split_string.hpp diff --git a/sycl/include/sycl/detail/common_info.hpp b/sycl/include/sycl/detail/common_info.hpp deleted file mode 100644 index a84adc5af11d8..0000000000000 --- a/sycl/include/sycl/detail/common_info.hpp +++ /dev/null @@ -1,24 +0,0 @@ -//==------- common_info.hpp ----- Common SYCL info methods------------------==// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#pragma once -#include - -#include -#include - -namespace sycl { -inline namespace _V1 { -namespace detail { - -std::vector __SYCL_EXPORT split_string(const std::string &str, - char delimeter); - -} // namespace detail -} // namespace _V1 -} // namespace sycl diff --git a/sycl/source/detail/common.cpp b/sycl/source/detail/common.cpp index 8df4c1ba0b3d4..9e6aee1e85693 100644 --- a/sycl/source/detail/common.cpp +++ b/sycl/source/detail/common.cpp @@ -7,7 +7,6 @@ //===----------------------------------------------------------------------===// #include -#include namespace sycl { inline namespace _V1 { @@ -70,28 +69,6 @@ const char *stringifyErrorCode(pi_int32 error) { return "Unknown error code"; } } - -std::vector split_string(const std::string &str, char delimeter) { - std::vector Result; - size_t Start = 0; - size_t End = 0; - while ((End = str.find(delimeter, Start)) != std::string::npos) { - Result.push_back(str.substr(Start, End - Start)); - Start = End + 1; - } - // Get the last substring and ignore the null character so we wouldn't get - // double null characters \0\0 at the end of the substring - End = str.find('\0'); - if (Start < End) { - std::string LastSubStr(str.substr(Start, End - Start)); - // In case str has a delimeter at the end, the substring will be empty, so - // we shouldn't add it to the final vector - if (!LastSubStr.empty()) - Result.push_back(LastSubStr); - } - return Result; -} - } // namespace detail } // namespace _V1 } // namespace sycl diff --git a/sycl/source/detail/device_info.hpp b/sycl/source/detail/device_info.hpp index 39f47c05207ed..a56281b862ef3 100644 --- a/sycl/source/detail/device_info.hpp +++ b/sycl/source/detail/device_info.hpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -27,6 +26,8 @@ #include #include +#include "split_string.hpp" + namespace sycl { inline namespace _V1 { namespace detail { diff --git a/sycl/source/detail/kernel_bundle_impl.hpp b/sycl/source/detail/kernel_bundle_impl.hpp index 26fa707a307f9..55586b6d2b5ac 100644 --- a/sycl/source/detail/kernel_bundle_impl.hpp +++ b/sycl/source/detail/kernel_bundle_impl.hpp @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -27,6 +26,8 @@ #include #include +#include "split_string.hpp" + namespace sycl { inline namespace _V1 { namespace detail { diff --git a/sycl/source/detail/kernel_compiler/kernel_compiler_opencl.cpp b/sycl/source/detail/kernel_compiler/kernel_compiler_opencl.cpp index be2d66b0f01c7..ef4cd6974520e 100644 --- a/sycl/source/detail/kernel_compiler/kernel_compiler_opencl.cpp +++ b/sycl/source/detail/kernel_compiler/kernel_compiler_opencl.cpp @@ -6,13 +6,13 @@ // //===----------------------------------------------------------------------===// -#include // split_string #include // getOsLibraryFuncAddress #include // make_error_code #include "kernel_compiler_opencl.hpp" #include "../online_compiler/ocloc_api.h" +#include "../split_string.hpp" #include // strlen #include // for std::accumulate diff --git a/sycl/source/detail/kernel_info.hpp b/sycl/source/detail/kernel_info.hpp index c8a186cde8d64..12256158eed49 100644 --- a/sycl/source/detail/kernel_info.hpp +++ b/sycl/source/detail/kernel_info.hpp @@ -10,7 +10,6 @@ #include #include -#include #include #include #include diff --git a/sycl/source/detail/platform_info.hpp b/sycl/source/detail/platform_info.hpp index 778da1cf4247c..42c41b5063cf5 100644 --- a/sycl/source/detail/platform_info.hpp +++ b/sycl/source/detail/platform_info.hpp @@ -9,11 +9,12 @@ #pragma once #include #include -#include #include #include #include +#include "split_string.hpp" + namespace sycl { inline namespace _V1 { namespace detail { diff --git a/sycl/source/detail/program_impl.hpp b/sycl/source/detail/program_impl.hpp index 80fc9cf9811a8..32a0c7fd38bfe 100644 --- a/sycl/source/detail/program_impl.hpp +++ b/sycl/source/detail/program_impl.hpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include diff --git a/sycl/source/detail/split_string.hpp b/sycl/source/detail/split_string.hpp new file mode 100644 index 0000000000000..557c35229c054 --- /dev/null +++ b/sycl/source/detail/split_string.hpp @@ -0,0 +1,41 @@ +//==------------ split_string.hpp ------------------------------------------==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#pragma once + +#include +#include +#include + +namespace sycl { +inline namespace _V1 { +namespace detail { +inline std::vector split_string(std::string_view str, + char delimeter) { + std::vector Result; + size_t Start = 0; + size_t End = 0; + while ((End = str.find(delimeter, Start)) != std::string::npos) { + Result.emplace_back(str.substr(Start, End - Start)); + Start = End + 1; + } + // Get the last substring and ignore the null character so we wouldn't get + // double null characters \0\0 at the end of the substring + End = str.find('\0'); + if (Start < End) { + std::string LastSubStr(str.substr(Start, End - Start)); + // In case str has a delimeter at the end, the substring will be empty, so + // we shouldn't add it to the final vector + if (!LastSubStr.empty()) + Result.push_back(LastSubStr); + } + return Result; +} +} // namespace detail +} // namespace _V1 +} // namespace sycl diff --git a/sycl/test/abi/sycl_symbols_linux.dump b/sycl/test/abi/sycl_symbols_linux.dump index fb32e4b90fb90..28944dad6adba 100644 --- a/sycl/test/abi/sycl_symbols_linux.dump +++ b/sycl/test/abi/sycl_symbols_linux.dump @@ -3264,7 +3264,6 @@ _ZN4sycl3_V16detail12sampler_implC2ENS0_29coordinate_normalization_modeENS0_15ad _ZN4sycl3_V16detail12sampler_implC2EP11_cl_samplerRKNS0_7contextE _ZN4sycl3_V16detail12sampler_implD1Ev _ZN4sycl3_V16detail12sampler_implD2Ev -_ZN4sycl3_V16detail12split_stringERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEc _ZN4sycl3_V16detail13MemoryManager10advise_usmEPKvSt10shared_ptrINS1_10queue_implEEm14_pi_mem_adviceSt6vectorIP9_pi_eventSaISB_EEPSB_ _ZN4sycl3_V16detail13MemoryManager10advise_usmEPKvSt10shared_ptrINS1_10queue_implEEm14_pi_mem_adviceSt6vectorIP9_pi_eventSaISB_EEPSB_RKS5_INS1_10event_implEE _ZN4sycl3_V16detail13MemoryManager11copy_2d_usmEPKvmSt10shared_ptrINS1_10queue_implEEPvmmmSt6vectorIP9_pi_eventSaISB_EEPSB_ diff --git a/sycl/test/abi/sycl_symbols_windows.dump b/sycl/test/abi/sycl_symbols_windows.dump index 7540ef06954e0..5dc49a037a721 100644 --- a/sycl/test/abi/sycl_symbols_windows.dump +++ b/sycl/test/abi/sycl_symbols_windows.dump @@ -4585,7 +4585,6 @@ ?size@image_impl@detail@_V1@sycl@@QEBA_KXZ ?size@stream@_V1@sycl@@QEBA_KXZ ?size@stream_impl@detail@_V1@sycl@@QEBA_KXZ -?split_string@detail@_V1@sycl@@YA?AV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@5@D@Z ?start@HostProfilingInfo@detail@_V1@sycl@@QEAAXXZ ?start_fusion@fusion_wrapper@experimental@codeplay@ext@_V1@sycl@@QEAAXXZ ?stringifyErrorCode@detail@_V1@sycl@@YAPEBDH@Z