Skip to content

Commit

Permalink
[ABI-Break][SYCL] Fix ext_oneapi_cl_profile to be ABI-neutral (#14883)
Browse files Browse the repository at this point in the history
Returning a std::string from device.cpp to device.hpp will cross the ABI
boundary.
So, we need to neutralize it via detail::string.
  • Loading branch information
bso-intel authored Aug 1, 2024
1 parent ebb7dd9 commit 7b74721
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
6 changes: 5 additions & 1 deletion sycl/include/sycl/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,10 @@ class __SYCL_EXPORT device : public detail::OwnerLessBase<device> {
/// query `CL_DEVICE_PROFILE`, as defined in section 4.2 "Querying Devices" of
/// the OpenCL specification. If the device does not support kernel bundles
/// written in `source_language::opencl`, returns the empty string.
std::string ext_oneapi_cl_profile() const;
std::string ext_oneapi_cl_profile() const {
detail::string profile = ext_oneapi_cl_profile_impl();
return profile.c_str();
}

// TODO: Remove this diagnostics when __SYCL_WARN_IMAGE_ASPECT is removed.
#if defined(__clang__)
Expand Down Expand Up @@ -370,6 +373,7 @@ class __SYCL_EXPORT device : public detail::OwnerLessBase<device> {
bool ext_oneapi_supports_cl_extension(
detail::string_view name,
ext::oneapi::experimental::cl_version *version = nullptr) const;
detail::string ext_oneapi_cl_profile_impl() const;
};

} // namespace _V1
Expand Down
8 changes: 5 additions & 3 deletions sycl/source/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,17 +314,19 @@ bool device::ext_oneapi_supports_cl_extension(
Name.data(), VersionPtr, ipVersion);
}

std::string device::ext_oneapi_cl_profile() const {
detail::string device::ext_oneapi_cl_profile_impl() const {
ur_device_handle_t Device = impl->getHandleRef();
auto Plugin = impl->getPlugin();
uint32_t ipVersion = 0;
auto res =
Plugin->call_nocheck(urDeviceGetInfo, Device, UR_DEVICE_INFO_IP_VERSION,
sizeof(uint32_t), &ipVersion, nullptr);
if (res != UR_RESULT_SUCCESS)
return "";
return detail::string{""};

return ext::oneapi::experimental::detail::OpenCLC_Profile(ipVersion);
std::string profile =
ext::oneapi::experimental::detail::OpenCLC_Profile(ipVersion);
return detail::string{profile};
}

} // namespace _V1
Expand Down
1 change: 0 additions & 1 deletion sycl/test/abi/sycl_abi_neutrality_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@
// CHECK:_ZN4sycl3_V16opencl13has_extensionERKNS0_6deviceERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
// CHECK:_ZN4sycl3_V16opencl13has_extensionERKNS0_8platformERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
// CHECK:_ZNK4sycl3_V13ext6oneapi12experimental6detail24modifiable_command_graph11print_graphENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb
// CHECK:_ZNK4sycl3_V16device21ext_oneapi_cl_profileB5cxx11Ev
2 changes: 1 addition & 1 deletion sycl/test/abi/sycl_symbols_linux.dump
Original file line number Diff line number Diff line change
Expand Up @@ -3890,7 +3890,7 @@ _ZNK4sycl3_V16device18create_sub_devicesILNS0_4info18partition_propertyE4230EEES
_ZNK4sycl3_V16device18create_sub_devicesILNS0_4info18partition_propertyE4231EEESt6vectorIS1_SaIS1_EERKS5_ImSaImEE
_ZNK4sycl3_V16device18create_sub_devicesILNS0_4info18partition_propertyE4232EEESt6vectorIS1_SaIS1_EENS3_25partition_affinity_domainE
_ZNK4sycl3_V16device18create_sub_devicesILNS0_4info18partition_propertyE4233EEESt6vectorIS1_SaIS1_EEv
_ZNK4sycl3_V16device21ext_oneapi_cl_profileB5cxx11Ev
_ZNK4sycl3_V16device26ext_oneapi_cl_profile_implEv
_ZNK4sycl3_V16device32ext_oneapi_supports_cl_c_versionERKNS0_3ext6oneapi12experimental10cl_versionE
_ZNK4sycl3_V16device32ext_oneapi_supports_cl_extensionENS0_6detail11string_viewEPNS0_3ext6oneapi12experimental10cl_versionE
_ZNK4sycl3_V16device3getEv
Expand Down
1 change: 1 addition & 0 deletions sycl/test/abi/sycl_symbols_windows.dump
Original file line number Diff line number Diff line change
Expand Up @@ -3770,6 +3770,7 @@
?ext_oneapi_can_access_peer@device@_V1@sycl@@QEAA_NAEBV123@W4peer_access@oneapi@ext@23@@Z
?ext_oneapi_can_compile@device@_V1@sycl@@QEAA_NW4source_language@experimental@oneapi@ext@23@@Z
?ext_oneapi_cl_profile@device@_V1@sycl@@QEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ
?ext_oneapi_cl_profile_impl@device@_V1@sycl@@AEBA?AVstring@detail@23@XZ
?ext_oneapi_copy@handler@_V1@sycl@@QEAAXPEBXPEAXAEBUimage_descriptor@experimental@oneapi@ext@23@_K@Z
?ext_oneapi_copy@handler@_V1@sycl@@QEAAXPEBXUimage_mem_handle@experimental@oneapi@ext@23@AEBUimage_descriptor@56723@@Z
?ext_oneapi_copy@handler@_V1@sycl@@QEAAXPEBXV?$range@$02@23@1Uimage_mem_handle@experimental@oneapi@ext@23@1AEBUimage_descriptor@67823@1@Z
Expand Down

0 comments on commit 7b74721

Please sign in to comment.