[ROOT-5473] TMath::Abs slower than std::abs Created: 06/Sep/13  Updated: 15/May/19  Resolved: 13/Sep/13

Status: Closed
Project: ROOT
Component/s: Math Libraries
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Medium
Reporter: Sandro Christian Wenzel Assignee: Lorenzo Moneta
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Customer: Alice
Bug / Feature: Suggestion
Severity: 3 - Normal


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.

Comment by Lorenzo Moneta [ 13/Sep/13 ]

TMath::Abs has been now implemented in term of std::abs in the ROOT master

Generated at Sat Sep 21 07:32:48 CEST 2019 using Jira 7.13.1#713001-sha1:5e06076c2d215a6f699b7e5c90ab2fae7ba5a1ce.