Hello,
I am still a novice as far as it comes to CUDA (and for that matter, I’m relatively new to C++). My task the last few weeks has been to convert the SDK volumeRender example to read 16bit .RAW files. Actually, the datasets I am trying to read are of the 10/12 bit varety (http://www.gris.uni-tuebingen.de/edu/areas…tasets/new.html).
I’ve poked around the forum a little bit and found the most pertinent information a little bit unfinished: http://forums.nvidia.com/index.php?showtopic=68074. Despite what has been said, the opening 16bit files is not as straightforward as one should believe. When replacing this codeblock from uchar to ushort (1byte/8bits to 16bits), there is an error at cudaMemCpy3D.
[codebox]
void initCuda(ushort *h_volume, cudaExtent volumeSize)
{
// create 3D array
cudaChannelFormatDesc channelDesc = cudaCreateChannelDesc<uchar>();
cutilSafeCall( cudaMalloc3DArray(&d_volumeArray, &channelDesc, volumeSize) );
// copy data to 3D arraycudaMemcpy3DParms copyParams = {0};
copyParams.srcPtr = make_cudaPitchedPtr((void*)h_volume, volumeSize.width*sizeof(uchar), volumeSize.width, volumeSize.height);
copyParams.dstArray = d_volumeArray;
copyParams.extent = volumeSize;
copyParams.kind = cudaMemcpyHostToDevice;
cutilSafeCall( cudaMemcpy3D(©Params) );
[/codebox]
I have used the correct TypeDef for ushort and seemed to have approriately modified the code to deal with 2bytes of .RAW data instead of the 1byte uchars. The fopen/fread have appropriately been passed parameters which should allow for opening the correct data.
After frustration, I’ve decided to play with different datatypes… Since I noticed that the dstArray in the cudaMalloc3DArray used the cudaArray datastructure, I tried using this as the source array for h_volume. I have attached the modified program called “volumeArray_cudaArray”.
I have some “newbie” like questions such as,
1.) Can cudaArrays be instantiated & used on the host?
the error with the cudaArray-source program seems to not allow memory copies from the host to device.
2.) What type of easier to understand remedies can I use to solve this problem? I haven’t found much documentation about some of the features used in SDK examples besides (http://developer.download.nvidia.com/compu…line/index.html)
Thanks in advance, also, let me know if I can clarify anything. I am using CUDA SDK 2.3 with Visual Studio 2008. If you would like to get the sourcecode working, download the headMRT scan (http://www.gris.uni-tuebingen.de/edu/areas…6_angio.raw.zip) and place it within the “/data” “bucky.raw” folder under the attached VS solution file.
I don’t want to give up, in fact I can’t, so thanks again!
volumeRender_ushort.zip (2.01 MB)
volumeRender_cudaArray.zip (1.2 MB)