4 ms·
Cute. It's fun to see game programmer code. This is really C with a little C++. Lots of pointer casts, comments like "The user must provide ample buffer spac
by Animats 11y ago
Cute. It's fun to see game programmer code. This is really C with a little C++. Lots of pointer casts, comments like "The user must provide ample buffer space, preferably 256 chars or more." There's a lot of stuff in there to deal with Microsoft Visual C++'s interpretation of the language, which prior to 2010, was kind of off.
Why does "swap" use EASTL/move_help.h? There are things that can go wrong with a move that can't go wrong with a swap. Move is a swap with a constraint that the destination be empty.
(Doing things through swapping has its uses. It preserves single ownership, for example.)
- ixtli 11y ago> Cute. It's fun to see game programmer code. This. I work almost exclusively with game programmers and it can be ... difficult at times. They seem to be largely unaware of the larger computer science community that's existed since the mid sixties, often "discovering" things that were solved by the science years ago.
- pcwalton 11y agoOn the other hand, game programmers are just as frequently the only ones exercising anything close to the full functionality of today's hardware. It's kind of depressing how little use SIMD, multicore, and GPU (compute or otherwise) get outside of games. Games have done a pretty good job keeping up with the ending of Moore's Law for sequential code, but we continue to use our old sequential libraries and leave so much performance on the table in the app world. I do agree that the apps and server world is ahead, in many cases way ahead, in terms of effective development practices and programming languages. But we've lost sight of how to get performance out of the hardware.
- santaclaus 11y ago> game programmers are just as frequently the only ones exercising anything close to the full functionality of today's hardware I know some ML and HPC cats who obsess about hitting peak gigaflops...
- pcwalton 11y agoYeah, I was too broad there, sorry about that. There are definitely a few fields like scientific computing and HFT that are very good at extracting performance out of modern hardware. Still, app and server developers, by and large, have not been able to do this (and I count myself among them!) We use languages with no support for SIMD, we stick to language implementations without optimizing compilers, single-threaded language implementations are very popular, we ignore GPU computing despite the fact that the die space reserved for the GPU is as large or larger than the die space reserved for the CPU cores nowadays, and so on.
- nickpsecurity 11y agoI was re-exploring that issue recently. It wasn't obvious to me which of two strategies I commonly saw are best: extend existing languages with parallel constructs as in Cilk/C, ParaSail/Ada, or Lime/Java; create custom languages + compilers like Cray's Chapel or academic Triolet whose output cleanly integrates with apps in an existing language. My uncertainty comes from the fact that general-purpose languages founded in sequential use might be too hard to max out on arbitrary multi-core & CPU architectures. What's your opinion on which looks to be the best route so far? Cilk http://supertech.lcs.mit.edu/cilk/ http://supertech.lcs.mit.edu/cilk/ ParaSail http://www.embedded.com/design/other/4375616/ParaSail--Less-is-more-with-multicore?page=0 http://www.embedded.com/design/other/4375616/ParaSail--Less-... Lime Compilation http://researcher.watson.ibm.com/researcher/files/us-bacon/Dubach12Compiling.pdf http://researcher.watson.ibm.com/researcher/files/us-bacon/D... Chapel http://chapel.cray.com/overview.html http://chapel.cray.com/overview.html Triolet http://impact.crhc.illinois.edu/shared/Papers/dissertation-rodrigues.pdf http://impact.crhc.illinois.edu/shared/Papers/dissertation-r...
- pcwalton 11y agoAnything and everything. I don't believe there's a one-size-fits-all solution for parallelism.
- danbolt 11y agoThis is a really good counterpoint, and I think it reflects how the client's nature can very much shape the development process. Big-budget video games often have very different feature requirements compared to ofter types of software, not to mention especially strict deadlines, so their attitudes towards shipping products is going to be different.
- pjmlp 11y agoThe problem is that the majority of applications we get hired to develop are either some kind of CRUD or data transformation project.
- sharpneli 11y agoThe constraints and things that matter are different. I've had both experiences like you and also the opposite ones. As an example the constant factor in time usage is surprisingly important in games. Amortized time consumption is not the absolute end all be all. Designing any soft realtime application is subtly different from traditional application. Your frametime budget is 16ms. It's rock solid. You spend 17ms and you're down to 30fps and you could've just spent 33ms. That's actually the reason why garbage collection is big no no in games. One cannot afford even 1ms gc pauses. And in server world that's considered blazingly fast. If a game is for some reason developed using a language with GC it's just skipped by making object pools. And then tediously checking that no allocations and freeing actually happens during a frame.
- santaclaus 11y ago> Move is a swap with a constraint that the destination be empty. Is there actually any constraint here? I thought the only constraint on a moved-from object is that you can't use it in the current state.
- pbsd 11y agoThe standard defines moved from objects (standard library types, at least) to be in a 'valid but unspecified state'. For container types like std::vector, 'valid but unspecified' usually means empty.
- pbsd 11y ago`swap` uses `move` to enable swapping objects that can only be moved but not copied (e.g., std::unique_ptr<T>). Note that this swap implementation is meant to be generic---types may implement their own specific `swap` that performs no copies or moves whatsoever. Example: namespace NS { struct S { friend void swap(S& a, S& b) { // do something interesting here } }; } // later.. template<typename T> void f(T& a, T& b) { using std::swap; swap(a, b); // calls NS::swap(a, b) if T = NS::S }
- yoklov 11y agoLooks like way more than a little C++ to me. I mean, it's a template library!
- TwoBit 11y agoC with a little C++? It's a full C++11 implementation of each of the components it implements, modulo the namespace and allocator change. Perhaps it seems simpler to you because you are used to complicated implementations.