Project
Loading...
Searching...
No Matches
EntropyEncoderSpec.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
15
17
18#include <vector>
19#include <unordered_map>
23#include "Framework/DataRef.h"
25#include "Headers/DataHeader.h"
28
29using namespace o2::framework;
30
31namespace o2
32{
33namespace mid
34{
35EntropyEncoderSpec::EntropyEncoderSpec(bool selIR, const std::string& ctfdictOpt) : mCTFCoder(o2::ctf::CTFCoderBase::OpType::Encoder, ctfdictOpt), mSelIR(selIR)
36{
37 mTimer.Stop();
38 mTimer.Reset();
39}
40
42{
43 if (mCTFCoder.finaliseCCDB<CTF>(matcher, obj)) {
44 return;
45 }
46}
47
49{
50 mCTFCoder.init<CTF>(ic);
51}
52
54{
55 auto cput = mTimer.CpuTime();
56 mTimer.Start(false);
57 mCTFCoder.updateTimeDependentParams(pc, true);
59 size_t insize = 0;
60 for (o2::header::DataHeader::SubSpecificationType subSpec = 0; subSpec < NEvTypes; ++subSpec) {
61 tfData.colData[subSpec] = pc.inputs().get<gsl::span<o2::mid::ColumnData>>(fmt::format("cols_{}", subSpec));
62 insize += tfData.colData[subSpec].size() * sizeof(o2::mid::ColumnData);
63
64 tfData.rofData[subSpec] = pc.inputs().get<gsl::span<o2::mid::ROFRecord>>(fmt::format("rofs_{}", subSpec));
65 insize += tfData.rofData[subSpec].size() * sizeof(o2::mid::ROFRecord);
66 }
67
68 if (mSelIR) {
69 mCTFCoder.setSelectedIRFrames(pc.inputs().get<gsl::span<o2::dataformats::IRFrame>>("selIRFrames"));
70 }
71 // build references for looping over the data in BC increasing direction
72 tfData.buildReferences(mCTFCoder.getIRFramesSelector());
73
74 auto& buffer = pc.outputs().make<std::vector<o2::ctf::BufferType>>(Output{header::gDataOriginMID, "CTFDATA", 0});
75 auto iosize = mCTFCoder.encode(buffer, tfData);
76 pc.outputs().snapshot({"ctfrep", 0}, iosize);
77 iosize.rawIn = insize;
78 if (mSelIR) {
79 mCTFCoder.getIRFramesSelector().clear();
80 }
81 mTimer.Stop();
82 LOG(info) << iosize.asString() << " in " << mTimer.CpuTime() - cput << " s";
83}
84
86{
87 LOGF(info, "MID Entropy Encoding total timing: Cpu: %.3e Real: %.3e s in %d slots",
88 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
89}
90
91DataProcessorSpec getEntropyEncoderSpec(bool selIR, const std::string& ctfdictOpt)
92{
93 std::vector<InputSpec> inputs;
94 for (o2::header::DataHeader::SubSpecificationType subSpec = 0; subSpec < NEvTypes; ++subSpec) {
95 inputs.emplace_back(fmt::format("cols_{}", subSpec), header::gDataOriginMID, "DATA", subSpec, Lifetime::Timeframe);
96 inputs.emplace_back(fmt::format("rofs_{}", subSpec), header::gDataOriginMID, "DATAROF", subSpec, Lifetime::Timeframe);
97 }
98
99 if (ctfdictOpt.empty() || ctfdictOpt == "ccdb") {
100 inputs.emplace_back("ctfdict", header::gDataOriginMID, "CTFDICT", 0, Lifetime::Condition, ccdbParamSpec("MID/Calib/CTFDictionaryTree"));
101 }
102 if (selIR) {
103 inputs.emplace_back("selIRFrames", "CTF", "SELIRFRAMES", 0, Lifetime::Timeframe);
104 }
105 return DataProcessorSpec{
106 "mid-entropy-encoder",
107 inputs,
108 Outputs{{header::gDataOriginMID, "CTFDATA", 0, Lifetime::Timeframe},
109 {{"ctfrep"}, header::gDataOriginMID, "CTFENCREP", 0, Lifetime::Timeframe}},
110 AlgorithmSpec{adaptFromTask<EntropyEncoderSpec>(selIR, ctfdictOpt)},
111 Options{{"irframe-margin-bwd", VariantType::UInt32, 0u, {"margin in BC to add to the IRFrame lower boundary when selection is requested"}},
112 {"irframe-margin-fwd", VariantType::UInt32, 0u, {"margin in BC to add to the IRFrame upper boundary when selection is requested"}},
113 {"mem-factor", VariantType::Float, 1.f, {"Memory allocation margin factor"}},
114 {"ans-version", VariantType::String, {"version of ans entropy coder implementation to use"}}}};
115}
116} // namespace mid
117} // namespace o2
Declarations for CTFCoderBase class (support of external dictionaries)
A helper class to iteratate over all parts of all input routes.
Convert MID data to CTF (EncodedBlocks)
Definition of the Names Generator class.
void updateTimeDependentParams(o2::framework::ProcessingContext &pc, bool askTree=false)
void init(o2::framework::InitContext &ic)
void setSelectedIRFrames(const SPAN &sp)
o2::utils::IRFrameSelector & getIRFramesSelector()
bool finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj)
void snapshot(const Output &spec, T const &object)
decltype(auto) make(const Output &spec, Args... args)
decltype(auto) get(R binding, int part=0) const
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
InputRecord & inputs()
The inputs associated with this processing context.
o2::ctf::CTFIOSize encode(VEC &buff, const CTFHelper::TFData &tfData)
entropy-encode data to buffer with CTF
Definition CTFCoder.h:60
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void run(o2::framework::ProcessingContext &pc) final
void init(o2::framework::InitContext &ic) final
void finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj) final
EntropyEncoderSpec(bool selIR, const std::string &ctfdictOpt="none")
GLuint buffer
Definition glcorearb.h:655
constexpr o2::header::DataOrigin gDataOriginMID
Definition DataHeader.h:573
Defining PrimaryVertex explicitly as messageable.
Definition Cartesian.h:288
std::vector< ConfigParamSpec > ccdbParamSpec(std::string const &path, int runDependent, std::vector< CCDBMetadata > metadata={}, int qrate=0)
std::vector< ConfigParamSpec > Options
std::vector< OutputSpec > Outputs
framework::DataProcessorSpec getEntropyEncoderSpec(bool selIR=false, const std::string &ctfdictOpt="none")
create a processor spec
constexpr uint32_t NEvTypes
Definition ROFRecord.h:37
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
uint32_t SubSpecificationType
Definition DataHeader.h:622
std::array< gsl::span< const o2::mid::ColumnData >, NEvTypes > colData
Definition CTFHelper.h:42
wrapper for the Entropy-encoded clusters of the TF
Definition CTF.h:41
Column data structure for MID.
Definition ColumnData.h:29
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
CTFHelper::TFData tfData