DPC++ Runtime
Runtime libraries for oneAPI DPC++
plugin_printers.hpp
Go to the documentation of this file.
1 //==--------- plugin_printers.hpp - Printers for the Plugin Interface ------==//
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 // Print functions used for the Plguin Interface tracing.
10 
11 #pragma once
12 
13 #include <sycl/detail/pi.hpp>
14 
15 #include <type_traits>
16 
17 namespace sycl {
18 inline namespace _V1 {
19 namespace detail {
20 namespace pi {
21 
22 template <typename T>
23 inline typename std::enable_if<!std::is_pointer<T>::value, void>::type
24 print(T val) {
25  std::cout << "<unknown> : " << val << std::endl;
26 }
27 
28 template <typename T>
29 inline typename std::enable_if<std::is_pointer<T>::value, void>::type
30 print(T val) {
31  std::cout << "<unknown> : " << reinterpret_cast<const void *>(val)
32  << std::endl;
33 }
34 
35 template <> inline void print<>(PiPlatform val) {
36  std::cout << "pi_platform : " << val << std::endl;
37 }
38 
39 template <> inline void print<>(PiEvent val) {
40  std::cout << "pi_event : " << val << std::endl;
41 }
42 
43 template <> inline void print<>(PiMem val) {
44  std::cout << "pi_mem : " << val << std::endl;
45 }
46 
47 template <> inline void print<>(PiEvent *val) {
48  std::cout << "pi_event * : " << val;
49  if (val)
50  std::cout << "[ " << *val << " ... ]";
51  else
52  std::cout << "[ nullptr ]";
53  std::cout << std::endl;
54 }
55 
56 template <> inline void print<>(const PiEvent *val) {
57  std::cout << "const pi_event * : " << val;
58  if (val)
59  std::cout << "[ " << *val << " ... ]";
60  else
61  std::cout << "[ nullptr ]";
62  std::cout << std::endl;
63 }
64 
65 template <> inline void print<>(pi_buffer_region rgn) {
66  std::cout << "pi_buffer_region origin/size : " << rgn->origin << "/"
67  << rgn->size << std::endl;
68 }
69 
70 template <> inline void print<>(pi_buff_rect_region rgn) {
71  std::cout << "pi_buff_rect_region width_bytes/height/depth : "
72  << rgn->width_bytes << "/" << rgn->height_scalar << "/"
73  << rgn->depth_scalar << std::endl;
74 }
75 
76 template <> inline void print<>(pi_buff_rect_offset off) {
77  std::cout << "pi_buff_rect_offset x_bytes/y/z : " << off->x_bytes << "/"
78  << off->y_scalar << "/" << off->z_scalar << std::endl;
79 }
80 
81 template <> inline void print<>(pi_image_region rgn) {
82  std::cout << "pi_image_region width/height/depth : " << rgn->width << "/"
83  << rgn->height << "/" << rgn->depth << std::endl;
84 }
85 
86 template <> inline void print<>(pi_image_offset off) {
87  std::cout << "pi_image_offset x/y/z : " << off->x << "/" << off->y << "/"
88  << off->z << std::endl;
89 }
90 
91 template <> inline void print<>(const pi_image_desc *desc) {
92  std::cout << "image_desc w/h/d : " << desc->image_width << " / "
93  << desc->image_height << " / " << desc->image_depth
94  << " -- arrSz/row/slice : " << desc->image_array_size << " / "
95  << desc->image_row_pitch << " / " << desc->image_slice_pitch
96  << " -- num_mip_lvls/num_smpls/image_type : "
97  << desc->num_mip_levels << " / " << desc->num_samples << " / "
98  << desc->image_type << std::endl;
99 }
100 
101 template <> inline void print<>(PiResult val) {
102  std::cout << "pi_result : ";
103  if (val == PI_SUCCESS)
104  std::cout << "PI_SUCCESS" << std::endl;
105  else
106  std::cout << val << std::endl;
107 }
108 
109 // cout does not resolve a nullptr.
110 template <> inline void print<>(std::nullptr_t) {
111  std::cout << "<nullptr>" << std::endl;
112 }
113 
114 template <> inline void print<>(char *val) {
115  std::cout << "<char * > : " << static_cast<void *>(val) << std::endl;
116 }
117 
118 template <> inline void print<>(const char *val) {
119  std::cout << "<const char *>: " << val << std::endl;
120 }
121 
122 inline void printArgs(void) {}
123 template <typename Arg0, typename... Args>
124 void printArgs(Arg0 arg0, Args... args) {
125  std::cout << "\t";
126  print(arg0);
127  pi::printArgs(std::forward<Args>(args)...);
128 }
129 
130 template <typename T> struct printOut {
131  printOut(T) {}
132 }; // Do nothing
133 
134 template <> struct printOut<PiEvent *> {
136  std::cout << "\t[out]pi_event * : " << val;
137  if (val)
138  std::cout << "[ " << *val << " ... ]";
139  else
140  std::cout << "[ nullptr ]";
141  std::cout << std::endl;
142  }
143 };
144 
145 template <> struct printOut<PiMem *> {
146  printOut(PiMem *val) {
147  std::cout << "\t[out]pi_mem * : " << val;
148  if (val)
149  std::cout << "[ " << *val << " ... ]";
150  else
151  std::cout << "[ nullptr ]";
152  std::cout << std::endl;
153  }
154 };
155 
156 template <> struct printOut<void *> {
157  printOut(void *val) { std::cout << "\t[out]void * : " << val << std::endl; }
158 };
159 
160 template <typename T> struct printOut<T **> {
161  printOut(T **val) {
162  std::cout << "\t[out]<unknown> ** : " << val;
163  if (val)
164  std::cout << "[ " << *val << " ... ]";
165  else
166  std::cout << "[ nullptr ]";
167  std::cout << std::endl;
168  }
169 };
170 
171 inline void printOuts(void) {}
172 template <typename Arg0, typename... Args>
173 void printOuts(Arg0 arg0, Args... args) {
174  using T = decltype(arg0);
175  printOut<T> a(arg0);
176  printOuts(std::forward<Args>(args)...);
177 }
178 
179 } // namespace pi
180 } // namespace detail
181 } // namespace _V1
182 } // namespace sycl
_pi_image_desc::num_samples
pi_uint32 num_samples
Definition: pi.h:1112
pi_image_region_struct::height
size_t height
Definition: pi.h:1047
_pi_mem
Definition: pi_cuda.hpp:56
pi_buff_rect_region_struct::depth_scalar
size_t depth_scalar
Definition: pi.h:1030
_pi_image_desc::image_array_size
size_t image_array_size
Definition: pi.h:1108
pi_buff_rect_region_struct::height_scalar
size_t height_scalar
Definition: pi.h:1029
pi_buff_rect_offset_struct
Definition: pi.h:1018
sycl::_V1::detail::pi::printOut< PiMem * >::printOut
printOut(PiMem *val)
Definition: plugin_printers.hpp:146
sycl::_V1::detail::pi::printOut< T ** >::printOut
printOut(T **val)
Definition: plugin_printers.hpp:161
_pi_image_desc::image_type
pi_mem_type image_type
Definition: pi.h:1104
_pi_result
_pi_result
Definition: pi.h:205
sycl
Definition: access.hpp:18
_pi_image_desc::image_height
size_t image_height
Definition: pi.h:1106
_pi_platform
Definition: pi_cuda.hpp:44
pi_image_offset_struct::y
size_t y
Definition: pi.h:1038
pi.hpp
_pi_image_desc::image_slice_pitch
size_t image_slice_pitch
Definition: pi.h:1110
pi_image_region_struct::width
size_t width
Definition: pi.h:1046
pi_image_offset_struct::x
size_t x
Definition: pi.h:1037
pi_buff_rect_offset_struct::y_scalar
size_t y_scalar
Definition: pi.h:1020
pi_buff_rect_region_struct::width_bytes
size_t width_bytes
Definition: pi.h:1028
sycl::_V1::detail::pi::printOuts
void printOuts(void)
Definition: plugin_printers.hpp:171
pi_image_region_struct::depth
size_t depth
Definition: pi.h:1048
sycl::_V1::detail::pi::printOut
Definition: plugin_printers.hpp:130
_pi_image_desc::image_depth
size_t image_depth
Definition: pi.h:1107
pi_buff_rect_region_struct
Definition: pi.h:1027
sycl::_V1::a
T detail::marray_element_t< T > y T T T maxval[i] T T T a
Definition: builtins_legacy_marray_vec.hpp:542
sycl::_V1::detail::pi::print
std::enable_if<!std::is_pointer< T >::value, void >::type print(T val)
Definition: plugin_printers.hpp:24
sycl::_V1::detail::pi::printOut< void * >::printOut
printOut(void *val)
Definition: plugin_printers.hpp:157
pi_buffer_region_struct::size
size_t size
Definition: pi.h:1012
_pi_image_desc::image_width
size_t image_width
Definition: pi.h:1105
pi_image_offset_struct::z
size_t z
Definition: pi.h:1039
pi_buffer_region_struct::origin
size_t origin
Definition: pi.h:1011
_pi_image_desc::image_row_pitch
size_t image_row_pitch
Definition: pi.h:1109
pi_buffer_region_struct
Definition: pi.h:1010
_pi_image_desc
Definition: pi.h:1103
sycl::_V1::detail::pi::printOut::printOut
printOut(T)
Definition: plugin_printers.hpp:131
sycl::_V1::detail::pi::printArgs
void printArgs(void)
Definition: plugin_printers.hpp:122
_pi_event
Definition: pi_cuda.hpp:64
pi_image_offset_struct
Definition: pi.h:1036
pi_buff_rect_offset_struct::z_scalar
size_t z_scalar
Definition: pi.h:1021
pi_image_region_struct
Definition: pi.h:1045
sycl::_V1::detail::pi::printOut< PiEvent * >::printOut
printOut(PiEvent *val)
Definition: plugin_printers.hpp:135
pi_buff_rect_offset_struct::x_bytes
size_t x_bytes
Definition: pi.h:1019
std::cout
__SYCL_EXTERN_STREAM_ATTRS ostream cout
Linked to standard output.
_pi_image_desc::num_mip_levels
pi_uint32 num_mip_levels
Definition: pi.h:1111