Go to the documentation of this file. 1 #ifndef HALIDE_RUNTIME_PRINTER_H
2 #define HALIDE_RUNTIME_PRINTER_H
9 #ifndef HALIDE_RUNTIME_PRINTER_LOG_THREADID
10 #define HALIDE_RUNTIME_PRINTER_LOG_THREADID 0
13 #if HALIDE_RUNTIME_PRINTER_LOG_THREADID
14 extern "C" int pthread_threadid_np(
long thread,
uint64_t *thread_id);
45 template<Pr
interType pr
inter_type, u
int64_t buffer_length = default_pr
inter_buffer_length>
47 char *buf, *dst, *end;
52 explicit Printer(
void *ctx,
char *mem =
nullptr)
53 : user_context(ctx), own_mem(mem ==
nullptr) {
57 buf = (
char *)
malloc(buffer_length);
62 end = buf + (buffer_length - 1);
69 #if HALIDE_RUNTIME_PRINTER_LOG_THREADID
71 pthread_threadid_np(0, &tid);
72 *
this <<
"(TID:" << tid <<
")";
77 Printer(
const Printer ©) =
delete;
78 Printer &operator=(
const Printer &) =
delete;
79 Printer(Printer &&) =
delete;
80 Printer &operator=(Printer &&) =
delete;
122 Printer &write_float16_from_bits(
const uint16_t arg) {
139 void append(
const T &value) {
143 template<
typename First,
typename Second,
typename... Rest>
144 void append(
const First &first,
const Second &second,
const Rest &...rest) {
145 append<First>(first);
146 append<Second, Rest...>(second, rest...);
153 msan_annotate_is_initialized();
157 return allocation_error();
175 return buffer_length;
189 const char *allocation_error() {
190 return "Printer buffer allocation failed.\n";
193 void msan_annotate_is_initialized() {
201 msan_annotate_is_initialized();
229 template<u
int64_t buffer_length = default_pr
inter_buffer_length>
230 using BasicPrinter = Printer<BasicPrinterType, buffer_length>;
232 template<u
int64_t buffer_length = default_pr
inter_buffer_length>
233 using ErrorPrinter = Printer<ErrorPrinterType, buffer_length>;
235 template<u
int64_t buffer_length = default_pr
inter_buffer_length>
236 using StringStreamPrinter = Printer<StringStreamPrinterType, buffer_length>;
238 using print = BasicPrinter<>;
239 using error = ErrorPrinter<>;
240 using stringstream = StringStreamPrinter<>;
243 using debug = BasicPrinter<>;
245 using debug = SinkPrinter;
251 template<Pr
interType pr
inter_type, u
int64_t buffer_length>
253 char scratch[buffer_length];
257 : Printer<printer_type, buffer_length>(ctx, scratch) {
258 static_assert(buffer_length <= 256,
"StackPrinter is meant only for small buffer sizes; you are probably making a mistake.");
262 template<u
int64_t buffer_length = default_pr
inter_buffer_length>
265 template<u
int64_t buffer_length = default_pr
inter_buffer_length>
268 template<u
int64_t buffer_length = default_pr
inter_buffer_length>
signed __INT32_TYPE__ int32_t
WEAK char * halide_double_to_string(char *dst, char *end, double arg, int scientific)
WEAK char * halide_type_to_string(char *dst, char *end, const halide_type_t *arg)
unsigned __INT16_TYPE__ uint16_t
double halide_float16_bits_to_double(uint16_t)
Read bits representing a half precision floating point number and return the double that represents t...
@ StringStreamPrinterType
A runtime tag for a type in the halide type system.
WEAK char * halide_buffer_to_string(char *dst, char *end, const halide_buffer_t *arg)
unsigned __INT64_TYPE__ uint64_t
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
void halide_error(void *user_context, const char *)
Halide calls this function on runtime errors (for example bounds checking failures).
Expr print(const std::vector< Expr > &values)
Create an Expr that prints out its value whenever it is evaluated.
signed __INT64_TYPE__ int64_t
WEAK char * halide_int64_to_string(char *dst, char *end, int64_t arg, int digits)
std::ostream & operator<<(std::ostream &stream, const Expr &)
Emit an expression on an output stream (such as std::cout) in human-readable form.
int halide_msan_annotate_memory_is_initialized(void *user_context, const void *ptr, uint64_t len)
Annotate that a given range of memory has been initialized; only used when Target::MSAN is enabled.
The raw representation of an image passed around by generated Halide code.
WEAK char * halide_uint64_to_string(char *dst, char *end, uint64_t arg, int digits)
WEAK char * halide_pointer_to_string(char *dst, char *end, const void *arg)
void halide_print(void *user_context, const char *)
Print a message to stderr.
WEAK char * halide_string_to_string(char *dst, char *end, const char *arg)
unsigned __INT32_TYPE__ uint32_t
constexpr uint64_t default_printer_buffer_length