39#include <fairmq/Device.h>
40#include <fairmq/Channel.h>
55 fair::mq::Parts parts;
56 fair::mq::MessagePtr payload(
device->NewMessage());
59 auto channelAlloc = o2::pmr::getTransportAllocator(
device->GetChannel(channel.
name, 0).Transport());
63 parts.AddPart(std::move(
header));
64 parts.AddPart(std::move(payload));
66 LOGP(info,
"Sending end-of-stream message to channel {}", channel.
name);
71 fair::mq::Parts parts;
72 fair::mq::MessagePtr payload(transport->CreateMessage());
75 auto channelAlloc = o2::pmr::getTransportAllocator(transport);
79 parts.AddPart(std::move(
header));
80 parts.AddPart(std::move(payload));
90 if (
state.oldestForChannel.value >= timeslice) {
94 state.oldestForChannel = {timeslice};
103 if (
state.oldestForChannel.value >= timeslice) {
107 state.oldestForChannel = {timeslice};
114 for (
int ci = 0; ci < proxy.getNumOutputChannels(); ++ci) {
115 auto& info = proxy.getOutputChannelInfo({ci});
116 auto&
state = proxy.getOutputChannelState({ci});
128 state.streaming = newState;
134 return std::all_of(spec.
inputs.cbegin(), spec.
inputs.cend(), [](
InputRoute const& route) ->
bool { return route.matcher.lifetime == Lifetime::Timer; });
139 return (spec.
inputChannels.size() == 1) && (spec.
inputs[0].matcher.lifetime == Lifetime::Timer || spec.
inputs[0].matcher.lifetime == Lifetime::Enumeration);
153 O2_SIGNPOST_EVENT_EMIT_INFO(calibration, cid,
"callback",
"Grace period for data processing expired. Switching to EndOfStreaming.");
156 O2_SIGNPOST_EVENT_EMIT_INFO(calibration, cid,
"callback",
"Grace period for data processing expired. Only calibrations from this point onwards.");
183 return state.transitionHandling;
195 if (deviceContext.dataProcessingTimeout > 0 && deviceContext.dataProcessingTimeout < deviceContext.exitTransitionTimeout) {
196 uv_update_time(
state.loop);
197 O2_SIGNPOST_EVENT_EMIT(calibration, cid,
"timer_setup",
"Starting %d s timer for dataProcessingTimeout.", deviceContext.dataProcessingTimeout);
198 uv_timer_start(deviceContext.dataProcessingGracePeriodTimer,
on_data_processing_expired, deviceContext.dataProcessingTimeout * 1000, 0);
202 uv_update_time(
state.loop);
204 deviceContext.exitTransitionTimeout);
207 int timeout = onlyGenerated ? deviceContext.dataProcessingTimeout : deviceContext.exitTransitionTimeout;
212 "New state requested. Waiting for %d seconds before %{public}s",
214 onlyGenerated ?
"dropping remaining input and switching to READY state." :
"switching to READY state.");
232 const bool copyByDefault,
bool consume)
235 std::vector<ChannelIndex> forwardingChoices{};
237 while (pi < messages.size()) {
238 auto&
header = messages[pi];
244 if (
header->GetData() ==
nullptr) {
248 auto dih = o2::header::get<DomainInfoHeader*>(
header->GetData());
253 auto sih = o2::header::get<SourceInfoHeader*>(
header->GetData());
259 auto dph = o2::header::get<DataProcessingHeader*>(
header->GetData());
260 auto dh = o2::header::get<o2::header::DataHeader*>(
header->GetData());
262 if (dph ==
nullptr || dh ==
nullptr) {
264 LOGP(
error,
"Data is missing {}{}{}",
265 dph ?
"DataProcessingHeader" :
"", dph || dh ?
"and" :
"", dh ?
"DataHeader" :
"");
271 auto& payload = messages[pi + 1];
274 size_t numberOfMessages = 0;
275 if (dh->splitPayloadParts > 0 && dh->splitPayloadParts == dh->splitPayloadIndex) {
277 numberOfMessages = dh->splitPayloadParts + 1;
281 numberOfMessages = (dh->splitPayloadParts > 0 ? dh->splitPayloadParts : 1) * 2;
284 if (payload.get() ==
nullptr && consume ==
true) {
289 pi += numberOfMessages;
308 forwardingChoices.clear();
311 if (forwardingChoices.empty()) {
313 pi += numberOfMessages;
319 if (copyByDefault || forwardingChoices.size() > 1) {
320 for (
auto& choice : forwardingChoices) {
322 fmt::format(
"{}/{}/{}@timeslice:{} tfCounter:{}", dh->dataOrigin, dh->dataDescription, dh->subSpecification, dph->startTime, dh->tfCounter).c_str(), choice.value);
324 for (
size_t ppi = pi; ppi < pi + numberOfMessages; ++ppi) {
325 auto&& newMsg =
header->GetTransport()->CreateMessage();
326 newMsg->Copy(*messages[ppi]);
327 forwardedParts[choice.value].AddPart(std::move(newMsg));
332 fmt::format(
"{}/{}/{}@timeslice:{} tfCounter:{}", dh->dataOrigin, dh->dataDescription, dh->subSpecification, dph->startTime, dh->tfCounter).c_str(), forwardingChoices.back().value);
333 for (
size_t ppi = pi; ppi < pi + numberOfMessages; ++ppi) {
334 forwardedParts[forwardingChoices.back().value].AddPart(std::move(messages[ppi]));
337 pi += numberOfMessages;
344 while (pi < messages.size()) {
345 auto&
header = messages[pi];
351 if (
header->GetData() ==
nullptr ||
352 o2::header::get<DomainInfoHeader*>(
header->GetData()) ||
353 o2::header::get<SourceInfoHeader*>(
header->GetData())) {
358 auto dph = o2::header::get<DataProcessingHeader*>(
header->GetData());
359 auto dh = o2::header::get<o2::header::DataHeader*>(
header->GetData());
361 if (dph ==
nullptr || dh ==
nullptr) {
363 LOGP(
error,
"Data is missing {}{}{}",
364 dph ?
"DataProcessingHeader" :
"", dph || dh ?
"and" :
"", dh ?
"DataHeader" :
"");
370 auto& payload = messages[pi + 1];
373 size_t numberOfMessages = 0;
374 if (dh->splitPayloadParts > 0 && dh->splitPayloadParts == dh->splitPayloadIndex) {
376 numberOfMessages = dh->splitPayloadParts + 1;
380 numberOfMessages = (dh->splitPayloadParts > 0 ? dh->splitPayloadParts : 1) * 2;
383 if (payload.get() ==
nullptr && consume ==
true) {
391 pi += numberOfMessages;
396 std::vector<std::span<fair::mq::MessagePtr>>& currentSetOfInputs,
397 const bool copyByDefault,
bool consume) -> std::vector<fair::mq::Parts>
400 std::vector<fair::mq::Parts> forwardedParts(proxy.getNumForwardChannels());
402 for (
size_t ii = 0, ie = currentSetOfInputs.size(); ii < ie; ++ii) {
403 routeForwardedMessages(proxy, currentSetOfInputs[ii], forwardedParts, copyByDefault, consume);
405 return forwardedParts;
struct uv_timer_s uv_timer_t
std::vector< std::string > header
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc Replace constant variables static by constexpr expressions Compile RTC in deterministic with NO_FAST_MATH flags and GPUCA_DETERMINISTIC_MODE define Use RTC to optimize GPU code h configStandalone Processing proc_rtctech Use a file lock to serialize access to the cache folder Print launch bounds used for RTC code as debugging for exit after Allow RTC with slave GPUReconstruction instances with optConstexpr and optSpecialcode Maximum number of RTC cache files per backend in the cache the oldest are Prepend RTC compilation commands by this string Load a parameter object containing the launch bounds from a file h configStandalone Processing proc_param TPC Cluster Z Error Parameterization h configStandalone Processing settings for neural network proc_nn std::string Specify inference device(cpu(default), rocm, cuda)") AddOption(nnInferenceDeviceId
char error[CURL_ERROR_SIZE]
#define O2_SIGNPOST_EVENT_EMIT_ERROR(log, id, name, format,...)
#define O2_DECLARE_DYNAMIC_LOG(name)
#define O2_SIGNPOST_ID_FROM_POINTER(name, log, pointer)
#define O2_SIGNPOST_EVENT_EMIT_INFO(log, id, name, format,...)
#define O2_SIGNPOST_END(log, id, name, format,...)
#define O2_SIGNPOST_ID_GENERATE(name, log)
#define O2_SIGNPOST_EVENT_EMIT_WARN(log, id, name, format,...)
#define O2_SIGNPOST_EVENT_EMIT(log, id, name, format,...)
#define O2_SIGNPOST_START(log, id, name, format,...)
void getMatchingForwardChannelIndexes(std::vector< ChannelIndex > &result, header::DataHeader const &header, size_t timeslice) const
Retrieve the channel index from a given OutputSpec and the associated timeslice.
virtual fair::mq::Device * device()=0
GLbitfield GLuint64 timeout
Defining ITS Vertex explicitly as messageable.
void on_transition_requested_expired(uv_timer_t *handle)
void doSendOldestPossibleTimeframe(ServiceRegistryRef ref, fair::mq::TransportFactory *transport, ChannelIndex index, SendingPolicy::SendingCallback const &callback, size_t timeslice)
@ EndOfStreaming
End of streaming requested, but not notified.
@ Idle
End of streaming notified.
@ Expired
A transition needs to be fullfilled ASAP.
@ NoTransition
No pending transitions.
@ Requested
A transition was notified to be requested.
@ Completed
The channel was signaled it will not receive any data.
void on_data_processing_expired(uv_timer_t *handle)
bool hasOnlyTimers(DeviceSpec const &spec)
fair::mq::MessagePtr getMessage(ContainerT &&container, FairMQMemoryResource *targetResource=nullptr)
static bool hasOnlyGenerated(DeviceSpec const &spec)
check if spec is a source devide
static std::vector< fair::mq::Parts > routeForwardedMessageSet(FairMQDeviceProxy &proxy, std::vector< std::span< fair::mq::MessagePtr > > ¤tSetOfInputs, bool copy, bool consume)
Helper to route messages for forwarding.
static TransitionHandlingState updateStateTransition(ServiceRegistryRef const &ref, ProcessingPolicies const &policies)
starts the EoS timers and returns the new TransitionHandlingState in case as new state is requested
static void switchState(ServiceRegistryRef const &ref, StreamingState newState)
change the device StreamingState to newState
static void sendEndOfStream(ServiceRegistryRef const &ref, OutputChannelSpec const &channel)
static bool sendOldestPossibleTimeframe(ServiceRegistryRef const &ref, ForwardChannelInfo const &info, ForwardChannelState &state, size_t timeslice)
static void cleanForwardedMessages(std::span< fair::mq::MessagePtr > ¤tSetOfInputs, bool consume)
static void broadcastOldestPossibleTimeslice(ServiceRegistryRef const &ref, size_t timeslice)
Broadcast the oldest possible timeslice to all channels in output.
static void routeForwardedMessages(FairMQDeviceProxy &proxy, std::span< fair::mq::MessagePtr > ¤tSetOfInputs, std::vector< fair::mq::Parts > &forwardedParts, bool copy, bool consume)
Helper to route messages for forwarding.
bool suppressDomainInfo
do not advertise/forward DomainInfoHeader from this device
static bool onlineDeploymentMode()
@true if running online
std::vector< InputRoute > inputs
std::vector< InputChannelSpec > inputChannels
Running state information of a given device.
a BaseHeader with domain information from the source
size_t oldestPossibleTimeslice
Forward channel information.
Output channel information.
enum TerminationPolicy termination
std::function< void(fair::mq::Parts &, ChannelIndex channelIndex, ServiceRegistryRef registry)> SendingCallback