Skip to content

Commit

Permalink
[ABI-Break][SYCL] Enable "Neutral" ABI in regards to C++11 ABI by def…
Browse files Browse the repository at this point in the history
…ault (#13183)

Co-authored-by: Alexey Bader <[email protected]>
  • Loading branch information
aelovikov-intel and bader authored Apr 1, 2024
1 parent ff9e48a commit f70ad5b
Show file tree
Hide file tree
Showing 19 changed files with 394 additions and 615 deletions.
8 changes: 1 addition & 7 deletions sycl/include/sycl/detail/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
#ifndef __SYCL_DEVICE_ONLY

#include <sycl/detail/defines.hpp>
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
#include <sycl/detail/string.hpp>
#endif

#include <cstring>
#include <mutex>
#include <vector>
Expand Down Expand Up @@ -69,7 +68,6 @@ 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>.
Expand All @@ -85,10 +83,6 @@ template <> struct ABINeutralT<std::vector<std::string>> {
};

template <typename T> using ABINeutralT_t = typename ABINeutralT<T>::type;
#else
template <typename T> using ABINeutralT_t = T;
#endif

} // namespace detail
} // namespace _V1
} // namespace sycl
Expand Down
11 changes: 0 additions & 11 deletions sycl/include/sycl/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
#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>
Expand Down Expand Up @@ -221,17 +219,10 @@ 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>
detail::ABINeutralT_t<
typename detail::is_device_info_desc<Param>::return_type>
get_info() const;
#endif

/// Queries this SYCL device for SYCL backend-specific information.
///
Expand Down Expand Up @@ -377,12 +368,10 @@ class __SYCL_EXPORT device : public detail::OwnerLessBase<device> {
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 Down
13 changes: 0 additions & 13 deletions sycl/include/sycl/exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,13 @@ 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 @@ -137,16 +129,11 @@ class __SYCL_EXPORT exception : public virtual std::exception {
// base constructor for all SYCL 2020 constructors
// exception(context *ctxPtr, std::error_code Ec, const std::string
// &what_arg);
#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 Down
21 changes: 0 additions & 21 deletions sycl/include/sycl/handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@
#include <sycl/detail/pi.h>
#include <sycl/detail/pi.hpp>
#include <sycl/detail/reduction_forward.hpp>
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
#include <sycl/detail/string.hpp>
#include <sycl/detail/string_view.hpp>
#endif
#include <sycl/device.hpp>
#include <sycl/event.hpp>
#include <sycl/exception.hpp>
Expand Down Expand Up @@ -422,11 +420,6 @@ template <int Dims> bool range_size_fits_in_size_t(const range<Dims> &r) {
}
return true;
}
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
using string = std::string;
using string_view = std::string;
#endif

} // namespace detail

/// Command group handler class.
Expand Down Expand Up @@ -872,14 +865,10 @@ 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) {
verifyUsedKernelBundleInternal(detail::string_view{KernelName});
}
void verifyUsedKernelBundleInternal(detail::string_view KernelName);
#else
void verifyUsedKernelBundle(const std::string &KernelName);
#endif

/// Stores lambda to the template-free object
///
Expand Down Expand Up @@ -3414,35 +3403,25 @@ 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);
#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;
friend class ext::oneapi::experimental::detail::dynamic_parameter_impl;

Expand Down
8 changes: 0 additions & 8 deletions sycl/include/sycl/kernel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
#include <sycl/detail/info_desc_helpers.hpp> // for is_kernel_device_specif...
#include <sycl/detail/owner_less_base.hpp> // for OwnerLessBase
#include <sycl/detail/pi.h> // for pi_native_handle
#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.hpp> // for device
#include <sycl/kernel_bundle_enums.hpp> // for bundle_state
Expand Down Expand Up @@ -142,13 +140,9 @@ class __SYCL_EXPORT kernel : public detail::OwnerLessBase<kernel> {
///
/// \return depends on information being queried.
template <typename Param>
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
typename detail::is_kernel_info_desc<Param>::return_type get_info() const {
return detail::convert_from_abi_neutral(get_info_impl<Param>());
}
#else
typename detail::is_kernel_info_desc<Param>::return_type get_info() const;
#endif

/// Queries the kernel object for SYCL backend-specific information.
///
Expand Down Expand Up @@ -201,12 +195,10 @@ class __SYCL_EXPORT kernel : public detail::OwnerLessBase<kernel> {
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_kernel_info_desc<Param>::return_type>
get_info_impl() const;
#endif
};
} // namespace _V1
} // namespace sycl
Expand Down
9 changes: 0 additions & 9 deletions sycl/include/sycl/kernel_bundle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
#include <sycl/detail/owner_less_base.hpp> // for OwnerLessBase
#include <sycl/detail/pi.h> // for pi_native_handle
#include <sycl/detail/pi.hpp> // for cast
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
#include <sycl/detail/string_view.hpp>
#endif
#include <sycl/device.hpp> // for device
#include <sycl/kernel.hpp> // for kernel, kernel_bundle
#include <sycl/kernel_bundle_enums.hpp> // for bundle_state
Expand Down Expand Up @@ -450,9 +448,6 @@ kernel_bundle(kernel_bundle<State> &&) -> kernel_bundle<State>;
/////////////////////////

namespace detail {
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
using string_view = std::string;
#endif
// Internal non-template versions of get_kernel_id API which is used by public
// onces
__SYCL_EXPORT kernel_id get_kernel_id_impl(string_view KernelName);
Expand All @@ -463,11 +458,7 @@ 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
return detail::get_kernel_id_impl(detail::string_view{KI::getName()});
#else
return detail::get_kernel_id_impl(KI::getName());
#endif
}

/// \returns a vector with all kernel_id's defined in the application
Expand Down
19 changes: 0 additions & 19 deletions sycl/include/sycl/platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
#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/info/info_desc.hpp>
Expand Down Expand Up @@ -58,7 +56,6 @@ class platform_impl;
void __SYCL_EXPORT enable_ext_oneapi_default_context(bool Val);

template <typename ParamT> auto convert_to_abi_neutral(ParamT &&Info) {
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
using ParamNoRef = std::remove_reference_t<ParamT>;
if constexpr (std::is_same_v<ParamNoRef, std::string>) {
return detail::string{Info};
Expand All @@ -72,13 +69,9 @@ template <typename ParamT> auto convert_to_abi_neutral(ParamT &&Info) {
} else {
return std::forward<ParamT>(Info);
}
#else
return std::forward<ParamT>(Info);
#endif
}

template <typename ParamT> auto convert_from_abi_neutral(ParamT &&Info) {
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
using ParamNoRef = std::remove_reference_t<ParamT>;
if constexpr (std::is_same_v<ParamNoRef, detail::string>) {
return Info.c_str();
Expand All @@ -93,9 +86,6 @@ template <typename ParamT> auto convert_from_abi_neutral(ParamT &&Info) {
} else {
return std::forward<ParamT>(Info);
}
#else
return std::forward<ParamT>(Info);
#endif
}
} // namespace detail
namespace ext::oneapi {
Expand Down Expand Up @@ -190,17 +180,10 @@ class __SYCL_EXPORT platform : public detail::OwnerLessBase<platform> {
/// Queries this SYCL platform for info.
///
/// The return type depends on information being queried.
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
template <typename Param>
typename detail::is_platform_info_desc<Param>::return_type get_info() const {
return detail::convert_from_abi_neutral(get_info_impl<Param>());
}
#else
template <typename Param>
detail::ABINeutralT_t<
typename detail::is_platform_info_desc<Param>::return_type>
get_info() const;
#endif

/// Queries this SYCL platform for SYCL backend-specific info.
///
Expand Down Expand Up @@ -269,12 +252,10 @@ class __SYCL_EXPORT platform : public detail::OwnerLessBase<platform> {
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_platform_info_desc<Param>::return_type>
get_info_impl() const;
#endif
}; // class platform
} // namespace _V1
} // namespace sycl
Expand Down
Loading

0 comments on commit f70ad5b

Please sign in to comment.