From a04fc0cfa5f6c409bd352bb6f731f1748373d492 Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Sat, 10 Feb 2024 19:03:34 -0800 Subject: [PATCH] fix platform prop Signed-off-by: Byoungro So --- sycl/include/sycl/device.hpp | 2 +- sycl/include/sycl/platform.hpp | 21 +++++++++++++++++---- sycl/source/device.cpp | 6 +++++- sycl/source/platform.cpp | 20 +++++++++++++++++++- 4 files changed, 42 insertions(+), 7 deletions(-) diff --git a/sycl/include/sycl/device.hpp b/sycl/include/sycl/device.hpp index d0d856fe85d01..e7262945ba8af 100644 --- a/sycl/include/sycl/device.hpp +++ b/sycl/include/sycl/device.hpp @@ -231,7 +231,7 @@ class __SYCL_EXPORT device : public detail::OwnerLessBase { } else if constexpr (std::is_same_v, typename detail::is_device_info_desc< Param>::return_type>) { - // return value is std::vector + // The return value is std::vector detail::string_view PropertyName(typeid(Param).name()); std::vector Info = get_device_info_vector(PropertyName); std::vector Res; diff --git a/sycl/include/sycl/platform.hpp b/sycl/include/sycl/platform.hpp index 727e756a0af27..384e21e6fdb38 100644 --- a/sycl/include/sycl/platform.hpp +++ b/sycl/include/sycl/platform.hpp @@ -151,13 +151,24 @@ class __SYCL_EXPORT platform : public detail::OwnerLessBase { typename detail::is_platform_info_desc::return_type get_info() const { // For C++11-ABI compatibility, we handle these string Param types // separately. - if constexpr (std::is_same_v || - std::is_same_v || - std::is_same_v || - std::is_same_v) { + if constexpr (std::is_same_v::return_type>) { detail::string_view PropertyName(typeid(Param).name()); detail::string Info = get_platform_info(PropertyName); return Info.c_str(); + } else if constexpr (std::is_same_v, + typename detail::is_platform_info_desc< + Param>::return_type>) { + // The return value is std::vector + detail::string_view PropertyName(typeid(Param).name()); + std::vector Info = get_platform_info_vector(PropertyName); + std::vector Res; + Res.reserve(Info.size()); + for (detail::string &Str : Info) { + Res.push_back(Str.c_str()); + } + return Res; } return get_info_internal(); } @@ -229,6 +240,8 @@ class __SYCL_EXPORT platform : public detail::OwnerLessBase { get_info_internal() const; // proxy of get_info_internal() to handle C++11-ABI compatibility separately. detail::string get_platform_info(detail::string_view Type) const; + std::vector + get_platform_info_vector(detail::string_view Type) const; #endif }; // class platform } // namespace _V1 diff --git a/sycl/source/device.cpp b/sycl/source/device.cpp index 963b703b67a28..228205790986f 100644 --- a/sycl/source/device.cpp +++ b/sycl/source/device.cpp @@ -160,6 +160,8 @@ detail::string device::get_device_info(detail::string_view Type) const { Info = impl->template get_info(); } else if (Type == typeid(info::device::ext_intel_pci_address).name()) { Info = impl->template get_info(); + } else if (Type == typeid(info::device::backend_version).name()) { + Info = impl->template get_info(); } else { throw sycl::invalid_parameter_error("unsupported device info requested", PI_ERROR_INVALID_OPERATION); @@ -170,7 +172,9 @@ detail::string device::get_device_info(detail::string_view Type) const { std::vector device::get_device_info_vector(detail::string_view Type) const { std::vector Info; - if (Type == typeid(info::device::extensions).name()) { + if (Type == typeid(info::device::built_in_kernels).name()) { + Info = impl->template get_info(); + } else if (Type == typeid(info::device::extensions).name()) { Info = impl->template get_info(); } else { throw sycl::invalid_parameter_error( diff --git a/sycl/source/platform.cpp b/sycl/source/platform.cpp index c70e79820bace..cb213116a86d7 100644 --- a/sycl/source/platform.cpp +++ b/sycl/source/platform.cpp @@ -74,11 +74,29 @@ detail::string platform::get_platform_info(detail::string_view Type) const { } else if (Type == typeid(info::platform::profile).name()) { Info = impl->get_info(); } else { - throw sycl::invalid_parameter_error("unsupported device info requested", + throw sycl::invalid_parameter_error("unsupported platform info requested", PI_ERROR_INVALID_OPERATION); } return detail::string(Info); } + +std::vector +platform::get_platform_info_vector(detail::string_view Type) const { + std::vector Info; + if (Type == typeid(info::platform::extensions).name()) { + Info = impl->template get_info(); + } else { + throw sycl::invalid_parameter_error( + "unsupported platform info vector requested", + PI_ERROR_INVALID_OPERATION); + } + + std::vector Result; + for (std::string &Str : Info) { + Result.push_back(detail::string(Str.c_str())); + } + return Result; +} #else template typename detail::is_platform_info_desc::return_type