Skip to content

Removed avx512_calls.c by replacing LUTs with intrinsics / shifts - #357

Merged
manodeep merged 6 commits into
masterfrom
remove_avx512_calls_c
Aug 16, 2026
Merged

Removed avx512_calls.c by replacing LUTs with intrinsics / shifts#357
manodeep merged 6 commits into
masterfrom
remove_avx512_calls_c

Conversation

@manodeep

@manodeep manodeep commented Aug 13, 2026

Copy link
Copy Markdown
Owner

The AVX512 kernel was the only one that had a C source file for implementing lookup tables (LUTs) for floats and doubles. This has bothered me for a while, but now I finally know how to remove it (well, really the calculating partial load mask was the bottleneck and I got the solution from simSIMD, although simSIMD/numkong now appears to use _bzhi - which requires BMI2 to be enabled at compile time and available at runtime - so the shift method seemed safer)

Ugghh My shell script / editor seems to have made some necessary but unasked for trailing-whitespace fixes as well :( Fixed now

@manodeep
manodeep requested a review from lgarrison August 13, 2026 13:11
@manodeep
manodeep force-pushed the remove_avx512_calls_c branch from 28bd033 to 5a96e4b Compare August 14, 2026 12:15

@lgarrison lgarrison left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see a few remaining references to masks_per_misalignment_value_DOUBLE and avx512_calls.c, are those now stale? Odd that CI didn't catch them, but maybe they're behind AVX-512 feature flags.

Comment thread theory/xi/xi_kernels.c.src Outdated

for(int64_t j=n_off;j<N2;j+=AVX512_NVEC) {
AVX512_MASK m_mask_left = (N2 - j) >= AVX512_NVEC ? ~0:masks_per_misalignment_value_DOUBLE[N2-j];
AVX512_MASK m_mask_left = (N2 - j) >= AVX512_NVEC ? ~0U:masks_per_misalignment_value_DOUBLE[N2-j];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this reference to masks_per_misalignment_value supposed to be changed to the new form?

@manodeep

Copy link
Copy Markdown
Owner Author

@lgarrison Thanks for picking those trailing references up - I have now checked that all references are now gone. Still not sure how the tests could have passed (or really, how the exes could have built) - only plausible explanation is that the CI machine yesterday did not have a CPU with AVX512. (And I have a MAC laptop, but that would still bring in an empty avx512_calls.o - but presumably that was hanging out from before I removed the source from Makefile and hence never got deleted)

However, I see that the CI is now failing. I will check on a AVX512 machine and report back

@manodeep

Copy link
Copy Markdown
Owner Author

I am very confused - why did the 3 out of 4 CI tests pass in the previous typo-ed xi. Makes me think that we need to have markers for the code changed, and not have the tests pass count if the required ISA was not available on the runner (or perhaps there is a way to request specific runners)

…et caught since utils/ Makefiles never get invoked)
@sonarqubecloud

Copy link
Copy Markdown

@lgarrison lgarrison left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked locally, looks good!

@manodeep

Copy link
Copy Markdown
Owner Author

Thanks @lgarrison - yeah I just checked with a fresh clone on a sapphirerapids machine and the tests pass and no references to avx512_calls.c, masks_per or bits_set.

This PR definitely made me realise how important the tests are, and that we need a proper testing harness that checks whether the Actions runner has AVX512, and if not, emulates the AVX512 instructions (probably with Intel SDE)

@manodeep
manodeep merged commit fbf4d08 into master Aug 16, 2026
9 checks passed
@manodeep
manodeep deleted the remove_avx512_calls_c branch August 16, 2026 23:49
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

Successfully merging this pull request may close these issues.

2 participants