Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
3 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "bench_util.h"
#include "core/mlas/lib/mlasi.h"
 
#if defined(MLAS_F16VEC_INTRINSICS_SUPPORTED) && defined(MLAS_TARGET_ARM64)
 
void BM_ConvertF16ToF32(benchmark::State& state) {
  bool aligned = static_cast<bool>(state.range(0));
  const size_t count = 1 << 18;
  auto src = RandomVectorUniform<unsigned short>(count, 0, 60000);
  auto dst = std::vector<float>(count + 16);
  auto aligned_dst = (reinterpret_cast<intptr_t>(dst.data()) + 15) & (~15);
  float* dst_start = aligned ? reinterpret_cast<float*>(aligned_dst)
                             : reinterpret_cast<float*>(aligned_dst + 1);
 
  // Warm up
  MlasCastF16ToF32KernelNeon(src.data(), dst_start, count);
 
  for (auto _ : state) {
    MlasCastF16ToF32KernelNeon(src.data(), dst_start, count);
  }
}
 
void BM_ConvertF32ToF16(benchmark::State& state) {
  bool aligned = static_cast<bool>(state.range(0));
  const size_t count = 1 << 18;
  auto src = RandomVectorUniform(count, -30000.0f, 30000.0f);
  auto dst = std::vector<unsigned short>(count + 16);
  auto aligned_dst = (reinterpret_cast<intptr_t>(dst.data()) + 15) & (~15);
  unsigned short* dst_start = aligned ? reinterpret_cast<unsigned short*>(aligned_dst)
                                      : reinterpret_cast<unsigned short*>(aligned_dst + 1);
 
  // Warm up
  MlasCastF32ToF16KernelNeon(src.data(), dst_start, count);
 
  for (auto _ : state) {
    MlasCastF32ToF16KernelNeon(src.data(), dst_start, count);
  }
}
 
BENCHMARK(BM_ConvertF16ToF32)
    ->UseRealTime()
    ->Apply([](benchmark::Benchmark* b) {
      b->ArgNames({"aligned"});
      b->ArgsProduct({{0, 1}});
    });
 
BENCHMARK(BM_ConvertF32ToF16)
    ->UseRealTime()
    ->Apply([](benchmark::Benchmark* b) {
      b->ArgNames({"aligned"});
      b->ArgsProduct({{0, 1}});
    });
 
#endif  // defined(MLAS_F16VEC_INTRINSICS_SUPPORTED) && defined(MLAS_TARGET_ARM64)