Halide 19.0.0
Halide compiler and libraries
Loading...
Searching...
No Matches
HalideRuntimeHexagonHost.h
Go to the documentation of this file.
1#ifndef HALIDE_HALIDERUNTIMEHEXAGONHOST_H
2#define HALIDE_HALIDERUNTIMEHEXAGONHOST_H
3
4// Don't include HalideRuntime.h if the contents of it were already pasted into a generated header above this one
5#ifndef HALIDE_HALIDERUNTIME_H
6
7#include "HalideRuntime.h"
8
9#endif
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
15/** \file
16 * Routines specific to the Halide Hexagon host-side runtime.
17 */
18
19#define HALIDE_RUNTIME_HEXAGON
20
22
24
25/** Check if the Hexagon runtime (libhalide_hexagon_host.so) is
26 * available. If it is not, pipelines using Hexagon will fail. */
27extern bool halide_is_hexagon_available(void *user_context);
28
29/** The device handle for Hexagon is simply a pointer and size, stored
30 * in the dev field of the halide_buffer_t. If the buffer is allocated in a
31 * particular way (ion_alloc), the buffer will be shared with Hexagon
32 * (not copied). The device field of the halide_buffer_t must be NULL when this
33 * routine is called. This call can fail due to running out of memory
34 * or being passed an invalid device handle. The device and host
35 * dirty bits are left unmodified. */
36extern int halide_hexagon_wrap_device_handle(void *user_context, struct halide_buffer_t *buf,
37 void *ptr, uint64_t size);
38
39/** Disconnect this halide_buffer_t from the device handle it was
40 * previously wrapped around. Should only be called for a
41 * halide_buffer_t that halide_hexagon_wrap_device_handle was
42 * previously called on. Frees any storage associated with the binding
43 * of the halide_buffer_t and the device handle, but does not free the
44 * device handle. The device field of the halide_buffer_t will be NULL
45 * on return. */
46extern int halide_hexagon_detach_device_handle(void *user_context, struct halide_buffer_t *buf);
47
48/** Return the underlying device handle for a halide_buffer_t. If there is
49 * no device memory (dev field is NULL), this returns 0. */
50extern void *halide_hexagon_get_device_handle(void *user_context, struct halide_buffer_t *buf);
51extern uint64_t halide_hexagon_get_device_size(void *user_context, struct halide_buffer_t *buf);
52
53/** Return a pointer to the module_state. */
54extern void *halide_hexagon_get_module_state(void *user_context, void **host);
55
56/** Power HVX on and off. Calling a Halide pipeline will do this
57 * automatically on each pipeline invocation; however, it costs a
58 * small but possibly significant amount of time for short running
59 * pipelines. To avoid this cost, HVX can be powered on prior to
60 * running several pipelines, and powered off afterwards. If HVX is
61 * powered on, subsequent calls to power HVX on will be cheap. */
62// @{
63extern int halide_hexagon_power_hvx_on(void *user_context);
64extern int halide_hexagon_power_hvx_off(void *user_context);
65extern void halide_hexagon_power_hvx_off_as_destructor(void *user_context, void * /* obj */);
66// @}
67
68/** Power modes for Hexagon. */
84
85/** More detailed power settings to control Hexagon.
86 * @param set_mips - Set to TRUE to request MIPS
87 * @param mipsPerThread - mips requested per thread, to establish a minimal clock frequency per HW thread
88 * @param mipsTotal - Total mips requested, to establish total number of MIPS required across all HW threads
89 * @param set_bus_bw - Set to TRUE to request bus_bw
90 * @param bwMeagabytesPerSec - Max bus BW requested (megabytes per second)
91 * @param busbwUsagePercentage - Percentage of time during which bwBytesPerSec BW is required from the bus (0..100)
92 * @param set_latency - Set to TRUE to set latency
93 * @param latency - maximum hardware wakeup latency in microseconds. The
94 * higher the value the deeper state of sleep
95 * that can be entered but the longer it may
96 * take to awaken. Only values > 0 are supported (1 microsecond is the smallest valid value)
97 */
98typedef struct {
100 unsigned int mipsPerThread;
101 unsigned int mipsTotal;
103 unsigned int bwMegabytesPerSec;
104 unsigned short busbwUsagePercentage;
108
109// This is deprecated.
111
112/** Set a performance target for Hexagon. Hexagon applications can
113 * vote for the performance levels they want, which may or may not be
114 * respected by Hexagon. Applications should be careful not to leave
115 * Hexagon in a high power state for too long. These functions can
116 * significantly increase standby power consumption. Use
117 * halide_hexagon_power_default to reset performance to the default
118 * power state. */
119// @{
121extern int halide_hexagon_set_performance(void *user_context, halide_hexagon_power_t *perf);
122// @}
123
124/** Set the default priority for Halide Hexagon user threads:
125 * - Valid priority values range from 1 to 255
126 * - Smaller number for higher priority
127 * - The highest priority for a user thread is 1
128 * - Priority 0 is reserved for OS usage
129 * If this routine is not called, the priority will default to 100.
130 * This is intended to be called before dispatching any pipeline. */
131// @{
132extern int halide_hexagon_set_thread_priority(void *user_context, int priority);
133// @}
134
135/** These are forward declared here to allow clients to override the
136 * Halide Hexagon runtime. Do not call them. */
137// @{
138extern int halide_hexagon_initialize_kernels(void *user_context,
139 void **module_ptr,
140 const uint8_t *code, uint64_t code_size,
141 const uint8_t *runtime, uint64_t runtime_size);
142extern int halide_hexagon_run(void *user_context,
143 void *module_ptr,
144 const char *name,
145 halide_hexagon_handle_t *function,
146 uint64_t arg_sizes[],
147 void *args[],
148 int arg_flags[]);
149extern void halide_hexagon_finalize_kernels(void *user_context, void *state_ptr);
150extern int halide_hexagon_device_release(void *user_context);
151// @}
152
153#ifdef __cplusplus
154} // End extern "C"
155#endif
156
157#endif // HALIDE_HALIDERUNTIMEHEXAGONHOST_H
This file declares the routines used by Halide internally in its runtime.
const struct halide_device_interface_t * halide_hexagon_device_interface()
int halide_hexagon_run(void *user_context, void *module_ptr, const char *name, halide_hexagon_handle_t *function, uint64_t arg_sizes[], void *args[], int arg_flags[])
int halide_hexagon_device_release(void *user_context)
int halide_hexagon_wrap_device_handle(void *user_context, struct halide_buffer_t *buf, void *ptr, uint64_t size)
The device handle for Hexagon is simply a pointer and size, stored in the dev field of the halide_buf...
int halide_hexagon_handle_t
void halide_hexagon_power_hvx_off_as_destructor(void *user_context, void *)
uint64_t halide_hexagon_get_device_size(void *user_context, struct halide_buffer_t *buf)
int halide_hexagon_power_hvx_off(void *user_context)
bool halide_is_hexagon_available(void *user_context)
Check if the Hexagon runtime (libhalide_hexagon_host.so) is available.
halide_hexagon_power_t halide_hvx_power_perf_t
int halide_hexagon_detach_device_handle(void *user_context, struct halide_buffer_t *buf)
Disconnect this halide_buffer_t from the device handle it was previously wrapped around.
halide_hexagon_power_mode_t
Power modes for Hexagon.
@ halide_hvx_power_default
@ halide_hexagon_power_nominal_plus
@ halide_hexagon_power_low_2
@ halide_hexagon_power_turbo
@ halide_hvx_power_low
@ halide_hvx_power_turbo
@ halide_hexagon_power_low_plus
Resets power to its default state.
@ halide_hexagon_power_nominal
@ halide_hexagon_power_low
@ halide_hexagon_power_default
@ halide_hvx_power_nominal
int halide_hexagon_power_hvx_on(void *user_context)
Power HVX on and off.
int halide_hexagon_set_thread_priority(void *user_context, int priority)
Set the default priority for Halide Hexagon user threads:
int halide_hexagon_set_performance(void *user_context, halide_hexagon_power_t *perf)
void halide_hexagon_finalize_kernels(void *user_context, void *state_ptr)
int halide_hexagon_initialize_kernels(void *user_context, void **module_ptr, const uint8_t *code, uint64_t code_size, const uint8_t *runtime, uint64_t runtime_size)
These are forward declared here to allow clients to override the Halide Hexagon runtime.
int halide_hexagon_set_performance_mode(void *user_context, halide_hexagon_power_mode_t mode)
Set a performance target for Hexagon.
void * halide_hexagon_get_device_handle(void *user_context, struct halide_buffer_t *buf)
Return the underlying device handle for a halide_buffer_t.
void * halide_hexagon_get_module_state(void *user_context, void **host)
Return a pointer to the module_state.
unsigned __INT64_TYPE__ uint64_t
unsigned __INT8_TYPE__ uint8_t
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...
More detailed power settings to control Hexagon.