Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIMD support #483

Open
kfjahnke opened this issue Jan 19, 2021 · 0 comments
Open

SIMD support #483

kfjahnke opened this issue Jan 19, 2021 · 0 comments

Comments

@kfjahnke
Copy link

Dear group!

Working on my b-spline library vspline, I have used SIMD data types together with vigra. I have investigated several approches to SIMD programming by using/defining several SIMD data types, following the pattern set by M. Kretz' SIMD library Vc, and described in his thesis, using both Vc's own SIMD data types, data types introduced by it's successor std::simd, and a fallback implementation which relies on loop vectorization with the compiler's optimizer, as coded here. I found that I could introduce these SIMD data types into the vigra type system by defining the appropriate traits, which enabled me to do stuff like vectorized vigra::quaternions.

My library depends heavily on SIMD arithmetic for maximum speed, and I found that using the techniques laid out by M. Kretz - and his data types and collateral code in Vc - produce a noticeable performance boost. SIMD programming is - sadly - slow to take off, even though modern processors now contain powerful SIMD units. The majority of SIMD code is probably machine code produced by the compiler's optimizer, and such automatic vectorization of scalar code is oftentimes suboptimal, because good SIMD code has to be restructured and uses a few specific features like masks and gather and scatter operations, which are hard for the optimizer to synthesize from scalar code. M. Kretz' approach is to use specific SIMD data types (which map to SIMD registers in the CPU) and to use intrinsics internally, but to hide the complexity in an easy-to-use portable type. So to help SIMD programming to become more common, my proposition is to add support for such SIMD data types to vigra. My traits code would be a step towards such an integration, but I feel it's a bit rough and ready, so I'd welcome cooperation to make it fit to be contributed to vigra, if that seems like a good idea at all - I'd like to see the matter discussed; it may turn out that SIMD support is best left outside the library.

Kay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant