# Strange performance of a loop

**URL:** <https://discourse.julialang.org/t/strange-performance-of-a-loop/12504>\
**Category:** Performance\
**Created:** [July 19, 2018, 4:38pm UTC](https://discourse.julialang.org/t/strange-performance-of-a-loop/12504 "2018-07-19T16:38:02Z")\
**Posts on this page:** 1\
**Showing post:** 28

<div class="post-metadata">

**Author:** ![RoyiAvital](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/royiavital/32/571_2.png) [@RoyiAvital](https://discourse.julialang.org/u/RoyiAvital)\
**Post date:** [July 20, 2018, 3:57pm UTC](https://discourse.julialang.org/t/strange-performance-of-a-loop/12504/28 "2018-07-20T15:57:15Z")

</div>

> [@kristoffer.carlsson](#):
>
> The alignment is set here
> 
> [https://github.com/JuliaLang/julia/blob/9ed628780776f59bd5e52fa3d7f8244d615a0301/src/julia\_internal.h#L252-L253](https://github.com/JuliaLang/julia/blob/9ed628780776f59bd5e52fa3d7f8244d615a0301/src/julia_internal.h#L252-L253)
> 
> and depends on the size of the array. Large arrays are already 64 bytes aligned:
> 
> ```julia
> julia> Int(pointer(rand(32))) % 64
> 48
> 
> julia> Int(pointer(rand(1024))) % 64
> 0
> 
> ```

What you show is only the address of the 1st element.  
What I suggest is making sure any Loop with vectorization won’t have “Anomaly” to take care of.

I meant something like Intel IPP.

If we define 1D array it will be padded to have size which is multiplication of 16 / 32 / 64 Bytes.  
If you define 2D array it will be padded with rows which are also multiplication of 16 / 32 / 64 Bytes.

This way all loops will be able to be unrolled and vectorized with no issues about taking care of edge cases.

---

_[View the full topic](https://discourse.julialang.org/t/strange-performance-of-a-loop/12504)._
