cuda 内存拷贝速率问题
`` CPU与GPU之间内存拷贝速率,一个9M的图片,CPU->GPU耗时9ms,GPU->CPU耗时11ms,项目要求处理的是大图,对每一个像素点做处理,以400M的图片为例子,cpu与gpu之间拷贝均耗时200多ms。显卡带宽为192GB/s,(我认为的)正常情况应该传输速率很快,请问一下有什么需要修改的地方吗(刚刚接触GPU的萌新)。下图为GPU型号:
void Binaryzation_GPU(CppColorRange* range_host,byte* src_host, byte* dst_host, int width, int height)
{
int length = width * height;
int memSize = length * sizeof(uchar4);
CppColorRange range_devive = *range_host;
uchar4* src_device;
uchar4* dst_device;
cudaMalloc((void**)&src_device, memSize);
cudaMallocHost((void**)&dst_device, memSize);
//copy
cudaMemcpy((void**)src_device, src_host, memSize, cudaMemcpyHostToDevice);
cudaMemcpy((void**)dst_device, dst_host, memSize, cudaMemcpyHostToDevice);
dim3 threadsPerBlock(32, 32);
dim3 blocksPerGrid((width + threadsPerBlock.x - 1) / threadsPerBlock.x, (height + threadsPerBlock.y - 1) / threadsPerBlock.y);
cudaDeviceSynchronize();
kernel_Binaryzation << <blocksPerGrid, threadsPerBlock >> >(range_devive, src_device, dst_device, width, height);
cudaMemcpy((void**)dst_host, dst_device, memSize, cudaMemcpyDeviceToHost);
cudaFree(src_device);
cudaFree(dst_device);
}