RadialIntegration: Don't keep RadialIntegration on stack

This commit is contained in:
2023-08-08 11:32:27 +02:00
parent 4159fc7b6d
commit 6006850c40
2 changed files with 10 additions and 5 deletions
+5 -1
View File
@@ -18,6 +18,10 @@ RadialIntegration::RadialIntegration(const std::vector<uint16_t>& in_mapping, ui
"Only pixel split of 1 and 4 allowed at the moment for radial integration");
coeff = (float *) std::aligned_alloc(64, in_mapping.size() * sizeof(float));
if (coeff == nullptr)
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
"Memory allocation error");
for (int i = 0; i < in_mapping.size(); i++)
coeff[i] = 1.0f;
}
@@ -50,7 +54,7 @@ void RadialIntegration::Process(const int16_t *__restrict data, size_t npixel) {
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
"Mismatch in size of pixel-to-bin mapping and image");
auto coeff_aligned = std::assume_aligned<64>(coeff);
const auto coeff_aligned = std::assume_aligned<64>(coeff);
if (pixel_split == 1) {
for (int i = 0; i < npixel; i++) {
+5 -4
View File
@@ -25,12 +25,13 @@ auto TestRadialIntegration(const DiffractionExperiment &experiment,
RadialIntegrationMapping mapping(experiment);
std::vector<float> result;
std::vector<RadialIntegration> integration;
std::vector<std::unique_ptr<RadialIntegration>> integration;
for (int i = 0; i < nthreads; i++) {
if (pixel_split == 1)
integration.emplace_back(mapping);
integration.emplace_back(std::make_unique<RadialIntegration>(mapping));
else
integration.emplace_back(mapping.GetPixelToBinMappingSplitTo4(), mapping.GetBinNumber(), 4);
integration.emplace_back(std::make_unique<RadialIntegration>(mapping.GetPixelToBinMappingSplitTo4(),
mapping.GetBinNumber(), 4));
}
auto start_time = std::chrono::system_clock::now();
@@ -38,7 +39,7 @@ auto TestRadialIntegration(const DiffractionExperiment &experiment,
std::vector<std::future<void>> futures;
for (int i = 0; i < nthreads; i++) {
futures.emplace_back(std::async(std::launch::async, &RunRadialIntegrationThread,
&integration[i], image, nimages, i, nthreads,
integration[i].get(), image, nimages, i, nthreads,
experiment.GetPixelsNum()));
}
for (auto &f: futures)