Halide 22.0.0 Halide compiler and libraries

HalideRuntimeD3D12Compute.h
Go to the documentation of this file.
1#ifndef HALIDE_HALIDERUNTIMED3D12COMPUTE_H
2#define HALIDE_HALIDERUNTIMED3D12COMPUTE_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 Direct3D 12 Compute runtime.
17 */
18
19 extern const struct halide_device_interface_t *halide_d3d12compute_device_interface();
20
21/** These are forward declared here to allow clients to override the
22 * Halide Direct3D 12 Compute runtime. Do not call them. */
23// @{
24 extern int halide_d3d12compute_initialize_kernels(void *user_context, void **state_ptr,
25 const char *src, int size);
26
27 extern int halide_d3d12compute_run(void *user_context,
28 void *state_ptr,
29 const char *entry_name,
30 int blocksX, int blocksY, int blocksZ,
31 int threadsX, int threadsY, int threadsZ,
32 int shared_mem_bytes,
33 struct halide_type_t arg_types[], void *args[], int8_t arg_is_buffer[]);
34 extern void halide_d3d12compute_finalize_kernels(void *user_context, void *state_ptr);
35// @}
36
37/** Set the underlying ID3D12Resource for a halide_buffer_t. The memory backing
38 * the resource should be managed by the caller (via a default/device heap) and
39 * must be large enough to cover the extent of the halide_buffer_t. The device
40 * field of the halide_buffer_t must be NULL when this routine is called. This
41 * call can fail due to running out of memory or if an invalid D3D12 resource is
42 * passed. The device and host dirty bits are left unmodified. */
43 extern int halide_d3d12compute_wrap_buffer(void *user_context, struct halide_buffer_t *buf, uint64_t d3d12_resource);
44
45/** Disconnect a halide_buffer_t from the ID3D12Resource it was previously
46 * wrapped around. Should only be called for a halide_buffer_t that
47 * halide_d3d12compute_wrap_buffer was previously called on. Frees any
48 * storage associated with the binding of the halide_buffer_t and the
49 * buffer, but does not free the ID3D12Resource. The dev field of the
50 * halide_buffer_t will be NULL on return.
51 */
52 extern int halide_d3d12compute_detach_buffer(void *user_context, struct halide_buffer_t *buf);
53
54/** Return the underlying ID3D12Resource for a halide_buffer_t. This resource
55 * must be valid on an D3D12 device, unless halide_buffer_t has no associated
56 * resource. If there is no device memory (device field is NULL), returns 0.
57 */
58 extern uintptr_t halide_d3d12compute_get_buffer(void *user_context, struct halide_buffer_t *buf);
59
60struct halide_d3d12compute_device;
61struct halide_d3d12compute_command_queue;
62
63/** This prototype is exported as applications will typically need to
64 * replace it to get Halide filters to execute on the same device and
65 * command queue used for other purposes. The halide_d3d12compute_device is an
66 * ID3D12Device and halide_d3d12compute_command_queue is an ID3D12CommandQueue.
67 * No reference counting is done by Halide on these objects. They must remain
68 * valid until all off the following are true:
69 * - A balancing halide_d3d12compute_release_context has occurred for each
70 * halide_d3d12compute_acquire_context which returned the device/queue
71 * - All Halide filters using the context information have completed
72 * - All halide_buffer_t objects on the device have had
73 * halide_device_free called or have been detached via
74 * halide_d3d12compute_detach_buffer.
75 * - halide_device_release has been called on the interface returned from
76 * halide_d3d12compute_device_interface(). (This releases the programs on the context.)
77 */
78 extern int halide_d3d12compute_acquire_context(void *user_context, struct halide_d3d12compute_device **device_ret,
79 struct halide_d3d12compute_command_queue **queue_ret, bool create);
80
81/** This call balances each successful halide_d3d12compute_acquire_context call.
82 * If halide_d3d12compute_acquire_context is replaced, this routine must be replaced
83 * as well.
84 */
85 extern int halide_d3d12compute_release_context(void *user_context);
86
87#ifdef __cplusplus
88} // End extern "C"
89#endif
90
91#endif // HALIDE_HALIDERUNTIMED3D12COMPUTE_H
HalideRuntime.h
This file declares the routines used by Halide internally in its runtime.
halide_d3d12compute_acquire_context
int halide_d3d12compute_acquire_context(void *user_context, struct halide_d3d12compute_device **device_ret, struct halide_d3d12compute_command_queue **queue_ret, bool create)
This prototype is exported as applications will typically need to replace it to get Halide filters to...
halide_d3d12compute_run
int halide_d3d12compute_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, struct halide_type_t arg_types[], void *args[], int8_t arg_is_buffer[])
halide_d3d12compute_device_interface
const struct halide_device_interface_t * halide_d3d12compute_device_interface()
halide_d3d12compute_get_buffer
uintptr_t halide_d3d12compute_get_buffer(void *user_context, struct halide_buffer_t *buf)
Return the underlying ID3D12Resource for a halide_buffer_t.
halide_d3d12compute_detach_buffer
int halide_d3d12compute_detach_buffer(void *user_context, struct halide_buffer_t *buf)
Disconnect a halide_buffer_t from the ID3D12Resource it was previously wrapped around.
halide_d3d12compute_finalize_kernels
void halide_d3d12compute_finalize_kernels(void *user_context, void *state_ptr)
halide_d3d12compute_wrap_buffer
int halide_d3d12compute_wrap_buffer(void *user_context, struct halide_buffer_t *buf, uint64_t d3d12_resource)
Set the underlying ID3D12Resource for a halide_buffer_t.
halide_d3d12compute_initialize_kernels
int halide_d3d12compute_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 Direct3D 12 Compute runtime.
halide_d3d12compute_release_context
int halide_d3d12compute_release_context(void *user_context)
This call balances each successful halide_d3d12compute_acquire_context call.
uint64_t
unsigned __INT64_TYPE__ uint64_t
Definition: runtime_internal.h:23
uintptr_t
__UINTPTR_TYPE__ uintptr_t
Definition: runtime_internal.h:75
int8_t
signed __INT8_TYPE__ int8_t
Definition: runtime_internal.h:28
halide_buffer_t
The raw representation of an image passed around by generated Halide code.
Definition: HalideRuntime.h:1569
halide_device_interface_t
Each GPU API provides a halide_device_interface_t struct pointing to the code that manages device all...
Definition: HalideRuntime.h:797
halide_type_t
A runtime tag for a type in the halide type system.
Definition: HalideRuntime.h:503
user_context
void * user_context
Definition: vulkan_resources.h:178