-
Notifications
You must be signed in to change notification settings - Fork 796
[SYCL] Initial changes for C++11 ABI=0 support #12193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 35 commits
2d34c19
4dabfd3
108bf4d
d7f21ab
34cd0b9
ded92db
77aaeba
fa6a931
5709e28
da8ab9f
841f042
a79d58f
74bb97d
7cebd8d
20448f7
95f48f8
f0aa89c
a1e4479
312cda8
1db3ca8
d83490d
273f4b0
ac1ee03
436288b
84f8e2d
db67a87
66c0405
4823b25
cff7fae
3af523e
f918818
316627a
741db80
2db4e56
22a59c6
4e28f9f
e24da9c
f707404
272e400
67ecf71
e385649
8a9aaaf
2adf0fb
a309a8d
537491d
8fc92b8
f9a9af4
0aa4158
b51cb8a
6e7da0a
05a0ca1
ecb8ce9
6f36028
f4655aa
a04fc0c
a803e6d
a22fd4a
429c7a3
b18eb02
4f0d634
9d9cf42
921b754
bf313f1
32a0401
431ac8d
a4c2ffa
273248b
182afc7
0a97845
d62e175
3fdd985
8d1fa21
232e759
019d30b
36e5dd8
b074631
524d53d
4f9b8d4
fa1ae30
7095cf7
d6c7ddc
82febee
1748dea
5a37c73
7780ca5
3bc950d
0bf1237
f31b89c
037a13b
962fa26
d6ab3ca
7eb7314
a11280e
f85a76a
1327442
05dc42d
050509e
dd8e563
ffa36e1
5c0b8a1
28ad4fc
823614d
c702858
f1bf10d
43a7823
37be2ba
82908d5
1ca910c
d88422a
b48f868
6e18644
0d19467
85b7d36
b79a347
1650d6d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| //==----------------- string.hpp - SYCL standard header file ---------------==// | ||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include <cstring> | ||
| #include <string> | ||
|
|
||
| #pragma once | ||
|
|
||
| namespace sycl { | ||
| inline namespace _V1 { | ||
| namespace detail { | ||
|
|
||
| // This class and detail::string_view class are intended to support | ||
| // different ABIs between libsycl and the user program. | ||
| // This class is not inteded to replace std::string for general purpose usage. | ||
| class string { | ||
| char *str = nullptr; | ||
|
|
||
| public: | ||
| string() { | ||
| allocate(1); | ||
| *str = '\0'; | ||
| } | ||
|
|
||
| string(const std::string_view &strn) { | ||
| allocate(strn.length() + 1); | ||
| strcpy(str, strn.data()); | ||
bso-intel marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| string(string &&strn) { | ||
| str = strn.str; | ||
| strn.str = nullptr; | ||
| } | ||
| string(const string &strn) { | ||
| allocate(strlen(strn.str) + 1); | ||
| strcpy(str, strn.str); | ||
| } | ||
|
|
||
| string &operator=(string &&strn) { | ||
| delete[] str; | ||
| str = strn.str; | ||
| strn.str = nullptr; | ||
| return *this; | ||
| } | ||
| string &operator=(const string &strn) { | ||
| allocate(strlen(strn.str) + 1); | ||
| strcpy(str, strn.str); | ||
| return *this; | ||
| } | ||
|
|
||
| string &operator=(const std::string_view &strn) { | ||
| allocate(strn.length() + 1); | ||
| strcpy(str, strn.data()); | ||
| return *this; | ||
| } | ||
|
|
||
| ~string() { delete[] str; } | ||
|
|
||
| const char *c_str() { return str; } | ||
| const char *c_str() const { return str; } | ||
|
|
||
| friend bool operator==(const string &lhs, const std::string_view &rhs) { | ||
| return rhs == lhs.c_str(); | ||
| } | ||
| friend bool operator==(const std::string_view &lhs, const string &rhs) { | ||
| return lhs == rhs.c_str(); | ||
| } | ||
|
|
||
| private: | ||
| void allocate(int size) { | ||
| delete[] str; | ||
| str = new char[size]; | ||
bso-intel marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| }; | ||
|
|
||
| } // namespace detail | ||
| } // namespace _V1 | ||
| } // namespace sycl | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| //==-------------- string_view.hpp - SYCL standard header file -------------==// | ||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include <string> | ||
|
|
||
| #pragma once | ||
|
|
||
| namespace sycl { | ||
| inline namespace _V1 { | ||
| namespace detail { | ||
|
|
||
| // This class and detail::string class are intended to support | ||
| // different ABIs between libsycl and the user program. | ||
| // This class is not inteded to replace std::string_view for general purpose | ||
| // usage. | ||
| class string_view { | ||
| const char *str = nullptr; | ||
|
|
||
| public: | ||
| string_view() = default; | ||
| string_view(const string_view &strn) = default; | ||
| string_view(const std::string_view &strn) : str(strn.data()) {} | ||
| string_view(string_view &&strn) : str(strn.data()) {} | ||
|
|
||
| string_view &operator=(string_view &&strn) { | ||
| str = strn.str; | ||
| return *this; | ||
| } | ||
| string_view &operator=(const string_view &strn) { | ||
| str = strn.str; | ||
| return *this; | ||
| } | ||
|
|
||
| string_view &operator=(string &&strn) { | ||
| str = strn.c_str(); | ||
| return *this; | ||
| } | ||
| string_view &operator=(const string &strn) { | ||
| str = strn.c_str(); | ||
| return *this; | ||
| } | ||
|
|
||
| string_view &operator=(const std::string_view &strn) { | ||
| str = strn.data(); | ||
| return *this; | ||
| } | ||
|
|
||
| const char *data() { return str; } | ||
| const char *data() const { return str; } | ||
|
|
||
| friend bool operator==(const string_view &lhs, const std::string_view &rhs) { | ||
| return rhs == lhs.data(); | ||
| } | ||
| friend bool operator==(const std::string_view &lhs, const string_view &rhs) { | ||
| return lhs == rhs.data(); | ||
| } | ||
| }; | ||
|
|
||
| } // namespace detail | ||
| } // namespace _V1 | ||
| } // namespace sycl |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,8 @@ | |
| #include <sycl/detail/pi.h> | ||
| #include <sycl/detail/pi.hpp> | ||
| #include <sycl/detail/reduction_forward.hpp> | ||
| #include <sycl/detail/string.hpp> | ||
| #include <sycl/detail/string_view.hpp> | ||
| #include <sycl/device.hpp> | ||
| #include <sycl/event.hpp> | ||
| #include <sycl/exception.hpp> | ||
|
|
@@ -548,7 +550,11 @@ class __SYCL_EXPORT handler { | |
| bool IsKernelCreatedFromSource, bool IsESIMD); | ||
|
|
||
| /// \return a string containing name of SYCL kernel. | ||
| #ifdef __INTEL_PREVIEW_BREAKING_CHANGES | ||
| detail::string getKernelName(); | ||
| #else | ||
| std::string getKernelName(); | ||
| #endif | ||
|
|
||
| template <typename LambdaNameT> bool lambdaAndKernelHaveEqualName() { | ||
| // TODO It is unclear a kernel and a lambda/functor must to be equal or not | ||
|
|
@@ -558,8 +564,12 @@ class __SYCL_EXPORT handler { | |
| // values of arguments for the kernel. | ||
| assert(MKernel && "MKernel is not initialized"); | ||
| const std::string LambdaName = detail::KernelInfo<LambdaNameT>::getName(); | ||
| #ifdef __INTEL_PREVIEW_BREAKING_CHANGES | ||
| detail::string KernelName = getKernelName(); | ||
bso-intel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #else | ||
| const std::string KernelName = getKernelName(); | ||
| return LambdaName == KernelName; | ||
| #endif | ||
| return KernelName == LambdaName; | ||
| } | ||
|
|
||
| /// Saves the location of user's code passed in \p CodeLoc for future usage in | ||
|
|
@@ -842,7 +852,15 @@ class __SYCL_EXPORT handler { | |
| /// | ||
| /// \param KernelName is the name of the SYCL kernel to check that the used | ||
| /// kernel bundle contains. | ||
| #ifdef __INTEL_PREVIEW_BREAKING_CHANGES | ||
| void verifyUsedKernelBundle(const std::string &KernelName) { | ||
| detail::string_view Name(KernelName); | ||
| verifyUsedKernelBundleInternal(Name); | ||
bso-intel marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| void verifyUsedKernelBundleInternal(detail::string_view KernelName); | ||
| #else | ||
| void verifyUsedKernelBundle(const std::string &KernelName); | ||
| #endif | ||
|
|
||
| /// Stores lambda to the template-free object | ||
| /// | ||
|
|
@@ -894,7 +912,11 @@ class __SYCL_EXPORT handler { | |
| extractArgsAndReqsFromLambda(reinterpret_cast<char *>(KernelPtr), | ||
| KI::getNumParams(), &KI::getParamDesc(0), | ||
| KI::isESIMD()); | ||
| #ifdef __INTEL_PREVIEW_BREAKING_CHANGES | ||
| MKernelName = detail::string(KI::getName()); | ||
| #else | ||
bso-intel marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| MKernelName = KI::getName(); | ||
| #endif | ||
| } else { | ||
| // In case w/o the integration header it is necessary to process | ||
| // accessors from the list(which are associated with this handler) as | ||
|
|
@@ -3294,7 +3316,11 @@ class __SYCL_EXPORT handler { | |
| std::vector<detail::ArgDesc> MAssociatedAccesors; | ||
| /// Struct that encodes global size, local size, ... | ||
| detail::NDRDescT MNDRDesc; | ||
| #ifdef __INTEL_PREVIEW_BREAKING_CHANGES | ||
| detail::string MKernelName; | ||
|
||
| #else | ||
| std::string MKernelName; | ||
| #endif | ||
| /// Storage for a sycl::kernel object. | ||
| std::shared_ptr<detail::kernel_impl> MKernel; | ||
| /// Type of the command group, e.g. kernel, fill. Can also encode version. | ||
|
|
@@ -3396,17 +3422,35 @@ class __SYCL_EXPORT handler { | |
| /// expr m_Storage member | ||
| /// \param Size the size of data getting read back / to. | ||
| /// \param Block if read operation is blocking, default to false. | ||
| #ifdef __INTEL_PREVIEW_BREAKING_CHANGES | ||
| void ext_intel_read_host_pipe(const std::string &Name, void *Ptr, size_t Size, | ||
| bool Block = false) { | ||
| ext_intel_read_host_pipe(detail::string_view(Name), Ptr, Size, Block); | ||
| } | ||
| void ext_intel_read_host_pipe(detail::string_view Name, void *Ptr, | ||
| size_t Size, bool Block = false); | ||
aelovikov-intel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #else | ||
| void ext_intel_read_host_pipe(const std::string &Name, void *Ptr, size_t Size, | ||
| bool Block = false); | ||
| #endif | ||
|
|
||
| /// Write to host pipes given a host address and | ||
| /// \param Name name of the host pipe to be passed into lower level runtime | ||
| /// \param Ptr host pointer of host pipe as identified by address of its const | ||
| /// expr m_Storage member | ||
| /// \param Size the size of data getting read back / to. | ||
| /// \param Block if write opeartion is blocking, default to false. | ||
| #ifdef __INTEL_PREVIEW_BREAKING_CHANGES | ||
| void ext_intel_write_host_pipe(const std::string &Name, void *Ptr, | ||
| size_t Size, bool Block = false) { | ||
| ext_intel_write_host_pipe(detail::string_view(Name), Ptr, Size, Block); | ||
| } | ||
| void ext_intel_write_host_pipe(detail::string_view Name, void *Ptr, | ||
| size_t Size, bool Block = false); | ||
| #else | ||
| void ext_intel_write_host_pipe(const std::string &Name, void *Ptr, | ||
| size_t Size, bool Block = false); | ||
| #endif | ||
| friend class ext::oneapi::experimental::detail::graph_impl; | ||
|
|
||
| bool DisableRangeRounding(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,7 +46,7 @@ auto get_native(const kernel_bundle<State> &Obj) | |
| namespace detail { | ||
| class kernel_id_impl; | ||
| class kernel_impl; | ||
| } | ||
| } // namespace detail | ||
|
|
||
| template <typename KernelName> kernel_id get_kernel_id(); | ||
|
|
||
|
|
@@ -446,15 +446,23 @@ kernel_bundle(kernel_bundle<State> &&) -> kernel_bundle<State>; | |
| namespace detail { | ||
| // Internal non-template versions of get_kernel_id API which is used by public | ||
| // onces | ||
| #ifdef __INTEL_PREVIEW_BREAKING_CHANGES | ||
| __SYCL_EXPORT kernel_id get_kernel_id_impl(string_view KernelName); | ||
| #else | ||
| __SYCL_EXPORT kernel_id get_kernel_id_impl(std::string KernelName); | ||
| #endif | ||
| } // namespace detail | ||
|
|
||
| /// \returns the kernel_id associated with the KernelName | ||
| template <typename KernelName> kernel_id get_kernel_id() { | ||
| // FIXME: This must fail at link-time if KernelName not in any available | ||
| // translation units. | ||
| using KI = sycl::detail::KernelInfo<KernelName>; | ||
| #ifdef __INTEL_PREVIEW_BREAKING_CHANGES | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should be able to drop the else branch in favor of this one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks a lot, I will address it in a follow-up PR. |
||
| return detail::get_kernel_id_impl(detail::string_view(KI::getName())); | ||
| #else | ||
bso-intel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return detail::get_kernel_id_impl(KI::getName()); | ||
| #endif | ||
| } | ||
|
|
||
| /// \returns a vector with all kernel_id's defined in the application | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.