Re: Proposal for new Physics Vector classes in ROOT

From: Federico Carminati <federico.carminati_at_cern.ch>
Date: Thu, 9 Jun 2005 20:17:29 +0200


Yep,

   sorry to chime in, but inlining is NOT a silver bullet even for functions that contain little beef.
There are only so many registers in a CPU. If I use many times a function in a piece of code, even
if the function does very little, the advantage of inlining can be well off-set by the exhaustion of
CPU registers for local variables, which forces to go the cache, degrading the whole performance.
Also, optimisation of inlined code sometimes is not so optimal. These are not suppositions, I have
seen this many times in benchmarks. I think some judicious benchmarking should be done before
relegating impossible stuff to the compiler and hence falling flat on one own's face. Fed

On 9 Jun 2005, at 19:41, Edmond Offermann wrote:

> Alan,
>
> hmm, you are using there a very wide brush .
> There is the time spend calling the function and the time spend in the
> function .
> If that ratio is unfavorable, you are right . However, if you have a
> function
> that contains a little bit of beef , the picture looks of course
> different .
>
> Eddy
>
> --- alan coelho <alan.coelho_at_attglobal.net> wrote:
>
>
>>> - Throughout the code you are using templates (it's good and bad)
>>> why not to use templates and class inheritance with method
>>>
>> overloading
>>
>>> for classes like BasicLorentzVector, PositionVector3D etc. -
>>> they are all "vectors" and should be derived from a single base
>>>
>> class.
>>
>>
>> Valeriy
>>
>> You are partly right. Code that contains inheritance and virtual
>> functions are more flexible and easy to read than something like the
>> STL.
>>
>> Virtual functions however cannot be inlined and this can result in a
>> severe performance hit.
>>
>> Consider the simple loop:
>>
>>
>> double s = 0.0;
>> for (int i = 0; i < 1000000000; i++) {
>> s += 1.0;
>> }
>>
>> If you were to instead invoke a function call inside of this loop to
>> do
>> the add then this run around 6 times slower. If you had two
>> unnecessary
>> function calls (two adds) then it would run 12 times slower. If you
>> made
>> everything a function call then you would end up with interpreter
>> speeds. There are ways of rearranging functons in memory to avoid a
>> casche miss but this leads to more complications.
>>
>> Thus virtual function are nice but unfortunately we are tied to a
>> physical world where hardware dictates how we write code.
>>
>> cheers
>> Alan
>>
>>
>>
>>
>>
>>
>> -----Original Message-----
>> From: owner-roottalk_at_pcroot.cern.ch
>> [mailto:owner-roottalk_at_pcroot.cern.ch] On Behalf Of Valeriy Onuchin
>> Sent: Thursday, June 09, 2005 2:16 PM
>> To: Lorenzo Moneta; roottalk_at_cern.ch; Andras Zsenei; Mf Mf; Walter E
>> Brown
>> Subject: Re: [ROOT] Proposal for new Physics Vector classes in ROOT
>>
>>
>> Hi Lorenzo,
>> this is my personal impression (ignore it).
>>
>> - First of all, the package lacks of "generality".
>> Just glance at GenVector/GenVector/
>> it contains too many (probably) "auxilary" classes like
>> "EulerAngles", "CoordinateTraits" etc. why to show it to user?
>>
>> - Throughout the code you are using templates (it's good and bad)
>> why not to use templates and class inheritance with method
>> overloading
>> for classes like BasicLorentzVector, PositionVector3D etc. -
>> they are all "vectors" and should be derived from a single base
>> class.
>>
>> - I do not see in the code *.cxx files. It is BAD to put the actual
>> code only into header files.
>>
>> - totally the code contains ~2000 lines (without comments),
>> most of them "just primitive assignments".
>> This 2 days of work for professional programmer
>> I'm afraid this is just another game which I/we saw at CERN for >10
>> years
>> LHC++, Objectivity, Anaphe, Aida, Pi, Seal, Spi ... GRID!!! ...
>> repressing ROOT.
>> Spent a lot of money (rougth estimates it's hundreds of millions
>> of
>> Euros) and
>> efforts, conferencing in "exotic places" without any usable
>> output.
>>
>> Regards. Valeriy
>>
>>
>> Valeriy Onuchin wrote:
>>
>>
>>> Hi Lorenzo,
>>> as Linus Torvalds says - "show me the code".
>>> Where can I find the latest sources of this library?
>>>
>>> Thanks. Regards. Valeriy
>>>
>>> Lorenzo Moneta wrote:
>>>
>>>
>>>> Dear ROOT users,
>>>>
>>>> This is a proposal describing new Physics Vector classes for 3D
>>>> (geometrical Points and Vectors) and 4D (LorentzVectors) with
>>>>
>> their
>>
>>>> operations and transformations (rotations).
>>>>
>>>> The proposal is available, together with a prototype describing
>>>>
>> the
>>
>>>> API for the classes at
>>>>
>>>>
>>>>
>> http://seal.web.cern.ch/seal/MathLibs/GenVector/0-1-0/html/index.html
>>
>>>>
>>>> These new classes will be part of the new mathcore package
>>>> (part of libCore) and also available as a standalone library
>>>> (libMathCore).
>>>>
>>>> The main characteristics as explained in the linked Web page are:
>>>>
>>>> -possibility to have Vector based on various coordinate
>>>>
>> systems
>>
>>>> such as Cartesian, Polar and Cylindrical
>>>> -distinction between position vectors (Points) and
>>>>
>> displacement
>>
>>>> vectors
>>>> -possibility to have classes based on arbitrary scalar type
>>>>
>> (they
>>
>>>> are templated on the scalar value type)
>>>>
>>>> An easy connection to Linear Algebra Vector and Matrices classes
>>>>
>> is
>>
>>>> also provided.
>>>>
>>>> The plan is to release a first version in the new ROOT version 5
>>>>
>> at
>> the
>>
>>>> end of the month.
>>>> The current Physics classes, TVector3, TLorentzVector, .. will be
>>>>
>> kept,
>>
>>>> and eventually they will be reimplemented using the new Vector
>>>>
>> classes
>>
>>>> (but still being back compatible).
>>>>
>>>> It is also planned to add to libMathCore other classes such as
>>>>
>>>> -Random number generators
>>>> -Numerical algorithms such as adaptive integration,
>>>> differentiation, root finders
>>>> - Some basics mathematical functions
>>>>
>>>> In addition we will provide a libMathMore library with a more
>>>> complete set of functions and algorithms
>>>> based on the GNU GSL library.
>>>>
>>>> Any comments, or feedback or criticism is highly welcomed,
>>>>
>>>> Best Regards
>>>>
>>>> Lorenzo Moneta (on behalf of the ROOT Math Library Team)
>>>>
>>
>>
>>
>
>
Received on Thu Jun 09 2005 - 20:25:59 MEST

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:09 MET