Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the meaning of the params x,y,z,w in function cudaCreateChannelDesc

Tags:

cuda

gpu

nvidia

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

Now i have an example code: cudaCreateChannelDesc(32, 0, 0, 0, cudaChannelFormatKindFloat);

I have no idea about why x=32,y=z=w=0.Could anybody help me?

like image 353
biaodiluer Avatar asked Jul 12 '17 03:07

biaodiluer


2 Answers

There is a separate C, and C++ API for that function (the C++ API being overloaded).

For the C API function those are the number of bits for each channel. These can be colors channels or spatial dimensions or really anything you want to use them for. The example you copied from is only using scalar values. 32 bits being appropriate for float data type.

__host__ ​cudaChannelFormatDesc cudaCreateChannelDesc ( int  x, int  y, int  z, int  w, cudaChannelFormatKind f )

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.
like image 74
Jonathan Olson Avatar answered Nov 19 '22 09:11

Jonathan Olson


Returns a channel descriptor with format f and number of bits of each component x, y, z, and w.

The x,y,z,w are the number of bits in the x,y,z dimensions and 'w'. In your example the 'x' data is 32bits and the other dimensions aren't used.

(The 'w' is used to make the math easier for applying transformations to 3d data)

like image 22
Martin Beckett Avatar answered Nov 19 '22 08:11

Martin Beckett