3 #include "scanner/api/kernel.h" 4 #include "scanner/util/common.h" 6 #include "HalideRuntime.h" 9 #include "HalideRuntimeCuda.h" 10 #include "scanner/util/halide_context.h" 15 void setup_halide_frame_buf(buffer_t& halide_buf, FrameInfo& frame_info) {
17 halide_buf.stride[0] = 3;
18 halide_buf.stride[1] = frame_info.width() * 3;
19 halide_buf.stride[2] = 1;
20 halide_buf.extent[0] = frame_info.width();
21 halide_buf.extent[1] = frame_info.height();
22 halide_buf.extent[2] = 3;
23 halide_buf.elem_size = 1;
26 void set_halide_buf_ptr(
const DeviceHandle& device, buffer_t& halide_buf,
27 u8* buf,
size_t size) {
28 if (device.type == DeviceType::GPU) {
30 halide_buf.dev = (uintptr_t)
nullptr;
34 halide_buf.dev_dirty =
true;
37 halide_cuda_wrap_device_ptr(
nullptr, &halide_buf, (uintptr_t)buf);
38 LOG_IF(FATAL, err != 0) <<
"Halide wrap device ptr failed";
43 halide_buf.host = (u8*)0xdeadbeef;
46 halide_buf.host = buf;
50 void unset_halide_buf_ptr(
const DeviceHandle& device, buffer_t& halide_buf) {
51 if (device.type == DeviceType::GPU) {
52 CUDA_PROTECT({ halide_cuda_detach_device_ptr(
nullptr, &halide_buf); });
Definition: database.cpp:36