ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
report.c
Go to the documentation of this file.
1#include "global.h"
2
3#ifndef KISSAT_QUIET
4
5#include "report.h"
6#include "colors.h"
7#include "internal.h"
8#include "print.h"
9#include "resources.h"
10
11#include <inttypes.h>
12#include <string.h>
13
14#define MB (kissat_current_resident_set_size () / (double) (1 << 20))
15
16#define REMAINING_VARIABLES \
17 kissat_percent (solver->active, statistics->variables_original)
18
19#define REPORTS \
20 REP ("seconds", "5.2f", kissat_time (solver)) \
21 REP ("MB", "2.0f", MB) \
22 REP ("level", ".0f", AVERAGE (level)) \
23 REP ("switched", "1" PRIu64, statistics->switched) \
24 REP ("reductions", "1" PRIu64, statistics->reductions) \
25 REP ("restarts", "2" PRIu64, statistics->restarts) \
26 REP ("rate", ".0f", AVERAGE (decision_rate)) \
27 REP ("conflicts", "3" PRIu64, CONFLICTS) \
28 REP ("redundant", "3" PRIu64, REDUNDANT_CLAUSES) \
29 REP ("size/glue", ".1f", \
30 kissat_average (AVERAGE (size), AVERAGE (slow_glue))) \
31 REP ("size", ".0f", AVERAGE (size)) \
32 REP ("glue", ".0f", AVERAGE (slow_glue)) \
33 REP ("tier1", "1u", solver->tier1[solver->stable]) \
34 REP ("tier2", "1u", solver->tier2[solver->stable]) \
35 REP ("trail", ".0f%%", AVERAGE (trail)) \
36 REP ("binary", "3" PRIu64, BINARY_CLAUSES) \
37 REP ("irredundant", "2" PRIu64, IRREDUNDANT_CLAUSES) \
38 REP ("variables", "2u", solver->active) \
39 REP ("remaining", "1.0f%%", REMAINING_VARIABLES)
40
41void kissat_report (kissat *solver, bool verbose, char type) {
42 statistics *statistics = &solver->statistics;
43 const int verbosity = kissat_verbosity (solver);
44 if (verbosity < 0)
45 return;
46 if (verbose && verbosity < 2)
47 return;
48 char line[128], *p = line;
49 unsigned pad[32], n = 1, pos = 0;
50 pad[0] = 0;
51 // clang-format off
52#define REP(NAME,FMT,VALUE) \
53 do { \
54 *p++ = ' ', pos++; \
55 sprintf (p, "%" FMT, VALUE); \
56 while (*p) \
57 p++, pos++; \
58 pad[n++] = pos; \
59 } while (0);
60 REPORTS
61#undef REP
62 // clang-format on
63 KISSAT_assert (p < line + sizeof line);
64 TERMINAL (stdout, 1);
65 if (!(solver->limits.reports++ % 20)) {
66#define ROWS 3
67 unsigned last[ROWS];
68 char rows[ROWS][128], *r[ROWS];
69 for (unsigned j = 0; j < ROWS; j++)
70 last[j] = 0, rows[j][0] = 0, r[j] = rows[j];
71 unsigned row = 0, i = 1;
72#define REP(NAME, FMT, VALUE) \
73 do { \
74 if (last[row]) \
75 *r[row]++ = ' ', last[row]++; \
76 unsigned target = pad[i]; \
77 const unsigned name_len = strlen (NAME); \
78 const unsigned val_len = target - pad[i - 1] - 1; \
79 if (val_len < name_len) \
80 target += (name_len - val_len) / 2; \
81 while (last[row] + name_len < target) \
82 *r[row]++ = ' ', last[row]++; \
83 for (const char *p = NAME; *p; p++) \
84 *r[row]++ = *p, last[row]++; \
85 if (++row == ROWS) \
86 row = 0; \
87 i++; \
88 } while (0);
89 REPORTS
90#undef REP
91 KISSAT_assert (i == n);
92 for (unsigned j = 0; j < ROWS; j++) {
93 KISSAT_assert (r[j] < rows[j] + sizeof rows[j]);
94 *r[j] = 0;
95 }
96 if (solver->limits.reports > 1)
98 for (unsigned j = 0; j < ROWS; j++) {
99 fputs (solver->prefix, stdout);
100 COLOR (CYAN);
101 fputs (rows[j], stdout);
102 COLOR (NORMAL);
103 fputc ('\n', stdout);
104 }
106 }
107 kissat_prefix (solver);
108 switch (type) {
109 case '1':
110 case '0':
111 case '?':
112 case 'i':
113 case '.':
114 COLOR (BOLD);
115 break;
116 case 'e':
117 COLOR (BOLD GREEN);
118 break;
119 case '2':
120 case 's':
121 COLOR (GREEN);
122 break;
123 case 'f':
124 case 't':
125 case 'u':
126 case 'v':
127 case 'w':
128 case 'x':
129 COLOR (BLUE);
130 break;
131 case 'b':
132 case 'c':
133 case 'd':
134 case '=':
135 COLOR (BOLD BLUE);
136 break;
137 case '[':
138 case ']':
139 COLOR (MAGENTA);
140 break;
141 case '(':
142 case ')':
143 COLOR (BOLD YELLOW);
144 }
145 fputc (type, stdout);
146 COLOR (NORMAL);
147 if (solver->preprocessing)
148 COLOR (YELLOW);
149 else if (solver->stable)
150 COLOR (MAGENTA);
151 fputs (line, stdout);
152 COLOR (NORMAL);
153 fputc ('\n', stdout);
154 fflush (stdout);
155}
156
157#else
158
160
161#endif
#define NORMAL
Definition colors.h:18
#define BOLD
Definition colors.h:14
#define COLOR(CODE)
Definition colors.h:41
#define MAGENTA
Definition colors.h:17
#define BLUE
Definition colors.h:13
#define TERMINAL(F, I)
Definition colors.h:34
#define YELLOW
Definition colors.h:21
#define GREEN
Definition colors.h:16
#define CYAN
Definition colors.h:15
bool pos
Definition globals.c:30
Cube * p
Definition exorList.c:222
type
CUBE COVER and CUBE typedefs ///.
Definition exor.h:90
#define KISSAT_assert(ignore)
Definition global.h:13
#define solver
Definition kitten.c:211
#define kissat_line(...)
Definition print.h:46
int kissat_report_dummy_to_avoid_warning
Definition report.c:159