How We Beat C++ STL Binary Search
1–10 of 52 posts
Re: How We Beat C++ STL Binary Search
#2Re: How We Beat C++ STL Binary Search
#3Re: How We Beat C++ STL Binary Search
#4Re: How We Beat C++ STL Binary Search
#5The most educational bit for me was the careful structuring and eventual elimination of the if/else to shake out a conditional move rather than an unpredictable branch.
Modern optimizers and CPU scheduling engines are so powerful, a lot of received wisdom on how to code for speed is outdated; manual loop unrolling, for example, is rarely very beneficial. It's nice to see that there's still some room for craftsmanship in the most critical of paths. Structuring loops for autovectorization is another useful habit to get into.
Re: How We Beat C++ STL Binary Search
#6Great link. The most educational bit for me was the careful structuring and eventual elimination of the if/else to shake out a conditional move rather than an unpredictable branch. Modern optimizers and CPU scheduling engines are so powerful, a lot of received wisdom on how to code for speed is outdated; manual loop unrolling, for example, is rarely very beneficial. It's nice to see that there's still some room for c…
I wonder how realistic their test were, and if the same results would be achieved with some cache trashing.
Re: How We Beat C++ STL Binary Search
#7Re: How We Beat C++ STL Binary Search
#8 size_t probe = (low + high) / 2;
may overflow?Re: How We Beat C++ STL Binary Search
#9gcc 5.2.0 on Windows x64 (i5-3210M)
stl : 881 miliseconds
version 1: 880 miliseconds
version 2: 1607 miliseconds
version 3: 1260 miliseconds
version 4: 1271 miliseconds
gcc 5.2.0 on Linux x86_64 (i7-4770S) stl : 629.231 miliseconds
version 1: 629.436 miliseconds
version 2: 897.143 miliseconds
version 3: 862.827 miliseconds
version 4: 863.22 miliseconds
clang 3.6.2 on Linux armv7h (CuBox-i, Cortex-A9) stl : 3380.29 miliseconds
version 1: 3428.9 miliseconds
version 2: 3433.65 miliseconds
version 3: 3391.86 miliseconds
version 4: 3376.91 miliseconds
Oh, and Visual Studio doesn't have "/O3" argument they say they are using for cl.exe.Re: How We Beat C++ STL Binary Search
#10Isn't version 2 wrong, because size_t probe = (low + high) / 2; may overflow?