typedef unsigned int uint32;
typedef unsigned char byte;
__device__ byte data[1024];
__device__ inline void Copy128(byte *dest,const byte *src)
{
((uint32*)dest)[0]=((uint32*)src)[0];
((uint32*)dest)[1]=((uint32*)src)[1];
((uint32*)dest)[2]=((uint32*)src)[2];
((uint32*)dest)[3]=((uint32*)src)[3];
}
__global__ kernel(){
byte v[4][4];
copy128((byte *)v,data);
}
代码大概是这样,调试的时候发现 v中的内容整体后移了两个字节,是什么原因呢?
data 前16字节: v
0x45 0x89
0x67 0x45
0x89 0x7a
0x45 0xf1
0x7a .
0xf1 .
.
. .
.
. 0x56
0x77
0x56 0xb2
0x77 0x3c