Go to the documentation of this file. 1 #ifndef HALIDE_RUNTIME_DEVICE_BUFFER_UTILS_H
2 #define HALIDE_RUNTIME_DEVICE_BUFFER_UTILS_H
32 #define MAX_COPY_DIMS 16
49 while (d >= 0 && copy.
extent[d] == 1) {
54 const void *from = (
void *)(copy.
src + src_off);
55 void *to = (
void *)(copy.
dst + dst_off);
68 if (copy.
src != copy.
dst) {
71 debug(user_context) <<
"copy_memory: no copy needed as pointers are the same.\n";
81 c.
dst = dst_host ? (
uint64_t)dst->host : dst->device;
97 src->
type.bytes() != dst->type.bytes() ||
115 for (
int i = 0; i < dst->dimensions; i++) {
117 uint64_t dst_stride_bytes = (
uint64_t)dst->dim[i].stride * dst->type.bytes();
121 for (insert = 0; insert < i; insert++) {
124 if (dst_stride_bytes < c.
dst_stride_bytes[insert] && dst_stride_bytes != 0) {
128 for (
int j = i; j > insert; j--) {
133 c.
extent[insert] = dst->dim[i].extent;
178 offset *= src->
type.bytes();
186 offset *= src->
type.bytes();
194 #endif // HALIDE_DEVICE_BUFFER_UTILS_H
WEAK device_copy make_buffer_copy(const halide_buffer_t *src, bool src_host, const halide_buffer_t *dst, bool dst_host)
WEAK void copy_memory(const device_copy ©, void *user_context)
halide_dimension_t * dim
The shape of the buffer.
uint64_t dst_stride_bytes[MAX_COPY_DIMS]
uint64_t src_stride_bytes[MAX_COPY_DIMS]
struct halide_type_t type
The type of each buffer element.
unsigned __INT64_TYPE__ uint64_t
uint64_t extent[MAX_COPY_DIMS]
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
int32_t dimensions
The dimensionality of the buffer.
@ Internal
Not visible externally, similar to 'static' linkage in C.
WEAK void copy_memory_helper(const device_copy ©, int d, int64_t src_off, int64_t dst_off)
signed __INT64_TYPE__ int64_t
ALWAYS_INLINE int64_t calc_device_slice_byte_offset(const struct halide_buffer_t *src, int slice_dim, int slice_pos)
uint8_t * host
A pointer to the start of the data in main memory.
WEAK device_copy make_device_to_host_copy(const halide_buffer_t *buf)
WEAK device_copy make_host_to_device_copy(const halide_buffer_t *buf)
void * memcpy(void *s1, const void *s2, size_t n)
The raw representation of an image passed around by generated Halide code.
ALWAYS_INLINE int64_t calc_device_crop_byte_offset(const struct halide_buffer_t *src, struct halide_buffer_t *dst)
uint64_t device
A device-handle for e.g.