您的位置:首页 > 其它

CUDA:纹理内存及其使用

2017-12-23 19:42 573 查看
本博客参考资料来源如下:

http://cuda-programming.blogspot.com/2013/02/texture-memory-in-cuda-what-is-texture.html

http://blog.csdn.net/ai_vivi/article/details/42235787

http://blog.csdn.net/traceorigin/article/details/9213453

https://devtalk.nvidia.com/default/topic/489304/size-of-constant-cache-and-texture-cache/

https://devtalk.nvidia.com/default/topic/805057/cuda-programming-and-performance/cudabindtexture2d-showing-error-

http://blog.csdn.net/yh880/article/details/50715844

https://stackoverflow.com/questions/22083499/constant-cache-vs-texture-cache-for-broadcasting-behaviour-in-cuda

http://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#features-and-technical-specifications__technical-specifications-per-compute-capability

http://bbs.csdn.net/topics/390806590

http://bbs.csdn.net/topics/390818003

Texture Memory

首先简单介绍一下什么是Texture Memory。从硬件角度来说,纹理内存实际上是存储在Global Memory上;唯一的区别是,当某一个变量绑定纹理内存后,在程序运行过程中会将部分信息存储在Texture Cache中,以减少线程块对Global Memory的读取,进而提高程序的运行速度。在《CUDA By Example》中的一个图片生动的描述了Texture Memory的运行模式。



关于使用Texture Memory的好处,我已经在CUDA性能测试中做了比较详细的测试,此处就不详细介绍。

Texture Cache

在使用Texture Memory时,有一个比较重要的事情就是Texture Cache到底有多大内存。在查阅了一些CUDA的官方文档后,得到了以下两个表,放在下边以便再次查询。在知道了本电脑CUDA框架和版本之后,即可查阅知道Texture Cache的大小。



Texture Demo

纹理内存有一维纹理内存和二维纹理内存两种,在CUDA性能测试中提到,代码链接如下:

https://github.com/Yannnnnnnnnnnn/cpu_cuda_compare/blob/master/cuda_texture.cu

https://github.com/Yannnnnnnnnnnn/cpu_cuda_compare/blob/master/cuda_texture_2d.cu

代码中包括一维纹理和二维纹理。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  cuda