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

Fboemer/ntt fix #58

Merged
merged 7 commits into from
Sep 1, 2021
Merged

Fboemer/ntt fix #58

merged 7 commits into from
Sep 1, 2021

Conversation

fboemer
Copy link
Contributor

@fboemer fboemer commented Sep 1, 2021

Fixes bug in AVX512 NTT that appeared in the IFMA implementation with primes close to 2**50. Added bool prefer_small_primes parameter to GeneratePrimes() which is used to trigger the failing condition.

@@ -266,7 +266,7 @@ void ForwardTransformToBitReverseAVX512(
const uint64_t* W = &root_of_unity_powers[W_idx];
const uint64_t* W_precon = &precon_root_of_unity_powers[W_idx];

if (input_mod_factor <= 2) {
if ((input_mod_factor <= 2) && (recursion_depth == 0)) {
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 actual fix

@fboemer fboemer temporarily deployed to intel_workflow September 1, 2021 15:51 Inactive
@fboemer fboemer temporarily deployed to intel_workflow September 1, 2021 15:52 Inactive
@fboemer fboemer temporarily deployed to intel_workflow September 1, 2021 15:52 Inactive
@fboemer fboemer temporarily deployed to intel_workflow September 1, 2021 15:52 Inactive
@fboemer fboemer temporarily deployed to intel_workflow September 1, 2021 15:52 Inactive
@fboemer fboemer temporarily deployed to intel_workflow September 1, 2021 15:52 Inactive
@fboemer fboemer temporarily deployed to intel_workflow September 1, 2021 15:52 Inactive
@fboemer fboemer temporarily deployed to intel_workflow September 1, 2021 15:52 Inactive
@fboemer fboemer temporarily deployed to intel_workflow September 1, 2021 15:52 Inactive
@fboemer fboemer temporarily deployed to intel_workflow September 1, 2021 15:52 Inactive
@fboemer fboemer temporarily deployed to intel_workflow September 1, 2021 15:52 Inactive
@fboemer fboemer temporarily deployed to intel_workflow September 1, 2021 15:52 Inactive
@fboemer fboemer temporarily deployed to intel_workflow September 1, 2021 15:52 Inactive
@fboemer fboemer temporarily deployed to intel_workflow September 1, 2021 15:52 Inactive
@fboemer fboemer temporarily deployed to intel_workflow September 1, 2021 16:10 Inactive
@fboemer fboemer temporarily deployed to intel_workflow September 1, 2021 16:10 Inactive
@fboemer fboemer temporarily deployed to intel_workflow September 1, 2021 16:10 Inactive
@fboemer fboemer temporarily deployed to intel_workflow September 1, 2021 16:10 Inactive
@fboemer fboemer temporarily deployed to intel_workflow September 1, 2021 16:10 Inactive
@fboemer fboemer temporarily deployed to intel_workflow September 1, 2021 16:10 Inactive
@fboemer fboemer temporarily deployed to intel_workflow September 1, 2021 16:10 Inactive
@fboemer fboemer temporarily deployed to intel_workflow September 1, 2021 16:10 Inactive
@fboemer fboemer temporarily deployed to intel_workflow September 1, 2021 16:10 Inactive
@fboemer fboemer temporarily deployed to intel_workflow September 1, 2021 16:10 Inactive
@fboemer fboemer temporarily deployed to intel_workflow September 1, 2021 16:10 Inactive
@fboemer fboemer temporarily deployed to intel_workflow September 1, 2021 16:10 Inactive
@fboemer fboemer temporarily deployed to intel_workflow September 1, 2021 16:10 Inactive
@fboemer fboemer temporarily deployed to intel_workflow September 1, 2021 16:10 Inactive
@fboemer fboemer temporarily deployed to intel_workflow September 1, 2021 16:10 Inactive
@fboemer fboemer marked this pull request as ready for review September 1, 2021 16:13
@fboemer fboemer requested a review from a team as a code owner September 1, 2021 16:13
@@ -35,7 +35,7 @@ static void BM_EltwiseFMAModAddNative(benchmark::State& state) { // NOLINT

BENCHMARK(BM_EltwiseFMAModAddNative)
->Unit(benchmark::kMicrosecond)
->ArgsProduct({{1024, 8192, 16384}, {false, true}});
->ArgsProduct({{1024, 4096, 16384}, {false, true}});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just making parameters consistent with other benchmarks.

Copy link
Contributor

@GelilaSeifu GelilaSeifu left a comment

Choose a reason for hiding this comment

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

LG

Copy link
Contributor

@hamishun hamishun left a comment

Choose a reason for hiding this comment

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

LG though I added an optional suggestion

Comment on lines +253 to +261
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<uint64_t> distrib(1, modulus - 1);

for (size_t trial = 0; trial < num_trials; ++trial) {
std::vector<uint64_t> input64(N, 0);
for (size_t i = 0; i < N; ++i) {
input64[i] = distrib(gen);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This code block is repeated a few times. Would it be worth, refactoring into a helper function that returns a vector? Or, abstract away distrib and gen into a functor and use std::generate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion. I've created https://jiratest.idoc.intel.com/browse/GLADE-79 to fix in a separate PR

@fboemer fboemer merged commit 7301e50 into 1.2.1 Sep 1, 2021
@fboemer fboemer deleted the fboemer/ntt-fix branch September 1, 2021 18:46
fboemer added a commit that referenced this pull request Sep 2, 2021
* Fix NTT AVX512 implementation
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.

None yet

3 participants