diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d863aecaf7e0c493a0dcead1fb76dc9ed6efd4b..ea70ff2632401b94d6212a274152387734e85b84 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,7 +37,7 @@ ENDIF() SET(CXX_DISABLE_WERROR True) # Create different building options -OPTION(ENABLE_VECTORIZATION "Enable vectorization and futhers processor-related optimizations" ON) +OPTION(ENABLE_VECTORIZATION "Enable vectorization and futhers processor-related optimizations" OFF) OPTION(BUILD_PYTHON_INTERFACE "Build the python binding" ON) OPTION(BUILD_UNIT_TESTS "Build the unitary tests" ON) OPTION(BUILD_BENCHMARK "Build the benchmark" ON) @@ -58,16 +58,25 @@ ADD_OPTIONAL_DEPENDENCY("quadprog") ADD_OPTIONAL_DEPENDENCY("scipy") -OPTION(BUILD_WITH_MULTITHREADING "Build the library with the OpenMP support (required OpenMP)" ON) +OPTION(BUILD_WITH_MULTITHREADS "Build the library with the OpenMP support (required OpenMP)" OFF) +IF(BUILD_WITH_MULTITHREADS) + SET(BUILD_WITH_NTHREADS "4" CACHE STRING "Number of threads") + string(REGEX MATCH "^[0-9]+$" BUILD_WITH_NTHREADS ${BUILD_WITH_NTHREADS}) + IF(NOT BUILD_WITH_NTHREADS MATCHES "^[0-9]+$") + SET(BUILD_WITH_NTHREADS 4) + MESSAGE("Warning: the number of threads have to be an interger value, set to ${BUILD_WITH_NTHREADS}") + ENDIF() +ENDIF() -#OpenMP -if(BUILD_WITH_MULTITHREADING) +# Add OpenMP +if(BUILD_WITH_MULTITHREADS) find_package(OpenMP) ENDIF() if(OPENMP_FOUND) SET(CMAKE_CXX_FLAGS "-fopenmp") ADD_DEFINITIONS(-DWITH_MULTITHREADING) - LIST(APPEND CFLAGS_DEPENDENCIES "-DWITH_MULTITHREADING") + ADD_DEFINITIONS(-DNTHREADS=${BUILD_WITH_NTHREADS}) + LIST(APPEND CFLAGS_DEPENDENCIES "-DWITH_MULTITHREADING", "DNTHREADS") ENDIF() diff --git a/benchmark/unicycle.cpp b/benchmark/unicycle.cpp index 87bc5c2cb06922d64c5dda81f31e1e54cfb3dd68..5be6f9860700f6c71ce21b72daa7f528b245daff 100644 --- a/benchmark/unicycle.cpp +++ b/benchmark/unicycle.cpp @@ -10,7 +10,7 @@ int main() { bool CALLBACKS = false; unsigned int N = 200; // number of nodes - unsigned int T = 10; // number of trials + unsigned int T = 5e3; // number of trials unsigned int MAXITER = 1; using namespace crocoddyl; diff --git a/src/core/optctrl/shooting.cpp b/src/core/optctrl/shooting.cpp index aaf79b1567b17316d8e20721da6511e2ef2701da..04ef09e48efbd933d2fdda3d1372e04ca541fde3 100644 --- a/src/core/optctrl/shooting.cpp +++ b/src/core/optctrl/shooting.cpp @@ -10,7 +10,7 @@ #include <iostream> #ifdef WITH_MULTITHREADING #include <omp.h> -#define NUM_THREADS 4 +#define NUM_THREADS NTHREADS #endif // WITH_MULTITHREADING namespace crocoddyl {