Explicit conversions from long to int in benchmarks (for num_threads) Change-Id: I175328a890efe79c97180be03997324532d4c7a7
diff --git a/internal/ceres/block_jacobi_preconditioner_benchmark.cc b/internal/ceres/block_jacobi_preconditioner_benchmark.cc index d2508c4..edd431d 100644 --- a/internal/ceres/block_jacobi_preconditioner_benchmark.cc +++ b/internal/ceres/block_jacobi_preconditioner_benchmark.cc
@@ -63,7 +63,7 @@ Preconditioner::Options preconditioner_options; ContextImpl context; preconditioner_options.context = &context; - preconditioner_options.num_threads = state.range(0); + preconditioner_options.num_threads = static_cast<int>(state.range(0)); context.EnsureMinimumThreads(preconditioner_options.num_threads); BlockSparseJacobiPreconditioner p(preconditioner_options, *jacobian); @@ -91,7 +91,7 @@ Preconditioner::Options preconditioner_options; ContextImpl context; preconditioner_options.context = &context; - preconditioner_options.num_threads = state.range(0); + preconditioner_options.num_threads = static_cast<int>(state.range(0)); context.EnsureMinimumThreads(preconditioner_options.num_threads); BlockCRSJacobiPreconditioner p(preconditioner_options, jacobian_crs); @@ -124,7 +124,7 @@ Preconditioner::Options preconditioner_options; ContextImpl context; preconditioner_options.context = &context; - preconditioner_options.num_threads = state.range(0); + preconditioner_options.num_threads = static_cast<int>(state.range(0)); context.EnsureMinimumThreads(preconditioner_options.num_threads); BlockSparseJacobiPreconditioner p(preconditioner_options, *jacobian); @@ -160,7 +160,7 @@ Preconditioner::Options preconditioner_options; ContextImpl context; preconditioner_options.context = &context; - preconditioner_options.num_threads = state.range(0); + preconditioner_options.num_threads = static_cast<int>(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 a01e0d6..a5c529b 100644 --- a/internal/ceres/dense_linear_solver_benchmark.cc +++ b/internal/ceres/dense_linear_solver_benchmark.cc
@@ -40,8 +40,8 @@ template <ceres::DenseLinearAlgebraLibraryType kLibraryType, ceres::LinearSolverType kSolverType> 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<int>(state.range(0)); + const int num_cols = static_cast<int>(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 be784c2..5dc1ef4 100644 --- a/internal/ceres/evaluation_benchmark.cc +++ b/internal/ceres/evaluation_benchmark.cc
@@ -208,7 +208,7 @@ static void Residuals(benchmark::State& state, BALData* data, ContextImpl* context) { - const int num_threads = state.range(0); + const int num_threads = static_cast<int>(state.range(0)); Evaluator::Options options; options.linear_solver_type = SPARSE_NORMAL_CHOLESKY; @@ -240,7 +240,7 @@ static void ResidualsAndJacobian(benchmark::State& state, BALData* data, ContextImpl* context) { - const int num_threads = state.range(0); + const int num_threads = static_cast<int>(state.range(0)); Evaluator::Options options; options.linear_solver_type = SPARSE_NORMAL_CHOLESKY; @@ -271,7 +271,7 @@ } static void Plus(benchmark::State& state, BALData* data, ContextImpl* context) { - const int num_threads = state.range(0); + const int num_threads = static_cast<int>(state.range(0)); Evaluator::Options options; options.linear_solver_type = SPARSE_NORMAL_CHOLESKY; @@ -300,7 +300,7 @@ BALData* data, ContextImpl* context) { LinearSolver::Options options; - options.num_threads = state.range(0); + options.num_threads = static_cast<int>(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 @@ BALData* data, ContextImpl* context) { LinearSolver::Options options; - options.num_threads = state.range(0); + options.num_threads = static_cast<int>(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 @@ BALData* data, ContextImpl* context) { LinearSolver::Options options; - options.num_threads = state.range(0); + options.num_threads = static_cast<int>(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 @@ BALData* data, ContextImpl* context) { LinearSolver::Options options; - options.num_threads = state.range(0); + options.num_threads = static_cast<int>(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 @@ BALData* data, ContextImpl* context) { LinearSolver::Options options; - options.num_threads = state.range(0); + options.num_threads = static_cast<int>(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 @@ BALData* data, ContextImpl* context) { LinearSolver::Options options; - options.num_threads = state.range(0); + options.num_threads = static_cast<int>(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 @@ BALData* data, ContextImpl* context) { LinearSolver::Options options; - options.num_threads = state.range(0); + options.num_threads = static_cast<int>(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 @@ BALData* data, ContextImpl* context) { LinearSolver::Options options; - options.num_threads = state.range(0); + options.num_threads = static_cast<int>(state.range(0)); options.elimination_groups.push_back(data->bal_problem->num_points()); options.context = context; @@ -436,7 +436,7 @@ static void JacobianSquaredColumnNorm(benchmark::State& state, BALData* data, ContextImpl* context) { - const int num_threads = state.range(0); + const int num_threads = static_cast<int>(state.range(0)); auto jacobian = data->BlockSparseJacobian(context); @@ -451,7 +451,7 @@ static void JacobianScaleColumns(benchmark::State& state, BALData* data, ContextImpl* context) { - const int num_threads = state.range(0); + const int num_threads = static_cast<int>(state.range(0)); auto jacobian_const = data->BlockSparseJacobian(context); auto jacobian = const_cast<BlockSparseMatrix*>(jacobian_const); @@ -466,7 +466,7 @@ static void JacobianRightMultiplyAndAccumulate(benchmark::State& state, BALData* data, ContextImpl* context) { - const int num_threads = state.range(0); + const int num_threads = static_cast<int>(state.range(0)); auto jacobian = data->BlockSparseJacobian(context); @@ -483,7 +483,7 @@ static void JacobianLeftMultiplyAndAccumulate(benchmark::State& state, BALData* data, ContextImpl* context) { - const int num_threads = state.range(0); + const int num_threads = static_cast<int>(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 eb8deb1..d23e9f8 100644 --- a/internal/ceres/invert_psd_matrix_benchmark.cc +++ b/internal/ceres/invert_psd_matrix_benchmark.cc
@@ -64,7 +64,7 @@ static void BenchmarkDynamicallyInvertPSDMatrix(benchmark::State& state) { using MatrixType = typename EigenTypes<Eigen::Dynamic, Eigen::Dynamic>::Matrix; - const int size = state.range(0); + const int size = static_cast<int>(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 7e523c3..6dd9a5b 100644 --- a/internal/ceres/parallel_vector_operations_benchmark.cc +++ b/internal/ceres/parallel_vector_operations_benchmark.cc
@@ -46,7 +46,7 @@ BENCHMARK(SetZero); static void SetZeroParallel(benchmark::State& state) { - const int num_threads = state.range(0); + const int num_threads = static_cast<int>(state.range(0)); ContextImpl context; context.EnsureMinimumThreads(num_threads); @@ -70,7 +70,7 @@ BENCHMARK(Negate); static void NegateParallel(benchmark::State& state) { - const int num_threads = state.range(0); + const int num_threads = static_cast<int>(state.range(0)); ContextImpl context; context.EnsureMinimumThreads(num_threads); @@ -95,7 +95,7 @@ BENCHMARK(Assign); static void AssignParallel(benchmark::State& state) { - const int num_threads = state.range(0); + const int num_threads = static_cast<int>(state.range(0)); ContextImpl context; context.EnsureMinimumThreads(num_threads); @@ -121,7 +121,7 @@ BENCHMARK(D2X); static void D2XParallel(benchmark::State& state) { - const int num_threads = state.range(0); + const int num_threads = static_cast<int>(state.range(0)); ContextImpl context; context.EnsureMinimumThreads(num_threads); @@ -147,7 +147,7 @@ BENCHMARK(DivideSqrt); static void DivideSqrtParallel(benchmark::State& state) { - const int num_threads = state.range(0); + const int num_threads = static_cast<int>(state.range(0)); ContextImpl context; context.EnsureMinimumThreads(num_threads); @@ -176,7 +176,7 @@ BENCHMARK(Clamp); static void ClampParallel(benchmark::State& state) { - const int num_threads = state.range(0); + const int num_threads = static_cast<int>(state.range(0)); ContextImpl context; context.EnsureMinimumThreads(num_threads); @@ -204,7 +204,7 @@ BENCHMARK(Norm); static void NormParallel(benchmark::State& state) { - const int num_threads = state.range(0); + const int num_threads = static_cast<int>(state.range(0)); ContextImpl context; context.EnsureMinimumThreads(num_threads); @@ -231,7 +231,7 @@ BENCHMARK(Dot); static void DotParallel(benchmark::State& state) { - const int num_threads = state.range(0); + const int num_threads = static_cast<int>(state.range(0)); ContextImpl context; context.EnsureMinimumThreads(num_threads); @@ -261,7 +261,7 @@ BENCHMARK(Axpby); static void AxpbyParallel(benchmark::State& state) { - const int num_threads = state.range(0); + const int num_threads = static_cast<int>(state.range(0)); ContextImpl context; context.EnsureMinimumThreads(num_threads);
diff --git a/internal/ceres/spmv_benchmark.cc b/internal/ceres/spmv_benchmark.cc index 69df1ea..2a6e679 100644 --- a/internal/ceres/spmv_benchmark.cc +++ b/internal/ceres/spmv_benchmark.cc
@@ -66,7 +66,7 @@ static void BM_BlockSparseRightMultiplyAndAccumulateBA( benchmark::State& state) { - const int num_threads = state.range(0); + const int num_threads = static_cast<int>(state.range(0)); std::mt19937 prng; auto jacobian = CreateFakeBundleAdjustmentJacobian( kNumCameras, kNumPoints, kCameraSize, kPointSize, kVisibility, prng); @@ -96,7 +96,7 @@ static void BM_BlockSparseRightMultiplyAndAccumulateUnstructured( benchmark::State& state) { - const int num_threads = state.range(0); + const int num_threads = static_cast<int>(state.range(0)); BlockSparseMatrix::RandomMatrixOptions options; options.num_row_blocks = kNumRowBlocks; options.num_col_blocks = kNumColBlocks; @@ -178,7 +178,7 @@ BENCHMARK(BM_BlockSparseLeftMultiplyAndAccumulateUnstructured); static void BM_CRSRightMultiplyAndAccumulateBA(benchmark::State& state) { - const int num_threads = state.range(0); + const int num_threads = static_cast<int>(state.range(0)); std::mt19937 prng; auto bsm_jacobian = CreateFakeBundleAdjustmentJacobian( kNumCameras, kNumPoints, kCameraSize, kPointSize, kVisibility, prng); @@ -213,7 +213,7 @@ static void BM_CRSRightMultiplyAndAccumulateUnstructured( benchmark::State& state) { - const int num_threads = state.range(0); + const int num_threads = static_cast<int>(state.range(0)); BlockSparseMatrix::RandomMatrixOptions options; options.num_row_blocks = kNumRowBlocks; options.num_col_blocks = kNumColBlocks;