MXAnalysisWithoutFPGA: Use GPU spot finder if available

This commit is contained in:
2025-10-05 05:43:48 +02:00
parent 1a2c234525
commit ab73184a0b
5 changed files with 34 additions and 2 deletions

View File

@@ -7,6 +7,7 @@
#include "../compression/JFJochDecompress.h"
#include "SpotAnalyze.h"
#include "spot_finding/ImageSpotFinderFactory.h"
MXAnalysisWithoutFPGA::MXAnalysisWithoutFPGA(const DiffractionExperiment &in_experiment,
const AzimuthalIntegration &in_integration,
@@ -33,7 +34,7 @@ MXAnalysisWithoutFPGA::MXAnalysisWithoutFPGA(const DiffractionExperiment &in_exp
for (int i = 0; i < npixels; i++)
mask_1bit[i] = (in_mask.GetMask().at(i) != 0);
spotFinder = std::make_unique<ImageSpotFinderCPU>(experiment.GetXPixelsNum(), experiment.GetYPixelsNum());
spotFinder = CreateImageSpotFinder(experiment.GetXPixelsNum(), experiment.GetYPixelsNum());
updated_image = spotFinder->GetHostBuffer();
}

View File

@@ -11,7 +11,7 @@
#include "../common/AzimuthalIntegration.h"
#include "../common/PixelMask.h"
#include "../common/AzimuthalIntegrationProfile.h"
#include "spot_finding/ImageSpotFinderCPU.h"
#include "spot_finding/ImageSpotFinder.h"
#include "indexing/IndexerThreadPool.h"
class MXAnalysisWithoutFPGA {

View File

@@ -9,6 +9,8 @@ ADD_LIBRARY(JFJochSpotFinding STATIC
DetModuleSpotFinder_cpu.h
ImageSpotFinder.cpp
ImageSpotFinder.h
ImageSpotFinderFactory.cpp
ImageSpotFinderFactory.h
)
TARGET_LINK_LIBRARIES(JFJochSpotFinding JFJochCommon)

View File

@@ -0,0 +1,18 @@
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#include "ImageSpotFinderFactory.h"
#include "ImageSpotFinderCPU.h"
#ifdef JFJOCH_USE_CUDA
#include "../../common/CUDAWrapper.h"
#include "ImageSpotFinderGPU.h"
#endif
std::unique_ptr<ImageSpotFinder> CreateImageSpotFinder(size_t width, size_t height) {
#ifdef JFJOCH_USE_CUDA
if (get_gpu_count() > 0)
return std::make_unique<ImageSpotFinderGPU>(width, height);
#endif
return std::make_unique<ImageSpotFinderCPU>(width, height);
}

View File

@@ -0,0 +1,11 @@
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#ifndef JFJOCH_IMAGESPOTFINDERFACTORY_H
#define JFJOCH_IMAGESPOTFINDERFACTORY_H
#include "ImageSpotFinder.h"
std::unique_ptr<ImageSpotFinder> CreateImageSpotFinder(size_t width, size_t height);
#endif //JFJOCH_IMAGESPOTFINDERFACTORY_H