dlib - d utility library
Rory McGuire
rjmcguire at gmail.com
Sat Sep 29 06:07:39 PDT 2012
On Sep 29, 2012 2:55 PM, "Jacob Carlborg" <doob at me.com> wrote:
>
> On 2012-09-28 19:47, Peter Alexander wrote:
>
>> A note on your Vector implementation. Currently you use the vector
>> operators, e.g.
>>
>> Vector!(T,size) opAddAssign (Vector!(T,size) v)
>> body
>> {
>> arrayof[] += v.arrayof[];
>> return this;
>> }
>>
>> This is fine for large vectors, but (correct me if I'm wrong), your
>> vector class appears to be designed for small vectors. Those vector ops
>> currently call a asm optimised function that uses SIMD instructions in a
>> loop - it works well for larger vectors with hundreds of elements, but
>> for small vectors it's significantly faster to just use:
>>
>> foreach (i; 0..size)
>> arrayof[i] += v.arrayof[i];
>
>
> Isn't the whole point of the array operators that it gives the compiler
more semantic understanding of the code. Just as a foreach-loop does
compared to a for-loop. So the compiler should be able to optimize this and
generated the most optimal code. But the compiler might not be that good.
>
> --
> /Jacob Carlborg
+1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-announce/attachments/20120929/d4d34978/attachment-0001.html>
More information about the Digitalmars-d-announce
mailing list