rust-lang / rust-lang/portable-simd

"Free" dynamic dispatch for core SIMD?

Open
#178 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-feature-request
Dominant language
Rust
Stars
1.1k
Forks
108
Avg merge
22h 53m
Merged PRs (30d)
3

Description

Hi! I'm very excited by the work on portable/core simd. Thank you for all of your work :)

I was looking over the API, and I was thinking it should be possible to get "free" runtime dispatch with a proc macro on top of portable SIMD, which would make portability really easy!

I'm thinking something like (more of a sketch than concrete proposal):

#[runtime_dispatch(sse,avx,avx2)]
fn some_simd_fn(...) {
    // uses portable simd API
}

This would generate code much like the example in the core::arch docs here: https://doc.rust-lang.org/core/arch/index.html#dynamic-cpu-feature-detection, where it would generate versions of the function for each target_feature, then make the actual main function dynamically dispatch to each implementation.

Anyway, I thought I'd open this and get your thoughts.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the portable/core SIMD API and the dynamic CPU feature detection example in the core::arch documentation. The issue is a sketch seeking feedback rather than a defined implementation task; done would require an agreed design and scope for runtime dispatch.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.