diff --git a/sycl/include/CL/sycl/queue.hpp b/sycl/include/CL/sycl/queue.hpp index d50840e8f345e..f11e94213ef26 100644 --- a/sycl/include/CL/sycl/queue.hpp +++ b/sycl/include/CL/sycl/queue.hpp @@ -231,6 +231,10 @@ class __SYCL_EXPORT queue { template typename info::param_traits::return_type get_info() const; + // A shorthand for `get_device().has()' which is expected to be a bit quicker + // than the long version + bool device_has(aspect Aspect) const; + public: /// Submits a command group function object to the queue, in order to be /// scheduled for execution on the device. @@ -247,7 +251,7 @@ class __SYCL_EXPORT queue { if (!is_host()) { auto PostProcess = [this, &CodeLoc](bool IsKernel, bool KernelUsesAssert, event &E) { - if (IsKernel && !get_device().has(aspect::ext_oneapi_native_assert) && + if (IsKernel && !device_has(aspect::ext_oneapi_native_assert) && KernelUsesAssert) { // __devicelib_assert_fail isn't supported by Device-side Runtime // Linking against fallback impl of __devicelib_assert_fail is @@ -287,7 +291,7 @@ class __SYCL_EXPORT queue { #if __SYCL_USE_FALLBACK_ASSERT auto PostProcess = [this, &SecondaryQueue, &CodeLoc]( bool IsKernel, bool KernelUsesAssert, event &E) { - if (IsKernel && !get_device().has(aspect::ext_oneapi_native_assert) && + if (IsKernel && !device_has(aspect::ext_oneapi_native_assert) && KernelUsesAssert) { // __devicelib_assert_fail isn't supported by Device-side Runtime // Linking against fallback impl of __devicelib_assert_fail is performed diff --git a/sycl/source/detail/device_impl.cpp b/sycl/source/detail/device_impl.cpp index d988b0c291b6e..9b3c142e2b41b 100644 --- a/sycl/source/detail/device_impl.cpp +++ b/sycl/source/detail/device_impl.cpp @@ -17,7 +17,9 @@ namespace sycl { namespace detail { device_impl::device_impl() - : MIsHostDevice(true), MPlatform(platform_impl::getHostPlatformImpl()) {} + : MIsHostDevice(true), MPlatform(platform_impl::getHostPlatformImpl()), + // assert is natively supported by host + MIsAssertFailSupported(true) {} device_impl::device_impl(pi_native_handle InteropDeviceHandle, const plugin &Plugin) @@ -70,6 +72,9 @@ device_impl::device_impl(pi_native_handle InteropDeviceHandle, Platform = platform_impl::getPlatformFromPiDevice(MDevice, Plugin); } MPlatform = Platform; + + MIsAssertFailSupported = + has_extension(PI_DEVICE_INFO_EXTENSION_DEVICELIB_ASSERT); } device_impl::~device_impl() { @@ -334,11 +339,7 @@ std::shared_ptr device_impl::getHostDeviceImpl() { } bool device_impl::isAssertFailSupported() const { - // assert is sort of natively supported by host - if (MIsHostDevice) - return true; - - return has_extension(PI_DEVICE_INFO_EXTENSION_DEVICELIB_ASSERT); + return MIsAssertFailSupported; } } // namespace detail diff --git a/sycl/source/detail/device_impl.hpp b/sycl/source/detail/device_impl.hpp index 51ea4f593de51..5d4a7deb4a2af 100644 --- a/sycl/source/detail/device_impl.hpp +++ b/sycl/source/detail/device_impl.hpp @@ -232,6 +232,7 @@ class device_impl { bool MIsRootDevice = false; bool MIsHostDevice; PlatformImplPtr MPlatform; + bool MIsAssertFailSupported = false; }; // class device_impl } // namespace detail diff --git a/sycl/source/detail/device_info.hpp b/sycl/source/detail/device_info.hpp index 718a0919f906a..1bcdf67276586 100644 --- a/sycl/source/detail/device_info.hpp +++ b/sycl/source/detail/device_info.hpp @@ -126,7 +126,7 @@ template struct get_device_info { // for string return type in other specializations. template struct get_device_info_string { static std::string get(RT::PiDevice dev, const plugin &Plugin) { - size_t resultSize; + size_t resultSize = 0; Plugin.call( dev, pi::cast(param), 0, nullptr, &resultSize); if (resultSize == 0) { diff --git a/sycl/source/queue.cpp b/sycl/source/queue.cpp index 50031313412a9..2880e0461207d 100644 --- a/sycl/source/queue.cpp +++ b/sycl/source/queue.cpp @@ -191,5 +191,10 @@ pi_native_handle queue::getNative() const { return impl->getNative(); } buffer &queue::getAssertHappenedBuffer() { return impl->getAssertHappenedBuffer(); } + +bool queue::device_has(aspect Aspect) const { + // avoid creating sycl object from impl + return impl->getDeviceImplPtr()->has(Aspect); +} } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/test/abi/sycl_symbols_linux.dump b/sycl/test/abi/sycl_symbols_linux.dump index 48df1d6dd9ff1..bdf2ff540e0b7 100644 --- a/sycl/test/abi/sycl_symbols_linux.dump +++ b/sycl/test/abi/sycl_symbols_linux.dump @@ -3656,6 +3656,7 @@ _ZN2cl4sycl5eventC1Ev _ZN2cl4sycl5eventC2EP9_cl_eventRKNS0_7contextE _ZN2cl4sycl5eventC2ESt10shared_ptrINS0_6detail10event_implEE _ZN2cl4sycl5eventC2Ev +_ZNK2cl4sycl5queue10device_hasENS0_6aspectE _ZN2cl4sycl5queue10mem_adviseEPKvm14_pi_mem_advice _ZN2cl4sycl5queue10mem_adviseEPKvmi _ZN2cl4sycl5queue10mem_adviseEPKvmiNS0_5eventE diff --git a/sycl/test/abi/sycl_symbols_windows.dump b/sycl/test/abi/sycl_symbols_windows.dump index dc854bf1395eb..ef3e56ba5652f 100644 --- a/sycl/test/abi/sycl_symbols_windows.dump +++ b/sycl/test/abi/sycl_symbols_windows.dump @@ -108,6 +108,7 @@ ??$get_info@$0BAIA@@context@sycl@cl@@QEBAIXZ ??$get_info@$0BAIB@@context@sycl@cl@@QEBA?AV?$vector@Vdevice@sycl@cl@@V?$allocator@Vdevice@sycl@cl@@@std@@@std@@XZ ??$get_info@$0BAIE@@context@sycl@cl@@QEBA?AVplatform@12@XZ +?device_has@queue@sycl@cl@@QEBA_NW4aspect@23@@Z ??$get_info@$0BAJA@@queue@sycl@cl@@QEBA?AVcontext@12@XZ ??$get_info@$0BAJB@@queue@sycl@cl@@QEBA?AVdevice@12@XZ ??$get_info@$0BAJC@@queue@sycl@cl@@QEBAIXZ