Skip to content

Commit c212f41

Browse files
author
Armin Biere
committed
32 bit port, fixed MS VC++ issue in radix, fixed -j not default anymore
1 parent 76624b2 commit c212f41

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+833
-869
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ os:
99
- osx
1010
branches:
1111
- master
12+
- development

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.2
1+
1.0.3

configure

+21-77
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ check=no
2121
coverage=no
2222
profile=no
2323
unlocked=yes
24-
stdint=unknown
2524
pedantic=no
2625
options=""
2726
quiet=no
27+
m32=no
2828

2929
#--------------------------------------------------------------------------#
3030

@@ -88,9 +88,12 @@ where '<option>' is one of the following
8888
--profile compile with '-pg' to profile with 'gprof'
8989
9090
-f... pass '-f<option>[=<val>]' options to the makefile
91+
-m32 pass '-m32' to the compiler (compile for 32 bit)
9192
-ggdb3 pass '-ggdb3' to makefile (like '-s')
9293
-O|-O[123] pass '-O' or '-O[123]' to the makefile
9394
95+
-j|-j... pass this option to the makefile (for parallel build)
96+
9497
The environment variable CXX can be used to set a different C++
9598
compiler than the default 'g++'. Similarly you can add additional
9699
compilation options by setting CXXFLAGS. For example
@@ -111,8 +114,6 @@ The following configuration options might be usefull during porting the
111114
code to a new platform and are usually not necessary to change.
112115
113116
--no-unlocked force compilation without unlocked IO
114-
--no-[c]stdint avoid trying to '#include <cstdint>'
115-
--[c]stdint force '#include <cstdint>'
116117
EOF
117118
exit 0
118119
}
@@ -138,9 +139,10 @@ do
138139
--profile) profile=yes;;
139140

140141
--no-unlocked) unlocked=no;;
141-
--no-stdint) stdint=no;;
142-
--stdint) stdint=yes;;
143142

143+
-j*) MAKEFLAGS="$1";;
144+
145+
-m32) options="$options $1";m32=yes;;
144146
-f*|-ggdb3|-O|-O1|-O2|-O3) options="$options $1";;
145147
-s|--symbols) options="$options -ggdb3";;
146148

@@ -227,10 +229,12 @@ msg "root directory '$root'"
227229

228230
[ x"$CXX" = x ] && CXX=g++
229231
[ x"$CXXFLAGS" = x ] || CXXFLAGS="$CXXFLAGS "
232+
230233
case x"$CXX" in
231234
xg++*|xclang++*) CXXFLAGS="${CXXFLAGS}-Wall -Wextra";;
232235
*) CXXFLAGS="${CXXFLAGS}-W";;
233236
esac
237+
234238
if [ $debug = yes ]
235239
then
236240
CXXFLAGS="$CXXFLAGS -g"
@@ -241,12 +245,23 @@ else
241245
esac
242246
fi
243247

248+
if [ $m32 = yes ]
249+
then
250+
case x"$CXX" in
251+
xg++*)
252+
options="$options -mpc64"
253+
msg "forcing portable 64-bit FPU mode ('-mpc64') for '$CXX'"
254+
;;
255+
esac
256+
fi
257+
244258
[ $check = no ] && CXXFLAGS="$CXXFLAGS -DNDEBUG"
245259
[ $logging = yes ] && CXXFLAGS="$CXXFLAGS -DLOGGING"
246260
[ $quiet = yes ] && CXXFLAGS="$CXXFLAGS -DQUIET"
247261
[ $profile = yes ] && CXXFLAGS="$CXXFLAGS -pg"
248262
[ $coverage = yes ] && CXXFLAGS="$CXXFLAGS -ftest-coverage -fprofile-arcs"
249263
[ $pedantic = yes ] && CXXFLAGS="$CXXFLAGS --pedantic -Werror"
264+
250265
CXXFLAGS="$CXXFLAGS$options"
251266

252267
#--------------------------------------------------------------------------#
@@ -372,78 +387,6 @@ fi
372387

373388
#--------------------------------------------------------------------------#
374389

375-
# For 'Random.hpp' we really needed a clean unsigned 64 bit word type such
376-
# as 'uint64_t'. Since this requires 'cstdint' to be included, we feature
377-
# whether we can do that or otherwise try to find alternatives.
378-
379-
if [ $stdint = unknown ]
380-
then
381-
feature=./configure-have-stdint
382-
cat <<EOF > $feature.cpp
383-
#include <cstdint>
384-
EOF
385-
if $CXX $CXXFLAGS -c $feature.cpp 2>>configure.log
386-
then
387-
msg "using '#include <cstdint>' for 'uint32_t' and 'uint64_t'"
388-
stdint=yes
389-
else
390-
msg "can not use '#include <cstdint>'"
391-
stdint=no
392-
uint64_t=""
393-
uint32_t=""
394-
for type in "unsigned" "size_t" "unsigned long" "unsigned long long"
395-
do
396-
feature=./"configure-`echo $type|sed -e 's, ,-,g'`"
397-
cat <<EOF > $feature.cpp
398-
#include <cstdlib>
399-
#include <cstdio>
400-
int main () {
401-
$type x = 0, y = x >> 1;
402-
size_t bytes = sizeof x;
403-
if (y & (1 << (bytes*8 - 1))) abort (); // signed type!
404-
printf ("%ld\n", (long) bytes);
405-
return 0;
406-
}
407-
EOF
408-
if $CXX $CXXFLAGS -o $feature.exe $feature.cpp 2>&1 2>>configure.log
409-
then
410-
bytes="`$feature.exe 2>>configure.log`"
411-
msg "sizeof ($type) = $bytes"
412-
case x"$bytes" in
413-
x4) [ "$uint32_t" ] || uint32_t="$type";;
414-
x8) [ "$uint64_t" ] || uint64_t="$type";;
415-
esac
416-
fi
417-
[ "$uint32_t" -a "$uint64_t" ] && break
418-
done
419-
if [ "$uint32_t" ]
420-
then
421-
msg "using '$uint32_t' for 'uint32_t'"
422-
[ "$uint32_t" = "unsigned" ] || \
423-
CXXFLAGS="$CXXFLAGS -Duint32_t=\"$type\""
424-
else
425-
die "no 4 bytes unsigned type found for 'uint32_t'"
426-
fi
427-
if [ "$uint64_t" ]
428-
then
429-
msg "using '$uint64_t' for 'uint64_t'"
430-
[ "$uint64_t" = "size_t" ] || \
431-
CXXFLAGS="$CXXFLAGS -Duint64_t=\"$type\""
432-
else
433-
die "no 8 bytes unsigned type found for 'uint64_t'"
434-
fi
435-
fi
436-
elif [ $stdint = yes ]
437-
then
438-
msg "forced to use '#include <cstdint>' for 'uint32_t' and 'uint64_t'"
439-
else
440-
msg "will not use '#include <cstdint>' for 'uint32_t' and 'uint64_t'"
441-
fi
442-
443-
[ $stdint = no ] && CXXFLAGS="$CXXFLAGS -DNSTDINT"
444-
445-
#--------------------------------------------------------------------------#
446-
447390
# Instantiate '../makefile.in' template to produce 'makefile' in 'build'.
448391

449392
msg "compiling with ${HILITE}'$CXX $CXXFLAGS'${NORMAL}"
@@ -454,6 +397,7 @@ sed \
454397
# This 'makefile' is generated from '../makefile.in'." \
455398
-e "s,@CXX@,$CXX," \
456399
-e "s,@CXXFLAGS@,$CXXFLAGS," \
400+
-e "s,@MAKEFLAGS@,$MAKEFLAGS," \
457401
../makefile.in > makefile
458402

459403
msg "generated '$build/makefile' from '../makefile.in'"

makefile.in

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@
1010
CXX=@CXX@
1111
CXXFLAGS=@CXXFLAGS@
1212

13+
# Mainly used for parallel build ('-j' option to 'configure')
14+
15+
MAKEFLAGS=@MAKEFLAGS@
16+
1317
############################################################################
1418
# It is usually not necessary to change anything below this line! #
1519
############################################################################
1620

17-
MAKEFLAGS=-j12
1821
APP=cadical.cpp mobical.cpp
1922
ALL=$(sort $(wildcard ../src/*.[ch]pp))
2023
SRC=$(filter %.cpp,$(subst ../src/,,$(ALL)))

scripts/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Scripts needed for the build process
44

55
./make-build-header.sh # generates 'build.hpp'
6-
./get-git-id.sh # get GIT id (needed by 'make-build-headers.sh')
6+
./get-git-id.sh # get GIT id (needed by 'make-build-header.sh')
77
./update-version.sh # synchronizes VERSION in '../src/version.cpp'
88

99
and a script which builds and tests all configurations

scripts/build-and-test-all-configurations.sh

+3-5
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,10 @@ run -g -l -p
9494

9595
# finally check that these also work to some extend
9696

97-
run --no-unlocked -p
98-
run --no-stdint -p
99-
run --stdint -p
97+
run -m32 -q
98+
run -m32 -a -p
10099

100+
run --no-unlocked -q
101101
run --no-unlocked -a -p
102-
run --no-stdint -a -p
103-
run --stdint -a -p
104102

105103
echo "successfully compiled and tested ${GOOD}${ok}${NORMAL} configurations"

src/analyze.cpp

+20-15
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ void Internal::bump_queue (int lit) {
3939
if (!links[idx].next) return;
4040
queue.dequeue (links, idx);
4141
queue.enqueue (links, idx);
42+
assert (stats.bumped != INT64_MAX);
4243
btab[idx] = ++stats.bumped;
43-
LOG ("moved to front variable %d and bumped to %ld", idx, btab[idx]);
44+
LOG ("moved to front variable %d and bumped to %" PRId64 "", idx, btab[idx]);
4445
if (!vals[idx]) update_queue_unassigned (idx);
4546
}
4647

@@ -77,7 +78,7 @@ void Internal::rescore () {
7778
stab[idx] *= factor;
7879
scinc *= factor;
7980
PHASE ("rescore", stats.rescored,
80-
"new score increment %g after %ld conflicts",
81+
"new score increment %g after %" PRId64 " conflicts",
8182
scinc, stats.conflicts);
8283
}
8384

@@ -130,15 +131,17 @@ void Internal::bump_scinc () {
130131
struct analyze_bumped_rank {
131132
Internal * internal;
132133
analyze_bumped_rank (Internal * i) : internal (i) { }
133-
size_t operator () (const int & a) const { return internal->bumped (a); }
134+
uint64_t operator () (const int & a) const {
135+
return internal->bumped (a);
136+
}
134137
};
135138

136139
struct analyze_bumped_smaller {
137140
Internal * internal;
138141
analyze_bumped_smaller (Internal * i) : internal (i) { }
139142
bool operator () (const int & a, const int & b) const {
140-
const size_t s = analyze_bumped_rank (internal) (a);
141-
const size_t t = analyze_bumped_rank (internal) (b);
143+
const auto s = analyze_bumped_rank (internal) (a);
144+
const auto t = analyze_bumped_rank (internal) (b);
142145
return s < t;
143146
}
144147
};
@@ -160,7 +163,8 @@ void Internal::bump_variables () {
160163
// queue and seems to work best. We also experimented with focusing on
161164
// variables of the last decision level, but results were mixed.
162165

163-
MSORT (analyzed.begin (), analyzed.end (),
166+
MSORT (opts.radixsortlim,
167+
analyzed.begin (), analyzed.end (),
164168
analyze_bumped_rank (this), analyze_bumped_smaller (this));
165169
}
166170

@@ -294,9 +298,9 @@ void Internal::clear_analyzed_levels () {
294298
struct analyze_trail_negative_rank {
295299
Internal * internal;
296300
analyze_trail_negative_rank (Internal * s) : internal (s) { }
297-
size_t operator () (int a) {
301+
uint64_t operator () (int a) {
298302
Var & v = internal->var (a);
299-
size_t res = v.level;
303+
uint64_t res = v.level;
300304
res <<= 32;
301305
res |= v.trail;
302306
return ~res;
@@ -344,7 +348,8 @@ Clause * Internal::new_driving_clause (const int glue, int & jump) {
344348
// the opposite order) with the hope to hit the recursion limit less
345349
// frequently. Thus sorting effort is doubled here.
346350
//
347-
MSORT (clause.begin (), clause.end (),
351+
MSORT (opts.radixsortlim,
352+
clause.begin (), clause.end (),
348353
analyze_trail_negative_rank (this), analyze_trail_larger (this));
349354

350355
jump = var (clause[1]).level;
@@ -479,7 +484,7 @@ inline int Internal::determine_actual_backtrack_level (int jump) {
479484
best_idx = idx;
480485
best_pos = i;
481486
}
482-
LOG ("best variable bumped %ld", bumped (best_idx));
487+
LOG ("best variable bumped %" PRId64 "", bumped (best_idx));
483488
}
484489
assert (best_idx);
485490
LOG ("best variable %d at trail position %d", best_idx, best_pos);
@@ -516,11 +521,11 @@ void Internal::eagerly_subsume_recently_learned_clauses (Clause * c) {
516521
assert (opts.eagersubsume);
517522
LOG (c, "trying eager subsumption with");
518523
mark (c);
519-
long lim = stats.eagertried + opts.eagersubsumelim;
524+
int64_t lim = stats.eagertried + opts.eagersubsumelim;
520525
const auto begin = clauses.begin ();
521526
auto it = clauses.end ();
522527
#ifdef LOGGING
523-
long before = stats.eagersub;
528+
int64_t before = stats.eagersub;
524529
#endif
525530
while (it != begin && stats.eagertried++ <= lim) {
526531
Clause * d = *--it;
@@ -540,7 +545,7 @@ void Internal::eagerly_subsume_recently_learned_clauses (Clause * c) {
540545
}
541546
unmark (c);
542547
#ifdef LOGGING
543-
long subsumed = stats.eagersub - before;
548+
uint64_t subsumed = stats.eagersub - before;
544549
if (subsumed) LOG ("eagerly subsumed %d clauses", subsumed);
545550
#endif
546551
}
@@ -667,8 +672,8 @@ void Internal::analyze () {
667672
// Update glue statistics.
668673
//
669674
const int glue = (int) levels.size ();
670-
LOG (clause, "1st UIP size %ld and glue %d clause",
671-
(long) clause.size (), glue);
675+
LOG (clause, "1st UIP size %zd and glue %d clause",
676+
clause.size (), glue);
672677
UPDATE_AVERAGE (averages.current.glue.fast, glue);
673678
UPDATE_AVERAGE (averages.current.glue.slow, glue);
674679

src/arena.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ Arena::~Arena () {
1313
}
1414

1515
void Arena::prepare (size_t bytes) {
16-
LOG ("preparing 'to' space of arena with %ld bytes", (long) bytes);
16+
LOG ("preparing 'to' space of arena with %zd bytes", bytes);
1717
assert (!to.start);
1818
to.top = to.start = new char[bytes];
1919
to.end = to.start + bytes;
2020
}
2121

2222
void Arena::swap () {
2323
delete [] from.start;
24-
LOG ("delete 'from' space of arena with %ld bytes",
25-
(long) (from.end - from.start));
24+
LOG ("delete 'from' space of arena with %zd bytes",
25+
(size_t) (from.end - from.start));
2626
from = to;
2727
to.start = to.top = to.end = 0;
2828
}

src/averages.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace CaDiCaL {
77

88
struct Averages {
99

10-
long swapped;
10+
int64_t swapped;
1111

1212
struct {
1313

0 commit comments

Comments
 (0)