DPC++ Runtime
Runtime libraries for oneAPI DPC++
platform_info.hpp
Go to the documentation of this file.
1 //==------ platform_info.hpp - SYCL platform info methods ------------------==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #pragma once
10 #include <detail/plugin.hpp>
11 #include <sycl/detail/common.hpp>
14 #include <sycl/detail/pi.hpp>
15 #include <sycl/info/info_desc.hpp>
16 
17 namespace sycl {
18 inline namespace _V1 {
19 namespace detail {
20 
21 inline std::string
23  const PluginPtr &Plugin,
24  pi_platform_info PiCode) {
25  size_t ResultSize;
26  // TODO catch an exception and put it to list of asynchronous exceptions
27  Plugin->call<PiApiKind::piPlatformGetInfo>(Plt, PiCode, 0, nullptr,
28  &ResultSize);
29  if (ResultSize == 0) {
30  return "";
31  }
32  std::unique_ptr<char[]> Result(new char[ResultSize]);
33  // TODO catch an exception and put it to list of asynchronous exceptions
34  Plugin->call<PiApiKind::piPlatformGetInfo>(Plt, PiCode, ResultSize,
35  Result.get(), nullptr);
36  return Result.get();
37 }
38 // The platform information methods
39 template <typename Param>
40 typename std::enable_if<
41  std::is_same<typename Param::return_type, std::string>::value,
42  std::string>::type
45  "Invalid platform information descriptor");
46  return get_platform_info_string_impl(Plt, Plugin,
48 }
49 
50 template <typename Param>
51 typename std::enable_if<std::is_same<Param, info::platform::extensions>::value,
52  std::vector<std::string>>::type
55  "Invalid platform information descriptor");
56  std::string Result = get_platform_info_string_impl(
58  return split_string(Result, ' ');
59 }
60 
61 // Host platform information methods
62 template <typename Param>
63 inline typename Param::return_type get_platform_info_host() = delete;
64 
65 template <>
66 inline std::string get_platform_info_host<info::platform::profile>() {
67  return "FULL PROFILE";
68 }
69 
70 template <>
71 inline std::string get_platform_info_host<info::platform::version>() {
72  return "1.2";
73 }
74 
75 template <> inline std::string get_platform_info_host<info::platform::name>() {
76  return "SYCL host platform";
77 }
78 
79 template <>
80 inline std::string get_platform_info_host<info::platform::vendor>() {
81  return "";
82 }
83 
84 template <>
85 inline std::vector<std::string>
86 get_platform_info_host<info::platform::extensions>() {
87  // TODO update when appropriate
88  return {};
89 }
90 
91 } // namespace detail
92 } // namespace _V1
93 } // namespace sycl
common.hpp
piPlatformGetInfo
pi_result piPlatformGetInfo(pi_platform platform, pi_platform_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
Definition: pi_cuda.cpp:30
detail
---— Error handling, matching OpenCL plugin semantics.
Definition: common.hpp:44
sycl
Definition: access.hpp:18
sycl::_V1::detail::PiInfoCode
Definition: info_desc_helpers.hpp:25
plugin.hpp
_pi_platform
Definition: pi_cuda.hpp:44
sycl::_V1::detail::get_platform_info_string_impl
std::string get_platform_info_string_impl(sycl::detail::pi::PiPlatform Plt, const PluginPtr &Plugin, pi_platform_info PiCode)
Definition: platform_info.hpp:22
pi.hpp
sycl::_V1::detail::split_string
std::vector< std::string > split_string(const std::string &str, char delimeter)
Definition: common.cpp:74
sycl::_V1::detail::get_platform_info
std::enable_if< std::is_same< typename Param::return_type, std::string >::value, std::string >::type get_platform_info(sycl::detail::pi::PiPlatform Plt, const PluginPtr &Plugin)
Definition: platform_info.hpp:43
_pi_platform_info
_pi_platform_info
Definition: pi.h:220
info_desc_helpers.hpp
sycl::_V1::detail::get_platform_info_host
Param::return_type get_platform_info_host()=delete
sycl::_V1::detail::is_platform_info_desc
Definition: info_desc_helpers.hpp:26
info_desc.hpp
common_info.hpp
sycl::_V1::detail::PluginPtr
std::shared_ptr< plugin > PluginPtr
Definition: pi.hpp:48