I’ve been playing with the example @e3c6 proposed but instead of computing the total norm I computed the individual norm:
function normSoA(x)
out = Array{Float64,1}(undef, length(x.real))
for i in 1:length(x.real)
@inbounds out[i] = sqrt(x.real[i]^2 + x.imag[i]^2)
end
out
end
function normAoS(x)
out = Array{Float64,1}(undef, length(x))
for i in 1:length(x)
@inbounds out[i] = sqrt(x[i].real^2 + x[i].imag^2)
end
out
end
In that case benchmarking give the exact same results for both cases. Using code_llvm
shows that both codes use <4 x double>
SIMD instructions.
Not sure how to interpret those findings but I wanted to share it with you. I’m a new Julia user.