Go to the documentation of this file. 1 #ifndef HALIDE_HALIDERUNTIME_H
2 #define HALIDE_HALIDERUNTIME_H
4 #ifndef COMPILING_HALIDE_RUNTIME
10 #include <string_view>
35 #define HALIDE_ALWAYS_INLINE __forceinline
36 #define HALIDE_NEVER_INLINE __declspec(noinline)
40 #define HALIDE_ALWAYS_INLINE inline __attribute__((always_inline))
41 #define HALIDE_NEVER_INLINE __attribute__((noinline))
44 #ifndef HALIDE_MUST_USE_RESULT
45 #ifdef __has_attribute
46 #if __has_attribute(nodiscard)
48 #define HALIDE_MUST_USE_RESULT [[nodiscard]]
49 #elif __has_attribute(warn_unused_result)
51 #define HALIDE_MUST_USE_RESULT __attribute__((warn_unused_result))
53 #define HALIDE_MUST_USE_RESULT
56 #define HALIDE_MUST_USE_RESULT
66 #ifndef HALIDE_FUNCTION_ATTRS
67 #define HALIDE_FUNCTION_ATTRS
70 #ifndef HALIDE_EXPORT_SYMBOL
72 #define HALIDE_EXPORT_SYMBOL __declspec(dllexport)
74 #define HALIDE_EXPORT_SYMBOL __attribute__((visibility("default")))
78 #ifndef COMPILING_HALIDE_RUNTIME
85 #if defined(__clang__) && (__clang_major__ >= 16) && !defined(__EMSCRIPTEN__)
86 #if defined(__is_identifier)
87 #if !__is_identifier(_Float16)
88 #define HALIDE_CPP_COMPILER_HAS_FLOAT16
96 #if defined(__GNUC__) && (__GNUC__ >= 12)
97 #if defined(__x86_64__) || defined(__i386__) || defined(__arm__) || defined(__aarch64__)
98 #define HALIDE_CPP_COMPILER_HAS_FLOAT16
102 #endif // !COMPILING_HALIDE_RUNTIME
143 extern void halide_print(
void *user_context,
const char *);
157 extern void halide_error(
void *user_context,
const char *);
239 uint8_t *closure,
void *task_parent);
317 uint8_t *closure,
void *task_parent);
358 struct halide_thread;
401 extern void halide_free(
void *user_context,
void *ptr);
404 typedef void *(*halide_malloc_t)(
void *,
size_t);
427 typedef void *(*halide_get_symbol_t)(
const char *name);
428 typedef void *(*halide_load_library_t)(
const char *name);
429 typedef void *(*halide_get_library_symbol_t)(
void *lib,
const char *name);
450 #if (__cplusplus >= 201103L || _MSVC_LANG >= 201103L)
463 #ifndef HALIDE_ATTRIBUTE_ALIGN
465 #define HALIDE_ATTRIBUTE_ALIGN(x) __declspec(align(x))
467 #define HALIDE_ATTRIBUTE_ALIGN(x) __attribute__((aligned(x)))
478 #if (__cplusplus >= 201103L || _MSVC_LANG >= 201103L)
494 #if (__cplusplus >= 201103L || _MSVC_LANG >= 201103L)
518 return as_u32() == other.as_u32();
522 return !(*
this == other);
526 return as_u32() < other.as_u32();
531 return (
bits + 7) / 8;
546 #if (__cplusplus >= 201103L || _MSVC_LANG >= 201103L)
670 #if (__cplusplus >= 201103L || _MSVC_LANG >= 201103L)
675 return (
const int *)(
this + 1);
679 return (
int *)(
this + 1);
686 return (
const void *)(coordinates() +
dimensions);
707 const char *f = func();
867 int slice_dim,
int slice_pos,
963 bool has_eviction_key,
uint64_t eviction_key);
1247 int min_bound,
int max_bound,
int min_required,
int max_required);
1253 int dimension,
int min_touched,
int max_touched,
1254 int min_valid,
int max_valid);
1262 int constrained_min,
int constrained_extent,
1263 int required_min,
int required_extent);
1265 const char *constrained_var,
int constrained_val);
1271 double val,
double min_val);
1277 double val,
double max_val);
1281 const char *filename,
int error_code);
1285 const char *loop_name);
1287 int dim,
int min,
int extent,
int valid_min,
int fold_factor);
1290 int fold_factor,
const char *loop_name,
int required_extent);
1299 int provided_size,
int required_size);
1449 #if (__cplusplus >= 201103L || _MSVC_LANG >= 201103L)
1461 return (
min == other.
min) &&
1468 return !(*
this == other);
1518 #if (__cplusplus >= 201103L || _MSVC_LANG >= 201103L)
1522 return (
flags & flag) != 0;
1594 return host + begin_offset() *
type.bytes();
1600 return host + end_offset() *
type.bytes();
1605 return (
size_t)(end_offset() - begin_offset()) *
type.bytes();
1614 return host + index *
type.bytes();
1642 #ifndef HALIDE_ATTRIBUTE_DEPRECATED
1643 #ifdef HALIDE_ALLOW_DEPRECATED
1644 #define HALIDE_ATTRIBUTE_DEPRECATED(x)
1647 #define HALIDE_ATTRIBUTE_DEPRECATED(x) __declspec(deprecated(x))
1649 #define HALIDE_ATTRIBUTE_DEPRECATED(x) __attribute__((deprecated(x)))
1736 static const int32_t VERSION = 1;
1770 int (*filter_argv_call)(
void **),
1772 const char *
const *extra_key_value_pairs);
1796 uint64_t active_threads_numerator, active_threads_denominator;
1822 uint64_t active_threads_numerator, active_threads_denominator;
1828 struct halide_profiler_func_stats *funcs;
2011 #if (__cplusplus >= 201103L || _MSVC_LANG >= 201103L)
2015 template<
typename T>
2016 struct check_is_pointer {
2017 static constexpr
bool value =
false;
2020 template<
typename T>
2021 struct check_is_pointer<T *> {
2022 static constexpr
bool value =
true;
2028 template<
typename T>
2034 static_assert(check_is_pointer<T>::value,
"Expected a pointer type here");
2038 #ifdef HALIDE_CPP_COMPILER_HAS_FLOAT16
2100 #ifndef COMPILING_HALIDE_RUNTIME
2105 namespace HalideFunctionInfo {
2107 enum ArgumentKind { InputScalar = 0,
2111 struct ArgumentInfo {
2112 std::string_view name;
2120 #endif // COMPILING_HALIDE_RUNTIME
2122 #endif // (__cplusplus >= 201103L || _MSVC_LANG >= 201103L)
2124 #endif // HALIDE_HALIDERUNTIME_H
@ halide_target_feature_no_bounds_query
Disable the bounds querying functionality.
void *(* halide_get_symbol_t)(const char *name)
signed __INT32_TYPE__ int32_t
int(* device_crop)(void *user_context, const struct halide_buffer_t *src, struct halide_buffer_t *dst)
halide_free_t halide_set_custom_free(halide_free_t user_free)
int halide_set_num_threads(int n)
Set the number of threads used by Halide's thread pool.
@ halide_target_feature_cl_half
Enable half support on OpenCL targets.
@ halide_trace_begin_realization
halide_target_feature_t
Optional features a compilation Target can have.
int first_free_id
An internal id used for bookkeeping.
int halide_error_device_interface_no_device(void *user_context)
void halide_free(void *user_context, void *ptr)
@ halide_error_code_host_and_device_dirty
Buffer has both host and device dirty bits set, which violates a Halide invariant.
struct halide_mutex * array
int halide_default_semaphore_init(struct halide_semaphore_t *, int n)
int halide_error_constraints_make_required_region_smaller(void *user_context, const char *buffer_name, int dimension, int constrained_min, int constrained_extent, int required_min, int required_extent)
void halide_set_trace_file(int fd)
Set the file descriptor that Halide should write binary trace events to.
const struct halide_scalar_value_t * scalar_min
int(* halide_task_t)(void *user_context, int task_number, uint8_t *closure)
Define halide_do_par_for to replace the default thread pool implementation.
@ halide_type_handle
opaque pointer type (void *)
@ halide_target_feature_sve
Enable ARM Scalable Vector Extensions.
@ halide_argument_kind_output_buffer
int(* halide_do_par_for_t)(void *, halide_task_t, int, int, uint8_t *)
Set a custom method for performing a parallel for loop.
void halide_memoization_cache_set_size(int64_t size)
Set the soft maximum amount of memory, in bytes, that the LRU cache will use to memoize Func results.
const char * trace_tag
For halide_trace_tag, this points to a read-only null-terminated string of arbitrary text.
@ halide_error_code_internal_error
There is a bug in the Halide compiler.
int halide_error_debug_to_file_failed(void *user_context, const char *func, const char *filename, int error_code)
halide_dimension_t * dim
The shape of the buffer.
unsigned __INT8_TYPE__ uint8_t
@ halide_error_code_device_crop_failed
Cropping/slicing a buffer failed for some other reason.
int(* halide_do_task_t)(void *, halide_task_t, int, uint8_t *)
If you use the default do_par_for, you can still set a custom handler to perform each individual task...
@ halide_type_bfloat
floating point numbers in the bfloat format
@ halide_target_feature_vulkan
Enable Vulkan runtime support.
@ halide_profiler_please_stop
Set current_func to this value to tell the profiling thread to halt.
int halide_memoization_cache_lookup(void *user_context, const uint8_t *cache_key, int32_t size, struct halide_buffer_t *realized_bounds, int32_t tuple_count, struct halide_buffer_t **tuple_buffers)
Given a cache key for a memoized result, currently constructed from the Func name and top-level Func ...
@ halide_error_code_success
There was no error.
unsigned __INT16_TYPE__ uint16_t
int halide_mutex_array_unlock(struct halide_mutex_array *array, int entry)
void halide_register_argv_and_metadata(int(*filter_argv_call)(void **), const struct halide_filter_metadata_t *filter_metadata, const char *const *extra_key_value_pairs)
halide_register_argv_and_metadata() is a user-defined function that must be provided in order to use ...
@ halide_error_code_fold_factor_too_small
A fold_storage directive was used with a fold factor that was too small to store all the values of a ...
void halide_set_custom_parallel_runtime(halide_do_par_for_t, halide_do_task_t, halide_do_loop_task_t, halide_do_parallel_tasks_t, halide_semaphore_init_t, halide_semaphore_try_acquire_t, halide_semaphore_release_t)
@ halide_error_code_constraints_make_required_region_smaller
Applying explicit constraints on the size of an input or output buffer shrank the size of that buffer...
@ halide_target_feature_asan
Enable hooks for ASAN support.
auto operator!=(const Other &a, const GeneratorParam< T > &b) -> decltype(a !=(T) b)
Inequality comparison between between GeneratorParam<T> and any type that supports operator!...
void halide_cond_wait(struct halide_cond *cond, struct halide_mutex *mutex)
int halide_reuse_device_allocations(void *user_context, bool)
Tell Halide whether or not it is permitted to hold onto device allocations to service future requests...
int halide_default_do_loop_task(void *user_context, halide_loop_task_t f, int min, int extent, uint8_t *closure, void *task_parent)
int(* halide_loop_task_t)(void *user_context, int min, int extent, uint8_t *closure, void *task_parent)
A task representing a serial for loop evaluated over some range.
int halide_error_host_and_device_dirty(void *user_context)
@ halide_error_code_device_run_failed
The Halide runtime encountered an error while trying to launch a GPU kernel.
int(* device_and_host_free)(void *user_context, struct halide_buffer_t *buf)
@ halide_error_code_buffer_extents_too_large
A halide_buffer_t was given with extents that multiply to a number greater than 2^31-1.
halide_get_symbol_t halide_set_custom_get_symbol(halide_get_symbol_t user_get_symbol)
struct halide_mutex_array * halide_mutex_array_create(int sz)
@ halide_type_float
IEEE floating point numbers.
int halide_error_device_dirty_with_no_device_support(void *user_context, const char *buffer_name)
int halide_device_sync(void *user_context, struct halide_buffer_t *buf)
Wait for current GPU operations to complete.
int(* device_and_host_malloc)(void *user_context, struct halide_buffer_t *buf, const struct halide_device_interface_t *device_interface)
@ halide_target_feature_vulkan_version10
Enable Vulkan v1.0 runtime target support.
void halide_start_timer_chain()
For timer based profiling, this routine starts the timer chain running.
Expr min(const FuncRef &a, const FuncRef &b)
Explicit overloads of min and max for FuncRef.
int halide_mutex_array_lock(struct halide_mutex_array *array, int entry)
int(* device_malloc)(void *user_context, struct halide_buffer_t *buf, const struct halide_device_interface_t *device_interface)
int halide_shutdown_trace()
If tracing is writing to a file.
void halide_memoization_cache_release(void *user_context, void *host)
If halide_memoization_cache_lookup succeeds, halide_memoization_cache_release must be called to signa...
halide_malloc_t halide_set_custom_malloc(halide_malloc_t user_malloc)
void halide_mutex_lock(struct halide_mutex *mutex)
A basic set of mutex and condition variable functions, which call platform specific code for mutual e...
enum halide_trace_event_code_t event
signed __INT8_TYPE__ int8_t
@ halide_target_feature_sse41
Use SSE 4.1 and earlier instructions. Only relevant on x86.
int32_t id
The id of this packet (for the purpose of parent_id).
int(* detach_native)(void *user_context, struct halide_buffer_t *buf)
int(* wrap_native)(void *user_context, struct halide_buffer_t *buf, uint64_t handle, const struct halide_device_interface_t *device_interface)
@ halide_error_code_unaligned_host_ptr
The Halide runtime encountered a host pointer that violated the alignment set for it by way of a call...
The header of a packet in a binary trace.
@ halide_error_code_copy_to_device_failed
The Halide runtime encountered an error while trying to copy from host to device.
Cross platform condition variable.
@ halide_target_feature_d3d12compute
Enable Direct3D 12 Compute runtime.
@ halide_target_feature_no_runtime
Do not include a copy of the Halide runtime in any generated object file or assembly.
@ halide_target_feature_cuda_capability32
Enable CUDA compute capability 3.2 (Tegra K1)
uint8_t bits
The number of bits of precision of a single scalar value of this type.
Expr with_lanes(const Expr &x, int lanes)
Rewrite the expression x to have lanes lanes.
@ halide_target_feature_profile_by_timer
Alternative to halide_target_feature_profile using timer interrupt for systems without threads or app...
int halide_do_loop_task(void *user_context, halide_loop_task_t f, int min, int extent, uint8_t *closure, void *task_parent)
struct halide_type_t type
int halide_error_explicit_bounds_too_small(void *user_context, const char *func_name, const char *var_name, int min_bound, int max_bound, int min_required, int max_required)
Various other error conditions.
@ halide_target_feature_vulkan_version13
Enable Vulkan v1.3 runtime target support.
void *(* halide_load_library_t)(const char *name)
double halide_float16_bits_to_double(uint16_t)
Read bits representing a half precision floating point number and return the double that represents t...
@ halide_target_feature_embed_bitcode
Emulate clang -fembed-bitcode flag.
int halide_error_no_device_interface(void *user_context)
void halide_profiler_report(void *user_context)
Print out timing statistics for everything run since the last reset.
struct halide_thread * sampling_thread
Sampling thread reference to be joined at shutdown.
int halide_default_do_parallel_tasks(void *user_context, int num_tasks, struct halide_parallel_task_t *tasks, void *task_parent)
@ halide_target_feature_trace_stores
Trace all stores done by the pipeline. Equivalent to calling Func::trace_stores on every non-inlined ...
int halide_copy_to_host(void *user_context, struct halide_buffer_t *buf)
Copy image data from device memory to host memory.
int halide_error_bad_fold(void *user_context, const char *func_name, const char *var_name, const char *loop_name)
void halide_default_free(void *user_context, void *ptr)
@ halide_trace_end_pipeline
A runtime tag for a type in the halide type system.
void(* halide_error_handler_t)(void *, const char *)
@ halide_error_code_constraint_violated
A constraint on a size or stride of an input or output buffer was not met by the halide_buffer_t pass...
@ halide_target_feature_armv7s
Generate code for ARMv7s. Only relevant for 32-bit ARM.
@ halide_target_feature_msan
Enable hooks for MSAN support.
int halide_error_bad_dimensions(void *user_context, const char *func_name, int32_t dimensions_given, int32_t correct_dimensions)
void halide_default_print(void *user_context, const char *)
@ halide_target_feature_armv81a
Enable ARMv8.1-a instructions.
int(* device_slice)(void *user_context, const struct halide_buffer_t *src, int slice_dim, int slice_pos, struct halide_buffer_t *dst)
int halide_error_bad_type(void *user_context, const char *func_name, uint32_t type_given, uint32_t correct_type)
void halide_cond_signal(struct halide_cond *cond)
@ halide_target_feature_tsan
Enable hooks for TSAN support.
halide_trace_event_code_t
void(* get_remote_profiler_state)(int *func, int *active_workers)
Retrieve remote profiler state.
@ halide_error_code_explicit_bounds_too_small
A Func was given an explicit bound via Func::bound, but this was not large enough to encompass the re...
int halide_error_buffer_extents_too_large(void *user_context, const char *buffer_name, int64_t actual_size, int64_t max_size)
int halide_error_param_too_large_f64(void *user_context, const char *param_name, double val, double max_val)
struct halide_type_t type
The type of each buffer element.
__UINTPTR_TYPE__ uintptr_t
@ halide_target_feature_fma
Enable x86 FMA instruction.
int halide_error_constraint_violated(void *user_context, const char *var, int val, const char *constrained_var, int constrained_val)
void(* device_release)(void *user_context, const struct halide_device_interface_t *device_interface)
@ halide_target_feature_hvx_v65
Enable Hexagon v65 architecture.
int(* compute_capability)(void *user_context, int *major, int *minor)
const char * func
The name of the Func or Pipeline that this event refers to.
@ halide_target_feature_cl_doubles
Enable double support on OpenCL targets.
int32_t * coordinates
For loads and stores, an array which contains the location being accessed.
unsigned __INT64_TYPE__ uint64_t
int halide_do_par_for(void *user_context, halide_task_t task, int min, int size, uint8_t *closure)
@ halide_error_code_gpu_device_error
Call(s) to a GPU backend API failed.
@ halide_error_code_generic_error
An uncategorized error occurred.
@ halide_profiler_outside_of_halide
current_func takes on this value when not inside Halide code
int sleep_time
The amount of time the profiler thread sleeps between samples in milliseconds.
@ halide_error_code_device_wrap_native_failed
The Halide runtime encountered an error while trying to wrap a native device handle.
int halide_error_param_too_large_i64(void *user_context, const char *param_name, int64_t val, int64_t max_val)
int(* device_sync)(void *user_context, struct halide_buffer_t *buf)
@ halide_error_code_out_of_memory
A call to halide_malloc returned NULL.
@ halide_error_code_unimplemented
This part of the Halide runtime is unimplemented on this platform.
int(* halide_do_parallel_tasks_t)(void *, int, struct halide_parallel_task_t *, void *task_parent)
Provide an entire custom tasking runtime via function pointers.
@ halide_error_code_trace_failed
Failure recording trace packets for one of the halide_target_feature_trace features.
const struct halide_scalar_value_t * max
void * value
If the event type is a load or a store, this points to the value being loaded or stored.
void halide_error(void *user_context, const char *)
Halide calls this function on runtime errors (for example bounds checking failures).
struct halide_device_allocation_pool * next
int halide_device_wrap_native(void *user_context, struct halide_buffer_t *buf, uint64_t handle, const struct halide_device_interface_t *device_interface)
Wrap or detach a native device handle, setting the device field and device_interface field as appropr...
@ halide_target_feature_openglcompute
Enable OpenGL Compute runtime. NOTE: This feature is deprecated and will be removed in Halide 17.
int32_t halide_default_trace(void *user_context, const struct halide_trace_event_t *event)
void halide_mutex_unlock(struct halide_mutex *mutex)
int32_t dimensions
The dimensionality of the buffer.
int halide_error_buffer_argument_is_null(void *user_context, const char *buffer_name)
halide_scalar_value_t is a simple union able to represent all the well-known scalar values in a filte...
int(* copy_to_device)(void *user_context, struct halide_buffer_t *buf, const struct halide_device_interface_t *device_interface)
@ halide_target_feature_wasm_threads
Enable use of threads in WebAssembly codegen. Requires the use of a wasm runtime that provides pthrea...
#define HALIDE_ATTRIBUTE_ALIGN(x)
@ halide_target_feature_spirv
Enable SPIR-V code generation support.
halide_trace_t halide_set_custom_trace(halide_trace_t trace)
int current_func
The id of the current running Func.
Expr print(const std::vector< Expr > &values)
Create an Expr that prints out its value whenever it is evaluated.
@ halide_target_feature_profile
Launch a sampling profiler alongside the Halide pipeline that monitors and reports the runtime used b...
void halide_memoization_cache_cleanup()
Free all memory and resources associated with the memoization cache.
int(* halide_semaphore_init_t)(struct halide_semaphore_t *, int)
int halide_msan_check_memory_is_initialized(void *user_context, const void *ptr, uint64_t len, const char *name)
Verify that a given range of memory has been initialized; only used when Target::MSAN is enabled.
int halide_error_host_is_null(void *user_context, const char *func_name)
halide_can_use_target_features_t halide_set_custom_can_use_target_features(halide_can_use_target_features_t)
@ halide_target_feature_avx2
Use AVX 2 instructions. Only relevant on x86.
@ halide_target_feature_avx512
Enable the base AVX512 subset supported by all AVX512 architectures. The specific feature sets are AV...
void halide_mutex_array_destroy(void *user_context, void *array)
@ halide_error_code_device_buffer_copy_failed
The Halide runtime encountered an error while trying to copy from one buffer to another.
A struct representing a semaphore and a number of items that must be acquired from it.
uint64_t flags
flags with various meanings.
@ halide_target_feature_semihosting
Used together with Target::NoOS for the baremetal target built with semihosting library and run with ...
union halide_scalar_value_t::@4 u
bool halide_default_semaphore_try_acquire(struct halide_semaphore_t *, int n)
int halide_error_param_too_small_i64(void *user_context, const char *param_name, int64_t val, int64_t min_val)
@ halide_trace_end_realization
@ halide_error_code_buffer_is_null
The halide_buffer_t * passed to a halide runtime routine is nullptr and this is not allowed.
@ halide_target_feature_end
A sentinel. Every target is considered to have this feature, and setting this feature does nothing.
int halide_device_crop(void *user_context, const struct halide_buffer_t *src, struct halide_buffer_t *dst)
Give the destination buffer a device allocation which is an alias for the same coordinate range in th...
struct halide_thread * halide_spawn_thread(void(*f)(void *), void *closure)
Spawn a thread.
int halide_error_device_crop_failed(void *user_context)
int halide_msan_annotate_buffer_is_initialized(void *user_context, struct halide_buffer_t *buffer)
Mark the data pointed to by the halide_buffer_t as initialized (but not the halide_buffer_t itself),...
halide_type_code_t
Types in the halide type system.
@ halide_target_feature_avx512_skylake
Enable the AVX512 features supported by Skylake Xeon server processors. This adds AVX512-VL,...
int halide_buffer_copy(void *user_context, struct halide_buffer_t *src, const struct halide_device_interface_t *dst_device_interface, struct halide_buffer_t *dst)
Copy data from one buffer to another.
@ halide_error_code_host_is_null
The host field on an input or output was null, the device field was not zero, and the pipeline tries ...
@ halide_target_feature_vulkan_int64
Enable Vulkan 64-bit integer support.
void halide_profiler_reset()
Reset profiler state cheaply.
int halide_get_trace_file(void *user_context)
Halide calls this to retrieve the file descriptor to write binary trace events to.
@ halide_error_code_device_malloc_failed
The Halide runtime encountered an error while trying to allocate memory on device.
int halide_default_semaphore_release(struct halide_semaphore_t *, int n)
struct halide_profiler_state * halide_profiler_get_state()
Get a pointer to the global profiler state for programmatic inspection.
void *(* halide_get_library_symbol_t)(void *lib, const char *name)
@ halide_target_feature_strict_float
Turn off all non-IEEE floating-point optimization. Currently applies only to LLVM targets.
struct halide_semaphore_t * semaphore
@ halide_target_feature_wasm_simd128
Enable +simd128 instructions for WebAssembly codegen.
@ halide_target_feature_user_context
Generated code takes a user_context pointer as first argument.
int(* device_release_crop)(void *user_context, struct halide_buffer_t *buf)
struct halide_type_t type
int(* halide_do_loop_task_t)(void *, halide_loop_task_t, int, int, uint8_t *, void *)
The version of do_task called for loop tasks.
#define HALIDE_ALWAYS_INLINE
halide_error_code_t
The error codes that may be returned by a Halide pipeline.
@ halide_error_code_debug_to_file_failed
debug_to_file failed to open or write to the specified file.
@ halide_error_code_buffer_argument_is_null
A halide_buffer_t pointer passed in was NULL.
auto operator==(const Other &a, const GeneratorParam< T > &b) -> decltype(a==(T) b)
Equality comparison between GeneratorParam<T> and any type that supports operator== with T.
uint16_t lanes
How many elements in a vector.
@ halide_target_feature_jit
Generate code that will run immediately inside the calling process.
@ halide_target_feature_arm_fp16
Enable ARMv8.2-a half-precision floating point data processing.
@ halide_error_code_bad_extern_fold
A folded buffer was passed to an extern stage, but the region touched wraps around the fold boundary.
int halide_msan_check_buffer_is_initialized(void *user_context, struct halide_buffer_t *buffer, const char *buf_name)
Verify that the data pointed to by the halide_buffer_t is initialized (but not the halide_buffer_t it...
@ halide_error_code_access_out_of_bounds
A pipeline would access memory outside of the halide_buffer_t passed in.
halide_load_library_t halide_set_custom_load_library(halide_load_library_t user_load_library)
@ halide_argument_kind_input_scalar
int halide_error_buffer_is_null(void *user_context, const char *routine)
int(* release_unused)(void *user_context)
@ halide_error_code_device_interface_no_device
Buffer has a non-null device_interface but device is 0, which violates a Halide invariant.
@ halide_target_feature_no_asserts
Disable all runtime checks, for slightly tighter code.
@ halide_buffer_flag_device_dirty
signed __INT64_TYPE__ int64_t
@ halide_argument_kind_input_buffer
struct halide_dimension_t halide_dimension_t
@ halide_trace_end_produce
@ halide_target_feature_wasm_signext
Enable +sign-ext instructions for WebAssembly codegen.
The global state of the profiler.
@ halide_trace_end_consume
@ halide_type_uint
unsigned integers
@ halide_target_feature_no_neon
Avoid using NEON instructions. Only relevant for 32-bit ARM.
struct halide_buffer_t halide_buffer_t
The raw representation of an image passed around by generated Halide code.
@ halide_error_code_copy_to_host_failed
The Halide runtime encountered an error while trying to copy from device to host.
int halide_device_detach_native(void *user_context, struct halide_buffer_t *buf)
@ halide_target_feature_hvx_v66
Enable Hexagon v66 architecture.
void * halide_default_malloc(void *user_context, size_t x)
int(* halide_can_use_target_features_t)(int count, const uint64_t *features)
int halide_copy_to_device(void *user_context, struct halide_buffer_t *buf, const struct halide_device_interface_t *device_interface)
Copy image data from host memory to device memory.
uint8_t * host
A pointer to the start of the data in main memory.
@ halide_target_feature_power_arch_2_07
Use POWER ISA 2.07 new instructions. Only relevant on POWERPC.
const struct halide_scalar_value_t * min
int active_threads
The number of threads currently doing work.
int halide_error_param_too_small_u64(void *user_context, const char *param_name, uint64_t val, uint64_t min_val)
int halide_device_release_crop(void *user_context, struct halide_buffer_t *buf)
Release any resources associated with a cropped/sliced view of another buffer.
@ halide_target_feature_large_buffers
Enable 64-bit buffer indexing to support buffers > 2GB. Ignored if bits != 64.
Obsolete version of halide_filter_argument_t; only present in code that wrote halide_filter_metadata_...
@ halide_target_feature_opencl
Enable the OpenCL runtime.
void * padding
Pads the buffer up to a multiple of 8 bytes.
int halide_error_extern_stage_failed(void *user_context, const char *extern_stage_name, int result)
A call to an extern stage failed.
@ halide_error_code_device_free_failed
The Halide runtime encountered an error while trying to free a device allocation.
@ halide_target_feature_enable_llvm_loop_opt
Enable loop vectorization + unrolling in LLVM. Overrides halide_target_feature_disable_llvm_loop_opt....
@ halide_error_code_requirement_failed
User-specified require() expression was not satisfied.
@ halide_target_feature_cuda_capability61
Enable CUDA compute capability 6.1 (Pascal)
@ halide_target_feature_trace_pipeline
Trace the pipeline.
void halide_set_gpu_device(int n)
Selects which gpu device to use.
bool(* halide_semaphore_try_acquire_t)(struct halide_semaphore_t *, int)
@ halide_target_feature_cuda_capability75
Enable CUDA compute capability 7.5 (Turing)
int32_t halide_debug_to_file(void *user_context, const char *filename, int32_t type_code, struct halide_buffer_t *buf)
Called when debug_to_file is used inside Halide code.
void * halide_malloc(void *user_context, size_t x)
Halide calls these functions to allocate and free memory.
int halide_error_specialize_fail(void *user_context, const char *message)
int halide_error_out_of_memory(void *user_context)
void halide_profiler_shutdown()
Reset all profiler state.
struct halide_type_t type
The remaining fields are equivalent to those in halide_trace_event_t.
@ halide_target_feature_cuda_capability50
Enable CUDA compute capability 5.0 (Maxwell)
@ halide_target_feature_trace_realizations
Trace all realizations done by the pipeline. Equivalent to calling Func::trace_realizations on every ...
@ halide_target_feature_hvx_128
Enable HVX 128 byte mode.
void * halide_get_symbol(const char *name)
Halide calls these functions to interact with the underlying system runtime functions.
halide_get_library_symbol_t halide_set_custom_get_library_symbol(halide_get_library_symbol_t user_get_library_symbol)
void halide_enable_timer_interrupt()
halide_filter_argument_t is essentially a plain-C-struct equivalent to Halide::Argument; most user co...
@ halide_target_feature_cuda_capability86
Enable CUDA compute capability 8.6 (Ampere)
int halide_semaphore_init(struct halide_semaphore_t *, int n)
@ halide_target_feature_vulkan_int8
Enable Vulkan 8-bit integer support.
@ halide_error_code_bad_dimensions
The dimensions field of a halide_buffer_t does not match the dimensions of that ImageParam.
bool halide_semaphore_try_acquire(struct halide_semaphore_t *, int n)
@ halide_target_feature_webgpu
Enable the WebGPU runtime.
@ halide_target_feature_cuda_capability70
Enable CUDA compute capability 7.0 (Volta)
void * halide_load_library(const char *name)
int halide_semaphore_release(struct halide_semaphore_t *, int n)
@ halide_target_feature_cuda_capability35
Enable CUDA compute capability 3.5 (Kepler)
struct halide_semaphore_acquire_t * semaphores
int halide_can_use_target_features(int count, const uint64_t *features)
This function is called internally by Halide in some situations to determine if the current execution...
const struct halide_scalar_value_t * scalar_estimate
@ halide_target_feature_cuda_capability30
Enable CUDA compute capability 3.0 (Kepler)
@ halide_error_code_device_crop_unsupported
Attempted to make cropped/sliced alias of a buffer with a device field, but the device_interface does...
enum halide_trace_event_code_t event
The type of event.
int halide_get_gpu_device(void *user_context)
Halide calls this to get the desired halide gpu device setting.
struct halide_profiler_pipeline_stats * pipelines
A linked list of stats gathered for each pipeline.
@ halide_target_feature_vulkan_float16
Enable Vulkan 16-bit float support.
@ halide_target_feature_cl_atomic64
Enable 64-bit atomics operations on OpenCL targets.
@ halide_target_feature_debug
Turn on debug info and output for runtime code.
@ halide_error_code_param_too_small
A scalar parameter passed in was smaller than its minimum declared value.
void * halide_default_get_library_symbol(void *lib, const char *name)
int32_t dimensions
The length of the coordinates array.
@ halide_target_feature_wasm_bulk_memory
Enable +bulk-memory instructions for WebAssembly codegen.
void halide_join_thread(struct halide_thread *)
Join a thread.
int(* copy_to_host)(void *user_context, struct halide_buffer_t *buf)
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.
@ halide_error_code_no_device_interface
Buffer has a non-zero device but no device interface, which violates a Halide invariant.
@ halide_target_feature_avx
Use AVX 1 instructions. Only relevant on x86.
@ halide_target_feature_soft_float_abi
Enable soft float ABI. This only enables the soft float ABI calling convention, which does not necess...
@ halide_error_code_storage_bound_too_small
An explicit storage bound provided is too small to store all the values produced by the function.
const int64_t *const * buffer_estimates
@ halide_target_feature_cuda
Enable the CUDA runtime. Defaults to compute capability 2.0 (Fermi)
@ halide_target_feature_fuzz_float_stores
On every floating point store, set the last bit of the mantissa to zero. Pipelines for which the outp...
void(* halide_print_t)(void *, const char *)
halide_print_t halide_set_custom_print(halide_print_t print)
A parallel task to be passed to halide_do_parallel_tasks.
@ halide_target_feature_avx512_knl
Enable the AVX512 features supported by Knight's Landing chips, such as the Xeon Phi x200....
int halide_error_bounds_inference_call_failed(void *user_context, const char *extern_stage_name, int result)
Halide calls the functions below on various error conditions.
int halide_profiler_sample(struct halide_profiler_state *s, uint64_t *prev_t)
Collects profiling information.
The raw representation of an image passed around by generated Halide code.
int halide_do_parallel_tasks(void *user_context, int num_tasks, struct halide_parallel_task_t *tasks, void *task_parent)
Enqueue some number of the tasks described above and wait for them to complete.
int halide_error_bad_extern_fold(void *user_context, const char *func_name, int dim, int min, int extent, int valid_min, int fold_factor)
int halide_error_requirement_failed(void *user_context, const char *condition, const char *message)
@ halide_target_feature_cuda_capability80
Enable CUDA compute capability 8.0 (Ampere)
void halide_cond_broadcast(struct halide_cond *cond)
@ halide_target_feature_check_unsafe_promises
Insert assertions for promises.
void halide_default_error(void *user_context, const char *)
@ halide_target_feature_vulkan_version12
Enable Vulkan v1.2 runtime target support.
void *(* halide_malloc_t)(void *, size_t)
void * halide_default_load_library(const char *name)
int halide_error_fold_factor_too_small(void *user_context, const char *func_name, const char *var_name, int fold_factor, const char *loop_name, int required_extent)
@ halide_error_code_device_detach_native_failed
The Halide runtime encountered an error while trying to detach a native device handle.
int(* halide_semaphore_release_t)(struct halide_semaphore_t *, int)
A type traits template to provide a halide_handle_cplusplus_type value from a C++ type.
const struct halide_device_interface_impl_t * impl
@ halide_target_feature_vulkan_int16
Enable Vulkan 16-bit integer support.
int32_t value_index
If this was a load or store of a Tuple-valued Func, this is which tuple element was accessed.
int halide_error_param_too_large_u64(void *user_context, const char *param_name, uint64_t val, uint64_t max_val)
struct halide_mutex lock
Guards access to the fields below.
int32_t halide_trace(void *user_context, const struct halide_trace_event_t *event)
Called when Funcs are marked as trace_load, trace_store, or trace_realization.
void halide_print(void *user_context, const char *)
Print a message to stderr.
int halide_error_buffer_allocation_too_large(void *user_context, const char *buffer_name, uint64_t allocation_size, uint64_t max_size)
Each GPU API provides a halide_device_interface_t struct pointing to the code that manages device all...
@ halide_target_feature_avx512_cannonlake
Enable the AVX512 features expected to be supported by future Cannonlake processors....
@ halide_llvm_large_code_model
Use the LLVM large code model to compile.
float halide_float16_bits_to_float(uint16_t)
Read bits representing a half precision floating point number and return the float that represents th...
@ halide_target_feature_egl
Force use of EGL support.
@ halide_target_feature_trace_loads
Trace all loads done by the pipeline. Equivalent to calling Func::trace_loads on every non-inlined Fu...
@ halide_error_code_bad_type
The elem_size field of a halide_buffer_t does not match the size in bytes of the type of that ImagePa...
signed __INT16_TYPE__ int16_t
int halide_error_param_too_small_f64(void *user_context, const char *param_name, double val, double min_val)
void(* halide_free_t)(void *, void *)
@ halide_type_int
signed integers
An opaque struct representing a semaphore.
void halide_msan_annotate_buffer_is_initialized_as_destructor(void *user_context, void *buffer)
@ halide_error_code_buffer_extents_negative
At least one of the buffer's extents are negative.
halide_do_task_t halide_set_custom_do_task(halide_do_task_t do_task)
bool halide_can_reuse_device_allocations(void *user_context)
Determines whether on device_free the memory is returned immediately to the device API,...
struct halide_profiler_pipeline_stats * halide_profiler_get_pipeline_state(const char *pipeline_name)
Get a pointer to the pipeline state associated with pipeline_name.
int32_t(* halide_trace_t)(void *user_context, const struct halide_trace_event_t *)
int halide_default_can_use_target_features(int count, const uint64_t *features)
This is the default implementation of halide_can_use_target_features; it is provided for convenience ...
@ halide_target_feature_c_plus_plus_mangling
Generate C++ mangled names for result function, et al.
@ halide_target_feature_wasm_sat_float_to_int
Enable saturating (nontrapping) float-to-int instructions for WebAssembly codegen.
int halide_device_slice(void *user_context, const struct halide_buffer_t *src, int slice_dim, int slice_pos, struct halide_buffer_t *dst)
Give the destination buffer a device allocation which is an alias for a similar coordinate range in t...
@ halide_target_feature_sve2
Enable ARM Scalable Vector Extensions v2.
int(* buffer_copy)(void *user_context, struct halide_buffer_t *src, const struct halide_device_interface_t *dst_device_interface, struct halide_buffer_t *dst)
int halide_error_storage_bound_too_small(void *user_context, const char *func_name, const char *var_name, int provided_size, int required_size)
@ halide_target_feature_metal
Enable the (Apple) Metal runtime.
halide_error_handler_t halide_set_error_handler(halide_error_handler_t handler)
int halide_error_unaligned_host_ptr(void *user_context, const char *func_name, int alignment)
unsigned __INT32_TYPE__ uint32_t
@ halide_error_code_device_sync_failed
The Halide runtime encountered an error while trying to synchronize with a device.
@ halide_error_code_bad_fold
A fold_storage directive was used on a dimension that is not accessed in a monotonically increasing o...
void halide_shutdown_thread_pool()
@ halide_target_feature_hexagon_dma
Enable Hexagon DMA buffers.
halide_do_loop_task_t halide_set_custom_do_loop_task(halide_do_loop_task_t do_task)
int halide_error_buffer_extents_negative(void *user_context, const char *buffer_name, int dimension, int extent)
@ halide_target_feature_vsx
Use VSX instructions. Only relevant on POWERPC.
@ halide_target_feature_hvx_v62
Enable Hexagon v62 architecture.
void * halide_default_get_symbol(const char *name)
@ halide_buffer_flag_host_dirty
int halide_default_do_par_for(void *user_context, halide_task_t task, int min, int size, uint8_t *closure)
The default versions of the parallel runtime functions.
halide_do_par_for_t halide_set_custom_do_par_for(halide_do_par_for_t do_par_for)
@ halide_target_feature_fma4
Enable x86 (AMD) FMA4 instruction set.
@ halide_target_feature_vulkan_float64
Enable Vulkan 64-bit float support.
@ halide_target_feature_avx512_sapphirerapids
Enable the AVX512 features supported by Sapphire Rapids processors. This include all of the Cannonlak...
const struct halide_scalar_value_t * def
__PTRDIFF_TYPE__ ptrdiff_t
void halide_disable_timer_interrupt()
These routines are called to temporarily disable and then reenable timer interuppts for profiling.
uint32_t size
The total size of this packet in bytes.
const struct halide_device_interface_t * device_interface
The interface used to interpret the above handle.
@ halide_error_code_param_too_large
A scalar parameter passed in was greater than its minimum declared value.
int(* device_free)(void *user_context, struct halide_buffer_t *buf)
const struct halide_scalar_value_t * scalar_max
@ halide_error_code_symbol_not_found
A runtime symbol could not be loaded.
uint64_t device
A device-handle for e.g.
int halide_device_free(void *user_context, struct halide_buffer_t *buf)
Free device memory.
int halide_default_do_task(void *user_context, halide_task_t f, int idx, uint8_t *closure)
@ halide_target_feature_arm_dot_prod
Enable ARMv8.2-a dotprod extension (i.e. udot and sdot instructions)
void halide_register_device_allocation_pool(struct halide_device_allocation_pool *)
Register a callback to be informed when halide_reuse_device_allocations(false) is called,...
void halide_memoization_cache_evict(void *user_context, uint64_t eviction_key)
Evict all cache entries that were tagged with the given eviction_key in the memoize scheduling direct...
@ halide_error_code_incompatible_device_interface
An operation on a buffer required an allocation on a particular device interface, but a device alloca...
@ halide_target_feature_rvv
Enable RISCV "V" Vector Extension.
int halide_do_task(void *user_context, halide_task_t f, int idx, uint8_t *closure)
auto operator<(const Other &a, const GeneratorParam< T > &b) -> decltype(a<(T) b)
Less than comparison between GeneratorParam<T> and any type that supports operator< with T.
void halide_device_release(void *user_context, const struct halide_device_interface_t *device_interface)
Release all data associated with the given device interface, in particular all resources (memory,...
@ halide_error_code_buffer_allocation_too_large
A halide_buffer_t was given that spans more than 2GB of memory.
void * halide_get_library_symbol(void *lib, const char *name)
@ halide_error_code_device_dirty_with_no_device_support
A buffer with the device_dirty flag set was passed to a pipeline compiled with no device backends ena...
int halide_device_malloc(void *user_context, struct halide_buffer_t *buf, const struct halide_device_interface_t *device_interface)
Allocate device memory to back a halide_buffer_t.
@ halide_target_feature_f16c
Enable x86 16-bit float support.
@ halide_error_code_specialize_fail
A specialize_fail() schedule branch was selected at runtime.
const struct halide_scalar_value_t * scalar_def
struct halide_type_t type
If the event type is a load or a store, this is the type of the data.
int halide_error_access_out_of_bounds(void *user_context, const char *func_name, int dimension, int min_touched, int max_touched, int min_valid, int max_valid)
@ halide_target_feature_sanitizer_coverage
Enable hooks for SanitizerCoverage support.
uint8_t code
The basic type code: signed integer, unsigned integer, or floating point.
int halide_memoization_cache_store(void *user_context, const uint8_t *cache_key, int32_t size, struct halide_buffer_t *realized_bounds, int32_t tuple_count, struct halide_buffer_t **tuple_buffers, bool has_eviction_key, uint64_t eviction_key)
Given a cache key for a memoized result, currently constructed from the Func name and top-level Func ...
@ halide_trace_begin_pipeline