[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-hackers] ⍄PATCH⍃ Unboxing optimization for flonums
From: |
felix . winkelmann |
Subject: |
[Chicken-hackers] ⍄PATCH⍃ Unboxing optimization for flonums |
Date: |
Thu, 22 Nov 2018 11:46:44 +0100 |
This patch adds an additional optimization pass to the "lfa2"
compiler stage, which attempts to remove unnecessary
boxing and unboxing of floating point numbers. Specifically,
calls to floating point inline operations that have a variant that
accepts unboxed arguments are replaced with a faster version,
omitting the unboxing of arguments, and possibly also the
boxing of results.
This also enables -lfa2 at optimization levels 2 or higher.
The performance improvement for flonum-intensive code is
quite considerable, but only really takes effect in unsafe code
(removing error checks and therefore making possible to pass
arguments to numeric ops directly), so either compile your
code in unsafe mode or use the "unsafe" egg
(http://wiki.call-cc.org/eggref/5/unsafe) which provides replacement modules
for some
core libraries.
The core libraries don't seem to take much advantage of this
optimization, this is mainly intended for speed-critical, tight
code (tests/fft.scm is a good example).
Here a few timings, using 5.0.0 as a baseline:
baseline:
0m17.51s real 0m17.47s user 0m00.06s system
unsafe (baseline):
0m08.69s real 0m08.68s user 0m00.01s system
unboxing:
0m16.77s real 0m16.74s user 0m00.06s system
unsafe (unboxing):
0m06.02s real 0m05.94s user 0m00.05s system
baseline, -O5:
0m07.45s real 0m07.44s user 0m00.00s system
unboxing, -O5:
0m05.10s real 0m05.08s user 0m00.00s system
Results will of course change wildly, depending on whatever
code you throw at it.
felix
0001-Add-unboxing-pass-to-lfa2.patch
Description: Text document
- [Chicken-hackers] ⍄PATCH⍃ Unboxing optimization for flonums,
felix . winkelmann <=