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

Poseidon2 perf improvement #758

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

danny-shterman
Copy link
Contributor

Poseidon2 CPU perf improvement by 17% for sponge and 10% for non-sponge.
Changes are only in CPU backend file and the tests file.

This PR...

Linked Issues

Resolves #

(optional) CUDA backend branch

cuda-backend-branch: main # specify the branch here

// Multiplication by partial (sparse) matrix.
partial_matrix_diagonal_m1_mul_by_vector(tmp_fields, partial_matrix_diagonal_m1, tmp_fields);
S prepared_element;
#pragma unroll
Copy link
Contributor

Choose a reason for hiding this comment

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

Is T known at compile time? if not, unrolling won't be made anyway
Can unroll the smallest value of T...

return element * element * element * element * element * element * element * element * element * element *
element;
default: {
// Danny TODO: How to stop here if there is an illegal alpha?
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO return eIcicileError and add the return to the api

// Note that in order to increase the performance the partial matrix diagonal values
// are actually partial matrix diagonal values minus 1.
void partial_matrix_diagonal_m1_mul_by_vector(const S* vec_in, const S* matrix_in, S* result) const
S sbox_el(S element, const int alpha) const
Copy link
Contributor

Choose a reason for hiding this comment

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

name unclear, sbox_element?

Suggested change
S sbox_el(S element, const int alpha) const
eIcicleError sbox_element(S element, const int alpha, S to_return) const

@@ -145,341 +142,437 @@ namespace icicle {
break;
default:
ICICLE_LOG_ERROR
<< "cpu_poseidon2_init_default_constants: T (width) must be one of [2, 3, 4, 8, 12, 16, 20, 24]\n";
<< "cuda_poseidon2_init_default_constants: T (width) must be one of [2, 3, 4, 8, 12, 16, 20, 24]";
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is cuda here?

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