// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute // SPDX-License-Identifier: GPL-3.0-only #pragma once #include #include "ROIIntegration.h" #include "../indexing/CUDAMemHelpers.h" class ROIIntegrationGPU : public ROIIntegration { std::shared_ptr stream; int threads; int blocks; size_t shared_needed; CudaDevicePtr gpu_roi_map; // 64-bit sums are accumulated as unsigned long long (two's-complement bit // pattern) because CUDA atomicAdd has no signed 64-bit overload. CudaDevicePtr gpu_sum; CudaDevicePtr gpu_sum2; CudaDevicePtr gpu_pixels; CudaDevicePtr gpu_x_weighted; CudaDevicePtr gpu_y_weighted; CudaDevicePtr gpu_max; std::vector host_sum; std::vector host_sum2; std::vector host_pixels; std::vector host_x_weighted; std::vector host_y_weighted; std::vector host_max; std::vector max_init; // INT_MIN seed copied into gpu_max each frame public: ROIIntegrationGPU(const DiffractionExperiment &experiment, std::shared_ptr stream); void Run(const ImagePreprocessorBuffer &image, std::map &out) override; };