mirror of
https://github.com/ceres-solver/ceres-solver.git
synced 2026-08-29 08:34:37 +08:00
Remove OpenMP and No threading backends.
Since c++11, we can depend on C++ threads always being available. With the recent work on the performance of CXX threading, the additional complexity of maintaining multiple backends for some minor performance delta is not worth it https://github.com/ceres-solver/ceres-solver/issues/886 Change-Id: Idee480b22a498daec9c4366da8589aa58eaf36a1
This commit is contained in:
@@ -4,7 +4,7 @@ on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: ${{matrix.os}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.threading_model}}
|
||||
name: ${{matrix.os}}-${{matrix.build_type}}-${{matrix.lib}}
|
||||
runs-on: ubuntu-latest
|
||||
container: ${{matrix.os}}
|
||||
defaults:
|
||||
@@ -25,10 +25,6 @@ jobs:
|
||||
lib:
|
||||
- shared
|
||||
- static
|
||||
threading_model:
|
||||
- CXX_THREADS
|
||||
- NO_THREADS
|
||||
- OPENMP
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@@ -55,8 +51,8 @@ jobs:
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{env.CCACHE_DIR}}
|
||||
key: ${{matrix.os}}-ccache-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.threading_model}}-${{github.run_id}}
|
||||
restore-keys: ${{matrix.os}}-ccache-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.threading_model}}-
|
||||
key: ${{matrix.os}}-ccache-${{matrix.build_type}}-${{matrix.lib}}-${{github.run_id}}
|
||||
restore-keys: ${{matrix.os}}-ccache-${{matrix.build_type}}-${{matrix.lib}}-
|
||||
|
||||
- name: Setup Environment
|
||||
if: matrix.build_type == 'Release'
|
||||
@@ -67,7 +63,6 @@ jobs:
|
||||
run: |
|
||||
cmake -S . -B build_${{matrix.build_type}} \
|
||||
-DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} \
|
||||
-DCERES_THREADING_MODEL=${{matrix.threading_model}} \
|
||||
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
|
||||
-DCMAKE_C_COMPILER_LAUNCHER=$(which ccache) \
|
||||
-DCMAKE_CXX_COMPILER_LAUNCHER=$(which ccache) \
|
||||
|
||||
+2
-19
@@ -118,24 +118,9 @@ read_ceres_version_from_source(${Ceres_SOURCE_DIR})
|
||||
|
||||
enable_testing()
|
||||
|
||||
include(CeresThreadingModels)
|
||||
include(CMakeDependentOption)
|
||||
include(PrettyPrintCMakeList)
|
||||
|
||||
find_available_ceres_threading_models(CERES_THREADING_MODELS_AVAILABLE)
|
||||
pretty_print_cmake_list(PRETTY_CERES_THREADING_MODELS_AVAILABLE
|
||||
${CERES_THREADING_MODELS_AVAILABLE})
|
||||
message("-- Detected available Ceres threading models: "
|
||||
"${PRETTY_CERES_THREADING_MODELS_AVAILABLE}")
|
||||
set(CERES_THREADING_MODEL "${CERES_THREADING_MODEL}" CACHE STRING
|
||||
"Ceres threading back-end" FORCE)
|
||||
if (NOT CERES_THREADING_MODEL)
|
||||
list(GET CERES_THREADING_MODELS_AVAILABLE 0 DEFAULT_THREADING_MODEL)
|
||||
update_cache_variable(CERES_THREADING_MODEL ${DEFAULT_THREADING_MODEL})
|
||||
endif()
|
||||
set_property(CACHE CERES_THREADING_MODEL PROPERTY STRINGS
|
||||
${CERES_THREADING_MODELS_AVAILABLE})
|
||||
|
||||
option(MINIGLOG "Use a stripped down version of glog." OFF)
|
||||
option(GFLAGS "Enable Google Flags." ON)
|
||||
option(SUITESPARSE "Enable SuiteSparse." ON)
|
||||
@@ -197,8 +182,8 @@ if (IOS)
|
||||
# Apple claims that the BLAS call dsyrk_ is a private API, and will not allow
|
||||
# you to submit to the Apple Store if the symbol is present.
|
||||
update_cache_variable(LAPACK OFF)
|
||||
message(STATUS "Building for iOS: SuiteSparse, LAPACK, gflags, "
|
||||
"and OpenMP are not available.")
|
||||
message(STATUS "Building for iOS: SuiteSparse, LAPACK, gflags "
|
||||
"are not available.")
|
||||
|
||||
update_cache_variable(BUILD_EXAMPLES OFF)
|
||||
message(STATUS "Building for iOS: Will not build examples.")
|
||||
@@ -489,8 +474,6 @@ if (NOT CUSTOM_BLAS)
|
||||
message("-- Disabling custom blas")
|
||||
endif (NOT CUSTOM_BLAS)
|
||||
|
||||
set_ceres_threading_model("${CERES_THREADING_MODEL}")
|
||||
|
||||
if (BUILD_BENCHMARKS)
|
||||
# Version 1.3 was first to provide import targets
|
||||
find_package(benchmark 1.3 QUIET)
|
||||
|
||||
@@ -80,10 +80,6 @@ function(ceres_compile_options_to_components CURRENT_CERES_COMPILE_OPTIONS CERES
|
||||
CERES_NO_ACCELERATE_SPARSE "AccelerateSparse;SparseLinearAlgebraLibrary")
|
||||
add_to_output_if_not_found(CURRENT_CERES_COMPILE_OPTIONS ${CERES_COMPONENTS_VAR}
|
||||
CERES_RESTRICT_SCHUR_SPECIALIZATION "SchurSpecializations")
|
||||
add_to_output_if_found(CURRENT_CERES_COMPILE_OPTIONS ${CERES_COMPONENTS_VAR}
|
||||
CERES_USE_OPENMP "OpenMP;Multithreading")
|
||||
add_to_output_if_found(CURRENT_CERES_COMPILE_OPTIONS ${CERES_COMPONENTS_VAR}
|
||||
CERES_USE_CXX_THREADS "Multithreading")
|
||||
# Remove duplicates of SparseLinearAlgebraLibrary if multiple sparse backends
|
||||
# are present.
|
||||
list(REMOVE_DUPLICATES ${CERES_COMPONENTS_VAR})
|
||||
|
||||
@@ -178,10 +178,9 @@ set(CERES_VERSION @CERES_VERSION@)
|
||||
include(CMakeFindDependencyMacro)
|
||||
# Optional dependencies
|
||||
@METIS_DEPENDENCY@
|
||||
@OpenMP_DEPENDENCY@
|
||||
@SuiteSparse_DEPENDENCY@
|
||||
@Threads_DEPENDENCY@
|
||||
@CUDAToolkit_DEPENDENCY@
|
||||
@Threads_DEPENDENCY@
|
||||
|
||||
# As imported CMake targets are not re-exported when a dependent target is
|
||||
# exported, we must invoke find_package(XXX) here to reload the definition
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
# Ceres Solver - A fast non-linear least squares minimizer
|
||||
# Copyright 2018 Google Inc. All rights reserved.
|
||||
# http://ceres-solver.org/
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
# * Neither the name of Google Inc. nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# Author: alexs.mac@gmail.com (Alex Stewart)
|
||||
|
||||
# Ordered by expected preference.
|
||||
set(CERES_THREADING_MODELS "CXX_THREADS;OPENMP;NO_THREADS")
|
||||
|
||||
function(find_available_ceres_threading_models CERES_THREADING_MODELS_AVAILABLE_VAR)
|
||||
set(CERES_THREADING_MODELS_AVAILABLE ${CERES_THREADING_MODELS})
|
||||
# Remove any threading models for which the dependencies are not available.
|
||||
find_package(OpenMP QUIET)
|
||||
if (NOT OPENMP_FOUND)
|
||||
list(REMOVE_ITEM CERES_THREADING_MODELS_AVAILABLE "OPENMP")
|
||||
endif()
|
||||
if (NOT CERES_THREADING_MODELS_AVAILABLE)
|
||||
# At least NO_THREADS should never be removed. This check is purely
|
||||
# protective against future threading model updates.
|
||||
message(FATAL_ERROR "Ceres bug: Removed all threading models.")
|
||||
endif()
|
||||
set(${CERES_THREADING_MODELS_AVAILABLE_VAR}
|
||||
${CERES_THREADING_MODELS_AVAILABLE} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
macro(set_ceres_threading_model_to_cxx11_threads)
|
||||
list(APPEND CERES_COMPILE_OPTIONS CERES_USE_CXX_THREADS)
|
||||
endmacro()
|
||||
|
||||
macro(set_ceres_threading_model_to_openmp)
|
||||
find_package(OpenMP REQUIRED)
|
||||
list(APPEND CERES_COMPILE_OPTIONS CERES_USE_OPENMP)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
|
||||
endmacro()
|
||||
|
||||
macro(set_ceres_threading_model_to_no_threads)
|
||||
list(APPEND CERES_COMPILE_OPTIONS CERES_NO_THREADS)
|
||||
endmacro()
|
||||
|
||||
macro(set_ceres_threading_model CERES_THREADING_MODEL_TO_SET)
|
||||
if ("${CERES_THREADING_MODEL_TO_SET}" STREQUAL "CXX_THREADS")
|
||||
set_ceres_threading_model_to_cxx11_threads()
|
||||
elseif ("${CERES_THREADING_MODEL_TO_SET}" STREQUAL "OPENMP")
|
||||
set_ceres_threading_model_to_openmp()
|
||||
elseif ("${CERES_THREADING_MODEL_TO_SET}" STREQUAL "NO_THREADS")
|
||||
set_ceres_threading_model_to_no_threads()
|
||||
else()
|
||||
include(PrettyPrintCMakeList)
|
||||
find_available_ceres_threading_models(_AVAILABLE_THREADING_MODELS)
|
||||
pretty_print_cmake_list(
|
||||
_AVAILABLE_THREADING_MODELS ${_AVAILABLE_THREADING_MODELS})
|
||||
message(FATAL_ERROR "Unknown threading model specified: "
|
||||
"'${CERES_THREADING_MODEL_TO_SET}'. Available threading models for "
|
||||
"this platform are: ${_AVAILABLE_THREADING_MODELS}")
|
||||
endif()
|
||||
message("-- Using Ceres threading model: ${CERES_THREADING_MODEL_TO_SET}")
|
||||
endmacro()
|
||||
@@ -70,12 +70,6 @@
|
||||
// routines.
|
||||
@CERES_NO_CUSTOM_BLAS@
|
||||
|
||||
// If defined, Ceres was compiled without multithreading support.
|
||||
@CERES_NO_THREADS@
|
||||
// If defined Ceres was compiled with OpenMP multithreading.
|
||||
@CERES_USE_OPENMP@
|
||||
// If defined Ceres was compiled with modern C++ multithreading.
|
||||
@CERES_USE_CXX_THREADS@
|
||||
// If defined, Ceres was compiled with a version of SuiteSparse/CHOLMOD without
|
||||
// the Partition module (requires METIS).
|
||||
@CERES_NO_CHOLMOD_PARTITION@
|
||||
@@ -87,22 +81,6 @@
|
||||
// with underscore prefixed versions (e.g. j0() -> _j0()).
|
||||
@CERES_MSVC_USE_UNDERSCORE_PREFIXED_BESSEL_FUNCTIONS@
|
||||
|
||||
#if defined(CERES_USE_OPENMP)
|
||||
#if defined(CERES_USE_CXX_THREADS) || defined(CERES_NO_THREADS)
|
||||
#error CERES_USE_OPENMP is mutually exclusive to CERES_USE_CXX_THREADS and CERES_NO_THREADS
|
||||
#endif
|
||||
#elif defined(CERES_USE_CXX_THREADS)
|
||||
#if defined(CERES_USE_OPENMP) || defined(CERES_NO_THREADS)
|
||||
#error CERES_USE_CXX_THREADS is mutually exclusive to CERES_USE_OPENMP, CERES_USE_CXX_THREADS and CERES_NO_THREADS
|
||||
#endif
|
||||
#elif defined(CERES_NO_THREADS)
|
||||
#if defined(CERES_USE_OPENMP) || defined(CERES_USE_CXX_THREADS)
|
||||
#error CERES_NO_THREADS is mutually exclusive to CERES_USE_OPENMP and CERES_USE_CXX_THREADS
|
||||
#endif
|
||||
#else
|
||||
# error One of CERES_USE_OPENMP, CERES_USE_CXX_THREADS or CERES_NO_THREADS must be defined.
|
||||
#endif
|
||||
|
||||
// CERES_NO_SPARSE should be automatically defined by config.h if Ceres was
|
||||
// compiled without any sparse back-end. Verify that it has not subsequently
|
||||
// been inconsistently redefined.
|
||||
|
||||
@@ -32,25 +32,10 @@
|
||||
|
||||
# Avoid 'xxx.cc has no symbols' warnings from source files which are 'empty'
|
||||
# when their enclosing #ifdefs are disabled.
|
||||
if (CERES_THREADING_MODEL STREQUAL "CXX_THREADS")
|
||||
set(CERES_PARALLEL_FOR_SRC parallel_for_cxx.cc thread_pool.cc)
|
||||
find_package(Threads REQUIRED)
|
||||
list(APPEND CERES_LIBRARY_PRIVATE_DEPENDENCIES Threads::Threads)
|
||||
|
||||
# Make dependency visible to the parent CMakeLists.txt
|
||||
set(Threads_DEPENDENCY "find_dependency (Threads)" PARENT_SCOPE)
|
||||
elseif (CERES_THREADING_MODEL STREQUAL "OPENMP")
|
||||
# OpenMP requires linking to the corresponding library.
|
||||
find_package(OpenMP REQUIRED COMPONENTS CXX)
|
||||
|
||||
set(CERES_PARALLEL_FOR_SRC parallel_for_openmp.cc)
|
||||
list(APPEND CERES_LIBRARY_PRIVATE_DEPENDENCIES OpenMP::OpenMP_CXX)
|
||||
|
||||
# Make dependency visible to the parent CMakeLists.txt
|
||||
set(OpenMP_DEPENDENCY "find_dependency (OpenMP ${OpenMP_CXX_VERSION} COMPONENTS CXX)" PARENT_SCOPE)
|
||||
elseif (CERES_THREADING_MODEL STREQUAL "NO_THREADS")
|
||||
set(CERES_PARALLEL_FOR_SRC parallel_for_nothreads.cc)
|
||||
endif()
|
||||
find_package(Threads REQUIRED)
|
||||
list(APPEND CERES_LIBRARY_PRIVATE_DEPENDENCIES Threads::Threads)
|
||||
# Make dependency visible to the parent CMakeLists.txt
|
||||
set(Threads_DEPENDENCY "find_dependency (Threads)" PARENT_SCOPE)
|
||||
|
||||
# Source files that contain public symbols and live in the ceres namespaces.
|
||||
# Such symbols are expected to be marked with CERES_EXPORT and the files below
|
||||
@@ -171,7 +156,6 @@ endif ()
|
||||
# lexicographical order.
|
||||
add_library(ceres_internal OBJECT
|
||||
${CERES_INTERNAL_SCHUR_FILES}
|
||||
${CERES_PARALLEL_FOR_SRC}
|
||||
accelerate_sparse.cc
|
||||
array_utils.cc
|
||||
block_evaluate_preparer.cc
|
||||
@@ -235,6 +219,7 @@ add_library(ceres_internal OBJECT
|
||||
linear_solver.cc
|
||||
low_rank_inverse_hessian.cc
|
||||
minimizer.cc
|
||||
parallel_for_cxx.cc
|
||||
parallel_utils.cc
|
||||
parameter_block_ordering.cc
|
||||
partitioned_matrix_view.cc
|
||||
@@ -260,6 +245,7 @@ add_library(ceres_internal OBJECT
|
||||
stringprintf.cc
|
||||
subset_preconditioner.cc
|
||||
suitesparse.cc
|
||||
thread_pool.cc
|
||||
thread_token_provider.cc
|
||||
triplet_sparse_matrix.cc
|
||||
trust_region_minimizer.cc
|
||||
|
||||
@@ -28,15 +28,12 @@
|
||||
//
|
||||
// Author: vitus@google.com (Michael Vitus)
|
||||
|
||||
// This include must come before any #ifndef check on Ceres compile options.
|
||||
#include "ceres/internal/config.h"
|
||||
|
||||
#ifdef CERES_USE_CXX_THREADS
|
||||
#include "ceres/concurrent_queue.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
#include "ceres/concurrent_queue.h"
|
||||
#include "ceres/internal/config.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
@@ -300,5 +297,3 @@ TEST(ConcurrentQueue, StopAndEnableWaiters) {
|
||||
}
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_USE_CXX_THREADS
|
||||
|
||||
@@ -171,9 +171,9 @@ ContextImpl::~ContextImpl() {
|
||||
TearDown();
|
||||
#endif // CERES_NO_CUDA
|
||||
}
|
||||
|
||||
void ContextImpl::EnsureMinimumThreads(int num_threads) {
|
||||
#ifdef CERES_USE_CXX_THREADS
|
||||
thread_pool.Resize(num_threads);
|
||||
#endif // CERES_USE_CXX_THREADS
|
||||
}
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
@@ -49,9 +49,7 @@
|
||||
#include "cusparse.h"
|
||||
#endif // CERES_NO_CUDA
|
||||
|
||||
#ifdef CERES_USE_CXX_THREADS
|
||||
#include "ceres/thread_pool.h"
|
||||
#endif // CERES_USE_CXX_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
@@ -67,9 +65,7 @@ class CERES_NO_EXPORT ContextImpl final : public Context {
|
||||
// defined by the hardware. Otherwise this call is a no-op.
|
||||
void EnsureMinimumThreads(int num_threads);
|
||||
|
||||
#ifdef CERES_USE_CXX_THREADS
|
||||
ThreadPool thread_pool;
|
||||
#endif // CERES_USE_CXX_THREADS
|
||||
|
||||
#ifndef CERES_NO_CUDA
|
||||
// Note on Ceres' use of CUDA Devices on multi-GPU systems:
|
||||
|
||||
@@ -65,15 +65,6 @@ using CovarianceBlocks = std::vector<std::pair<const double*, const double*>>;
|
||||
|
||||
CovarianceImpl::CovarianceImpl(const Covariance::Options& options)
|
||||
: options_(options), is_computed_(false), is_valid_(false) {
|
||||
#ifdef CERES_NO_THREADS
|
||||
if (options_.num_threads > 1) {
|
||||
LOG(WARNING) << "No threading support is compiled into this binary; "
|
||||
<< "only options.num_threads = 1 is supported. Switching "
|
||||
<< "to single threaded mode.";
|
||||
options_.num_threads = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
evaluate_options_.num_threads = options_.num_threads;
|
||||
evaluate_options_.apply_loss_function = options_.apply_loss_function;
|
||||
}
|
||||
|
||||
@@ -639,8 +639,6 @@ TEST_F(CovarianceTest, NormalBehavior) {
|
||||
ComputeAndCompareCovarianceBlocks(options, expected_covariance);
|
||||
}
|
||||
|
||||
#ifdef CERES_USE_OPENMP
|
||||
|
||||
TEST_F(CovarianceTest, ThreadedNormalBehavior) {
|
||||
// J
|
||||
//
|
||||
@@ -691,8 +689,6 @@ TEST_F(CovarianceTest, ThreadedNormalBehavior) {
|
||||
ComputeAndCompareCovarianceBlocks(options, expected_covariance);
|
||||
}
|
||||
|
||||
#endif // CERES_USE_OPENMP
|
||||
|
||||
TEST_F(CovarianceTest, ConstantParameterBlock) {
|
||||
problem_.SetParameterBlockConstant(parameters_);
|
||||
|
||||
@@ -1355,13 +1351,13 @@ class LargeScaleCovarianceTest : public ::testing::Test {
|
||||
vector<pair<const double*, const double*>> all_covariance_blocks_;
|
||||
};
|
||||
|
||||
#if !defined(CERES_NO_SUITESPARSE) && defined(CERES_USE_OPENMP)
|
||||
#if !defined(CERES_NO_SUITESPARSE)
|
||||
|
||||
TEST_F(LargeScaleCovarianceTest, Parallel) {
|
||||
ComputeAndCompare(SPARSE_QR, SUITE_SPARSE, 4);
|
||||
}
|
||||
|
||||
#endif // !defined(CERES_NO_SUITESPARSE) && defined(CERES_USE_OPENMP)
|
||||
#endif // !defined(CERES_NO_SUITESPARSE)
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ceres
|
||||
|
||||
@@ -221,11 +221,6 @@ def generate_bundle_test(linear_solver,
|
||||
preprocessor_conditions_begin.append('#ifndef CERES_NO_CUDA')
|
||||
preprocessor_conditions_end.insert(0, '#endif // CERES_NO_CUDA')
|
||||
|
||||
# Accumulate appropriate #ifdef/#ifndefs for threading conditions.
|
||||
if thread_config == MULTI_THREADED:
|
||||
preprocessor_conditions_begin.append('#ifndef CERES_NO_THREADS')
|
||||
preprocessor_conditions_end.insert(0, '#endif // CERES_NO_THREADS')
|
||||
|
||||
# If there are #ifdefs, put newlines around them.
|
||||
if preprocessor_conditions_begin:
|
||||
preprocessor_conditions_begin.insert(0, '')
|
||||
|
||||
-2
@@ -39,7 +39,6 @@
|
||||
#include "bundle_adjustment_test_util.h"
|
||||
|
||||
#ifndef CERES_NO_CUDA
|
||||
#ifndef CERES_NO_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
@@ -61,5 +60,4 @@ TEST_F(BundleAdjustmentTest,
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
#endif // CERES_NO_CUDA
|
||||
|
||||
-2
@@ -39,7 +39,6 @@
|
||||
#include "bundle_adjustment_test_util.h"
|
||||
|
||||
#ifndef CERES_NO_CUDA
|
||||
#ifndef CERES_NO_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
@@ -61,5 +60,4 @@ TEST_F(BundleAdjustmentTest,
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
#endif // CERES_NO_CUDA
|
||||
|
||||
-4
@@ -38,8 +38,6 @@
|
||||
#include "ceres/internal/config.h"
|
||||
#include "bundle_adjustment_test_util.h"
|
||||
|
||||
#ifndef CERES_NO_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
TEST_F(BundleAdjustmentTest,
|
||||
@@ -59,5 +57,3 @@ TEST_F(BundleAdjustmentTest,
|
||||
}
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
|
||||
-4
@@ -38,8 +38,6 @@
|
||||
#include "ceres/internal/config.h"
|
||||
#include "bundle_adjustment_test_util.h"
|
||||
|
||||
#ifndef CERES_NO_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
TEST_F(BundleAdjustmentTest,
|
||||
@@ -59,5 +57,3 @@ TEST_F(BundleAdjustmentTest,
|
||||
}
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
|
||||
-2
@@ -39,7 +39,6 @@
|
||||
#include "bundle_adjustment_test_util.h"
|
||||
|
||||
#ifndef CERES_NO_LAPACK
|
||||
#ifndef CERES_NO_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
@@ -61,5 +60,4 @@ TEST_F(BundleAdjustmentTest,
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
#endif // CERES_NO_LAPACK
|
||||
|
||||
-2
@@ -39,7 +39,6 @@
|
||||
#include "bundle_adjustment_test_util.h"
|
||||
|
||||
#ifndef CERES_NO_LAPACK
|
||||
#ifndef CERES_NO_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
@@ -61,5 +60,4 @@ TEST_F(BundleAdjustmentTest,
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
#endif // CERES_NO_LAPACK
|
||||
|
||||
-2
@@ -39,7 +39,6 @@
|
||||
#include "bundle_adjustment_test_util.h"
|
||||
|
||||
#ifndef CERES_NO_ACCELERATE_SPARSE
|
||||
#ifndef CERES_NO_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
@@ -61,5 +60,4 @@ TEST_F(BundleAdjustmentTest,
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
#endif // CERES_NO_ACCELERATE_SPARSE
|
||||
|
||||
-2
@@ -39,7 +39,6 @@
|
||||
#include "bundle_adjustment_test_util.h"
|
||||
|
||||
#ifndef CERES_NO_ACCELERATE_SPARSE
|
||||
#ifndef CERES_NO_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
@@ -61,5 +60,4 @@ TEST_F(BundleAdjustmentTest,
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
#endif // CERES_NO_ACCELERATE_SPARSE
|
||||
|
||||
-2
@@ -39,7 +39,6 @@
|
||||
#include "bundle_adjustment_test_util.h"
|
||||
|
||||
#ifndef CERES_NO_ACCELERATE_SPARSE
|
||||
#ifndef CERES_NO_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
@@ -61,5 +60,4 @@ TEST_F(BundleAdjustmentTest,
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
#endif // CERES_NO_ACCELERATE_SPARSE
|
||||
|
||||
-2
@@ -39,7 +39,6 @@
|
||||
#include "bundle_adjustment_test_util.h"
|
||||
|
||||
#ifndef CERES_NO_ACCELERATE_SPARSE
|
||||
#ifndef CERES_NO_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
@@ -61,5 +60,4 @@ TEST_F(BundleAdjustmentTest,
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
#endif // CERES_NO_ACCELERATE_SPARSE
|
||||
|
||||
-2
@@ -39,7 +39,6 @@
|
||||
#include "bundle_adjustment_test_util.h"
|
||||
|
||||
#ifdef CERES_USE_EIGEN_SPARSE
|
||||
#ifndef CERES_NO_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
@@ -61,5 +60,4 @@ TEST_F(BundleAdjustmentTest,
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
#endif // CERES_USE_EIGEN_SPARSE
|
||||
|
||||
-2
@@ -39,7 +39,6 @@
|
||||
#include "bundle_adjustment_test_util.h"
|
||||
|
||||
#ifdef CERES_USE_EIGEN_SPARSE
|
||||
#ifndef CERES_NO_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
@@ -61,5 +60,4 @@ TEST_F(BundleAdjustmentTest,
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
#endif // CERES_USE_EIGEN_SPARSE
|
||||
|
||||
-2
@@ -39,7 +39,6 @@
|
||||
#include "bundle_adjustment_test_util.h"
|
||||
|
||||
#ifdef CERES_USE_EIGEN_SPARSE
|
||||
#ifndef CERES_NO_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
@@ -61,5 +60,4 @@ TEST_F(BundleAdjustmentTest,
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
#endif // CERES_USE_EIGEN_SPARSE
|
||||
|
||||
-2
@@ -39,7 +39,6 @@
|
||||
#include "bundle_adjustment_test_util.h"
|
||||
|
||||
#ifdef CERES_USE_EIGEN_SPARSE
|
||||
#ifndef CERES_NO_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
@@ -61,5 +60,4 @@ TEST_F(BundleAdjustmentTest,
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
#endif // CERES_USE_EIGEN_SPARSE
|
||||
|
||||
-4
@@ -38,8 +38,6 @@
|
||||
#include "ceres/internal/config.h"
|
||||
#include "bundle_adjustment_test_util.h"
|
||||
|
||||
#ifndef CERES_NO_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
TEST_F(BundleAdjustmentTest,
|
||||
@@ -59,5 +57,3 @@ TEST_F(BundleAdjustmentTest,
|
||||
}
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
|
||||
-4
@@ -38,8 +38,6 @@
|
||||
#include "ceres/internal/config.h"
|
||||
#include "bundle_adjustment_test_util.h"
|
||||
|
||||
#ifndef CERES_NO_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
TEST_F(BundleAdjustmentTest,
|
||||
@@ -59,5 +57,3 @@ TEST_F(BundleAdjustmentTest,
|
||||
}
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
|
||||
-4
@@ -38,8 +38,6 @@
|
||||
#include "ceres/internal/config.h"
|
||||
#include "bundle_adjustment_test_util.h"
|
||||
|
||||
#ifndef CERES_NO_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
TEST_F(BundleAdjustmentTest,
|
||||
@@ -59,5 +57,3 @@ TEST_F(BundleAdjustmentTest,
|
||||
}
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
|
||||
-4
@@ -38,8 +38,6 @@
|
||||
#include "ceres/internal/config.h"
|
||||
#include "bundle_adjustment_test_util.h"
|
||||
|
||||
#ifndef CERES_NO_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
TEST_F(BundleAdjustmentTest,
|
||||
@@ -59,5 +57,3 @@ TEST_F(BundleAdjustmentTest,
|
||||
}
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
|
||||
-2
@@ -39,7 +39,6 @@
|
||||
#include "bundle_adjustment_test_util.h"
|
||||
|
||||
#ifndef CERES_NO_SUITESPARSE
|
||||
#ifndef CERES_NO_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
@@ -61,5 +60,4 @@ TEST_F(BundleAdjustmentTest,
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
#endif // CERES_NO_SUITESPARSE
|
||||
|
||||
-2
@@ -39,7 +39,6 @@
|
||||
#include "bundle_adjustment_test_util.h"
|
||||
|
||||
#ifndef CERES_NO_SUITESPARSE
|
||||
#ifndef CERES_NO_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
@@ -61,5 +60,4 @@ TEST_F(BundleAdjustmentTest,
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
#endif // CERES_NO_SUITESPARSE
|
||||
|
||||
-2
@@ -39,7 +39,6 @@
|
||||
#include "bundle_adjustment_test_util.h"
|
||||
|
||||
#ifndef CERES_NO_SUITESPARSE
|
||||
#ifndef CERES_NO_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
@@ -61,5 +60,4 @@ TEST_F(BundleAdjustmentTest,
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
#endif // CERES_NO_SUITESPARSE
|
||||
|
||||
-2
@@ -39,7 +39,6 @@
|
||||
#include "bundle_adjustment_test_util.h"
|
||||
|
||||
#ifndef CERES_NO_SUITESPARSE
|
||||
#ifndef CERES_NO_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
@@ -61,5 +60,4 @@ TEST_F(BundleAdjustmentTest,
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
#endif // CERES_NO_SUITESPARSE
|
||||
|
||||
-2
@@ -39,7 +39,6 @@
|
||||
#include "bundle_adjustment_test_util.h"
|
||||
|
||||
#ifndef CERES_NO_ACCELERATE_SPARSE
|
||||
#ifndef CERES_NO_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
@@ -61,5 +60,4 @@ TEST_F(BundleAdjustmentTest,
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
#endif // CERES_NO_ACCELERATE_SPARSE
|
||||
|
||||
-2
@@ -39,7 +39,6 @@
|
||||
#include "bundle_adjustment_test_util.h"
|
||||
|
||||
#ifndef CERES_NO_ACCELERATE_SPARSE
|
||||
#ifndef CERES_NO_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
@@ -61,5 +60,4 @@ TEST_F(BundleAdjustmentTest,
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
#endif // CERES_NO_ACCELERATE_SPARSE
|
||||
|
||||
-2
@@ -39,7 +39,6 @@
|
||||
#include "bundle_adjustment_test_util.h"
|
||||
|
||||
#ifdef CERES_USE_EIGEN_SPARSE
|
||||
#ifndef CERES_NO_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
@@ -61,5 +60,4 @@ TEST_F(BundleAdjustmentTest,
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
#endif // CERES_USE_EIGEN_SPARSE
|
||||
|
||||
-2
@@ -39,7 +39,6 @@
|
||||
#include "bundle_adjustment_test_util.h"
|
||||
|
||||
#ifdef CERES_USE_EIGEN_SPARSE
|
||||
#ifndef CERES_NO_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
@@ -61,5 +60,4 @@ TEST_F(BundleAdjustmentTest,
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
#endif // CERES_USE_EIGEN_SPARSE
|
||||
|
||||
-2
@@ -39,7 +39,6 @@
|
||||
#include "bundle_adjustment_test_util.h"
|
||||
|
||||
#ifndef CERES_NO_SUITESPARSE
|
||||
#ifndef CERES_NO_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
@@ -61,5 +60,4 @@ TEST_F(BundleAdjustmentTest,
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
#endif // CERES_NO_SUITESPARSE
|
||||
|
||||
-2
@@ -39,7 +39,6 @@
|
||||
#include "bundle_adjustment_test_util.h"
|
||||
|
||||
#ifndef CERES_NO_SUITESPARSE
|
||||
#ifndef CERES_NO_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
@@ -61,5 +60,4 @@ TEST_F(BundleAdjustmentTest,
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
#endif // CERES_NO_SUITESPARSE
|
||||
|
||||
-2
@@ -39,7 +39,6 @@
|
||||
#include "bundle_adjustment_test_util.h"
|
||||
|
||||
#ifndef CERES_NO_ACCELERATE_SPARSE
|
||||
#ifndef CERES_NO_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
@@ -61,5 +60,4 @@ TEST_F(BundleAdjustmentTest,
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
#endif // CERES_NO_ACCELERATE_SPARSE
|
||||
|
||||
-2
@@ -39,7 +39,6 @@
|
||||
#include "bundle_adjustment_test_util.h"
|
||||
|
||||
#ifndef CERES_NO_ACCELERATE_SPARSE
|
||||
#ifndef CERES_NO_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
@@ -61,5 +60,4 @@ TEST_F(BundleAdjustmentTest,
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
#endif // CERES_NO_ACCELERATE_SPARSE
|
||||
|
||||
-2
@@ -39,7 +39,6 @@
|
||||
#include "bundle_adjustment_test_util.h"
|
||||
|
||||
#ifdef CERES_USE_EIGEN_SPARSE
|
||||
#ifndef CERES_NO_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
@@ -61,5 +60,4 @@ TEST_F(BundleAdjustmentTest,
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
#endif // CERES_USE_EIGEN_SPARSE
|
||||
|
||||
-2
@@ -39,7 +39,6 @@
|
||||
#include "bundle_adjustment_test_util.h"
|
||||
|
||||
#ifdef CERES_USE_EIGEN_SPARSE
|
||||
#ifndef CERES_NO_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
@@ -61,5 +60,4 @@ TEST_F(BundleAdjustmentTest,
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
#endif // CERES_USE_EIGEN_SPARSE
|
||||
|
||||
-2
@@ -39,7 +39,6 @@
|
||||
#include "bundle_adjustment_test_util.h"
|
||||
|
||||
#ifndef CERES_NO_SUITESPARSE
|
||||
#ifndef CERES_NO_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
@@ -61,5 +60,4 @@ TEST_F(BundleAdjustmentTest,
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
#endif // CERES_NO_SUITESPARSE
|
||||
|
||||
-2
@@ -39,7 +39,6 @@
|
||||
#include "bundle_adjustment_test_util.h"
|
||||
|
||||
#ifndef CERES_NO_SUITESPARSE
|
||||
#ifndef CERES_NO_THREADS
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
@@ -61,5 +60,4 @@ TEST_F(BundleAdjustmentTest,
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
#endif // CERES_NO_SUITESPARSE
|
||||
|
||||
@@ -338,21 +338,7 @@ void ParallelFor(ContextImpl* context,
|
||||
} // namespace ceres::internal
|
||||
|
||||
// Backend-specific implementations of ParallelInvoke
|
||||
#include "ceres/parallel_for_cxx.h"
|
||||
#include "ceres/parallel_for_openmp.h"
|
||||
#ifdef CERES_NO_THREADS
|
||||
namespace ceres::internal {
|
||||
template <typename F>
|
||||
void ParallelInvoke(ContextImpl* context,
|
||||
int start,
|
||||
int end,
|
||||
int num_threads,
|
||||
const F& function) {
|
||||
ParallelFor(context, start, end, 1, function);
|
||||
}
|
||||
} // namespace ceres::internal
|
||||
#endif
|
||||
|
||||
#include "ceres/internal/disable_warnings.h"
|
||||
#include "ceres/parallel_for_cxx.h"
|
||||
|
||||
#endif // CERES_INTERNAL_PARALLEL_FOR_H_
|
||||
|
||||
@@ -28,17 +28,13 @@
|
||||
//
|
||||
// Author: vitus@google.com (Michael Vitus)
|
||||
|
||||
// This include must come before any #ifndef check on Ceres compile options.
|
||||
#include "ceres/internal/config.h"
|
||||
|
||||
#ifdef CERES_USE_CXX_THREADS
|
||||
|
||||
#include <atomic>
|
||||
#include <cmath>
|
||||
#include <condition_variable>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
#include "ceres/internal/config.h"
|
||||
#include "ceres/parallel_for.h"
|
||||
#include "glog/logging.h"
|
||||
|
||||
@@ -79,5 +75,3 @@ ThreadPoolState::ThreadPoolState(int start,
|
||||
int MaxNumThreadsAvailable() { return ThreadPool::MaxNumThreadsAvailable(); }
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_USE_CXX_THREADS
|
||||
|
||||
@@ -29,21 +29,16 @@
|
||||
// Authors: vitus@google.com (Michael Vitus),
|
||||
// dmitriy.korchemkin@gmail.com (Dmitriy Korchemkin)
|
||||
|
||||
// This include must come before any #ifndef check on Ceres compile options.
|
||||
#ifndef CERES_INTERNAL_PARALLEL_FOR_CXX_H_
|
||||
#define CERES_INTERNAL_PARALLEL_FOR_CXX_H_
|
||||
|
||||
// This include must come before any #ifndef check on Ceres compile options.
|
||||
#include "ceres/internal/config.h"
|
||||
|
||||
#ifdef CERES_USE_CXX_THREADS
|
||||
|
||||
#include <atomic>
|
||||
#include <cmath>
|
||||
#include <condition_variable>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
#include "ceres/internal/config.h"
|
||||
#include "glog/logging.h"
|
||||
|
||||
namespace ceres::internal {
|
||||
@@ -243,6 +238,7 @@ void ParallelInvoke(ContextImpl* context,
|
||||
// Wait until all tasks have finished.
|
||||
shared_state->block_until_finished.Block();
|
||||
}
|
||||
|
||||
} // namespace ceres::internal
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // CERES_INTERNAL_PARALLEL_FOR_CXX_H_
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
// Ceres Solver - A fast non-linear least squares minimizer
|
||||
// Copyright 2018 Google Inc. All rights reserved.
|
||||
// http://ceres-solver.org/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its contributors may be
|
||||
// used to endorse or promote products derived from this software without
|
||||
// specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: alexs.mac@gmail.com (Alex Stewart)
|
||||
|
||||
// This include must come before any #ifndef check on Ceres compile options.
|
||||
#include "ceres/internal/config.h"
|
||||
|
||||
#ifdef CERES_NO_THREADS
|
||||
|
||||
#include "ceres/parallel_for.h"
|
||||
#include "glog/logging.h"
|
||||
|
||||
namespace ceres {
|
||||
namespace internal {
|
||||
|
||||
int MaxNumThreadsAvailable() { return 1; }
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ceres
|
||||
|
||||
#endif // CERES_NO_THREADS
|
||||
@@ -1,48 +0,0 @@
|
||||
// Ceres Solver - A fast non-linear least squares minimizer
|
||||
// Copyright 2018 Google Inc. All rights reserved.
|
||||
// http://ceres-solver.org/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its contributors may be
|
||||
// used to endorse or promote products derived from this software without
|
||||
// specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: vitus@google.com (Michael Vitus)
|
||||
|
||||
// This include must come before any #ifndef check on Ceres compile options.
|
||||
#include "ceres/internal/config.h"
|
||||
|
||||
#if defined(CERES_USE_OPENMP)
|
||||
|
||||
#include "ceres/parallel_for.h"
|
||||
#include "glog/logging.h"
|
||||
#include "omp.h"
|
||||
|
||||
namespace ceres {
|
||||
namespace internal {
|
||||
|
||||
int MaxNumThreadsAvailable() { return omp_get_max_threads(); }
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ceres
|
||||
|
||||
#endif // defined(CERES_USE_OPENMP)
|
||||
@@ -1,70 +0,0 @@
|
||||
// Ceres Solver - A fast non-linear least squares minimizer
|
||||
// Copyright 2018 Google Inc. All rights reserved.
|
||||
// http://ceres-solver.org/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its contributors may be
|
||||
// used to endorse or promote products derived from this software without
|
||||
// specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Authors: vitus@google.com (Michael Vitus),
|
||||
// dmitriy.korchemkin@gmail.com (Dmitriy Korchemkin)
|
||||
|
||||
// This include must come before any #ifndef check on Ceres compile options.
|
||||
#ifndef CERES_INTERNAL_PARALLEL_FOR_OPENMP_H_
|
||||
#define CERES_INTERNAL_PARALLEL_FOR_OPENMP_H_
|
||||
|
||||
#include "ceres/internal/config.h"
|
||||
|
||||
#if defined(CERES_USE_OPENMP)
|
||||
|
||||
#include "ceres/parallel_for.h"
|
||||
#include "ceres/scoped_thread_token.h"
|
||||
#include "ceres/thread_token_provider.h"
|
||||
#include "glog/logging.h"
|
||||
#include "omp.h"
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
template <typename F>
|
||||
void ParallelInvoke(ContextImpl* context,
|
||||
int start,
|
||||
int end,
|
||||
int num_threads,
|
||||
const F& function) {
|
||||
using namespace parallel_for_details;
|
||||
ThreadTokenProvider token_provider(num_threads);
|
||||
#pragma omp parallel num_threads(num_threads)
|
||||
{
|
||||
const ScopedThreadToken scoped_thread_token(&token_provider);
|
||||
const int thread_id = scoped_thread_token.token();
|
||||
#pragma omp for schedule(guided)
|
||||
for (int i = start; i < end; ++i) {
|
||||
Invoke<F>(thread_id, i, function);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -28,11 +28,6 @@
|
||||
//
|
||||
// Author: vitus@google.com (Michael Vitus)
|
||||
|
||||
// This include must come before any #ifndef check on Ceres compile options.
|
||||
// clang-format off
|
||||
#include "ceres/internal/config.h"
|
||||
// clang-format on
|
||||
|
||||
#include "ceres/parallel_for.h"
|
||||
|
||||
#include <cmath>
|
||||
@@ -44,6 +39,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "ceres/context_impl.h"
|
||||
#include "ceres/internal/config.h"
|
||||
#include "glog/logging.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
@@ -133,8 +129,6 @@ TEST(ParallelForWithThreadId, NestedParallelForDeadlock) {
|
||||
}
|
||||
}
|
||||
|
||||
// This test is only valid when multithreading support is enabled.
|
||||
#ifndef CERES_NO_THREADS
|
||||
TEST(ParallelForWithThreadId, UniqueThreadIds) {
|
||||
// Ensure the hardware supports more than 1 thread to ensure the test will
|
||||
// pass.
|
||||
@@ -166,7 +160,6 @@ TEST(ParallelForWithThreadId, UniqueThreadIds) {
|
||||
|
||||
EXPECT_THAT(x, UnorderedElementsAreArray({0, 1}));
|
||||
}
|
||||
#endif // CERES_NO_THREADS
|
||||
|
||||
// Helper function for partition tests
|
||||
bool BruteForcePartition(
|
||||
|
||||
@@ -28,13 +28,9 @@
|
||||
//
|
||||
// Author: wjr@google.com (William Rucklidge)
|
||||
|
||||
// This include must come before any #ifndef check on Ceres compile options.
|
||||
// clang-format off
|
||||
#include "ceres/internal/config.h"
|
||||
// clang-format on
|
||||
|
||||
#include "ceres/parallel_utils.h"
|
||||
|
||||
#include "ceres/internal/config.h"
|
||||
#include "glog/logging.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
|
||||
@@ -672,17 +672,7 @@ bool ProblemImpl::Evaluate(const Problem::EvaluateOptions& evaluate_options,
|
||||
// the Evaluator decides the storage for the Jacobian based on the
|
||||
// type of linear solver being used.
|
||||
evaluator_options.linear_solver_type = SPARSE_NORMAL_CHOLESKY;
|
||||
#ifdef CERES_NO_THREADS
|
||||
if (evaluate_options.num_threads > 1) {
|
||||
LOG(WARNING)
|
||||
<< "No threading support is compiled into this binary; "
|
||||
<< "only evaluate_options.num_threads = 1 is supported. Switching "
|
||||
<< "to single threaded mode.";
|
||||
}
|
||||
evaluator_options.num_threads = 1;
|
||||
#else
|
||||
evaluator_options.num_threads = evaluate_options.num_threads;
|
||||
#endif // CERES_NO_THREADS
|
||||
|
||||
// The main thread also does work so we only need to launch num_threads - 1.
|
||||
context_impl_->EnsureMinimumThreads(evaluator_options.num_threads - 1);
|
||||
|
||||
@@ -119,15 +119,6 @@ class ProgramEvaluator final : public Evaluator {
|
||||
jacobian_writer_(options, program),
|
||||
evaluate_preparers_(std::move(
|
||||
jacobian_writer_.CreateEvaluatePreparers(options.num_threads))) {
|
||||
#ifdef CERES_NO_THREADS
|
||||
if (options_.num_threads > 1) {
|
||||
LOG(WARNING) << "No threading support is compiled into this binary; "
|
||||
<< "only options.num_threads = 1 is supported. Switching "
|
||||
<< "to single threaded mode.";
|
||||
options_.num_threads = 1;
|
||||
}
|
||||
#endif // CERES_NO_THREADS
|
||||
|
||||
BuildResidualLayout(*program, &residual_layout_);
|
||||
evaluate_scratch_ = std::move(CreateEvaluatorScratch(
|
||||
*program, static_cast<unsigned>(options.num_threads)));
|
||||
|
||||
@@ -78,12 +78,6 @@ constexpr char kVersion[] =
|
||||
"-no_schur_specializations"
|
||||
#endif
|
||||
|
||||
#ifdef CERES_USE_OPENMP
|
||||
"-openmp"
|
||||
#else
|
||||
"-no_openmp"
|
||||
#endif
|
||||
|
||||
#ifdef CERES_NO_CUSTOM_BLAS
|
||||
"-no_custom_blas"
|
||||
#endif
|
||||
|
||||
@@ -28,15 +28,12 @@
|
||||
//
|
||||
// Author: vitus@google.com (Michael Vitus)
|
||||
|
||||
// This include must come before any #ifndef check on Ceres compile options.
|
||||
#include "ceres/internal/config.h"
|
||||
|
||||
#ifdef CERES_USE_CXX_THREADS
|
||||
#include "ceres/thread_pool.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
|
||||
#include "ceres/thread_pool.h"
|
||||
#include "ceres/internal/config.h"
|
||||
|
||||
namespace ceres::internal {
|
||||
namespace {
|
||||
@@ -105,5 +102,3 @@ void ThreadPool::ThreadMainLoop() {
|
||||
void ThreadPool::Stop() { task_queue_.StopWaiters(); }
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_USE_CXX_THREADS
|
||||
|
||||
@@ -28,17 +28,14 @@
|
||||
//
|
||||
// Author: vitus@google.com (Michael Vitus)
|
||||
|
||||
// This include must come before any #ifndef check on Ceres compile options.
|
||||
#include "ceres/internal/config.h"
|
||||
|
||||
#ifdef CERES_USE_CXX_THREADS
|
||||
#include "ceres/thread_pool.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
|
||||
#include "ceres/thread_pool.h"
|
||||
#include "ceres/internal/config.h"
|
||||
#include "glog/logging.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
@@ -193,5 +190,3 @@ TEST(ThreadPool, Resize) {
|
||||
}
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_USE_CXX_THREADS
|
||||
|
||||
@@ -30,42 +30,20 @@
|
||||
|
||||
#include "ceres/thread_token_provider.h"
|
||||
|
||||
#ifdef CERES_USE_OPENMP
|
||||
#include <omp.h>
|
||||
#endif
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
ThreadTokenProvider::ThreadTokenProvider(int num_threads) {
|
||||
(void)num_threads;
|
||||
#ifdef CERES_USE_CXX_THREADS
|
||||
for (int i = 0; i < num_threads; i++) {
|
||||
pool_.Push(i);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int ThreadTokenProvider::Acquire() {
|
||||
#ifdef CERES_USE_OPENMP
|
||||
return omp_get_thread_num();
|
||||
#endif
|
||||
|
||||
#ifdef CERES_NO_THREADS
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
#ifdef CERES_USE_CXX_THREADS
|
||||
int thread_id;
|
||||
CHECK(pool_.Wait(&thread_id));
|
||||
return thread_id;
|
||||
#endif
|
||||
}
|
||||
|
||||
void ThreadTokenProvider::Release(int thread_id) {
|
||||
(void)thread_id;
|
||||
#ifdef CERES_USE_CXX_THREADS
|
||||
pool_.Push(thread_id);
|
||||
#endif
|
||||
}
|
||||
void ThreadTokenProvider::Release(int thread_id) { pool_.Push(thread_id); }
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
@@ -31,13 +31,10 @@
|
||||
#ifndef CERES_INTERNAL_THREAD_TOKEN_PROVIDER_H_
|
||||
#define CERES_INTERNAL_THREAD_TOKEN_PROVIDER_H_
|
||||
|
||||
#include "ceres/concurrent_queue.h"
|
||||
#include "ceres/internal/config.h"
|
||||
#include "ceres/internal/export.h"
|
||||
|
||||
#ifdef CERES_USE_CXX_THREADS
|
||||
#include "ceres/concurrent_queue.h"
|
||||
#endif
|
||||
|
||||
namespace ceres::internal {
|
||||
|
||||
// Helper for C++ thread number identification that is similar to
|
||||
@@ -47,12 +44,6 @@ namespace ceres::internal {
|
||||
// 0 to num_threads - 1 that can be acquired to identify the thread in a thread
|
||||
// pool.
|
||||
//
|
||||
// If CERES_NO_THREADS is defined, Acquire() always returns 0 and Release()
|
||||
// takes no action.
|
||||
//
|
||||
// If CERES_USE_OPENMP, omp_get_thread_num() is used to Acquire() with no action
|
||||
// in Release()
|
||||
//
|
||||
//
|
||||
// Example usage pseudocode:
|
||||
//
|
||||
@@ -77,15 +68,12 @@ class CERES_NO_EXPORT ThreadTokenProvider {
|
||||
void Release(int thread_id);
|
||||
|
||||
private:
|
||||
#ifdef CERES_USE_CXX_THREADS
|
||||
// This queue initially holds a sequence from 0..num_threads-1. Every
|
||||
// Acquire() call the first number is removed from here. When the token is not
|
||||
// needed anymore it shall be given back with corresponding Release()
|
||||
// call. This concurrent queue is more expensive than TBB's version, so you
|
||||
// should not acquire the thread ID on every for loop iteration.
|
||||
ConcurrentQueue<int> pool_;
|
||||
#endif
|
||||
|
||||
ThreadTokenProvider(ThreadTokenProvider&) = delete;
|
||||
ThreadTokenProvider& operator=(ThreadTokenProvider&) = delete;
|
||||
};
|
||||
|
||||
@@ -30,13 +30,9 @@
|
||||
|
||||
#include "ceres/wall_time.h"
|
||||
|
||||
#include "ceres/internal/config.h"
|
||||
|
||||
#ifdef CERES_USE_OPENMP
|
||||
#include <omp.h>
|
||||
#else
|
||||
#include <ctime>
|
||||
#endif
|
||||
|
||||
#include "ceres/internal/config.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
@@ -47,9 +43,6 @@
|
||||
namespace ceres::internal {
|
||||
|
||||
double WallTimeInSeconds() {
|
||||
#ifdef CERES_USE_OPENMP
|
||||
return omp_get_wtime();
|
||||
#else
|
||||
#ifdef _WIN32
|
||||
LARGE_INTEGER count;
|
||||
LARGE_INTEGER frequency;
|
||||
@@ -62,7 +55,6 @@ double WallTimeInSeconds() {
|
||||
gettimeofday(&time_val, nullptr);
|
||||
return (time_val.tv_sec + time_val.tv_usec * 1e-6);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
EventLogger::EventLogger(const std::string& logger_name) {
|
||||
|
||||
Reference in New Issue
Block a user