ice 发表于 2013-8-23 10:42
LZ您好:
我无法直接推断出您的问题所在,以及您仅提供了kernel的代码,下面就该代码的目测情况做简要说明 ...
不好意思,是我没说清楚
host段代码
bool Threshold(float*hos_hist,int width,int height,int*threshold)
{
float *dev_hist=NULL;
int *dev_threshold=NULL;
float size=(float)width*height;
checkCudaErrors(cudaMalloc((void**)&dev_hist,256*sizeof(float)));
checkCudaErrors(cudaMalloc((void**)&dev_threshold,sizeof(int)));
checkCudaErrors(cudaMemcpy(dev_hist,hos_hist,256*sizeof(int),cudaMemcpyHostToDevice));
thresholdkernel<<<1,256>>>(dev_hist,size,dev_threshold);
checkCudaErrors(cudaMemcpy(threshold,dev_threshold,sizeof(int),cudaMemcpyDeviceToHost));
checkCudaErrors(cudaFree(dev_hist));
checkCudaErrors(cudaFree(dev_threshold));
return 0;
}
|