Initializing portions of arrays

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

matthewlai
Posts: 793
Joined: Sun Aug 03, 2014 4:48 am
Location: London, UK

Re: Initializing portions of arrays

Post by matthewlai »

mar wrote:
matthewlai wrote:The value of loop unrolling in modern CPUs is probably mostly only when combined with auto-vectorization - when unrolling loops allows the use of SIMD instructions.
This reminds me of a (funny?) story, I tried to iterate over a simple vector of ints and doing a sum or something like that.
The compiler (msc v11) vectorized the loop and it ran pretty fast.
Then I tried to use range-based for loop of C++11: for( type x:arr ) { ... } and to my surprise the compiler failed to vectorize in this case,
because range-based loop uses iterators (=pointers for vector) and somehow it failed to optimize this case.
The same of course applies to iterating the standard way using iterators.
I wonder if the most recent version of their compiler still has problems with this.
That is very interesting. I haven't used MSVC in many many years, only GCC and LLVM. I didn't notice any performance loss converting a bunch of loops to range-based.
Disclosure: I work for DeepMind on the AlphaZero project, but everything I say here is personal opinion and does not reflect the views of DeepMind / Alphabet.