Skip to content

Optionally use CORE-MATH correctly rounded elementary functions - #1510

Closed
ridgeworks wants to merge 7 commits into
SWI-Prolog:masterfrom
ridgeworks:crmath
Closed

Optionally use CORE-MATH correctly rounded elementary functions#1510
ridgeworks wants to merge 7 commits into
SWI-Prolog:masterfrom
ridgeworks:crmath

Conversation

@ridgeworks

Copy link
Copy Markdown
Contributor

Under control of CMake option USE_CRMATH (default=OFF), build a local copy of library containing a subset of CORE-MATH functions from repo https://github.com/indigobio/core-math-binary64.

If option is OFF, use existing explicitly rounded functions currently in pl-arith.c. (under control of O_ROUNDING_UP_DOWN).

Caveats:

  1. Only tested on MacOS, X86 architecture.
  2. compile flags for local crmath library set to "-O3 -ffp-contract=on -fno-math-errno" as per external repo. Is this right for all architectures/compilers. (Note: no support for different FP rounding in WASM).
  3. Limited CMake experience so additions should be reviewed.

Option depends on flag HAVE_CRMATH. IF CORE-MATH not used, defers to local defintions of cr_xxx functions with explicit rounding. 

Always use explicitly rounded `lgamma` function based on comment in source repo: "The lgamma function is omitted because Windows' math.h does not provide signgam."
@JanWielemaker

Copy link
Copy Markdown
Member

Merged after some refactoring. Notably reuse the external dependency with as little as possible own code and pin the version by git HASH for security and reproducibility purposes.

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