Skip to content

Commit

Permalink
[SYCL] Fix weak_object on Windows (#7642)
Browse files Browse the repository at this point in the history
This commit makes the following fixes for weak_object and order_less for
Windows:
 1. Adds the new ABI symbols.
 2. Adds the missing include for std::optional in weak_object.hpp.
3. Fixes a problem where MSVC could not resolve createSyclObjFromImpl
for accessors due to a mismatch in template argument names between the
function declaration and the friend declaration.
4. Enables empty-base optimization on accessor classes inheriting from
OwnerLessBase when compiling with MSVC. This is needed as otherwise it
changes the size of the corresponding classes, which would be an ABI
break.

Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
  • Loading branch information
steffenlarsen authored Dec 5, 2022
1 parent 441bffe commit 9297f63
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 21 deletions.
40 changes: 19 additions & 21 deletions sycl/include/sycl/accessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,8 @@ class __SYCL_EXPORT AccessorBaseHost {
template <class Obj>
friend decltype(Obj::impl) getSyclObjImpl(const Obj &SyclObject);

template <class Obj>
friend Obj detail::createSyclObjFromImpl(decltype(Obj::impl) ImplObj);
template <class T>
friend T detail::createSyclObjFromImpl(decltype(T::impl) ImplObj);

template <typename, int, access::mode, access::target, access::placeholder,
typename>
Expand Down Expand Up @@ -541,8 +541,8 @@ class __SYCL_EXPORT LocalAccessorBaseHost {
template <class Obj>
friend decltype(Obj::impl) getSyclObjImpl(const Obj &SyclObject);

template <class Obj>
friend Obj detail::createSyclObjFromImpl(decltype(Obj::impl) ImplObj);
template <class T>
friend T detail::createSyclObjFromImpl(decltype(T::impl) ImplObj);

LocalAccessorImplPtr impl;
};
Expand Down Expand Up @@ -984,7 +984,7 @@ class __image_array_slice__ {
template <typename DataT, int Dimensions, access::mode AccessMode,
access::target AccessTarget, access::placeholder IsPlaceholder,
typename PropertyListT>
class __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
#ifndef __SYCL_DEVICE_ONLY__
public detail::AccessorBaseHost,
#endif
Expand Down Expand Up @@ -1226,8 +1226,8 @@ class __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
friend class sycl::stream;
friend class sycl::ext::intel::esimd::detail::AccessorPrivateProxy;

template <class Obj>
friend Obj detail::createSyclObjFromImpl(decltype(Obj::impl) ImplObj);
template <class T>
friend T detail::createSyclObjFromImpl(decltype(T::impl) ImplObj);

public:
// 4.7.6.9.1. Interface for buffer command accessors
Expand Down Expand Up @@ -2498,8 +2498,8 @@ class __SYCL_SPECIAL_CLASS local_accessor_base :
return Result;
}

template <class Obj>
friend Obj detail::createSyclObjFromImpl(decltype(Obj::impl) ImplObj);
template <class T>
friend T detail::createSyclObjFromImpl(decltype(T::impl) ImplObj);

public:
using value_type = DataT;
Expand Down Expand Up @@ -2649,8 +2649,8 @@ class __SYCL_SPECIAL_CLASS local_accessor_base :
// TODO: Remove deprecated specialization once no longer needed
template <typename DataT, int Dimensions, access::mode AccessMode,
access::placeholder IsPlaceholder>
class __SYCL_SPECIAL_CLASS accessor<DataT, Dimensions, AccessMode,
access::target::local, IsPlaceholder>
class __SYCL_EBO __SYCL_SPECIAL_CLASS accessor<
DataT, Dimensions, AccessMode, access::target::local, IsPlaceholder>
: public local_accessor_base<DataT, Dimensions, AccessMode, IsPlaceholder>,
public detail::OwnerLessBase<
accessor<DataT, Dimensions, AccessMode, access::target::local,
Expand Down Expand Up @@ -2687,7 +2687,7 @@ class __SYCL_SPECIAL_CLASS accessor<DataT, Dimensions, AccessMode,
};

template <typename DataT, int Dimensions = 1>
class __SYCL_SPECIAL_CLASS __SYCL_TYPE(local_accessor) local_accessor
class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(local_accessor) local_accessor
: public local_accessor_base<DataT, Dimensions, access::mode::read_write,
access::placeholder::false_t>,
public detail::OwnerLessBase<local_accessor<DataT, Dimensions>> {
Expand Down Expand Up @@ -2782,9 +2782,8 @@ class __SYCL_SPECIAL_CLASS __SYCL_TYPE(local_accessor) local_accessor
/// \ingroup sycl_api_acc
template <typename DataT, int Dimensions, access::mode AccessMode,
access::placeholder IsPlaceholder>
class __SYCL_SPECIAL_CLASS
__SYCL_TYPE(accessor) accessor<DataT, Dimensions, AccessMode,
access::target::image, IsPlaceholder>
class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor<
DataT, Dimensions, AccessMode, access::target::image, IsPlaceholder>
: public detail::image_accessor<DataT, Dimensions, AccessMode,
access::target::image, IsPlaceholder>,
public detail::OwnerLessBase<
Expand Down Expand Up @@ -2848,8 +2847,8 @@ __SYCL_TYPE(accessor) accessor<DataT, Dimensions, AccessMode,
/// \ingroup sycl_api_acc
template <typename DataT, int Dimensions, access::mode AccessMode,
access::placeholder IsPlaceholder>
class accessor<DataT, Dimensions, AccessMode, access::target::host_image,
IsPlaceholder>
class __SYCL_EBO accessor<DataT, Dimensions, AccessMode,
access::target::host_image, IsPlaceholder>
: public detail::image_accessor<DataT, Dimensions, AccessMode,
access::target::host_image, IsPlaceholder>,
public detail::OwnerLessBase<
Expand Down Expand Up @@ -2882,9 +2881,8 @@ class accessor<DataT, Dimensions, AccessMode, access::target::host_image,
/// \ingroup sycl_api_acc
template <typename DataT, int Dimensions, access::mode AccessMode,
access::placeholder IsPlaceholder>
class __SYCL_SPECIAL_CLASS
__SYCL_TYPE(accessor) accessor<DataT, Dimensions, AccessMode,
access::target::image_array, IsPlaceholder>
class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor<
DataT, Dimensions, AccessMode, access::target::image_array, IsPlaceholder>
: public detail::image_accessor<DataT, Dimensions + 1, AccessMode,
access::target::image, IsPlaceholder>,
public detail::OwnerLessBase<
Expand Down Expand Up @@ -2942,7 +2940,7 @@ __SYCL_TYPE(accessor) accessor<DataT, Dimensions, AccessMode,

template <typename DataT, int Dimensions = 1,
access_mode AccessMode = access_mode::read_write>
class host_accessor
class __SYCL_EBO host_accessor
: public accessor<DataT, Dimensions, AccessMode, target::host_buffer,
access::placeholder::false_t>,
public detail::OwnerLessBase<
Expand Down
8 changes: 8 additions & 0 deletions sycl/include/sycl/detail/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,14 @@ static inline std::string codeToString(pi_int32 code) {
__SYCL_REPORT_ERR_TO_EXC_THROW_VIA_ERRC(X, ERRC)
#endif

// Helper for enabling empty-base optimizations on MSVC.
// TODO: Remove this when MSVC has this optimization enabled by default.
#ifdef _MSC_VER
#define __SYCL_EBO __declspec(empty_bases)
#else
#define __SYCL_EBO
#endif

namespace sycl {
__SYCL_INLINE_VER_NAMESPACE(_V1) {
namespace detail {
Expand Down
2 changes: 2 additions & 0 deletions sycl/include/sycl/ext/oneapi/weak_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include <sycl/detail/defines_elementary.hpp>
#include <sycl/ext/oneapi/weak_object_base.hpp>

#include <optional>

namespace sycl {
__SYCL_INLINE_VER_NAMESPACE(_V1) {
namespace ext {
Expand Down
34 changes: 34 additions & 0 deletions sycl/test/abi/sycl_symbols_windows.dump
Original file line number Diff line number Diff line change
Expand Up @@ -338,12 +338,14 @@
??$has_property@Vuse_primary_context@cuda@context@property@_V1@sycl@@@image_plain@detail@_V1@sycl@@IEBA_NXZ
??$has_property@Vuse_primary_context@cuda@context@property@_V1@sycl@@@sampler@_V1@sycl@@QEBA_NXZ
??$has_property@Vuse_primary_context@cuda@context@property@_V1@sycl@@@stream@_V1@sycl@@QEBA_NXZ
??0AccessorBaseHost@detail@_V1@sycl@@IEAA@AEBV?$shared_ptr@VAccessorImplHost@detail@_V1@sycl@@@std@@@Z
??0AccessorBaseHost@detail@_V1@sycl@@QEAA@$$QEAV0123@@Z
??0AccessorBaseHost@detail@_V1@sycl@@QEAA@AEBV0123@@Z
??0AccessorBaseHost@detail@_V1@sycl@@QEAA@V?$id@$02@23@V?$range@$02@23@1W4mode@access@23@PEAXHHH_NAEBVproperty_list@23@@Z
??0AccessorImplHost@detail@_V1@sycl@@QEAA@AEBV0123@@Z
??0AccessorImplHost@detail@_V1@sycl@@QEAA@V?$id@$02@23@V?$range@$02@23@1W4mode@access@23@PEAXHHH_NAEBVproperty_list@23@@Z
??0HostProfilingInfo@detail@_V1@sycl@@QEAA@XZ
??0LocalAccessorBaseHost@detail@_V1@sycl@@IEAA@AEBV?$shared_ptr@VLocalAccessorImplHost@detail@_V1@sycl@@@std@@@Z
??0LocalAccessorBaseHost@detail@_V1@sycl@@QEAA@$$QEAV0123@@Z
??0LocalAccessorBaseHost@detail@_V1@sycl@@QEAA@AEBV0123@@Z
??0LocalAccessorBaseHost@detail@_V1@sycl@@QEAA@V?$range@$02@23@HHAEBVproperty_list@23@@Z
Expand Down Expand Up @@ -553,6 +555,22 @@
??1sampler_impl@detail@_V1@sycl@@QEAA@XZ
??1stream@_V1@sycl@@QEAA@XZ
??1stream_impl@detail@_V1@sycl@@QEAA@XZ
??4?$OwnerLessBase@Vcontext@_V1@sycl@@@detail@_V1@sycl@@QEAAAEAV0123@AEBV0123@@Z
??4?$OwnerLessBase@Vcontext@_V1@sycl@@@detail@_V1@sycl@@QEAAAEAV0123@$$QEAV0123@@Z
??4?$OwnerLessBase@Vdevice@_V1@sycl@@@detail@_V1@sycl@@QEAAAEAV0123@$$QEAV0123@@Z
??4?$OwnerLessBase@Vdevice@_V1@sycl@@@detail@_V1@sycl@@QEAAAEAV0123@AEBV0123@@Z
??4?$OwnerLessBase@Vqueue@_V1@sycl@@@detail@_V1@sycl@@QEAAAEAV0123@AEBV0123@@Z
??4?$OwnerLessBase@Vqueue@_V1@sycl@@@detail@_V1@sycl@@QEAAAEAV0123@$$QEAV0123@@Z
??4?$OwnerLessBase@Vstream@_V1@sycl@@@detail@_V1@sycl@@QEAAAEAV0123@AEBV0123@@Z
??4?$OwnerLessBase@Vstream@_V1@sycl@@@detail@_V1@sycl@@QEAAAEAV0123@$$QEAV0123@@Z
??4?$OwnerLessBase@Vevent@_V1@sycl@@@detail@_V1@sycl@@QEAAAEAV0123@AEBV0123@@Z
??4?$OwnerLessBase@Vevent@_V1@sycl@@@detail@_V1@sycl@@QEAAAEAV0123@$$QEAV0123@@Z
??4?$OwnerLessBase@Vplatform@_V1@sycl@@@detail@_V1@sycl@@QEAAAEAV0123@$$QEAV0123@@Z
??4?$OwnerLessBase@Vplatform@_V1@sycl@@@detail@_V1@sycl@@QEAAAEAV0123@AEBV0123@@Z
??4?$OwnerLessBase@Vkernel_id@_V1@sycl@@@detail@_V1@sycl@@QEAAAEAV0123@AEBV0123@@Z
??4?$OwnerLessBase@Vkernel_id@_V1@sycl@@@detail@_V1@sycl@@QEAAAEAV0123@$$QEAV0123@@Z
??4?$OwnerLessBase@Vkernel@_V1@sycl@@@detail@_V1@sycl@@QEAAAEAV0123@AEBV0123@@Z
??4?$OwnerLessBase@Vkernel@_V1@sycl@@@detail@_V1@sycl@@QEAAAEAV0123@$$QEAV0123@@Z
??4AccessorBaseHost@detail@_V1@sycl@@QEAAAEAV0123@$$QEAV0123@@Z
??4AccessorBaseHost@detail@_V1@sycl@@QEAAAEAV0123@AEBV0123@@Z
??4AccessorImplHost@detail@_V1@sycl@@QEAAAEAV0123@AEBV0123@@Z
Expand Down Expand Up @@ -794,6 +812,22 @@
?ext_oneapi_barrier@handler@_V1@sycl@@QEAAXXZ
?ext_oneapi_empty@queue@_V1@sycl@@QEBA_NXZ
?ext_oneapi_get_default_context@platform@_V1@sycl@@QEBA?AVcontext@23@XZ
?ext_oneapi_owner_before@?$OwnerLessBase@Vdevice@_V1@sycl@@@detail@_V1@sycl@@QEBA_NAEBV?$weak_object_base@Vdevice@_V1@sycl@@@2oneapi@ext@34@@Z
?ext_oneapi_owner_before@?$OwnerLessBase@Vdevice@_V1@sycl@@@detail@_V1@sycl@@QEBA_NAEBVdevice@34@@Z
?ext_oneapi_owner_before@?$OwnerLessBase@Vevent@_V1@sycl@@@detail@_V1@sycl@@QEBA_NAEBV?$weak_object_base@Vevent@_V1@sycl@@@2oneapi@ext@34@@Z
?ext_oneapi_owner_before@?$OwnerLessBase@Vevent@_V1@sycl@@@detail@_V1@sycl@@QEBA_NAEBVevent@34@@Z
?ext_oneapi_owner_before@?$OwnerLessBase@Vcontext@_V1@sycl@@@detail@_V1@sycl@@QEBA_NAEBVcontext@34@@Z
?ext_oneapi_owner_before@?$OwnerLessBase@Vcontext@_V1@sycl@@@detail@_V1@sycl@@QEBA_NAEBV?$weak_object_base@Vcontext@_V1@sycl@@@2oneapi@ext@34@@Z
?ext_oneapi_owner_before@?$OwnerLessBase@Vkernel@_V1@sycl@@@detail@_V1@sycl@@QEBA_NAEBVkernel@34@@Z
?ext_oneapi_owner_before@?$OwnerLessBase@Vkernel@_V1@sycl@@@detail@_V1@sycl@@QEBA_NAEBV?$weak_object_base@Vkernel@_V1@sycl@@@2oneapi@ext@34@@Z
?ext_oneapi_owner_before@?$OwnerLessBase@Vplatform@_V1@sycl@@@detail@_V1@sycl@@QEBA_NAEBV?$weak_object_base@Vplatform@_V1@sycl@@@2oneapi@ext@34@@Z
?ext_oneapi_owner_before@?$OwnerLessBase@Vplatform@_V1@sycl@@@detail@_V1@sycl@@QEBA_NAEBVplatform@34@@Z
?ext_oneapi_owner_before@?$OwnerLessBase@Vqueue@_V1@sycl@@@detail@_V1@sycl@@QEBA_NAEBV?$weak_object_base@Vqueue@_V1@sycl@@@2oneapi@ext@34@@Z
?ext_oneapi_owner_before@?$OwnerLessBase@Vqueue@_V1@sycl@@@detail@_V1@sycl@@QEBA_NAEBVqueue@34@@Z
?ext_oneapi_owner_before@?$OwnerLessBase@Vkernel_id@_V1@sycl@@@detail@_V1@sycl@@QEBA_NAEBVkernel_id@34@@Z
?ext_oneapi_owner_before@?$OwnerLessBase@Vkernel_id@_V1@sycl@@@detail@_V1@sycl@@QEBA_NAEBV?$weak_object_base@Vkernel_id@_V1@sycl@@@2oneapi@ext@34@@Z
?ext_oneapi_owner_before@?$OwnerLessBase@Vstream@_V1@sycl@@@detail@_V1@sycl@@QEBA_NAEBV?$weak_object_base@Vstream@_V1@sycl@@@2oneapi@ext@34@@Z
?ext_oneapi_owner_before@?$OwnerLessBase@Vstream@_V1@sycl@@@detail@_V1@sycl@@QEBA_NAEBVstream@34@@Z
?ext_oneapi_submit_barrier@queue@_V1@sycl@@QEAA?AVevent@23@AEBUcode_location@detail@23@@Z
?ext_oneapi_submit_barrier@queue@_V1@sycl@@QEAA?AVevent@23@AEBV?$vector@Vevent@_V1@sycl@@V?$allocator@Vevent@_V1@sycl@@@std@@@std@@AEBUcode_location@detail@23@@Z
?extractArgsAndReqs@handler@_V1@sycl@@AEAAXXZ
Expand Down

0 comments on commit 9297f63

Please sign in to comment.