Skip to content

FFT context initialization speedup#2690

Merged
fredrik-johansson merged 2 commits into
flintlib:mainfrom
user202729:sd-fft-init-speedup
May 23, 2026
Merged

FFT context initialization speedup#2690
fredrik-johansson merged 2 commits into
flintlib:mainfrom
user202729:sd-fft-init-speedup

Conversation

@user202729

@user202729 user202729 commented May 19, 2026

Copy link
Copy Markdown
Contributor

Requires #2681 (now merged).

Note that now initialization hard-fail for primes with insufficient 2-valuation instead of just fill the root table with garbage values. This can be reverted.

Also primes with 2-valuation less than 12 is supported.

The change to no longer compute primitive root speed things up but is backwards incompatible in case someone access the primitive_root field.

It's not clear if we really want the interface of n_primitive_root_prime_prefactor and n_quadratic_nonresidue to be that general.

@user202729 user202729 force-pushed the sd-fft-init-speedup branch from d2b60ac to 8d040f4 Compare May 21, 2026 00:13
@fredrik-johansson

Copy link
Copy Markdown
Collaborator

Did you profile this? How big is the speedup?

@user202729

user202729 commented May 22, 2026

Copy link
Copy Markdown
Contributor Author

Most significant case: About 20% for small n (n = 1500) and large p (p ~ 50 bits) with the benchmark added in #2681.

before:

threads,bits,p,n,depth,usec
1,14,12289,1500,12,23.875
1,16,61441,1500,12,23.625
1,17,86017,1500,12,23.875
...
1,48,140737488498689,1500,12,26.875
1,49,281474976829441,1500,12,29.125
1,50,562949953548289,1500,12,31.625

after:

threads,bits,p,n,depth,usec
1,14,12289,1500,12,23.750
1,16,61441,1500,12,23.750
1,17,86017,1500,12,23.750
...
1,48,140737488498689,1500,12,24.625
1,49,281474976829441,1500,12,24.625
1,50,562949953548289,1500,12,24.750

Mostly the culprit is the factorization of p-1.

@fredrik-johansson fredrik-johansson merged commit 950d86c into flintlib:main May 23, 2026
13 checks passed
@fredrik-johansson

Copy link
Copy Markdown
Collaborator

OK, that looks quite good.

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.

2 participants