Lite loses its four mode branches, and no longer builds a DarkMaskAnalysis for runs that do not use one. The dark mask goes where it went: a DECTRIS mask sequence here with rugnux on or off, a PSI detector's to JFJochReceiverFPGA. JFJochReceiverRugnux_DestroyedMidRun destroys each of the four leaves with its threads waiting, since the start and join moved to the most-derived class. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HVeDQsU5a8AJUdJPgWevAK
107 lines
4.2 KiB
C++
107 lines
4.2 KiB
C++
// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include "JFJochReceiverLite.h"
|
|
#include "../image_analysis/indexing/IndexerFactory.h"
|
|
#include "../common/CUDAWrapper.h"
|
|
|
|
JFJochReceiverLite::JFJochReceiverLite(const DiffractionExperiment &in_experiment,
|
|
const PixelMask &in_pixel_mask,
|
|
ImagePuller &in_image_puller,
|
|
ImagePusher &in_image_pusher,
|
|
Logger &in_logger,
|
|
int64_t forward_and_sum_nthreads,
|
|
const SpotFindingSettings &in_spot_finding_settings,
|
|
JFJochReceiverCurrentStatus &in_current_status,
|
|
JFJochReceiverPlots &in_plots,
|
|
ImageBuffer &in_image_buffer,
|
|
ZMQPreviewSocket *in_zmq_preview_socket,
|
|
ZMQMetadataSocket *in_zmq_metadata_socket,
|
|
IndexerThreadPool *indexing_thread_pool)
|
|
: JFJochReceiverStream(in_experiment,
|
|
in_pixel_mask,
|
|
in_image_puller,
|
|
in_image_pusher,
|
|
in_logger,
|
|
forward_and_sum_nthreads,
|
|
in_spot_finding_settings,
|
|
in_current_status,
|
|
in_plots,
|
|
in_image_buffer,
|
|
in_zmq_preview_socket,
|
|
in_zmq_metadata_socket,
|
|
indexing_thread_pool),
|
|
analysis(nthreads) {
|
|
StartThreads();
|
|
}
|
|
|
|
JFJochReceiverLite::~JFJochReceiverLite() {
|
|
cancelled = true;
|
|
JoinThreads();
|
|
}
|
|
|
|
void JFJochReceiverLite::ImageThread(uint32_t id) {
|
|
logger.Debug("Thread {} started", id);
|
|
|
|
try {
|
|
pin_gpu();
|
|
} catch (const JFJochException &e) {
|
|
logger.Warning("Error pinning GPU {}", e.what());
|
|
}
|
|
|
|
WaitForImages();
|
|
|
|
try {
|
|
// The analysis works on the assembled image; an image in raw module layout is only forwarded.
|
|
if (experiment.IsGeometryTransformed())
|
|
analysis[id] = std::make_unique<MXAnalysisWithoutFPGA>(experiment, *az_int_mapping, pixel_mask, indexer,
|
|
/*enable_fused_adaptive_gpu=*/true);
|
|
} catch (const JFJochException &e) {
|
|
Cancel(e);
|
|
return;
|
|
}
|
|
|
|
PollImages(id);
|
|
|
|
logger.Debug("Thread {} finished", id);
|
|
}
|
|
|
|
void JFJochReceiverLite::OnImage(uint32_t id, DataMessage &data_msg, std::chrono::steady_clock::time_point received) {
|
|
auto start = std::chrono::high_resolution_clock::now();
|
|
|
|
CountImage(data_msg);
|
|
collection_efficiency_sum += data_msg.image_collection_efficiency.value_or(1.0f);
|
|
|
|
auto image_start_time = std::chrono::high_resolution_clock::now();
|
|
|
|
AzimuthalIntegrationProfile profile(*az_int_mapping);
|
|
if (analysis[id])
|
|
analysis[id]->AnalyzeStreamImage(data_msg, profile, GetSpotFindingSettings());
|
|
|
|
auto image_end_time = std::chrono::high_resolution_clock::now();
|
|
std::chrono::duration<float> image_duration = image_end_time - image_start_time;
|
|
|
|
data_msg.processing_time_s = image_duration.count();
|
|
StampImage(data_msg, image_puller.GetCurrentFifoUtilization());
|
|
AddToAverages(data_msg);
|
|
|
|
plots.Add(data_msg, profile);
|
|
scan_result.Add(data_msg);
|
|
|
|
if (!serialmx_filter.ApplyFilter(data_msg))
|
|
++images_skipped;
|
|
else
|
|
ForwardImage(data_msg, image_buffer.GetImageSlot());
|
|
|
|
auto end = std::chrono::high_resolution_clock::now();
|
|
std::chrono::duration<float> duration_total = end - start;
|
|
logger.Debug("Thread {} Image {:6d} processing {:8.04f} s analysis {:8.04f} s",
|
|
id, data_msg.number, duration_total.count(), image_duration.count());
|
|
}
|
|
|
|
float JFJochReceiverLite::GetEfficiency() const {
|
|
if (ExpectedImages() == 0)
|
|
return 0;
|
|
return static_cast<float>(collection_efficiency_sum / static_cast<double>(ExpectedImages()));
|
|
}
|