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

Waiting for single-exponentiation within multiexponentiation #22

Open
JanBobolz opened this issue Sep 10, 2020 · 1 comment
Open

Waiting for single-exponentiation within multiexponentiation #22

JanBobolz opened this issue Sep 10, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@JanBobolz
Copy link
Member

Consider the following code using the LazyGroup:

var h = g1.pow(x).compute();
var C = h.op(g2.pow(y)).compute();

Currently, this will (unless thread scheduling gets weird) cause computation of C to wait for the computation of h to finish before starting its own computation, i.e. the time-cost of the lines above is basically two exponentiations.

However, ideally (given you have two processors), the computation of C wouldn't wait for h, but instead immediately start with the multiexponentiation. In total, this would result in more group operations done, but the time to compute the lines would decrease to max(one pow, one multiexp) because of parallelism. So that would be faster than the current approach.

However, there may also be cases where it's stupid not to wait for a (sub-)computation to finish. For example (assume two cores):

var h = g1.pow(x).op(g3.pow(z)).compute();
var h2 = g1.pow(x).compute();
var C = h.op(g2.pow(y)).compute();

In this case, h and h2 are being computed in parallel. h2 would finish first, then C would start computing. It's likely that at that point, h is almost finished computing, so for C it's likely better to wait a short time for h instead of re-doing everything that h has already almost finished, anyway.

@JanBobolz
Copy link
Member Author

Actually, writing this I now notice that the best way to resolve the first scenario is actually to wait for h to be computed, but already finish computing the rest of C anyway. This way, the time cost is just one exponentiation (two in parallel).

@JanBobolz JanBobolz added the enhancement New feature or request label Sep 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant