-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kernel: rewrite (C)Log2Int using compiler builtins
Compared to the old CLog2Int code, on my machine the new code using compiler builtins is between 5 and 10 times faster, and the new generic code is still 1.2 to 4 times faster. The new FuncLog2Int calls CLog2Int (or rather, the new static inline function CLog2UInt which expects an unsigned argument), and thus benefits from the optimizations as well (though not by as much). Some micro benchmarks, using the old code: gap> x:=2^0;; for a in [0..2^25] do Log2Int(x); od; time; 998 gap> x:=2^50;; for a in [0..2^25] do Log2Int(x); od; time; 1916 gap> x:=2^60;; for a in [0..2^25] do Log2Int(x); od; time; 1312 gap> x:=2^80;; for a in [0..2^25] do Log2Int(x); od; time; 2773 gap> x:=2^180;; for a in [0..2^25] do Log2Int(x); od; time; 1504 New code: gap> x:=2^0;; for a in [0..2^25] do Log2Int(x); od; time; 955 gap> x:=2^50;; for a in [0..2^25] do Log2Int(x); od; time; 970 gap> x:=2^60;; for a in [0..2^25] do Log2Int(x); od; time; 1045 gap> x:=2^80;; for a in [0..2^25] do Log2Int(x); od; time; 1020 gap> x:=2^180;; for a in [0..2^25] do Log2Int(x); od; time; 1007
- Loading branch information
1 parent
eda43da
commit 814ec4d
Showing
4 changed files
with
164 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters