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 {"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings"}}};
36
37 std::swap(workflowOptions, options);
38}
39
41
43{
44 using namespace o2::tpc;
45 o2::conf::ConfigurableParam::updateFromString(config.options().get<std::string>("configKeyValues"));
46 const auto tpcCRUs = o2::RangeTokenizer::tokenize<int>(config.options().get<std::string>("crus"));
47 const auto nCRUs = tpcCRUs.size();
48 const auto nLanes = std::min(static_cast<unsigned long>(config.options().get<int>("lanes")), nCRUs);
49 const auto time_lanes = static_cast<unsigned int>(config.options().get<int>("time-lanes"));
50 const auto crusPerLane = nCRUs / nLanes + ((nCRUs % nLanes) != 0);
51 const int nTFsBuffer = config.options().get<int>("n-TFs-buffer");
52
53 o2::conf::ConfigurableParam::updateFromFile(config.options().get<std::string>("configFile"));
54 o2::conf::ConfigurableParam::writeINI("o2tpcflp_configuration.ini");
55
56 WorkflowSpec workflow;
57 if (nLanes <= 0) {
58 return workflow;
59 }
60
61 for (int ilane = 0; ilane < nLanes; ++ilane) {
62 const auto first = tpcCRUs.begin() + ilane * crusPerLane;
63 if (first >= tpcCRUs.end()) {
64 break;
65 }
66 const auto last = std::min(tpcCRUs.end(), first + crusPerLane);
67 const std::vector<uint32_t> rangeCRUs(first, last);
68 workflow.emplace_back(timePipeline(getTPCFLPCMVSpec(ilane, rangeCRUs, nTFsBuffer), time_lanes));
69 }
70
71 return workflow;
72}
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
DataProcessorSpec getTPCFLPCMVSpec(const int ilane, const std::vector< uint32_t > &crus, const int nTFsBuffer=1)
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)