Hi,
I write that code just for check if memset is working properly
float * distanceTransformDevice;
cutilSafeCall(cudaMalloc((void**)&distanceTransformDevice,sizeof(float)*SCREEN_RES));
cutilSafeCall(cudaMemset((void**)distanceTransformDevice,2.,sizeof(float)*SCREEN_RES));
float * distanceTransform=new float[SCREEN_RES];
cutilSafeCall(cudaMemcpy(distanceTransform,distanceTransformDevice,sizeof(float)*SCREEN_RES,cudaMemcpyDeviceToHost));
//Print distanceTransform to File
But the file do not contain '2.'s (which should). Does anyone knows why?
Thank you very much.
Hi,
I write that code just for check if memset is working properly
float * distanceTransformDevice;
cutilSafeCall(cudaMalloc((void**)&distanceTransformDevice,sizeof(float)*SCREEN_RES));
cutilSafeCall(cudaMemset((void**)distanceTransformDevice,2.,sizeof(float)*SCREEN_RES));
float * distanceTransform=new float[SCREEN_RES];
cutilSafeCall(cudaMemcpy(distanceTransform,distanceTransformDevice,sizeof(float)*SCREEN_RES,cudaMemcpyDeviceToHost));
//Print distanceTransform to File
But the file do not contain '2.'s (which should). Does anyone knows why?
Thank you very much.
This will happen for you in regular c++ as well… nothing to do with CUDA.
You can only use memset to set an array items like this for BYTE/char elements (element size 1)…
eyal
I didn’t know that. I thought that everything should work correctly since I set right the number of bytes. But you are right. It just works for char/Byte arrays.
Thank you very much.