Uploaded image for project: 'ROOT'
  1. ROOT
  2. ROOT-5473

TMath::Abs slower than std::abs

    Details

    • Type: Improvement
    • Status: Closed (View Workflow)
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Math Libraries
    • Labels:
      None
    • Customer:
    • Bug / Feature:
      Suggestion
    • Severity:
      3 - Normal
    • Development:

      Description

      I noticed that the inline definition of TMath::Abs (in terms of an if statement) is a factor of 2 slower than std::abs.

      Of course, this seems to be rather a compiler optimization issue but at the standard -O2 release flag, the gcc compiler 4.7 does currently not translate this to any optimized implementation (which just extracts the sign bit).

      A direct beneficiary would be the ROOT geometry library (and hence ALICE simulation) which makes heavy use of TMath::Abs.

      Possible path of improvement: Replace critical ROOT math functions by calls to already optimized math functions instead of reimplementing them.

        Attachments

          Activity

            People

            • Assignee:
              moneta Lorenzo Moneta
              Reporter:
              swenzel Sandro Christian Wenzel
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                PlannedEnd:
                PlannedStart: