Division on Zero

Discuss any Chipmunk bugs here.

Re: Division on Zero

Postby ShiftZ » Wed Feb 15, 2012 2:15 am

Would you fixed it?
ShiftZ
 
Posts: 114
Joined: Sat Mar 07, 2009 7:23 am

Re: Division on Zero

Postby slembcke » Wed Feb 15, 2012 10:25 am

I could, but why? Are you not running somewhere that offers IEEE floating point compatibility? Chipmunk already uses infinities extensively, I don't understand why this instance is an issue. It works fine on pretty much every reasonable platform I've tested it on from PPC to ARM to x86.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4089
Joined: Tue Aug 14, 2007 7:13 pm

Re: Division on Zero

Postby ShiftZ » Wed Feb 15, 2012 10:50 am

I could, but why?


We had discussid it already in this thread. Division by zero is not intended to perform in a real time simulations. It stalls CPU so terrible, even single division by zero per frame results in noticeable freezes. Other then that, it's ok.
This thread would not exist if there was no reason to avoid div by zero.

http://infocenter.arm.com/help/index.js ... a4061.html

Just read first three rows.
Probably you could read this thead from start to remind things.
ShiftZ
 
Posts: 114
Joined: Sat Mar 07, 2009 7:23 am

Re: Division on Zero

Postby slembcke » Wed Feb 15, 2012 11:52 am

The article you linked is specifically talking about ARM's software floating point library. What platform are you running on where you need to use that? At least for the mainline Chipmunk branch I'd like to keep the algorithm I have as it's faster (at least on x86 and ARMs with hardware FPUs) and shorter than the previous and more branchy algorithm I had.

Going back in the thread I see you are talking about the iPhone specifically, but they all have hardware FPUs as do almost all Android devices now (certainly the ones good enough to run many games on). On both the iPod 4G and iPhone 3G I have on my desk, a divide by zero makes no measurable runtime difference to the following snippet:
Code: Select all
      NSLog(@"starting");
      float x = 5.0;
      float y = 0.0;
      float z = 0.0;
      for(int i=0; i<100000000; i++){
         z = x/y;
      }
      NSLog(@"done");


Even running it with optimizations turned off couldn't be hiding that much of a performance hog. Running it in the profiler, loading x and y, and storing z show up 1000x more heavily than the division instruction, and the loop increment is 2x as expensive (a load hit store presumably?) as the whole z = x/y line.

Image
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4089
Joined: Tue Aug 14, 2007 7:13 pm

Re: Division on Zero

Postby ShiftZ » Thu Feb 16, 2012 12:03 am

Well, if you target specificaly on iPhone platform, perhaps you are right.
ShiftZ
 
Posts: 114
Joined: Sat Mar 07, 2009 7:23 am

Previous

Return to Bugs

Who is online

Users browsing this forum: No registered users and 1 guest

cron