Assert in dgJacobianMemory::InitBodyBuffer

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Assert in dgJacobianMemory::InitBodyBuffer

Postby Bird » Thu Feb 16, 2012 11:40 am

I have a simple scene composed of just boxes. If there's 9 boxes in the scene all is well but if I add a 10th box, then the _ASSERTE at line 235 of dgWorldDynamicUpdate.cpp fails. I noticed that the passed in "bodyCount" variable is 2 times the actual number of the bodies in the scene. Is that what's causing the problem?

I'm using the latset SVN 1584 and the Win32 version of Newton.

-Bird
Bird
 
Posts: 636
Joined: Tue Nov 22, 2011 1:27 am

Re: Assert in dgJacobianMemory::InitBodyBuffer

Postby Julio Jerez » Thu Feb 16, 2012 12:53 pm

yes the count should be twice the actual number of bopies in the scene. It is teh new upper limit of teh body caount not the needed body count.
bascially each time the number of itme in a memory poll grown larger than the actual count, the memory pool is doubled in size.

I has to make some modification to that function while working with the AVX and the parallel solver.
AVX requre a diffrnet memopry aligmnet, and the calculation of teh offest may be off, In teh end I realize than I did not have to make any change at all, but I left teh function splited anyway.
however I has not see that assert in any of my test.

you say that adding 10 boxes should reproduce it?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Assert in dgJacobianMemory::InitBodyBuffer

Postby Julio Jerez » Thu Feb 16, 2012 12:55 pm

teh old funtion was this

Code: Select all
void dgJacobianMemory::Init (dgWorld* const world, dgInt32 rowsCount, dgInt32 bodyCount)
{
   InitJointBuffer (world, rowsCount);
   InitBodyBuffer (world, bodyCount);

/*
   dgInt32 stride = sizeof (dgJacobianMatrixElement);
   if (world->m_solverMatrixMemory.ExpandCapacityIfNeessesary (rowsCount + 4, stride)) {
      m_memory = (dgJacobianMatrixElement*) &world->m_solverMatrixMemory[0];
      memset (m_memory, 0, 4 * sizeof (dgJacobianMatrixElement));
      m_memory[0].m_force = dgFloat32 (1.0f);
      m_memory[1].m_force = dgFloat32 (1.0f);
      m_memory[2].m_force = dgFloat32 (1.0f);
      m_memory[3].m_force = dgFloat32 (1.0f);
      m_memory += 4;
   }


   stride = CalculateIntenalMemorySize();
   if (world->m_internalForcesMemory.ExpandCapacityIfNeessesary (bodyCount, stride)) {
      dgInt32 newCount = ((world->m_internalForcesMemory.GetBytesCapacity() - 16)/ stride) & (-8);
      _ASSERTE (bodyCount <= newCount);
      dgInt8* memory = (dgInt8*) &world->m_internalForcesMemory[0];

      m_internalForces = (dgJacobian*) memory;
      m_internalVeloc = (dgJacobian*) &m_internalForces[newCount];
      m_threadLocks = (dgInt32*) &m_internalVeloc[newCount];
      memset (m_threadLocks, 0, newCount * sizeof (dgInt32));

      _ASSERTE ((dgUnsigned64(m_internalForces) & 0x0f) == 0);
      _ASSERTE ((dgUnsigned64(m_internalVeloc) & 0x0f) == 0);
   }
*/
}


try uncomment the comment out code and commnet pout teh tow first lines, and see if the bug go away please.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Assert in dgJacobianMemory::InitBodyBuffer

Postby Bird » Thu Feb 16, 2012 2:25 pm

try uncomment the comment out code and commnet pout teh tow first lines, and see if the bug go away please.

There's no problems if I comment out the first 2 lines and uncomment the rest of the lines.

you say that adding 10 boxes should reproduce it?

Yes. Up to 10 works ok on my system but 10 or more causes the assert to fail. The geometry I used is just a basic cube mesh.

My platform architecture setting is 2 (NewtonSetPlatformArchitecture (world_, 2)) if that makes a difference.

-Bird
Bird
 
Posts: 636
Joined: Tue Nov 22, 2011 1:27 am

Re: Assert in dgJacobianMemory::InitBodyBuffer

Postby Julio Jerez » Thu Feb 16, 2012 3:05 pm

Bird wrote:There's no problems if I comment out the first 2 lines and uncomment the rest of the lines.


I will simple rever back to the old function, soem tim ether are subtle changes but since that cngae is unnesseary,
because I did not have to change anythingg to handle memory aligment when usin AVX,
there is not reason to figure out what is wrong wit the new functions. we simple remove then.
wokr with the local chnage until the new check in
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests