Slowdown when switching from Eigen 3.2.10 to Eigen 3.3.1
Submitted by Luca Vandelli
Assigned to Nobody
Link to original bugzilla bug (#1365)
Version: 3.3 (current stable)
Operating system: Windows
Description
Created attachment 762
Test C++ code and assembly obtained using the 2 versions of Eigen
I have written this small piece of code performing squared norm on vectors of floating points (see the attachment).
This is the output I obtain using Eigen 3.2.10 :
nTrials 200 nPoints 1000 time 0.392
This is the output I obtain using Eigen 3.3.1 :
nTrials 200 nPoints 1000 time 2.098
This means that using Eigen 3.3.1 is about 5x slower than using Eigen previous version!
The test is performed on a Intel Core I5 4690K 3.50GHz with 16 GB RAM.
The code is built using Microsoft Visual Studio 2015. The AVX2 vector extension (/arch:AVX2 switch) is enabled.
I have tried also to disassembly the code, though I do not understand the reason for such a slow-down.
The attachment contains the assembly code corresponding to the inner loop (for (int j = 0; j < np; ++j)) obtained with the two Eigen versions.
Another strange thing I noticed: introducing a temporary Vector4f like this:
Eigen::Vector4f dx = points[j] - points[i];
out(i, j) = dx.squaredNorm();
allows obtaining a 2x speed up in Eigen 3.3 (the computation time becomes about 0.9sec). A slow down is obtained instead in Eigen 3.2.10.
Thanks a lot for your help.
Attachment 762, "Test C++ code and assembly obtained using the 2 versions of Eigen":
file_1365.txt