4 ms·
This is awful. Some reasons, in no particular order - Straight up, this isn't data oriented. You're dealing with one object at a time. - This code is vastly h
by yoklov 11y ago
This is awful. Some reasons, in no particular order
- Straight up, this isn't data oriented. You're dealing with one object at a time.
- This code is vastly harder to understand in its entirety, much less extend, than the data oriented approach. This is template craziness to it's fullest degree, and what it's doing is going to be unfamiliar to the vast majority of programmers. Hell, I've read an article, and have been staring at for 15 minutes now and I'm not fully sure. Admittedly, I'm a bit rusty with my templates, but that's a very bad sign for maintainability.
- Memory access patterns aren't the only reason to do DOD, a big one is being able to easily simd optimize your code. This defeats that.
- If you're not going to simd optimize your code, then storing everything as SoA is often not a great idea (you want to group the things you touch at the same time, so that you have fewer cache misses).
- You can still have encapsulation with data oriented code. It's just encapsulated at a different granularity (you encapsulate access to the data arrays).
- Veedrac 11y agoI think the idea here is just to put names onto traditional SOA. Thus, instead of doing `foo_xs[k] += foo_dxs[k]`, one does `foo.x += foo.dx` and lets it all magically resolve itself. In theory, this should help the compiler automatically vectorize (than AOS), but even if it doesn't it still allows you to use a slightly higher-level interface for loading your values for manual SIMD. Note that at the end, the poster says > Traversal is at the core of DOD, as the paradigm is oriented towards handling large numbers of like objects. In a later entry we will extend this framework to provide for easy object traversal and measure the resulting performance as compared with OOP. I also agree that recursive templates are a pain, but "modern" C++ kind'a expects you to use them anyway. As recursive templates go, this one isn't all that bad to use.
- kllrnohj 11y agoI suspect it's far more likely for "foo_xs[k] += foo_dxs[k]" to be auto-vec'd than for "foo.x += foo.dx" via templates to be auto-vec'd. The first is very straightforward and obvious with a clean auto-vec route, the later is not.
- Veedrac 11y agoI've obviously not benchmarked, but from what I can see all the complexity is in the templates, which only exist at compile-time. From what it looks like to me, it should all dissolve before the optimizer gets to peek at it.
- deleted 11y ago[deleted]
- joaquintides 11y agoHi Veedrac, some results at https://news.ycombinator.com/item?id=10177262 https://news.ycombinator.com/item?id=10177262