Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Framework/Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ foreach(w
Forwarding
ParallelPipeline
ParallelProducer
PipelinedSourceEndOfStream
SlowConsumer
SlowProducerWithWildCard
SimpleDataProcessingDevice01
Expand Down
21 changes: 18 additions & 3 deletions Framework/Core/src/DataProcessingDevice.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1550,7 +1550,9 @@ void DataProcessingDevice::doPrepare(ServiceRegistryRef ref)
O2_SIGNPOST_END(device, dpid, "do_prepare", "Nothing to poll. Waiting for next iteration.");
return;
}
auto currentOldest = state.inputChannelInfos[pollOrder.front()].oldestForChannel;
// A completed channel will not send anything anymore, so it must not hold back the others.
auto oldestRunning = std::ranges::find_if(pollOrder, [&infos = state.inputChannelInfos](int a) { return infos[a].state != InputChannelState::Completed; });
auto currentOldest = state.inputChannelInfos[oldestRunning != pollOrder.end() ? *oldestRunning : pollOrder.front()].oldestForChannel;
auto currentNewest = state.inputChannelInfos[pollOrder.back()].oldestForChannel;
auto delta = currentNewest.value - currentOldest.value;
O2_SIGNPOST_EVENT_EMIT(device, dpid, "do_prepare", "Oldest possible timeframe range %" PRIu64 " => %" PRIu64 " delta %" PRIu64,
Expand Down Expand Up @@ -1729,8 +1731,21 @@ void DataProcessingDevice::doRun(ServiceRegistryRef ref)

bool shouldProcess = DataProcessingHelpers::hasOnlyGenerated(spec) == false;

while (DataProcessingDevice::tryDispatchComputation(ref, streamContext.completed) && shouldProcess) {
relayer.processDanglingInputs(context.expirationHandlers, *context.registry, false);
auto& decongestion = ref.get<DecongestionService>();
while (true) {
while (DataProcessingDevice::tryDispatchComputation(ref, streamContext.completed) && shouldProcess) {
relayer.processDanglingInputs(context.expirationHandlers, *context.registry, false);
}
// No input can arrive anymore, so an ordered consumer must not wait for the timeslices it misses.
if (!shouldProcess || !decongestion.orderedCompletionPolicyActive) {
break;
}
auto oldest = (int64_t)ref.get<TimesliceIndex>().updateOldestPossibleOutput(false).timeslice.value;
if (oldest <= decongestion.nextTimeslice) {
break;
}
decongestion.nextTimeslice = oldest;
ref.get<TimesliceIndex>().rescan();
}

auto& timingInfo = ref.get<TimingInfo>();
Expand Down
4 changes: 2 additions & 2 deletions Framework/Core/src/TimesliceIndex.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ TimesliceIndex::OldestInputInfo TimesliceIndex::setOldestPossibleInput(Timeslice
OldestInputInfo result{timestamp, channel};
bool changed = false;
for (int ci = 0; ci < mChannels.size(); ci++) {
// Check if this is a real channel. Skip otherwise.
// Check if this is a real channel which can still send data. Skip otherwise.
auto& channelRef = mChannels[ci];
if (channelRef.channelType != ChannelAccountingType::DPL) {
if (channelRef.channelType != ChannelAccountingType::DPL || channelRef.state == InputChannelState::Completed) {
continue;
}
auto& a = channelRef.oldestForChannel;
Expand Down
66 changes: 66 additions & 0 deletions Framework/Core/test/test_PipelinedSourceEndOfStream.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#include "Framework/CompletionPolicyHelpers.h"

void customize(std::vector<o2::framework::CompletionPolicy>& policies)
{
policies.push_back(o2::framework::CompletionPolicyHelpers::consumeWhenAllOrdered("ordered-consumer"));
}

#include "Framework/CallbackService.h"
#include "Framework/ControlService.h"
#include "Framework/DeviceSpec.h"
#include "Framework/EndOfStreamContext.h"
#include "Framework/Logger.h"
#include "Framework/runDataProcessing.h"

using namespace o2::framework;

// A source with two time-pipelined lanes, like the AOD reader with --readers 2,
// where one lane has nothing to read and ends immediately. The other lane must
// still deliver all its data: the completed channel must hold back neither the
// polling of the other channel nor the oldest possible timeslice.
constexpr int nTimeframes = 100;

DataProcessorSpec consumer(std::string name)
{
return DataProcessorSpec{
.name = name,
.inputs = {InputSpec{"data", "TST", "PIPELINED"}},
.algorithm = adaptStateful([](CallbackService& callbacks) {
static int received = 0;
callbacks.set<CallbackService::Id::EndOfStream>([](EndOfStreamContext&) {
if (received != nTimeframes) {
LOGP(fatal, "Received {} timeframes, expected {}", received, nTimeframes);
}
});
return adaptStateless([]() { received++; });
})};
}

WorkflowSpec defineDataProcessing(ConfigContext const&)
{
return WorkflowSpec{
timePipeline(DataProcessorSpec{
.name = "producer",
.outputs = {OutputSpec{{"data"}, "TST", "PIPELINED"}},
.algorithm = adaptStateless([](DataAllocator& outputs, ControlService& control, DeviceSpec const& spec) {
static int sent = 0;
if (spec.inputTimesliceId == 1 || sent == nTimeframes) {
control.endOfStream();
control.readyToQuit(QuitRequest::Me);
return;
}
outputs.make<int>(Output{"TST", "PIPELINED", 0}) = sent++;
})},
2),
consumer("consumer"), consumer("ordered-consumer")};
}