-
Notifications
You must be signed in to change notification settings - Fork 494
Expand file tree
/
Copy pathdata-generator-workflow.cxx
More file actions
49 lines (43 loc) · 2.6 KB
/
data-generator-workflow.cxx
File metadata and controls
49 lines (43 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// 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/DataProcessorSpec.h"
#include "DataGeneratorSpec.h"
using namespace o2::framework;
// we need to add workflow options before including Framework/runDataProcessing
void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
{
// option allowing to set parameters
workflowOptions.push_back(ConfigParamSpec{"lanes", o2::framework::VariantType::Int, 2, {"number of data generator lanes"}});
workflowOptions.push_back(ConfigParamSpec{"gen-norm", o2::framework::VariantType::Int, 1, {"nominal number of expected generators"}});
workflowOptions.push_back(ConfigParamSpec{"gen-slot", o2::framework::VariantType::Int, 0, {"generate TFs of slot in [0 : gen-norm) range"}});
workflowOptions.push_back(ConfigParamSpec{"pressure", o2::framework::VariantType::Float, 1.f, {"generation / processing rate factor"}});
workflowOptions.push_back(ConfigParamSpec{"mean-latency", o2::framework::VariantType::Int, 1000, {"mean latency of the processor in microseconds"}});
workflowOptions.push_back(ConfigParamSpec{"latency-spread", o2::framework::VariantType::Int, 100, {"latency gaussian RMS of the processor in microseconds"}});
}
// ------------------------------------------------------------------
#include "Framework/runDataProcessing.h"
WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
{
WorkflowSpec specs;
auto nlanes = std::max(1, configcontext.options().get<int>("lanes"));
auto ngen = std::max(1, configcontext.options().get<int>("gen-norm"));
auto slot = std::max(0, configcontext.options().get<int>("gen-slot"));
auto latency = std::max(1, configcontext.options().get<int>("mean-latency"));
auto latencyRMS = std::max(1, configcontext.options().get<int>("latency-spread"));
auto pressure = std::max(0.001f, configcontext.options().get<float>("pressure"));
if (slot >= ngen) {
slot = 0;
ngen = 1;
}
specs.emplace_back(getTFDispatcherSpec(slot, ngen, nlanes, std::max(1, int(float(latency) / nlanes / pressure))));
specs.emplace_back(timePipeline(getTFProcessorSpec(latency, latencyRMS), nlanes));
return specs;
}