Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
Алгоритмы были скомпилированы с максимальной оптимизацией
T t = a; a = std::min(t, b); b = std::max(t, b);)1 std::sort
2 std::nth_element
3 if
4 std::min std::max
5 bits
6 sse2
Компилятор T 1 2 3 4 5 6
GCC native int 260 305 11.3 11.3 18 2.82
uint16_t - - 5.3 5.3 7.7 2.82
uint8_t - - 2.79 2.82 - 2.83
GCC int - - 21 21.2 17.7 2.79
uint16_t - - 8.36 8.56 7.95 2.8
uint8_t - - 2.85 2.85 - 2.8
clang int 234 309 155 40.9 82.2 2.92
uint16_t - - 155 40.9 79.5 2.92
uint8_t - - 155 184 - 2.92
CXXFLAGS: -O3 -std=c++11
GCC: gcc version 4.8.1 (Ubuntu/Linaro 4.8.1-10ubuntu9)
native: -march=native
clang: Ubuntu clang version 3.4-1ubuntu1 (trunk) (based on LLVM 3.4)
CPU: Core2 Duo P8600 2.4 GHz
OS: Ubuntu 13.10 64-bit
ICC int - - 132 240 66.7 2.88
uint16_t - - 156 260 74.4 2.79
uint8_t - - 158 268 - 2.97
ICC native int - - 132 111 66.7 2.8
uint16_t - - 156 109 74.5 2.8
uint8_t - - 158 115 - 2.8
icc: icc version 14.0.1 (gcc version 4.8.0 compatibility)
-vec-report2 (для программы с if):scalar-if.cpp(46): (col. 9) remark: loop was not vectorized: existence of vector dependence
scalar-if.cpp(44): (col. 5) remark: loop was not vectorized: not inner loop
-ftree-vectorizer-verbose=1:Analyzing loop at scalar-if.cpp:44
Analyzing loop at scalar-if.cpp:46
Vectorizing loop at scalar-if.cpp:46
scalar-if.cpp:46: note: create runtime check for data references MEM[(const uint8_t *)_28 + -1B] and *_17
scalar-if.cpp:46: note: create runtime check for data references *_28 and *_17
scalar-if.cpp:46: note: create runtime check for data references MEM[(const uint8_t *)_28 + 1B] and *_17
scalar-if.cpp:46: note: create runtime check for data references MEM[(const uint8_t *)_13 + -1B] and *_17
scalar-if.cpp:46: note: create runtime check for data references *_13 and *_17
scalar-if.cpp:46: note: create runtime check for data references MEM[(const uint8_t *)_13 + 1B] and *_17
scalar-if.cpp:46: note: create runtime check for data references MEM[(const uint8_t *)_41 + -1B] and *_17
scalar-if.cpp:46: note: create runtime check for data references *_41 and *_17
scalar-if.cpp:46: note: create runtime check for data references MEM[(const uint8_t *)_41 + 1B] and *_17
scalar-if.cpp:46: note: created 9 versioning for alias checks.
scalar-if.cpp:46: note: === vect_do_peeling_for_loop_bound ===Setting upper bound of nb iterations for epilogue loop to 14
scalar-if.cpp:46: note: LOOP VECTORIZED.
scalar-if.cpp:41: note: vectorized 1 loops in function.
Оптимизация обработки изображений на C++ с использованием SIMD. Медианный фильтр