cuda二维数组从host到device(未完待续)

网上的资料讲了不少了,在此,先感谢各位铺路的大牛,偶记录一下测试和遇到的各种问题,同时做一下比较。如有出入,欢迎指正!

二维数据,转一维再传比较好。这句话是我开始探索二维数组传递听到最多的了。

CUDA本身提供的二维数据传递为下面两个函数

cudaMallocPitch()

cudaMemcpy2D()

Library Document里面的原文是这样子的:
http://developer.download.nvidia.com/compute/cuda/4_1/rel/toolkit/docs/online/group__CUDART__MEMORY_g80d689bc903792f906e49be4a0b6d8db.html

cudaError_t cudaMallocPitch( void** devPtr, size_t * pitch, size_t width, size_t height ) 

Allocates at least width (in bytes) * height bytes of linear memory on the device and returns in *devPtr a pointer to the allocated memory. The function may pad the allocation to ensure that corresponding pointers in any given row will continue to meet the alignment requirements for coalescing as the address is updated from row to row. The pitch returned in *pitch by cudaMallocPitch() is the width in bytes of the allocation. The intended usage of pitch is as a separate parameter of the allocation, used to compute addresses within the 2D array. Given the row and column of an array element of typ

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值