Dynamic dispatching for best_variant selection

This commit is contained in:
Wangyang Guo 2022-07-13 15:15:54 +08:00
parent 62c62a2df7
commit f275b35bba
2 changed files with 14 additions and 6 deletions

View File

@ -454,7 +454,9 @@ inline void copyOverlap32Shuffle(UInt8 * op, const UInt8 *& match, const size_t
_mm256_load_si256(reinterpret_cast<const __m256i *>(masks) + offset),
_mm256_loadu_si256(reinterpret_cast<const __m256i *>(match))));
match += masks[offset];
} else {
}
else
{
copyOverlap32(op, match, offset);
}
#else
@ -638,7 +640,13 @@ bool decompress(
/// Don't run timer if the block is too small.
if (dest_size >= 32768)
{
size_t best_variant = statistics.select();
size_t variant_size = 4;
#if defined(__AVX512VBMI__) && !defined(MEMORY_SANITIZER)
/// best_variant == 4 only valid when AVX512VBMI available
if (DB::Cpu::CpuFlagsCache::have_AVX512VBMI)
variant_size = 5;
#endif
size_t best_variant = statistics.select(variant_size);
/// Run the selected method and measure time.

View File

@ -106,17 +106,17 @@ struct PerformanceStatistics
/// To select from different algorithms we use a kind of "bandits" algorithm.
/// Sample random values from estimated normal distributions and choose the minimal.
size_t select()
size_t select(size_t max_method = NUM_ELEMENTS)
{
if (choose_method < 0)
{
double samples[NUM_ELEMENTS];
for (size_t i = 0; i < NUM_ELEMENTS; ++i)
double samples[max_method];
for (size_t i = 0; i < max_method; ++i)
samples[i] = choose_method == -1
? data[i].sample(rng)
: data[i].adjustedCount();
return std::min_element(samples, samples + NUM_ELEMENTS) - samples;
return std::min_element(samples, samples + max_method) - samples;
}
else
return choose_method;