Project
Loading...
Searching...
No Matches
eliasDelta.h
Go to the documentation of this file.
1// Copyright 2019-2023 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
16#ifndef RANS_INTERNAL_PACK_ELIASDELTA_H_
17#define RANS_INTERNAL_PACK_ELIASDELTA_H_
18
19#include <cstdint>
20#include <cstring>
21
26
27namespace o2::rans::internal
28{
29
31{
32 using namespace internal;
33 using namespace utils;
34
35 assert(data > 0);
36
37 const uint32_t highestPow2 = log2UIntNZ(data);
38 const uint32_t nLeadingZeros = log2UIntNZ(highestPow2 + 1);
39
40 packing_type eliasDeltaCode = highestPow2 + 1;
41 eliasDeltaCode = eliasDeltaCode << highestPow2 | bitExtract(data, 0, highestPow2);
42 uint32_t packedSize = nLeadingZeros + nLeadingZeros + 1 + highestPow2;
43
44 return pack(dst, eliasDeltaCode, packedSize);
45};
46
47inline constexpr size_t EliasDeltaDecodeMaxBits = 42;
48
49template <typename dst_T>
50[[nodiscard]] inline dst_T eliasDeltaDecode(BitPtr& srcPos, size_t rBitOffset = EliasDeltaDecodeMaxBits)
51{
52 using namespace internal;
53 using namespace utils;
54 static_assert(sizeof(dst_T) <= sizeof(uint32_t));
55 assert(rBitOffset <= EliasDeltaDecodeMaxBits);
56 constexpr size_t PackingBufferBits = toBits<packing_type>();
57
58 auto unpackedData = unpack<packing_type>(srcPos - rBitOffset, rBitOffset);
59
60 // do delta decoding algorithm
61 unpackedData <<= PackingBufferBits - rBitOffset;
62 const uint32_t nLeadingZeros = __builtin_clzl(unpackedData);
63 uint32_t eliasDeltaBits = 2 * nLeadingZeros + 1;
64 const uint32_t highestPow2 = bitExtract(unpackedData, PackingBufferBits - eliasDeltaBits, nLeadingZeros + 1) - 1;
65 eliasDeltaBits += highestPow2;
66 dst_T decodedValue = static_cast<dst_T>(pow2(highestPow2) + bitExtract(unpackedData, PackingBufferBits - eliasDeltaBits, highestPow2));
67
68 srcPos -= eliasDeltaBits;
69
70 return decodedValue;
71};
72
73} // namespace o2::rans::internal
74
75#endif /* RANS_INTERNAL_PACK_ELIASDELTA_H_ */
Pointer type helper class for bitwise Packing.
configStandalone Light OpenGL display display_light Apply smoothing to points Enable Z buffer Highlight links Highlight seeds Highlight sector tracks Highlight final tracks Show individual Show related Highlight grid Show only individual collision Color clusters belonging to track objects Set line Enable drawing TPC data Enable drawing TOF data Enable drawing magnetic field Set field line step count Invert colors configStandalone Heavy OpenGL display display_heavy Show tracks with ITS contribution Show tracks with TOF contribution Enable propagation of loopers Show clusters at nominal x of pad row for early transformed data Split CE tracks when they cross the central Mark clusters Mark adjacent clusters Hide rejected tracks Apply filter on tracks to be displayed Separate increase X h configStandalone Camera window renderer OpenGL display display_camera Orient the camera such that the y axis is always upwards Full Screen MultiSample Anti Downsampling Anti Enable Vertical Sync Target frame or if the backend cannot limit to the refresh Use OpenGL indirect draws to reduce number of draw calls Display h configStandalone Vulkan display display_vulkan Have uniform buffers in host accessible device memory h internal
common helper classes and functions
helper functionalities useful for packing operations
GLenum GLenum dst
Definition glcorearb.h:1767
packs data into a buffer
dst_T eliasDeltaDecode(BitPtr &srcPos, size_t rBitOffset=EliasDeltaDecodeMaxBits)
Definition eliasDelta.h:50
BitPtr eliasDeltaEncode(BitPtr dst, uint32_t data)
Definition eliasDelta.h:30
constexpr size_t EliasDeltaDecodeMaxBits
Definition eliasDelta.h:47
uint64_t packing_type
Definition utils.h:33
constexpr T log2UIntNZ(T x) noexcept
Definition utils.h:90
uint64_t bitExtract(uint64_t data, uint32_t start, uint32_t length) noexcept
Definition utils.h:58
Common utility functions.