Skip to content

Commit 0fe1341

Browse files
committed
Update CaDiCaL from 2.0.0 to 2.2.0
Update to the latest release.
1 parent 4fe3ade commit 0fe1341

File tree

8 files changed

+82
-15
lines changed

8 files changed

+82
-15
lines changed

.github/workflows/pull-request-checks.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ jobs:
545545
echo "CCACHE_BASEDIR=$PWD" >> $GITHUB_ENV
546546
echo "CCACHE_DIR=$PWD/.ccache" >> $GITHUB_ENV
547547
- name: Configure using CMake
548-
run: cmake -S . -Bbuild -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ -Dsat_impl="minisat2;cadical" -DCMAKE_CXX_FLAGS=-m32
548+
run: cmake -S . -Bbuild -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ -Dsat_impl="minisat2;cadical" -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32
549549
- name: Zero ccache stats and limit in size
550550
run: ccache -z --max-size=500M
551551
- name: Build with Ninja
File renamed without changes.

scripts/cadical_CMakeLists.txt

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
file(GLOB sources "src/*.cpp" "src/*.hpp" "src/*.h")
1+
file(GLOB sources "src/*.cpp" "src/*.c" "src/*.hpp" "src/*.h")
22
# Remove "app" sources from list
33
list(REMOVE_ITEM sources
44
"${CMAKE_CURRENT_SOURCE_DIR}/src/cadical.cpp"
@@ -9,7 +9,33 @@ add_library(cadical ${sources})
99

1010
# Pass -DNBUILD to disable including the version information, which is not
1111
# needed since cbmc doesn't run the cadical binary
12-
target_compile_options(cadical PRIVATE -DNBUILD -DNFLEXIBLE -DNDEBUG)
12+
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
13+
target_compile_options(
14+
cadical
15+
PRIVATE
16+
-DNBUILD -DNFLEXIBLE -DNDEBUG
17+
-Wno-error=switch-enum
18+
)
19+
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR
20+
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
21+
if (CMAKE_HOST_SYSTEM_NAME STREQUAL Darwin)
22+
target_compile_options(
23+
cadical
24+
PRIVATE
25+
-DNBUILD -DNFLEXIBLE -DNDEBUG -DNCLOSEFROM
26+
-Wno-error=switch-enum
27+
)
28+
else()
29+
target_compile_options(
30+
cadical
31+
PRIVATE
32+
-DNBUILD -DNFLEXIBLE -DNDEBUG
33+
-Wno-error=switch-enum
34+
)
35+
endif()
36+
else()
37+
target_compile_options(cadical PRIVATE -DNBUILD -DNFLEXIBLE -DNDEBUG)
38+
endif()
1339

1440
set_target_properties(
1541
cadical

src/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,14 @@ glucose-download:
186186
@(cd ../glucose-syrup; patch -p1 < ../scripts/glucose-syrup-patch)
187187
@$(RM) $(glucose_rev).tar.gz
188188

189-
cadical_release = rel-2.0.0
189+
cadical_release = rel-2.2.0
190190
cadical-download:
191191
@echo "Downloading CaDiCaL $(cadical_release)"
192192
@$(DOWNLOADER) https://github.com/arminbiere/cadical/archive/$(cadical_release).tar.gz
193193
@$(TAR) xfz $(cadical_release).tar.gz
194194
@rm -Rf ../cadical
195195
@mv cadical-$(cadical_release) ../cadical
196-
@(cd ../cadical; patch -p1 < ../scripts/cadical-2.0.0-patch)
196+
@(cd ../cadical; patch -p1 < ../scripts/cadical-2.2.0-patch)
197197
@(cd ../cadical && ./configure CXX="$(CXX)")
198198
# Need to rename VERSION so that it isn't picked up by `#include<version>` on
199199
# macOS which is case insensitive

src/solvers/CMakeLists.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,11 @@ foreach(SOLVER ${sat_impl})
121121
message(STATUS "Building solvers with cadical")
122122

123123
download_project(PROJ cadical
124-
URL https://github.com/arminbiere/cadical/archive/rel-2.0.0.tar.gz
125-
PATCH_COMMAND patch -p1 -i ${CBMC_SOURCE_DIR}/scripts/cadical-2.0.0-patch
124+
URL https://github.com/arminbiere/cadical/archive/rel-2.2.0.tar.gz
125+
PATCH_COMMAND patch -p1 -i ${CBMC_SOURCE_DIR}/scripts/cadical-2.2.0-patch
126126
COMMAND cmake -E copy ${CBMC_SOURCE_DIR}/scripts/cadical_CMakeLists.txt CMakeLists.txt
127127
COMMAND ./configure
128-
URL_MD5 9fc2a66196b86adceb822a583318cc35
128+
URL_MD5 856484d1a022ca22826fc6d67432e1d1
129129
)
130130

131131
add_subdirectory(${cadical_SOURCE_DIR} ${cadical_BINARY_DIR})
@@ -144,10 +144,10 @@ foreach(SOLVER ${sat_impl})
144144
message(STATUS "Building with IPASIR solver linking against: CaDiCaL")
145145

146146
download_project(PROJ cadical
147-
URL https://github.com/arminbiere/cadical/archive/rel-2.0.0.tar.gz
148-
PATCH_COMMAND patch -p1 -i ${CBMC_SOURCE_DIR}/scripts/cadical-2.0.0-patch
147+
URL https://github.com/arminbiere/cadical/archive/rel-2.2.0.tar.gz
148+
PATCH_COMMAND patch -p1 -i ${CBMC_SOURCE_DIR}/scripts/cadical-2.2.0-patch
149149
COMMAND ./configure
150-
URL_MD5 9fc2a66196b86adceb822a583318cc35
150+
URL_MD5 856484d1a022ca22826fc6d67432e1d1
151151
)
152152

153153
message(STATUS "Building CaDiCaL")

src/solvers/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,8 @@ solvers$(LIBEXT): $(OBJ) $(SOLVER_LIB)
282282
$(LINKLIB)
283283

284284
../../cadical/build/libcadical$(LIBEXT):
285-
$(MAKE) $(MAKEARGS) -C $(CADICAL)/build libcadical.a CXX="$(CXX)" CXXFLAGS="$(CP_CXXFLAGS) -DNFLEXIBLE -DNDEBUG"
285+
$(MAKE) $(MAKEARGS) -C $(CADICAL)/build libcadical.a CXX="$(CXX)" \
286+
CXXFLAGS="$(CP_CXXFLAGS) -DNFLEXIBLE -DNDEBUG -DNCLOSEFROM"
286287

287288
-include smt2/smt2_solver$(DEPEXT)
288289

src/solvers/sat/satcheck_cadical.cpp

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ tvt satcheck_cadical_baset::l_get(literalt a) const
2727
if(a.var_no() > narrow<unsigned>(solver->vars()))
2828
return tvt(tvt::tv_enumt::TV_UNKNOWN);
2929

30-
const int val = solver->val(a.dimacs());
30+
const int val = solver->val(a.var_no(), true);
3131
if(val>0)
32-
result = tvt(true);
32+
result = tvt(!a.sign());
3333
else if(val<0)
34-
result = tvt(false);
34+
result = tvt(a.sign());
3535
else
3636
return tvt(tvt::tv_enumt::TV_UNKNOWN);
3737

@@ -140,6 +140,35 @@ void satcheck_cadical_baset::set_assignment(literalt a, bool value)
140140
INVARIANT(false, "method not supported");
141141
}
142142

143+
# if 0
144+
/// Generate a new variable and return it as a literal
145+
/// \return New variable as literal
146+
literalt satcheck_cadical_baset::new_variable()
147+
{
148+
int new_var_index = solver->declare_more_variables(1);
149+
CHECK_RETURN(new_var_index >= 0);
150+
set_no_variables(new_var_index + 1);
151+
return literalt{static_cast<literalt::var_not>(new_var_index), false};
152+
}
153+
154+
/// Generate a vector of new variables.
155+
/// \return Vector of new variables.
156+
bvt satcheck_cadical_baset::new_variables(std::size_t width)
157+
{
158+
bvt result;
159+
result.reserve(width);
160+
161+
for(std::size_t i = _no_variables; i < _no_variables + width; ++i)
162+
result.emplace_back(i, false);
163+
164+
int new_max_var_index = solver->declare_more_variables(width);
165+
CHECK_RETURN(new_max_var_index >= 0);
166+
set_no_variables(new_max_var_index + 1);
167+
168+
return result;
169+
}
170+
# endif
171+
143172
satcheck_cadical_baset::satcheck_cadical_baset(
144173
int _preprocessing_limit,
145174
int _localsearch_limit,
@@ -150,6 +179,12 @@ satcheck_cadical_baset::satcheck_cadical_baset(
150179
localsearch_limit(_localsearch_limit)
151180
{
152181
solver->set("quiet", 1);
182+
// Explicitly disable bounded variable addition; this is disabled by default
183+
// in version 2.2.0, but will be enabled in the next major release. Early
184+
// experiments, however, suggest that this results in degraded performance. If
185+
// we ever choose to enable it then the above overrides of `new_variable` and
186+
// `new_variables` need to be enabled.
187+
solver->set("factor", 0);
153188
}
154189

155190
satcheck_cadical_baset::~satcheck_cadical_baset()

src/solvers/sat/satcheck_cadical.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ class satcheck_cadical_baset : public cnf_solvert, public hardness_collectort
4444
}
4545
bool is_in_conflict(literalt a) const override;
4646

47+
#if 0
48+
literalt new_variable() override;
49+
bvt new_variables(std::size_t width) override;
50+
#endif
51+
4752
protected:
4853
resultt do_prop_solve(const bvt &assumptions) override;
4954

0 commit comments

Comments
 (0)