nissy-fmc

A Rubik's cube FMC assistant
git clone https://git.tronto.net/nissy-fmc
Download | Log | Files | Refs | README | LICENSE

commit ecd8bbf2c0b7a4ca20c9cdc5f8f26836d4082c36
parent b5a692702643c8f3e77765ca38677e076bce2b59
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date:   Thu,  3 Mar 2022 19:02:08 +0100

Added messages about generating pruning tables

Diffstat:
MTODO.md | 8+-------
Msrc/pruning.c | 13+++++++++++++
Msrc/shell.c | 34++++++++++++++++++++++++++++++++++
Msrc/shell.h | 1+
Msrc/symcoord.c | 4++--
5 files changed, 51 insertions(+), 9 deletions(-)

diff --git a/TODO.md b/TODO.md @@ -4,16 +4,11 @@ This is a list of things that I would like to add or change at some point. It's more of a personal reminder than anything else. ## For version 2.1 -### Scrambles -* dr and htr scrambles ### Memory management * Free large tables from memory before exit (this is not strictly necessary, but can help with WSL bugs) ### Installation -* At startup, check if tables are all there; if not, print an error message - suggesting to run `nissy gen -t 8` (or more than 8). Is it - possible to make table generation at least 3x faster? -* make 8 threads default for gen? +* Is it possible to make table generation at least 3x faster? ### Documentation * Write an examples.md file * More screenshots! @@ -85,7 +80,6 @@ including e.g. solutions that were not shown because -c) open up the door for a web-based version or graphical clients ### Cleanup -* Remove khuge from everywhere * sort again functions alphabetically in their files * more stuff to load at start (or when suitable command is called) rather than when called directly, to avoid nasty problems with threading diff --git a/src/pruning.c b/src/pruning.c @@ -135,6 +135,18 @@ genptable(PruneData *pd, int nthreads) return; } + if (nthreads < 4) { + fprintf(stderr, + "--- Warning ---\n" + "You are using only %d threads to generate the pruning" + "tables. This can take a while." + "Unless you did this intentionally, you should re-run" + "this command with `-t 4' or more.\n" + "---------------\n\n", nthreads + ); + } + + /* For the first steps we proceed the same way for compact and not */ compact = pd->compact; pd->compact = false; @@ -144,6 +156,7 @@ genptable(PruneData *pd, int nthreads) fprintf(stderr, "Cannot load %s, generating it with %d threads\n", pd->filename, nthreads); + memset(pd->ptable, ~(uint8_t)0, ptablesize(pd)*sizeof(entry_group_t)); ptable_update(pd, (Cube){0}, 0); diff --git a/src/shell.c b/src/shell.c @@ -3,6 +3,27 @@ static void cleanwhitespaces(char *line); static int parseline(char *line, char **v); +bool +checkfiles() +{ + /* TODO: add more checks (other files, use checksum...) */ + FILE *f; + char fname[strlen(tabledir)+100]; + int i; + + for (i = 0; allpd[i] != NULL; i++) { + strcpy(fname, tabledir); + strcpy(fname, "/"); + strcpy(fname, allpd[i]->filename); + if ((f = fopen(fname, "rb")) == NULL) + return false; + else + fclose(f); + } + + return true; +} + static void cleanwhitespaces(char *line) { @@ -119,6 +140,19 @@ launch(bool batchmode) int main(int argc, char *argv[]) { + init_env(); + + if (!checkfiles()) { + fprintf(stderr, + "--- Warning ---\n" + "Some pruning tables are missing or unreadable." + "You can generate them with `nissy gen -t 4'\n" + "Here `4' is the number of threads. Use more if your" + "CPU has them, or expect it to take a while.\n" + "---------------\n\n" + ); + } + if (argc > 1) { if (!strcmp(argv[1], "-b")) { launch(true); diff --git a/src/shell.h b/src/shell.h @@ -7,6 +7,7 @@ #define MAXTOKENLEN 255 #define MAXNTOKENS 255 +bool checkfiles(); void exec_args(int c, char **v); void launch(bool batchmode); diff --git a/src/symcoord.c b/src/symcoord.c @@ -53,10 +53,10 @@ sd_eofbepos_16 = { .trans = trans_group_udfix }; -static int nsymdata = 2; static SymData * all_sd[] = { &sd_cp_16, &sd_eofbepos_16, + NULL }; @@ -403,7 +403,7 @@ init_symcoord() init_coord(); - for (i = 0; i < nsymdata; i++) + for (i = 0; all_sd[i] != NULL; i++) gensym(all_sd[i]); }