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
12 #include <CL/sycl/detail/pi.hpp>
14 #include <detail/plugin.hpp>
15 
17 namespace sycl {
18 namespace detail {
19 
20 // The platform information methods
21 template <typename T, info::platform param> struct get_platform_info {};
22 
23 template <info::platform param> struct get_platform_info<std::string, param> {
24  static std::string get(RT::PiPlatform plt, const plugin &Plugin) {
25  size_t resultSize;
26  // TODO catch an exception and put it to list of asynchronous exceptions
28  plt, pi::cast<pi_platform_info>(param), 0, nullptr, &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
35  plt, pi::cast<pi_platform_info>(param), resultSize, result.get(),
36  nullptr);
37  return result.get();
38  }
39 };
40 
41 template <>
42 struct get_platform_info<std::vector<std::string>, info::platform::extensions> {
43  static std::vector<std::string> get(RT::PiPlatform plt,
44  const plugin &Plugin) {
45  std::string result =
47  Plugin);
48  return split_string(result, ' ');
49  }
50 };
51 
52 // Host platform information methods
53 template <info::platform param>
55 get_platform_info_host() = delete;
56 
57 template <>
58 inline std::string get_platform_info_host<info::platform::profile>() {
59  return "FULL PROFILE";
60 }
61 
62 template <>
63 inline std::string get_platform_info_host<info::platform::version>() {
64  return "1.2";
65 }
66 
67 template <> inline std::string get_platform_info_host<info::platform::name>() {
68  return "SYCL host platform";
69 }
70 
71 template <>
72 inline std::string get_platform_info_host<info::platform::vendor>() {
73  return "";
74 }
75 
76 template <>
77 inline std::vector<std::string>
78 get_platform_info_host<info::platform::extensions>() {
79  // TODO update when appropriate
80  return {};
81 }
82 
83 } // namespace detail
84 } // namespace sycl
85 } // __SYCL_INLINE_NAMESPACE(cl)
cl::sycl::detail::get_platform_info_host
info::param_traits< info::platform, param >::return_type get_platform_info_host()=delete
cl::sycl::info::param_traits
Definition: info_desc.hpp:310
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_esimd_emulator.cpp:439
sycl
Definition: invoke_simd.hpp:68
plugin.hpp
cl::sycl::detail::get_platform_info< std::vector< std::string >, info::platform::extensions >::get
static std::vector< std::string > get(RT::PiPlatform plt, const plugin &Plugin)
Definition: platform_info.hpp:43
_pi_platform
A PI platform stores all known PI devices, in the CUDA plugin this is just a vector of available devi...
Definition: pi_cuda.hpp:63
pi.hpp
cl::sycl::detail::plugin::call
void call(ArgsT... Args) const
Calls the API, traces the call, checks the result.
Definition: plugin.hpp:217
cl
We provide new interfaces for matrix muliply in this patch:
Definition: access.hpp:13
cl::sycl::detail::plugin
The plugin class provides a unified interface to the underlying low-level runtimes for the device-agn...
Definition: plugin.hpp:90
cl::sycl::detail::split_string
std::vector< std::string > split_string(const std::string &str, char delimeter)
Definition: common.cpp:230
std::get
constexpr tuple_element< I, tuple< Types... > >::type & get(cl::sycl::detail::tuple< Types... > &Arg) noexcept
Definition: tuple.hpp:199
std
Definition: accessor.hpp:2616
cl::sycl::detail::get_platform_info< std::string, param >::get
static std::string get(RT::PiPlatform plt, const plugin &Plugin)
Definition: platform_info.hpp:24
info_desc.hpp
common.hpp
common_info.hpp
cl::sycl::detail::get_platform_info
Definition: platform_info.hpp:21
__SYCL_INLINE_NAMESPACE
#define __SYCL_INLINE_NAMESPACE(X)
Definition: defines_elementary.hpp:12