Page 1 of 1

SIMD support

Posted: Tue May 06, 2014 9:31 pm
by JmD
After visiting Unity3D for a while I'm back in an all-VIsual Studio development environment again making yet another effort to implement a mechanical/elektrical simulation system. So I am very happy to se BEPU Physics is very alive and well.

I am just wondering whether you devlopers here have been looking into the (still in preview) JIT that supports SIMD? In that case - are there any plans on implementing it in BEPU when it goes final?

link to the JIT+SIMD:
http://blogs.msdn.com/b/dotnet/archive/ ... rried.aspx

Re: SIMD support

Posted: Tue May 06, 2014 10:32 pm
by Norbo
While I lack the environment needed to actually test it for now, I have been following the RyuJIT and .NET Native stuff closely and excitedly.

The SIMD types will be interesting. I definitely want to see what I can do with them, but there is one issue still floating around: old platform support. For example, the Xbox360 probably won't be able to use the new types directly without providing a stand-in version or falling back to existing math. Given how poorly I handled multiple backing math frameworks in the past, there's a decent chance that these old platforms would simply be deprecated (in my official branches) if I moved over to the provided SIMD types. This would likely happen eventually anyway, and it wouldnt stop v1.3.0 and earlier from working just fine.

There will also be a huge amount of work involved in reshuffling logic to expose vectorization opportunities both for RyuJIT and the .NET Native autovectorizing compiler. A bunch of memory bottlenecks will need to get addressed, too, or else the SIMD gains will be unimpressive. It will be a significant undertaking, so I'm not sure when it'll show up. That said, v1.4.0's primary focus is heavy optimization and every ounce of performance saves us money in the long run, so it fits in pretty well.

Re: SIMD support

Posted: Wed May 07, 2014 11:54 am
by JmD
Glad to see you are considering it. Backwards compatibility will, as you say, be an issue. And I guess it will be a while before Win 8 + is such a large platform that RyuJIT is available for the avarage user.

I'm very impressed by you library, especially since serious, managed physics engines are quite uncommon. Have you (or someone else) done any comparisons to other engines, like Bullet/BulletSharp, Jitter etc? I'm thinking of feture sets and perfomance. How do you consider BEPU compared to "giants" like PhysX and Havok?

All in all - no one is happier than me that this engine is available since I'm all into managed code rather than native. Keep up the good work, and thank you for the impressive efforts.

///JmD

Re: SIMD support

Posted: Wed May 07, 2014 5:11 pm
by Norbo
All in all - no one is happier than me that this engine is available since I'm all into managed code rather than native. Keep up the good work, and thank you for the impressive efforts.
Glad it's working for you :)
I'm very impressed by you library, especially since serious, managed physics engines are quite uncommon. Have you (or someone else) done any comparisons to other engines, like Bullet/BulletSharp, Jitter etc? I'm thinking of feture sets and perfomance. How do you consider BEPU compared to "giants" like PhysX and Havok?
I haven't personally done direct benchmarking between engines, since:
1) There's enough known low hanging fruit remaining such that comparisons don't provide much more development guidance.
2) It would be very hard to tune the other engine as well as I could tune BEPUphysics for the benchmark, since I would be ignorant of their best practices.
3) It makes me feel a bit gross!

Just from having played with it at one point, though, I believe Bullet (CPU version) and BEPUphysics aren't very far apart in performance. Plus or minus 50% depending on the simulation, maybe. The error bars are pretty huge since the goal of playing with it wasn't to benchmark anything.

I have to assume PhysX and Havok have a significant lead in performance, but it's hard to say exactly how much. The fact that they have a dedicated team of smart people and man-decades of development effort in their engines would imply they've already eaten up all of the 'easy' opportunities I'm aware of (not that Bullet isn't made by a bunch of smart people, but the conditions are a bit different!). Top it off with native code and an optimizing compiler, and I wouldn't be surprised to hear they were at least twice as fast. But then I see things like this and I get a little confused. I believe it's an older version of PhysX, and I don't know much about the benchmark details, but it's still very surprising to see BEPU providing comparable or better per-thread performance in any test.

Feature wise, BEPUphysics tends to stick to a core rigid body featureset. I haven't been able to justify CPU simulated fluids or soft bodies in terms of effect/performance/development effort. I suspect that feature gap will stay for quite a while since our main project wouldn't benefit much from them.

Re: SIMD support

Posted: Thu Jul 31, 2014 4:08 pm
by sergiusz308
Norbo wrote:(...), there's a decent chance that these old platforms would simply be deprecated (in my official branches) if I moved over to the provided SIMD types(...)
Hi, Norbo, what other than Xbox360 old platforms you have in mind here?

Thanks,
Sergiusz

Re: SIMD support

Posted: Thu Jul 31, 2014 7:35 pm
by Norbo
It depends on how Microsoft chooses to release the types. If they released it in a completely platform agnostic fashion, all platforms could be theoretically be supported. On platforms without ryujit, the ryujit math library would be consumed like regular IL.

I'm guessing there will be some issues which prevent a 100% universal release, though. Xbox360 is a weird case, so I assume it will get ignored. Mobile platforms are another question mark, since there's movement away from JIT in favor of AOT compilation. Universal libraries have received a good bit of attention though, so I think/hope that at least the modern mobile platforms would get covered.