函数cudaCreateChannelDesc中的参数x,y,z,w是什么意思

bia*_*uer 6 cuda gpu nvidia

cudaCreateChannelDesc(int x,int y,int z,int w,枚举cudaChannelFormatKind f);

现在我有一个示例代码:cudaCreateChannelDesc(32,0,0,0,cudaChannelFormatKindFloat);

我不知道为什么x = 32,y = z = w = 0。有人可以帮助我吗?

Mar*_*ett 5

返回格式为 f 的通道描述符以及每个分量 x、y、z 和 w 的位数。

x,y,z,w 是 x,y,z 维度和“w”中的位数。在您的示例中,“x”数据是 32 位,未使用其他维度。

(“w”用于使数学更容易将变换应用于 3d 数据)


Jon*_*son 5

该功能有一个单独的C和C ++ API(C ++ API重载)。

对于C API函数,这些是每个通道的位数。这些可以是颜色通道或空间尺寸,也可以是您想要使用它们的任何东西。您复制的示例仅使用标量值。32位适用于float数据类型。

__host__ ?cudaChannelFormatDesc cudaCreateChannelDesc ( int  x, int  y, int  z, int  w, cudaChannelFormatKind f )
Run Code Online (Sandbox Code Playgroud)

From the cuda docs, "Returns a channel descriptor with format f and number of bits of each component x, y, z, and w."

The C++ API is overloaded and looks like this... If you are compiling on windows with visual studio or g++ for a .cu file you should use this form. For c files, use the above.

__inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<float>(void)
__inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<float2>(void)
__inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<float4>(void)
etc.
Run Code Online (Sandbox Code Playgroud)