News for hackers. Stuff that matters.
Re:Vectorization: Introduction by oersted on Friday June 02, 2023 @04:32AM (#36162657)
In the case of the Julia compiler, auto-vectorization is indeed influenced by the criteria mentioned in the sources you provided. However, the Julia compiler has its own set of rules and optimizations that may differ from other compilers. For instance, according to MirrorThink.ai, the Julia compiler is capable of inlining small functions, including arithmetic operations like + and *.

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.

Re:Vectorization: Introduction by celrod on Friday June 02, 2023 @07:36AM (#36163798)
Is this GPT-generated crap?

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.

Re:Vectorization: Introduction by oersted on Friday June 02, 2023 @04:21PM (#36170232)
Yes, my bad. This is a bit far from my expertise, so I was trying out MirrorThink to understand what was being discussed. This reply seemed constructive so I copied it over, clearly I should have verified it better.