Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIMD Compilation issues on mac M1 #2

Closed
RagnarGrootKoerkamp opened this issue Jun 29, 2023 · 5 comments
Closed

SIMD Compilation issues on mac M1 #2

RagnarGrootKoerkamp opened this issue Jun 29, 2023 · 5 comments

Comments

@RagnarGrootKoerkamp
Copy link

RagnarGrootKoerkamp commented Jun 29, 2023

See RagnarGrootKoerkamp/astar-pairwise-aligner#17 originally:

error[E0425]: cannot find function `_mm_loadu_si128` in this scope
   --> /Users/finn/.cargo/registry/src/index.crates.io-6f17d22bba15001f/editdistancek-1.0.1/src/lib.rs:108:25
    |
108 |                 let x = _mm_loadu_si128(xs.as_ptr() as _);
    |                         ^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `_mm_loadu_si128` in this scope
   --> /Users/finn/.cargo/registry/src/index.crates.io-6f17d22bba15001f/editdistancek-1.0.1/src/lib.rs:109:25
    |
109 |                 let y = _mm_loadu_si128(ys.as_ptr() as _);
    |                         ^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `_mm_cmpeq_epi8` in this scope
   --> /Users/finn/.cargo/registry/src/index.crates.io-6f17d22bba15001f/editdistancek-1.0.1/src/lib.rs:110:25
    |
110 |                 let r = _mm_cmpeq_epi8(x, y);
    |                         ^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `_mm_movemask_epi8` in this scope
   --> /Users/finn/.cargo/registry/src/index.crates.io-6f17d22bba15001f/editdistancek-1.0.1/src/lib.rs:111:25
    |
111 |                 let r = _mm_movemask_epi8(r);
    |                         ^^^^^^^^^^^^^^^^^ not found in this scope

For more information about this error, try `rustc --explain E0425`.
error: could not compile `editdistancek` (lib) due to 4 previous errors

you should probably put the SIMD behind a feature flag or so, and/or use neon instructiong (see e.g. https://github.com/Daniel-Liu-c0deb0t/block-aligner/blob/main/src/neon.rs)

@nkkarpov
Copy link
Owner

Currently, I have simply wrapped the function definition to prevent any compilation errors on M1/M2 architectures. I plan to add support for aarch64 at a later stage.

@RagnarGrootKoerkamp
Copy link
Author

ok, fine for me -- I don't actually depend on this anyway. Side note: I will probably make a small benchmark of extend (what you call mismatch) functions somewhere in the pairwise-alignment org, comparing:

  • compare per char/u8
  • compare per u64
  • compare per 128-bit SIMD
  • compare per 256-bit SIMD
    I also think there might be value in first checking if the first char matches, and only doing more complicated things if that's the case. Especially in WFA/diagonal transition, most calls are on random sequences, and 75% of time you can stop on first char mismatch already.

@RagnarGrootKoerkamp
Copy link
Author

Oh, can you make a PR to rust-bio to update the dependency?

@nkkarpov
Copy link
Owner

The rust-bio should use the corrected version by default. Yes, it would be nice if you could do some benchmarks that on real-data sequences. Please, share with me your findings.
first char matches: yes, it sounds reasonable.

@RagnarGrootKoerkamp
Copy link
Author

thanks for fixing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants