16#ifndef ALICEO2_ITSMFT_TRACKING_CAPACITYESTIMATOR_H_
17#define ALICEO2_ITSMFT_TRACKING_CAPACITYESTIMATOR_H_
39constexpr const char*
const SlabSiteNames[
SlabSite::NSlabSite]{
"Tracklets",
"Cells",
"Neighbours",
"RoadCandidates",
"Roads",
"TrackSeeds",
"TracksExtended",
"Tracks"};
79 return (
static_cast<KeyType>(site) << 56) |
80 (
static_cast<KeyType>(iteration & 0xFF) << 48) |
81 (
static_cast<KeyType>(variant & 0xFFFF) << 32) |
82 static_cast<KeyType>(
static_cast<uint32_t
>(slot));
85 template <
typename Identifier>
88 return makeKey(site, iteration, variant,
static_cast<int>(identifier.value()));
95 .iteration =
static_cast<int>((
key >> 48) & 0xFF),
96 .variant =
static_cast<int>((
key >> 32) & 0xFFFF),
97 .slot =
static_cast<int>(
static_cast<uint32_t
>(
key & 0xFFFFFFFF))};
102 return ((high & 0xFF) << 8) | (low & 0xFF);
107 return (variant >> 8) & 0xFF;
112 return variant & 0xFF;
129 void update(uint64_t
key,
double scale,
size_t emitted,
size_t capacityUsed,
bool overflowed,
bool memoryLimited);
130 void update(uint64_t
key,
double scale,
size_t requested,
size_t granted,
size_t emitted,
131 size_t spilled,
bool overflowed,
bool memoryLimited);
139template <typename Emit>
142 const auto toInt = [](
const size_t v) {
return static_cast<int>(std::min(
v,
static_cast<size_t>(std::numeric_limits<int>::max()))); };
143 const int initialCapacity = toInt(estimator.capacity(
key, scale));
144 int capacity = std::max(initialCapacity, toInt(floorCapacity));
146 bool overflowed =
false;
147 bool needsRetry =
false;
149 const int attemptCapacity =
capacity;
150 emitted = emit(attemptCapacity);
151 needsRetry = emitted > attemptCapacity;
152 overflowed |= needsRetry;
154 }
while (needsRetry);
155 estimator.update(
key, scale, emitted, initialCapacity, overflowed,
false);
static constexpr int makeVariant(int high, int low) noexcept
void commitTransaction() noexcept
static constexpr int getVariantHigh(int variant) noexcept
static constexpr KeyType makeKey(SlabSite site, int iteration, int variant, int slot) noexcept
void rollbackTransaction() noexcept
static constexpr KeyType makeKey(SlabSite site, int iteration, int variant, Identifier identifier) noexcept
Statistics statistics(uint64_t key) const
size_t capacity(uint64_t key, double scale) const
size_t peakCapacity(uint64_t key) const
CapacityEstimator & operator=(const CapacityEstimator &)=delete
static constexpr int getVariantLow(int variant) noexcept
void update(uint64_t key, double scale, size_t emitted, size_t capacityUsed, bool overflowed, bool memoryLimited)
CapacityEstimator(const CapacityEstimator &)=delete
static constexpr Decoded decodeKey(KeyType key) noexcept
GLfloat GLfloat GLfloat alpha
uint32_t trackClusterIndicesSize noexcept
constexpr const char *const SlabSiteNames[SlabSite::NSlabSite]
float marginOverflowSlack
std::map< std::string, ID > expected