Project
Loading...
Searching...
No Matches
TimeFrameScratch.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
13
14#include <stdexcept>
15
17{
18
19namespace
20{
21template <typename Operation, typename... Containers>
22void applyToContainers(Operation&& operation, Containers&... containers)
23{
24 (operation(containers), ...);
25}
26} // namespace
27
28void TimeFrameScratch::clearResizeEdgeStorage(std::size_t nEdges)
29{
30 auto clearResize = [this, nEdges](auto& container) {
31 clearResizeBoundedVector(container, nEdges, mMemoryPool.get());
32 };
33 applyToContainers(clearResize, mTracklets, mTrackletsLookupTable, mTrackletLabels,
35}
36
37void TimeFrameScratch::clearResizeCellStorage(std::size_t nCells)
38{
39 auto clearResize = [this, nCells](auto& container) {
40 clearResizeBoundedVector(container, nCells, mMemoryPool.get());
41 };
42 applyToContainers(clearResize, mCells, mCellsLookupTable, mCellsNeighbours,
44}
45
46void TimeFrameScratch::configureStorage(std::size_t nEdges, std::size_t nCells)
47{
48 mNEdges = nEdges;
49 mNCells = nCells;
50 clearResizeEdgeStorage(nEdges);
51 clearResizeCellStorage(nCells);
52}
53
61
73
74void TimeFrameScratch::setMemoryPool(std::shared_ptr<BoundedMemoryResource> pool)
75{
76 mMemoryPool = std::move(pool);
77 applyToContainers([this](auto& container) { deepVectorClear(container, mMemoryPool.get()); },
81}
82
84{
85 std::size_t result = 0;
86 for (const auto& cells : mCells) {
87 result += cells.size();
88 }
89 return result;
90}
91
93{
94 std::size_t result = 0;
95 for (const auto& tracklets : mTracklets) {
96 result += tracklets.size();
97 }
98 return result;
99}
100
102{
103 std::size_t result = 0;
104 for (const auto& neighbours : mCellsNeighbours) {
105 result += neighbours.size();
106 }
107 return result;
108}
109
110void TimeFrameScratch::beginIteration(std::size_t nEdges, std::size_t nCells,
111 gsl::span<const std::size_t> trackletLookupSizes)
112{
113 if (nEdges > mNEdges || nCells > mNCells || trackletLookupSizes.size() != nEdges) {
114 throw std::logic_error{"TimeFrameScratch::beginIteration(): requested storage exceeds configured capacity"};
115 }
116
117 clearResizeCellStorage(nCells);
118 clearResizeEdgeStorage(nEdges);
119
120 for (std::size_t edge = 0; edge < nEdges; ++edge) {
121 mTrackletsLookupTable[edge].resize(trackletLookupSizes[edge] + 1, 0);
122 }
123}
124
125} // namespace o2::itsmft::tracking
BasicOp operation
Runtime-plan-owned, detector-neutral CA workspace.
std::vector< bounded_vector< o2::MCCompLabel > > mTrackletLabels
std::vector< bounded_vector< int > > mCellsLookupTable
std::vector< bounded_vector< Triplet > > mCells
std::vector< bounded_vector< int > > mTrackletsLookupTable
void beginIteration(std::size_t nEdges, std::size_t nCells, gsl::span< const std::size_t > trackletLookupSizes)
void setMemoryPool(std::shared_ptr< BoundedMemoryResource > pool)
Reseat allocator-backed containers.
std::vector< bounded_vector< int > > mCellsNeighboursLUT
std::vector< bounded_vector< int > > mCellsNeighbours
std::vector< bounded_vector< int > > mCellsNeighboursTopology
std::vector< bounded_vector< Tracklet > > mTracklets
void configureStorage(std::size_t nEdges, std::size_t nCells)
Size reusable edge and cell storage; setMemoryPool() comes first.
void reset()
Clear iteration state without changing plan sizes.
std::vector< bounded_vector< o2::MCCompLabel > > mCellLabels
void clearStorage() noexcept
Release plan-sized storage while preserving this object's identity.
GLuint64EXT * result
Definition glcorearb.h:5662
void deepVectorClear(std::vector< T > &vec)
void clearResizeBoundedVector(bounded_vector< T > &vec, size_t sz, std::pmr::memory_resource *mr=nullptr, T def=T())
uint32_t trackClusterIndicesSize noexcept
std::vector< Cell > cells
std::vector< Tracklet64 > tracklets