CUDA 纹理和夹紧
有什么方法可以将超出范围的纹理地址限制为某个值吗?就我而言,我希望将它们设置为简单的零,但我需要的地址模式似乎不存在。
谢谢。
编辑:知道 cudaAddressModeBorder 设置的作用吗?
Is there any way to clamp out of range texture addresses to a certain value? In my case, I want them to be set to a simple zero, but the address mode I need doesn't seem to exist.
Thanks.
Edit: Any idea what the cudaAddressModeBorder
setting does?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不认为有办法指定钳位,但您可以做明显的事情并在边缘周围添加 1 像素黑色(零)边框并将您的寻址偏移 1。它不应该有更多的数据,它会免费为您提供夹具。
如果您有最大尺寸的 2D 纹理(对于 CUDA 2.x,它是 64k x 64k),每像素 16 字节(最坏情况),那么您只需要为 1 像素边界查看 4 MB 的额外数据,而对于 PCIe x16 卡将需要大约 500 微秒才能复制到卡上——即使在最坏的情况下也几乎没有什么。
I don't think there's a way to specify the clamp but you can do the obvious and add a 1 pixel black (zero) border around the edge and offset your addressing by 1. It shouldn't be much more data and it'll get you the clamping for free.
If you have a maximum size 2D texture (for CUDA 2.x it is 64k x 64k) with 16 bytes per pixel (worst case) then you're looking at only 4 MB of extra data for the 1 pixel border which for a PCIe x16 card will take about 500 microseconds to copy to the card--hardly anything even in the worst case.
您可以将边界模式设置为在使用 Surface 函数访问纹理时返回零。我现在无法测试它,因为您需要计算能力 2.0+ 的设备,但您可以查看 NVIDIA CUDA C 编程指南(版本 3.2)第 B.9 节第 114 页中的参考。
我们还可以限制边界并捕获它(使内核失败),这是使用表面内存时的默认值。
问候!
You can set the boundary mode to return zero when accessing to textures using Surface functions. I can not test it right now as you need a device of compute capability 2.0+ but you can check the reference in the NVIDIA CUDA C Programming Guide (version 3.2), Section B.9 p.114.
We can also clamp the boundary and trap it (make kernel fail) what is the default when using the surface memory.
Regards!