Skip to content

LinearMap with explicit SIMD support? #645

Open

Description

@tower120

I don't know how much this would fit into this crate, but LinearMap could significantly win from SIMD search.
I have implementation of similar container that store keys in wide::simd packs. It works on top of "the usual" Vec, but it would be
not so hard to port it to heapless::Vec.

Alternatively - it is possible to implement SIMD search on existent LinearMap for supported SIMD types... But as far as I
know - only desktop CPUs have zero-to-none penalty for loading from non-aligned memory to register. And looks like you
aim for embedded hardware... So you probably "have" to explicitly use SIMD types as key packs.

I understand that simd types is not stable in Rust, and wide crate supports only desktop hardware... But as a suggested solution for that: we could have simple custom SIMD types/traits which will initially points to wide implementation. Than they could be expanded by community on as-need basis...

Activity

  1. k5602 commented on Apr 21, 2026

    @k5602

    I don't know how much this would fit into this crate, but LinearMap could significantly win from SIMD search. I have implementation of similar container that store keys in wide::simd packs. It works on top of "the usual" Vec, but it would be not so hard to port it to heapless::Vec.

    Alternatively - it is possible to implement SIMD search on existent LinearMap for supported SIMD types... But as far as I know - only desktop CPUs have zero-to-none penalty for loading from non-aligned memory to register. And looks like you aim for embedded hardware... So you probably "have" to explicitly use SIMD types as key packs.

    I understand that simd types is not stable in Rust, and wide crate supports only desktop hardware... But as a suggested solution for that: we could have simple custom SIMD types/traits which will initially points to wide implementation. Than they could be expanded by community on as-need basis...

    i agree i will start a research and design for this,
    i've felt it in my usecase too so i will begin the work.

  2. tower120 commented on Apr 21, 2026

    @tower120
    ContributorAuthor

    @k5602 What you gonna use for SIMD operations abstraction?

  3. k5602 commented on Apr 21, 2026

    @k5602

    @k5602 What you gonna use for SIMD operations abstraction?

    i'm still in researching and trial and error phase but for now what i got
    i design SimdKey with lanes that should match target's natural width and
    implemented by types that support batch equality comparison.
    and for the backing will be between

    1. core::simd is the right thing as longterm option
    2. raw core::arch is the answer for now where SIMD, and the scalar impl as the always-available floor, Verbose but can get handled
    3. wide is desktop-only

    what do you think?

  4. tower120 commented on Apr 23, 2026

    @tower120
    ContributorAuthor

    I don't know - I have working implementation with abstraction over wide and abstraction over Contiguous container (so it can be SmallVec, Vec, ArrayVec, etc). Which is actually rather a SortedLinearMap...
    I need it to work only for desktop and mobile...
    I just thought it could be useful in heapless...

  5. k5602 commented on Apr 25, 2026

    @k5602

    I don't know - I have working implementation with abstraction over wide and abstraction over Contiguous container (so it can be SmallVec, Vec, ArrayVec, etc). Which is actually rather a SortedLinearMap... I need it to work only for desktop and mobile... I just thought it could be useful in heapless...

    good thought but ig the whole idea of this that it can be used in embedded devices, i see core::arch is the solution for now so it can be mobile across all platforms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions