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

Request: add log1p in math prelude #1820

Closed
nbos opened this issue Dec 27, 2022 · 4 comments
Closed

Request: add log1p in math prelude #1820

nbos opened this issue Dec 27, 2022 · 4 comments

Comments

@nbos
Copy link
Contributor

nbos commented Dec 27, 2022

log1p(x) computes accurately log(1 + x) even when x is very small.

It looks like OpenCL and CUDA have it as primitives, although I can't find reference to a 16-bit CUDA log1p.

I can give it a go if it turns out just to require appending definitions to the prelude.

@athas
Copy link
Member

athas commented Dec 27, 2022

Sure, have at it. The main challenge is getting it done for all the backends, but if you add a test to tests/primitive, CI will tell you the ones you missed. For the 16 bit version, I would just use 32 bit arithmetic - we do that with many others. Let me know if you need more pointers.

@nbos
Copy link
Contributor Author

nbos commented Dec 27, 2022

Will do, thanks!

@nbos nbos mentioned this issue Dec 28, 2022
@nbos
Copy link
Contributor Author

nbos commented Dec 28, 2022

How bad is it if results vary by 1 or 2 ULPs between backends? E.g. Haskell's log1p 2.0 gives 1.0986122886681096 to the interpreter while my implementation for ISPC gives 1.0986122886681098. Do I just omit those cases in tests?

@athas
Copy link
Member

athas commented Dec 28, 2022

The testing tool uses a fairly generous tolerance when comparing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants