Disable NEON

Share your projects and Chipmunk enhancements.
Post Reply
barcelonans
Posts: 5
Joined: Thu Oct 25, 2012 8:31 pm
Contact:

Disable NEON

Post by barcelonans »

Is it possible to disable NEON instructions for IOS? I need to compare NEON and non-NEON performance. If anyone has benchmark or demo examples, that would be really great
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Disable NEON

Post by slembcke »

With Objective-Chipmunk, [[ChipmunkSpace alloc] init] will return a ChipmunkHastySpace if the hasty space class is linked in your executable. The NEON solver really has no downsides like the threaded one does. If you want to disable that functionality, you either need to edit the [ChipmunkSpace -init] method or remove ChipmunkHastySpace.m from the library target. Either case is going to require a recompile of Chipmunk Pro. It's also possible to do it with linker flags probably... but that sounds more complicated than it's worth.

Using the regular C API, you have to explicitly create a cpSpace or a cpHastySpace.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
barcelonans
Posts: 5
Joined: Thu Oct 25, 2012 8:31 pm
Contact:

Re: Disable NEON

Post by barcelonans »

Thanks. I have downloaded the ChipmunkPro-Trial6.1.1 4, but cannot see the ChipmunkHastySpace.m. Have I downloaded the wrong thing?
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Disable NEON

Post by slembcke »

Oh. The trial does not come with the source code. The Chipmunk Indie package doesn't have the NEON optimizations, but does have the Objective-Chipmunk binding. You could compare the performance of those two.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
barcelonans
Posts: 5
Joined: Thu Oct 25, 2012 8:31 pm
Contact:

Re: Disable NEON

Post by barcelonans »

I bought the Pro version, and changed the the ChipmunkSpace init to not ever return a hastyspace with:

- (id)init {
// Use a fast space instead if the class is available.
// However if you don't specify -ObjC as a linker flag the dynamic substitution won't work.
Class hastySpace = NSClassFromString(@"ChipmunkHastySpace");
return [self initWithSpace:cpSpaceNew()];
}

I recompiled the whole thing and moved the libChipmunkPro-Iphone.a into the iphone demo project, cleaned and recompiled. Running on an Ipad, I expected to see a deterioration in the smoothness or the demos or something, but regardless of the settings, Time Scale or Time Step or even changing some of the values in the demos such as the tick value in the grabberDemo.m, I don't see any difference in the visual performance between, what I think I have in NEON mode and non-NEON mode. Am I missing something?
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Disable NEON

Post by slembcke »

There is a benchmark target in the Chipmunk Pro project. That's where the numbers on the Chipmunk Pro site came from. The Chipmunk Showcase app on the other hand isn't really meant to be a benchmark, although it is supposed to saturate the CPU as much as possible on most devices. Did you also change the showcase source to use a regular Chipmunk space? It explicitly creates a ChipmunkHastySpace to enable multiple threads. Check ShowcaseDemo.m in the init method.

At least on my iPad 2, there is a *huge* difference in performance on the Pyramid Topple/Pyramid Stack demos if you force NEON/threading off. The framerate drops to the point where the UI become unresponsive and you can barely interact with it.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
barcelonans
Posts: 5
Joined: Thu Oct 25, 2012 8:31 pm
Contact:

Re: Disable NEON

Post by barcelonans »

I didn't change the ShowcaseDemo.m. It looks like the init method has:

_space = [[self.spaceClass alloc] init];

and with _space defined as:

ChipmunkHastySpace *_space;

I tried the collapsing pyramid demo, and it looks about the same in NEON and non-NEON...so obviously I am doing something wrong still. Can you tell me how ShowcaseDemo.m should look....Thanks
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Disable NEON

Post by slembcke »

Replace the first few lines of the init method like so:

Code: Select all

//		_space = [[self.spaceClass alloc] init];
//		// On iOS and OS X, 0 threads will automatically select the number of threads to use.
//		_space.threads = 0;
//		
//		NSLog(@"cpHastySpace solver running on %d threads.", _space.threads);
		
		// Call the private initWithSpace: method and pass it a regular space.
		_space = objc_msgSend([ChipmunkSpace alloc], @selector(initWithSpace:), cpSpaceNew());
On an iPad 2, it's the difference between 12 and 60fps on the Pyramid demos. Not to say that it makes the physics alone 4x faster, but it frees up a lot time for rendering and the user interface code to run.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
barcelonans
Posts: 5
Joined: Thu Oct 25, 2012 8:31 pm
Contact:

Re: Disable NEON

Post by barcelonans »

Thanks for all your help so far. I have made the changes you suggested, and was really hoping for a dramatic visual demonstration of NEON against non-NEON. Both modes appear visually the same even on all of the demos. The performance display I get matches your statistics, 14 FPS on the non-NEON and 60 FPS on the NEON. Any ideas on how I would demonstrate that visually other than the performance numbers.
User avatar
AndyKorth
Site Admin
Posts: 36
Joined: Wed Aug 15, 2007 3:56 pm

Re: Disable NEON

Post by AndyKorth »

14 FPS to 60 FPS should have a pretty good visual effect. It should look pretty choppy at 14 fps compared to 60 fps.

Other than that, the NEON optimizations were designed to run the simulation and give the same results as the slower non-neon code. If the results were different, one of them would be wrong ;)

One thing to consider is that you could add a lot more physics objects because of the NEON optimization, but chipmunk won't randomly add objects to make up for that difference.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests