From 57f2d05b324564bf9e2d4575b4d540b8cd6abdfa Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Sat, 4 Oct 2025 19:49:28 +0200 Subject: [PATCH] ImageSpotFinderGPU: Rename --- .../spot_finding/ImageAnalysisGPU.cu | 20 +++++++++---------- .../spot_finding/ImageAnalysisGPU.h | 6 +++--- tests/ImageSpotFinderGPUTest.cpp | 10 +++++----- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/image_analysis/spot_finding/ImageAnalysisGPU.cu b/image_analysis/spot_finding/ImageAnalysisGPU.cu index 9d21345f..4c89debe 100644 --- a/image_analysis/spot_finding/ImageAnalysisGPU.cu +++ b/image_analysis/spot_finding/ImageAnalysisGPU.cu @@ -256,7 +256,7 @@ __global__ void analyze_pixel(const int32_t *in, uint32_t *out, const spot_param } while (back < rmax); } -GPUImageAnalysis::GPUImageAnalysis(int32_t in_xpixels, int32_t in_ypixels) : +ImageSpotFinderGPU::ImageSpotFinderGPU(int32_t in_xpixels, int32_t in_ypixels) : xpixels(in_xpixels), ypixels(in_ypixels), gpu_out(nullptr) { int device_count; @@ -281,7 +281,7 @@ GPUImageAnalysis::GPUImageAnalysis(int32_t in_xpixels, int32_t in_ypixels) : cuda_err(cudaHostAlloc(&host_out, output_byte_size(host_out, xpixels, ypixels), cudaHostAllocPortable)); } -GPUImageAnalysis::~GPUImageAnalysis() { +ImageSpotFinderGPU::~ImageSpotFinderGPU() { cudaStreamDestroy(cudastream->v); delete(cudastream); @@ -290,18 +290,18 @@ GPUImageAnalysis::~GPUImageAnalysis() { cudaFree(gpu_out); } -void GPUImageAnalysis::SetInputBuffer(void *ptr) { +void ImageSpotFinderGPU::SetInputBuffer(void *ptr) { host_in = (int32_t *) ptr; } -bool GPUImageAnalysis::GPUPresent() { +bool ImageSpotFinderGPU::GPUPresent() { int device_count; cuda_err(cudaGetDeviceCount(&device_count)); return (device_count > 0); } -void GPUImageAnalysis::RunSpotFinder(const SpotFindingSettings &settings) { +void ImageSpotFinderGPU::RunSpotFinder(const SpotFindingSettings &settings) { // data_in is CUDA registered memory // Run COLSPOT (GPU version) @@ -345,7 +345,7 @@ void GPUImageAnalysis::RunSpotFinder(const SpotFindingSettings &settings) { cudaMemcpyDeviceToHost,cudastream->v)); } -void GPUImageAnalysis::GetSpotFinderResults(StrongPixelSet &pixel_set) { +void ImageSpotFinderGPU::GetSpotFinderResults(StrongPixelSet &pixel_set) { if (host_in == nullptr) throw JFJochException(JFJochExceptionCategory::SpotFinderError, "Host/GPU buffer not defined"); @@ -368,7 +368,7 @@ void GPUImageAnalysis::GetSpotFinderResults(StrongPixelSet &pixel_set) { } } -void GPUImageAnalysis::GetSpotFinderResults(const DiffractionExperiment &experiment, +void ImageSpotFinderGPU::GetSpotFinderResults(const DiffractionExperiment &experiment, const SpotFindingSettings &settings, std::vector &vec) { StrongPixelSet pixel_set; @@ -376,15 +376,15 @@ void GPUImageAnalysis::GetSpotFinderResults(const DiffractionExperiment &experim pixel_set.FindSpotsImage(settings, vec); } -void GPUImageAnalysis::RegisterBuffer() { +void ImageSpotFinderGPU::RegisterBuffer() { cudaHostRegister(host_in, xpixels * ypixels * sizeof(int32_t), cudaHostRegisterDefault); } -void GPUImageAnalysis::UnregisterBuffer() { +void ImageSpotFinderGPU::UnregisterBuffer() { cudaHostUnregister(host_in); } -void GPUImageAnalysis::LoadDataToGPU() { +void ImageSpotFinderGPU::LoadDataToGPU() { if (host_in == nullptr) throw JFJochException(JFJochExceptionCategory::SpotFinderError, "Host/GPU buffer not defined"); diff --git a/image_analysis/spot_finding/ImageAnalysisGPU.h b/image_analysis/spot_finding/ImageAnalysisGPU.h index 4ff34044..9a1df976 100644 --- a/image_analysis/spot_finding/ImageAnalysisGPU.h +++ b/image_analysis/spot_finding/ImageAnalysisGPU.h @@ -13,7 +13,7 @@ struct CudaStreamWrapper; -class GPUImageAnalysis { +class ImageSpotFinderGPU { std::mutex m; CudaStreamWrapper *cudastream; @@ -32,8 +32,8 @@ class GPUImageAnalysis { constexpr static int NBX = 15; public: - GPUImageAnalysis(int32_t xpixels, int32_t ypixels); - ~GPUImageAnalysis(); + ImageSpotFinderGPU(int32_t xpixels, int32_t ypixels); + ~ImageSpotFinderGPU(); void SetInputBuffer(void *host_in); void LoadDataToGPU(); diff --git a/tests/ImageSpotFinderGPUTest.cpp b/tests/ImageSpotFinderGPUTest.cpp index a5782bac..0d822878 100644 --- a/tests/ImageSpotFinderGPUTest.cpp +++ b/tests/ImageSpotFinderGPUTest.cpp @@ -21,13 +21,13 @@ static std::vector run_gpu_and_collect_spots(const std::vector< size_t width, size_t height, const SpotFindingSettings& settings) { - GPUImageAnalysis gpu(static_cast(width), static_cast(height)); - REQUIRE(GPUImageAnalysis::GPUPresent()); + ImageSpotFinderGPU gpu(static_cast(width), static_cast(height)); + REQUIRE(ImageSpotFinderGPU::GPUPresent()); // Set input buffer pointer to our CPU data, register and upload // Note: RegisterBuffer/UnregisterBuffer are optional for plain memcpy path, // but we use them to mirror intended flow. - const_cast(gpu).SetInputBuffer((void*)input.data()); + const_cast(gpu).SetInputBuffer((void*)input.data()); gpu.RegisterBuffer(); gpu.LoadDataToGPU(); @@ -47,7 +47,7 @@ static std::vector run_gpu_and_collect_spots(const std::vector< // Mirror of ImageSpotFinder_SignalToNoise TEST_CASE("GPUImageAnalysis_SignalToNoise") { - if (!GPUImageAnalysis::GPUPresent()) { + if (!ImageSpotFinderGPU::GPUPresent()) { WARN("No CUDA GPU present. Skipping GPUImageAnalysis_SignalToNoise"); return; } @@ -80,7 +80,7 @@ TEST_CASE("GPUImageAnalysis_SignalToNoise") { } TEST_CASE("GPUImageAnalysis_CountThreshold") { - if (!GPUImageAnalysis::GPUPresent()) { + if (!ImageSpotFinderGPU::GPUPresent()) { WARN("No CUDA GPU present. Skipping GPUImageAnalysis_SignalToNoise"); return; }