Three resource fixes and two latent bugs, none of which changes a computed number. The preprocessed image has a host copy that only a CPU engine ever reads. On the GPU path every engine reads the device buffer instead, and rugnux always runs the fused adaptive finder, so that host copy is allocated, zeroed and PAGE-LOCKED for nothing - 72 MB per worker, 3.5 GB over 48 of them, and a cudaHostRegister each, which the driver serializes. It is now skipped by the same condition that already decides whether the device copies the image back. ImagePreprocessorBuffer keeps the pixel count separately so size() still answers when the mirror was not allocated. ROIIntegrationGPU asked device 0 for the SM count it sizes its grid from, while workers are pinned round-robin across the GPUs - so on a multi-GPU node it could size a grid from a card it never launches on. It asks the current device now, like every other engine. ~CudaRegisteredVector called a function that throws out of a destructor, and the move-assignment did the same from a noexcept function. Either would abort the process rather than report the failure, and teardown - after a device reset, or while another exception unwinds - is exactly where cudaHostUnregister fails. Both now use an unchecked unregister, as every other destructor in that header already does for its own teardown call. The throwing form stays for rebind()/unregister(), which are called from live code. Measured on a 16M-pixel rotation dataset: unchanged space group, merged reflection count and merging statistics. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
34 lines
1.5 KiB
C++
34 lines
1.5 KiB
C++
// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#pragma once
|
|
|
|
#include <memory>
|
|
|
|
#include "ImagePreprocessorBuffer.h"
|
|
#include "../indexing/CUDAMemHelpers.h"
|
|
|
|
class ImagePreprocessorBufferGPU : public ImagePreprocessorBuffer {
|
|
CudaDevicePtr<int32_t> gpu_image;
|
|
CudaRegisteredVector<int32_t> buffer_reg;
|
|
|
|
// Staging for Gather(). Its only caller is ImageSpotFinder::ExtractSpots, which gives up on a frame
|
|
// with UINT16_MAX or more strong pixels (the connected-component search rejects it anyway), so that
|
|
// is the largest gather that can be asked for.
|
|
static constexpr size_t MAX_GATHER = UINT16_MAX;
|
|
CudaDevicePtr<uint32_t> gpu_gather_index;
|
|
CudaDevicePtr<int32_t> gpu_gather_value;
|
|
// Own stream: every analysis engine synchronises its own stream before it returns, so the device
|
|
// image is final by the time a gather is asked for. The NULL stream would serialise all workers.
|
|
CudaStream gather_stream;
|
|
|
|
public:
|
|
// host_mirror = false skips the host copy of the preprocessed image entirely (and with it the
|
|
// page-locking): pass it when every engine reading this buffer runs on the device.
|
|
explicit ImagePreprocessorBufferGPU(size_t npixel, bool host_mirror = true);
|
|
|
|
int32_t *getGPUBuffer() override;
|
|
const int32_t *getGPUBuffer() const override;
|
|
void Gather(const std::vector<uint32_t> &npixel, std::vector<int32_t> &values) const override;
|
|
};
|