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

Modify bit_reverse for SIMD backend #594

Merged
merged 1 commit into from
May 15, 2024

Conversation

andrewmilson
Copy link
Contributor

@andrewmilson andrewmilson commented May 1, 2024

This change is Reviewable

@codecov-commenter
Copy link

codecov-commenter commented May 1, 2024

Codecov Report

Attention: Patch coverage is 91.37931% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 91.33%. Comparing base (15e93af) to head (2719965).

Files Patch % Lines
crates/prover/src/core/backend/simd/bit_reverse.rs 91.37% 5 Missing ⚠️
Additional details and impacted files
@@                            Coverage Diff                             @@
##           05-02-Add_bit_reverse_for_SIMD_backend     #594      +/-   ##
==========================================================================
+ Coverage                                   91.24%   91.33%   +0.09%     
==========================================================================
  Files                                          76       76              
  Lines                                        9529     9560      +31     
  Branches                                     9529     9560      +31     
==========================================================================
+ Hits                                         8695     8732      +37     
+ Misses                                        763      757       -6     
  Partials                                       71       71              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@andrewmilson andrewmilson force-pushed the 04-30-Implement_FieldOps_for_SIMD_backend branch from 0143448 to 9bd0fc4 Compare May 1, 2024 04:42
@andrewmilson andrewmilson force-pushed the 04-30-Add_bit_reverse_for_SIMD_backend branch from faed46b to d56ea1d Compare May 1, 2024 04:42
@andrewmilson andrewmilson force-pushed the 04-30-Implement_FieldOps_for_SIMD_backend branch 2 times, most recently from e9ed60d to aca433d Compare May 1, 2024 15:53
@andrewmilson andrewmilson force-pushed the 04-30-Add_bit_reverse_for_SIMD_backend branch 2 times, most recently from bf357b0 to ce999c2 Compare May 2, 2024 02:36
Copy link
Contributor

@spapinistarkware spapinistarkware left a comment

Choose a reason for hiding this comment

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

Reviewed all commit messages.
Reviewable status: 0 of 2 files reviewed, 1 unresolved discussion (waiting on @andrewmilson)

a discussion (no related file):
Same here, do a first commit with just copying


@andrewmilson andrewmilson changed the title Add bit_reverse for SIMD backend Modify bit_reverse for SIMD backend May 2, 2024
@andrewmilson andrewmilson changed the base branch from 04-30-Implement_FieldOps_for_SIMD_backend to 05-02-Add_bit_reverse_for_SIMD_backend May 2, 2024 15:53
@andrewmilson andrewmilson force-pushed the 04-30-Add_bit_reverse_for_SIMD_backend branch from ce999c2 to e04a2f6 Compare May 2, 2024 15:53
@andrewmilson andrewmilson force-pushed the 05-02-Add_bit_reverse_for_SIMD_backend branch from 738f4bf to c8d160c Compare May 2, 2024 16:29
@andrewmilson andrewmilson force-pushed the 04-30-Add_bit_reverse_for_SIMD_backend branch from e04a2f6 to 9ccaf1f Compare May 2, 2024 16:29
@andrewmilson andrewmilson force-pushed the 05-02-Add_bit_reverse_for_SIMD_backend branch from c8d160c to 5f8512f Compare May 2, 2024 16:30
@andrewmilson andrewmilson force-pushed the 04-30-Add_bit_reverse_for_SIMD_backend branch from 9ccaf1f to c13b2e1 Compare May 2, 2024 16:30
@andrewmilson andrewmilson force-pushed the 05-02-Add_bit_reverse_for_SIMD_backend branch from 5f8512f to 2774e5b Compare May 2, 2024 16:34
@andrewmilson andrewmilson force-pushed the 04-30-Add_bit_reverse_for_SIMD_backend branch from c13b2e1 to 4265dcb Compare May 2, 2024 16:35
@andrewmilson andrewmilson force-pushed the 04-30-Add_bit_reverse_for_SIMD_backend branch from 4265dcb to b2f874d Compare May 2, 2024 19:09
@andrewmilson andrewmilson force-pushed the 05-02-Add_bit_reverse_for_SIMD_backend branch from 2774e5b to 2e79a5f Compare May 2, 2024 19:24
@andrewmilson andrewmilson force-pushed the 04-30-Add_bit_reverse_for_SIMD_backend branch from 1a84c3c to a6a991b Compare May 6, 2024 19:16
Copy link
Collaborator

@shaharsamocha7 shaharsamocha7 left a comment

Choose a reason for hiding this comment

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

Reviewed all commit messages.
Reviewable status: 0 of 2 files reviewed, 5 unresolved discussions (waiting on @andrewmilson and @spapinistarkware)


crates/prover/src/core/backend/simd/bit_reverse.rs line 124 at r2 (raw file):

    }

    unsafe { transmute(data) }

Suggestion:
Have from_simd func?

Code quote:

    unsafe { transmute(data) }

crates/prover/src/core/backend/simd/bit_reverse.rs line 139 at r2 (raw file):

    use crate::core::backend::Column;
    use crate::core::fields::m31::BaseField;
    use crate::core::utils::bit_reverse as ground_truth_bit_reverse;

rename?

Suggestion:

cpu_bit_reverse

crates/prover/src/core/backend/simd/bit_reverse.rs line 144 at r2 (raw file):

    fn test_bit_reverse16() {
        let data: Aligned<A64, [u32; 256]> = Aligned(array::from_fn(|i| i as u32));
        let mut expected: Aligned<A64, [u32; 256]> = data;

Can you explain/document why we need this Aligned?

Code quote:

        let data: Aligned<A64, [u32; 256]> = Aligned(array::from_fn(|i| i as u32));
        let mut expected: Aligned<A64, [u32; 256]> = data;

crates/prover/src/core/backend/simd/mod.rs line 45 at r2 (raw file):

    fn bit_reverse_column(_column: &mut Self::Column) {
        todo!()

Don't you implement also this one?

Code quote:

todo!()

@andrewmilson andrewmilson force-pushed the 04-30-Add_bit_reverse_for_SIMD_backend branch from a6a991b to 314685b Compare May 7, 2024 15:57
Copy link
Contributor Author

@andrewmilson andrewmilson left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 2 files reviewed, 4 unresolved discussions (waiting on @shaharsamocha7 and @spapinistarkware)


crates/prover/src/core/backend/simd/bit_reverse.rs line 139 at r2 (raw file):

Previously, shaharsamocha7 wrote…

rename?

Done.


crates/prover/src/core/backend/simd/bit_reverse.rs line 144 at r2 (raw file):

Previously, shaharsamocha7 wrote…

Can you explain/document why we need this Aligned?

Removed, updated.


crates/prover/src/core/backend/simd/mod.rs line 45 at r2 (raw file):

Previously, shaharsamocha7 wrote…

Don't you implement also this one?

Not for &mut [PackedSecureField] only for &mut [PackedBaseField]

@andrewmilson andrewmilson force-pushed the 05-02-Add_bit_reverse_for_SIMD_backend branch from 545100b to 8c4703f Compare May 7, 2024 18:50
@andrewmilson andrewmilson force-pushed the 04-30-Add_bit_reverse_for_SIMD_backend branch from 314685b to f50af06 Compare May 7, 2024 18:50
Copy link
Collaborator

@shaharsamocha7 shaharsamocha7 left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 3 of 3 files at r4, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @spapinistarkware)


crates/prover/src/core/backend/simd/mod.rs line 45 at r2 (raw file):

Previously, andrewmilson (Andrew Milson) wrote…

Not for &mut [PackedSecureField] only for &mut [PackedBaseField]

Why not? in another pr?

Copy link
Contributor Author

@andrewmilson andrewmilson left a comment

Choose a reason for hiding this comment

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

Reviewable status: 2 of 3 files reviewed, 1 unresolved discussion (waiting on @shaharsamocha7 and @spapinistarkware)


crates/prover/src/core/backend/simd/mod.rs line 45 at r2 (raw file):

Previously, shaharsamocha7 wrote…

Why not? in another pr?

Sure, it's not used anywhere at the moment AFAIK and it's not trivial. AVX backend has a bogus implementation of it too

@andrewmilson andrewmilson force-pushed the 05-02-Add_bit_reverse_for_SIMD_backend branch from 42b44b6 to db1d83a Compare May 10, 2024 21:11
@andrewmilson andrewmilson force-pushed the 04-30-Add_bit_reverse_for_SIMD_backend branch from 3b8ca2d to 501b9ea Compare May 10, 2024 21:11
@andrewmilson andrewmilson force-pushed the 05-02-Add_bit_reverse_for_SIMD_backend branch from db1d83a to adcb5b9 Compare May 11, 2024 02:41
@andrewmilson andrewmilson force-pushed the 04-30-Add_bit_reverse_for_SIMD_backend branch from 501b9ea to 6e55592 Compare May 11, 2024 02:41
@andrewmilson andrewmilson force-pushed the 05-02-Add_bit_reverse_for_SIMD_backend branch from adcb5b9 to 15e93af Compare May 15, 2024 04:34
@andrewmilson andrewmilson force-pushed the 04-30-Add_bit_reverse_for_SIMD_backend branch from 6e55592 to 2719965 Compare May 15, 2024 04:34
Copy link
Contributor

@spapinistarkware spapinistarkware left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 3 files at r4, 1 of 1 files at r5.
Reviewable status: all files reviewed (commit messages unreviewed), 2 unresolved discussions (waiting on @andrewmilson)


crates/prover/src/core/backend/simd/bit_reverse.rs line 119 at r5 (raw file):

    for _ in 0..4 {
        // Apply the abcd:0123 => 0abc:123d permutation.
        // `LoLoInterleaveHiLo` allows us to interleave the first half of 2 words.

I don't see any reference for this (before as well). Maybe skip it, and just keep the interleave.

Copy link
Contributor

@spapinistarkware spapinistarkware left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: all files reviewed (commit messages unreviewed), 1 unresolved discussion (waiting on @andrewmilson)

Copy link
Contributor

@spapinistarkware spapinistarkware left a comment

Choose a reason for hiding this comment

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

with one comment

Reviewed 1 of 3 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @andrewmilson)

@andrewmilson andrewmilson force-pushed the 05-02-Add_bit_reverse_for_SIMD_backend branch from 15e93af to da34ddc Compare May 15, 2024 13:15
Base automatically changed from 05-02-Add_bit_reverse_for_SIMD_backend to dev May 15, 2024 13:30
@andrewmilson andrewmilson force-pushed the 04-30-Add_bit_reverse_for_SIMD_backend branch from 2719965 to e4f0cbb Compare May 15, 2024 14:57
@andrewmilson andrewmilson merged commit 24935cf into dev May 15, 2024
20 of 21 checks passed
@andrewmilson andrewmilson deleted the 04-30-Add_bit_reverse_for_SIMD_backend branch May 15, 2024 15:01
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.

4 participants