diff options
| author | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-12-10 18:15:20 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-12-10 18:15:20 +0100 |
| commit | 6c28dec4a111ad73f8ac17c89305a951371f765d (patch) | |
| tree | 0a7ac690a0957aa29fb37c91bc8c2bb340da542f | |
| parent | d8a94976ebad9c55aca6b0443c5f92d892e12dd0 (diff) | |
| download | nissy-6c28dec4a111ad73f8ac17c89305a951371f765d.tar.gz nissy-6c28dec4a111ad73f8ac17c89305a951371f765d.zip | |
Added gen command and modified installation instructions for tables
| -rw-r--r-- | INSTALL | 29 | ||||
| -rw-r--r-- | README.md | 39 | ||||
| -rw-r--r-- | TODO.md | 8 | ||||
| -rw-r--r-- | doc/nissy.1 | 8 | ||||
| -rwxr-xr-x | nissy | bin | 169184 -> 0 bytes | |||
| -rw-r--r-- | nissy-2.0beta5.tar.gz | bin | 54368 -> 55883 bytes | |||
| -rwxr-xr-x | nissy.exe | bin | 686582 -> 691884 bytes | |||
| -rw-r--r-- | src/commands.c | 55 | ||||
| -rw-r--r-- | src/pruning.c | 15 | ||||
| -rw-r--r-- | src/pruning.h | 4 |
10 files changed, 133 insertions, 25 deletions
| @@ -11,7 +11,7 @@ pruning table. If so, about 200Mb should be enough. | |||
| 11 | ## On Windows | 11 | ## On Windows |
| 12 | 12 | ||
| 13 | Try downloading and executing in a terminal the file nissy.exe, then | 13 | Try downloading and executing in a terminal the file nissy.exe, then |
| 14 | follow the instructions in the UNIX section below for downloading and | 14 | follow the instructions in the Tables section below for |
| 15 | installing the pruning tables. | 15 | installing the pruning tables. |
| 16 | If nissy.exe does not work, you can try following the UNIX instructions | 16 | If nissy.exe does not work, you can try following the UNIX instructions |
| 17 | in WSL (Windows Subsystem for Linux) or in a similar environment. | 17 | in WSL (Windows Subsystem for Linux) or in a similar environment. |
| @@ -22,11 +22,28 @@ Sorry for the inconvenience, I don't have a Windows machine to test this on. | |||
| 22 | 22 | ||
| 23 | Edit the Makefile to match your local configuration (usually not necessary, but you | 23 | Edit the Makefile to match your local configuration (usually not necessary, but you |
| 24 | may want to change the PREFIX variable) and run make, followed by make install. | 24 | may want to change the PREFIX variable) and run make, followed by make install. |
| 25 | After that, you need to download some files and manually save them to your NISSYDATA | 25 | Follows the instructions below to install the pruning tables. |
| 26 | folder (se manual page, ENVIRONMENT section). If you don't do it nissy can compute | 26 | |
| 27 | these files when needed and save them in the correct folders, but some of them | 27 | ## Tables |
| 28 | take hours to generate even for a powerful computer (for reference, the huge pruning | 28 | Nissy needs to generate certain large tables to work. These tables are by default |
| 29 | table takes about 20 hours on my laptop). | 29 | generated the first time they are needed (e.g the first time you ask to solve a |
| 30 | certain step) and then saved to a file. The following times nissy simply loads the | ||
| 31 | corresponding file from the hard disk. | ||
| 32 | |||
| 33 | The very large table for optimal solving can take some time to generate (about 20 | ||
| 34 | minutes on my fairly old but decent laptop, using 8 CPU threads). All other | ||
| 35 | tables are much faster. | ||
| 36 | |||
| 37 | You can ask nissy to generate all the tables it will ever need with the gen | ||
| 38 | command. It is recommended to use more than one thread, if your CPU has them. | ||
| 39 | For example, you can run: | ||
| 40 | |||
| 41 | nissy gen -t 8 | ||
| 42 | |||
| 43 | to generate all tables using 8 threads. | ||
| 44 | |||
| 45 | Alternatively, you can simply download all the tables and copy them into the | ||
| 46 | correct folder (see manual page, ENVIRONMENT section). | ||
| 30 | Choose one of the following: | 47 | Choose one of the following: |
| 31 | https://math.uni.lu/tronto/nissy/nissy-tables-full.zip | 48 | https://math.uni.lu/tronto/nissy/nissy-tables-full.zip |
| 32 | https://math.uni.lu/tronto/nissy/nissy-tables-full.tar.gz | 49 | https://math.uni.lu/tronto/nissy/nissy-tables-full.tar.gz |
| @@ -31,7 +31,7 @@ pruning table. If so, about 200Mb should be enough. | |||
| 31 | ### On Windows | 31 | ### On Windows |
| 32 | 32 | ||
| 33 | Try downloading and executing in a terminal the file nissy.exe, then | 33 | Try downloading and executing in a terminal the file nissy.exe, then |
| 34 | follow the instructions in the UNIX section below for downloading and | 34 | follow the instructions in the **Tables** section below for |
| 35 | installing the pruning tables. | 35 | installing the pruning tables. |
| 36 | If nissy.exe does not work, you can try following the UNIX instructions | 36 | If nissy.exe does not work, you can try following the UNIX instructions |
| 37 | in WSL (Windows Subsystem for Linux) or in a similar environment. | 37 | in WSL (Windows Subsystem for Linux) or in a similar environment. |
| @@ -40,17 +40,32 @@ Sorry for the inconvenience, I don't have a Windows machine to test this on. | |||
| 40 | 40 | ||
| 41 | ### On a UNIX system: | 41 | ### On a UNIX system: |
| 42 | 42 | ||
| 43 | You can download the source code for the latest version from git or simply clone | ||
| 44 | the repo with `git clone https://github.com/sebastianotronto/nissy`. | ||
| 45 | |||
| 46 | Edit the Makefile to match your local configuration (usually not necessary, but you | 43 | Edit the Makefile to match your local configuration (usually not necessary, but you |
| 47 | may want to change the `PREFIX` variable) and run `make`, followed by `make install`. | 44 | may want to change the `PREFIX` variable) and run `make`, followed by `make install`. |
| 48 | After that, you need to download some files and manually save them to your `NISSYDATA` | 45 | Follows the instructions below to install the pruning tables. |
| 49 | folder (see manual page, ENVIRONMENT section). If you don't do it nissy can compute | 46 | |
| 50 | these files when needed and save them in the correct folders, but some of them | 47 | ### Tables |
| 51 | take hours to generate even for a powerful computer (for reference, the huge pruning | 48 | Nissy needs to generate certain large tables to work. These tables are by default |
| 52 | table takes about 20 hours on my laptop). | 49 | generated the first time they are needed (e.g the first time you ask to solve a |
| 50 | certain step) and then saved to a file. The following times nissy simply loads the | ||
| 51 | corresponding file from the hard disk. | ||
| 52 | |||
| 53 | The very large table for optimal solving can take some time to generate (about 20 | ||
| 54 | minutes on my fairly old but decent laptop, using 8 CPU threads). All other | ||
| 55 | tables are much faster. | ||
| 56 | |||
| 57 | You can ask nissy to generate all the tables it will ever need with the **gen** | ||
| 58 | command. It is recommended to use more than one thread, if your CPU has them. | ||
| 59 | For example, you can run: | ||
| 60 | |||
| 61 | ``` | ||
| 62 | nissy gen -t 8 | ||
| 63 | ``` | ||
| 64 | |||
| 65 | to generate all tables using 8 threads. | ||
| 53 | 66 | ||
| 67 | Alternatively, you can simply download all the tables and copy them into the | ||
| 68 | correct folder (see manual page, `ENVIRONMENT` section). | ||
| 54 | Choose one of the following: | 69 | Choose one of the following: |
| 55 | 70 | ||
| 56 | | |.zip|.tar.gz| | 71 | | |.zip|.tar.gz| |
| @@ -58,9 +73,9 @@ Choose one of the following: | |||
| 58 | |Full (~720Mb)|[full.zip](https://math.uni.lu/tronto/nissy/nissy-tables-full.zip)|[full.tar.gz](https://math.uni.lu/tronto/nissy/nissy-tables-full.tar.gz)| | 73 | |Full (~720Mb)|[full.zip](https://math.uni.lu/tronto/nissy/nissy-tables-full.zip)|[full.tar.gz](https://math.uni.lu/tronto/nissy/nissy-tables-full.tar.gz)| |
| 59 | |No huge table (~90Mb)|[nohuge.zip](https://math.uni.lu/tronto/nissy/nissy-tables-nohuge.zip)|[nohuge.tar.gz](https://math.uni.lu/tronto/nissy/nissy-tables-nohuge.tar.gz)| | 74 | |No huge table (~90Mb)|[nohuge.zip](https://math.uni.lu/tronto/nissy/nissy-tables-nohuge.zip)|[nohuge.tar.gz](https://math.uni.lu/tronto/nissy/nissy-tables-nohuge.tar.gz)| |
| 60 | 75 | ||
| 61 | extract the archive and copy the `tables` folder into `NISSIDATA` (paste there | 76 | extract the archive and copy the tables folder into `NISSIDATA` (paste there |
| 62 | the whole folder, not the single files). The `nohuge` files are much smaller and | 77 | the whole folder, not file by file). The "nohuge" files are much smaller and do not |
| 63 | do not contain the huge pruning table for the optimal solver. | 78 | contain the huge pruning table for the optimal solver. |
| 64 | 79 | ||
| 65 | ## Structure of the code | 80 | ## Structure of the code |
| 66 | 81 | ||
| @@ -54,16 +54,10 @@ and just use previous values for all 3 axes. | |||
| 54 | ## Coordinates, symmetries, pruning tables | 54 | ## Coordinates, symmetries, pruning tables |
| 55 | * Cleanup symcoord.c: some coordinates and symdata are never actually used; | 55 | * Cleanup symcoord.c: some coordinates and symdata are never actually used; |
| 56 | remove also sd_eofbepos and just use sd_coud for khuge (this changes the | 56 | remove also sd_eofbepos and just use sd_coud for khuge (this changes the |
| 57 | coordinate so the whole table must be generated again!) | 57 | coordinate so the whole table must be generated again!) or viceversa |
| 58 | * Use pruning values mod 4 instead of mod 16 (or maybe not, I like the | 58 | * Use pruning values mod 4 instead of mod 16 (or maybe not, I like the |
| 59 | current system) | 59 | current system) |
| 60 | 60 | ||
| 61 | ### Memory management | ||
| 62 | * fail gracefully when there is not enough memory to load a large table | ||
| 63 | * free tables from memory when not used | ||
| 64 | * optionally run in low-memory friendly version (no tables above a few Mb); | ||
| 65 | this can be useful e.g. for embedded devices | ||
| 66 | |||
| 67 | ### Structural changes | 61 | ### Structural changes |
| 68 | * client/server architecture: run a server process in the background so that | 62 | * client/server architecture: run a server process in the background so that |
| 69 | multiple client processess can send it queries and get results; this would | 63 | multiple client processess can send it queries and get results; this would |
diff --git a/doc/nissy.1 b/doc/nissy.1 index e8ce7ea..992745d 100644 --- a/doc/nissy.1 +++ b/doc/nissy.1 | |||
| @@ -36,6 +36,14 @@ are the following: | |||
| 36 | .It Nm commands | 36 | .It Nm commands |
| 37 | List all available commands. | 37 | List all available commands. |
| 38 | . | 38 | . |
| 39 | .It Nm gen Op Fl t Ar N | ||
| 40 | Generate all tables used by nissy. Run this to complete your installation. | ||
| 41 | If | ||
| 42 | .Ar N | ||
| 43 | is specified, | ||
| 44 | .Ar N | ||
| 45 | CPU threads will be used (defaults to 1). | ||
| 46 | . | ||
| 39 | .It Nm help Op Ar command | 47 | .It Nm help Op Ar command |
| 40 | Display help. If no | 48 | Display help. If no |
| 41 | .Ar command | 49 | .Ar command |
| Binary files differ | |||
diff --git a/nissy-2.0beta5.tar.gz b/nissy-2.0beta5.tar.gz index 7c63ba5..1fa13b3 100644 --- a/nissy-2.0beta5.tar.gz +++ b/nissy-2.0beta5.tar.gz | |||
| Binary files differ | |||
| Binary files differ | |||
diff --git a/src/commands.c b/src/commands.c index 5e01e67..287ee67 100644 --- a/src/commands.c +++ b/src/commands.c | |||
| @@ -3,12 +3,14 @@ | |||
| 3 | /* Arg parsing functions *****************************************************/ | 3 | /* Arg parsing functions *****************************************************/ |
| 4 | 4 | ||
| 5 | CommandArgs * solve_parse_args(int c, char **v); | 5 | CommandArgs * solve_parse_args(int c, char **v); |
| 6 | CommandArgs * gen_parse_args(int c, char **v); | ||
| 6 | CommandArgs * help_parse_args(int c, char **v); | 7 | CommandArgs * help_parse_args(int c, char **v); |
| 7 | CommandArgs * print_parse_args(int c, char **v); | 8 | CommandArgs * print_parse_args(int c, char **v); |
| 8 | CommandArgs * parse_no_arg(int c, char **v); | 9 | CommandArgs * parse_no_arg(int c, char **v); |
| 9 | 10 | ||
| 10 | /* Exec functions ************************************************************/ | 11 | /* Exec functions ************************************************************/ |
| 11 | 12 | ||
| 13 | static void gen_exec(CommandArgs *args); | ||
| 12 | static void solve_exec(CommandArgs *args); | 14 | static void solve_exec(CommandArgs *args); |
| 13 | static void steps_exec(CommandArgs *args); | 15 | static void steps_exec(CommandArgs *args); |
| 14 | static void commands_exec(CommandArgs *args); | 16 | static void commands_exec(CommandArgs *args); |
| @@ -34,6 +36,15 @@ solve_cmd = { | |||
| 34 | }; | 36 | }; |
| 35 | 37 | ||
| 36 | Command | 38 | Command |
| 39 | gen_cmd = { | ||
| 40 | .name = "gen", | ||
| 41 | .usage = "gen [-t N]", | ||
| 42 | .description = "Generate all tables [using N threads]", | ||
| 43 | .parse_args = gen_parse_args, | ||
| 44 | .exec = gen_exec | ||
| 45 | }; | ||
| 46 | |||
| 47 | Command | ||
| 37 | steps_cmd = { | 48 | steps_cmd = { |
| 38 | .name = "steps", | 49 | .name = "steps", |
| 39 | .usage = "steps", | 50 | .usage = "steps", |
| @@ -89,6 +100,7 @@ version_cmd = { | |||
| 89 | 100 | ||
| 90 | Command *commands[NCOMMANDS] = { | 101 | Command *commands[NCOMMANDS] = { |
| 91 | &commands_cmd, | 102 | &commands_cmd, |
| 103 | &gen_cmd, | ||
| 92 | &help_cmd, | 104 | &help_cmd, |
| 93 | &print_cmd, | 105 | &print_cmd, |
| 94 | &quit_cmd, | 106 | &quit_cmd, |
| @@ -173,6 +185,34 @@ solve_parse_args(int c, char **v) | |||
| 173 | } | 185 | } |
| 174 | 186 | ||
| 175 | CommandArgs * | 187 | CommandArgs * |
| 188 | gen_parse_args(int c, char **v) | ||
| 189 | { | ||
| 190 | int val; | ||
| 191 | CommandArgs *a = new_args(); | ||
| 192 | |||
| 193 | a->opts->nthreads = 1; | ||
| 194 | a->success = false; | ||
| 195 | |||
| 196 | if (c == 0) { | ||
| 197 | a->success = true; | ||
| 198 | } else { | ||
| 199 | if (!strcmp(v[0], "-t") && c > 1) { | ||
| 200 | val = strtol(v[1], NULL, 10); | ||
| 201 | if (val < 1 || val > 64) { | ||
| 202 | fprintf(stderr, | ||
| 203 | "Invalid number of threads." | ||
| 204 | "1 <= t <= 64\n"); | ||
| 205 | return a; | ||
| 206 | } | ||
| 207 | a->opts->nthreads = val; | ||
| 208 | a->success = true; | ||
| 209 | } | ||
| 210 | } | ||
| 211 | |||
| 212 | return a; | ||
| 213 | } | ||
| 214 | |||
| 215 | CommandArgs * | ||
| 176 | help_parse_args(int c, char **v) | 216 | help_parse_args(int c, char **v) |
| 177 | { | 217 | { |
| 178 | int i; | 218 | int i; |
| @@ -229,6 +269,21 @@ solve_exec(CommandArgs *args) | |||
| 229 | } | 269 | } |
| 230 | 270 | ||
| 231 | static void | 271 | static void |
| 272 | gen_exec(CommandArgs *args) | ||
| 273 | { | ||
| 274 | int i; | ||
| 275 | |||
| 276 | fprintf(stderr, "Generating coordinates...\n"); | ||
| 277 | init_symcoord(); | ||
| 278 | |||
| 279 | fprintf(stderr, "Generating pruning tables...\n"); | ||
| 280 | for (i = 0; i < NPTABLES && allpd[i] != NULL; i++) | ||
| 281 | genptable(allpd[i], args->opts->nthreads); | ||
| 282 | |||
| 283 | fprintf(stderr, "Done!\n"); | ||
| 284 | } | ||
| 285 | |||
| 286 | static void | ||
| 232 | steps_exec(CommandArgs *args) | 287 | steps_exec(CommandArgs *args) |
| 233 | { | 288 | { |
| 234 | int i; | 289 | int i; |
diff --git a/src/pruning.c b/src/pruning.c index 8cfa582..b305a89 100644 --- a/src/pruning.c +++ b/src/pruning.c | |||
| @@ -84,6 +84,21 @@ pd_khuge_HTM = { | |||
| 84 | .moveset = moveset_HTM, | 84 | .moveset = moveset_HTM, |
| 85 | }; | 85 | }; |
| 86 | 86 | ||
| 87 | PruneData * allpd[NPTABLES] = { | ||
| 88 | &pd_eofb_HTM, | ||
| 89 | &pd_coud_HTM, | ||
| 90 | &pd_cornershtr_HTM, | ||
| 91 | &pd_corners_HTM, | ||
| 92 | &pd_drud_sym16_HTM, | ||
| 93 | &pd_drud_eofb, | ||
| 94 | &pd_drudfin_noE_sym16_drud, | ||
| 95 | &pd_htr_drud, | ||
| 96 | &pd_htrfin_htr, | ||
| 97 | &pd_khuge_HTM, | ||
| 98 | }; | ||
| 99 | |||
| 100 | /* Functions *****************************************************************/ | ||
| 101 | |||
| 87 | int | 102 | int |
| 88 | findchunk(PruneData *pd, int nchunks, uint64_t i) | 103 | findchunk(PruneData *pd, int nchunks, uint64_t i) |
| 89 | { | 104 | { |
diff --git a/src/pruning.h b/src/pruning.h index d337fd8..da9e58a 100644 --- a/src/pruning.h +++ b/src/pruning.h | |||
| @@ -3,6 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | #include "symcoord.h" | 4 | #include "symcoord.h" |
| 5 | 5 | ||
| 6 | #define NPTABLES 20 | ||
| 7 | |||
| 6 | extern PruneData pd_eofb_HTM; | 8 | extern PruneData pd_eofb_HTM; |
| 7 | extern PruneData pd_coud_HTM; | 9 | extern PruneData pd_coud_HTM; |
| 8 | extern PruneData pd_corners_HTM; | 10 | extern PruneData pd_corners_HTM; |
| @@ -14,6 +16,8 @@ extern PruneData pd_htr_drud; | |||
| 14 | extern PruneData pd_htrfin_htr; | 16 | extern PruneData pd_htrfin_htr; |
| 15 | extern PruneData pd_khuge_HTM; | 17 | extern PruneData pd_khuge_HTM; |
| 16 | 18 | ||
| 19 | extern PruneData * allpd[NPTABLES]; | ||
| 20 | |||
| 17 | void genptable(PruneData *pd, int nthreads); | 21 | void genptable(PruneData *pd, int nthreads); |
| 18 | void print_ptable(PruneData *pd); | 22 | void print_ptable(PruneData *pd); |
| 19 | uint64_t ptablesize(PruneData *pd); | 23 | uint64_t ptablesize(PruneData *pd); |
