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 carry propagation algorithm #1323

Merged
merged 1 commit into from
Jul 26, 2024

Conversation

tmontaigu
Copy link
Contributor

@tmontaigu tmontaigu commented Jun 28, 2024

Todo

  • Some inner comments
  • Some docstrings
  • Improve test to make sure both sequential and parallel algorithm are tested
  • Improve tests to use variable number of blocks
  • Check bench results
  • check correct algorimth is selected depending on number of CPU

@cla-bot cla-bot bot added the cla-signed label Jun 28, 2024
@tmontaigu tmontaigu force-pushed the tm/faster-carry-prop branch 2 times, most recently from e40a339 to 46290c2 Compare June 30, 2024 09:37
@tmontaigu tmontaigu force-pushed the tm/faster-carry-prop branch 2 times, most recently from 3ac064a to 599fa1f Compare July 22, 2024 19:18
@tmontaigu tmontaigu requested a review from IceTDrinker July 23, 2024 10:59
@IceTDrinker
Copy link
Member

the GPU crash is what you reported to the GPU team ?

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.

Lots of stuff (mainly because there is so much to make the addition happen), happy to discuss to avoid too much back and forth here :)

Comment on lines +1267 to +1311
for i in 1..grouping_size {
let state_fn = |block| {
let r = if block >= message_modulus {
2 // Generates Carry
} else if block == message_modulus - 1 {
Copy link
Member

Choose a reason for hiding this comment

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

IIRC from your sprint demo this is one of the genius part of the new algo, a small illustration might be useful to show how the addition of the bits will naturally compute the propagation

@tmontaigu
Copy link
Contributor Author

Yes the GPU crash is the thing I reported and a PR that has the fix has been openned

@tmontaigu tmontaigu force-pushed the tm/faster-carry-prop branch 2 times, most recently from 79967a7 to b3f7e39 Compare July 25, 2024 09:46
let carry = self.create_trivial_boolean_block(true);
let mut result = lhs.clone();
let overflowed = self
.advanced_add_assign_with_carry_sequential_parallelized(
Copy link
Member

Choose a reason for hiding this comment

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

parallelized algo in sequential non parallel code ?

Btw should we get rid of the non parallel code ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The parallel sequential only uses 2 threads at a time so its okayish

And yes I don't think non parallel code provide much value

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 a lot for all the hard work and for the patches on the PR you can squash in one and I'll approve the squash

@tmontaigu tmontaigu force-pushed the tm/faster-carry-prop branch from de7b9d1 to 2574083 Compare July 26, 2024 07:09
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 !

@tmontaigu tmontaigu merged commit f937524 into main Jul 26, 2024
66 of 69 checks passed
@tmontaigu tmontaigu deleted the tm/faster-carry-prop branch July 26, 2024 15:38
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.

3 participants