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."
19typedef __INT8_TYPE__
int8_t;
52#define WEAK __attribute__((weak))
54#define NEVER_INLINE __attribute__((noinline))
57#define ALWAYS_INLINE inline __attribute__((always_inline))
60#define WEAK_INLINE __attribute__((weak, always_inline))
74#if !defined(BITS_32) && !defined(BITS_64)
77static_assert(
sizeof(
uintptr_t) ==
sizeof(
void *));
78static_assert(
sizeof(
intptr_t) ==
sizeof(
void *));
81#define STDOUT_FILENO 1
82#define STDERR_FILENO 2
97const char *
strstr(
const char *,
const char *);
99int strcmp(
const char *s,
const char *t);
100int strncmp(
const char *s,
const char *t,
size_t n);
103void *
memcpy(
void *s1,
const void *s2,
size_t n);
104void *
memmove(
void *dest,
const void *src,
size_t n);
105int memcmp(
const void *s1,
const void *s2,
size_t n);
122size_t fwrite(
const void *,
size_t,
size_t,
void *);
125int ioctl(
int fd,
unsigned long request, ...);
126char *
strncpy(
char *dst,
const char *src,
size_t n);
161struct halide_profiler_instance_state;
163 halide_profiler_instance_state *instance,
166 halide_profiler_instance_state *instance,
170 halide_profiler_instance_state *instance,
174 const char *pipeline_name,
177 halide_profiler_instance_state *instance);
179 halide_profiler_instance_state *instance);
195 void *value,
int *coords,
196 int type_code,
int type_bits,
int type_lanes,
198 int parent_id,
int value_index,
int dimensions,
199 const char *trace_tag);
222 return (p + alignment - 1) & ~(alignment - 1);
227 return (value != 0) && ((value & (value - 1)) == 0);
240 return a > b ? a : b;
245 return a < b ? a : b;
269#define _halide_stringify(x) #x
270#define _halide_expand_and_stringify(x) _halide_stringify(x)
271#define halide_abort_if_false(user_context, cond) \
274 halide_print(user_context, __FILE__ ":" _halide_expand_and_stringify(__LINE__) " halide_abort_if_false() failed: " #cond "\n"); \
282#define halide_debug_assert(user_context, cond) \
285 halide_print(user_context, __FILE__ ":" _halide_expand_and_stringify(__LINE__) " halide_debug_assert() failed: " #cond "\n"); \
290#define halide_debug_assert(user_context, cond)
size_t strlen(const char *string)
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
@ Internal
Not visible externally, similar to 'static' linkage in C.
unsigned __INT64_TYPE__ uint64_t
int remove(const char *pathname)
const char * strchr(const char *s, int c)
ALWAYS_INLINE T is_power_of_two(T value)
WEAK void halide_start_timer_chain()
WEAK void halide_profiler_memory_free(void *user_context, halide_profiler_instance_state *instance, int func_id, uint64_t decr)
signed __INT64_TYPE__ int64_t
WEAK int halide_host_cpu_count()
int ioctl(int fd, unsigned long request,...)
WEAK void * halide_get_library_symbol(void *lib, const char *name)
WEAK char * halide_uint64_to_string(char *dst, char *end, uint64_t arg, int digits)
int strcmp(const char *s, const char *t)
WEAK int halide_profiler_instance_end(void *user_context, halide_profiler_instance_state *instance)
void * halide_malloc(void *user_context, size_t x)
WEAK int halide_profiler_instance_start(void *user_context, const char *pipeline_name, int num_funcs, const uint64_t *func_names, halide_profiler_instance_state *instance)
void halide_free(void *user_context, void *ptr)
WEAK int halide_device_and_host_malloc(void *user_context, struct halide_buffer_t *buf, const struct halide_device_interface_t *device_interface)
void * memmove(void *dest, const void *src, size_t n)
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)
int strncmp(const char *s, const char *t, size_t n)
WEAK int halide_start_clock(void *user_context)
WEAK void halide_enable_timer_interrupt()
WEAK void * halide_load_library(const char *name)
WEAK void halide_device_free_as_destructor(void *user_context, void *obj)
size_t fwrite(const void *, size_t, size_t, void *)
__UINTPTR_TYPE__ uintptr_t
WEAK void halide_profiler_memory_allocate(void *user_context, halide_profiler_instance_state *instance, int func_id, uint64_t incr)
ALWAYS_INLINE T align_up(T p, size_t alignment)
WEAK int halide_device_and_host_free(void *user_context, struct halide_buffer_t *buf)
WEAK char * halide_type_to_string(char *dst, char *end, const halide_type_t *arg)
WEAK void halide_release_jit_module()
WEAK void * halide_get_symbol(const char *name)
signed __INT32_TYPE__ int32_t
unsigned __INT8_TYPE__ uint8_t
WEAK void halide_disable_timer_interrupt()
WEAK void halide_device_and_host_free_as_destructor(void *user_context, void *obj)
__PTRDIFF_TYPE__ ptrdiff_t
WEAK void(*)(void *, const char *) halide_set_custom_print(void(*print)(void *, const char *))
void halide_thread_yield()
char * strncpy(char *dst, const char *src, size_t n)
unsigned __INT16_TYPE__ uint16_t
WEAK char * halide_int64_to_string(char *dst, char *end, int64_t arg, int digits)
WEAK char * halide_pointer_to_string(char *dst, char *end, const void *arg)
void * memcpy(void *s1, const void *s2, size_t n)
ssize_t write(int fd, const void *buf, size_t bytes)
WEAK void halide_print(void *user_context, const char *msg)
WEAK void halide_profiler_stack_peak_update(void *user_context, halide_profiler_instance_state *instance, uint64_t *f_values)
int memcmp(const void *s1, const void *s2, size_t n)
WEAK_INLINE int halide_internal_malloc_alignment()
void * memset(void *s, int val, size_t n)
unsigned __INT32_TYPE__ uint32_t
WEAK char * halide_double_to_string(char *dst, char *end, double arg, int scientific)
WEAK void halide_sleep_us(void *user_context, int us)
WEAK int64_t halide_current_time_ns(void *user_context)
signed __INT16_TYPE__ int16_t
WEAK void halide_error(void *user_context, const char *msg)
WEAK void halide_use_jit_module()
WEAK_INLINE void halide_internal_aligned_free(void *ptr)
WEAK_INLINE void * halide_fopen(const char *filename, const char *type)
const char * strstr(const char *, const char *)
signed __INT8_TYPE__ int8_t
WEAK char * halide_buffer_to_string(char *dst, char *end, const halide_buffer_t *arg)
WEAK void(*)(void *, const char *) halide_set_error_handler(void(*handler)(void *, const char *))
WEAK void halide_device_host_nop_free(void *user_context, void *obj)
char * getenv(const char *)
WEAK_INLINE void * halide_internal_aligned_alloc(size_t alignment, size_t size)
WEAK char * halide_string_to_string(char *dst, char *end, const char *arg)
The raw representation of an image passed around by generated Halide code.
Each GPU API provides a halide_device_interface_t struct pointing to the code that manages device all...
A runtime tag for a type in the halide type system.