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 <CL/sycl/detail/pi.hpp>
14 
15 #include <type_traits>
16 
18 namespace sycl {
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 sycl
182 } // __SYCL_INLINE_NAMESPACE(cl)
_pi_image_desc::num_samples
pi_uint32 num_samples
Definition: pi.h:945
pi_image_region_struct::height
size_t height
Definition: pi.h:884
_pi_mem
PI Mem mapping to CUDA memory allocations, both data and texture/surface.
Definition: pi_cuda.hpp:207
pi_buff_rect_region_struct::depth_scalar
size_t depth_scalar
Definition: pi.h:867
_pi_image_desc::image_array_size
size_t image_array_size
Definition: pi.h:941
PI_SUCCESS
@ PI_SUCCESS
Definition: pi.h:86
pi_buff_rect_region_struct::height_scalar
size_t height_scalar
Definition: pi.h:866
pi_buff_rect_offset_struct
Definition: pi.h:855
cl::sycl::detail::pi::printOut
Definition: plugin_printers.hpp:130
_pi_image_desc::image_type
pi_mem_type image_type
Definition: pi.h:937
_pi_result
_pi_result
Definition: pi.h:85
sycl
Definition: invoke_simd.hpp:68
_pi_image_desc::image_height
size_t image_height
Definition: pi.h:939
_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_image_offset_struct::y
size_t y
Definition: pi.h:875
pi.hpp
_pi_image_desc::image_slice_pitch
size_t image_slice_pitch
Definition: pi.h:943
pi_image_region_struct::width
size_t width
Definition: pi.h:883
pi_image_offset_struct::x
size_t x
Definition: pi.h:874
cl::sycl::detail::pi::print
void print(const char *val)
Definition: plugin_printers.hpp:118
pi_buff_rect_offset_struct::y_scalar
size_t y_scalar
Definition: pi.h:857
pi_buff_rect_region_struct::width_bytes
size_t width_bytes
Definition: pi.h:865
cl::sycl::detail::pi::printOut< PiMem * >::printOut
printOut(PiMem *val)
Definition: plugin_printers.hpp:146
pi_image_region_struct::depth
size_t depth
Definition: pi.h:885
_pi_image_desc::image_depth
size_t image_depth
Definition: pi.h:940
pi_buff_rect_region_struct
Definition: pi.h:864
cl::sycl::detail::pi::printOut::printOut
printOut(T)
Definition: plugin_printers.hpp:131
cl::sycl::detail::pi::printArgs
void printArgs(Arg0 arg0, Args... args)
Definition: plugin_printers.hpp:124
cl
We provide new interfaces for matrix muliply in this patch:
Definition: access.hpp:13
cl::sycl::detail::pi::printOut< void * >::printOut
printOut(void *val)
Definition: plugin_printers.hpp:157
cl::sycl::image_channel_order::a
@ a
pi_buffer_region_struct::size
size_t size
Definition: pi.h:849
_pi_image_desc::image_width
size_t image_width
Definition: pi.h:938
cl::sycl::detail::pi::printOut< T ** >::printOut
printOut(T **val)
Definition: plugin_printers.hpp:161
pi_image_offset_struct::z
size_t z
Definition: pi.h:876
pi_buffer_region_struct::origin
size_t origin
Definition: pi.h:848
_pi_image_desc::image_row_pitch
size_t image_row_pitch
Definition: pi.h:942
pi_buffer_region_struct
Definition: pi.h:847
_pi_image_desc
Definition: pi.h:936
_pi_event
PI Event mapping to CUevent.
Definition: pi_cuda.hpp:458
cl::sycl::detail::pi::printOuts
void printOuts(Arg0 arg0, Args... args)
Definition: plugin_printers.hpp:173
pi_image_offset_struct
Definition: pi.h:873
pi_buff_rect_offset_struct::z_scalar
size_t z_scalar
Definition: pi.h:858
pi_image_region_struct
Definition: pi.h:882
cl::sycl::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:856
_pi_image_desc::num_mip_levels
pi_uint32 num_mip_levels
Definition: pi.h:944
__SYCL_INLINE_NAMESPACE
#define __SYCL_INLINE_NAMESPACE(X)
Definition: defines_elementary.hpp:12