|
15 | 15 | #include <core/lower_bound_impl.hpp> |
16 | 16 | #include <core/z_normalize.hpp> |
17 | 17 |
|
18 | | -#ifdef DTWC_HAS_HIGHWAY |
19 | | -#include <simd/multi_pair_dtw.hpp> |
20 | | -namespace dtwc::simd { |
21 | | -double lb_keogh_highway(const double *, const double *, const double *, std::size_t); |
22 | | -void z_normalize_highway(double *, std::size_t); |
23 | | -} // namespace dtwc::simd |
24 | | -#endif |
25 | | - |
26 | 18 | #include <vector> |
27 | 19 | #include <random> |
28 | 20 | #include <string> |
@@ -452,91 +444,3 @@ BENCHMARK(BM_compute_envelopes) |
452 | 444 | ->Args({4000, 50}) |
453 | 445 | ->Unit(benchmark::kNanosecond); |
454 | 446 |
|
455 | | -// --------------------------------------------------------------------------- |
456 | | -// SIMD vs scalar A/B comparisons (compiled only when DTWC_HAS_HIGHWAY is set) |
457 | | -// --------------------------------------------------------------------------- |
458 | | - |
459 | | -#ifdef DTWC_HAS_HIGHWAY |
460 | | - |
461 | | -static void BM_lb_keogh_highway(benchmark::State &state) |
462 | | -{ |
463 | | - const auto len = static_cast<size_t>(state.range(0)); |
464 | | - auto query = random_series(len, 42); |
465 | | - auto candidate = random_series(len, 43); |
466 | | - std::vector<double> upper(len), lower(len); |
467 | | - dtwc::core::compute_envelopes(candidate.data(), len, 10, upper.data(), lower.data()); |
468 | | - |
469 | | - for (auto _ : state) { |
470 | | - benchmark::DoNotOptimize( |
471 | | - dtwc::simd::lb_keogh_highway(query.data(), upper.data(), lower.data(), len)); |
472 | | - } |
473 | | - state.SetItemsProcessed(static_cast<int64_t>(state.iterations())); |
474 | | - state.SetComplexityN(static_cast<int64_t>(len)); |
475 | | -} |
476 | | -BENCHMARK(BM_lb_keogh_highway) |
477 | | - ->Arg(100)->Arg(500)->Arg(1000)->Arg(4000)->Arg(8000) |
478 | | - ->Unit(benchmark::kNanosecond)->Complexity(); |
479 | | - |
480 | | -static void BM_z_normalize_highway(benchmark::State &state) |
481 | | -{ |
482 | | - const auto len = static_cast<size_t>(state.range(0)); |
483 | | - auto series_data = random_series(len, 42); |
484 | | - |
485 | | - for (auto _ : state) { |
486 | | - state.PauseTiming(); |
487 | | - auto copy = series_data; |
488 | | - state.ResumeTiming(); |
489 | | - dtwc::simd::z_normalize_highway(copy.data(), copy.size()); |
490 | | - benchmark::DoNotOptimize(copy.data()); |
491 | | - } |
492 | | - state.SetItemsProcessed(static_cast<int64_t>(state.iterations())); |
493 | | - state.SetComplexityN(static_cast<int64_t>(len)); |
494 | | -} |
495 | | -BENCHMARK(BM_z_normalize_highway) |
496 | | - ->Arg(100)->Arg(500)->Arg(1000)->Arg(4000)->Arg(8000) |
497 | | - ->Unit(benchmark::kNanosecond)->Complexity(); |
498 | | - |
499 | | -static void BM_dtw_4pairs_sequential(benchmark::State &state) |
500 | | -{ |
501 | | - const auto len = static_cast<size_t>(state.range(0)); |
502 | | - std::vector<std::vector<double>> xs(4), ys(4); |
503 | | - for (int p = 0; p < 4; ++p) { |
504 | | - xs[p] = random_series(len, 100 + p * 2); |
505 | | - ys[p] = random_series(len, 101 + p * 2); |
506 | | - } |
507 | | - for (auto _ : state) { |
508 | | - double total = 0; |
509 | | - for (int p = 0; p < 4; ++p) |
510 | | - total += dtwc::dtwFull_L<double>(xs[p], ys[p]); |
511 | | - benchmark::DoNotOptimize(total); |
512 | | - } |
513 | | - state.SetItemsProcessed(static_cast<int64_t>(state.iterations()) * 4); |
514 | | -} |
515 | | -BENCHMARK(BM_dtw_4pairs_sequential) |
516 | | - ->Arg(100)->Arg(500)->Arg(1000) |
517 | | - ->Unit(benchmark::kMicrosecond); |
518 | | - |
519 | | -static void BM_dtw_4pairs_simd(benchmark::State &state) |
520 | | -{ |
521 | | - const auto len = static_cast<size_t>(state.range(0)); |
522 | | - std::vector<std::vector<double>> xs(4), ys(4); |
523 | | - for (int p = 0; p < 4; ++p) { |
524 | | - xs[p] = random_series(len, 100 + p * 2); |
525 | | - ys[p] = random_series(len, 101 + p * 2); |
526 | | - } |
527 | | - const double *x_ptrs[4] = {xs[0].data(), xs[1].data(), xs[2].data(), xs[3].data()}; |
528 | | - const double *y_ptrs[4] = {ys[0].data(), ys[1].data(), ys[2].data(), ys[3].data()}; |
529 | | - std::size_t x_lens[4] = {len, len, len, len}; |
530 | | - std::size_t y_lens[4] = {len, len, len, len}; |
531 | | - |
532 | | - for (auto _ : state) { |
533 | | - auto result = dtwc::simd::dtw_multi_pair(x_ptrs, y_ptrs, x_lens, y_lens, 4); |
534 | | - benchmark::DoNotOptimize(result); |
535 | | - } |
536 | | - state.SetItemsProcessed(static_cast<int64_t>(state.iterations()) * 4); |
537 | | -} |
538 | | -BENCHMARK(BM_dtw_4pairs_simd) |
539 | | - ->Arg(100)->Arg(500)->Arg(1000) |
540 | | - ->Unit(benchmark::kMicrosecond); |
541 | | - |
542 | | -#endif // DTWC_HAS_HIGHWAY |
0 commit comments