Fix intermittent optimization crash in Debug+TBB modes, exposed by testGeneralSFMFactor, etc.
parent
cd35db218b
commit
fbcb9a4d67
|
@ -17,9 +17,32 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gtsam/base/debug.h>
|
#include <gtsam/base/debug.h>
|
||||||
|
#ifdef GTSAM_USE_TBB
|
||||||
|
#include <tbb/mutex.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
|
||||||
GTSAM_EXPORT FastMap<std::string, ValueWithDefault<bool,false> > debugFlags;
|
GTSAM_EXPORT FastMap<std::string, ValueWithDefault<bool, false> > debugFlags;
|
||||||
|
|
||||||
|
#ifdef GTSAM_USE_TBB
|
||||||
|
tbb::mutex debugFlagsMutex;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* ************************************************************************* */
|
||||||
|
bool guardedIsDebug(const std::string& s) {
|
||||||
|
#ifdef GTSAM_USE_TBB
|
||||||
|
tbb::mutex::scoped_lock lock(debugFlagsMutex);
|
||||||
|
#endif
|
||||||
|
return gtsam::debugFlags[s];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ************************************************************************* */
|
||||||
|
void guardedSetDebug(const std::string& s, const bool v) {
|
||||||
|
#ifdef GTSAM_USE_TBB
|
||||||
|
tbb::mutex::scoped_lock lock(debugFlagsMutex);
|
||||||
|
#endif
|
||||||
|
gtsam::debugFlags[s] = v;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,10 @@
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
GTSAM_EXTERN_EXPORT FastMap<std::string, ValueWithDefault<bool,false> > debugFlags;
|
GTSAM_EXTERN_EXPORT FastMap<std::string, ValueWithDefault<bool,false> > debugFlags;
|
||||||
|
|
||||||
|
// thread-safe functions to access debugFlags map
|
||||||
|
bool guardedIsDebug(const std::string& s);
|
||||||
|
void guardedSetDebug(const std::string& s, const bool v);
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef ISDEBUG
|
#undef ISDEBUG
|
||||||
|
@ -50,8 +54,8 @@ namespace gtsam {
|
||||||
|
|
||||||
#ifdef GTSAM_ENABLE_DEBUG
|
#ifdef GTSAM_ENABLE_DEBUG
|
||||||
|
|
||||||
#define ISDEBUG(S) (gtsam::debugFlags[S])
|
#define ISDEBUG(S) (gtsam::guardedIsDebug(S))
|
||||||
#define SETDEBUG(S,V) ((void)(gtsam::debugFlags[S] = (V)))
|
#define SETDEBUG(S,V) ((void)(gtsam::guardedSetDebug(S,V)))
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue