<div dir="ltr">On 18 August 2013 14:39, Ilya Yaroshenko <span dir="ltr"><<a href="mailto:ilyayaroshenko@gmail.com" target="_blank">ilyayaroshenko@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Sunday, 18 August 2013 at 01:53:53 UTC, Manu wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
It doesn't look like you account for alignment.<br>
This is basically not-portable (I doubt unaligned loads in this context are<br>
faster than performing scalar operations), and possibly inefficient on x86<br>
too.<br>
</blockquote>
<br></div>
dotProduct uses unaligned loads (__builtin_ia32_loadups256, __builtin_ia32_loadupd256) and it up to 21 times faster then trivial scalar version.<br>
<br>
Why unaligned loads is not-portable and inefficient?</blockquote><div><br></div><div>x86 is the only arch that can perform an unaligned load. And even on x86 (many implementations) it's not very efficient.</div><div>
<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
To make it account for potentially random alignment will be awkward, but it<br>
might be possible to do efficiently.<br>
</blockquote>
<br></div>
Did you mean use unaligned loads or prepare data for alignment loads at the beginning of function?<br>
</blockquote></div><br></div><div class="gmail_extra">I mean to only use aligned loads, in whatever way that happens to work out.</div><div class="gmail_extra">The hard case is when the 2 arrays have different start offsets.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">Otherwise you need to wrap your code in a version(x86) block.</div></div>