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 /src/commands.c | |
| parent | d8a94976ebad9c55aca6b0443c5f92d892e12dd0 (diff) | |
| download | nissy-6c28dec4a111ad73f8ac17c89305a951371f765d.tar.gz nissy-6c28dec4a111ad73f8ac17c89305a951371f765d.zip | |
Added gen command and modified installation instructions for tables
Diffstat (limited to 'src/commands.c')
| -rw-r--r-- | src/commands.c | 55 |
1 files changed, 55 insertions, 0 deletions
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; |
