I’m trying to figure out how to use pitched arrays, and the cudaExtent structure associated with this is confusing me - particularly when used with cudaArrays too.
On Page 19 of the 2.3 Programming guide, there is an example which strongly suggests that the fields of the cudaExtent structure hold element counts - the declaration
cudaExtent extent = make_cudaExtent(64, 64, 64); cudaMalloc3D(&devPitchedPtr, extent);
is used to allocate an array of 64[sup]3[/sup] floats However, when I tried following this example, I found that it didn’t work unless the cudaExtent was defined as
cudaExtent extent = make_cudaExtent(64*sizeof(float), 64, 64);
In a way, this isn’t terribly surprising - how was cudaMalloc3D supposed to know the data type which was being allocated?
In the online developer documentation for the cudaExtent, the field sizes are said to be all in bytes. This is contrary to the above, where the width field is in bytes, but the height and depth fields are in elements.
Trying to copy these pitched linear arrays to cudaArrays is getting more confusing. In this case, it seems that the cudaExtent supplied to cudaMemcpy3D has to have the element count in the width field too.
Does this match other people’s experiences? I’m piecing together things from a number of other threads here.