cuda 内存拷贝速率

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);
}

在这里插入图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值