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

Implement fast-math Version of ReverseDouble with +ffi #106

Open
julmb opened this issue Aug 23, 2023 · 4 comments
Open

Implement fast-math Version of ReverseDouble with +ffi #106

julmb opened this issue Aug 23, 2023 · 4 comments

Comments

@julmb
Copy link
Contributor

julmb commented Aug 23, 2023

  1. I wonder if it is worth adding a "fast-math" version of ReverseDouble that achieves better performance at the expense of not being correct with respect to special IEEE floating-point values. This would be more work, but it would give a better migration story for anyone whose applications' performance might be negatively impacted by these changes.

Originally posted by @RyanGlScott in #105 (comment)

@julmb
Copy link
Contributor Author

julmb commented Aug 23, 2023

This is the relevant position in the code for this issue:

ad/cbits/tape.c

Lines 90 to 108 in 18efa2c

double v = buffer[idx + pTape->offset];
// TODO: if we do not care about handling IEEE floating point special values (NaN, Inf) correctly
// then we can skip the rest of the loop body in case v == 0
// see also https://github.com/ekmett/ad/issues/106
int i = pTape->lnk[idx*2];
if (i >= 0)
{
double x = v * pTape->val[idx*2];
if (x != 0) buffer[i] += x;
}
int j = pTape->lnk[idx*2 + 1];
if (j >= 0)
{
double y = v * pTape->val[idx*2 + 1];
if (y != 0) buffer[j] += y;
}

@cartazio
Copy link
Collaborator

cartazio commented Oct 4, 2023

Did including this check create a measurable change in any large examples? I forget if we discussed this before

@RyanGlScott
Copy link
Collaborator

@julmb has some large ad-based projects that incur a slight performance penalty because of this, if I understand #105 (comment) correctly.

@julmb
Copy link
Contributor Author

julmb commented Oct 7, 2023

Did including this check create a measurable change in any large examples? I forget if we discussed this before

Yes, in my application this would result in a performance improvement of around 20%.

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

No branches or pull requests

3 participants