From 9cddce73a5c0f88d589c1c594f0f684d4a9e0940 Mon Sep 17 00:00:00 2001 From: Alexander Ivanov Date: Fri, 27 Jan 2023 02:34:30 +0000 Subject: [PATCH] Explicit conversions from long to int in benchmarks (for num_threads) Change-Id: I175328a890efe79c97180be03997324532d4c7a7 --- .../block_jacobi_preconditioner_benchmark.cc | 8 ++--- .../ceres/dense_linear_solver_benchmark.cc | 4 +-- internal/ceres/evaluation_benchmark.cc | 30 +++++++++---------- internal/ceres/invert_psd_matrix_benchmark.cc | 2 +- .../parallel_vector_operations_benchmark.cc | 18 +++++------ internal/ceres/spmv_benchmark.cc | 8 ++--- 6 files changed, 35 insertions(+), 35 deletions(-) diff --git a/internal/ceres/block_jacobi_preconditioner_benchmark.cc b/internal/ceres/block_jacobi_preconditioner_benchmark.cc index d2508c4db..edd431d6f 100644 --- a/internal/ceres/block_jacobi_preconditioner_benchmark.cc +++ b/internal/ceres/block_jacobi_preconditioner_benchmark.cc @@ -63,7 +63,7 @@ static void BM_BlockSparseJacobiPreconditionerBA(benchmark::State& state) { Preconditioner::Options preconditioner_options; ContextImpl context; preconditioner_options.context = &context; - preconditioner_options.num_threads = state.range(0); + preconditioner_options.num_threads = static_cast(state.range(0)); context.EnsureMinimumThreads(preconditioner_options.num_threads); BlockSparseJacobiPreconditioner p(preconditioner_options, *jacobian); @@ -91,7 +91,7 @@ static void BM_BlockCRSJacobiPreconditionerBA(benchmark::State& state) { Preconditioner::Options preconditioner_options; ContextImpl context; preconditioner_options.context = &context; - preconditioner_options.num_threads = state.range(0); + preconditioner_options.num_threads = static_cast(state.range(0)); context.EnsureMinimumThreads(preconditioner_options.num_threads); BlockCRSJacobiPreconditioner p(preconditioner_options, jacobian_crs); @@ -124,7 +124,7 @@ static void BM_BlockSparseJacobiPreconditionerUnstructured( Preconditioner::Options preconditioner_options; ContextImpl context; preconditioner_options.context = &context; - preconditioner_options.num_threads = state.range(0); + preconditioner_options.num_threads = static_cast(state.range(0)); context.EnsureMinimumThreads(preconditioner_options.num_threads); BlockSparseJacobiPreconditioner p(preconditioner_options, *jacobian); @@ -160,7 +160,7 @@ static void BM_BlockCRSJacobiPreconditionerUnstructured( Preconditioner::Options preconditioner_options; ContextImpl context; preconditioner_options.context = &context; - preconditioner_options.num_threads = state.range(0); + preconditioner_options.num_threads = static_cast(state.range(0)); context.EnsureMinimumThreads(preconditioner_options.num_threads); BlockCRSJacobiPreconditioner p(preconditioner_options, jacobian_crs); diff --git a/internal/ceres/dense_linear_solver_benchmark.cc b/internal/ceres/dense_linear_solver_benchmark.cc index a01e0d608..a5c529be1 100644 --- a/internal/ceres/dense_linear_solver_benchmark.cc +++ b/internal/ceres/dense_linear_solver_benchmark.cc @@ -40,8 +40,8 @@ namespace ceres::internal { template static void BM_DenseSolver(benchmark::State& state) { - const int num_rows = state.range(0); - const int num_cols = state.range(1); + const int num_rows = static_cast(state.range(0)); + const int num_cols = static_cast(state.range(1)); DenseSparseMatrix jacobian(num_rows, num_cols); *jacobian.mutable_matrix() = Eigen::MatrixXd::Random(num_rows, num_cols); Eigen::VectorXd rhs = Eigen::VectorXd::Random(num_rows, 1); diff --git a/internal/ceres/evaluation_benchmark.cc b/internal/ceres/evaluation_benchmark.cc index be784c20c..5dc1ef495 100644 --- a/internal/ceres/evaluation_benchmark.cc +++ b/internal/ceres/evaluation_benchmark.cc @@ -208,7 +208,7 @@ struct BALData { static void Residuals(benchmark::State& state, BALData* data, ContextImpl* context) { - const int num_threads = state.range(0); + const int num_threads = static_cast(state.range(0)); Evaluator::Options options; options.linear_solver_type = SPARSE_NORMAL_CHOLESKY; @@ -240,7 +240,7 @@ static void Residuals(benchmark::State& state, static void ResidualsAndJacobian(benchmark::State& state, BALData* data, ContextImpl* context) { - const int num_threads = state.range(0); + const int num_threads = static_cast(state.range(0)); Evaluator::Options options; options.linear_solver_type = SPARSE_NORMAL_CHOLESKY; @@ -271,7 +271,7 @@ static void ResidualsAndJacobian(benchmark::State& state, } static void Plus(benchmark::State& state, BALData* data, ContextImpl* context) { - const int num_threads = state.range(0); + const int num_threads = static_cast(state.range(0)); Evaluator::Options options; options.linear_solver_type = SPARSE_NORMAL_CHOLESKY; @@ -300,7 +300,7 @@ static void PMVRightMultiplyAndAccumulateF(benchmark::State& state, BALData* data, ContextImpl* context) { LinearSolver::Options options; - options.num_threads = state.range(0); + options.num_threads = static_cast(state.range(0)); options.elimination_groups.push_back(data->bal_problem->num_points()); options.context = context; auto jacobian = data->PartitionedMatrixViewJacobian(options); @@ -318,7 +318,7 @@ static void PMVLeftMultiplyAndAccumulateF(benchmark::State& state, BALData* data, ContextImpl* context) { LinearSolver::Options options; - options.num_threads = state.range(0); + options.num_threads = static_cast(state.range(0)); options.elimination_groups.push_back(data->bal_problem->num_points()); options.context = context; auto jacobian = data->PartitionedMatrixViewJacobian(options); @@ -336,7 +336,7 @@ static void PMVRightMultiplyAndAccumulateE(benchmark::State& state, BALData* data, ContextImpl* context) { LinearSolver::Options options; - options.num_threads = state.range(0); + options.num_threads = static_cast(state.range(0)); options.elimination_groups.push_back(data->bal_problem->num_points()); options.context = context; auto jacobian = data->PartitionedMatrixViewJacobian(options); @@ -354,7 +354,7 @@ static void PMVLeftMultiplyAndAccumulateE(benchmark::State& state, BALData* data, ContextImpl* context) { LinearSolver::Options options; - options.num_threads = state.range(0); + options.num_threads = static_cast(state.range(0)); options.elimination_groups.push_back(data->bal_problem->num_points()); options.context = context; auto jacobian = data->PartitionedMatrixViewJacobian(options); @@ -372,7 +372,7 @@ static void PMVUpdateBlockDiagonalEtE(benchmark::State& state, BALData* data, ContextImpl* context) { LinearSolver::Options options; - options.num_threads = state.range(0); + options.num_threads = static_cast(state.range(0)); options.elimination_groups.push_back(data->bal_problem->num_points()); options.context = context; auto jacobian = data->PartitionedMatrixViewJacobian(options); @@ -387,7 +387,7 @@ static void PMVUpdateBlockDiagonalFtF(benchmark::State& state, BALData* data, ContextImpl* context) { LinearSolver::Options options; - options.num_threads = state.range(0); + options.num_threads = static_cast(state.range(0)); options.elimination_groups.push_back(data->bal_problem->num_points()); options.context = context; auto jacobian = data->PartitionedMatrixViewJacobian(options); @@ -402,7 +402,7 @@ static void ISCRightMultiplyNoDiag(benchmark::State& state, BALData* data, ContextImpl* context) { LinearSolver::Options options; - options.num_threads = state.range(0); + options.num_threads = static_cast(state.range(0)); options.elimination_groups.push_back(data->bal_problem->num_points()); options.context = context; auto jacobian = data->ImplicitSchurComplementWithoutDiagonal(options); @@ -419,7 +419,7 @@ static void ISCRightMultiplyDiag(benchmark::State& state, BALData* data, ContextImpl* context) { LinearSolver::Options options; - options.num_threads = state.range(0); + options.num_threads = static_cast(state.range(0)); options.elimination_groups.push_back(data->bal_problem->num_points()); options.context = context; @@ -436,7 +436,7 @@ static void ISCRightMultiplyDiag(benchmark::State& state, static void JacobianSquaredColumnNorm(benchmark::State& state, BALData* data, ContextImpl* context) { - const int num_threads = state.range(0); + const int num_threads = static_cast(state.range(0)); auto jacobian = data->BlockSparseJacobian(context); @@ -451,7 +451,7 @@ static void JacobianSquaredColumnNorm(benchmark::State& state, static void JacobianScaleColumns(benchmark::State& state, BALData* data, ContextImpl* context) { - const int num_threads = state.range(0); + const int num_threads = static_cast(state.range(0)); auto jacobian_const = data->BlockSparseJacobian(context); auto jacobian = const_cast(jacobian_const); @@ -466,7 +466,7 @@ static void JacobianScaleColumns(benchmark::State& state, static void JacobianRightMultiplyAndAccumulate(benchmark::State& state, BALData* data, ContextImpl* context) { - const int num_threads = state.range(0); + const int num_threads = static_cast(state.range(0)); auto jacobian = data->BlockSparseJacobian(context); @@ -483,7 +483,7 @@ static void JacobianRightMultiplyAndAccumulate(benchmark::State& state, static void JacobianLeftMultiplyAndAccumulate(benchmark::State& state, BALData* data, ContextImpl* context) { - const int num_threads = state.range(0); + const int num_threads = static_cast(state.range(0)); auto jacobian = data->BlockSparseJacobian(context); diff --git a/internal/ceres/invert_psd_matrix_benchmark.cc b/internal/ceres/invert_psd_matrix_benchmark.cc index eb8deb191..d23e9f83e 100644 --- a/internal/ceres/invert_psd_matrix_benchmark.cc +++ b/internal/ceres/invert_psd_matrix_benchmark.cc @@ -64,7 +64,7 @@ BENCHMARK_TEMPLATE(BenchmarkFixedSizedInvertPSDMatrix, 12); static void BenchmarkDynamicallyInvertPSDMatrix(benchmark::State& state) { using MatrixType = typename EigenTypes::Matrix; - const int size = state.range(0); + const int size = static_cast(state.range(0)); MatrixType input = MatrixType::Random(size, size); input += input.transpose() + MatrixType::Identity(size, size); diff --git a/internal/ceres/parallel_vector_operations_benchmark.cc b/internal/ceres/parallel_vector_operations_benchmark.cc index 7e523c3fd..6dd9a5baa 100644 --- a/internal/ceres/parallel_vector_operations_benchmark.cc +++ b/internal/ceres/parallel_vector_operations_benchmark.cc @@ -46,7 +46,7 @@ static void SetZero(benchmark::State& state) { BENCHMARK(SetZero); static void SetZeroParallel(benchmark::State& state) { - const int num_threads = state.range(0); + const int num_threads = static_cast(state.range(0)); ContextImpl context; context.EnsureMinimumThreads(num_threads); @@ -70,7 +70,7 @@ static void Negate(benchmark::State& state) { BENCHMARK(Negate); static void NegateParallel(benchmark::State& state) { - const int num_threads = state.range(0); + const int num_threads = static_cast(state.range(0)); ContextImpl context; context.EnsureMinimumThreads(num_threads); @@ -95,7 +95,7 @@ static void Assign(benchmark::State& state) { BENCHMARK(Assign); static void AssignParallel(benchmark::State& state) { - const int num_threads = state.range(0); + const int num_threads = static_cast(state.range(0)); ContextImpl context; context.EnsureMinimumThreads(num_threads); @@ -121,7 +121,7 @@ static void D2X(benchmark::State& state) { BENCHMARK(D2X); static void D2XParallel(benchmark::State& state) { - const int num_threads = state.range(0); + const int num_threads = static_cast(state.range(0)); ContextImpl context; context.EnsureMinimumThreads(num_threads); @@ -147,7 +147,7 @@ static void DivideSqrt(benchmark::State& state) { BENCHMARK(DivideSqrt); static void DivideSqrtParallel(benchmark::State& state) { - const int num_threads = state.range(0); + const int num_threads = static_cast(state.range(0)); ContextImpl context; context.EnsureMinimumThreads(num_threads); @@ -176,7 +176,7 @@ static void Clamp(benchmark::State& state) { BENCHMARK(Clamp); static void ClampParallel(benchmark::State& state) { - const int num_threads = state.range(0); + const int num_threads = static_cast(state.range(0)); ContextImpl context; context.EnsureMinimumThreads(num_threads); @@ -204,7 +204,7 @@ static void Norm(benchmark::State& state) { BENCHMARK(Norm); static void NormParallel(benchmark::State& state) { - const int num_threads = state.range(0); + const int num_threads = static_cast(state.range(0)); ContextImpl context; context.EnsureMinimumThreads(num_threads); @@ -231,7 +231,7 @@ static void Dot(benchmark::State& state) { BENCHMARK(Dot); static void DotParallel(benchmark::State& state) { - const int num_threads = state.range(0); + const int num_threads = static_cast(state.range(0)); ContextImpl context; context.EnsureMinimumThreads(num_threads); @@ -261,7 +261,7 @@ static void Axpby(benchmark::State& state) { BENCHMARK(Axpby); static void AxpbyParallel(benchmark::State& state) { - const int num_threads = state.range(0); + const int num_threads = static_cast(state.range(0)); ContextImpl context; context.EnsureMinimumThreads(num_threads); diff --git a/internal/ceres/spmv_benchmark.cc b/internal/ceres/spmv_benchmark.cc index 69df1ea2f..2a6e67996 100644 --- a/internal/ceres/spmv_benchmark.cc +++ b/internal/ceres/spmv_benchmark.cc @@ -66,7 +66,7 @@ constexpr double kBlockDensity = 5.0 / kNumColBlocks; static void BM_BlockSparseRightMultiplyAndAccumulateBA( benchmark::State& state) { - const int num_threads = state.range(0); + const int num_threads = static_cast(state.range(0)); std::mt19937 prng; auto jacobian = CreateFakeBundleAdjustmentJacobian( kNumCameras, kNumPoints, kCameraSize, kPointSize, kVisibility, prng); @@ -96,7 +96,7 @@ BENCHMARK(BM_BlockSparseRightMultiplyAndAccumulateBA) static void BM_BlockSparseRightMultiplyAndAccumulateUnstructured( benchmark::State& state) { - const int num_threads = state.range(0); + const int num_threads = static_cast(state.range(0)); BlockSparseMatrix::RandomMatrixOptions options; options.num_row_blocks = kNumRowBlocks; options.num_col_blocks = kNumColBlocks; @@ -178,7 +178,7 @@ static void BM_BlockSparseLeftMultiplyAndAccumulateUnstructured( BENCHMARK(BM_BlockSparseLeftMultiplyAndAccumulateUnstructured); static void BM_CRSRightMultiplyAndAccumulateBA(benchmark::State& state) { - const int num_threads = state.range(0); + const int num_threads = static_cast(state.range(0)); std::mt19937 prng; auto bsm_jacobian = CreateFakeBundleAdjustmentJacobian( kNumCameras, kNumPoints, kCameraSize, kPointSize, kVisibility, prng); @@ -213,7 +213,7 @@ BENCHMARK(BM_CRSRightMultiplyAndAccumulateBA) static void BM_CRSRightMultiplyAndAccumulateUnstructured( benchmark::State& state) { - const int num_threads = state.range(0); + const int num_threads = static_cast(state.range(0)); BlockSparseMatrix::RandomMatrixOptions options; options.num_row_blocks = kNumRowBlocks; options.num_col_blocks = kNumColBlocks;