[eigen] Re: small sums: vectorization not worth it |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: [eigen] Re: small sums: vectorization not worth it
- From: "Benoit Jacob" <jacob.benoit.1@xxxxxxxxx>
- Date: Fri, 16 Jan 2009 23:43:00 +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:in-reply-to:mime-version:content-type:references; bh=MYfYrbzK7/Y5rG2HDJWQDnZaSPBDtbyEkgO2NTaP2Zw=; b=l1rJdeY6laVinKBWXD4I2nrHdXq0lfr1Xykfzlo7HAH/Mp4SHYuIAWpGx4thsw+6c8 9UI7Bn/7x6OD1v4oA0awpMN4tWHpr+IsGKsTPJBpfkXABeiatRtF3Jh+diCg2NFO+i1h OZJZkPjg6a7JwMuvbgUseueyv1O9YxYC0j0ec=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:references; b=nwD4lrFAFUgTr6avUCPJzeuT6hd03MHowl2/C9VYG4e3YWTlC6m/jYWSGJQ/2BVa5r xmyX74hxQx4CcCahhChGUmBU1HeE9W8kRk9Eru54t2BbfSLbyfVKOq1aR7BJTmaHzkV9 Oyz6U8GGe+DluiXIC/CX9Tdd7D4kvSk4sORdw=
and in case you wonder: the situation is almost the same for dot product
(attached file dot.cpp)
runs 2x slower with SSE...
Cheers,
Benoit
2009/1/16 Benoit Jacob <jacob.benoit.1@xxxxxxxxx>:
> Note: i think the old heuristic was wrong anyway.
>
> Maybe take this occasion to introduce a EIGEN_COST_OF_PREDUX (since
> this cost depends greatly on the simd platform) ?
> And then do a natural heuristic rather than a quick hack like we used to have?
>
> Benoit
>
> 2009/1/16 Benoit Jacob <jacob.benoit.1@xxxxxxxxx>:
>> 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 * 1e-30;
v[0] = v.dot(v);
v[1] = v.dot(v);
v[0] = v.dot(v);
v[1] = v.dot(v);
v[0] = v.dot(v);
// std::cout << v << "\n"; // check it's not inf...
}
return int(v[0]);
}