[ODE] [patch] a little less quickstep work
Adam D. Moss
adam at gimp.org
Thu Jun 23 17:23:04 MST 2005
This patch avoids creating and copying-around the last_lambda
array inside QuickStep if (by default) we don't actually need it.
I'll put this (probably minus the #if0 cruft from another
experiment) on the trunk soon if there are no objections.
--adam
--
Adam D. Moss - adam at gimp.org
-------------- next part --------------
Index: ode/src/quickstep.cpp
===================================================================
--- ode/src/quickstep.cpp (revision 4632)
+++ ode/src/quickstep.cpp (revision 4633)
@@ -326,9 +326,11 @@
dSetZero (lambda,m);
#endif
+#ifdef REORDER_CONSTRAINTS
// the lambda computed at the previous iteration.
// this is used to measure error for when we are reordering the indexes.
dRealAllocaArray (last_lambda,m);
+#endif
// a copy of the 'hi' vector in case findex[] is being used
dRealAllocaArray (hicopy,m);
@@ -416,7 +418,12 @@
order[i].index = i;
}
}
- qsort (order,m,sizeof(IndexError),&compare_index_error);
+ qsort (order,m,sizeof(IndexError),&compare_index_error);
+
+ //@@@ potential optimization: swap lambda and last_lambda pointers rather
+ // than copying the data. we must make sure lambda is properly
+ // returned to the caller
+ memcpy (last_lambda,lambda,m*sizeof(dReal));
#endif
#ifdef RANDOMLY_REORDER_CONSTRAINTS
if ((iteration & 7) == 0) {
@@ -426,14 +433,19 @@
order[i] = order[swapi];
order[swapi] = tmp;
}
+ } else {
+#if 0
+ /* this should help, but mysteriously it hurts a little. */
+ for (i=0; i<m/2; ++i) {
+ IndexError tmp = order[i];
+ int swapi = (m-1)-i;
+ order[i] = order[swapi];
+ order[swapi] = tmp;
+ }
+#endif
}
#endif
- //@@@ potential optimization: swap lambda and last_lambda pointers rather
- // than copying the data. we must make sure lambda is properly
- // returned to the caller
- memcpy (last_lambda,lambda,m*sizeof(dReal));
-
for (int i=0; i<m; i++) {
// @@@ potential optimization: we could pre-sort J and iMJ, thereby
// linearizing access to those arrays. hmmm, this does not seem
More information about the ODE
mailing list