mirror of
https://github.com/ceres-solver/ceres-solver.git
synced 2026-08-30 00:50:37 +08:00
Adds a Ceres Context structure.
A Ceres Context holds common global state that can be re-used within Ceres. The Context current contains a thread pool if compiling with C++11 threading support. Threads are expensive to create and destroy so it is good to maintain across multiple Ceres solves. Tested by compiling with and without TBB support and ran unit tests. Ran bazel as well. Change-Id: I82f598dfae642aa0e81a6039dc174608a5e8dbfb
This commit is contained in:
+12
-4
@@ -39,13 +39,13 @@
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
#include "glog/logging.h"
|
||||
#include "ceres/context.h"
|
||||
#include "ceres/internal/disable_warnings.h"
|
||||
#include "ceres/internal/macros.h"
|
||||
#include "ceres/internal/port.h"
|
||||
#include "ceres/internal/scoped_ptr.h"
|
||||
#include "ceres/types.h"
|
||||
#include "ceres/internal/disable_warnings.h"
|
||||
|
||||
#include "glog/logging.h"
|
||||
|
||||
namespace ceres {
|
||||
|
||||
@@ -126,7 +126,8 @@ class CERES_EXPORT Problem {
|
||||
loss_function_ownership(TAKE_OWNERSHIP),
|
||||
local_parameterization_ownership(TAKE_OWNERSHIP),
|
||||
enable_fast_removal(false),
|
||||
disable_all_safety_checks(false) {}
|
||||
disable_all_safety_checks(false),
|
||||
context(NULL) {}
|
||||
|
||||
// These flags control whether the Problem object owns the cost
|
||||
// functions, loss functions, and parameterizations passed into
|
||||
@@ -165,6 +166,13 @@ class CERES_EXPORT Problem {
|
||||
// WARNING: Do not set this to true, unless you are absolutely sure of what
|
||||
// you are doing.
|
||||
bool disable_all_safety_checks;
|
||||
|
||||
// A Ceres global context to use for solving this problem. This may help to
|
||||
// reduce computation time as Ceres can reuse expensive objects to create.
|
||||
// The context object can be NULL, in which case Ceres may create one.
|
||||
//
|
||||
// Ceres does NOT take ownership of the pointer.
|
||||
Context* context;
|
||||
};
|
||||
|
||||
// The default constructor is equivalent to the
|
||||
|
||||
Reference in New Issue
Block a user