aboutsummaryrefslogtreecommitdiff
path: root/src/solvers/h48/gendata_h48.h
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-04-19 12:28:52 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-04-19 12:28:52 +0200
commit3485be851f4fff1c9c6fe621f0619d2b4103bc06 (patch)
tree894197f164a7ef66801ae3a701fb10a3c1e3f5e3 /src/solvers/h48/gendata_h48.h
parent691da8f06614418ed847bdeefa4e708c372a3ecf (diff)
downloadnissy-core-3485be851f4fff1c9c6fe621f0619d2b4103bc06.tar.gz
nissy-core-3485be851f4fff1c9c6fe621f0619d2b4103bc06.zip
Improved logging, especially for solve
Diffstat (limited to 'src/solvers/h48/gendata_h48.h')
-rw-r--r--src/solvers/h48/gendata_h48.h50
1 files changed, 29 insertions, 21 deletions
diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h
index 4478e9e..18157dc 100644
--- a/src/solvers/h48/gendata_h48.h
+++ b/src/solvers/h48/gendata_h48.h
@@ -87,7 +87,7 @@ gendata_h48(gendata_h48_arg_t arg[static 1])
87 return size; /* Dry-run */ 87 return size; /* Dry-run */
88 88
89 if (arg->buf_size < size) { 89 if (arg->buf_size < size) {
90 LOG("Error computing H48 data: buffer is too small " 90 LOG("[H48 gendata] Error data: buffer is too small "
91 "(needed %" PRId64 " bytes but received %" PRId64 ")\n", 91 "(needed %" PRId64 " bytes but received %" PRId64 ")\n",
92 size, arg->buf_size); 92 size, arg->buf_size);
93 return NISSY_ERROR_BUFFER_SIZE; 93 return NISSY_ERROR_BUFFER_SIZE;
@@ -106,22 +106,24 @@ gendata_h48(gendata_h48_arg_t arg[static 1])
106 } else if (arg->k == 2) { 106 } else if (arg->k == 2) {
107 gendata_h48k2(arg); 107 gendata_h48k2(arg);
108 } else { 108 } else {
109 LOG("Cannot generate data for h = %" PRIu8 " and k = %" PRIu8 109 LOG("[H48 gendata] Error: cannot generate data for h = %" PRIu8
110 " (not implemented yet)\n", arg->h, arg->k); 110 " and k = %" PRIu8 " (not implemented yet)\n",
111 arg->h, arg->k);
111 return NISSY_ERROR_INVALID_SOLVER; 112 return NISSY_ERROR_INVALID_SOLVER;
112 } 113 }
113 114
114 r = readtableinfo(arg->buf_size, arg->buf, &cocsepinfo); 115 r = readtableinfo(arg->buf_size, arg->buf, &cocsepinfo);
115 if (r != NISSY_OK) { 116 if (r != NISSY_OK) {
116 LOG("gendata_h48: could not read info for cocsep table\n"); 117 LOG("[H48 gendata] Error: could not read info "
118 "for cocsep table\n");
117 return NISSY_ERROR_UNKNOWN; 119 return NISSY_ERROR_UNKNOWN;
118 } 120 }
119 121
120 cocsepinfo.next = cocsepsize; 122 cocsepinfo.next = cocsepsize;
121 r = writetableinfo(&cocsepinfo, arg->buf_size, arg->buf); 123 r = writetableinfo(&cocsepinfo, arg->buf_size, arg->buf);
122 if (r != NISSY_OK) { 124 if (r != NISSY_OK) {
123 LOG("gendata_h48: could not write info for cocsep table" 125 LOG("[H48 gendata] Error: could not write info for "
124 " with updated 'next' value\n"); 126 "cocsep table with updated 'next' value\n");
125 return NISSY_ERROR_UNKNOWN; 127 return NISSY_ERROR_UNKNOWN;
126 } 128 }
127 129
@@ -149,21 +151,23 @@ gendata_h48(gendata_h48_arg_t arg[static 1])
149 151
150 r = readtableinfo_n(arg->buf_size, arg->buf, 2, &h48info); 152 r = readtableinfo_n(arg->buf_size, arg->buf, 2, &h48info);
151 if (r != NISSY_OK) { 153 if (r != NISSY_OK) {
152 LOG("gendata_h48: could not read info for h48 table\n"); 154 LOG("[H48 gendata] Error: could not read info "
155 "for h48 table\n");
153 return NISSY_ERROR_UNKNOWN; 156 return NISSY_ERROR_UNKNOWN;
154 } 157 }
155 h48info.next = h48size; 158 h48info.next = h48size;
156 r = writetableinfo(&h48info, 159 r = writetableinfo(&h48info,
157 arg->buf_size - cocsepsize, (char *)arg->buf + cocsepsize); 160 arg->buf_size - cocsepsize, (char *)arg->buf + cocsepsize);
158 if (r != NISSY_OK) { 161 if (r != NISSY_OK) {
159 LOG("gendata_h48: could not write info for h48 table\n"); 162 LOG("[H48 gendata] Error: could not write info "
163 "for h48 table\n");
160 return NISSY_ERROR_UNKNOWN; 164 return NISSY_ERROR_UNKNOWN;
161 } 165 }
162 166
163 if (arg->k == 2) { 167 if (arg->k == 2) {
164 r = readtableinfo_n(arg->buf_size, arg->buf, 3, &fallbackinfo); 168 r = readtableinfo_n(arg->buf_size, arg->buf, 3, &fallbackinfo);
165 if (r != NISSY_OK) { 169 if (r != NISSY_OK) {
166 LOG("gendata_h48: could not read info for h48 " 170 LOG("[H48 gendata] Error: could not read info for h48 "
167 "fallback table\n"); 171 "fallback table\n");
168 return NISSY_ERROR_UNKNOWN; 172 return NISSY_ERROR_UNKNOWN;
169 } 173 }
@@ -173,8 +177,8 @@ gendata_h48(gendata_h48_arg_t arg[static 1])
173 r = writetableinfo(&fallbackinfo, 177 r = writetableinfo(&fallbackinfo,
174 arg->buf_size - of, (char *)arg->buf + of); 178 arg->buf_size - of, (char *)arg->buf + of);
175 if (r != NISSY_OK) { 179 if (r != NISSY_OK) {
176 LOG("gendata_h48: could not write info for h48 " 180 LOG("[H48 gendata] Error: could not write info for "
177 "fallback table\n"); 181 "h48 fallback table\n");
178 return NISSY_ERROR_UNKNOWN; 182 return NISSY_ERROR_UNKNOWN;
179 } 183 }
180 } 184 }
@@ -233,7 +237,7 @@ gendata_h48h0k4(gendata_h48_arg_t arg[static 1])
233 bfsarg[t].table_mutex[tt] = &table_mutex[tt]; 237 bfsarg[t].table_mutex[tt] = &table_mutex[tt];
234 } 238 }
235 for (done = 1, d = 1; done < h48max && d <= arg->maxdepth; d++) { 239 for (done = 1, d = 1; done < h48max && d <= arg->maxdepth; d++) {
236 LOG("h48: generating depth %" PRId64 "\n", d); 240 LOG("[H48 gendata] Generating depth %" PRId64 "\n", d);
237 241
238 for (t = 0; t < THREADS; t++) { 242 for (t = 0; t < THREADS; t++) {
239 bfsarg[t].depth = d; 243 bfsarg[t].depth = d;
@@ -252,7 +256,7 @@ gendata_h48h0k4(gendata_h48_arg_t arg[static 1])
252 done += cc; 256 done += cc;
253 arg->info.distribution[d] = cc; 257 arg->info.distribution[d] = cc;
254 258
255 LOG("found %" PRId64 "\n", cc); 259 LOG("[H48 gendata] Found %" PRId64 "\n", cc);
256 } 260 }
257 261
258 arg->info.maxvalue = d - 1; 262 arg->info.maxvalue = d - 1;
@@ -382,7 +386,7 @@ gendata_h48k2(gendata_h48_arg_t arg[static 1])
382 table = (uint8_t *)arg->h48buf + INFOSIZE; 386 table = (uint8_t *)arg->h48buf + INFOSIZE;
383 memset(table, 0xFF, H48_TABLESIZE(arg->h, arg->k)); 387 memset(table, 0xFF, H48_TABLESIZE(arg->h, arg->k));
384 388
385 LOG("Computing depth <=%" PRIu8 "\n", shortdepth) 389 LOG("[H48 gendata] Computing depth <=%" PRIu8 "\n", shortdepth)
386 h48map_create(&shortcubes, capacity, randomizer); 390 h48map_create(&shortcubes, capacity, randomizer);
387 shortarg = (gendata_h48short_arg_t) { 391 shortarg = (gendata_h48short_arg_t) {
388 .maxdepth = shortdepth, 392 .maxdepth = shortdepth,
@@ -392,7 +396,7 @@ gendata_h48k2(gendata_h48_arg_t arg[static 1])
392 .map = &shortcubes 396 .map = &shortcubes
393 }; 397 };
394 gendata_h48short(&shortarg); 398 gendata_h48short(&shortarg);
395 LOG("Computed %" PRIu64 " positions\n", shortarg.map->n); 399 LOG("[H48 gendata] Computed %" PRIu64 " positions\n", shortarg.map->n);
396 400
397 if (arg->base >= 20) 401 if (arg->base >= 20)
398 arg->base = base[arg->h]; 402 arg->base = base[arg->h];
@@ -459,7 +463,8 @@ gendata_h48k2_runthread(void *arg)
459 pthread_mutex_unlock(dfsarg->shortcubes_mutex); 463 pthread_mutex_unlock(dfsarg->shortcubes_mutex);
460 464
461 if (count % UINT64_C(1000000) == 0) 465 if (count % UINT64_C(1000000) == 0)
462 LOG("Processing %" PRIu64 "th short cube\n", count); 466 LOG("[H48 gendata] Processing %" PRIu64
467 "th short cube\n", count);
463 468
464 if (kv.val < dfsarg->shortdepth) { 469 if (kv.val < dfsarg->shortdepth) {
465 coord = kv.key >> (int64_t)(11 - dfsarg->h); 470 coord = kv.key >> (int64_t)(11 - dfsarg->h);
@@ -780,15 +785,16 @@ gendata_h48_derive(uint8_t h, const void *fulltable, void *buf)
780 785
781 bufsize = COCSEP_FULLSIZE + INFOSIZE; 786 bufsize = COCSEP_FULLSIZE + INFOSIZE;
782 if (readtableinfo(bufsize, buf, &cocsepinfo) != NISSY_OK) { 787 if (readtableinfo(bufsize, buf, &cocsepinfo) != NISSY_OK) {
783 LOG("gendata_h48: could not read info for cocsep table\n"); 788 LOG("[H48 derive gendata] Error: could not read info for "
789 "cocsep table\n");
784 goto gendata_h48_derive_error; 790 goto gendata_h48_derive_error;
785 } 791 }
786 792
787 cocsepinfo.next = cocsepsize; 793 cocsepinfo.next = cocsepsize;
788 bufsize = COCSEP_FULLSIZE + INFOSIZE; 794 bufsize = COCSEP_FULLSIZE + INFOSIZE;
789 if (writetableinfo(&cocsepinfo, bufsize, buf) != NISSY_OK) { 795 if (writetableinfo(&cocsepinfo, bufsize, buf) != NISSY_OK) {
790 LOG("gendata_h48_derive: could not write info for cocsep table" 796 LOG("[H48 derive gendata] Error: could not write info for "
791 " with updated 'next' value\n"); 797 "cocsep table with updated 'next' value\n");
792 goto gendata_h48_derive_error; 798 goto gendata_h48_derive_error;
793 } 799 }
794 800
@@ -801,7 +807,8 @@ gendata_h48_derive(uint8_t h, const void *fulltable, void *buf)
801 h48max = H48_COORDMAX(fulltableinfo.h48h); 807 h48max = H48_COORDMAX(fulltableinfo.h48h);
802 for (i = 0; i < h48max; i++) { 808 for (i = 0; i < h48max; i++) {
803 if (i % INT64_C(1000000000) == 0 && i > 0) 809 if (i % INT64_C(1000000000) == 0 && i > 0)
804 LOG("Processing %" PRId64 "th coordinate\n", i); 810 LOG("[H48 derive gendata] Processing %" PRId64
811 "th coordinate\n", i);
805 j = i >> (int64_t)(fulltableinfo.h48h - h); 812 j = i >> (int64_t)(fulltableinfo.h48h - h);
806 val_full = get_h48_pval(h48full, i, arg.k); 813 val_full = get_h48_pval(h48full, i, arg.k);
807 val_derive = get_h48_pval(h48derive, j, arg.k); 814 val_derive = get_h48_pval(h48derive, j, arg.k);
@@ -813,7 +820,8 @@ gendata_h48_derive(uint8_t h, const void *fulltable, void *buf)
813 820
814 bufsize = arg.buf_size - COCSEP_FULLSIZE - INFOSIZE; 821 bufsize = arg.buf_size - COCSEP_FULLSIZE - INFOSIZE;
815 if (writetableinfo(&arg.info, bufsize, arg.h48buf) != NISSY_OK) { 822 if (writetableinfo(&arg.info, bufsize, arg.h48buf) != NISSY_OK) {
816 LOG("gendata_h48_derive: could not write info for table\n"); 823 LOG("H48 derive gendata] Error: could not write info "
824 "for table\n");
817 goto gendata_h48_derive_error; 825 goto gendata_h48_derive_error;
818 } 826 }
819 827

Generated with cgit - Back to sebastiano.tronto.net