| 461 | |
| 462 | namespace { |
| 463 | void benchmark_impl( |
| 464 | const typename WarpPerspective::Param& param, |
| 465 | std::vector<SmallVector<TensorShape>> shapes, size_t RUNS, |
| 466 | TaskExecutorConfig&& multi_thread_config, |
| 467 | TaskExecutorConfig&& single_thread_config) { |
| 468 | std::vector<float> multi_thread_times, single_thread_times; |
| 469 | { |
| 470 | auto multi_thread_hanle = create_cpu_handle(0, true, &multi_thread_config); |
| 471 | auto benchmarker = Benchmarker<WarpPerspective>(multi_thread_hanle.get()); |
| 472 | benchmarker.set_times(RUNS).set_display(false).set_param(param); |
| 473 | for (auto shape : shapes) { |
| 474 | multi_thread_times.push_back(benchmarker.exec(shape) / RUNS); |
| 475 | } |
| 476 | } |
| 477 | { |
| 478 | auto single_thread_handle = create_cpu_handle(0, true, &single_thread_config); |
| 479 | auto benchmarker = Benchmarker<WarpPerspective>(single_thread_handle.get()); |
| 480 | benchmarker.set_times(RUNS).set_display(false).set_param(param); |
| 481 | for (auto shape : shapes) { |
| 482 | single_thread_times.push_back(benchmarker.exec(shape) / RUNS); |
| 483 | } |
| 484 | } |
| 485 | printf("Benchmark : Multi threads %zu, ", multi_thread_config.nr_thread); |
| 486 | printf("core_ids:"); |
| 487 | for (size_t i = 0; i < multi_thread_config.affinity_core_set.size(); i++) { |
| 488 | printf("%zu ", multi_thread_config.affinity_core_set[i]); |
| 489 | } |
| 490 | printf(", Single thread core_id %zu\n", single_thread_config.affinity_core_set[0]); |
| 491 | for (size_t i = 0; i < shapes.size(); i++) { |
| 492 | auto shape = shapes[i]; |
| 493 | printf("Case: "); |
| 494 | for (auto sh : shape) |
| 495 | printf("%s ", sh.to_string().c_str()); |
| 496 | printf("%zu threads time: %f,\n single thread time: " |
| 497 | "%f. spead up = %f, speedup/cores=%f\n", |
| 498 | multi_thread_config.nr_thread, multi_thread_times[i], |
| 499 | single_thread_times[i], single_thread_times[i] / multi_thread_times[i], |
| 500 | single_thread_times[i] / multi_thread_times[i] / |
| 501 | multi_thread_config.nr_thread); |
| 502 | } |
| 503 | } |
| 504 | } // namespace |
| 505 | |
| 506 | TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS, BENCHMARK_WARP_PERSPECTIVE) { |