Skip to content

SIMD Best Practice for Vectorisation #538

Answered by felker
hwhitehead asked this question in Q&A
Discussion options

You must be logged in to vote

These days, compilers are generally smart enough to auto-vectorize even with runtime conditionals present (tons of caveats to this statement). Certainly if the conditional is a simple constant that has no way to switch from true to false or vice versa within the loop body, it is likely to vectorize without problems. Unfortunately, my impression is that the only ways to be sure are to 1) generate a compiler vectorization report 2) profile or instrument your compiled code. Everything is compiler/version/target architecture/option dependent.

Use vectorized intrinsic functions if you need or want absolute control over the vectorization .

std::sqrt should compile to AVX vectorized functions _m…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@felker
Comment options

@hwhitehead
Comment options

Answer selected by hwhitehead
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants