ZH version is available. Content is displayed in original English for accuracy.
Advertisement
Advertisement
⚡ Community Insights
Discussion Sentiment
80% Positive
Analyzed from 1288 words in the discussion.
Trending Topics
#code#int#https#used#writing#simd#etc#size#write#speed

Discussion (31 Comments)Read Original on HackerNews
https://web.archive.org/web/20250201145327/https://users.ece...
https://devblogs.microsoft.com/oldnewthing/20060731-15/?p=30...
https://learn.microsoft.com/en-us/archive/blogs/ricom/perfor...
The kicker is, in my case I chose C++ because templates allow me to reuse most of the code in the rendering pipeline _regardless_ of whether I go for AoS or SoA layout. I leverage operator overloading to do vector by matrix multplication which is implemented in both variants. I do have to specify the desired variant during building, but I've profiled and for Intel x86 and AVX in my case SoA is an order of magnitude improvement, so I just use that.
TL;DR; C++ gives you plenty fast by default, but it's not always enough. The difference between 15 and 45 frames per second is the difference between raw and baked (if it was bread).
https://stackoverflow.com/questions/69444641/c17-stdvariant-...
High-performance programming is a big topic. The scope is far too broad for a single blog post, which naturally gives only cursory discussion of C++ and computer architecture. The article isn't bad considering, but I do think it's the wrong format. A blog series, or even a book, would be more fitting.
https://www.agner.org/optimize/
https://www.agner.org/optimize/optimizing_cpp.pdf
What you've written mostly makes sense to someone who already has a solid understanding of SIMD and of C++ (although I can't say I follow all of it), but the target audience is people who don't. For them, each point needs a much lengthier explanation.
A quick restrict example:
copy1 is 52 lines, copy2 is 28 lines, copy3 is 2 lines (just a call to memcpy).This is a good starting point for self teaching. The impact of your TLB, L1, and overall instruction count (with IPC) can further be measured with `./perf stat -d -d -d ./a.out`. If you want a quick rule of thumb, no instructions are fast instructions.
So many complex, esoteric, and difficult to maintain incantations that used to be required for efficient code generation are no longer necessary.
Or take constexpr - it permits to move computations to compile time that are complex and in older versions either had to be done at runtime, or an ugly workaround had to be used (e.g. assigning a mysterious literal pre-computed in another run or by hand).
What C++23 feature allows that?
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p22...
There are so many things that are expressible in C++ now that could not be without writing much more code or using per-compilation tools back then. The ability to run code at compile time that is not run at runtime is huge, #embed lets us make other tools output available without linker scripts or compiler specific tools that.
Also, most of the code from the past still works(from 10 years ago definitely works)