# Error: Unaligned memory accesses not supported aligned memory accesses

**URL:** <https://forums.developer.nvidia.com/t/error-unaligned-memory-accesses-not-supported-aligned-memory-accesses/3559>\
**Category:** CUDA Programming and Performance\
**Created:** [May 1, 2008, 8:06am UTC](https://forums.developer.nvidia.com/t/error-unaligned-memory-accesses-not-supported-aligned-memory-accesses/3559 "2008-05-01T08:06:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ElJoshua](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@ElJoshua](https://forums.developer.nvidia.com/u/ElJoshua)\
**Post date:** [May 1, 2008, 8:06am UTC](https://forums.developer.nvidia.com/t/error-unaligned-memory-accesses-not-supported-aligned-memory-accesses/3559/1 "2008-05-01T08:06:32Z")

</div>

When compiling, I get the following error: Error: Unaligned memory accesses not supported

```auto
__device__  void function()

{

      uint8_t  ib[8], block[8];

     extern __shared__ uint8_t pkt[];

     .... init ... 

     for( i = 1; i < n + 1; i++ )

     {       

    

        ... does stuff here...

       for( j = 0; j < 8; j++ )

        {            

            pkt[iHeader+8*(i-1)+j] = ib[j] ^ block[j]; //unalignment

        }

    }

}

```

the strange thing is that the following replaced in the code compiles fine:

uint8\_t temp = ib[j] ^ block[j];

pkt[iHeader+8\*(i-1)+j] = 0; //this is not the same ofcourse

but

uint8\_t temp = ib[j] ^ block[j];

pkt[iHeader+8\*(i-1)+j] = temp

doesnt work.

Can someone point me toward the sollution or origin of this problem? I have left out alot of code for clearity. Please ask if you need to see more code.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![ElJoshua](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@ElJoshua](https://forums.developer.nvidia.com/u/ElJoshua)\
**Post date:** [May 1, 2008, 9:30am UTC](https://forums.developer.nvidia.com/t/error-unaligned-memory-accesses-not-supported-aligned-memory-accesses/3559/2 "2008-05-01T09:30:26Z")

</div>

I found a way to avoid the error but i still don’t understand the problem:

i just replaced:

```auto
for( j = 0; j < 8; j++ )

       {            

           pkt[iHeader+8*(i-1)+j] = ib[j] ^ block[j]; //unalignment

       }

```

with

```auto
pkt[iHeader+8*(i-1)  ] =ib[0] ^ block[0];

pkt[iHeader+8*(i-1)+1] =ib[1] ^ block[1];

pkt[iHeader+8*(i-1)+2] =ib[2] ^ block[2];

pkt[iHeader+8*(i-1)+3] =ib[3] ^ block[3];

pkt[iHeader+8*(i-1)+4] =ib[4] ^ block[4];

pkt[iHeader+8*(i-1)+5] =ib[5] ^ block[5];

pkt[iHeader+8*(i-1)+6] =ib[6] ^ block[6];	

pkt[iHeader+8*(i-1)+7] =ib[7] ^ block[7];

```

---

<div class="post-metadata">

**Author:** ![wlangdon](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@wlangdon](https://forums.developer.nvidia.com/u/wlangdon)\
**Post date:** [January 11, 2010, 3:44pm UTC](https://forums.developer.nvidia.com/t/error-unaligned-memory-accesses-not-supported-aligned-memory-accesses/3559/3 "2010-01-11T15:44:17Z")

</div>

This still seams to be a problem.  
I am uploading a complete example which causes nvcc to fail  
[bug\_371104.cu](https://forums.developer.nvidia.com/uploads/short-url/2FqCX5JIpG7TmFVuHIs2eaw4TKI.cu) (19.6 KB)
