Skip to content

Commit

Permalink
[SYCL] Move sycl::detail::split_string to sycl/source/detail (#13271)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
aelovikov-intel committed Apr 4, 2024
1 parent 9480738 commit 13b72b3
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 55 deletions.
24 changes: 0 additions & 24 deletions sycl/include/sycl/detail/common_info.hpp

This file was deleted.

23 changes: 0 additions & 23 deletions sycl/source/detail/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//

#include <sycl/detail/common.hpp>
#include <sycl/detail/common_info.hpp>

namespace sycl {
inline namespace _V1 {
Expand Down Expand Up @@ -70,28 +69,6 @@ const char *stringifyErrorCode(pi_int32 error) {
return "Unknown error code";
}
}

std::vector<std::string> split_string(const std::string &str, char delimeter) {
std::vector<std::string> 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
3 changes: 2 additions & 1 deletion sycl/source/detail/device_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <detail/platform_util.hpp>
#include <detail/plugin.hpp>
#include <detail/program_manager/program_manager.hpp>
#include <sycl/detail/common_info.hpp>
#include <sycl/detail/defines.hpp>
#include <sycl/detail/os_util.hpp>
#include <sycl/detail/pi.hpp>
Expand All @@ -27,6 +26,8 @@
#include <chrono>
#include <thread>

#include "split_string.hpp"

namespace sycl {
inline namespace _V1 {
namespace detail {
Expand Down
3 changes: 2 additions & 1 deletion sycl/source/detail/kernel_bundle_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <sycl/backend_types.hpp>
#include <sycl/context.hpp>
#include <sycl/detail/common.hpp>
#include <sycl/detail/common_info.hpp>
#include <sycl/detail/pi.h>
#include <sycl/device.hpp>
#include <sycl/kernel_bundle.hpp>
Expand All @@ -27,6 +26,8 @@
#include <memory>
#include <vector>

#include "split_string.hpp"

namespace sycl {
inline namespace _V1 {
namespace detail {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//

#include <sycl/detail/common_info.hpp> // split_string
#include <sycl/detail/pi.hpp> // getOsLibraryFuncAddress
#include <sycl/exception.hpp> // make_error_code

#include "kernel_compiler_opencl.hpp"

#include "../online_compiler/ocloc_api.h"
#include "../split_string.hpp"

#include <cstring> // strlen
#include <numeric> // for std::accumulate
Expand Down
1 change: 0 additions & 1 deletion sycl/source/detail/kernel_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#include <detail/error_handling/error_handling.hpp>
#include <sycl/detail/common.hpp>
#include <sycl/detail/common_info.hpp>
#include <sycl/detail/info_desc_helpers.hpp>
#include <sycl/detail/pi.hpp>
#include <sycl/device.hpp>
Expand Down
3 changes: 2 additions & 1 deletion sycl/source/detail/platform_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
#pragma once
#include <detail/plugin.hpp>
#include <sycl/detail/common.hpp>
#include <sycl/detail/common_info.hpp>
#include <sycl/detail/info_desc_helpers.hpp>
#include <sycl/detail/pi.hpp>
#include <sycl/info/info_desc.hpp>

#include "split_string.hpp"

namespace sycl {
inline namespace _V1 {
namespace detail {
Expand Down
1 change: 0 additions & 1 deletion sycl/source/detail/program_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <detail/program_manager/program_manager.hpp>
#include <detail/spec_constant_impl.hpp>
#include <sycl/context.hpp>
#include <sycl/detail/common_info.hpp>
#include <sycl/detail/kernel_desc.hpp>
#include <sycl/device.hpp>
#include <sycl/property_list.hpp>
Expand Down
41 changes: 41 additions & 0 deletions sycl/source/detail/split_string.hpp
Original file line number Diff line number Diff line change
@@ -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 <string>
#include <string_view>
#include <vector>

namespace sycl {
inline namespace _V1 {
namespace detail {
inline std::vector<std::string> split_string(std::string_view str,
char delimeter) {
std::vector<std::string> 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
1 change: 0 additions & 1 deletion sycl/test/abi/sycl_symbols_linux.dump
Original file line number Diff line number Diff line change
Expand Up @@ -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_
Expand Down
1 change: 0 additions & 1 deletion sycl/test/abi/sycl_symbols_windows.dump
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 13b72b3

Please sign in to comment.