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

Use precomputed twiddles in avx #443

Merged
merged 1 commit into from
Mar 14, 2024

Conversation

spapinistarkware
Copy link
Contributor

@spapinistarkware spapinistarkware commented Mar 7, 2024

This change is Reviewable

Copy link

graphite-app bot commented Mar 7, 2024

Your org has enabled the Graphite merge queue for merging into dev

Add the label “merge-queue” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

@spapinistarkware spapinistarkware force-pushed the spapini/03-07-Use_precomputed_twiddles_in_avx branch from 8fff079 to 6aa41bc Compare March 7, 2024 09:54
@spapinistarkware spapinistarkware requested review from ohad-starkware and shaharsamocha7 and removed request for ohad-starkware March 7, 2024 09:54
@spapinistarkware spapinistarkware force-pushed the spapini/02-25-Precompute_twiddles branch from 30e1f97 to 86da951 Compare March 9, 2024 09:43
@spapinistarkware spapinistarkware force-pushed the spapini/03-07-Use_precomputed_twiddles_in_avx branch from 6aa41bc to 41f6f0a Compare March 9, 2024 09:43
@spapinistarkware spapinistarkware force-pushed the spapini/02-25-Precompute_twiddles branch from 86da951 to 37bb799 Compare March 12, 2024 09:28
@spapinistarkware spapinistarkware force-pushed the spapini/02-25-Precompute_twiddles branch from 655019f to 0b60491 Compare March 12, 2024 13:58
@spapinistarkware spapinistarkware force-pushed the spapini/03-07-Use_precomputed_twiddles_in_avx branch from 87f6b9f to 686f51a Compare March 12, 2024 13:58
@spapinistarkware spapinistarkware force-pushed the spapini/02-25-Precompute_twiddles branch from 0b60491 to e2fa88e Compare March 12, 2024 14:03
@spapinistarkware spapinistarkware force-pushed the spapini/03-07-Use_precomputed_twiddles_in_avx branch from 686f51a to 14ccf9d Compare March 12, 2024 14:03
@spapinistarkware spapinistarkware force-pushed the spapini/02-25-Precompute_twiddles branch from e2fa88e to 24220ed Compare March 12, 2024 14:14
@spapinistarkware spapinistarkware force-pushed the spapini/03-07-Use_precomputed_twiddles_in_avx branch from 14ccf9d to 0857a54 Compare March 12, 2024 14:14
@spapinistarkware spapinistarkware force-pushed the spapini/02-25-Precompute_twiddles branch from 24220ed to 52a6ea3 Compare March 12, 2024 15:11
@spapinistarkware spapinistarkware force-pushed the spapini/03-07-Use_precomputed_twiddles_in_avx branch from 0857a54 to 6accca8 Compare March 12, 2024 15:11
@spapinistarkware spapinistarkware force-pushed the spapini/02-25-Precompute_twiddles branch from 52a6ea3 to 034a430 Compare March 12, 2024 16:18
@spapinistarkware spapinistarkware force-pushed the spapini/03-07-Use_precomputed_twiddles_in_avx branch from 6accca8 to db9ada9 Compare March 12, 2024 16:18
@spapinistarkware spapinistarkware force-pushed the spapini/02-25-Precompute_twiddles branch from 034a430 to 07065a8 Compare March 13, 2024 07:53
@spapinistarkware spapinistarkware force-pushed the spapini/03-07-Use_precomputed_twiddles_in_avx branch 3 times, most recently from 7b2d0e0 to b710ea6 Compare March 13, 2024 07:59
@spapinistarkware spapinistarkware force-pushed the spapini/02-25-Precompute_twiddles branch from 07065a8 to b0988f6 Compare March 13, 2024 09:44
@spapinistarkware spapinistarkware force-pushed the spapini/03-07-Use_precomputed_twiddles_in_avx branch from b710ea6 to 917bf93 Compare March 13, 2024 09:44
@spapinistarkware spapinistarkware force-pushed the spapini/02-25-Precompute_twiddles branch from b0988f6 to d6a9ea6 Compare March 13, 2024 11:27
@spapinistarkware spapinistarkware changed the base branch from spapini/02-25-Precompute_twiddles to dev March 13, 2024 11:31
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 1 of 2 files at r2, 6 of 6 files at r4, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @spapinistarkware)


src/core/backend/avx512/circle.rs line 22 at r4 (raw file):

// Decide if and when it's ok and what to do if it's not.
impl PolyOps for AVX512Backend {
    type Twiddles = Vec<i32>;

I think that something should be written here w.r.t why the twiddle in the avx is a vec of i32.

Code quote:

type Twiddles = Vec<i32>

src/core/backend/avx512/circle.rs line 118 at r4 (raw file):

                    &twiddles[layer_i]
                        [i << (fft_log_size - 2 - layer_i)..(i + 1) << (fft_log_size - 2 - layer_i)]
                })

Why do we want this change?

Code quote:

            let subdomain_twiddles = (0..(fft_log_size - 1))
                .map(|layer_i| {
                    &twiddles[layer_i]
                        [i << (fft_log_size - 2 - layer_i)..(i + 1) << (fft_log_size - 2 - layer_i)]
                })

src/core/backend/avx512/circle.rs line 147 at r4 (raw file):

    }

    fn precompute_twiddles(coset: Coset) -> TwiddleTree<Self> {

Do we maybe want the twiddles to be stored also in avx registers?

Code quote:

fn precompute_twiddles(coset: Coset) -> TwiddleTree<Self> {

src/core/backend/avx512/circle.rs line 152 at r4 (raw file):

        // TODO(spapini): Optimize.
        for layer in &rfft::get_twiddle_dbls(coset)[1..] {

Is this the only use of get_twiddle_dbls?
Why are we storing the layer0 twiddles there if we are going to ignore them anyway?

Code quote:

&rfft::get_twiddle_dbls(coset)[1..] 

src/core/backend/avx512/circle.rs line 155 at r4 (raw file):

            twiddles.extend(layer);
        }
        twiddles.push(2);

Explain

Code quote:

twiddles.push(2)

@spapinistarkware spapinistarkware force-pushed the spapini/03-07-Use_precomputed_twiddles_in_avx branch 2 times, most recently from cb666dd to 7cf3a4c Compare March 14, 2024 11:57
Copy link
Contributor Author

@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.

Reviewable status: 2 of 7 files reviewed, 5 unresolved discussions (waiting on @shaharsamocha7)


src/core/backend/avx512/circle.rs line 22 at r4 (raw file):

Previously, shaharsamocha7 wrote…

I think that something should be written here w.r.t why the twiddle in the avx is a vec of i32.

Done.


src/core/backend/avx512/circle.rs line 118 at r4 (raw file):

Previously, shaharsamocha7 wrote…

Why do we want this change?

It seems that without it, I would need to access twiddles[layer_i-1], and doing the -1 is weird.


src/core/backend/avx512/circle.rs line 147 at r4 (raw file):

Previously, shaharsamocha7 wrote…

Do we maybe want the twiddles to be stored also in avx registers?

Not all twiddles can, and its not that important.
Except for the first layer, only the first is loaded as an AVX register. The other are broadcasted.


src/core/backend/avx512/circle.rs line 152 at r4 (raw file):

Previously, shaharsamocha7 wrote…

Is this the only use of get_twiddle_dbls?
Why are we storing the layer0 twiddles there if we are going to ignore them anyway?

Done.


src/core/backend/avx512/circle.rs line 155 at r4 (raw file):

Previously, shaharsamocha7 wrote…

Explain

Done.

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 5 of 5 files at r5, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @spapinistarkware)


src/core/backend/avx512/fft/ifft.rs line 377 at r4 (raw file):

}

pub fn get_itwiddle_dbls(mut coset: Coset) -> Vec<Vec<i32>> {

Document that this returns all the twiddles that relevant only for the line domains.

Code quote:

pub fn get_itwiddle_dbls(mut coset: Coset) -> Vec<Vec<i32>> {

@spapinistarkware spapinistarkware force-pushed the spapini/03-07-Use_precomputed_twiddles_in_avx branch from 7cf3a4c to 3664014 Compare March 14, 2024 15:05
Copy link
Contributor Author

@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.

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @shaharsamocha7)


src/core/backend/avx512/fft/ifft.rs line 377 at r4 (raw file):

Previously, shaharsamocha7 wrote…

Document that this returns all the twiddles that relevant only for the line domains.

Done.

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 2 of 2 files at r6, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @spapinistarkware)

Copy link

graphite-app bot commented Mar 14, 2024

Merge activity

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/starkware-libs/stwo/443)
<!-- Reviewable:end -->
@spapinistarkware spapinistarkware force-pushed the spapini/03-07-Use_precomputed_twiddles_in_avx branch from 3664014 to 882e7f6 Compare March 14, 2024 15:17
@graphite-app graphite-app bot merged commit 882e7f6 into dev Mar 14, 2024
8 of 9 checks passed
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