Skip to content

Commit 354fbb1

Browse files
MichaelLettrichshahor02
authored andcommitted
[rANS] Fix Compiler Warnings
1 parent d57a264 commit 354fbb1

21 files changed

+27
-43
lines changed

DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/EncodedBlocks.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ auto EncodedBlocks<H, N, W>::getImage(const void* newHead)
835835
// we don't modify newHead, but still need to remove constness for relocation interface
836836
relocate(image.mRegistry.head, const_cast<char*>(reinterpret_cast<const char*>(newHead)), reinterpret_cast<char*>(&image));
837837

838-
return std::move(image);
838+
return image;
839839
}
840840

841841
///_____________________________________________________________________________
@@ -945,7 +945,6 @@ CTFIOSize EncodedBlocks<H, N, W>::decodeCompatImpl(dst_IT dstBegin, int slot, co
945945
{
946946

947947
// get references to the right data
948-
const auto& ansVersion = getANSHeader();
949948
const auto& block = mBlocks[slot];
950949
const auto& md = mMetadata[slot];
951950

@@ -984,7 +983,6 @@ CTFIOSize EncodedBlocks<H, N, W>::decodeRansV1Impl(dst_IT dstBegin, int slot, co
984983
{
985984

986985
// get references to the right data
987-
const auto& ansVersion = getANSHeader();
988986
const auto& block = mBlocks[slot];
989987
const auto& md = mMetadata[slot];
990988

DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/internal/ExternalEntropyCoder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ template <typename dst_T>
7979
constexpr size_t Overhead = 10 * rans::utils::pow2(10); // 10KB overhead safety margin
8080
const double_t RelativeSafetyFactor = 2.0 * safetyFactor;
8181
const size_t messageSizeB = nElements * sizeof(source_type);
82-
return rans::utils::nBytesTo<dst_T>(std::ceil(safetyFactor * messageSizeB) + Overhead);
82+
return rans::utils::nBytesTo<dst_T>(std::ceil(RelativeSafetyFactor * messageSizeB) + Overhead);
8383
}
8484

8585
template <typename source_T>

DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/internal/InplaceEntropyCoder.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ void InplaceEntropyCoder<source_T>::makeEncoder()
166166
}
167167

168168
const size_t rangeBits = rans::utils::getRangeBits(*mMetrics.getCoderProperties().min, *mMetrics.getCoderProperties().max);
169-
const size_t nSamples = mMetrics.getDatasetProperties().numSamples;
170169
const size_t nUsedAlphabetSymbols = mMetrics.getDatasetProperties().nUsedAlphabetSymbols;
171170

172171
if (rangeBits <= 18) {

DataFormats/Detectors/Common/test/testCTFEntropyCoder.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ void encodeInplace(source_IT begin, source_IT end)
126126
std::vector<buffer_type> dictBuffer(sizeEstimate.getCompressedDictionarySize<buffer_type>(), 0);
127127

128128
auto encoderEnd = entropyCoder.encode(begin, end, encodeBuffer.data(), encodeBuffer.data() + encodeBuffer.size());
129-
auto literalsEnd = entropyCoder.writeIncompressible(literalSymbolsBuffer.data(), literalSymbolsBuffer.data() + literalSymbolsBuffer.size());
129+
[[maybe_unused]] auto literalsEnd = entropyCoder.writeIncompressible(literalSymbolsBuffer.data(), literalSymbolsBuffer.data() + literalSymbolsBuffer.size());
130130
auto dictEnd = entropyCoder.writeDictionary(dictBuffer.data(), dictBuffer.data() + dictBuffer.size());
131131
// decode
132132
const auto& coderProperties = metrics.getCoderProperties();
@@ -303,7 +303,7 @@ void encodeExternal(source_IT begin, source_IT end)
303303
auto encoderEnd = entropyCoder.encode(begin, end, encodeBuffer.data(), encodeBuffer.data() + encodeBuffer.size());
304304

305305
std::vector<buffer_type> literalSymbolsBuffer(entropyCoder.template computePackedIncompressibleSize<buffer_type>(), 0);
306-
auto literalsEnd = entropyCoder.writeIncompressible(literalSymbolsBuffer.data(), literalSymbolsBuffer.data() + literalSymbolsBuffer.size());
306+
[[maybe_unused]] auto literalsEnd = entropyCoder.writeIncompressible(literalSymbolsBuffer.data(), literalSymbolsBuffer.data() + literalSymbolsBuffer.size());
307307

308308
// decode
309309
auto decoder = ExternalEncoders.getDecoder<source_type>();

Utilities/rANS/benchmarks/bench_ransHistogram.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ void ransMakeHistogramBenchmark(benchmark::State& st, Args&&... args)
137137
histogram_type hist{};
138138
hist.addSamples(gsl::span<const source_type>(inputData));
139139

140-
for (std::ptrdiff_t symbol = histogram.getOffset(); symbol != histogram.getOffset() + histogram.size(); ++symbol) {
140+
for (std::ptrdiff_t symbol = histogram.getOffset(); symbol != histogram.getOffset() + static_cast<std::ptrdiff_t>(histogram.size()); ++symbol) {
141141
if (histogram[symbol] > 0) {
142142
LOG_IF(info, histogram[symbol] != hist[symbol]) << fmt::format("[{}]: {} != {}", symbol, hist[symbol], histogram[symbol]);
143143
isSame = isSame && (histogram[symbol] == hist[symbol]);
@@ -190,7 +190,7 @@ void ransAccessHistogramBenchmark(benchmark::State& st, Args&&... args)
190190
#endif
191191

192192
bool isSame = true;
193-
for (std::ptrdiff_t symbol = histogram.getOffset(); symbol != histogram.getOffset() + histogram.size(); ++symbol) {
193+
for (std::ptrdiff_t symbol = histogram.getOffset(); symbol != histogram.getOffset() + static_cast<std::ptrdiff_t>(histogram.size()); ++symbol) {
194194
if (histogram[symbol] > 0) {
195195
LOG_IF(info, histogram[symbol] != hist[symbol]) << fmt::format("[{}]: {} != {}", symbol, hist[symbol], histogram[symbol]);
196196
isSame = isSame && (histogram[symbol] == hist[symbol]);

Utilities/rANS/include/rANS/internal/containers/DenseHistogram.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ inline bool DenseHistogram<source_T, std::enable_if_t<sizeof(source_T) == 4>>::i
184184
ret = false;
185185
}
186186
}
187-
if (max - min > this->MaxSize) {
187+
if (max - min > static_cast<difference_type>(this->MaxSize)) {
188188
LOGP(warning, "DenseHistogram exceeds {} elements threshold", this->MaxSize);
189189
ret = false;
190190
}
@@ -233,8 +233,6 @@ inline auto DenseHistogram<source_T, std::enable_if_t<sizeof(source_T) == 4>>::a
233233
constexpr size_t nUnroll = 4 * ElemsPerQWord;
234234
auto iter = begin;
235235

236-
const source_type offset = this->getOffset();
237-
238236
if (getRangeBits(min, max) <= 17) {
239237
container_type histogram{this->mContainer.size(), this->mContainer.getOffset()};
240238

Utilities/rANS/include/rANS/internal/containers/ReverseSymbolLookupTable.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ class ReverseSymbolLookupTable
7171
return mLut[cumul];
7272
};
7373

74-
inline const iterator_type begin() const noexcept { return mLut.data(); };
75-
inline const iterator_type end() const noexcept { return mLut.data() + size(); };
74+
inline iterator_type begin() const noexcept { return mLut.data(); };
75+
inline iterator_type end() const noexcept { return mLut.data() + size(); };
7676

7777
container_type mLut{};
7878
};

Utilities/rANS/include/rANS/internal/containers/Symbol.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,8 @@ class Symbol
3737

3838
// TODO(milettri): fix once ROOT cling respects the standard http://wg21.link/p1286r2
3939
constexpr Symbol() noexcept {}; // NOLINT
40-
constexpr Symbol(value_type frequency, value_type cumulative, size_t symbolTablePrecision = 0)
41-
: mSymbol{frequency, cumulative}
42-
{
43-
(void)symbolTablePrecision; // silence compiler warnings
44-
};
40+
constexpr Symbol(value_type frequency, value_type cumulative, [[maybe_unused]] size_t symbolTablePrecision = 0)
41+
: mSymbol{frequency, cumulative} {};
4542
[[nodiscard]] inline constexpr value_type getFrequency() const noexcept { return mSymbol[0]; };
4643
[[nodiscard]] inline constexpr value_type getCumulative() const noexcept { return mSymbol[1]; };
4744
[[nodiscard]] inline constexpr const value_type* data() const noexcept { return mSymbol.data(); };

Utilities/rANS/include/rANS/internal/encode/Encoder.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,11 @@ decltype(auto) Encoder<encoder_T, symbolTable_T, nStreams_V>::process(source_IT
143143
EncoderSymbolMapper<symbolTable_type, coder_type, literals_IT> symbolMapper{this->mSymbolTable, literalsBegin};
144144
typename coder_type::symbol_type encoderSymbols[2]{};
145145

146+
// one past the end. Will not be dereferenced, thus safe.
147+
#pragma GCC diagnostic push
148+
#pragma GCC diagnostic ignored "-Warray-bounds"
146149
coder_type* codersREnd = advanceIter(coders.data(), -1);
150+
#pragma GCC diagnostic pop
147151
coder_type* activeCoder = codersREnd + nPartialCoderIterations;
148152

149153
// we are encoding backwards!

Utilities/rANS/include/rANS/internal/encode/EncoderSymbolMapper.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,6 @@ class EncoderSymbolMapper<symbolTable_T,
254254
{
255255
using namespace internal::simd;
256256

257-
const size_type nStreams = coder_type::getNstreams();
258-
259257
difference_type currentStream = nActiveStreams;
260258

261259
epi32_t<SIMDWidth::SSE, 2> frequencies;
@@ -330,8 +328,6 @@ class EncoderSymbolMapper<symbolTable_T,
330328
{
331329
using namespace internal::simd;
332330

333-
const size_type nStreams = coder_type::getNstreams();
334-
335331
difference_type currentStream = nActiveStreams;
336332

337333
epi32_t<SIMDWidth::SSE, 2> frequencies;

0 commit comments

Comments
 (0)