|Re: [eigen] Cost of a map operation|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Cost of a map operation
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Wed, 2 Sep 2009 08:16:40 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=qcx3vpJS7E4E24lWoIyZRrtR43Bv444bJgxwVhX289Y=; b=D3CUSHiIJKJUh0J3UknazXEh6e+Zkeven6unjYEuxjo73CB/U6lW5MTrLDpQ95y1Y1 gu/rETlONtpLsDjao1lxlEsmqaIDlDGj13XTxj5Zi00IO4+q+gvyXcVhzMxLAha5nVt3 xRD4XCvRS8fXBcAawUj5F0/1+fRY82CLrE9bY=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=UiA4JBkkuSOGXy+sMWsssWvmps8UVW+2uKV3jN7oPL/r/wY3OZvAKk4KTyrS2bAhgA T/FGAqCPc2ZVu4GsWXUiIKAFUxXYWoA4K5msXSEI+4Q85V7872E2G5n92vch0HUSqeD9 Yk7wqZcQfKqt8zY9We/fDjQAyvrSVYGdWIVzk=
This is as efficient as it could be: typically, this expands to
nothing more than:
for(int i = 0; i < cordNum; ++i)
AddressVector[i] = address[i];
and then 1) Eigen unrolls this if appropriate and 2) Eigen vectorizes
this if possible.
Basically, the Map object itself is just an expression, so its
construction is cheap at least, and in practice the compiler is able
to avoid actually creating it, everything gets "inlined".
Tip: you could check the resulting assembly code for yourself, just
put asm comments around this, asm("#hello"); , and use gcc -S to get
2009/9/2 Rohit Garg <rpg.314@xxxxxxxxx>:
> What is the cost of this map operation?
> AddressVector_t AddressVector = Map<AddressVector_t,ForceAligned>(address)
> where AddressVector_t itself is a typedef for
> typedef Matrix<int,cordNum,1> AddressVector_t;
> cordNum is a compile time constant.
> This map operation occurs in inner loop of my application, so I want
> to know, how costly is it gonna be? I mean with what use in mind was
> it written for?
> Rohit Garg
> Senior Undergraduate
> Department of Physics
> Indian Institute of Technology