|
aligator 0.16.0
A versatile and efficient C++ library for real-time constrained trajectory optimization.
|
When creating the CMake build, make sure to add the -DCMAKE_EXPORT_COMPILE_COMMANDS=1 flag. See its documentation here.
A template project for using aligator with CMake and C++ can be found in the aligator-cmake-example-project repository.
When aligator is installed, the CMake configuration file (aligatorConfig.cmake) provides a CMake function to help users easily create a Python extension module. Users can write an extension module in C++ for performance reasons when providing e.g. custom constraints, cost functions, dynamics, and so on.
The CMake function is called as follows:
This will create a CMake MODULE target named <name> on which the user can set properties and add an install directive.
An usage example can be found in this repo.
This project builds some C++ examples and tests. Debugging them is fairly straightforward using GDB:
with the appropriate command line arguments. Examples will appear in the binaries of build/examples. Make sure to look at GDB's documentation.
If you want to catch std::exception instances thrown, enter the following command once in GDB:
In order for debug symbols to be loaded and important variables not being optimized out, you will want to compile in DEBUG mode.
Then, you can run the module under gdb using
If you want to look at Eigen types such as vectors and matrices, you should look into the eigengdb plugin for GDB.
[TODO]
The SolverProxDDP solver is able to leverage multicore CPU architectures.
Before calling the solver make sure to enable parallelization as follows:
In Python:
And in C++:
Aligator uses OpenMP for parallelization which is setup using environment variables in your shell. The settings are local to your shell.
Printing OpenMP parameters at launch:
Print when a thread is launched and with which affinity (CPU thread(s) on where it will try to run):
OpenMP operates with places which define a CPU thread or core reserved for a thread. Places can be a CPU thread or an entire CPU core (which can have one thread, or multiple with hyperthreading).
or
Threads will run on the first nth CPU cores, with one thread per core, even if the core has multiple threads
For more info on places see here.
Some modern CPUs have a mix of performance (P) and efficiency (E) cores. The E-cores are often slower, hence we should have OpenMP schedule threads on P-cores only.
Get your CPU model with
Get CPU core info with:
A little digging on the internet tells us that this CPU has 6 performance cores and 8 efficiency cores for a total of 20 threads. We see higher frequencies in core 0 to 5: these are the performance cores. To use only performance cores on this CPU you would set:
We use google benchmark to define C++ benchmarks which are able to aggregate data from runs, and Flame Graphs to produce a breakdown of the various function calls and their importance as a proportion of the call stack.
If you have the Rust toolchain and cargo installed, we suggest you install cargo-flamegraph. Then, you can create a flame graph with the following command:
Here's Crocoddyl's flame graph:
Here's for aligator::SolverFDDP: