aboutsummaryrefslogtreecommitdiff
path: root/src/solvers/coord/checkdata.h
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-05-19 17:45:14 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-05-19 17:45:14 +0200
commit62d87e063318cc4c842b1b2d8c184f48aeaf6659 (patch)
tree832bf338232c477975bea69f7370ca13f350fb07 /src/solvers/coord/checkdata.h
parent8b94d135429a9f3253cc7f25a1453b412065c4a0 (diff)
downloadnissy-core-62d87e063318cc4c842b1b2d8c184f48aeaf6659.tar.gz
nissy-core-62d87e063318cc4c842b1b2d8c184f48aeaf6659.zip
Refactored checkdata
Relevant changes include: - Changed the signature of nissy_checkdata(). - Removed expected_distribution.h from tools; this data is now included in each solver's src/ code. - Removed distribution check for cocsep; may add back later.
Diffstat (limited to 'src/solvers/coord/checkdata.h')
-rw-r--r--src/solvers/coord/checkdata.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/solvers/coord/checkdata.h b/src/solvers/coord/checkdata.h
new file mode 100644
index 0000000..81394c7
--- /dev/null
+++ b/src/solvers/coord/checkdata.h
@@ -0,0 +1,65 @@
1STATIC long long checkdata_coord(
2 const char *, unsigned long long n, const unsigned char [n]);
3
4STATIC long long
5checkdata_coord(
6 const char *solver,
7 unsigned long long data_size,
8 const unsigned char data[data_size]
9)
10{
11 coord_t *coord;
12 const unsigned char *table;
13 tableinfo_t info;
14 int64_t err;
15 uint64_t actual_distribution[INFO_DISTRIBUTION_LEN];
16
17 if ((size_t)data % 8 != 0) {
18 LOG("[checkdata] Error: buffer is not 8-byte aligned\n");
19 return NISSY_ERROR_DATA;
20 }
21
22 parse_coord_and_axis(solver, &coord, NULL);
23 if (coord == NULL) {
24 LOG("[cehckdata] Unknown coordinate solver '%s'\n", solver);
25 return NISSY_ERROR_DATA;
26 }
27
28 table = data + INFOSIZE;
29 err = readtableinfo(data_size, data, &info);
30 if (err != NISSY_OK) {
31 LOG("[checkdata] Data is corrupt\n");
32 return err;
33 }
34
35 if (info.type != TABLETYPE_PRUNING) {
36 LOG("[checkdata] Skipping '%s'\n", info.solver);
37 table += info.next;
38 err = readtableinfo_n(data_size, data, 2, &info);
39 if (err != NISSY_OK) {
40 LOG("[checkdata] Data is corrupt\n");
41 return err;
42 }
43 }
44
45 LOG("[checkdata] Checking distribution for '%s' from "
46 "table preamble\n", info.solver);
47 if (!distribution_equal(coord->pruning_distribution,
48 info.distribution, coord->pruning_max)) {
49 LOG("[checkdata] Distribution from the table preamble does "
50 "not match the expected one\n");
51 return NISSY_ERROR_DATA;
52 }
53
54 LOG("\n[checkdata] Checking distribution for '%s' from "
55 "actual table\n", info.solver);
56 getdistribution(table, actual_distribution, &info);
57 if (!distribution_equal(coord->pruning_distribution,
58 actual_distribution, coord->pruning_max)) {
59 LOG("[checkdata] Distribution from the actual table does "
60 "not match the expected one\n");
61 return NISSY_ERROR_DATA;
62 }
63
64 return NISSY_OK;
65}

Generated with cgit - Back to sebastiano.tronto.net