From 37deaefe474f698d2785189ffc9480f68c01007f Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sun, 9 Mar 2014 21:36:50 +0100 Subject: Add -j --- src/ambigator.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ambigator.c b/src/ambigator.c index fbe29091..72894eb9 100644 --- a/src/ambigator.c +++ b/src/ambigator.c @@ -73,6 +73,7 @@ static void show_help(const char *s) " --fg-graph= Save f and g correlation values to file .\n" " --ncorr= Use correlations per crystal. Default 1000\n" " --stop-after= Use at most the first crystals.\n" +" -j Use threads for CC calculation.\n" ); } @@ -474,10 +475,9 @@ static void work(void *wp, int cookie) static struct cc_list *calc_ccs(struct flist **crystals, int n_crystals, int ncorr, SymOpList *amb, gsl_rng *rng, - float *pmean_nac) + float *pmean_nac, int nthreads) { struct cc_list *ccs; - int nthreads = 8; struct queue_args qargs; assert(n_crystals >= ncorr); @@ -617,6 +617,7 @@ int main(int argc, char *argv[]) int ncorr = 1000; int stop_after = 0; float mean_nac; + int n_threads = 1; /* Long options */ const struct option longopts[] = { @@ -636,7 +637,7 @@ int main(int argc, char *argv[]) }; /* Short options */ - while ((c = getopt_long(argc, argv, "ho:y:n:w:", + while ((c = getopt_long(argc, argv, "ho:y:n:w:j:", longopts, NULL)) != -1) { @@ -662,6 +663,13 @@ int main(int argc, char *argv[]) n_iter = atoi(optarg); break; + case 'j' : + if ( sscanf(optarg, "%i", &n_threads) != 1 ) { + ERROR("Invalid value for -j\n"); + return 1; + } + break; + case 2 : if ( sscanf(optarg, "%e", &highres) != 1 ) { ERROR("Invalid value for --highres\n"); @@ -843,7 +851,8 @@ int main(int argc, char *argv[]) } } - ccs = calc_ccs(crystals, n_crystals, ncorr, amb, rng, &mean_nac); + ccs = calc_ccs(crystals, n_crystals, ncorr, amb, rng, &mean_nac, + n_threads); if ( ccs == NULL ) { ERROR("Failed to allocate CCs\n"); return 1; -- cgit v1.2.3