Skip to content

Commit 76d8fe1

Browse files
committed
[constraint] Improve speed in constructing A matrix in LCP
Before: BM_INTEGRATION_boxes Run on (64 X 3700 MHz CPU s) CPU Caches: L1 Data 32 KiB (x32) L1 Instruction 32 KiB (x32) L2 Unified 512 KiB (x32) L3 Unified 16384 KiB (x8) Load Average: 31.98, 20.05, 10.93 ***WARNING*** CPU scaling is enabled, the benchmark real time measurements may be noisy and will incur extra overhead. -------------------------------------------------------- Benchmark Time CPU Iterations -------------------------------------------------------- BM_RunBoxes/2 130 ms 130 ms 5 BM_RunBoxes/5 19524 ms 19523 ms 1 After: BM_INTEGRATION_boxes Run on (64 X 3700 MHz CPU s) CPU Caches: L1 Data 32 KiB (x32) L1 Instruction 32 KiB (x32) L2 Unified 512 KiB (x32) L3 Unified 16384 KiB (x8) Load Average: 39.58, 35.26, 21.57 ***WARNING*** CPU scaling is enabled, the benchmark real time measurements may be noisy and will incur extra overhead. -------------------------------------------------------- Benchmark Time CPU Iterations -------------------------------------------------------- BM_RunBoxes/2 128 ms 128 ms 5 BM_RunBoxes/5 17537 ms 17535 ms 1
1 parent adeb4f7 commit 76d8fe1

File tree

4 files changed

+13
-26
lines changed

4 files changed

+13
-26
lines changed

cmake/DARTMacros.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ function(dart_build_tests)
371371
)
372372

373373
# Link libraries
374-
target_link_libraries(${target_name} PRIVATE gtest gtest_main)
374+
target_link_libraries(${target_name} PRIVATE GTest::gtest GTest::gtest_main)
375375
target_link_libraries(
376376
${target_name} PRIVATE ${_ARG_LINK_LIBRARIES}
377377
)

dart/constraint/BoxedLcpConstraintSolver.cpp

+10-23
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ void BoxedLcpConstraintSolver::solveConstrainedGroup(ConstrainedGroup& group)
203203
if (mFIndex[mOffset[i] + j] >= 0)
204204
mFIndex[mOffset[i] + j] += mOffset[i];
205205

206-
// Apply impulse for mipulse test
206+
// Apply impulse for impulse test
207207
{
208208
DART_PROFILE_SCOPED_N("Unit impulse test");
209209
constraint->applyUnitImpulse(j);
@@ -220,34 +220,21 @@ void BoxedLcpConstraintSolver::solveConstrainedGroup(ConstrainedGroup& group)
220220
mA.data() + index, false);
221221
}
222222
}
223-
224-
// Filling symmetric part of A matrix
225-
{
226-
DART_PROFILE_SCOPED_N("Fill lower triangle of A");
227-
for (std::size_t k = 0; k < i; ++k) {
228-
const int indexI = mOffset[i] + j;
229-
for (std::size_t l = 0;
230-
l < group.getConstraint(k)->getDimension();
231-
++l) {
232-
const int indexJ = mOffset[k] + l;
233-
mA(indexI, indexJ) = mA(indexJ, indexI);
234-
}
235-
}
236-
}
237223
}
238224
}
239225

240-
assert(isSymmetric(
241-
n,
242-
mA.data(),
243-
mOffset[i],
244-
mOffset[i] + constraint->getDimension() - 1));
245-
246226
{
247227
DART_PROFILE_SCOPED_N("Unexcite");
248228
constraint->unexcite();
249229
}
250230
}
231+
232+
{
233+
// Fill lower triangle blocks of A matrix
234+
DART_PROFILE_SCOPED_N("Fill lower triangle of A");
235+
mA.leftCols(n).triangularView<Eigen::Lower>()
236+
= mA.leftCols(n).triangularView<Eigen::Upper>().transpose();
237+
}
251238
}
252239

253240
assert(isSymmetric(n, mA.data()));
@@ -258,7 +245,7 @@ void BoxedLcpConstraintSolver::solveConstrainedGroup(ConstrainedGroup& group)
258245
// std::cout << std::endl;
259246

260247
// Solve LCP using the primary solver and fallback to secondary solver when
261-
// the parimary solver failed.
248+
// the primary solver failed.
262249
if (mSecondaryBoxedLcpSolver) {
263250
// Make backups for the secondary LCP solver because the primary solver
264251
// modifies the original terms.
@@ -283,7 +270,7 @@ void BoxedLcpConstraintSolver::solveConstrainedGroup(ConstrainedGroup& group)
283270
earlyTermination);
284271

285272
// Sanity check. LCP solvers should not report success with nan values, but
286-
// it could happen. So we set the sucees to false for nan values.
273+
// it could happen. So we set the success to false for nan values.
287274
if (success && mX.hasNaN())
288275
success = false;
289276

dart/constraint/DantzigLCPSolver.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ void DantzigLCPSolver::solve(ConstrainedGroup* _group)
119119
if (findex[offset[i] + j] >= 0)
120120
findex[offset[i] + j] += offset[i];
121121

122-
// Apply impulse for mipulse test
122+
// Apply impulse for impulse test
123123
constraint->applyUnitImpulse(j);
124124

125125
// Fill upper triangle blocks of A matrix

dart/constraint/PGSLCPSolver.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void PGSLCPSolver::solve(ConstrainedGroup* _group)
114114
if (findex[offset[i] + j] >= 0)
115115
findex[offset[i] + j] += offset[i];
116116

117-
// Apply impulse for mipulse test
117+
// Apply impulse for impulse test
118118
constraint->applyUnitImpulse(j);
119119

120120
// Fill upper triangle blocks of A matrix

0 commit comments

Comments
 (0)