Remove fine-grained timing from narrow-phase collision functions, delete mjTIMER_COL_MID.

PiperOrigin-RevId: 599225419
Change-Id: Ieca166753c20a0abf660e2821b2844dda8758951
This commit is contained in:
Yuval Tassa
2024-01-17 10:53:19 -08:00
committed by Copybara-Service
parent edc254b213
commit 2feefbc5d2
9 changed files with 17 additions and 44 deletions
+8 -5
View File
@@ -9,17 +9,20 @@ General
^^^^^^^
1. Improved the :ref:discardvisual<compiler-discardvisual> compiler flag, which now discards all visual-only assets. See
:ref:discardvisual<compiler-discardvisual> for details.
2. Removed the :ref:`timer<mjtTimer>` for midphase colllision detection, it is now folded in with the narrowphase
timer. This is because timing the two phases seperately required fine-grained timers inside the collision
functions; these functions are so small and fast that the timer itself was incurring a measurable cost.
MJX
^^^
2. Added :ref:`dyntype<actuator-general-dyntype>` ``filterexact``.
3. Added :at:`site` transmission.
4. Updated MJX colab tutorial with more stable quadruped environment.
5. Added ``mjx.ray`` which mirrors :ref:`mj_ray` for planes, spheres, capsules, boxes, and meshes.
3. Added :ref:`dyntype<actuator-general-dyntype>` ``filterexact``.
4. Added :at:`site` transmission.
5. Updated MJX colab tutorial with more stable quadruped environment.
6. Added ``mjx.ray`` which mirrors :ref:`mj_ray` for planes, spheres, capsules, boxes, and meshes.
Bug fixes
^^^^^^^^^
6. Fixed a bug that prevented the use of pins with plugins if flexes are not in the worldbody. Fixes
7. Fixed a bug that prevented the use of pins with plugins if flexes are not in the worldbody. Fixes
:github:issue:`1270`.
7. Fixed a bug in the :ref:`muscle model<CMuscle>` that led to non-zero values outside the lower
bound of the length range. Fixes :github:issue:`1342`.
-1
View File
@@ -75,7 +75,6 @@ typedef enum mjtTimer_ { // internal timers
// breakdown of mj_collision
mjTIMER_COL_BROAD, // broadphase
mjTIMER_COL_MID, // midphase
mjTIMER_COL_NARROW, // narrowphase
mjNTIMER // number of timers
-1
View File
@@ -87,7 +87,6 @@ typedef enum mjtTimer_ { // internal timers
// breakdown of mj_collision
mjTIMER_COL_BROAD, // broadphase
mjTIMER_COL_MID, // midphase
mjTIMER_COL_NARROW, // narrowphase
mjNTIMER // number of timers
+2 -3
View File
@@ -458,9 +458,8 @@ ENUMS: Mapping[str, EnumDecl] = dict([
('mjTIMER_POS_MAKE', 11),
('mjTIMER_POS_PROJECT', 12),
('mjTIMER_COL_BROAD', 13),
('mjTIMER_COL_MID', 14),
('mjTIMER_COL_NARROW', 15),
('mjNTIMER', 16),
('mjTIMER_COL_NARROW', 14),
('mjNTIMER', 15),
]),
)),
('mjtCatBit',
+1 -1
View File
@@ -4154,7 +4154,7 @@ STRUCTS: Mapping[str, StructDecl] = dict([
name='timer',
type=ArrayType(
inner_type=ValueType(name='mjTimerStat'),
extents=(16,),
extents=(15,),
),
doc='timer statistics',
),
+1 -1
View File
@@ -278,7 +278,7 @@ int main(int argc, char** argv) {
// components of mjTIMER_POS_COLLISION
if (i == mjTIMER_POS_COLLISION) {
for (int j : {mjTIMER_COL_BROAD, mjTIMER_COL_MID, mjTIMER_COL_NARROW}) {
for (int j : {mjTIMER_COL_BROAD, mjTIMER_COL_NARROW}) {
int number = d[0]->timer[j].number;
mjtNum jstep = number ? d[0]->timer[j].duration/number : 0.0;
mjtNum percent = number ? 100*jstep/tstep : 0.0;
+3 -27
View File
@@ -291,12 +291,9 @@ void mj_collision(const mjModel* m, mjData* d) {
unsigned int last_signature = -1;
TM_END(mjTIMER_COL_BROAD);
// midphase collision detector
// narrowphase and midphase collision detector
TM_RESTART;
// save current narrowphase duration
mjtNum tmNarrow = d->timer[mjTIMER_COL_NARROW].duration;
// process bodyflex pairs returned by broadphase, merge with predefined geom pairs
int pairadr = 0;
for (int i=0; i < nbfpair; i++) {
@@ -471,14 +468,8 @@ void mj_collision(const mjModel* m, mjData* d) {
}
}
// end midphase timer
TM_END(mjTIMER_COL_MID);
// subtract nested narrowphase timing from midphase timer
d->timer[mjTIMER_COL_MID].duration -= (d->timer[mjTIMER_COL_NARROW].duration - tmNarrow);
// increment narrowphase counter
d->timer[mjTIMER_COL_NARROW].number++;
// end narrowphase and midphase timer
TM_END(mjTIMER_COL_NARROW);
mj_freeStack(d);
TM_END1(mjTIMER_POS_COLLISION);
@@ -1444,8 +1435,6 @@ static void mj_makeCapsule(const mjModel* m, mjData* d, int f, const int vid[2],
// test two geoms for collision, apply filters, add to contact list
void mj_collideGeoms(const mjModel* m, mjData* d, int g1, int g2) {
TM_START;
int num, type1, type2, condim;
mjtNum margin, gap, friction[5], solref[mjNREF], solimp[mjNIMP];
mjtNum solreffriction[mjNREF] = {0};
@@ -1635,9 +1624,6 @@ void mj_collideGeoms(const mjModel* m, mjData* d, int g1, int g2) {
// move arena pointer back to the end of the contact array
resetArena(d);
// add duration without incrementing counter
TM_ADD(mjTIMER_COL_NARROW);
}
@@ -1850,8 +1836,6 @@ void mj_collideFlexSAP(const mjModel* m, mjData* d, int f) {
// test a geom and an elem for collision, add to contact list
void mj_collideGeomElem(const mjModel* m, mjData* d, int g, int f, int e) {
TM_START;
mjtNum margin = mj_assignMargin(m, mju_max(m->geom_margin[g], m->flex_margin[f]));
int dim = m->flex_dim[f], type = m->geom_type[g];
int num;
@@ -1965,17 +1949,12 @@ void mj_collideGeomElem(const mjModel* m, mjData* d, int g, int f, int e) {
// move arena pointer back to the end of the contact array
resetArena(d);
// add duration without incrementing counter
TM_ADD(mjTIMER_COL_NARROW);
}
// test two elems for collision, add to contact list
void mj_collideElems(const mjModel* m, mjData* d, int f1, int e1, int f2, int e2) {
TM_START;
mjtNum margin = mj_assignMargin(m, mju_max(m->flex_margin[f1], m->flex_margin[f2]));
int dim1 = m->flex_dim[f1], dim2 = m->flex_dim[f2];
int num;
@@ -2070,9 +2049,6 @@ void mj_collideElems(const mjModel* m, mjData* d, int f1, int e1, int f2, int e2
// move arena pointer back to the end of the contact array
resetArena(d);
// add duration without incrementing counter
TM_ADD(mjTIMER_COL_NARROW);
}
-1
View File
@@ -89,7 +89,6 @@ const char* mjTIMERSTRING[mjNTIMER]= {
"pos_make",
"pos_project",
"col_broadphase",
"col_midphase",
"col_narrowphase"
};
+2 -4
View File
@@ -138,9 +138,8 @@ public enum mjtTimer : int{
mjTIMER_POS_MAKE = 11,
mjTIMER_POS_PROJECT = 12,
mjTIMER_COL_BROAD = 13,
mjTIMER_COL_MID = 14,
mjTIMER_COL_NARROW = 15,
mjNTIMER = 16,
mjTIMER_COL_NARROW = 14,
mjNTIMER = 15,
}
public enum mjtDisableBit : int{
mjDSBL_CONSTRAINT = 1,
@@ -769,7 +768,6 @@ public unsafe struct mjData_ {
public mjTimerStat_ timer12;
public mjTimerStat_ timer13;
public mjTimerStat_ timer14;
public mjTimerStat_ timer15;
public mjSolverStat_ solver0;
public mjSolverStat_ solver1;
public mjSolverStat_ solver2;