rugnux pre-scan: projection and defective pixels per card, the sample read once, beam stop memoised
The beam-stop projection (ShadowAccumulatorGPU) and the defective-pixel sums (HotPixelFinderGPU) are now kept one per card, fed by workers pinned t % gpus like the other pre-scan workers, and folded into the first card when they are read (cudaMemcpyPeer + an integer add / max-with-count kernel). All of them are integer sums or a maximum with the first-value rule, so the fold is order-free and the result is identical to one card's. With one card nothing is folded. The pre-scan sample is read once and kept (compressed as stored; up to 2 GiB, a frame past that is read again where it is wanted) for the spot measurement and the defective pixels, which read every frame again each before - a CBF/marCCD/SMV frame was decoded on the host three times. A beam-stop detection that finds no shadow leaves the mask as it was, so every probe copy of the run repeated it on the same inputs. Its answer (shadow, ring centre, mean projection) is now kept in a memo shared with the copies, keyed on the sampled frames, the geometry the rings are drawn in, the polarization and the binary mask; up to 4 entries. Debug TIMING lines for the pre-scan's parts (read and projection, beam stop, defective pixels, spot measurement). New tests: two accumulators/finders folded match one fed every frame. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EizBKhTqrAYago9KJG3dA3
This commit is contained in:
@@ -558,4 +558,50 @@ TEST_CASE("ShadowFinder_DeviceMaskMatchesHost", "[ShadowFinder]") {
|
||||
CHECK(r.device_mask == r.host_mask);
|
||||
}
|
||||
}
|
||||
|
||||
// The pre-scan keeps one accumulator per card and folds them together when the mask is read. Two
|
||||
// accumulators, each given half of the frames, folded into one must hold exactly what one given every
|
||||
// frame holds - including a pixel whose only valid values are negative and fell all to the second half,
|
||||
// which the maximum must take although the first half never counted the pixel.
|
||||
TEST_CASE("ShadowAccumulatorGPU_FoldedCardsMatchOneCard", "[ShadowFinder]") {
|
||||
if (get_gpu_count() == 0)
|
||||
SKIP("no GPU");
|
||||
constexpr size_t N = static_cast<size_t>(W) * H;
|
||||
std::vector<std::vector<int32_t>> frames;
|
||||
uint32_t state = 12345;
|
||||
const auto next = [&] { state = state * 1664525u + 1013904223u; return state >> 8; };
|
||||
for (int f = 0; f < 2 * NFRAMES; f++) {
|
||||
frames.emplace_back(N);
|
||||
for (auto &v : frames.back())
|
||||
v = next() % 50 == 0 ? INT32_MIN : static_cast<int32_t>(next() % 1100) - 100;
|
||||
frames.back()[I(3, 3)] = f % 2 == 0 ? INT32_MIN : -7 - f;
|
||||
frames.back()[I(5, 5)] = INT32_MIN;
|
||||
}
|
||||
JFJochBitShuffleCompressor compressor(CompressionAlgorithm::BSHUF_LZ4);
|
||||
std::vector<std::vector<uint8_t>> compressed;
|
||||
for (const auto &frame : frames)
|
||||
compressed.push_back(compressor.Compress(frame));
|
||||
const auto image = [&](size_t f) {
|
||||
return CompressedImage(compressed[f].data(), compressed[f].size(), W, H, CompressedImageMode::Int32,
|
||||
CompressionAlgorithm::BSHUF_LZ4);
|
||||
};
|
||||
|
||||
ShadowAccumulatorGPU one(N), first(N), second(N);
|
||||
for (size_t f = 0; f < frames.size(); f++) {
|
||||
one.Add(image(f));
|
||||
(f % 2 == 0 ? first : second).Add(image(f));
|
||||
}
|
||||
first.Fold(second);
|
||||
|
||||
std::vector<int64_t> max_one, sum_one, max_folded, sum_folded;
|
||||
std::vector<uint32_t> count_one, count_folded;
|
||||
one.Download(max_one, sum_one, count_one);
|
||||
first.Download(max_folded, sum_folded, count_folded);
|
||||
CHECK(first.GetFrameCount() == one.GetFrameCount());
|
||||
CHECK(max_folded[I(3, 3)] == -8);
|
||||
CHECK(count_folded[I(5, 5)] == 0);
|
||||
CHECK(max_folded == max_one);
|
||||
CHECK(sum_folded == sum_one);
|
||||
CHECK(count_folded == count_one);
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user