From 4330d385f145fcc3e47c7398293e69268cec5d60 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 11 Mar 2021 15:33:05 +0100 Subject: indexamajig: Add --max-indexer-threads This is a more general replacement for --pinkIndexer-thread-count. --- libcrystfel/src/index.c | 5 ++++- libcrystfel/src/index.h | 1 + libcrystfel/src/indexers/pinkindexer.c | 22 ++++++---------------- libcrystfel/src/indexers/pinkindexer.h | 2 +- 4 files changed, 12 insertions(+), 18 deletions(-) (limited to 'libcrystfel') diff --git a/libcrystfel/src/index.c b/libcrystfel/src/index.c index e0959657..6d1828a9 100644 --- a/libcrystfel/src/index.c +++ b/libcrystfel/src/index.c @@ -69,6 +69,7 @@ struct _indexingprivate UnitCell *target_cell; double tolerance[6]; double wavelength_estimate; + int n_threads; int n_methods; IndexingMethod *methods; @@ -361,6 +362,7 @@ IndexingPrivate *setup_indexing(const char *method_list, float *tols, IndexingFlags flags, double wavelength_estimate, + int n_threads, struct taketwo_options *ttopts, struct xgandalf_options *xgandalf_opts, struct pinkIndexer_options *pinkIndexer_opts, @@ -473,6 +475,7 @@ IndexingPrivate *setup_indexing(const char *method_list, ipriv->n_methods = n; ipriv->flags = flags; ipriv->wavelength_estimate = wavelength_estimate; + ipriv->n_threads = n_threads; if ( cell != NULL ) { ipriv->target_cell = cell_new_from_cell(cell); @@ -682,7 +685,7 @@ static int try_indexer(struct image *image, IndexingMethod indm, case INDEXING_PINKINDEXER : set_last_task(last_task, "indexing:pinkindexer"); - r = run_pinkIndexer(image, mpriv); + r = run_pinkIndexer(image, mpriv, ipriv->n_threads); break; case INDEXING_XGANDALF : diff --git a/libcrystfel/src/index.h b/libcrystfel/src/index.h index 24beb408..60e61630 100644 --- a/libcrystfel/src/index.h +++ b/libcrystfel/src/index.h @@ -168,6 +168,7 @@ extern IndexingPrivate *setup_indexing(const char *methods, float *ltl, IndexingFlags flags, double wavelength_estimate, + int n_threads, struct taketwo_options *ttopts, struct xgandalf_options *xgandalf_opts, struct pinkIndexer_options *pinkIndexer_opts, diff --git a/libcrystfel/src/indexers/pinkindexer.c b/libcrystfel/src/indexers/pinkindexer.c index db4da101..b0b5a9fa 100644 --- a/libcrystfel/src/indexers/pinkindexer.c +++ b/libcrystfel/src/indexers/pinkindexer.c @@ -51,7 +51,6 @@ struct pinkIndexer_options { unsigned int refinement_type; float maxResolutionForIndexing_1_per_A; float tolerance; - int thread_count; float reflectionRadius; /* In m^-1 */ float customBandwidth; float maxRefinementDisbalance; @@ -68,7 +67,6 @@ struct pinkIndexer_private_data { IndexingMethod indm; UnitCell *cellTemplate; - int threadCount; float maxRefinementDisbalance; @@ -115,7 +113,7 @@ static void scale_detector_shift(double fake_clen, } -int run_pinkIndexer(struct image *image, void *ipriv) +int run_pinkIndexer(struct image *image, void *ipriv, int n_threads) { struct pinkIndexer_private_data *pinkIndexer_private_data = ipriv; reciprocalPeaks_1_per_A_t reciprocalPeaks_1_per_A; @@ -164,7 +162,7 @@ int run_pinkIndexer(struct image *image, void *ipriv) &reciprocalPeaks_1_per_A, intensities, pinkIndexer_private_data->maxRefinementDisbalance, - pinkIndexer_private_data->threadCount); + n_threads); free(intensities); freeReciprocalPeaks(reciprocalPeaks_1_per_A); @@ -257,7 +255,6 @@ void *pinkIndexer_prepare(IndexingMethod *indm, struct pinkIndexer_private_data* pinkIndexer_private_data = malloc(sizeof(struct pinkIndexer_private_data)); pinkIndexer_private_data->indm = *indm; pinkIndexer_private_data->cellTemplate = cell; - pinkIndexer_private_data->threadCount = pinkIndexer_opts->thread_count; pinkIndexer_private_data->maxRefinementDisbalance = pinkIndexer_opts->maxRefinementDisbalance; UnitCell* primitiveCell = uncenter_cell(cell, &pinkIndexer_private_data->centeringTransformation, NULL); @@ -415,7 +412,7 @@ const char *pinkIndexer_probe(UnitCell *cell) #else /* HAVE_PINKINDEXER */ -int run_pinkIndexer(struct image *image, void *ipriv) +int run_pinkIndexer(struct image *image, void *ipriv, int n_threads) { ERROR("This copy of CrystFEL was compiled without PINKINDEXER support.\n"); return 0; @@ -463,9 +460,6 @@ static void pinkIndexer_show_help() " Specified in 1/A. Default is 2%% of a*.\n" " --pinkIndexer-max-resolution-for-indexing=n\n" " Measured in 1/A\n" -" --pinkIndexer-thread-count=n\n" -" Thread count for internal parallelization \n" -" Default: 1\n" " --pinkIndexer-max-refinement-disbalance=n\n" " Maximum imbalance after refinement:\n" " 0 (no imbalance) to 2 (extreme imbalance), default 0.4\n" @@ -485,7 +479,6 @@ int pinkIndexer_default_options(PinkIndexerOptions **opts_ptr) opts->refinement_type = 1; opts->tolerance = 0.06; opts->maxResolutionForIndexing_1_per_A = +INFINITY; - opts->thread_count = 1; opts->reflectionRadius = -1; opts->maxRefinementDisbalance = 0.4; @@ -540,12 +533,9 @@ static error_t pinkindexer_parse_arg(int key, char *arg, break; case 5 : - if (sscanf(arg, "%d", &(*opts_ptr)->thread_count) != 1) - { - ERROR("Invalid value for --pinkIndexer-thread-count\n"); - return EINVAL; - } - break; + ERROR("Please use --max-indexer-threads instead of " + "--pinkIndexer-thread-count.\n"); + return EINVAL; case 6 : if (sscanf(arg, "%f", &(*opts_ptr)->maxResolutionForIndexing_1_per_A) != 1) diff --git a/libcrystfel/src/indexers/pinkindexer.h b/libcrystfel/src/indexers/pinkindexer.h index 12230225..358a8221 100644 --- a/libcrystfel/src/indexers/pinkindexer.h +++ b/libcrystfel/src/indexers/pinkindexer.h @@ -37,7 +37,7 @@ extern int pinkIndexer_default_options(PinkIndexerOptions **opts_ptr); -extern int run_pinkIndexer(struct image *image, void *ipriv); +extern int run_pinkIndexer(struct image *image, void *ipriv, int n_threads); extern void *pinkIndexer_prepare(IndexingMethod *indm, UnitCell *cell, -- cgit v1.2.3