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

Pre compute an optimal parallel solving strategy #646

Open
gbotrel opened this issue Apr 18, 2023 · 0 comments
Open

Pre compute an optimal parallel solving strategy #646

gbotrel opened this issue Apr 18, 2023 · 0 comments
Labels

Comments

@gbotrel
Copy link
Collaborator

gbotrel commented Apr 18, 2023

(post #641 ).

Currently, the parallelization of the constraint system solver is a bit naive. It relies on the "level builder". Essentially, we look at all the wires that appears in each instructions (constraints and hints), to build a dependency tree.

Then at solving time, we say "at level 0, we can solve constraint 0,2,5,7 independently". "at level 1, we can solve constraint 1,8,9,10... independently" etc. So the solver fires n go routines that synchronize at each level.

Main issues and avenue for improvements;

  • there is no weight. a constraint which needs 4 multiplication to solve as the same weight (1) as a hint that may need 40x time CPU time using big.Int arithmetic. So work is not necessary equally distributed.
  • the strategy is the same, independently of the number of CPU the target system has.

This is an optimization problem (job / task scheduling) and we want to optimize for wall clock. Some approaches reduce need for synchronization by solving several times the same constraint in different threads, etc..

Should be possible to build a tool, possibly completly independent from gnark that takes as input a constraint system and a number of CPUs, and output a data structure that gnark solver uses at run time to solve the constraint system. Using an external solver like Google's OR Tool could help, though ideally, for build convenience like the rest of gnark framework, pure Go with no CGO would be better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant