Card summation of 128 frames or more: packets of a module counted on the host
The card counts the packets of a summed module in 16 bits (axis_completion packet_count, hls_jfjoch.h), 512 per frame, so from 128 summed frames the count wraps: at 128 and 256 to exactly 0, which the host took for a module not collected (IsAnyPacketCollected), so every image was lost; between them the efficiency came out wrong. Where 512 * card summation exceeds 16 bits, the host now counts the packets from the module's packet mask (the packets present in all of its frames) times the summation, and keeps the count in 32 bits (Completion, AcquisitionCounters). Exact for complete modules; with packets lost in some frames it counts only those present in all. The mock of the card keeps the card's 16-bit count, so it shows the same wrap (checked: without this, summation 256 on the mock delivers no image). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HVeDQrPqZ52Tp6rzzZGxf3
This commit is contained in:
1 parent
c1ddc1abb4
commit
d8f41a488f
5 files changed
+14
-3
No files matched your search
@@ -31,7 +31,7 @@ void AcquisitionCounters::Reset(const DiffractionExperiment &experiment, uint16_
|
||||
curr_frame_number[i] = 0;
|
||||
|
||||
handle_for_frame = std::vector<uint64_t>(expected_frames * nmodules, HandleNotFound);
|
||||
packets_collected = std::vector<uint16_t>(expected_frames * nmodules);
|
||||
packets_collected = std::vector<uint32_t>(expected_frames * nmodules);
|
||||
packets_per_module = std::vector<uint64_t>(nmodules);
|
||||
total_packets = 0;
|
||||
expected_packets_per_module = 512 * experiment.GetFPGASummation();
|
||||
|
||||
@@ -21,7 +21,7 @@ class AcquisitionCounters {
|
||||
mutable std::condition_variable_any data_updated;
|
||||
|
||||
std::vector<uint64_t> handle_for_frame;
|
||||
std::vector<uint16_t> packets_collected;
|
||||
std::vector<uint32_t> packets_collected;
|
||||
|
||||
uint64_t total_packets;
|
||||
std::vector<uint64_t> packets_per_module;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
#include <bit>
|
||||
#include <thread>
|
||||
#include <fstream>
|
||||
#include <cmath>
|
||||
@@ -54,6 +55,7 @@ void AcquisitionDevice::StartAction(const DiffractionExperiment &experiment, uin
|
||||
|
||||
counters.Reset(experiment, data_stream);
|
||||
expected_frames = experiment.GetFrameNum() / experiment.GetFPGASummation();
|
||||
fpga_summation = experiment.GetFPGASummation();
|
||||
|
||||
// Ensure internal WR queue is empty
|
||||
work_request_queue.Clear();
|
||||
@@ -92,6 +94,14 @@ void AcquisitionDevice::WaitForActionComplete() {
|
||||
}
|
||||
|
||||
if (!skip_analysis) {
|
||||
// The card counts the packets of a summed module in 16 bits, which wraps from 128 frames on (512 a frame):
|
||||
// counted here from those present in all the frames
|
||||
if (512 * fpga_summation > UINT16_MAX) {
|
||||
uint32_t packets = 0;
|
||||
for (const auto &mask: output->module_statistics.packet_mask)
|
||||
packets += std::popcount(mask);
|
||||
output->module_statistics.packet_count = packets * fpga_summation;
|
||||
}
|
||||
c.module_number = output->module_statistics.module_number;
|
||||
c.packet_count = output->module_statistics.packet_count;
|
||||
c.frame_number = output->module_statistics.frame_number;
|
||||
|
||||
@@ -38,6 +38,7 @@ class AcquisitionDevice {
|
||||
std::chrono::time_point<std::chrono::system_clock> end_time;
|
||||
|
||||
int64_t expected_frames;
|
||||
int64_t fpga_summation = 1;
|
||||
|
||||
virtual void Start(const DiffractionExperiment& experiment, uint32_t flags) = 0;
|
||||
virtual void Finalize() {}; // do clean-up after action is done
|
||||
|
||||
@@ -14,7 +14,7 @@ struct Completion {
|
||||
|
||||
uint64_t frame_number;
|
||||
uint32_t handle;
|
||||
uint16_t packet_count;
|
||||
uint32_t packet_count;
|
||||
uint16_t data_collection_id;
|
||||
uint16_t module_number;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user