`@simd ivdep` may be needed when you have indirect indexing. Do not forget the `ivdep`, but only if you know it is actually safe. This can lead to hard to track down bugs if it is not.
This inlining can help improve the chances of auto-vectorization. However, it is not a strict requirement for all function calls to be inline-able. The compiler will make decisions based on the specific code and the potential performance gains.
As for indirect indexing, it can indeed impact auto-vectorization in Julia. Indirect indexing can introduce data dependencies that make it difficult for the compiler to determine if vectorization is safe or beneficial. In such cases, using the @simd annotation can provide a hint to the compiler that vectorization is desired, but it is still up to the compiler to determine if it is possible and beneficial.
It is wrong and useless, like GPT always is, but sounds intelligent to fool the ignorant.
The compiler can inline functions, but it is essential for it to do so. It does not adjust heuristics based on being in a loop.
Hence, manual intervention like `@inline` is often needed for non-trivial cases, such as `exp`.
`@simd` doesn't say vectotization is desired, which implies changing heuristics.
It adds flags to reduction variables to say it is legal to reassociate them. That does not help at all with indirect indexing. `@simd ivdep` does help by communicating it is legal to perform the loop iterations in parallel, meaning the legality checks are no longer required. The functions must still be inlined for it to succeed in generating vectorized code.
The one about avoiding function calls is a no-go, since things like + and * are function calls too. But is it still required for all function calls to be inline-able?
Indirect indexing isn't mentioned in Julia's case, but is it one of the things that would disable auto-vectorization and require an explicit @simd annotation?
[1] https://viralinstruction.com/posts/hardware/#74a3ddb4-8af1-1... [2] https://cvw.cac.cornell.edu/vector/coding_vectorizable