Skip to content

Commit 13b72b3

Browse files
[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.
1 parent 9480738 commit 13b72b3

File tree

11 files changed

+48
-55
lines changed

11 files changed

+48
-55
lines changed

sycl/include/sycl/detail/common_info.hpp

Lines changed: 0 additions & 24 deletions
This file was deleted.

sycl/source/detail/common.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
//===----------------------------------------------------------------------===//
88

99
#include <sycl/detail/common.hpp>
10-
#include <sycl/detail/common_info.hpp>
1110

1211
namespace sycl {
1312
inline namespace _V1 {
@@ -70,28 +69,6 @@ const char *stringifyErrorCode(pi_int32 error) {
7069
return "Unknown error code";
7170
}
7271
}
73-
74-
std::vector<std::string> split_string(const std::string &str, char delimeter) {
75-
std::vector<std::string> Result;
76-
size_t Start = 0;
77-
size_t End = 0;
78-
while ((End = str.find(delimeter, Start)) != std::string::npos) {
79-
Result.push_back(str.substr(Start, End - Start));
80-
Start = End + 1;
81-
}
82-
// Get the last substring and ignore the null character so we wouldn't get
83-
// double null characters \0\0 at the end of the substring
84-
End = str.find('\0');
85-
if (Start < End) {
86-
std::string LastSubStr(str.substr(Start, End - Start));
87-
// In case str has a delimeter at the end, the substring will be empty, so
88-
// we shouldn't add it to the final vector
89-
if (!LastSubStr.empty())
90-
Result.push_back(LastSubStr);
91-
}
92-
return Result;
93-
}
94-
9572
} // namespace detail
9673
} // namespace _V1
9774
} // namespace sycl

sycl/source/detail/device_info.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <detail/platform_util.hpp>
1313
#include <detail/plugin.hpp>
1414
#include <detail/program_manager/program_manager.hpp>
15-
#include <sycl/detail/common_info.hpp>
1615
#include <sycl/detail/defines.hpp>
1716
#include <sycl/detail/os_util.hpp>
1817
#include <sycl/detail/pi.hpp>
@@ -27,6 +26,8 @@
2726
#include <chrono>
2827
#include <thread>
2928

29+
#include "split_string.hpp"
30+
3031
namespace sycl {
3132
inline namespace _V1 {
3233
namespace detail {

sycl/source/detail/kernel_bundle_impl.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include <sycl/backend_types.hpp>
1616
#include <sycl/context.hpp>
1717
#include <sycl/detail/common.hpp>
18-
#include <sycl/detail/common_info.hpp>
1918
#include <sycl/detail/pi.h>
2019
#include <sycl/device.hpp>
2120
#include <sycl/kernel_bundle.hpp>
@@ -27,6 +26,8 @@
2726
#include <memory>
2827
#include <vector>
2928

29+
#include "split_string.hpp"
30+
3031
namespace sycl {
3132
inline namespace _V1 {
3233
namespace detail {

sycl/source/detail/kernel_compiler/kernel_compiler_opencl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include <sycl/detail/common_info.hpp> // split_string
109
#include <sycl/detail/pi.hpp> // getOsLibraryFuncAddress
1110
#include <sycl/exception.hpp> // make_error_code
1211

1312
#include "kernel_compiler_opencl.hpp"
1413

1514
#include "../online_compiler/ocloc_api.h"
15+
#include "../split_string.hpp"
1616

1717
#include <cstring> // strlen
1818
#include <numeric> // for std::accumulate

sycl/source/detail/kernel_info.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
#include <detail/error_handling/error_handling.hpp>
1212
#include <sycl/detail/common.hpp>
13-
#include <sycl/detail/common_info.hpp>
1413
#include <sycl/detail/info_desc_helpers.hpp>
1514
#include <sycl/detail/pi.hpp>
1615
#include <sycl/device.hpp>

sycl/source/detail/platform_info.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
#pragma once
1010
#include <detail/plugin.hpp>
1111
#include <sycl/detail/common.hpp>
12-
#include <sycl/detail/common_info.hpp>
1312
#include <sycl/detail/info_desc_helpers.hpp>
1413
#include <sycl/detail/pi.hpp>
1514
#include <sycl/info/info_desc.hpp>
1615

16+
#include "split_string.hpp"
17+
1718
namespace sycl {
1819
inline namespace _V1 {
1920
namespace detail {

sycl/source/detail/program_impl.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <detail/program_manager/program_manager.hpp>
1212
#include <detail/spec_constant_impl.hpp>
1313
#include <sycl/context.hpp>
14-
#include <sycl/detail/common_info.hpp>
1514
#include <sycl/detail/kernel_desc.hpp>
1615
#include <sycl/device.hpp>
1716
#include <sycl/property_list.hpp>

sycl/source/detail/split_string.hpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//==------------ split_string.hpp ------------------------------------------==//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#pragma once
10+
11+
#include <string>
12+
#include <string_view>
13+
#include <vector>
14+
15+
namespace sycl {
16+
inline namespace _V1 {
17+
namespace detail {
18+
inline std::vector<std::string> split_string(std::string_view str,
19+
char delimeter) {
20+
std::vector<std::string> Result;
21+
size_t Start = 0;
22+
size_t End = 0;
23+
while ((End = str.find(delimeter, Start)) != std::string::npos) {
24+
Result.emplace_back(str.substr(Start, End - Start));
25+
Start = End + 1;
26+
}
27+
// Get the last substring and ignore the null character so we wouldn't get
28+
// double null characters \0\0 at the end of the substring
29+
End = str.find('\0');
30+
if (Start < End) {
31+
std::string LastSubStr(str.substr(Start, End - Start));
32+
// In case str has a delimeter at the end, the substring will be empty, so
33+
// we shouldn't add it to the final vector
34+
if (!LastSubStr.empty())
35+
Result.push_back(LastSubStr);
36+
}
37+
return Result;
38+
}
39+
} // namespace detail
40+
} // namespace _V1
41+
} // namespace sycl

sycl/test/abi/sycl_symbols_linux.dump

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3264,7 +3264,6 @@ _ZN4sycl3_V16detail12sampler_implC2ENS0_29coordinate_normalization_modeENS0_15ad
32643264
_ZN4sycl3_V16detail12sampler_implC2EP11_cl_samplerRKNS0_7contextE
32653265
_ZN4sycl3_V16detail12sampler_implD1Ev
32663266
_ZN4sycl3_V16detail12sampler_implD2Ev
3267-
_ZN4sycl3_V16detail12split_stringERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEc
32683267
_ZN4sycl3_V16detail13MemoryManager10advise_usmEPKvSt10shared_ptrINS1_10queue_implEEm14_pi_mem_adviceSt6vectorIP9_pi_eventSaISB_EEPSB_
32693268
_ZN4sycl3_V16detail13MemoryManager10advise_usmEPKvSt10shared_ptrINS1_10queue_implEEm14_pi_mem_adviceSt6vectorIP9_pi_eventSaISB_EEPSB_RKS5_INS1_10event_implEE
32703269
_ZN4sycl3_V16detail13MemoryManager11copy_2d_usmEPKvmSt10shared_ptrINS1_10queue_implEEPvmmmSt6vectorIP9_pi_eventSaISB_EEPSB_

sycl/test/abi/sycl_symbols_windows.dump

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4585,7 +4585,6 @@
45854585
?size@image_impl@detail@_V1@sycl@@QEBA_KXZ
45864586
?size@stream@_V1@sycl@@QEBA_KXZ
45874587
?size@stream_impl@detail@_V1@sycl@@QEBA_KXZ
4588-
?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
45894588
?start@HostProfilingInfo@detail@_V1@sycl@@QEAAXXZ
45904589
?start_fusion@fusion_wrapper@experimental@codeplay@ext@_V1@sycl@@QEAAXXZ
45914590
?stringifyErrorCode@detail@_V1@sycl@@YAPEBDH@Z

0 commit comments

Comments
 (0)