-
Notifications
You must be signed in to change notification settings - Fork 274
Allow building CBMC with multiple backend SAT solvers that can be selected at runtime via a new --sat-solver
option
#7493
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
Conversation
Codecov ReportBase: 78.49% // Head: 78.27% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## develop #7493 +/- ##
===========================================
- Coverage 78.49% 78.27% -0.22%
===========================================
Files 1663 1667 +4
Lines 191339 191475 +136
===========================================
- Hits 150186 149882 -304
- Misses 41153 41593 +440
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Assigning myself to keep up to date on this. I've done a partial review, but will wait until all checks have passed. |
CMakeLists.txt
Outdated
@@ -91,7 +91,7 @@ set(enable_cbmc_tests on CACHE BOOL "Whether CBMC tests should be enabled") | |||
|
|||
set(sat_impl "minisat2" CACHE STRING | |||
"This setting controls the SAT library which is used. Valid values are | |||
'minisat2', 'glucose', 'cadical', 'ipasir-cadical' or 'ipasir-custom'" |
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.
Why was this deleted?
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.
I removed cadical
from the list, since the PR changes the build flow so that cadical
is always included in the build, so there is no longer a reason to build with -Dsat_impl=cadical
.
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.
See my above comment: maybe there is, and even if it's only to run tests with CaDiCaL (without having to specify --cadical
).
@@ -412,7 +412,7 @@ jobs: | |||
run: ccache -z --max-size=500M | |||
- name: Build using Make | |||
run: | | |||
make -C src minisat2-download |
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.
Why add the download to all of the builds even to the ones not using cadical
?
This seems to increase build times for no observable benefit (if it's not being used).
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.
To support the new --cadical
option, cadical now has to be always built (otherwise, the CBMC build will fail). Downloading and building it typically takes ~11 seconds, so hopefully this doesn't add too much overhead:
$ /usr/bin/time -p make -C src cadical-download
...
real 11.28
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.
Is this still the case? It would be good if it could be built without.
COMPILING.md
Outdated
``` | ||
mkdir -p build/minisat2-download/minisat2-download-prefix/src/ | ||
wget http://ftp.debian.org/debian/pool/main/m/minisat2/minisat2_2.2.1.orig.tar.gz \ | ||
-O build/minisat2-download/minisat2-download-prefix/src/minisat2_2.2.1.orig.tar.gz | ||
mkdir -p build/cadical-download/cadical-download-prefix/src/ | ||
wget https://github.com/arminbiere/cadical/archive/rel-1.4.1.tar.gz \ | ||
-O build/cadical-download/cadical-download-prefix/src/rel-1.4.1.tar.gz |
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.
Note to self: candidate for automation through the justfile
? #7486
@@ -520,7 +520,7 @@ successfully on Windows or macOS. | |||
This document assumes you have already been able to build CPROVER on | |||
your chosen architecture. | |||
|
|||
#RUNNING REGRESSION AND UNIT TESTS | |||
# RUNNING REGRESSION AND UNIT TESTS |
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.
I love little fixes to improve the docs 👍🏻
src/config.inc
Outdated
|
||
# select default solver to be minisat2 if no other is specified | ||
ifeq ($(BOOLEFORCE)$(CHAFF)$(GLUCOSE)$(IPASIR)$(LINGELING)$(MINISAT)$(MINISAT2)$(PICOSAT)$(CADICAL),) |
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.
Why did this need to be deleted?
It seems to also be containing minisat2
which is the default.
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.
Since cadical is now always included, it was necessary to remove it from the list so that we don't prevent minisat from getting built by default as well. That way, if the build is done with -Dsat_impl=glucose
for example, then glucose will be built in place of minisat (but cadical is always built regardless of the options).
We'll have to refrain from building CaDiCaL on Windows, unless we want to use the patched version from https://github.com/deiruch/cadical (which, arguably, we could - it seems it's being kept up to date; maybe we just use this version for Windows?). |
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.
It seems that this PR does a number of linked but different things.
A. Allow (limited) runtime switching of SAT solvers.
B. Remove the option to build without CaDiCaL.
C. Change the default solver to CaDiCaL.
A. is a good thing and long overdue. I would really support this, esp. if it worked for all solvers.
B. I am less sure about but I can see it is necessary for C.
C. Has some pretty far-reaching consequences and will change pretty much the entire performance profile of the tool. I suspect it will be for the better but it feels like the kind of change that should be profiled.
Can you explain a little more why you want this change and why it is important to do B and C? Is CADICAL=... make
not a option?
Thanks for taking a look @martin-cs.
The PR does A and B, but not C. The default SAT solver remains minisat. I updated the PR description to clarify this.
The point of this change is to include an option to run CBMC with cadical in CBMC releases going forward. This allows people using the CBMC binaries included in the releases to switch to cadical via an option instead of having to build CBMC from source. |
> Can you explain a little more why you want this change and why it
> is important to do B and C?
The point of this change is to include an option to run CBMC with
cadical in CBMC releases going forward. This allows people using the
CBMC binaries included in the releases to switch to cadical via an
option instead of having to build CBMC from source.
Why not just set `CADICAL = ../../cadical` before building in the part
of the CI that builds the release binaries? That way it is in the
release but is not added as a build dependency for everyone? We should
also possibly use it in some of the CI jobs just so that we catch if it
breaks.
|
Wouldn't that make CaDiCaL the only choice for released binaries? The point of the PR was to give users the option to switch to a different solver at runtime (cadical in this PR, but other solvers can be added later) as requested in #7467. |
> Why not just set CADICAL = ../../cadical before building in the
> part of the CI that builds the release binaries?
Wouldn't that make CaDiCaL the only choice for released binaries? The
point of the PR was to give users the option to switch to a different
solver at runtime (cadical in this PR, but other solvers can be added
later) as requested in #7467<
#7467>.
Forgive me if I have confused matters, my position is:
- I think the run-time switching is good. It would be great to have
that for all of the solvers. Keeping minisat2 as the default is good
too.
- I think it would be good if CADICAL remains an optional part of the
build.
- Having it enabled for the release build and some of the CI jobs seems
like a good way to get the functionality you need.
Does that make sense?
|
I see. Thanks for clarifying. I'll see if I can keep cadical an optional part of the build. In that case, we can error out if |
Does CaDiCaL need to be special? Could we let people build with any/multiple solvers and then run-time switch to any of the solvers they built with? |
@zhassan-aws It should be possible to guard using @jimgrundy That would be ideal! |
No, but CaDiCaL was explicitly requested in #7467.
That would be ideal. This PR was meant as a step in that direction. |
This is a response to a request, but it's our own request, so we have some flex here. Would it be a lot of work to do the more general thing? I mean if it is, then sure, let's do it later, but if it's not much it will be easiest to do it now while you have this in your head. |
Should the user experience/command-line interface then perhaps be |
fedd088
to
f1dfc28
Compare
a355830
to
4b17867
Compare
--sat-solver
option
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.
Have you tried to build with -Dsat_impl="minisat2;glucose"
?
I don't recall if I did, but I just tried it now, and it behaves as expected:
|
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 all of the reworking on this @zhassan-aws . I appreciate that it is tedious but I think it is really a better change because of it.
@@ -118,7 +118,7 @@ jobs: | |||
run: ccache -z --max-size=500M | |||
- name: Build with make | |||
run: | | |||
make -C src -j2 | |||
make -C src -j2 MINISAT2=../../minisat-2.2.1 CADICAL=../../cadical |
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.
I am probably wrong about this but shouldn't the assignment of environmental variables be before the make, as in:
CXXFLAGS="-O0 -g" make -j4000
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.
AFAIK, this is a standard way for passing variables from the command-line to make (e.g. see http://books.gigatux.nl/mirror/cinanutshell/0596006977/cinanut-CHP-19-SECT-5.html). In this form, the variables are not treated as environment variables, and they are parsed by the make
command.
@@ -412,7 +412,7 @@ jobs: | |||
run: ccache -z --max-size=500M | |||
- name: Build using Make | |||
run: | | |||
make -C src minisat2-download |
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.
Is this still the case? It would be good if it could be built without.
# The version. | ||
# | ||
-VERSION="`cat ../VERSION`" | ||
+VERSION="`cat ../VERSION.txt`" |
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.
Ummm... why the rename?
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.
I added a comment here that explains why the rename is necessary. In short, the build failed on macos-11 without this change:
https://github.com/diffblue/cbmc/actions/runs/4138376169/jobs/7154711888#step:9:782
because the used macos-11 image is case insensitive, and so it ends up using the VERSION
file in cadical's root directory for an #include<version>
directive, as opposed to using the system's version
header file. See this thread for more details:
@@ -126,6 +130,7 @@ void parse_solver_options(const cmdlinet &cmdline, optionst &options); | |||
" --smt2 use default SMT2 solver (Z3)\n" \ | |||
" --bitwuzla use Bitwuzla\n" \ | |||
" --boolector use Boolector\n" \ | |||
" --sat-solver solver use specified SAT solver\n" \ |
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.
This is a terrible thing to request as it is so fiddly, so feel free to ignore BUT would it be possible to have the available solvers given here, so it prints "use specified SAT solver : minisat2, CaDiCaL" etc.
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.
That's a good idea, but I'm not sure how easy it would be. I'll see if I can do this in a follow-up PR.
CaDiCaL is optional in the build, but I added it to as many workflows as possible because @tautschnig mentioned that there are a few regression tests that would be significantly sped up by using cadical, so he plans on updating them to use cadical to reduce CI time. |
This may be something of a moot point now the PR is merged, but I don't see the Windows release package being updated in this PR to be built with multiple SAT solvers like for the Ubuntu releases. Does this mean this new functionality doesn't work on Windows or just that we have moved further further from feature parity? |
The feature works on Windows as well, in the sense that the build can include multiple solvers. However, CaDiCaL cannot be built on Windows currently due to some platform-dependent code it uses, and thus, I haven't included it in the Windows release build. Perhaps we can try using the fork of CaDiCaL pointed out in this comment? We can also try patching it ourselves. |
Allow building CBMC with multiple backend solvers that can be selected at runtime via the new
--sat-solver
option.For example, if CBMC is built with
cmake -S . -Bbuild -Dsat_impl="minisat2;cadical"
, then one can usecbmc --sat-solver cadical
to use CaDiCaL instead of MiniSAT.The release build now includes both MiniSAT2 and CaDiCaL.
Fixes: #7467