问题描述
如何分配cuda纹理内存????有人可以帮我举个例子吗?
How to allocate cuda texture memory????can anyone help me with an example
推荐答案
texture<Type, Dim, ReadMode> Name
其中:
Type 是数据类型(float,int,...)
Dim 是尺寸1D,2D,3D的数量,仅表示为1、2或3的数量
ReadMode 是允许的访问. cudaReadModeNormalizedFloat
(在[0-1]范围内的浮点值,在其中转换int
)或cudaReadModeElementType
(您存储在内存中的实际值).请参考《 Cuda编程指南》 [ ^ ]进一步的解释.
名称是您的变量名称
因此,假设我们要一个2D整数数组(存储为整数),我们将有
Where:
Type is the data type (float, int, ...)
Dim is the number of dimensions 1D, 2D, 3D, represented as just the number 1, 2 or 3
ReadMode is the access allowed. Either cudaReadModeNormalizedFloat
(a float value in the range [0-1], where int
s are converted) or cudaReadModeElementType
(The actual value you store in the memory). Reffer to section 4.3.4 of the Cuda Programming Guide[^] for a further explanation.
Name is your variable name
So, say we want a 2D array of integers (to be stored as integers), we would have
texture<int, 2, cudaReadModeElementType> MyIntGrid;
这篇关于C语言中的Cuda纹理内存分配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!