Halide
device_interface.h
Go to the documentation of this file.
1 #ifndef HALIDE_RUNTIME_DEVICE_INTERFACE_H
2 #define HALIDE_RUNTIME_DEVICE_INTERFACE_H
3 
4 #include "HalideRuntime.h"
5 
6 extern "C" {
7 
9  // These next two methods are used to reference count the runtime code
10  // these function pointers point to. They should always be initialized
11  // to halide_use_jit_module and halide_release_jit_module and Halide's JIT
12  // arranges for this to reference count the container for the code. In AOT
13  // compilation, these are empty functions which do nothing.
14  void (*use_module)();
15  void (*release_module)();
16  int (*device_malloc)(void *user_context, struct halide_buffer_t *buf);
17  int (*device_free)(void *user_context, struct halide_buffer_t *buf);
18  int (*device_sync)(void *user_context, struct halide_buffer_t *buf);
19  int (*device_release)(void *user_context);
20  int (*copy_to_host)(void *user_context, struct halide_buffer_t *buf);
21  int (*copy_to_device)(void *user_context, struct halide_buffer_t *buf);
22  int (*device_and_host_malloc)(void *user_context, struct halide_buffer_t *buf);
23  int (*device_and_host_free)(void *user_context, struct halide_buffer_t *buf);
24  int (*buffer_copy)(void *user_context, struct halide_buffer_t *src,
25  const struct halide_device_interface_t *dst_device_interface, struct halide_buffer_t *dst);
26  int (*device_crop)(void *user_context,
27  const struct halide_buffer_t *src,
28  struct halide_buffer_t *dst);
29  int (*device_slice)(void *user_context,
30  const struct halide_buffer_t *src,
31  int slice_dim, int slice_pos,
32  struct halide_buffer_t *dst);
33  int (*device_release_crop)(void *user_context,
34  struct halide_buffer_t *buf);
35  int (*wrap_native)(void *user_context, struct halide_buffer_t *buf, uint64_t handle);
36  int (*detach_native)(void *user_context, struct halide_buffer_t *buf);
37 };
38 
39 extern WEAK int halide_default_device_and_host_malloc(void *user_context, struct halide_buffer_t *buf,
41 extern WEAK int halide_default_device_and_host_free(void *user_context, struct halide_buffer_t *buf,
43 extern WEAK int halide_default_buffer_copy(void *user_context, struct halide_buffer_t *src,
44  const struct halide_device_interface_t *dst_device_interface,
45  struct halide_buffer_t *dst);
46 extern WEAK int halide_default_device_crop(void *user_context, const struct halide_buffer_t *src,
47  struct halide_buffer_t *dst);
48 extern WEAK int halide_default_device_slice(void *user_context, const struct halide_buffer_t *src,
49  int slice_dim, int slice_pos, struct halide_buffer_t *dst);
50 extern WEAK int halide_default_device_release_crop(void *user_context, struct halide_buffer_t *buf);
51 extern WEAK int halide_default_device_wrap_native(void *user_context, struct halide_buffer_t *buf, uint64_t handle);
52 extern WEAK int halide_default_device_detach_native(void *user_context, struct halide_buffer_t *buf);
53 }
54 
55 #endif // HALIDE_RUNTIME_DEVICE_INTERFACE_H
halide_device_interface_impl_t::device_malloc
int(* device_malloc)(void *user_context, struct halide_buffer_t *buf)
Definition: device_interface.h:16
halide_device_interface_impl_t::device_free
int(* device_free)(void *user_context, struct halide_buffer_t *buf)
Definition: device_interface.h:17
halide_default_device_crop
WEAK int halide_default_device_crop(void *user_context, const struct halide_buffer_t *src, struct halide_buffer_t *dst)
halide_device_interface_impl_t::copy_to_device
int(* copy_to_device)(void *user_context, struct halide_buffer_t *buf)
Definition: device_interface.h:21
halide_default_device_and_host_free
WEAK int halide_default_device_and_host_free(void *user_context, struct halide_buffer_t *buf, const struct halide_device_interface_t *device_interface)
uint64_t
unsigned __INT64_TYPE__ uint64_t
Definition: runtime_internal.h:23
halide_device_interface_impl_t::device_crop
int(* device_crop)(void *user_context, const struct halide_buffer_t *src, struct halide_buffer_t *dst)
Definition: device_interface.h:26
halide_device_interface_impl_t::buffer_copy
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)
Definition: device_interface.h:24
halide_default_buffer_copy
WEAK int halide_default_buffer_copy(void *user_context, struct halide_buffer_t *src, const struct halide_device_interface_t *dst_device_interface, struct halide_buffer_t *dst)
halide_device_interface_impl_t::release_module
void(* release_module)()
Definition: device_interface.h:15
halide_device_interface_impl_t::device_slice
int(* device_slice)(void *user_context, const struct halide_buffer_t *src, int slice_dim, int slice_pos, struct halide_buffer_t *dst)
Definition: device_interface.h:29
halide_device_interface_impl_t::device_release_crop
int(* device_release_crop)(void *user_context, struct halide_buffer_t *buf)
Definition: device_interface.h:33
halide_device_interface_impl_t::detach_native
int(* detach_native)(void *user_context, struct halide_buffer_t *buf)
Definition: device_interface.h:36
halide_device_interface_impl_t
Definition: device_interface.h:8
halide_default_device_detach_native
WEAK int halide_default_device_detach_native(void *user_context, struct halide_buffer_t *buf)
halide_default_device_and_host_malloc
WEAK int halide_default_device_and_host_malloc(void *user_context, struct halide_buffer_t *buf, const struct halide_device_interface_t *device_interface)
halide_device_interface_impl_t::device_sync
int(* device_sync)(void *user_context, struct halide_buffer_t *buf)
Definition: device_interface.h:18
halide_device_interface_impl_t::device_release
int(* device_release)(void *user_context)
Definition: device_interface.h:19
halide_device_interface_impl_t::wrap_native
int(* wrap_native)(void *user_context, struct halide_buffer_t *buf, uint64_t handle)
Definition: device_interface.h:35
halide_device_interface_impl_t::device_and_host_free
int(* device_and_host_free)(void *user_context, struct halide_buffer_t *buf)
Definition: device_interface.h:23
HalideRuntime.h
halide_buffer_t
The raw representation of an image passed around by generated Halide code.
Definition: HalideRuntime.h:1490
halide_default_device_slice
WEAK int halide_default_device_slice(void *user_context, const struct halide_buffer_t *src, int slice_dim, int slice_pos, struct halide_buffer_t *dst)
halide_device_interface_impl_t::device_and_host_malloc
int(* device_and_host_malloc)(void *user_context, struct halide_buffer_t *buf)
Definition: device_interface.h:22
halide_device_interface_impl_t::copy_to_host
int(* copy_to_host)(void *user_context, struct halide_buffer_t *buf)
Definition: device_interface.h:20
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:770
halide_device_interface_impl_t::use_module
void(* use_module)()
Definition: device_interface.h:14
halide_default_device_release_crop
WEAK int halide_default_device_release_crop(void *user_context, struct halide_buffer_t *buf)
WEAK
#define WEAK
Definition: runtime_internal.h:52
halide_default_device_wrap_native
WEAK int halide_default_device_wrap_native(void *user_context, struct halide_buffer_t *buf, uint64_t handle)
halide_buffer_t::device_interface
const struct halide_device_interface_t * device_interface
The interface used to interpret the above handle.
Definition: HalideRuntime.h:1495