Skip to content
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

[SYCL] Initial changes for C++11 ABI=0 support #12193

Merged
merged 115 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from 113 commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
2d34c19
[SYCL] Initial change for C++11 ABI=0 support
bso-intel Dec 15, 2023
4dabfd3
clang-format fix
bso-intel Dec 15, 2023
108bf4d
Merge remote-tracking branch 'upstream/sycl' into abi
bso-intel Dec 15, 2023
d7f21ab
clang-format
bso-intel Dec 15, 2023
34cd0b9
format
bso-intel Dec 15, 2023
ded92db
fix mockup
bso-intel Dec 15, 2023
77aaeba
fix test
bso-intel Dec 15, 2023
fa6a931
fix test
bso-intel Dec 15, 2023
5709e28
fix test
bso-intel Dec 15, 2023
da8ab9f
address feedback
bso-intel Jan 4, 2024
841f042
clang-format
bso-intel Jan 4, 2024
a79d58f
guard preview-break-changes
bso-intel Jan 9, 2024
74bb97d
Update sycl/include/sycl/platform.hpp
bso-intel Jan 10, 2024
7cebd8d
guard
bso-intel Jan 10, 2024
20448f7
added comments
bso-intel Jan 11, 2024
95f48f8
adjusted comment
bso-intel Jan 11, 2024
f0aa89c
added support for get_kernel_id
bso-intel Jan 17, 2024
a1e4479
changed param type to reference
bso-intel Jan 23, 2024
312cda8
clang-format
bso-intel Jan 23, 2024
1db3ca8
separate string and string_view
bso-intel Jan 23, 2024
d83490d
address feedback
bso-intel Jan 24, 2024
273f4b0
removed marshall
bso-intel Jan 24, 2024
ac1ee03
address feedback
bso-intel Jan 24, 2024
436288b
fixed typo in comments
bso-intel Jan 24, 2024
84f8e2d
fixed again
bso-intel Jan 24, 2024
db67a87
address feedback
bso-intel Jan 25, 2024
66c0405
Update sycl/include/sycl/detail/string.hpp
bso-intel Jan 25, 2024
4823b25
Update sycl/include/sycl/detail/string.hpp
bso-intel Jan 25, 2024
cff7fae
remove
bso-intel Jan 25, 2024
3af523e
remove
bso-intel Jan 25, 2024
f918818
fix string_view
bso-intel Jan 25, 2024
316627a
address feedback
bso-intel Jan 25, 2024
741db80
include
bso-intel Jan 25, 2024
2db4e56
Update sycl/include/sycl/detail/string.hpp
bso-intel Jan 26, 2024
22a59c6
address feedback
bso-intel Jan 26, 2024
4e28f9f
address feedback
bso-intel Jan 31, 2024
e24da9c
missed char
bso-intel Jan 31, 2024
f707404
Merge branch 'sycl' into abi
bso-intel Jan 31, 2024
272e400
support return vec
bso-intel Feb 1, 2024
67ecf71
address feedback
bso-intel Feb 1, 2024
e385649
address feedback again
bso-intel Feb 5, 2024
8a9aaaf
pass std::string_view by value
bso-intel Feb 5, 2024
2adf0fb
more feedback
bso-intel Feb 6, 2024
a309a8d
ref removed
bso-intel Feb 6, 2024
537491d
fix
bso-intel Feb 6, 2024
8fc92b8
remove refs
bso-intel Feb 6, 2024
f9a9af4
return empty string
bso-intel Feb 6, 2024
0aa4158
default move
bso-intel Feb 7, 2024
b51cb8a
Update sycl/include/sycl/detail/string_view.hpp
bso-intel Feb 7, 2024
6e7da0a
feedback addressed
bso-intel Feb 7, 2024
05a0ca1
support exception
bso-intel Feb 8, 2024
ecb8ce9
Update sycl/include/sycl/handler.hpp
bso-intel Feb 9, 2024
6f36028
more feedback addressed
bso-intel Feb 9, 2024
f4655aa
fix get_info
bso-intel Feb 10, 2024
a04fc0c
fix platform prop
bso-intel Feb 11, 2024
a803e6d
replace string with enum
bso-intel Feb 12, 2024
a22fd4a
variant return struct
bso-intel Feb 13, 2024
429c7a3
fix errors
bso-intel Feb 14, 2024
b18eb02
added missing declaration
bso-intel Feb 14, 2024
4f0d634
fixed return type
bso-intel Feb 14, 2024
9d9cf42
cleanup comments
bso-intel Feb 14, 2024
921b754
silence the return type error
bso-intel Feb 14, 2024
bf313f1
fixed undefined reference
bso-intel Feb 14, 2024
32a0401
fixed undefined refs
bso-intel Feb 14, 2024
431ac8d
use template
bso-intel Feb 14, 2024
a4c2ffa
fix platform template
bso-intel Feb 15, 2024
273248b
fix duplicate
bso-intel Feb 15, 2024
182afc7
fix export
bso-intel Feb 15, 2024
0a97845
common returntype
bso-intel Feb 15, 2024
d62e175
unify preview
bso-intel Feb 16, 2024
3fdd985
revert
bso-intel Feb 16, 2024
8d1fa21
reduce to one method
bso-intel Feb 16, 2024
232e759
Update sycl/include/sycl/device.hpp
bso-intel Feb 16, 2024
019d30b
Update sycl/include/sycl/detail/util.hpp
bso-intel Feb 16, 2024
36e5dd8
Update sycl/include/sycl/detail/util.hpp
bso-intel Feb 16, 2024
b074631
Update sycl/include/sycl/platform.hpp
bso-intel Feb 16, 2024
524d53d
Update sycl/source/device.cpp
bso-intel Feb 16, 2024
4f9b8d4
Update sycl/source/platform.cpp
bso-intel Feb 16, 2024
fa1ae30
address feedback
bso-intel Feb 16, 2024
7095cf7
fix win abi symbols
bso-intel Feb 16, 2024
d6c7ddc
try alias
bso-intel Feb 19, 2024
82febee
missed #ifdef
bso-intel Feb 19, 2024
1748dea
fake detail::string
bso-intel Feb 19, 2024
5a37c73
Merge branch 'sergey2' into abi
bso-intel Feb 19, 2024
7780ca5
remove #ifdef
bso-intel Feb 20, 2024
3bc950d
add symbol
bso-intel Feb 20, 2024
0bf1237
windows symbol
bso-intel Feb 20, 2024
f31b89c
avoid duplicate body
bso-intel Feb 21, 2024
037a13b
Merge branch 'abi' of https://github.com/bso-intel/llvm into abi
bso-intel Feb 21, 2024
962fa26
try template
bso-intel Feb 22, 2024
d6ab3ca
template
bso-intel Feb 22, 2024
7eb7314
Merge remote-tracking branch 'upstream/sycl' into abi
bso-intel Feb 22, 2024
a11280e
rename
bso-intel Feb 22, 2024
f85a76a
remove param
bso-intel Feb 23, 2024
1327442
define ABINeutralT_t
bso-intel Feb 23, 2024
05dc42d
deduce
bso-intel Feb 23, 2024
050509e
moved namespace
bso-intel Feb 23, 2024
dd8e563
Update sycl/include/sycl/platform.hpp
bso-intel Feb 27, 2024
ffa36e1
Update sycl/source/device.cpp
bso-intel Feb 27, 2024
5c0b8a1
Update sycl/source/device.cpp
bso-intel Feb 27, 2024
28ad4fc
Update sycl/source/device.cpp
bso-intel Feb 27, 2024
823614d
Update sycl/include/sycl/platform.hpp
bso-intel Feb 27, 2024
c702858
change return type
bso-intel Feb 27, 2024
f1bf10d
WIP
aelovikov-intel Feb 27, 2024
43a7823
WIP2
aelovikov-intel Feb 27, 2024
37be2ba
WIP3
aelovikov-intel Feb 27, 2024
82908d5
WIP4
aelovikov-intel Feb 27, 2024
1ca910c
This is an ABI break
aelovikov-intel Feb 27, 2024
d88422a
But not anymore if do it like this.
aelovikov-intel Feb 27, 2024
b48f868
Merge remote-tracking branch 'andrei1/for-byoungro' into andrei3
bso-intel Feb 27, 2024
6e18644
merge
bso-intel Feb 27, 2024
0d19467
address feedback
bso-intel Feb 28, 2024
85b7d36
keep both
bso-intel Feb 28, 2024
b79a347
Update sycl/source/device.cpp
bso-intel Feb 29, 2024
1650d6d
Update sycl/include/sycl/device.hpp
bso-intel Feb 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions sycl/include/sycl/detail/string.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
//==----------------- 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>

jopperm marked this conversation as resolved.
Show resolved Hide resolved
#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() noexcept = default;
~string() { delete[] str; }

string(std::string_view strn) {
size_t len = strn.length();
str = new char[len + 1];
strn.copy(str, len);
str[len] = 0;
}

friend void swap(string &lhs, string &rhs) noexcept {
std::swap(lhs.str, rhs.str);
}

string(string &&other) noexcept { swap(*this, other); }
string(const string &other) {
if (other.str == nullptr)
return;
*this = string{other.str};
}

string &operator=(string &&other) noexcept {
swap(*this, other);
return *this;
}
string &operator=(const string &other) {
*this = string{other};
return *this;
}

string &operator=(std::string_view strn) {
*this = string{strn};
return *this;
}

const char *c_str() const noexcept { return str ? str : ""; }

friend bool operator==(const string &lhs, std::string_view rhs) noexcept {
return rhs == lhs.c_str();
}
friend bool operator==(std::string_view lhs, const string &rhs) noexcept {
return lhs == rhs.c_str();
}
};

} // namespace detail
} // namespace _V1
} // namespace sycl
52 changes: 52 additions & 0 deletions sycl/include/sycl/detail/string_view.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//==-------------- 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() noexcept = default;
string_view(const string_view &strn) noexcept = default;
string_view(string_view &&strn) noexcept = default;
string_view(std::string_view strn) noexcept : str(strn.data()) {}

string_view &operator=(string_view &&strn) noexcept = default;
string_view &operator=(const string_view &strn) noexcept = default;

string_view &operator=(std::string_view strn) noexcept {
str = strn.data();
return *this;
}

const char *data() const noexcept { return str; }

friend bool operator==(const string_view &lhs,
std::string_view rhs) noexcept {
return rhs == lhs.data();
}
friend bool operator==(std::string_view lhs,
const string_view &rhs) noexcept {
return lhs == rhs.data();
}
};

} // namespace detail
} // namespace _V1
} // namespace sycl
24 changes: 23 additions & 1 deletion sycl/include/sycl/detail/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
#ifndef __SYCL_DEVICE_ONLY

#include <sycl/detail/defines.hpp>

#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
bso-intel marked this conversation as resolved.
Show resolved Hide resolved
#include <sycl/detail/string.hpp>
#endif
#include <cstring>
#include <mutex>
#include <vector>
Expand Down Expand Up @@ -67,6 +69,26 @@ struct CmpCStr {

using SerializedObj = std::vector<unsigned char>;

#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
template <typename T> struct ABINeutralT { using type = T; };
// We need special handling of std::string to handle ABI incompatibility
// for get_info<>() when it returns std::string and vector<std::string>.
// For this purpose, get_info_impl<>() is created to handle special
// cases, and it is only called internally and not exposed to the user.
// The following ReturnType structure is intended for general return type,
// and special return types (std::string and vector of it).

template <> struct ABINeutralT<std::string> { using type = detail::string; };

template <> struct ABINeutralT<std::vector<std::string>> {
using type = std::vector<detail::string>;
};

template <typename T> using ABINeutralT_t = typename ABINeutralT<T>::type;
#else
template <typename T> using ABINeutralT_t = T;
#endif
bso-intel marked this conversation as resolved.
Show resolved Hide resolved

} // namespace detail
} // namespace _V1
} // namespace sycl
Expand Down
61 changes: 42 additions & 19 deletions sycl/include/sycl/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,30 @@

#pragma once

#include <sycl/aspects.hpp> // for aspect
#include <sycl/backend_types.hpp> // for backend
#include <sycl/detail/defines_elementary.hpp> // for __SY...
#include <sycl/detail/export.hpp> // for __SY...
#include <sycl/detail/info_desc_helpers.hpp> // for is_d...
#include <sycl/detail/owner_less_base.hpp> // for Owne...
#include <sycl/detail/pi.h> // for pi_n...
#include <sycl/device_selector.hpp> // for Enab...
#include <sycl/ext/oneapi/experimental/device_architecture.hpp> // for arch...
#include <sycl/info/info_desc.hpp> // for part...
#include <sycl/platform.hpp> // for plat...

#include <cstddef> // for size_t
#include <memory> // for shar...
#include <string> // for string
#include <type_traits> // for add_...
#include <variant> // for hash
#include <vector> // for vector
#include <sycl/aspects.hpp>
#include <sycl/backend_types.hpp>
#include <sycl/detail/defines_elementary.hpp>
#include <sycl/detail/export.hpp>
#include <sycl/detail/info_desc_helpers.hpp>
#include <sycl/detail/owner_less_base.hpp>
#include <sycl/detail/pi.h>
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
#include <sycl/detail/string.hpp>
#include <sycl/detail/string_view.hpp>
#endif
#include <sycl/detail/util.hpp>
#include <sycl/device_selector.hpp>
#include <sycl/ext/oneapi/experimental/device_architecture.hpp>
#include <sycl/info/info_desc.hpp>
#include <sycl/platform.hpp>

#include <cstddef>
#include <memory>
#include <string>
#include <type_traits>
#include <typeinfo>
#include <variant>
#include <vector>

namespace sycl {
inline namespace _V1 {
Expand Down Expand Up @@ -214,8 +220,17 @@ class __SYCL_EXPORT device : public detail::OwnerLessBase<device> {
/// type associated with the param parameter.
///
/// \return device info of type described in Table 4.20.
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
template <typename Param>
typename detail::is_device_info_desc<Param>::return_type get_info() const {
return detail::convert_from_abi_neutral(get_info_impl<Param>());
}
#else
template <typename Param>
typename detail::is_device_info_desc<Param>::return_type get_info() const;
detail::ABINeutralT_t<
typename detail::is_device_info_desc<Param>::return_type>
get_info() const;
#endif

/// Check SYCL extension support by device
///
Expand Down Expand Up @@ -291,6 +306,13 @@ class __SYCL_EXPORT device : public detail::OwnerLessBase<device> {
template <backend BackendName, class SyclObjectT>
friend auto get_native(const SyclObjectT &Obj)
-> backend_return_t<BackendName, SyclObjectT>;

#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
template <typename Param>
typename detail::ABINeutralT_t<
typename detail::is_device_info_desc<Param>::return_type>
get_info_impl() const;
#endif
};

} // namespace _V1
Expand All @@ -303,4 +325,5 @@ template <> struct hash<sycl::device> {
sycl::detail::getSyclObjImpl(Device));
}
};

bso-intel marked this conversation as resolved.
Show resolved Hide resolved
} // namespace std
42 changes: 30 additions & 12 deletions sycl/include/sycl/exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,21 @@ class __SYCL_EXPORT exception : public virtual std::exception {

exception(std::error_code, const char *Msg);

#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
exception(std::error_code Ec, const std::string &Msg)
: exception(Ec, nullptr, Msg.c_str()) {}
#else
exception(std::error_code, const std::string &Msg);
#endif

// new SYCL 2020 constructors
exception(std::error_code);
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
exception(int EV, const std::error_category &ECat, const std::string &WhatArg)
: exception(EV, ECat, WhatArg.c_str()) {}
#else
exception(int, const std::error_category &, const std::string &);
#endif
exception(int, const std::error_category &, const char *);
exception(int, const std::error_category &);

Expand Down Expand Up @@ -111,24 +121,32 @@ class __SYCL_EXPORT exception : public virtual std::exception {

protected:
// base constructors used by SYCL 1.2.1 exception subclasses
exception(std::error_code ec, const char *Msg, const pi_int32 PIErr,
exception(std::error_code Ec, const char *Msg, const pi_int32 PIErr,
std::shared_ptr<context> Context = nullptr)
: exception(ec, std::string(Msg), PIErr, Context) {}
: exception(Ec, std::string(Msg), PIErr, Context) {}

exception(std::error_code ec, const std::string &Msg, const pi_int32 PIErr,
exception(std::error_code Ec, const std::string &Msg, const pi_int32 PIErr,
std::shared_ptr<context> Context = nullptr)
: exception(ec, Context, Msg + " " + detail::codeToString(PIErr)) {
: exception(Ec, Context, Msg + " " + detail::codeToString(PIErr)) {
MPIErr = PIErr;
}

exception(const std::string &Msg)
: MMsg(std::make_shared<std::string>(Msg)), MContext(nullptr) {}

// base constructor for all SYCL 2020 constructors
// exception(context *ctxPtr, std::error_code ec, const std::string
// exception(context *ctxPtr, std::error_code Ec, const std::string
// &what_arg);
exception(std::error_code ec, std::shared_ptr<context> SharedPtrCtx,
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
exception(std::error_code Ec, std::shared_ptr<context> SharedPtrCtx,
const std::string &what_arg)
: exception(Ec, SharedPtrCtx, what_arg.c_str()) {}
exception(std::error_code Ec, std::shared_ptr<context> SharedPtrCtx,
const char *WhatArg);
#else
exception(std::error_code Ec, std::shared_ptr<context> SharedPtrCtx,
const std::string &what_arg);
#endif
};

class __SYCL2020_DEPRECATED(
Expand All @@ -143,12 +161,12 @@ class __SYCL2020_DEPRECATED(
runtime_error(const std::string &Msg, pi_int32 Err)
: exception(make_error_code(errc::runtime), Msg, Err) {}

runtime_error(std::error_code ec, const std::string &Msg,
runtime_error(std::error_code Ec, const std::string &Msg,
const pi_int32 PIErr)
: exception(ec, Msg, PIErr) {}
: exception(Ec, Msg, PIErr) {}

protected:
runtime_error(std::error_code ec) : exception(ec) {}
runtime_error(std::error_code Ec) : exception(Ec) {}
};

class __SYCL2020_DEPRECATED("use sycl::exception with sycl::errc::kernel or "
Expand Down Expand Up @@ -230,10 +248,10 @@ class __SYCL2020_DEPRECATED(
: exception(make_error_code(errc::invalid), Msg, Err) {}

protected:
device_error(std::error_code ec) : exception(ec) {}
device_error(std::error_code Ec) : exception(Ec) {}

device_error(std::error_code ec, const std::string &Msg, const pi_int32 PIErr)
: exception(ec, Msg, PIErr) {}
device_error(std::error_code Ec, const std::string &Msg, const pi_int32 PIErr)
: exception(Ec, Msg, PIErr) {}
};

class __SYCL2020_DEPRECATED(
Expand Down
Loading
Loading