Re: memory alignment vs passing by value
Dan Thompson <[email protected]> Wed, 01 Dec 2004 17:02:05 -0800
| Newsgroups | gmane.games.devel.windows |
|---|---|
| Message-ID | <[email protected]> |
Hmm now I'm confused. I'm going to make some statements and see if I can't show my ignorance in such a way that it can be corrected. It seems weird that aliasing would be a problem - since everything is in 4 bytes chunks. From what I understood about aliasing, that only mattered if you broke dword alignment, e.g. unsigned char* pData = some_aligned_junk; return *(pData + 1); // hit 1 byte off the alignment produced by the compiler. However everything he is dealing with is already in dwords, effectively, so this shouldn't be a problem... Could it be that the compiler recognizes the dprod as const, and as such can inline it directly without creating the parameter as a new instance? i.e. the code effectively just drops in without any copy constructors being called at all, whereas with a reference, it still has to chase the pointers, making it a bit slower? Does this make sense? -Dan Jon Watte wrote: >>I measured the time of computing 100 million bilinear interpolation using >>dot products, and changing the dprod operation to accept a const reference >>instead of the const value makes the test run an order of magnitude >> >> >slower!! > >Is this Evil Aliasing, Part II ? You could find out by disassembling >both versions and comparing. If it's re-loading through the reference >pointer all the time, then it's probably aliasing related. References >are really pointers, so they can introduce (false) aliasing hazards. > >Cheers, > > / h+ > > > >------------------------------------------------------- >SF email is sponsored by - The IT Product Guide >Read honest & candid reviews on hundreds of IT Products from real users. >Discover which products truly live up to the hype. Start reading now. >http://productguide.itmanagersjournal.com/ >_______________________________________________ >Gamedevlists-windows mailing list >[email protected] >https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows >Archives: >http://sourceforge.net/mailarchive/forum.php?forum_id=555 > > > > ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/ _______________________________________________ Gamedevlists-windows mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows Archives: http://sourceforge.net/mailarchive/forum.php?forum_id=555