Halide::Buffer on GPU

Deadly 提交于 2019-12-24 21:48:37

问题


I already have an application that takes input images, copies them to GPU, and then some CUDA filters are applied to that image. So, when I want to implement a new filter, I only write the filter itself (ie. kernel), since the CPU-GPU copying logic is already there.

Now I want to try out Halide for writing image filters for CUDA, and I encounter a problem that Halide::Buffer, which represents input image, is allocated on CPU, so I would have to change my existing copying logic.

Is there any way to initialize Halide::Buffer with data that is already on the GPU, and to avoid additional copying.


回答1:


Yes, you can construct a buffer with no host allocation of the correct size with the Halide::Buffer(nullptr, ... sizes ...) constructor, and then call Buffer::device_wrap_native to associate the cuda pointer with it.



来源:https://stackoverflow.com/questions/50822087/halidebuffer-on-gpu

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!