Further optimization ideas (for faster calculation)
myungjoo opened this issue · comments
This is to throw some ideas after the immenent release.
- add -ffast-math compiler option
- try SIMD-STL.
- It appears that we can enable SIMD (especially AVX/SSE) for many STL (std::*) functions. Then you can enjoy SIMD without actually writing SIMD codes or having design issues.
- Related link: https://mattkretz.github.io/2019/05/27/vectorized-conversion-from-utf8-using-stdx-simd.html
- Related link: https://stackoverflow.com/questions/59373900/why-is-there-no-simd-functionality-in-the-c-standard-library
- Writing SIMD code in C++ STD (not so sure about its portability)
- https://en.cppreference.com/w/cpp/experimental/simd/simd and https://en.cppreference.com/w/cpp/experimental/simd This looks a bit like "numpy".
- https://github.com/VcDevel/std-simd
- Not sure how efficient it is, but this results in AVX instructions:
#include <iostream>
#include <experimental/simd>
using intV = std::experimental::fixed_size_simd<int, 8>;
using floatV = std::experimental::fixed_size_simd<float, 11>;
int main()
{
int ia[] = {3, 1, -14, 1, 5, 9, -14, 9};
float fa[] = {0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0};
intV iv {[ia](const auto i) { return ia[i]; }};
floatV fv {[fa](const auto i) { return fa[i]; }};
iv += 100;
fv += 10.0f;
std::cout<<iv[0]<<std::endl;
std::cout<<fv[0]<<std::endl;
}