Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pinocchio
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stack Of Tasks
pinocchio
Commits
cd977414
Commit
cd977414
authored
7 years ago
by
jcarpent
Browse files
Options
Downloads
Patches
Plain Diff
[Bench] Add benchmark of Cholesky algo
parent
53669491
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
benchmark/CMakeLists.txt
+4
-0
4 additions, 0 deletions
benchmark/CMakeLists.txt
benchmark/timings-cholesky.cpp
+132
-0
132 additions, 0 deletions
benchmark/timings-cholesky.cpp
with
136 additions
and
0 deletions
benchmark/CMakeLists.txt
+
4
−
0
View file @
cd977414
...
...
@@ -42,6 +42,10 @@ ENDMACRO(ADD_TEST_CFLAGS)
#
ADD_BENCH
(
timings TRUE
)
# timings
#
ADD_BENCH
(
timings-cholesky TRUE
)
# timings derivatives
#
ADD_BENCH
(
timings-derivatives TRUE
)
...
...
This diff is collapsed.
Click to expand it.
benchmark/timings-cholesky.cpp
0 → 100644
+
132
−
0
View file @
cd977414
//
// Copyright (c) 2018 CNRS
//
// This file is part of Pinocchio
// Pinocchio is free software: you can redistribute it
// and/or modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation, either version
// 3 of the License, or (at your option) any later version.
//
// Pinocchio is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Lesser Public License for more details. You should have
// received a copy of the GNU Lesser General Public License along with
// Pinocchio If not, see
// <http://www.gnu.org/licenses/>.
#include
"pinocchio/spatial/fwd.hpp"
#include
"pinocchio/spatial/se3.hpp"
#include
"pinocchio/multibody/visitor.hpp"
#include
"pinocchio/multibody/model.hpp"
#include
"pinocchio/algorithm/crba.hpp"
#include
"pinocchio/algorithm/cholesky.hpp"
#include
"pinocchio/parsers/urdf.hpp"
#include
"pinocchio/parsers/sample-models.hpp"
#include
<iostream>
#include
"pinocchio/tools/timer.hpp"
#include
<Eigen/StdVector>
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION
(
Eigen
::
VectorXd
)
int
main
(
int
argc
,
const
char
**
argv
)
{
using
namespace
Eigen
;
using
namespace
se3
;
StackTicToc
timer
(
StackTicToc
::
US
);
#ifdef NDEBUG
const
int
NBT
=
1000
*
100
;
#else
const
int
NBT
=
1
;
std
::
cout
<<
"(the time score in debug mode is not relevant) "
<<
std
::
endl
;
#endif
se3
::
Model
model
;
std
::
string
filename
=
PINOCCHIO_SOURCE_DIR
"/models/simple_humanoid.urdf"
;
if
(
argc
>
1
)
filename
=
argv
[
1
];
if
(
filename
==
"HS"
)
se3
::
buildModels
::
humanoidSimple
(
model
,
true
);
else
if
(
filename
==
"H2"
)
se3
::
buildModels
::
humanoid2d
(
model
);
else
se3
::
urdf
::
buildModel
(
filename
,
JointModelFreeFlyer
(),
model
);
std
::
cout
<<
"nq = "
<<
model
.
nq
<<
std
::
endl
;
se3
::
Data
data
(
model
);
VectorXd
q
=
VectorXd
::
Random
(
model
.
nq
);
VectorXd
qdot
=
VectorXd
::
Random
(
model
.
nv
);
VectorXd
qddot
=
VectorXd
::
Random
(
model
.
nv
);
MatrixXd
A
(
model
.
nv
,
model
.
nv
),
B
(
model
.
nv
,
model
.
nv
);
A
.
setZero
();
B
.
setRandom
();
std
::
vector
<
VectorXd
>
qs
(
NBT
);
std
::
vector
<
VectorXd
>
lhs
(
NBT
);
std
::
vector
<
VectorXd
>
rhs
(
NBT
);
for
(
size_t
i
=
0
;
i
<
NBT
;
++
i
)
{
qs
[
i
]
=
Eigen
::
VectorXd
::
Random
(
model
.
nq
);
lhs
[
i
]
=
Eigen
::
VectorXd
::
Zero
(
model
.
nv
);
rhs
[
i
]
=
Eigen
::
VectorXd
::
Random
(
model
.
nv
);
}
double
total
=
0
;
SMOOTH
(
NBT
)
{
crba
(
model
,
data
,
qs
[
_smooth
]);
timer
.
tic
();
cholesky
::
decompose
(
model
,
data
);
total
+=
timer
.
toc
(
timer
.
DEFAULT_UNIT
);
}
std
::
cout
<<
"Cholesky =
\t
"
<<
(
total
/
NBT
)
<<
" "
<<
timer
.
unitName
(
timer
.
DEFAULT_UNIT
)
<<
std
::
endl
;
timer
.
tic
();
SMOOTH
(
NBT
)
{
cholesky
::
solve
(
model
,
data
,
rhs
[
_smooth
]);
}
std
::
cout
<<
"Cholesky solve vector =
\t\t
"
;
timer
.
toc
(
std
::
cout
,
NBT
);
timer
.
tic
();
SMOOTH
(
NBT
)
{
cholesky
::
Mv
(
model
,
data
,
rhs
[
_smooth
],
true
);
}
std
::
cout
<<
"UDUtv =
\t\t
"
;
timer
.
toc
(
std
::
cout
,
NBT
);
MatrixXd
Minv
(
model
.
nv
,
model
.
nv
);
Minv
.
setZero
();
timer
.
tic
();
SMOOTH
(
NBT
)
{
cholesky
::
computeMinv
(
model
,
data
,
Minv
);
}
std
::
cout
<<
"Minv from cholesky =
\t\t
"
;
timer
.
toc
(
std
::
cout
,
NBT
);
timer
.
tic
();
SMOOTH
(
NBT
)
{
cholesky
::
solve
(
model
,
data
,
Minv
.
col
(
10
));
}
std
::
cout
<<
"Cholesky solve column =
\t\t
"
;
timer
.
toc
(
std
::
cout
,
NBT
);
timer
.
tic
();
SMOOTH
(
NBT
)
{
lhs
[
_smooth
].
noalias
()
=
Minv
*
rhs
[
_smooth
];
}
std
::
cout
<<
"Minv*v =
\t\t
"
;
timer
.
toc
(
std
::
cout
,
NBT
);
timer
.
tic
();
SMOOTH
(
NBT
)
{
A
.
noalias
()
=
Minv
*
B
;
}
std
::
cout
<<
"A = Minv*B =
\t\t
"
;
timer
.
toc
(
std
::
cout
,
NBT
);
return
0
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment