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

feat(integer): improve scalar_add #1131

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

tmontaigu
Copy link
Contributor

By using the fact that one input is scalar
we can speed up computation of scalar_add by packing the blocks.

As the main loop as a log2 complexity, it means we just do one less
iteration, but its enough to bring a 15% to 20% improvements.

In other words a 64bits scalar add is as fast as a 32bit add

Same idea is applicable to scalar_sub and overflowing variants

@tmontaigu
Copy link
Contributor Author

What changed: The new code was moved into a pub(crate) function to be able to test it (and be sure that is it tested and not skipped because due to num_block/num_threads a different algorithm could be selected)

By using the fact that one input is scalar
we can speed up computation of scalar_add by packing the blocks.

As the main loop as a log2 complexity, it means we just do one less
iteration, but its enough to bring a 15% to 20% improvements.

In other words a 64bits scalar add is as fast as a 32bit add

Same idea is applicable to scalar_sub and overflowing variants
Copy link
Member

@IceTDrinker IceTDrinker left a comment

Choose a reason for hiding this comment

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

Thanks !

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

Successfully merging this pull request may close these issues.

None yet

3 participants