diff --git a/common/AzimuthalIntegrationMapping.cpp b/common/AzimuthalIntegrationMapping.cpp index 41e58afb..e842a955 100644 --- a/common/AzimuthalIntegrationMapping.cpp +++ b/common/AzimuthalIntegrationMapping.cpp @@ -40,9 +40,9 @@ AzimuthalIntegrationMapping::AzimuthalIntegrationMapping(const DiffractionExperi nthreads = std::clamp(nthreads, 1, 64); if (!experiment.IsGeometryTransformed()) - SetupRawGeom(experiment, mask.GetMaskRaw(), nthreads); + SetupRawGeom(experiment, mask.GetMaskRaw()); else - SetupConvGeom(experiment.GetDiffractionGeometry(),mask.GetMask(), nthreads); + SetupConvGeom(experiment.GetDiffractionGeometry(),mask.GetMask()); UpdateMaxBinNumber(); } @@ -55,9 +55,7 @@ void AzimuthalIntegrationMapping::SetupConvGeomRows(const DiffractionGeometry &g } } -void AzimuthalIntegrationMapping::SetupConvGeom(const DiffractionGeometry &geom, - const std::vector &mask, - size_t nthreads) { +void AzimuthalIntegrationMapping::SetupConvGeom(const DiffractionGeometry &geom, const std::vector &mask) { pixel_to_bin.resize(width * height, UINT16_MAX); pixel_resolution.resize(width * height, 0); corrections.resize(width * height, 0); @@ -68,13 +66,15 @@ void AzimuthalIntegrationMapping::SetupConvGeom(const DiffractionGeometry &geom, if (nthreads <= 1) { SetupConvGeomRows(geom, mask, 0, height); } else { - nthreads = std::min(nthreads, height); + auto local_nthreads = std::min(nthreads, height); std::vector> futures; - for (size_t t = 0; t < nthreads; ++t) + for (size_t t = 0; t < local_nthreads; ++t) futures.emplace_back(std::async(std::launch::async, &AzimuthalIntegrationMapping::SetupConvGeomRows, - this, std::cref(geom), std::cref(mask), t * height / nthreads, (t + 1) * height / nthreads)); + this, std::cref(geom), std::cref(mask), + t * height / local_nthreads, + (t + 1) * height / local_nthreads)); for (auto &f: futures) f.get(); @@ -82,7 +82,7 @@ void AzimuthalIntegrationMapping::SetupConvGeom(const DiffractionGeometry &geom, } void AzimuthalIntegrationMapping::SetupRawGeom(const DiffractionExperiment &experiment, - const std::vector &mask, size_t nthreads) { + const std::vector &mask) { if (mask.size() != RAW_MODULE_SIZE * experiment.GetModulesNum()) throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Mask size invalid"); @@ -100,13 +100,13 @@ void AzimuthalIntegrationMapping::SetupRawGeom(const DiffractionExperiment &expe } } } else { - nthreads = std::min(nthreads, experiment.GetModulesNum()); + auto local_nthreads = std::min(nthreads, experiment.GetModulesNum()); std::vector> futures; - futures.reserve(nthreads); + futures.reserve(local_nthreads); - for (size_t t = 0; t < nthreads; ++t) { - const size_t module_begin = t * experiment.GetModulesNum() / nthreads; - const size_t module_end = (t + 1) * experiment.GetModulesNum() / nthreads; + for (size_t t = 0; t < local_nthreads; ++t) { + const size_t module_begin = t * experiment.GetModulesNum() / local_nthreads; + const size_t module_end = (t + 1) * experiment.GetModulesNum() / local_nthreads; futures.emplace_back(std::async(std::launch::async, [&, module_begin, module_end] { for (size_t m = module_begin; m < module_end; ++m) { diff --git a/common/AzimuthalIntegrationMapping.h b/common/AzimuthalIntegrationMapping.h index 996e4b32..3203187e 100644 --- a/common/AzimuthalIntegrationMapping.h +++ b/common/AzimuthalIntegrationMapping.h @@ -29,9 +29,9 @@ protected: void UpdateMaxBinNumber(); - void SetupRawGeom(const DiffractionExperiment& experiment, const std::vector &mask, size_t nthreads); + void SetupRawGeom(const DiffractionExperiment& experiment, const std::vector &mask); void SetupConvGeomRows(const DiffractionGeometry &geom, const std::vector &mask, size_t row0, size_t row_end); - void SetupConvGeom(const DiffractionGeometry &geom, const std::vector &mask, size_t nthreads); + void SetupConvGeom(const DiffractionGeometry &geom, const std::vector &mask); void SetupPixel(const DiffractionGeometry &geom, const std::vector &mask, uint32_t pxl, uint32_t col, uint32_t row);