Skip to content

Commit

Permalink
[SYCL] Switch to "preview" sycl::exception implementation (#14548)
Browse files Browse the repository at this point in the history
It will use `sycl::detail::string` instead of `std::string` as data
member by default now.
  • Loading branch information
aelovikov-intel committed Jul 12, 2024
1 parent 2a5f913 commit ece363d
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 58 deletions.
2 changes: 0 additions & 2 deletions sycl/include/sycl/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ class __SYCL_EXPORT context : public detail::OwnerLessBase<context> {
friend T detail::createSyclObjFromImpl(decltype(T::impl) ImplObj);
};

#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
// context.hpp depends on exception.hpp but we can't define these ctors in
// exception.hpp while context is still an incomplete type.
inline exception::exception(context Ctx, std::error_code EC,
Expand All @@ -279,7 +278,6 @@ inline exception::exception(context Ctx, int EV,
inline exception::exception(context Ctx, int EV,
const std::error_category &ECat)
: exception(Ctx, EV, ECat, "") {}
#endif

} // namespace _V1
} // namespace sycl
Expand Down
6 changes: 0 additions & 6 deletions sycl/include/sycl/exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
#include <sycl/detail/defines_elementary.hpp> // for __SYCL2020_DEPRECATED
#include <sycl/detail/export.hpp> // for __SYCL_EXPORT
#include <sycl/detail/pi.h> // for pi_int32
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
#include <sycl/detail/string.hpp>
#endif

#include <exception> // for exception
#include <memory> // for allocator, shared_ptr, make...
Expand Down Expand Up @@ -119,11 +117,7 @@ class __SYCL_EXPORT exception : public virtual std::exception {
private:
// Exceptions must be noexcept copy constructible, so cannot use std::string
// directly.
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
std::shared_ptr<detail::string> MMsg;
#else
std::shared_ptr<std::string> MMsg;
#endif
pi_int32 MPIErr = 0;
std::shared_ptr<context> MContext;
std::error_code MErrC = make_error_code(sycl::errc::invalid);
Expand Down
27 changes: 0 additions & 27 deletions sycl/source/exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,37 +29,10 @@ exception::exception(int EV, const std::error_category &ECat,
exception::exception(int EV, const std::error_category &ECat)
: exception({EV, ECat}, nullptr, "") {}

#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
exception::exception(context Ctx, std::error_code EC,
const std::string &WhatArg)
: exception(EC, std::make_shared<context>(Ctx), WhatArg) {}

exception::exception(context Ctx, std::error_code EC, const char *WhatArg)
: exception(Ctx, EC, std::string(WhatArg)) {}

exception::exception(context Ctx, std::error_code EC)
: exception(Ctx, EC, "") {}

exception::exception(context Ctx, int EV, const std::error_category &ECat,
const char *WhatArg)
: exception(Ctx, {EV, ECat}, std::string(WhatArg)) {}

exception::exception(context Ctx, int EV, const std::error_category &ECat,
const std::string &WhatArg)
: exception(Ctx, {EV, ECat}, WhatArg) {}

exception::exception(context Ctx, int EV, const std::error_category &ECat)
: exception(Ctx, EV, ECat, "") {}
#endif

// protected base constructor for all SYCL 2020 constructors
exception::exception(std::error_code EC, std::shared_ptr<context> SharedPtrCtx,
const char *WhatArg)
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
: MMsg(std::make_shared<detail::string>(WhatArg)),
#else
: MMsg(std::make_shared<std::string>(WhatArg)),
#endif
MPIErr(PI_ERROR_INVALID_VALUE), MContext(SharedPtrCtx), MErrC(EC) {
detail::GlobalHandler::instance().TraceEventXPTI(MMsg->c_str());
}
Expand Down
10 changes: 4 additions & 6 deletions sycl/test/abi/layout_exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ void foo() {
}
}

// clang-format off

// The order of field declarations and their types are important.
// CHECK: 0 | class sycl::exception
// CHECK-NEXT: 8 | class std::shared_ptr<class std::basic_string<char> > MMsg
// CHECK-NEXT: 8 | class std::__shared_ptr<class std::basic_string<char> > (base)
// CHECK-NEXT: 8 | class std::__shared_ptr_access<class std::basic_string<char>, __gnu_cxx::_S_atomic> (base) (empty)
// CHECK-LABEL: 0 | class sycl::exception
// CHECK-NEXT: 8 | class std::shared_ptr<class sycl::detail::string> MMsg
// CHECK-NEXT: 8 | class std::__shared_ptr<class sycl::detail::string> (base)
// CHECK-NEXT: 8 | class std::__shared_ptr_access<class sycl::detail::string, __gnu_cxx::_S_atomic> (base) (empty)
// CHECK-NEXT: 8 | element_type * _M_ptr
// CHECK-NEXT: 16 | class std::__shared_count<> _M_refcount
// CHECK-NEXT: 16 | _Sp_counted_base<(_Lock_policy)2U> * _M_pi
Expand Down
16 changes: 2 additions & 14 deletions sycl/test/abi/sycl_symbols_linux.dump
Original file line number Diff line number Diff line change
Expand Up @@ -3516,14 +3516,14 @@ _ZN4sycl3_V17handler22memcpyFromDeviceGlobalEPvPKvbmm
_ZN4sycl3_V17handler22setHandlerKernelBundleENS0_6kernelE
_ZN4sycl3_V17handler22setHandlerKernelBundleERKSt10shared_ptrINS0_6detail18kernel_bundle_implEE
_ZN4sycl3_V17handler22setKernelIsCooperativeEb
_ZN4sycl3_V17handler26setKernelUsesClusterLaunchEv
_ZN4sycl3_V17handler24GetRangeRoundingSettingsERmS2_S2_
_ZN4sycl3_V17handler24ext_intel_read_host_pipeENS0_6detail11string_viewEPvmb
_ZN4sycl3_V17handler24ext_oneapi_memcpy2d_implEPvmPKvmmm
_ZN4sycl3_V17handler24ext_oneapi_memset2d_implEPvmimm
_ZN4sycl3_V17handler24registerDynamicParameterERNS0_3ext6oneapi12experimental6detail22dynamic_parameter_baseEi
_ZN4sycl3_V17handler25ext_intel_write_host_pipeENS0_6detail11string_viewEPvmb
_ZN4sycl3_V17handler26associateWithHandlerCommonESt10shared_ptrINS0_6detail16AccessorImplHostEEi
_ZN4sycl3_V17handler26setKernelUsesClusterLaunchEv
_ZN4sycl3_V17handler27computeFallbackKernelBoundsEmm
_ZN4sycl3_V17handler28extractArgsAndReqsFromLambdaEPcmPKNS0_6detail19kernel_param_desc_tEb
_ZN4sycl3_V17handler28memcpyToHostOnlyDeviceGlobalEPKvS3_mbmm
Expand Down Expand Up @@ -3559,23 +3559,11 @@ _ZN4sycl3_V18platformC2EP15_cl_platform_id
_ZN4sycl3_V18platformC2ERKNS0_15device_selectorE
_ZN4sycl3_V18platformC2ERKNS0_6deviceE
_ZN4sycl3_V18platformC2Ev
_ZN4sycl3_V19exceptionC1ENS0_7contextESt10error_code
_ZN4sycl3_V19exceptionC1ENS0_7contextESt10error_codePKc
_ZN4sycl3_V19exceptionC1ENS0_7contextESt10error_codeRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
_ZN4sycl3_V19exceptionC1ENS0_7contextEiRKNSt3_V214error_categoryE
_ZN4sycl3_V19exceptionC1ENS0_7contextEiRKNSt3_V214error_categoryEPKc
_ZN4sycl3_V19exceptionC1ENS0_7contextEiRKNSt3_V214error_categoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
_ZN4sycl3_V19exceptionC1ESt10error_code
_ZN4sycl3_V19exceptionC1ESt10error_codePKc
_ZN4sycl3_V19exceptionC1ESt10error_codeSt10shared_ptrINS0_7contextEEPKc
_ZN4sycl3_V19exceptionC1EiRKNSt3_V214error_categoryE
_ZN4sycl3_V19exceptionC1EiRKNSt3_V214error_categoryEPKc
_ZN4sycl3_V19exceptionC2ENS0_7contextESt10error_code
_ZN4sycl3_V19exceptionC2ENS0_7contextESt10error_codePKc
_ZN4sycl3_V19exceptionC2ENS0_7contextESt10error_codeRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
_ZN4sycl3_V19exceptionC2ENS0_7contextEiRKNSt3_V214error_categoryE
_ZN4sycl3_V19exceptionC2ENS0_7contextEiRKNSt3_V214error_categoryEPKc
_ZN4sycl3_V19exceptionC2ENS0_7contextEiRKNSt3_V214error_categoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
_ZN4sycl3_V19exceptionC2ESt10error_code
_ZN4sycl3_V19exceptionC2ESt10error_codePKc
_ZN4sycl3_V19exceptionC2ESt10error_codeSt10shared_ptrINS0_7contextEEPKc
Expand Down Expand Up @@ -3958,6 +3946,7 @@ _ZNK4sycl3_V16device13get_info_implINS0_4info6device27preferred_vector_width_hal
_ZNK4sycl3_V16device13get_info_implINS0_4info6device27preferred_vector_width_longEEENS0_6detail11ABINeutralTINS6_19is_device_info_descIT_E11return_typeEE4typeEv
_ZNK4sycl3_V16device13get_info_implINS0_4info6device28preferred_vector_width_floatEEENS0_6detail11ABINeutralTINS6_19is_device_info_descIT_E11return_typeEE4typeEv
_ZNK4sycl3_V16device13get_info_implINS0_4info6device28preferred_vector_width_shortEEENS0_6detail11ABINeutralTINS6_19is_device_info_descIT_E11return_typeEE4typeEv
_ZNK4sycl3_V16device13get_info_implINS0_4info6device29ext_oneapi_cuda_cluster_groupEEENS0_6detail11ABINeutralTINS6_19is_device_info_descIT_E11return_typeEE4typeEv
_ZNK4sycl3_V16device13get_info_implINS0_4info6device29ext_oneapi_max_work_groups_1dEEENS0_6detail11ABINeutralTINS6_19is_device_info_descIT_E11return_typeEE4typeEv
_ZNK4sycl3_V16device13get_info_implINS0_4info6device29ext_oneapi_max_work_groups_2dEEENS0_6detail11ABINeutralTINS6_19is_device_info_descIT_E11return_typeEE4typeEv
_ZNK4sycl3_V16device13get_info_implINS0_4info6device29ext_oneapi_max_work_groups_3dEEENS0_6detail11ABINeutralTINS6_19is_device_info_descIT_E11return_typeEE4typeEv
Expand All @@ -3973,7 +3962,6 @@ _ZNK4sycl3_V16device13get_info_implINS0_4info6device33ext_oneapi_max_global_work
_ZNK4sycl3_V16device13get_info_implINS0_4info6device33usm_restricted_shared_allocationsEEENS0_6detail11ABINeutralTINS6_19is_device_info_descIT_E11return_typeEE4typeEv
_ZNK4sycl3_V16device13get_info_implINS0_4info6device35ext_intel_gpu_eu_count_per_subsliceEEENS0_6detail11ABINeutralTINS6_19is_device_info_descIT_E11return_typeEE4typeEv
_ZNK4sycl3_V16device13get_info_implINS0_4info6device38sub_group_independent_forward_progressEEENS0_6detail11ABINeutralTINS6_19is_device_info_descIT_E11return_typeEE4typeEv
_ZNK4sycl3_V16device13get_info_implINS0_4info6device29ext_oneapi_cuda_cluster_groupEEENS0_6detail11ABINeutralTINS6_19is_device_info_descIT_E11return_typeEE4typeEv
_ZNK4sycl3_V16device13get_info_implINS0_4info6device4nameEEENS0_6detail11ABINeutralTINS6_19is_device_info_descIT_E11return_typeEE4typeEv
_ZNK4sycl3_V16device13get_info_implINS0_4info6device6vendorEEENS0_6detail11ABINeutralTINS6_19is_device_info_descIT_E11return_typeEE4typeEv
_ZNK4sycl3_V16device13get_info_implINS0_4info6device7aspectsEEENS0_6detail11ABINeutralTINS6_19is_device_info_descIT_E11return_typeEE4typeEv
Expand Down
2 changes: 1 addition & 1 deletion sycl/test/abi/sycl_symbols_windows.dump
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@
??$get_info_impl@Uext_intel_max_mem_bandwidth@device@info@_V1@sycl@@@device@_V1@sycl@@AEBA_KXZ
??$get_info_impl@Uext_intel_mem_channel@device@info@_V1@sycl@@@device@_V1@sycl@@AEBA_NXZ
??$get_info_impl@Uext_intel_pci_address@device@info@_V1@sycl@@@device@_V1@sycl@@AEBA?AVstring@detail@12@XZ
??$get_info_impl@Uext_oneapi_cuda_cluster_group@device@info@_V1@sycl@@@device@_V1@sycl@@AEBA_NXZ
??$get_info_impl@Uext_oneapi_max_global_work_groups@device@info@_V1@sycl@@@device@_V1@sycl@@AEBA_KXZ
??$get_info_impl@Uext_oneapi_max_work_groups_1d@device@info@_V1@sycl@@@device@_V1@sycl@@AEBA?AV?$id@$00@12@XZ
??$get_info_impl@Uext_oneapi_max_work_groups_2d@device@info@_V1@sycl@@@device@_V1@sycl@@AEBA?AV?$id@$01@12@XZ
??$get_info_impl@Uext_oneapi_max_work_groups_3d@device@info@_V1@sycl@@@device@_V1@sycl@@AEBA?AV?$id@$02@12@XZ
??$get_info_impl@Uext_oneapi_srgb@device@info@_V1@sycl@@@device@_V1@sycl@@AEBA_NXZ
??$get_info_impl@Uext_oneapi_cuda_cluster_group@device@info@_V1@sycl@@@device@_V1@sycl@@AEBA_NXZ
??$get_info_impl@Uextensions@device@info@_V1@sycl@@@device@_V1@sycl@@AEBA?AV?$vector@Vstring@detail@_V1@sycl@@V?$allocator@Vstring@detail@_V1@sycl@@@std@@@std@@XZ
??$get_info_impl@Uextensions@platform@info@_V1@sycl@@@platform@_V1@sycl@@AEBA?AV?$vector@Vstring@detail@_V1@sycl@@V?$allocator@Vstring@detail@_V1@sycl@@@std@@@std@@XZ
??$get_info_impl@Ufree_memory@device@info@intel@ext@_V1@sycl@@@device@_V1@sycl@@AEBA_KXZ
Expand Down
2 changes: 1 addition & 1 deletion sycl/test/include_deps/sycl_accessor.hpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
// CHECK-NEXT: CL/cl_version.h
// CHECK-NEXT: CL/cl_platform.h
// CHECK-NEXT: CL/cl_ext.h
// CHECK-NEXT: detail/string.hpp
// CHECK-NEXT: detail/common.hpp
// CHECK-NEXT: detail/is_device_copyable.hpp
// CHECK-NEXT: detail/owner_less_base.hpp
Expand Down Expand Up @@ -113,7 +114,6 @@
// CHECK-NEXT: info/ext_oneapi_device_traits.def
// CHECK-NEXT: info/sycl_backend_traits.def
// CHECK-NEXT: platform.hpp
// CHECK-NEXT: detail/string.hpp
// CHECK-NEXT: detail/string_view.hpp
// CHECK-NEXT: detail/util.hpp
// CHECK-NEXT: device_selector.hpp
Expand Down
1 change: 1 addition & 0 deletions sycl/test/include_deps/sycl_buffer.hpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
// CHECK-NEXT: CL/cl_version.h
// CHECK-NEXT: CL/cl_platform.h
// CHECK-NEXT: CL/cl_ext.h
// CHECK-NEXT: detail/string.hpp
// CHECK-NEXT: detail/common.hpp
// CHECK-NEXT: detail/helpers.hpp
// CHECK-NEXT: detail/pi.hpp
Expand Down
2 changes: 1 addition & 1 deletion sycl/test/include_deps/sycl_detail_core.hpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
// CHECK-NEXT: CL/cl_version.h
// CHECK-NEXT: CL/cl_platform.h
// CHECK-NEXT: CL/cl_ext.h
// CHECK-NEXT: detail/string.hpp
// CHECK-NEXT: detail/common.hpp
// CHECK-NEXT: detail/is_device_copyable.hpp
// CHECK-NEXT: detail/owner_less_base.hpp
Expand Down Expand Up @@ -114,7 +115,6 @@
// CHECK-NEXT: info/ext_oneapi_device_traits.def
// CHECK-NEXT: info/sycl_backend_traits.def
// CHECK-NEXT: platform.hpp
// CHECK-NEXT: detail/string.hpp
// CHECK-NEXT: detail/string_view.hpp
// CHECK-NEXT: detail/util.hpp
// CHECK-NEXT: device_selector.hpp
Expand Down

0 comments on commit ece363d

Please sign in to comment.