[eigen] small sums: vectorization not worth it |

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

*To*: eigen@xxxxxxxxxxxxxxxxxxx
*Subject*: [eigen] small sums: vectorization not worth it
*From*: "Benoit Jacob" <jacob.benoit.1@xxxxxxxxx>
*Date*: Fri, 16 Jan 2009 23:23:38 +0100
*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type; bh=1WS0W4y3N5WhkpnXzrDHJTR3n4ze2pK0tyCgfhSyjgY=; b=hRLNV2WvRKtpNhHel4LI4WD17aHiNG2rf0qGEnDZCHJuJrAOqb772x3th5/2Ptvl1j nxpwJjn5Bh3/jr191TptRBFCHiXbRBnc/LnXJbixMSrvuYc/uIIc7wexMemw5USfPmuF sN53jh/ACiy9gShIajAxD19CntMMFSZAfJJqg=
*Domainkey-signature*: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=Nah8qtQIPtfCO+tPjK/UZGISMMGRO6uaDQir14nWqlx34srwSDBDRTurZxc39d5A7a +33QQWetTLOMkvJs8k7gaQdow+ukjk0WMeUHJDw/qyWadKIEH1xEMi9H/BzWJEnMwuPu 5hxKImtcOuQqh6R044xph3HiLodxulePpWIoA=

Hi Gael *cough* List,
ei_predux is costly because it consists of >1 SIMD instruction.
So until recently we had sum() only vectorize if the size was big enough.
However this was recently changed.
Attached is a benchmark that runs 2.5x slower with SSE (2 or 3) than
without. It's just Vector2d::sum().
So, revert to old behavior?
Moreover: matrix product innerVectorization also uses a ei_predux. Same here?
Cheers,
Benoit

#include<Eigen/Core>
int main()
{
Eigen::Vector2d v; v << 1, 0;
for(int i = 0; i < 10000000; i++)
{
v = Eigen::Vector2d::Constant(1) + v/10000;
v[0] = v.sum();
v[1] = v.sum();
v[0] = v.sum();
v[1] = v.sum();
v[0] = v.sum();
v[1] = v.sum();
v[0] = v.sum();
v[1] = v.sum();
v[0] = v.sum();
v[1] = v.sum();
//std::cout << v << "\n"; // check it's not inf...
}
return int(v[0]);
}