Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elide bignum operations #4

Merged
merged 10 commits into from
Jul 4, 2024
Merged

Elide bignum operations #4

merged 10 commits into from
Jul 4, 2024

Conversation

paulapatience
Copy link
Member

No description provided.

@paulapatience paulapatience force-pushed the no-bignum branch 4 times, most recently from a38646e to 1140a64 Compare June 29, 2024 03:14
@paulapatience paulapatience force-pushed the no-bignum branch 2 times, most recently from 3583fe7 to 9599d7c Compare June 30, 2024 15:33
code/math/implementation.lisp Outdated Show resolved Hide resolved
code/math/implementation.lisp Outdated Show resolved Hide resolved
code/schubfach/implementation.lisp Outdated Show resolved Hide resolved
@paulapatience paulapatience force-pushed the no-bignum branch 6 times, most recently from 697b0a5 to 253f13b Compare July 4, 2024 20:58
paulapatience and others added 10 commits July 4, 2024 17:09
* code/schubfach/implementation.lisp (%schubfach): Remove spurious
character.
* code/liebler/implementation.lisp (%liebler): Add some type
declarations.

Co-authored-by: Tarn W. Burton <[email protected]>
A declared result type of T is effectively (VALUES T &REST T).
To constrain it to a single value, the syntax is (VALUES T &OPTIONAL).

* code/math/implementation.lisp (round-to-odd/32, round-to-odd/64)
(round-to-odd/128, expt10/32, expt10/64, expt10/128, floor-log-expt)
(ceiling-log-expt): Declare result types with the (VALUES T &OPTIONAL)
syntax.
It uses the anticipatory feature QUAVIVER/MATH/SMALLNUM.

* code/math/implementation.lisp (arithmetic-word): New type.
(round-to-odd/32, round-to-odd/64, round-to-odd/128, expt10/32)
(expt10/64, expt10/128): Use it in FTYPE declarations.
* code/math/packages.lisp (#:quaviver/math): Export ARITHMETIC-WORD.

Co-authored-by: Tarn W. Burton <[email protected]>
* code/liebler/implementation.lisp (%liebler):
* code/schubfach/implementation.lisp (%schubfach): Use ARITHMETIC-WORD,
declaring any EXPT10 variables DYNAMIC-EXTENT.
* code/dragonbox/implementation.lisp (floor-by-expt10-divisible-p)
(floor-by-expt10-small, floor-by-expt10, compute-mul)
(compute-mul-parity, %nearest, %directed): Same, and replace previous
uses of EXPT10-SIZE with (ASH ARITHMETIC-SIZE 1).
In anticipation for upcoming math routines, where the principal
arithmetic-sized parameter is first.

* code/math/implementation.lisp (%round-to-odd-1, %round-to-odd-2)
(round-to-odd/32, round-to-odd/64, round-to-odd/128): Swap parameter
order.
* code/liebler/implementation.lisp (%liebler):
* code/schubfach/implementation.lisp (%schubfach): Update.
So that the sizes of all the parameters are apparent.

* code/math/implementation.lisp (round-to-odd/32, round-to-odd/64)
(round-to-odd/128): Rename to...
(round-to-odd/32-64, round-to-odd/64-128, round-to-odd/128-256): ...
these.
* code/math/packages.lisp (#:quaviver/math):
* code/liebler/implementation.lisp (quaviver:integer-float):
* code/schubfach/implementation.lisp (quaviver:float-integer): Update.
From quaviver/dragonbox's COMPUTE-MUL operations.

* code/math/implementation.lisp: Add copyright header.
(%floor-multiply/n-2nq2n, %floor-multiply/evenp/n-2nq2n): New macros,
extracted from code/dragonbox/implementation.lisp.
(floor-multiply/32-64q64, floor-multiply/64-128q128)
(floor-multiply/evenp/32-64q64, floor-multiply/evenp/64-128q128): New
functions.
* code/math/utility.lisp: Add copyright header.
* code/math/packages.lisp: Same.
(#:quaviver/math): Export new functions.
* code/dragonbox/implementation.lisp (compute-mul, compute-mul-parity):
Remove macros now found in quaviver/math.
(beta-bounds/nearest/shorter-interval)
(beta-bounds/nearest/normal-interval, beta-bounds/left-closed-directed)
(beta-bounds/right-closed-directed): New functions.
(%nearest, %directed, quaviver:float-integer): Update to use
arithmetic-size–specific FLOOR-MULTIPLY and FLOOR-MULTIPLY/EVENP
functions.
* quaviver.asd (quaviver/math): Update license.
For extracting the high bits of a word. These operations allow some
simplifications in quaviver/dragonbox's nearest shorter interval case
and in the computations of DELTAI.

* code/math/implementation.lisp (hi/64, hi/hi64/128): New functions.
* code/math/packages.lisp (#:quaviver/math): Export them.
* code/dragonbox/implementation.lisp (%nearest, %directed)
(quaviver:float-integer): Use them.
Mostly ported from the reference implementation of Dragonbox.

They are activated by default only on SBCL, as on other implementations
they tend to be slower than bignum operations.

* code/math/implementation.lisp (+/64-64, +/128-64, */32-64/hi64)
(*/32-64/lo64, */64-64, */64-64/hi64, */64-64/lo64, */64-128/hi128)
(*/64-128/lo128): New functions, mostly ported from reference Dragonbox.
(hi/hi64/128): New smallnum optimization and compiler macro.
(round-to-odd/32-64, round-to-odd/64-128): New smallnum optimizations.
(floor-multiply/32-64q64, floor-multiply/64-128q128)
(floor-multiply/evenp/32-64q64, floor-multiply/evenp/64-128q128): New
smallnum optimizations from reference Dragonbox.
(*expt10/values/64*): Add smallnum version.
* code/math/packages.lisp: Push QUAVIVER/MATH/SMALLNUM feature on SBCL.
* code/dragonbox/implementation.lisp (floor-by-expt10): New smallnum
optimization from reference Dragonbox.
@paulapatience paulapatience marked this pull request as ready for review July 4, 2024 22:42
@paulapatience paulapatience merged commit 3b06535 into main Jul 4, 2024
6 checks passed
@paulapatience paulapatience deleted the no-bignum branch July 5, 2024 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants