arbor-sim / arbor

The Arbor multi-compartment neural network simulation library.
https://arbor-sim.org
BSD 3-Clause "New" or "Revised" License
108 stars 61 forks source link

Arbor SIMD Library Refactoring #1772

Open anstaf opened 2 years ago

anstaf commented 2 years ago

Motivation

Eventually factor out Arbor SIMD into a separate project and make it useful for the users outside of Arbor.

Current state

Arbor SIMD provides an API that is a variation of std::experimental::simd API. It is neither subset or superset of experimental.

Distinctive features of Arbor SIMD:

Observations

Proposal

Let us split Arbor SIMD into two libraries:

bcumming commented 2 years ago

Thanks for the proposal @antonf.

I feel that refactoring to use std::experimental::simd is impractical while not part of the standard.

As a rule in Arbor, we have implemented future standard library features internally, and used them when they can be replaced by mature implementations in our minimum compiler versions. Given this, I think it is too early to refactor the SIMD library to be based around std::experimental.

halfflat commented 2 years ago

I certainly like the idea of splitting out the SVE side; it's really incompatible with the rest of the API.

Regarding std::experimental::simd:

For our implementations of e.g. expm1, exprelr etc. which rely upon decomposition of the mantissa and exponent and such, we could implement a set of architecture-specific low-level operations which are then used within our generic implementations, or stick to writing things in terms of standard decomposition functions and arithmetic. The former would allow us to maintain (mostly) the performance; the latter could well be slower, but might allow us an implementation that is more easily robust (proper support for subnormal numbers, etc.).

jan-wassenberg commented 2 years ago

Hi, just happened across this issue while searching. Have you seen https://github.com/google/highway ? It's a C++ wrapper over intrinsics that supports SVE, RISC-V, AVX-512 and others. Would be happy to discuss if you're interested.

thorstenhater commented 1 year ago

Hi @jan-wassenberg,

thanks for the suggestion. Highway looks pretty interesting, but it's unlikely we'll change our SIMD backend soon without pressing need. (RISC-V might pose such a need in the future) Just out of curiosity, how does highway compare to VC2 (https://github.com/vectorclass/version2)?

Just to note our requirements (mostly in terms of performant operations, since this is the motivator) not only to highway, but any other choice as well

jan-wassenberg commented 1 year ago

Hi @thorstenhater , got it. Yes, RISC-V looks to be gathering momentum.

how does highway compare to VC2

I very much respect Agner's work but he is clear that no instruction sets other than x86 will be supported.

Just to note our requirements

Good to know. We have all of those except pow, and can help add that or other math functions if required. (For pow it really depends how much accuracy you want. A simple version can use log+exp already.)