aboutsummaryrefslogtreecommitdiff
path: root/tools/000_gendata
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 /tools/000_gendata
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 'tools/000_gendata')
-rw-r--r--tools/000_gendata/gendata.c21
1 files changed, 3 insertions, 18 deletions
diff --git a/tools/000_gendata/gendata.c b/tools/000_gendata/gendata.c
index 66c4864..f2da890 100644
--- a/tools/000_gendata/gendata.c
+++ b/tools/000_gendata/gendata.c
@@ -1,13 +1,10 @@
1#include "../tool.h" 1#include "../tool.h"
2#include "../expected_distributions.h"
3 2
4char *solver; 3char *solver;
5uint64_t *expected;
6 4
7static void 5static void
8run(void) { 6run(void) {
9 int64_t size; 7 int64_t size;
10 bool consistent, expected;
11 char filename[1024], dataid[NISSY_SIZE_DATAID]; 8 char filename[1024], dataid[NISSY_SIZE_DATAID];
12 unsigned char *buf; 9 unsigned char *buf;
13 10
@@ -18,20 +15,14 @@ run(void) {
18 case -2: 15 case -2:
19 goto gendata_run_finish; 16 goto gendata_run_finish;
20 default: 17 default:
21 nissy_datainfo(size, buf); 18 if (nissy_checkdata(solver, size, buf) == NISSY_OK) {
22 consistent = nissy_checkdata(size, buf) == 0;
23 expected = check_distribution(solver, size, buf);
24 if (consistent && expected) {
25 printf("\n"); 19 printf("\n");
26 printf("Generated %" PRId64 " bytes.\n", size); 20 printf("Generated %" PRId64 " bytes.\n", size);
27 sprintf(filename, "tables/%s", dataid); 21 sprintf(filename, "tables/%s", dataid);
28 writetable(buf, size, filename); 22 writetable(buf, size, filename);
23 } else {
24 printf("Error: table generated incorrectly!\n");
29 } 25 }
30 if (!consistent)
31 printf("Error: table is not consistent with info"
32 " (nissy_checkdata() failed)\n");
33 if (!expected)
34 printf("Error: distribution is not as expected\n");
35 break; 26 break;
36 } 27 }
37 28
@@ -40,8 +31,6 @@ gendata_run_finish:
40} 31}
41 32
42int main(int argc, char **argv) { 33int main(int argc, char **argv) {
43 uint8_t h, k;
44
45 if (argc < 2) { 34 if (argc < 2) {
46 printf("Error: not enough arguments. " 35 printf("Error: not enough arguments. "
47 "A solver must be given.\n"); 36 "A solver must be given.\n");
@@ -49,11 +38,7 @@ int main(int argc, char **argv) {
49 } 38 }
50 39
51 solver = argv[1]; 40 solver = argv[1];
52 parse_h48_hk(solver, &h, &k);
53 expected = expected_h48[h][k];
54
55 nissy_setlogger(log_stderr, NULL); 41 nissy_setlogger(log_stderr, NULL);
56
57 timerun(run); 42 timerun(run);
58 43
59 return 0; 44 return 0;

Generated with cgit - Back to sebastiano.tronto.net