Skip to content

Add SIMD vectorization to mapreduce_neighbor_unsafe - #165

Draft
efaulhaber wants to merge 3 commits into
mainfrom
ef/simd-mapreduce-neighbor
Draft

Add SIMD vectorization to mapreduce_neighbor_unsafe#165
efaulhaber wants to merge 3 commits into
mainfrom
ef/simd-mapreduce-neighbor

Conversation

@efaulhaber

@efaulhaber efaulhaber commented Aug 3, 2026

Copy link
Copy Markdown
Member

This PR adds a kwarg simd to mapreduce_neighbor_unsafe. Enabling this option adds a loop header that forces the inner loop to SIMD-vectorize.

A simple @simd doesn't trigger proper vectorization for TLSPH in my tests, so (unfortunately) we need this extra loop header. In situations where vectorization is not possible (e.g. when the loop contains branching or bounds checks), we get a warning, which is why this is not enabled by default. I would prefer a silent failure, so mapreduce_neighbor_unsafe always tries to vectorize, with an option to enable the warning for debugging, but this doesn't seem to be possible, as the warnings are coming from deep within Julia.

Note that vectorization doesn't work with bounds checks, so there is no point in adding this kwarg to mapreduce_neighbor.

This kwarg is intentionally undocumented, so we can test it first before we decide on a final public API.

@efaulhaber efaulhaber self-assigned this Aug 3, 2026
@efaulhaber efaulhaber changed the title Add SIMD-vectorization to mapreduce_neighbor_unsafe Add SIMD vectorization to mapreduce_neighbor_unsafe Aug 3, 2026
@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.40%. Comparing base (78be5a6) to head (f8de39d).

Files with missing lines Patch % Lines
src/nhs_precomputed.jl 60.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #165      +/-   ##
==========================================
- Coverage   84.59%   84.40%   -0.20%     
==========================================
  Files          15       15              
  Lines         792      795       +3     
==========================================
+ Hits          670      671       +1     
- Misses        122      124       +2     
Flag Coverage Δ
unit 84.40% <60.00%> (-0.20%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@efaulhaber
efaulhaber force-pushed the ef/simd-mapreduce-neighbor branch from a9afefa to 9fc74ce Compare August 4, 2026 14:04
@efaulhaber
efaulhaber force-pushed the ef/simd-mapreduce-neighbor branch from 1637527 to f8de39d Compare August 12, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant