Skip to content

Commit

Permalink
Use small_vector for VariableMatrix and Eigen::Triplet storage
Browse files Browse the repository at this point in the history
The small_vector implementation had to be replaced because ubsan caught
a bug. The current implementation was chosen over LLVM's SmallVector
because the latter threw maybe-uninitialized warnings in GCC 14.
  • Loading branch information
calcmogul committed Jun 16, 2024
1 parent e69fe49 commit 1d55add
Show file tree
Hide file tree
Showing 23 changed files with 4,458 additions and 215 deletions.
21 changes: 21 additions & 0 deletions LICENSE_small_vector.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Gene Harvey

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
10 changes: 5 additions & 5 deletions cart-pole-scalability-results-casadi.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Samples,Setup time (ms),Solve time (ms)
100,37.635,1860.9
150,61.511,3595.4
200,91.675,5057.65
250,128.267,7215.88
300,173.451,9321.7
100,36.86,1792.04
150,63.287,3599.32
200,93.634,4801.62
250,127.506,7008.37
300,170.969,9147.5
10 changes: 5 additions & 5 deletions cart-pole-scalability-results-sleipnir.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Samples,Setup time (ms),Solve time (ms)
100,2.227,378.752
150,1.34,1178.74
200,2.258,1990.53
250,2.766,2680.43
300,4.186,4327.73
100,1.714,435.634
150,1.122,1365.72
200,1.75,2182.76
250,2.337,2956.12
300,3.271,4988.65
Binary file modified cart-pole-scalability-results.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 14 additions & 14 deletions flywheel-scalability-results-casadi.csv
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Samples,Setup time (ms),Solve time (ms)
100,2.98,22.156
200,4.397,34.378
300,5.326,49.44
400,7.157,68.722
500,8.909,86.703
600,10.581,109.032
700,12.057,124.431
800,14.162,144.367
900,17.331,157.566
1000,19.646,182.46
2000,36.951,447.552
3000,55.494,810.256
4000,73.318,1250.63
5000,90.088,1838
100,3.205,22.398
200,3.696,34.257
300,5.336,50.792
400,7.305,68.759
500,8.825,89.552
600,11.271,109.922
700,12.308,144.673
800,14.499,142.165
900,16.002,166.643
1000,18.51,190.453
2000,40.209,480.517
3000,56.424,858.896
4000,74.706,1329.33
5000,92.89,1848.54
28 changes: 14 additions & 14 deletions flywheel-scalability-results-sleipnir.csv
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Samples,Setup time (ms),Solve time (ms)
100,0.261,1.763
200,0.141,3.392
300,0.23,4.992
400,0.314,7.711
500,0.419,11.769
600,0.489,12.423
700,0.588,14.202
800,0.666,14.475
900,0.804,18.397
1000,0.879,21.635
2000,3.426,52.533
3000,3.411,96.243
4000,7.933,148.911
5000,8.694,231.574
100,0.554,2.093
200,0.102,4.161
300,0.15,6.025
400,0.225,8.271
500,0.283,10.202
600,0.448,17.682
700,0.389,19.24
800,0.649,24.48
900,0.523,23.748
1000,0.596,28.405
2000,1.507,60.769
3000,4.308,121.029
4000,3.376,197.242
5000,4.427,312.582
Binary file modified flywheel-scalability-results.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions include/.styleguide
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ cppSrcFileInclude {
\.cpp$
}

licenseUpdateExclude {
include/sleipnir/util/small_vector\.hpp$
}

includeOtherLibs {
^Eigen/
}
2 changes: 1 addition & 1 deletion include/sleipnir/autodiff/Expression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
#include "sleipnir/autodiff/ExpressionType.hpp"
#include "sleipnir/util/IntrusiveSharedPtr.hpp"
#include "sleipnir/util/Pool.hpp"
#include "sleipnir/util/SmallVector.hpp"
#include "sleipnir/util/SymbolExports.hpp"
#include "sleipnir/util/small_vector.hpp"

namespace sleipnir::detail {

Expand Down
2 changes: 1 addition & 1 deletion include/sleipnir/autodiff/ExpressionGraph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

#include "sleipnir/autodiff/Expression.hpp"
#include "sleipnir/util/FunctionRef.hpp"
#include "sleipnir/util/SmallVector.hpp"
#include "sleipnir/util/SymbolExports.hpp"
#include "sleipnir/util/small_vector.hpp"

namespace sleipnir::detail {

Expand Down
2 changes: 1 addition & 1 deletion include/sleipnir/autodiff/Hessian.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include "sleipnir/autodiff/Profiler.hpp"
#include "sleipnir/autodiff/Variable.hpp"
#include "sleipnir/autodiff/VariableMatrix.hpp"
#include "sleipnir/util/SmallVector.hpp"
#include "sleipnir/util/SymbolExports.hpp"
#include "sleipnir/util/small_vector.hpp"

namespace sleipnir {

Expand Down
2 changes: 1 addition & 1 deletion include/sleipnir/autodiff/Jacobian.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include "sleipnir/autodiff/Profiler.hpp"
#include "sleipnir/autodiff/Variable.hpp"
#include "sleipnir/autodiff/VariableMatrix.hpp"
#include "sleipnir/util/SmallVector.hpp"
#include "sleipnir/util/SymbolExports.hpp"
#include "sleipnir/util/small_vector.hpp"

namespace sleipnir {

Expand Down
3 changes: 2 additions & 1 deletion include/sleipnir/autodiff/VariableMatrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "sleipnir/util/Assert.hpp"
#include "sleipnir/util/FunctionRef.hpp"
#include "sleipnir/util/SymbolExports.hpp"
#include "sleipnir/util/small_vector.hpp"

namespace sleipnir {

Expand Down Expand Up @@ -883,7 +884,7 @@ class SLEIPNIR_DLLEXPORT VariableMatrix {
}

private:
std::vector<Variable> m_storage;
small_vector<Variable> m_storage;
int m_rows = 0;
int m_cols = 0;
};
Expand Down
2 changes: 1 addition & 1 deletion include/sleipnir/optimization/Constraints.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include "sleipnir/autodiff/Variable.hpp"
#include "sleipnir/util/Assert.hpp"
#include "sleipnir/util/Concepts.hpp"
#include "sleipnir/util/SmallVector.hpp"
#include "sleipnir/util/SymbolExports.hpp"
#include "sleipnir/util/small_vector.hpp"

namespace sleipnir {

Expand Down
2 changes: 1 addition & 1 deletion include/sleipnir/optimization/Multistart.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "sleipnir/optimization/SolverStatus.hpp"
#include "sleipnir/util/FunctionRef.hpp"
#include "sleipnir/util/SmallVector.hpp"
#include "sleipnir/util/small_vector.hpp"

namespace sleipnir {

Expand Down
2 changes: 1 addition & 1 deletion include/sleipnir/optimization/OptimizationProblem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
#include "sleipnir/optimization/SolverStatus.hpp"
#include "sleipnir/optimization/solver/InteriorPoint.hpp"
#include "sleipnir/util/Print.hpp"
#include "sleipnir/util/SmallVector.hpp"
#include "sleipnir/util/SymbolExports.hpp"
#include "sleipnir/util/small_vector.hpp"

namespace sleipnir {

Expand Down
2 changes: 1 addition & 1 deletion include/sleipnir/util/Pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include <cstddef>
#include <memory>

#include "sleipnir/util/SmallVector.hpp"
#include "sleipnir/util/SymbolExports.hpp"
#include "sleipnir/util/small_vector.hpp"

namespace sleipnir {

Expand Down
163 changes: 0 additions & 163 deletions include/sleipnir/util/SmallVector.hpp

This file was deleted.

2 changes: 1 addition & 1 deletion include/sleipnir/util/Spy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

#include <Eigen/SparseCore>

#include "sleipnir/util/SmallVector.hpp"
#include "sleipnir/util/SymbolExports.hpp"
#include "sleipnir/util/small_vector.hpp"

namespace sleipnir {

Expand Down
Loading

0 comments on commit 1d55add

Please sign in to comment.