Re: [eigen] vectorization of loops using eigen arrays.

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Your example is only using Eigen's Array as a container, but does not use any of its feature. So you're only benchmarking compiler's abilities. Moreover, on my system, the actual distance computation represent only 15% of the total running time. So you are mostly benchmarking I/O.

gael

On Tue, Dec 9, 2014 at 10:43 AM, Max Linke <max_linke@xxxxxx> wrote:
Hi

I'm was implementing distance calculations in python for prototyping and then
switched to C++ with eigen to speed up the calculations. To my surprise on the
test data the python program is faster by a factor of two then my C++ program.

Perf-stat tells me that neither python nor c++ have cache-misses but the eigen
implementation uses more then twice as much cycles, even though I have to load
the whole python interpreter. The data and sources are shown below.

In python I have used a brute-force C implementation for the pairwise distances
from scipy. The code looks pretty similar to my C code.

My guess is that I either have not chosen a good representation in memory of my
data or that the python version is making a lot more use of vectorization then
my C++ code does.

How can I check/force the vectorization of my eigen code?

best, Max


DATA and SOURCES
================

Cycles used up by the different programs

Eigen: 73,132,906,861  cycles
Blaze: 39,290,635,107  cycles
Python: 29,960,555,581 cycles

The code for the programs, test data and the complete results of the perf-stats
measurements can be found at.

https://gist.github.com/kain88-de/731d9a2791cece980cc4

gcc -v:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /build/gcc/src/gcc-4.9.2/configure --prefix=/usr
--libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++
--enable-shared
--enable-threads=posix --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch
--disable-libssp --enable-gnu-unique-object --enable-linker-build-id
--enable-cloog-backend=isl --disable-isl-version-check
--disable-cloog-version-check --enable-lto --enable-plugin
--enable-install-libiberty --with-linker-hash-style=gnu --disable-multilib
--disable-werror --enable-checking=release Thread model: posix gcc version
4.9.2 (GCC)



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/