diff options
| -rw-r--r-- | TODO.md | 10 | ||||
| -rw-r--r-- | doc/nissy.1 | 4 | ||||
| -rwxr-xr-x | nissy | bin | 0 -> 327072 bytes | |||
| -rw-r--r-- | src/commands.c | 22 | ||||
| -rw-r--r-- | src/pruning.c | 11 | ||||
| -rw-r--r-- | src/pruning.h | 3 | ||||
| -rw-r--r-- | src/shell.c | 14 | ||||
| -rw-r--r-- | src/symcoord.c | 14 | ||||
| -rw-r--r-- | src/symcoord.h | 3 |
9 files changed, 57 insertions, 24 deletions
| @@ -4,10 +4,11 @@ This is a list of things that I would like to add or change at some point. | |||
| 4 | It's more of a personal reminder than anything else. | 4 | It's more of a personal reminder than anything else. |
| 5 | 5 | ||
| 6 | ## For version 2.1 | 6 | ## For version 2.1 |
| 7 | ### Memory management | ||
| 8 | * freemem command: implement the 5 functions, execute at the end of shell.c | ||
| 9 | ### Installation | 7 | ### Installation |
| 10 | * Is it possible to make table generation at least 3x faster? | 8 | * Implement coord->move to apply moves directly on coordinates |
| 9 | (can this be used to improve solving speed? Applying moves on | ||
| 10 | three coordinates is better than applying a move on a Cube and | ||
| 11 | then transforming it, but I still need to work with inverses...) | ||
| 11 | ### Documentation | 12 | ### Documentation |
| 12 | * Write an examples.md file | 13 | * Write an examples.md file |
| 13 | * More screenshots! | 14 | * More screenshots! |
| @@ -55,9 +56,6 @@ including e.g. solutions that were not shown because -c) | |||
| 55 | * free pruning table after solve is done? if I do this I need to deafault to a | 56 | * free pruning table after solve is done? if I do this I need to deafault to a |
| 56 | small table for < 8 moves solutions or smth | 57 | small table for < 8 moves solutions or smth |
| 57 | * improve multi-threading when solving multiple scrambles | 58 | * improve multi-threading when solving multiple scrambles |
| 58 | * alternative: just add a command "free" to free up memory; it is not | ||
| 59 | user friendly (who wants to manage memory manually?) but on the other hand | ||
| 60 | it will only be used by the few who have less than 4(?) Gb of ram. | ||
| 61 | * nissy -M maxmem option for running with at most maxmem memory; if exceeded | 59 | * nissy -M maxmem option for running with at most maxmem memory; if exceeded |
| 62 | when loading a pruning table, return failure (or make every solve command | 60 | when loading a pruning table, return failure (or make every solve command |
| 63 | use tiny tables instead?); if maxmem is very 600Mb or | 61 | use tiny tables instead?); if maxmem is very 600Mb or |
diff --git a/doc/nissy.1 b/doc/nissy.1 index 124df9b..dfc18ed 100644 --- a/doc/nissy.1 +++ b/doc/nissy.1 | |||
| @@ -53,6 +53,10 @@ all moves done on inverse. | |||
| 53 | .It Nm commands | 53 | .It Nm commands |
| 54 | List all available commands. | 54 | List all available commands. |
| 55 | . | 55 | . |
| 56 | .It Nm freemem | ||
| 57 | Release some large tables from memory. You can use this command in case | ||
| 58 | you want to keep nissy open without using too much RAM. | ||
| 59 | . | ||
| 56 | .It Nm gen Op Fl t Ar N | 60 | .It Nm gen Op Fl t Ar N |
| 57 | Generate all tables used by nissy. Run this to complete your installation. | 61 | Generate all tables used by nissy. Run this to complete your installation. |
| 58 | If | 62 | If |
| Binary files differ | |||
diff --git a/src/commands.c b/src/commands.c index 1396b69..e704d7a 100644 --- a/src/commands.c +++ b/src/commands.c | |||
| @@ -162,6 +162,7 @@ version_cmd = { | |||
| 162 | 162 | ||
| 163 | Command *commands[] = { | 163 | Command *commands[] = { |
| 164 | &commands_cmd, | 164 | &commands_cmd, |
| 165 | &freemem_cmd, | ||
| 165 | &gen_cmd, | 166 | &gen_cmd, |
| 166 | &help_cmd, | 167 | &help_cmd, |
| 167 | &invert_cmd, | 168 | &invert_cmd, |
| @@ -508,8 +509,8 @@ gen_exec(CommandArgs *args) | |||
| 508 | init_symcoord(); | 509 | init_symcoord(); |
| 509 | 510 | ||
| 510 | fprintf(stderr, "Generating pruning tables...\n"); | 511 | fprintf(stderr, "Generating pruning tables...\n"); |
| 511 | for (i = 0; allpd[i] != NULL; i++) | 512 | for (i = 0; all_pd[i] != NULL; i++) |
| 512 | genptable(allpd[i], args->opts->nthreads); | 513 | genptable(all_pd[i], args->opts->nthreads); |
| 513 | 514 | ||
| 514 | fprintf(stderr, "Done!\n"); | 515 | fprintf(stderr, "Done!\n"); |
| 515 | } | 516 | } |
| @@ -547,13 +548,16 @@ commands_exec(CommandArgs *args) | |||
| 547 | static void | 548 | static void |
| 548 | freemem_exec(CommandArgs *args) | 549 | freemem_exec(CommandArgs *args) |
| 549 | { | 550 | { |
| 550 | /* TODO: implement these functions | 551 | int i; |
| 551 | free_allpd(); | 552 | |
| 552 | free_allsd(); | 553 | for (i = 0; all_pd[i] != NULL; i++) |
| 553 | free_invtables(); | 554 | free_pd(all_pd[i]); |
| 554 | free_ttables(); | 555 | |
| 555 | free_mtables(); | 556 | for (i = 0; all_sd[i] != NULL; i++) |
| 556 | */ | 557 | free_sd(all_sd[i]); |
| 558 | |||
| 559 | /* TODO: invtables are also large, but for now they are * | ||
| 560 | * statically allocated. Consider releasing those too. */ | ||
| 557 | } | 561 | } |
| 558 | 562 | ||
| 559 | static void | 563 | static void |
diff --git a/src/pruning.c b/src/pruning.c index 869110f..c66f8d6 100644 --- a/src/pruning.c +++ b/src/pruning.c | |||
| @@ -89,7 +89,7 @@ pd_nxopt31_HTM = { | |||
| 89 | .fbmod = BINOM8ON4, | 89 | .fbmod = BINOM8ON4, |
| 90 | }; | 90 | }; |
| 91 | 91 | ||
| 92 | PruneData * allpd[] = { | 92 | PruneData * all_pd[] = { |
| 93 | &pd_eofb_HTM, | 93 | &pd_eofb_HTM, |
| 94 | &pd_coud_HTM, | 94 | &pd_coud_HTM, |
| 95 | &pd_cornershtr_HTM, | 95 | &pd_cornershtr_HTM, |
| @@ -117,6 +117,15 @@ findchunk(PruneData *pd, int nchunks, uint64_t i) | |||
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | void | 119 | void |
| 120 | free_pd(PruneData *pd) | ||
| 121 | { | ||
| 122 | if (pd->generated) | ||
| 123 | free(pd->ptable); | ||
| 124 | |||
| 125 | pd->generated = false; | ||
| 126 | } | ||
| 127 | |||
| 128 | void | ||
| 120 | genptable(PruneData *pd, int nthreads) | 129 | genptable(PruneData *pd, int nthreads) |
| 121 | { | 130 | { |
| 122 | bool compact; | 131 | bool compact; |
diff --git a/src/pruning.h b/src/pruning.h index df95ea2..6bdbee1 100644 --- a/src/pruning.h +++ b/src/pruning.h | |||
| @@ -14,8 +14,9 @@ extern PruneData pd_htr_drud; | |||
| 14 | extern PruneData pd_htrfin_htr; | 14 | extern PruneData pd_htrfin_htr; |
| 15 | extern PruneData pd_nxopt31_HTM; | 15 | extern PruneData pd_nxopt31_HTM; |
| 16 | 16 | ||
| 17 | extern PruneData * allpd[]; | 17 | extern PruneData * all_pd[]; |
| 18 | 18 | ||
| 19 | void free_pd(PruneData *pd); | ||
| 19 | void genptable(PruneData *pd, int nthreads); | 20 | void genptable(PruneData *pd, int nthreads); |
| 20 | void print_ptable(PruneData *pd); | 21 | void print_ptable(PruneData *pd); |
| 21 | uint64_t ptablesize(PruneData *pd); | 22 | uint64_t ptablesize(PruneData *pd); |
diff --git a/src/shell.c b/src/shell.c index 420dc1c..77d5d1d 100644 --- a/src/shell.c +++ b/src/shell.c | |||
| @@ -11,10 +11,10 @@ checkfiles() | |||
| 11 | char fname[strlen(tabledir)+100]; | 11 | char fname[strlen(tabledir)+100]; |
| 12 | int i; | 12 | int i; |
| 13 | 13 | ||
| 14 | for (i = 0; allpd[i] != NULL; i++) { | 14 | for (i = 0; all_pd[i] != NULL; i++) { |
| 15 | strcpy(fname, tabledir); | 15 | strcpy(fname, tabledir); |
| 16 | strcpy(fname, "/"); | 16 | strcat(fname, "/"); |
| 17 | strcpy(fname, allpd[i]->filename); | 17 | strcat(fname, all_pd[i]->filename); |
| 18 | if ((f = fopen(fname, "rb")) == NULL) | 18 | if ((f = fopen(fname, "rb")) == NULL) |
| 19 | return false; | 19 | return false; |
| 20 | else | 20 | else |
| @@ -140,14 +140,16 @@ launch(bool batchmode) | |||
| 140 | int | 140 | int |
| 141 | main(int argc, char *argv[]) | 141 | main(int argc, char *argv[]) |
| 142 | { | 142 | { |
| 143 | char *closing_cmd[1] = { "freemem" }; | ||
| 144 | |||
| 143 | init_env(); | 145 | init_env(); |
| 144 | 146 | ||
| 145 | if (!checkfiles()) { | 147 | if (!checkfiles()) { |
| 146 | fprintf(stderr, | 148 | fprintf(stderr, |
| 147 | "--- Warning ---\n" | 149 | "--- Warning ---\n" |
| 148 | "Some pruning tables are missing or unreadable." | 150 | "Some pruning tables are missing or unreadable\n" |
| 149 | "You can generate them with `nissy gen -t 4'\n" | 151 | "You can generate them with `nissy gen -t 4'\n" |
| 150 | "Here `4' is the number of threads. Use more if your" | 152 | "Here `4' is the number of threads. Use more if your " |
| 151 | "CPU has them, or expect it to take a while.\n" | 153 | "CPU has them, or expect it to take a while.\n" |
| 152 | "---------------\n\n" | 154 | "---------------\n\n" |
| 153 | ); | 155 | ); |
| @@ -163,7 +165,7 @@ main(int argc, char *argv[]) | |||
| 163 | launch(false); | 165 | launch(false); |
| 164 | } | 166 | } |
| 165 | 167 | ||
| 166 | /* TODO: exec freemem */ | 168 | exec_args(1, closing_cmd); |
| 167 | 169 | ||
| 168 | return 0; | 170 | return 0; |
| 169 | } | 171 | } |
diff --git a/src/symcoord.c b/src/symcoord.c index 4a737af..c4349f5 100644 --- a/src/symcoord.c +++ b/src/symcoord.c | |||
| @@ -53,7 +53,7 @@ sd_eofbepos_16 = { | |||
| 53 | .trans = trans_group_udfix | 53 | .trans = trans_group_udfix |
| 54 | }; | 54 | }; |
| 55 | 55 | ||
| 56 | static SymData * all_sd[] = { | 56 | SymData * all_sd[] = { |
| 57 | &sd_cp_16, | 57 | &sd_cp_16, |
| 58 | &sd_eofbepos_16, | 58 | &sd_eofbepos_16, |
| 59 | NULL | 59 | NULL |
| @@ -266,6 +266,18 @@ transfinder_nxopt31(uint64_t ind, Trans *ret) | |||
| 266 | 266 | ||
| 267 | /* Other functions ***********************************************************/ | 267 | /* Other functions ***********************************************************/ |
| 268 | 268 | ||
| 269 | void | ||
| 270 | free_sd(SymData *sd) | ||
| 271 | { | ||
| 272 | if (sd->generated) { | ||
| 273 | free(sd->class); | ||
| 274 | free(sd->rep); | ||
| 275 | free(sd->transtorep); | ||
| 276 | } | ||
| 277 | |||
| 278 | sd->generated = false; | ||
| 279 | } | ||
| 280 | |||
| 269 | static void | 281 | static void |
| 270 | gensym(SymData *sd) | 282 | gensym(SymData *sd) |
| 271 | { | 283 | { |
diff --git a/src/symcoord.h b/src/symcoord.h index a7b71ba..0882bff 100644 --- a/src/symcoord.h +++ b/src/symcoord.h | |||
| @@ -9,6 +9,9 @@ extern Coordinate coord_drud_sym16; | |||
| 9 | extern Coordinate coord_drudfin_noE_sym16; | 9 | extern Coordinate coord_drudfin_noE_sym16; |
| 10 | extern Coordinate coord_nxopt31; | 10 | extern Coordinate coord_nxopt31; |
| 11 | 11 | ||
| 12 | extern SymData *all_sd[]; | ||
| 13 | |||
| 14 | void free_sd(SymData *sd); | ||
| 12 | void init_symcoord(); | 15 | void init_symcoord(); |
| 13 | 16 | ||
| 14 | #endif | 17 | #endif |
