4 ms·
Exactly. I like C++ because it lets me abstract over the absolute fastest C-like code. For example, to produce generic SIMD-accelerated code over both Intel-sp
by stochastic_monk 9y ago
Exactly. I like C++ because it lets me abstract over the absolute fastest C-like code.
For example, to produce generic SIMD-accelerated code over both Intel-specific SIMD operations and the Sleef vector math library I needed for FHT-based JL-transforms and kernel projections, I used template specialization to abstract to operations on physical memory. [0]
The generic methods themselves were gross, but in application, it was extremely simple in downstream code to specify an operation and a container and have the compiler pick the fastest method for the job. I’ve also checked my generated assembly and the smaller functions are always inlined, even though they’re called from static constexpr function pointers.
This is also a great use case for macros, as they saved me huge amounts of typing.
I’m sure many will say C++ is the wrong direction to go for metaprogramming, but it’s worked great for my purposes and lets me get straight to the hardware.
[0]: https://github.com/dnbaker/frp/blob/master/include/frp/vec.h https://github.com/dnbaker/frp/blob/master/include/frp/vec.h
- stochastic_monk 9y agoAs a heads-up, in case anyone checks, I’ve moved this to its own repository so I can use it in other projects easily: https://github.com/dnbaker/vec https://github.com/dnbaker/vec.