On 29-Sep-12 20:39, Dmitry Olshansky wrote:
On 28-Sep-12 21:47, Peter Alexander wrote:
On Friday, 28 September 2012 at 09:43:34 UTC, Timur Gafarov wrote:
dlib is a growing collection of native D language libraries serving as
a framework for various higher-level projects - such as game engines,
rendering pipelines and multimedia applications. It is written in D2
and has no external external dependencies aside D's standart library,
Phobos.

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];

In this case simply unrolling it would be much better
(if size is fixed and is small e.g. < 10).

foreach (i; TypeTuple!(1, 2, 3, 4 ... ))
Sorry I've meant 0, 1, 2, 3 ...

//too bad we still don't have static Iota in Phobos
{
     arrayof[i] += v.arrayof[i];
}




--
Dmitry Olshansky

Reply via email to