Skip to content

Commit

Permalink
fix platform prop
Browse files Browse the repository at this point in the history
Signed-off-by: Byoungro So <byoungro.so@intel.com>
  • Loading branch information
bso-intel committed Feb 11, 2024
1 parent f4655aa commit a04fc0c
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 7 deletions.
2 changes: 1 addition & 1 deletion sycl/include/sycl/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ class __SYCL_EXPORT device : public detail::OwnerLessBase<device> {
} else if constexpr (std::is_same_v<std::vector<std::string>,
typename detail::is_device_info_desc<
Param>::return_type>) {
// return value is std::vector<std::string>
// The return value is std::vector<std::string>
detail::string_view PropertyName(typeid(Param).name());
std::vector<detail::string> Info = get_device_info_vector(PropertyName);
std::vector<std::string> Res;
Expand Down
21 changes: 17 additions & 4 deletions sycl/include/sycl/platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,24 @@ class __SYCL_EXPORT platform : public detail::OwnerLessBase<platform> {
typename detail::is_platform_info_desc<Param>::return_type get_info() const {
// For C++11-ABI compatibility, we handle these string Param types
// separately.
if constexpr (std::is_same_v<Param, info::platform::name> ||
std::is_same_v<Param, info::platform::vendor> ||
std::is_same_v<Param, info::platform::version> ||
std::is_same_v<Param, info::platform::profile>) {
if constexpr (std::is_same_v<std::string,
typename detail::is_platform_info_desc<
Param>::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<std::vector<std::string>,
typename detail::is_platform_info_desc<
Param>::return_type>) {
// The return value is std::vector<std::string>
detail::string_view PropertyName(typeid(Param).name());
std::vector<detail::string> Info = get_platform_info_vector(PropertyName);
std::vector<std::string> Res;
Res.reserve(Info.size());
for (detail::string &Str : Info) {
Res.push_back(Str.c_str());
}
return Res;
}
return get_info_internal<Param>();
}
Expand Down Expand Up @@ -229,6 +240,8 @@ class __SYCL_EXPORT platform : public detail::OwnerLessBase<platform> {
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<detail::string>
get_platform_info_vector(detail::string_view Type) const;
#endif
}; // class platform
} // namespace _V1
Expand Down
6 changes: 5 additions & 1 deletion sycl/source/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ detail::string device::get_device_info(detail::string_view Type) const {
Info = impl->template get_info<info::device::opencl_c_version>();
} else if (Type == typeid(info::device::ext_intel_pci_address).name()) {
Info = impl->template get_info<info::device::ext_intel_pci_address>();
} else if (Type == typeid(info::device::backend_version).name()) {
Info = impl->template get_info<info::device::backend_version>();
} else {
throw sycl::invalid_parameter_error("unsupported device info requested",
PI_ERROR_INVALID_OPERATION);
Expand All @@ -170,7 +172,9 @@ detail::string device::get_device_info(detail::string_view Type) const {
std::vector<detail::string>
device::get_device_info_vector(detail::string_view Type) const {
std::vector<std::string> Info;
if (Type == typeid(info::device::extensions).name()) {
if (Type == typeid(info::device::built_in_kernels).name()) {
Info = impl->template get_info<info::device::built_in_kernels>();
} else if (Type == typeid(info::device::extensions).name()) {
Info = impl->template get_info<info::device::extensions>();
} else {
throw sycl::invalid_parameter_error(
Expand Down
20 changes: 19 additions & 1 deletion sycl/source/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<info::platform::profile>();
} 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<detail::string>
platform::get_platform_info_vector(detail::string_view Type) const {
std::vector<std::string> Info;
if (Type == typeid(info::platform::extensions).name()) {
Info = impl->template get_info<info::platform::extensions>();
} else {
throw sycl::invalid_parameter_error(
"unsupported platform info vector requested",
PI_ERROR_INVALID_OPERATION);
}

std::vector<detail::string> Result;
for (std::string &Str : Info) {
Result.push_back(detail::string(Str.c_str()));
}
return Result;
}
#else
template <typename Param>
typename detail::is_platform_info_desc<Param>::return_type
Expand Down

0 comments on commit a04fc0c

Please sign in to comment.