Skip to content

Commit 642289b

Browse files
committed
DPL: provide ability to customise consumption order
1 parent c57a63a commit 642289b

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

Framework/Core/include/Framework/CompletionPolicy.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ struct CompletionPolicy {
6262
Retry,
6363
};
6464

65+
/// Order in which the completed slots must be consumed
66+
enum struct CompletionOrder {
67+
Any,
68+
Timeslice,
69+
Slot
70+
};
71+
6572
using Matcher = std::function<bool(DeviceSpec const& device)>;
6673
using InputSetElement = DataRef;
6774
using CallbackFull = std::function<CompletionOp(InputSpan const&, std::vector<InputSpec> const&, ServiceRegistryRef&)>;
@@ -91,6 +98,8 @@ struct CompletionPolicy {
9198
/// data.
9299
bool balanceChannels = true;
93100

101+
CompletionOrder order = CompletionOrder::Any;
102+
94103
/// Helper to create the default configuration.
95104
static std::vector<CompletionPolicy> createDefaultPolicies();
96105
};

Framework/Core/src/DataProcessingDevice.cxx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2307,6 +2307,17 @@ bool DataProcessingDevice::tryDispatchComputation(ServiceRegistryRef ref, std::v
23072307
using namespace o2::framework;
23082308
stats.updateStats({(int)ProcessingStatsId::PENDING_INPUTS, DataProcessingStats::Op::Set, static_cast<int64_t>(relayer.getParallelTimeslices() - completed.size())});
23092309
stats.updateStats({(int)ProcessingStatsId::INCOMPLETE_INPUTS, DataProcessingStats::Op::Set, completed.empty() ? 1 : 0});
2310+
switch (spec.completionPolicy.order) {
2311+
case CompletionPolicy::CompletionOrder::Timeslice:
2312+
std::sort(completed.begin(), completed.end(), [](auto const& a, auto const& b) { return a.timeslice.value < b.timeslice.value; });
2313+
break;
2314+
case CompletionPolicy::CompletionOrder::Slot:
2315+
std::sort(completed.begin(), completed.end(), [](auto const& a, auto const& b) { return a.slot.index < b.slot.index; });
2316+
break;
2317+
case CompletionPolicy::CompletionOrder::Any:
2318+
default:
2319+
break;
2320+
}
23102321

23112322
for (auto action : completed) {
23122323
O2_SIGNPOST_ID_GENERATE(aid, device);

0 commit comments

Comments
 (0)