Explicit conversions from long to int in benchmarks (for num_threads)

Change-Id: I175328a890efe79c97180be03997324532d4c7a7
This commit is contained in:
Alexander Ivanov
2023-01-27 02:34:30 +00:00
committed by Sameer Agarwal
parent 5e787ab700
commit 9cddce73a5
6 changed files with 35 additions and 35 deletions
@@ -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<int>(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<int>(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<int>(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<int>(state.range(0));
context.EnsureMinimumThreads(preconditioner_options.num_threads);
BlockCRSJacobiPreconditioner p(preconditioner_options, jacobian_crs);
@@ -40,8 +40,8 @@ namespace ceres::internal {
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);
+15 -15
View File
@@ -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<int>(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<int>(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<int>(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<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 @@ static void PMVLeftMultiplyAndAccumulateF(benchmark::State& state,
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 @@ static void PMVRightMultiplyAndAccumulateE(benchmark::State& state,
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 @@ static void PMVLeftMultiplyAndAccumulateE(benchmark::State& state,
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 @@ static void PMVUpdateBlockDiagonalEtE(benchmark::State& state,
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 @@ static void PMVUpdateBlockDiagonalFtF(benchmark::State& state,
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 @@ static void ISCRightMultiplyNoDiag(benchmark::State& state,
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 @@ static void ISCRightMultiplyDiag(benchmark::State& state,
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 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<int>(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<int>(state.range(0));
auto jacobian_const = data->BlockSparseJacobian(context);
auto jacobian = const_cast<BlockSparseMatrix*>(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<int>(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<int>(state.range(0));
auto jacobian = data->BlockSparseJacobian(context);
@@ -64,7 +64,7 @@ BENCHMARK_TEMPLATE(BenchmarkFixedSizedInvertPSDMatrix, 12);
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);
@@ -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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(state.range(0));
ContextImpl context;
context.EnsureMinimumThreads(num_threads);
+4 -4
View File
@@ -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<int>(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<int>(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<int>(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<int>(state.range(0));
BlockSparseMatrix::RandomMatrixOptions options;
options.num_row_blocks = kNumRowBlocks;
options.num_col_blocks = kNumColBlocks;