Halide :: GPU上的缓冲区 [英] Halide::Buffer on GPU

查看:274
本文介绍了Halide :: GPU上的缓冲区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经有一个应用程序来获取输入图像,将其复制到GPU,然后将某些CUDA过滤器应用于该图像.因此,当我想实现一个新的过滤器时,我只编写过滤器本身(即内核),因为CPU-GPU复制逻辑已经存在.

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.

现在,我想尝试使用Halide为CUDA编写图像过滤器,并且遇到一个问题,即代表输入图像的Halide :: Buffer在CPU上分配了,因此我必须更改现有的复制逻辑.

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.

有什么方法可以使用GPU上已经存在的数据初始化Halide :: Buffer,并避免其他复制.

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

推荐答案

是的,您可以使用Halide :: Buffer(nullptr,... Size ...)构造函数构造一个没有正确大小的主机分配的缓冲区,然后调用Buffer :: device_wrap_native将cuda指针与其关联.

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.

这篇关于Halide :: GPU上的缓冲区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆