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

intrinsics module with alternative implementations #915

Open
wants to merge 54 commits into
base: master
Choose a base branch
from

Conversation

jalvesz
Copy link
Contributor

@jalvesz jalvesz commented Jan 3, 2025

Add intrinsics module containing replacements for intrinsic function where some feature is found interesting: faster implementation, better accuracy, both simultaneously.

This PR follows the discussion in discourse https://fortran-lang.discourse.group/t/lfortran-now-supports-all-intrinsic-functions/8844/41 and it's based on https://github.com/jalvesz/fast_math

  • sum: 2 options (stdlib_sum and stdlib_sum_kahan)
  • dot_product: 2 options (stdlib_dot_product and stdlib_dot_product_kahan)

cc: @fortran-lang/stdlib @perazz @certik @jvdp1

@jalvesz jalvesz changed the title feate: intrinsics module with alternative implementations intrinsics module with alternative implementations Jan 4, 2025
@jalvesz
Copy link
Contributor Author

jalvesz commented Jan 7, 2025

One philosophical question: should the fsum interface be renamed to sum to enable direct replacement of the intrinsic? Keep this name? Or yet something like stdlib_sum? (Same for fprod->dot_product)

Regarding the kahan versions, given that the accuracy gains are close between the pure chunked version and the kahan one, I'm wondering which level of support should be enabled to switch between them?

@jalvesz jalvesz marked this pull request as ready for review January 12, 2025 10:32
@perazz
Copy link
Member

perazz commented Feb 4, 2025

I prefer to keep stdlib_sum and stdlib_dot_product

LGTM @jvdp1 @jalvesz!

Copy link
Member

@perazz perazz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM pending a few comments, thank you @jalvesz I think it is almost ready! I also like @jvdp1's suggestion of adding integer support.

Copy link
Member

@perazz perazz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you @jalvesz. I've adjusted the description of the kahan versions, that do not support integer in the final revision. Great addition!

@jalvesz
Copy link
Contributor Author

jalvesz commented Feb 22, 2025

Thanks @perazz I guess I pushed the changes before checking online that you had made the changes as well 😅 the same modifications are ready in the last commit

Copy link
Member

@jvdp1 jvdp1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. It can be merged pending a few very minor changes.

jalvesz and others added 4 commits February 24, 2025 07:07
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.

3 participants