Halide 19.0.0
Halide compiler and libraries
Loading...
Searching...
No Matches
HalideRuntimeVulkan.h
Go to the documentation of this file.
1#ifndef HALIDE_HALIDERUNTIMEVULKAN_H
2#define HALIDE_HALIDERUNTIMEVULKAN_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/** \file
11 * Routines specific to the Halide Vulkan runtime.
12 */
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18#define HALIDE_RUNTIME_VULKAN
19
21
22/** These are forward declared here to allow clients to override the
23 * Halide Vulkan runtime. Do not call them. */
24// @{
25extern int halide_vulkan_initialize_kernels(void *user_context, void **state_ptr,
26 const char *src, int size);
27
28extern int halide_vulkan_run(void *user_context,
29 void *state_ptr,
30 const char *entry_name,
31 int blocksX, int blocksY, int blocksZ,
32 int threadsX, int threadsY, int threadsZ,
33 int shared_mem_bytes,
34 size_t arg_sizes[],
35 void *args[],
36 int8_t arg_is_buffer[]);
37
38extern void halide_vulkan_finalize_kernels(void *user_context, void *state_ptr);
39
40// @}
41
42// The default implementation of halide_acquire_vulkan_context uses
43// the global pointers above, and serializes access with a spin lock.
44// Overriding implementations of acquire/release must implement the
45// following behavior:
46
47// - halide_acquire_vulkan_context should always store a valid
48// instance/device/queue in the corresponding out parameters,
49// or return an error code.
50// - A call to halide_acquire_vulkan_context is followed by a matching
51// call to halide_release_vulkan_context. halide_acquire_vulkan_context
52// should block while a previous call (if any) has not yet been
53// released via halide_release_vulkan_context.
54// - Parameters:
55// allocator: an internal halide type handle used for allocating resources
56// instance: the vulkan instance handle
57// device: the vulkan device handle
58// physical_device: the vulkan physical device handle
59// command_pool: the vulkan command pool handle (strangely doesn't have a VkCommandPool_T typedef)
60// queue: the vulkan queue handle
61// queue_family_index: the index corresponding to the device queue properties for the device (as described by vkGetPhysicalDeviceQueueFamilyProperties)
62// create: if set to true, attempt to create a new vulkan context, otherwise acquire the current one
63struct halide_vulkan_memory_allocator;
64extern int halide_vulkan_acquire_context(void *user_context,
65 struct halide_vulkan_memory_allocator **allocator,
66 struct VkInstance_T **instance,
67 struct VkDevice_T **device,
68 struct VkPhysicalDevice_T **physical_device,
69 uint64_t *command_pool,
70 struct VkQueue_T **queue,
71 uint32_t *queue_family_index,
72 bool create = true);
73
74extern int halide_vulkan_release_context(void *user_context,
75 struct VkInstance_T *instance,
76 struct VkDevice_T *device,
77 struct VkQueue_T *queue);
78
79// --
80
81// Override the default allocation callbacks (default uses Vulkan runtime implementation)
83
84// Access the current allocation callbacks
85// -- may return nullptr ... which indicates the default Vulkan runtime implementation is being used)
86extern const struct VkAllocationCallbacks *halide_vulkan_get_allocation_callbacks(void *user_context);
87
88// Access methods to assign/retrieve required layer names for the context
89extern void halide_vulkan_set_layer_names(const char *n);
90extern const char *halide_vulkan_get_layer_names(void *user_context);
91
92// Access methods to assign/retrieve required externsion names for the context
93extern void halide_vulkan_set_extension_names(const char *n);
94extern const char *halide_vulkan_get_extension_names(void *user_context);
95
96// Access methods to assign/retrieve required device type names for the context (either "cpu", "gpu" (any), "discrete-gpu" (only), "virtual-gpu" (sw))
97extern void halide_vulkan_set_device_type(const char *n);
98extern const char *halide_vulkan_get_device_type(void *user_context);
99
100// Access methods to assign/retrieve specific build options to the Vulkan runtime compiler
101extern void halide_vulkan_set_build_options(const char *n);
102extern const char *halide_vulkan_get_build_options(void *user_context);
103
104#ifdef __cplusplus
105} // End extern "C"
106#endif
107
108#endif // HALIDE_HALIDERUNTIMEVULKAN_H
This file declares the routines used by Halide internally in its runtime.
const char * halide_vulkan_get_layer_names(void *user_context)
int halide_vulkan_initialize_kernels(void *user_context, void **state_ptr, const char *src, int size)
These are forward declared here to allow clients to override the Halide Vulkan runtime.
void halide_vulkan_set_extension_names(const char *n)
const struct VkAllocationCallbacks * halide_vulkan_get_allocation_callbacks(void *user_context)
void halide_vulkan_set_build_options(const char *n)
int halide_vulkan_acquire_context(void *user_context, struct halide_vulkan_memory_allocator **allocator, struct VkInstance_T **instance, struct VkDevice_T **device, struct VkPhysicalDevice_T **physical_device, uint64_t *command_pool, struct VkQueue_T **queue, uint32_t *queue_family_index, bool create=true)
void halide_vulkan_set_layer_names(const char *n)
void halide_vulkan_set_device_type(const char *n)
const char * halide_vulkan_get_extension_names(void *user_context)
const char * halide_vulkan_get_device_type(void *user_context)
int halide_vulkan_run(void *user_context, void *state_ptr, const char *entry_name, int blocksX, int blocksY, int blocksZ, int threadsX, int threadsY, int threadsZ, int shared_mem_bytes, size_t arg_sizes[], void *args[], int8_t arg_is_buffer[])
const struct halide_device_interface_t * halide_vulkan_device_interface()
void halide_vulkan_finalize_kernels(void *user_context, void *state_ptr)
void halide_vulkan_set_allocation_callbacks(const struct VkAllocationCallbacks *callbacks)
const char * halide_vulkan_get_build_options(void *user_context)
int halide_vulkan_release_context(void *user_context, struct VkInstance_T *instance, struct VkDevice_T *device, struct VkQueue_T *queue)
unsigned __INT64_TYPE__ uint64_t
unsigned __INT32_TYPE__ uint32_t
signed __INT8_TYPE__ int8_t
Each GPU API provides a halide_device_interface_t struct pointing to the code that manages device all...