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?
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.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With