From c9e639ba81cc7454fe950c3759c78c0c1cfa13a2 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 8 Mar 2014 16:01:04 +0000 Subject: [PATCH] wip multicore: add argument parsing; currently -j option is actually ignored --- main.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/main.c b/main.c index 6f0df72..307eea9 100644 --- a/main.c +++ b/main.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -88,6 +89,8 @@ static AdjWord *best_adjmatrix; static unsigned printcounter; +static int ncpus = 1; + static AdjWord *xalloc_adjmatrix(void) { return xmalloc(sizeof(*adjmatrix)*n); } @@ -351,9 +354,20 @@ static void iterate(void) { } int main(int argc, char **argv) { + int opt; + while ((opt = getopt(argc,argv,"j:")) >= 0) { + switch (opt) { + case 'j': ncpus = atoi(optarg); break; + case '+': assert(!"bad option"); + default: abort(); + } + } + argc -= optind-1; + argv += optind-1; assert(argc==3); n = atoi(argv[1]); m = atoi(argv[2]); + prep(); iterate(); fprintf(stderr, "\n"); -- 2.30.2