Go to the documentation of this file. 1 #ifndef HALIDE_RUNTIME_INTERNAL_H
2 #define HALIDE_RUNTIME_INTERNAL_H
4 #ifdef COMPILING_HALIDE_RUNTIME_TESTS
8 #error "Halide runtime files must be compiled with clang in freestanding mode."
19 typedef __INT8_TYPE__
int8_t;
52 #define WEAK __attribute__((weak))
55 #define ALWAYS_INLINE inline __attribute__((always_inline))
58 #define WEAK_INLINE __attribute__((weak, always_inline))
72 #if !defined(BITS_32) && !defined(BITS_64)
75 static_assert(
sizeof(
uintptr_t) ==
sizeof(
void *));
76 static_assert(
sizeof(
intptr_t) ==
sizeof(
void *));
79 #define STDOUT_FILENO 1
80 #define STDERR_FILENO 2
92 char *
getenv(
const char *);
95 const char *
strstr(
const char *,
const char *);
96 int atoi(
const char *);
97 int strcmp(
const char *s,
const char *t);
98 int strncmp(
const char *s,
const char *t,
size_t n);
99 size_t strlen(
const char *s);
100 const char *
strchr(
const char *s,
int c);
101 void *
memcpy(
void *s1,
const void *s2,
size_t n);
102 void *
memmove(
void *dest,
const void *src,
size_t n);
103 int memcmp(
const void *s1,
const void *s2,
size_t n);
104 void *
memset(
void *s,
int val,
size_t n);
120 size_t fwrite(
const void *,
size_t,
size_t,
void *);
122 int remove(
const char *pathname);
123 int ioctl(
int fd,
unsigned long request, ...);
124 char *
strncpy(
char *dst,
const char *src,
size_t n);
162 void *pipeline_state,
165 void *pipeline_state,
169 void *pipeline_state,
173 const char *pipeline_name,
186 void *value,
int *coords,
187 int type_code,
int type_bits,
int type_lanes,
189 int parent_id,
int value_index,
int dimensions,
190 const char *trace_tag);
213 return (p + alignment - 1) & ~(alignment - 1);
218 return (value != 0) && ((value & (value - 1)) == 0);
231 return a > b ? a : b;
236 return a < b ? a : b;
260 #define _halide_stringify(x) #x
261 #define _halide_expand_and_stringify(x) _halide_stringify(x)
262 #define halide_abort_if_false(user_context, cond) \
265 halide_print(user_context, __FILE__ ":" _halide_expand_and_stringify(__LINE__) " halide_abort_if_false() failed: " #cond "\n"); \
273 #define halide_debug_assert(user_context, cond) \
276 halide_print(user_context, __FILE__ ":" _halide_expand_and_stringify(__LINE__) " halide_debug_assert() failed: " #cond "\n"); \
281 #define halide_debug_assert(user_context, cond)
284 #endif // HALIDE_RUNTIME_INTERNAL_H
WEAK void * halide_get_library_symbol(void *lib, const char *name)
void halide_free(void *user_context, void *ptr)
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)
WEAK_INLINE void * halide_internal_aligned_alloc(size_t alignment, size_t size)
WEAK void halide_error(void *user_context, const char *msg)
WEAK void(*)(void *, const char *) halide_set_error_handler(void(*handler)(void *, const char *))
unsigned __INT8_TYPE__ uint8_t
WEAK void halide_sleep_ms(void *user_context, int ms)
ALWAYS_INLINE T is_power_of_two(T value)
unsigned __INT16_TYPE__ uint16_t
WEAK int halide_device_and_host_free(void *user_context, struct halide_buffer_t *buf)
WEAK void halide_profiler_memory_allocate(void *user_context, void *pipeline_state, int func_id, uint64_t incr)
int memcmp(const void *s1, const void *s2, size_t n)
Expr min(const FuncRef &a, const FuncRef &b)
Explicit overloads of min and max for FuncRef.
const char * strchr(const char *s, int c)
ssize_t write(int fd, const void *buf, size_t bytes)
signed __INT8_TYPE__ int8_t
WEAK void * halide_get_symbol(const char *name)
char * getenv(const char *)
WEAK void halide_use_jit_module()
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)
size_t fwrite(const void *, size_t, size_t, void *)
__UINTPTR_TYPE__ uintptr_t
unsigned __INT64_TYPE__ uint64_t
WEAK int halide_start_clock(void *user_context)
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
void * memmove(void *dest, const void *src, size_t n)
@ Internal
Not visible externally, similar to 'static' linkage in C.
void * memset(void *s, int val, size_t n)
void * halide_malloc(void *user_context, size_t x)
Expr print(const std::vector< Expr > &values)
Create an Expr that prints out its value whenever it is evaluated.
WEAK int halide_host_cpu_count()
WEAK void * halide_load_library(const char *name)
WEAK_INLINE int halide_internal_malloc_alignment()
WEAK void halide_release_jit_module()
WEAK int64_t halide_current_time_ns(void *user_context)
int strncmp(const char *s, const char *t, size_t n)
WEAK void halide_profiler_memory_free(void *user_context, void *pipeline_state, int func_id, uint64_t decr)
WEAK void halide_device_host_nop_free(void *user_context, void *obj)
signed __INT64_TYPE__ int64_t
WEAK void(*)(void *, const char *) halide_set_custom_print(void(*print)(void *, const char *))
WEAK_INLINE void halide_internal_aligned_free(void *ptr)
WEAK char * halide_int64_to_string(char *dst, char *end, int64_t arg, int digits)
int strcmp(const char *s, const char *t)
WEAK_INLINE void * halide_fopen(const char *filename, const char *type)
void halide_thread_yield()
WEAK int halide_profiler_pipeline_start(void *user_context, const char *pipeline_name, int num_funcs, const uint64_t *func_names)
WEAK int halide_trace_helper(void *user_context, const char *func, void *value, int *coords, int type_code, int type_bits, int type_lanes, int code, int parent_id, int value_index, int dimensions, const char *trace_tag)
ALWAYS_INLINE T align_up(T p, size_t alignment)
WEAK int halide_device_and_host_malloc(void *user_context, struct halide_buffer_t *buf, const struct halide_device_interface_t *device_interface)
void * memcpy(void *s1, const void *s2, size_t n)
const char * strstr(const char *, const char *)
The raw representation of an image passed around by generated Halide code.
WEAK void halide_device_free_as_destructor(void *user_context, void *obj)
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)
Each GPU API provides a halide_device_interface_t struct pointing to the code that manages device all...
int ioctl(int fd, unsigned long request,...)
signed __INT16_TYPE__ int16_t
WEAK char * halide_string_to_string(char *dst, char *end, const char *arg)
WEAK void halide_print(void *user_context, const char *msg)
unsigned __INT32_TYPE__ uint32_t
Expr max(const FuncRef &a, const FuncRef &b)
WEAK void halide_device_and_host_free_as_destructor(void *user_context, void *obj)
size_t strlen(const char *s)
__PTRDIFF_TYPE__ ptrdiff_t
char * strncpy(char *dst, const char *src, size_t n)
WEAK void halide_profiler_stack_peak_update(void *user_context, void *pipeline_state, uint64_t *f_values)
int remove(const char *pathname)