diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ca25e132..004ded5e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -363,7 +363,7 @@ message(STATUS "================ Configuration Options ======================" message(STATUS "Build flags ") print_config_flag(${GTSAM_BUILD_TESTS} "Build Tests ") print_config_flag(${GTSAM_BUILD_EXAMPLES_ALWAYS} "Build examples with 'make all' ") -print_config_flag(${GTSAM_BUILD_TIMING} "Build Timing scripts ") +print_config_flag(${GTSAM_BUILD_TIMING_ALWAYS} "Build timing scripts with 'make all'") if (DOXYGEN_FOUND) print_config_flag(${GTSAM_BUILD_DOCS} "Build Docs ") endif() diff --git a/cmake/GtsamTesting.cmake b/cmake/GtsamTesting.cmake index 6195dc510..2e505c11e 100644 --- a/cmake/GtsamTesting.cmake +++ b/cmake/GtsamTesting.cmake @@ -52,7 +52,7 @@ endmacro() # an empty string "" if nothing needs to be excluded. # linkLibraries: The list of libraries to link to. macro(gtsamAddExamplesGlob globPatterns excludedFiles linkLibraries) - gtsamAddExesGlob_impl("${globPatterns}" "${excludedFiles}" "${linkLibraries}" "examples" "${GTSAM_BUILD_EXAMPLES_ALWAYS}") + gtsamAddExesGlob_impl("${globPatterns}" "${excludedFiles}" "${linkLibraries}" "examples" ${GTSAM_BUILD_EXAMPLES_ALWAYS}) endmacro() @@ -77,7 +77,7 @@ endmacro() # an empty string "" if nothing needs to be excluded. # linkLibraries: The list of libraries to link to. macro(gtsamAddTimingGlob globPatterns excludedFiles linkLibraries) - gtsamAddExesGlob_impl("${globPatterns}" "${excludedFiles}" "${linkLibraries}" "timing" "FALSE") + gtsamAddExesGlob_impl("${globPatterns}" "${excludedFiles}" "${linkLibraries}" "timing" ${GTSAM_BUILD_TIMING_ALWAYS}) endmacro() @@ -88,7 +88,7 @@ enable_testing() option(GTSAM_BUILD_TESTS "Enable/Disable building of tests" ON) option(GTSAM_BUILD_EXAMPLES_ALWAYS "Build examples with 'make all' (build with 'make examples' if not)" ON) -option(GTSAM_BUILD_TIMING "Enable/Disable building of timing scripts" OFF) # These do not currently work +option(GTSAM_BUILD_TIMING_ALWAYS "Build timing scripts with 'make all' (build with 'make timing' if not" OFF) # Add option for combining unit tests if(MSVC OR XCODE_VERSION) @@ -107,9 +107,7 @@ endif() add_custom_target(examples) # Add timing target -if(GTSAM_BUILD_TIMING) - add_custom_target(timing) -endif() +add_custom_target(timing) # Include obsolete macros - will be removed in the near future include(GtsamTestingObsolete) @@ -258,10 +256,12 @@ macro(gtsamAddExesGlob_impl globPatterns excludedFiles linkLibraries groupName b # Add TOPSRCDIR set_property(SOURCE ${script_src} APPEND PROPERTY COMPILE_DEFINITIONS "TOPSRCDIR=\"${PROJECT_SOURCE_DIR}\"") - - if(NOT buildWithAll) + + # Exclude from all or not - note weird variable assignment because we're in a macro + set(buildWithAll_on ${buildWithAll}) + if(NOT buildWithAll_on) # Exclude from 'make all' and 'make install' - set_target_properties(${target_name} PROPERTIES EXCLUDE_FROM_ALL ON) + set_target_properties("${script_name}" PROPERTIES EXCLUDE_FROM_ALL ON) endif() # Configure target folder (for MSVC and Xcode) diff --git a/timing/CMakeLists.txt b/timing/CMakeLists.txt index 1040c7ae1..fc16d3ac8 100644 --- a/timing/CMakeLists.txt +++ b/timing/CMakeLists.txt @@ -1,6 +1,3 @@ -list(APPEND to_exclude - timeFactorOverhead.cpp - timeSLAMlike.cpp) -gtsamAddTimingGlob("*.cpp" "${to_exclude}" "gtsam") +gtsamAddTimingGlob("*.cpp" "" "gtsam") target_link_libraries(timeGaussianFactorGraph CppUnitLite) diff --git a/timing/timeFactorOverhead.cpp b/timing/timeFactorOverhead.cpp index 6e5d6b9ad..97c40e6f4 100644 --- a/timing/timeFactorOverhead.cpp +++ b/timing/timeFactorOverhead.cpp @@ -16,30 +16,29 @@ * @date Aug 20, 2010 */ +#include +#include #include #include -#include +#include #include -#include #include using namespace gtsam; using namespace std; -typedef EliminationTree GaussianEliminationTree; - static boost::variate_generator > rg(boost::mt19937(), boost::uniform_real<>(0.0, 1.0)); int main(int argc, char *argv[]) { - Index key = 0; + Key key = 0; size_t vardim = 2; size_t blockdim = 1; - size_t nBlocks = 2000; + size_t nBlocks = 4000; - size_t nTrials = 10; + size_t nTrials = 20; double blockbuild, blocksolve, combbuild, combsolve; @@ -54,8 +53,7 @@ int main(int argc, char *argv[]) { // Build GFG's cout << "Building blockwise Gaussian factor graphs... "; cout.flush(); - boost::timer timer; - timer.restart(); + gttic_(blockbuild); vector blockGfgs; blockGfgs.reserve(nTrials); for(size_t trial=0; trial(key, A, b, noise)); } } - blockbuild = timer.elapsed(); + gttoc_(blockbuild); + tictoc_getNode(blockbuildNode, blockbuild); + blockbuild = blockbuildNode->secs(); cout << blockbuild << " s" << endl; // Solve GFG's cout << "Solving blockwise Gaussian factor graphs... "; cout.flush(); - timer.restart(); + gttic_(blocksolve); for(size_t trial=0; trialeliminate(&EliminateQR)); - VectorValues soln(optimize(*gbn)); + GaussianBayesNet::shared_ptr gbn = blockGfgs[trial].eliminateSequential(); + VectorValues soln = gbn->optimize(); } - blocksolve = timer.elapsed(); + gttoc_(blocksolve); + tictoc_getNode(blocksolveNode, blocksolve); + blocksolve = blocksolveNode->secs(); cout << blocksolve << " s" << endl; } @@ -97,8 +99,7 @@ int main(int argc, char *argv[]) { // Build GFG's cout << "Building combined-factor Gaussian factor graphs... "; cout.flush(); - boost::timer timer; - timer.restart(); + gttic_(combbuild); vector combGfgs; for(size_t trial=0; trial(key, Acomb, bcomb, + noiseModel::Isotropic::Sigma(blockdim*nBlocks, 1.0))); } - combbuild = timer.elapsed(); + gttoc(combbuild); + tictoc_getNode(combbuildNode, combbuild); + combbuild = combbuildNode->secs(); cout << combbuild << " s" << endl; // Solve GFG's cout << "Solving combined-factor Gaussian factor graphs... "; cout.flush(); - timer.restart(); + gttic_(combsolve); for(size_t trial=0; trialeliminate(&EliminateQR)); - VectorValues soln(optimize(*gbn)); + GaussianBayesNet::shared_ptr gbn = combGfgs[trial].eliminateSequential(); + VectorValues soln = gbn->optimize(); } - combsolve = timer.elapsed(); + gttoc_(combsolve); + tictoc_getNode(combsolveNode, combsolve); + combsolve = combsolveNode->secs(); cout << combsolve << " s" << endl; } diff --git a/timing/timeSLAMlike.cpp b/timing/timeSLAMlike.cpp deleted file mode 100644 index 479c03940..000000000 --- a/timing/timeSLAMlike.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/* ---------------------------------------------------------------------------- - - * GTSAM Copyright 2010, Georgia Tech Research Corporation, - * Atlanta, Georgia 30332-0415 - * All Rights Reserved - * Authors: Frank Dellaert, et al. (see THANKS for the full author list) - - * See LICENSE for the license information - - * -------------------------------------------------------------------------- */ - -/** - * @file timeSLAMlike.cpp - * @brief Times solving of random SLAM-like graphs - * @author Richard Roberts - * @date Aug 30, 2010 - */ - -#include -#include - -#include -#include -#include -#include -#include - -using namespace gtsam; -using namespace std; -using namespace boost::lambda; - -typedef EliminationTree GaussianEliminationTree; - -static boost::variate_generator > rg(boost::mt19937(), boost::uniform_real<>(0.0, 1.0)); - -bool _pair_compare(const pair& a1, const pair& a2) { return a1.first < a2.first; } - -int main(int argc, char *argv[]) { - - size_t vardim = 3; - size_t blockdim = 3; - int nVars = 500; - size_t blocksPerVar = 5; - size_t varsPerBlock = 2; - size_t varSpread = 10; - - size_t nTrials = 10; - - double blockbuild, blocksolve; - - cout << "\n" << nVars << " variables of dimension " << vardim << ", " << - blocksPerVar << " blocks for each variable, blocks of dimension " << blockdim << " measure " << varsPerBlock << " variables\n"; - cout << nTrials << " trials\n"; - - boost::variate_generator > ri(boost::mt19937(), boost::uniform_int<>(-varSpread, varSpread)); - - ///////////////////////////////////////////////////////////////////////////// - // Timing test with blockwise Gaussian factor graphs - - { - // Build GFG's - cout << "Building SLAM-like Gaussian factor graphs... "; - cout.flush(); - boost::timer timer; - timer.restart(); - vector blockGfgs; - blockGfgs.reserve(nTrials); - for(size_t trial=0; trial > terms; terms.reserve(varsPerBlock); - if(c == 0 && d == 0) - // If it's the first factor, just make a prior - terms.push_back(make_pair(0, eye(vardim))); - else if(c != 0) { - // Generate a random Gaussian factor - for(size_t h=0; h nVars-1 || find_if(terms.begin(), terms.end(), - boost::bind(&pair::first, boost::lambda::_1) == Index(var)) != terms.end()); - Matrix A(blockdim, vardim); - for(size_t j=0; j