-
Notifications
You must be signed in to change notification settings - Fork 269
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
Parallelize DIMACS formula printing #6431
base: develop
Are you sure you want to change the base?
Conversation
srogatch
commented
Nov 2, 2021
- Each commit message has a non-empty body, explaining why the change was made.
- Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
- The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
- Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
- My commit message includes data points confirming performance improvements (if claimed).
- My PR is restricted to a single feature or bugfix.
- White-space or formatting changes outside the feature-related changed lines are in commits of their own.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR. Adding threads to CBMC would be quite a big architectural step. It is not out of the question but I think it would need quite a significant use-case. Can you talk a little more about why you need this functionality and how it works in a wider context? Printing dimacs is not normally a particularly time-critical step, esp. compared with solving. Does having multiple threads really give a significant speed up over, say, outputting to a file on a RAM disk?
void dimacs_cnft::wait_file_block(const size_t ordinal) { | ||
std::unique_lock<std::mutex> lock(writing_sync); | ||
for(;;) { | ||
assert(next_file_block <= ordinal); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't add assert
s, use the various variants of INVARIANT
.
Sure, thanks for taking a look! DIMACS printing indeed takes a considerable time: CBMC converts my program into a boolean formula in ~200 seconds, then something else is going on (don't remember for how much - I think it's converting to SSA taking ~70 seconds), then 12GB of the formula are written to disk at the speed of ~50MBytes per second on a super-fast SSD with a single thread. So that takes ~240 seconds. Then |
Sure, thanks for taking a look! DIMACS printing indeed takes a
considerable time: CBMC converts my program into a boolean formula in
~200 seconds, then something else is going on (don't remember for how
much - I think it's converting to SSA taking ~70 seconds),
The option `--timestamp monotonic` can help for this kind of
application level profiling.
then 12GB of the formula are written to disk at the speed of
~50MBytes per second on a super-fast SSD with a single thread. So
that takes ~240 seconds. Then kissat solves the formula in ~600
seconds (because the formula is easy and has probable solutions with
a random assignment of some variables).
OK; thanks for the timings, that really helps with the context.
So DIMACS printing in a single thread takes as much as the rest of
the processing (except the solver), and it is not bound by the SSD
speed (SSD is PCIE-4.0 with up to 7GBytes per second transfers, 1
million IOPS). The printing is bound by C++ stream speed (conversion
from binary values to text). On a 128 logical thread CPU (Ryzen
Threadripper 3990X) I get the speed of writing to the disk about
4GBytes/second, so the formula gets saved in a few seconds.
At the risk of sounding ungrateful, have you considered:
1. Profiling the printing part of the code and seeing if we can
optimise it at all? If we could remove the bottleneck it might be
better than adding more compute to it.
2. Integrating Kissat as a SAT back-end so that the output to DIMACS is
not needed at all? I think @natasha-jeppu was using kissat (
#5494 ) so I think it can be
done.
|
#6439 is an example of adding support for a new SAT solver. |
|