Project
Loading...
Searching...
No Matches
tpc-flp-cmv.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#include <vector>
13#include <string>
14#include <thread>
20#include "TPCBase/CRU.h"
21
22using namespace o2::framework;
23
24void customize(std::vector<ConfigParamSpec>& workflowOptions)
25{
26 const std::string cruDefault = "0-" + std::to_string(o2::tpc::CRU::MaxCRU - 1);
27 const int defaultlanes = std::max(1u, std::thread::hardware_concurrency() / 2);
28
29 std::vector<ConfigParamSpec> options{
30 {"configFile", VariantType::String, "", {"configuration file for configurable parameters"}},
31 {"lanes", VariantType::Int, defaultlanes, {"Number of parallel processing lanes (crus are split per device)"}},
32 {"time-lanes", VariantType::Int, 1, {"Number of parallel processing lanes (timeframes are split per device)"}},
33 {"crus", VariantType::String, cruDefault.c_str(), {"List of CRUs, comma separated ranges, e.g. 0-3,7,9-15"}},
34 {"n-TFs-buffer", VariantType::Int, 1, {"Buffer n-TFs before sending output"}},
35 {"trigger-per-flp", VariantType::Bool, false, {"Aggregate triggers of CRUs on FLP to a single trigger"}},
36 {"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings"}}};
37
38 std::swap(workflowOptions, options);
39}
40
42
44{
45 using namespace o2::tpc;
46 o2::conf::ConfigurableParam::updateFromString(config.options().get<std::string>("configKeyValues"));
47 const auto tpcCRUs = o2::RangeTokenizer::tokenize<int>(config.options().get<std::string>("crus"));
48 const auto nCRUs = tpcCRUs.size();
49 const auto nLanes = std::min(static_cast<unsigned long>(config.options().get<int>("lanes")), nCRUs);
50 const auto time_lanes = static_cast<unsigned int>(config.options().get<int>("time-lanes"));
51 const auto crusPerLane = nCRUs / nLanes + ((nCRUs % nLanes) != 0);
52 const bool triggerPerFLP = config.options().get<bool>("trigger-per-flp");
53 const int nTFsBuffer = config.options().get<int>("n-TFs-buffer");
54
55 o2::conf::ConfigurableParam::updateFromFile(config.options().get<std::string>("configFile"));
56 o2::conf::ConfigurableParam::writeINI("o2tpcflp_configuration.ini");
57
58 WorkflowSpec workflow;
59 if (nLanes <= 0) {
60 return workflow;
61 }
62
63 for (int ilane = 0; ilane < nLanes; ++ilane) {
64 const auto first = tpcCRUs.begin() + ilane * crusPerLane;
65 if (first >= tpcCRUs.end()) {
66 break;
67 }
68 const auto last = std::min(tpcCRUs.end(), first + crusPerLane);
69 const std::vector<uint32_t> rangeCRUs(first, last);
70 workflow.emplace_back(timePipeline(getTPCFLPCMVSpec(ilane, rangeCRUs, triggerPerFLP, nTFsBuffer), time_lanes));
71 }
72
73 return workflow;
74}
Helper function to tokenize sequences and ranges of integral numbers.
TPC device for processing CMVs on FLPs.
static void writeINI(std::string const &filename, std::string const &keyOnly="")
static void updateFromFile(std::string const &, std::string const &paramsList="", bool unchangedOnly=false)
static void updateFromString(std::string const &)
ConfigParamRegistry & options() const
@ MaxCRU
Definition CRU.h:31
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
std::vector< DataProcessorSpec > WorkflowSpec
DataProcessorSpec timePipeline(DataProcessorSpec original, size_t count)
Global TPC definitions and constants.
Definition SimTraits.h:168
std::string to_string(gsl::span< T, Size > span)
Definition common.h:52
WorkflowSpec defineDataProcessing(ConfigContext const &config)
This function hooks up the the workflow specifications into the DPL driver.
void customize(std::vector< ConfigParamSpec > &workflowOptions)