View mode: basic / threaded / horizontal-split · Log in · Help
September 28, 2012
dlib - d utility library
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.

Currently dlib contains the following packages:

dlib.core - standard algorithms, data structures, useful templates, etc.

dlib.functional - some functional programming idioms (HOFs, combiners, 
quantifiers, etc.)

dlib.math - linear algebra (vectors, matrices, quaternions, etc.)

dlib.geometry - computational geometry (ray casting, primitives, etc.)

dlib.image - image processing (filters, color correction, graphics 
formats I/O, support for 8 and 16-bit RGBA buffers and floating point 
operations).

http://code.google.com/p/dlib/
September 28, 2012
Re: dlib - d utility library
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.
>
> Currently dlib contains the following packages:
>
> dlib.core - standard algorithms, data structures, useful 
> templates, etc.
>
> dlib.functional - some functional programming idioms (HOFs, 
> combiners, quantifiers, etc.)
>
> dlib.math - linear algebra (vectors, matrices, quaternions, 
> etc.)
>
> dlib.geometry - computational geometry (ray casting, 
> primitives, etc.)
>
> dlib.image - image processing (filters, color correction, 
> graphics formats I/O, support for 8 and 16-bit RGBA buffers and 
> floating point operations).
>
> http://code.google.com/p/dlib/

Apart from a description of the project this site seems empty! Is
there anywhere a person can download the source code/try this out.

Thanks.

Craig
September 28, 2012
Re: dlib - d utility library
> Apart from a description of the project this site seems empty! 
> Is
> there anywhere a person can download the source code/try this 
> out.

If you want to browse it online (without check-out):

http://code.google.com/p/dlib/source/browse/

Gr,
Danny
September 28, 2012
Re: dlib - d utility library
On Friday, 28 September 2012 at 13:29:05 UTC, Danny Arends wrote:
>
>> Apart from a description of the project this site seems empty! 
>> Is
>> there anywhere a person can download the source code/try this 
>> out.
>
> If you want to browse it online (without check-out):
>
> http://code.google.com/p/dlib/source/browse/
>
> Gr,
> Danny

Thanks. Now I was able to find it.

Craig
September 28, 2012
Re: dlib - d utility library
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];


I've also noticed that you've provided Matrix2x2 and Matrix4x4 as 
separate structs from the more generic Matrix. I'm guessing this 
is for specialisation. A more idiomatic way to handle this would 
be to use template specialisation to provide the optimised 
versions. That way, when people use Matrix!(T, 2, 2) they get all 
the benefits of Matrix2x2!T as well.
September 29, 2012
Re: dlib - d utility library
28.09.2012 20:47, Peter Alexander пишет:
> 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];
>
>
> I've also noticed that you've provided Matrix2x2 and Matrix4x4 as
> separate structs from the more generic Matrix. I'm guessing this is for
> specialisation. A more idiomatic way to handle this would be to use
> template specialisation to provide the optimised versions. That way,
> when people use Matrix!(T, 2, 2) they get all the benefits of
> Matrix2x2!T as well.

Thanks! I didn't realize that about vectors. I'm interested in 
performance optimization, so I will fix that as soon as possible.

As for matrices - I used Matrix4x4 for a long time (that was just the 
simplest way), and recently introduced that generalized version. 
Eventually I will port everything into it.
September 29, 2012
Re: dlib - d utility library
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
September 29, 2012
Re: dlib - d utility library
On Sep 29, 2012 2:55 PM, "Jacob Carlborg" <doob@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
September 29, 2012
Re: dlib - d utility library
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 ... ))
//too bad we still don't have static Iota in Phobos
{
	arrayof[i] += v.arrayof[i];
}


-- 
Dmitry Olshansky
September 29, 2012
Re: dlib - d utility library
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
Top | Discussion index | About this forum | D home