[Bf-committers] How about adding boost uBLAS library toblender/extern?

Yves Poissant ypoissant2 at videotron.ca
Sat Jan 24 18:00:29 CET 2009


This is probably not news for a lot of the people frequenting this list but 
I think the short description that Benoit supplied for Boost does not due 
justice to what it really is.

When he writes "It allows high level abstraction and yet it is almost as 
fast as an add-hoc C implementation because it uses the advanced technique 
of template expressions", it is not clear that the "add-hoc C 
implementation" means explicitly writing the C expression for each of the 
vector component wherever such an expression is needed and never using any 
vector/matrices libraries. Boost is that much efficient because this is 
exactly what expression templates do: they write that add-hoc C code from 
the vector expressions. Vector expression templates are faster than any 
vector/matrix class implementations because the class implementation 
generates a lot of temp store and fetch to memory while the expression 
templates avoid that except where it really is not possible otherwise. For 
small vectors such as we often use in CG, the improvement in speed from 
class implementation can be very significant because the overhead of storing 
and fetching the temps can be very high. It would have the potential of 
accelerating all vector/matrix as well as all color calculations in Blender.

The awareness of the expression template technique for optimizing vector in 
C++ is due to Jim Blinn from his 2000 article "Optimizing C++ Vector 
Expressions" in Computer Graphics & Applications. Blinn article is not 
available on the net.
But the development of the technique is credited to Todd Veldhuizen from the 
article "Expression Templates," in C++ Report, Vol. 7 No. 5 June 1995, and 
this article is available on the net at 
http://ubiety.uwaterloo.ca/~tveldhui/papers/Expression-Templates/exprtmpl.html
There is also a nice article by Tomas Arce "Faster Vector Math Using 
Templates"at flipcode 
http://www.flipcode.com/archives/Faster_Vector_Math_Using_Templates.shtml
Finally, consider the people behind coding boost and its development history 
at http://www.boost.org/

The only drawback I see concerning Boost, at the moment, is that it does not 
support SIMD/SSE. But that is not a concern for Blender which does not use 
SSE either.

Yves Poissant

----- Original Message ----- 
From: "joe" <joeedh at gmail.com>
To: "bf-blender developers" <bf-committers at blender.org>
Sent: Friday, January 23, 2009 10:26 PM
Subject: Re: [Bf-committers] How about adding boost uBLAS library 
toblender/extern?


> We have other math libraries, you may want to look at them.  There's
> intern/moto and source/blender/blenlib/BLI_arithb.h, there's also the
> math stuff the various simulation code uses, such as the superlu
> solver uv unwrapping uses, the laplacian solver bone heat uses (does
> that use superlu too? I'm too tired to remember) etc.
>
> Joe
>
> On Fri, Jan 23, 2009 at 2:50 PM, Benoit Bolsee <benoit.bolsee at online.be> 
> wrote:
>> Hi,
>>
>> The new IK algorithms developed at the KUL use the uBLAS template library
>> from boost for matrix definition and operation.
>> In order to minimize code change when porting to Blender, I am asking if 
>> it
>> would be acceptable to add that library in blender/extern.
>>
>> It is a template library, so it will not increase the size of the 
>> executable
>> more than necessary. It allows high level abstraction and yet it is 
>> almost
>> as fast as an add-hoc C implementation because it uses the advanced
>> technique of template expressions. The drawback is that it requires a 
>> modern
>> C compiler: gcc 3.2.3 and above, MSVC 7.1 and above, ICC 8.0 and above
>> (older compiler are supported with an earlier version of the library). I
>> guess this is not a limiting factor?
>> In terms of number of files, I extracted a subset of boost that contains 
>> all
>> the necessary files to compile uBLAS: 10Mb in 1650 files.
>>
>> The alternative is to implement add-hoc C functions or reuse the TNT
>> template library that is used by IK_Solver (intern/iksolver/intern/TNT).
>> This library is much smaller and provide similar functionality but it is 
>> not
>> as fast.
>>
>> For the interested ones, I've started a wiki on the IK project:
>> http://wiki.blender.org/index.php/GameEngineDev/RobotIKSolver
>>
>> /benoit
>>
>> _______________________________________________
>> Bf-committers mailing list
>> Bf-committers at blender.org
>> http://lists.blender.org/mailman/listinfo/bf-committers
>>
>>
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers
> 




More information about the Bf-committers mailing list