Skip to content

Rework the safe_wrappers feature / downcasting ability #166

@valadaptive

Description

@valadaptive

There's a proof-of-concept safe_wrappers feature that's supposed to let you use your own custom architecture-specific SIMD code if you want to, by obtaining an architecture-specific SIMD token from Level using as_neon, as_avx2, etc.

This isn't the ideal abstraction for a couple reasons:

  1. You need to pass the Level all the way down into every SIMD function you use.
  2. The as_[platform] methods on Level incur a runtime cost. When a SIMD-using function calls some method on the Simd token it's passed, that token's type is statically known, because it's a type parameter. Level, however, is always an enum.

I think #108 starts to move in a different direction, but it creates a lot of autogenerated code, is not fully implemented (WASM is missing), and doesn't actually tie into fearless_simd as implemented. It also seems to have stalled out.

In the meantime, I propose adding as_[platform] methods on the Simd trait itself. The default method implementations would all return None, and individual implementations (Sse4_2, Neon, etc.) could override specific methods to all return Some(self). This means we don't need to pass down the Level, and the new as_[platform] methods would be statically dispatched.

(/cc @DJMcNab; how much does this relate to #108?)

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