ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
Reduction.cpp
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #include <benchmark/benchmark.h>
9 
12 #include "cloudViewer/core/Dtype.h"
17 
18 namespace cloudViewer {
19 namespace core {
20 
21 void Reduction(benchmark::State& state, const Device& device) {
22  int64_t large_dim = (1ULL << 27) + 10;
23  SizeVector shape{2, large_dim};
24  Tensor src(shape, core::Int64, device);
25  Tensor warm_up = src.Sum({1});
26  (void)warm_up;
27  for (auto _ : state) {
28  Tensor dst = src.Sum({1});
29  cuda::Synchronize(device);
30  }
31 }
32 
33 BENCHMARK_CAPTURE(Reduction, CPU, Device("CPU:0"))
34  ->Unit(benchmark::kMillisecond);
35 
36 #ifdef BUILD_CUDA_MODULE
37 BENCHMARK_CAPTURE(Reduction, CUDA, Device("CUDA:0"))
38  ->Unit(benchmark::kMillisecond);
39 #endif
40 
41 } // namespace core
42 } // namespace cloudViewer
Common CUDA utilities.
Tensor Sum(const SizeVector &dims, bool keepdim=false) const
Definition: Tensor.cpp:1240
BENCHMARK_CAPTURE(BinaryEW, Add__CPU_Int8__100, 100, BinaryOpCode::Add, Int8, Device("CPU:0")) -> Unit(benchmark::kMillisecond)
const Dtype Int64
Definition: Dtype.cpp:47
void Reduction(benchmark::State &state, const Device &device)
Definition: Reduction.cpp:21
Generic file read and write utility for python interface.