aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/commands.c22
-rw-r--r--src/pruning.c11
-rw-r--r--src/pruning.h3
-rw-r--r--src/shell.c14
-rw-r--r--src/symcoord.c14
-rw-r--r--src/symcoord.h3
6 files changed, 49 insertions, 18 deletions
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
163Command *commands[] = { 163Command *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)
547static void 548static void
548freemem_exec(CommandArgs *args) 549freemem_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
559static void 563static 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
92PruneData * allpd[] = { 92PruneData * 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
119void 119void
120free_pd(PruneData *pd)
121{
122 if (pd->generated)
123 free(pd->ptable);
124
125 pd->generated = false;
126}
127
128void
120genptable(PruneData *pd, int nthreads) 129genptable(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;
14extern PruneData pd_htrfin_htr; 14extern PruneData pd_htrfin_htr;
15extern PruneData pd_nxopt31_HTM; 15extern PruneData pd_nxopt31_HTM;
16 16
17extern PruneData * allpd[]; 17extern PruneData * all_pd[];
18 18
19void free_pd(PruneData *pd);
19void genptable(PruneData *pd, int nthreads); 20void genptable(PruneData *pd, int nthreads);
20void print_ptable(PruneData *pd); 21void print_ptable(PruneData *pd);
21uint64_t ptablesize(PruneData *pd); 22uint64_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)
140int 140int
141main(int argc, char *argv[]) 141main(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
56static SymData * all_sd[] = { 56SymData * 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
269void
270free_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
269static void 281static void
270gensym(SymData *sd) 282gensym(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;
9extern Coordinate coord_drudfin_noE_sym16; 9extern Coordinate coord_drudfin_noE_sym16;
10extern Coordinate coord_nxopt31; 10extern Coordinate coord_nxopt31;
11 11
12extern SymData *all_sd[];
13
14void free_sd(SymData *sd);
12void init_symcoord(); 15void init_symcoord();
13 16
14#endif 17#endif

Generated with cgit - Back to sebastiano.tronto.net