Stream: helpdesk (published)

Topic: LoopVectorization staggered iteration


view this post on Zulip Mason Protter (May 15 2021 at 00:20):

I'm trying to write a loop that currently looks something like

@avx for i in 1:2:(length(a)-1)
    f(a[i], a[i+1]
end

What's the right way to write something like this with LoopVectorization? Is there an easy way I can tell if LoopVectorization is able to understand this loop, or if it is bailing out and just @inbounds @simd'ing it?

view this post on Zulip Mason Protter (May 15 2021 at 00:53):

Okay, so one approach is to just reshape a to a 2xN matrix and then treat the first index special. Interestingly, I found a performance loss when I made it a StaticInt(2)xN matrix for some reason.

view this post on Zulip Zachary P Christensen (May 17 2021 at 21:12):

What kind of static array

view this post on Zulip Mason Protter (May 17 2021 at 21:15):

I was using a PtrArray. Chris identified what the problem was in #general > Working with Complex Numbers in LoopVectorization. It was just that VectorizationBase.jl was making a suboptimal choice for my CPU architecture, so he added a patch that makes it make the right choice


Last updated: Nov 22 2024 at 04:41 UTC