root-project / veccore

C++ Library for Portable SIMD Vectorization

Home Page:https://root-project.github.io/veccore

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using VecCore with runtime-chosen implementations

amyspark opened this issue · comments

Hi,

I'm researching potential replacements for Vc in order to enable support for Arm in our app. However, your docs do not list whether implementations can be runtime dispatched. Is it possible to use VecCore as with Vc's Vc::CurrrentImplementation::current()?

Dear @amyspark,

I'm researching potential replacements for Vc in order to enable support for Arm in our app.

Would that be Krita?

VecCore is just a small abstraction layer on top of Vc, umesimd (no longer developed), and since last version also std::simd. The goal is just to provide a fallback for architectures not supported by Vc, and to be able to replace Vc with some other backend if that makes sense. VecCore does not have in it a mechanism to choose at runtime what to run, although it does allow you to compile multiple versions of your functions using SSE, AVX, etc, into the same binary and choose what to run at runtime via your own means. Take a look at the mandelbrot example, which runs with multiple backends in the same binary.

I think that if you just want to replace Vc, and you can work with std::simd, it's probably better to go with that. If you won't always have that available, and VecCore's API exposes enough of the SIMD features for your needs (and you're ok with it being a bit clunky), then you can write your code using VecCore and then choose between the scalar, Vc, or std::simd backends at compile-time depending on what's available to you. Vc should work on ARM, but I don't think performance is great there. std::simd does work with good performance, though. I've not looked too deep into PowerPC (no access to hardware at the moment), but I believe that's supported as well.

I hope this is enough to answer your question.

Would that be Krita?

Yes, it's Krita. We're looking for a replacement that supports Arm, especially now that Arm silicon is available on desktops. We could use std::simd but that's only available with GCC (we support macOS, hence Clang, and MSVC); moreover, I am told by our lead dev that VcDevel/std-simd#4 (or something to the effect) is a hard requirement.

If gather/scatter support and portability are both required, then I guess the choices are limited. VecCore can help you switch between scalar, Vc, and std::simd without having to change your own code, but I think you will only get gather/scatter support using hardware instructions when using the Vc backend on AMD/Intel architectures, and will have to fallback to a scalar implementation otherwise. If needed, we could add/improve in VecCore implementations of Gather/Scatter that would work on ARM.

@amyspark Can I close this? I see that you chose to move to xsimd. I think that was a good choice, the QuantStack team does good work. Cheers,

Yeah, move has been successful. Let's close this one.