Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Detectors/ITSMFT/ITS/tracking/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ o2_add_library(ITStracking
TARGETVARNAME targetName
SOURCES src/ClusterLines.cxx
src/Cluster.cxx
src/CapacityEstimator.cxx
src/Configuration.cxx
src/FastMultEstConfig.cxx
src/FastMultEst.cxx
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
// Copyright 2019-2026 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.
///
/// \file CapacityEstimator.h
/// \brief Cross-timeframe output-size prediction.
///

#ifndef TRACKINGITSU_INCLUDE_CAPACITYESTIMATOR_H_
#define TRACKINGITSU_INCLUDE_CAPACITYESTIMATOR_H_

#include <cstddef>
#include <cstdint>
#include <memory>

namespace o2::its
{

enum SlabSite : uint8_t {
Tracklets = 0,
Cells,
Neighbours,
Roads,
NSlabSite,
};
constexpr const char* const SlabSiteNames[SlabSite::NSlabSite]{"Tracklets", "Cells", "Neighbours", "Roads"};

class CapacityEstimator
{
public:
struct Config {
float alpha{0.2f};
float marginInit{1.30f};
float marginMin{1.10f};
float marginMax{4.00f};
float marginUp{1.50f};
float marginOverflowSlack{1.05f};
float marginDown{0.98f};
float lowWatermark{0.60f};
uint32_t decayAfter{2};
size_t floorSlots{1024};
};

using KeyType = uint64_t;

struct Decoded {
SlabSite site;
int iteration;
int variant;
int slot;
};

static constexpr KeyType makeKey(SlabSite site, int iteration, int variant, int slot) noexcept
{
return (static_cast<KeyType>(site) << 56) |
(static_cast<KeyType>(iteration & 0xFF) << 48) |
(static_cast<KeyType>(variant & 0xFFFF) << 32) |
static_cast<KeyType>(static_cast<uint32_t>(slot));
}

static constexpr Decoded decodeKey(KeyType key) noexcept
{
return {
.site = static_cast<SlabSite>((key >> 56) & 0xFF),
.iteration = static_cast<int>((key >> 48) & 0xFF),
.variant = static_cast<int>((key >> 32) & 0xFFFF),
.slot = static_cast<int>(static_cast<uint32_t>(key & 0xFFFFFFFF))};
}

static constexpr int makeVariant(int high, int low) noexcept
{
return ((high & 0xFF) << 8) | (low & 0xFF);
}

static constexpr int getVariantHigh(int variant) noexcept
{
return (variant >> 8) & 0xFF;
}

static constexpr int getVariantLow(int variant) noexcept
{
return variant & 0xFF;
}

CapacityEstimator();
explicit CapacityEstimator(Config cfg);
~CapacityEstimator();
CapacityEstimator(const CapacityEstimator&) = delete;
CapacityEstimator& operator=(const CapacityEstimator&) = delete;

void reset();
size_t capacity(uint64_t key, double scale) const;
void update(uint64_t key, double scale, size_t emitted, size_t capacityUsed, bool overflowed, bool memoryLimited);
void print() const;

private:
struct Impl;
std::unique_ptr<Impl> mImpl;
};

} // namespace o2::its

#endif /* TRACKINGITSU_INCLUDE_CAPACITYESTIMATOR_H_ */
Loading