Skip to content

Fix build on powerpc*#985

Open
pkubaj wants to merge 2 commits into
RedisAI:mainfrom
pkubaj:patch-1
Open

Fix build on powerpc*#985
pkubaj wants to merge 2 commits into
RedisAI:mainfrom
pkubaj:patch-1

Conversation

@pkubaj

@pkubaj pkubaj commented Jul 3, 2026

Copy link
Copy Markdown

Two simple patches to fix powerpc* builds.

Mark if applicable

  • This PR introduces API changes
  • This PR introduces serialization changes

Note

Low Risk
Small, build-target-specific wiring with no API or behavior change on x86_64/AArch64; PPC continues to use scalar distance paths guarded by existing arch macros.

Overview
Fixes powerpc* compilation and runtime CPU feature detection in VecSim by treating PPC like the existing x86_64 and AArch64 paths.

space_includes.h now includes cpuinfo_ppc.h when CPU_FEATURES_ARCH_PPC is defined. getCpuOptimizationFeatures in spaces.h selects cpu_features::PPCFeatures and GetPPCInfo on PPC instead of falling through to the x86 types and GetX86Info.

Reviewed by Cursor Bugbot for commit f033912. Bugbot is set up for automated code reviews on this repo. Configure here.

pkubaj added 2 commits July 3, 2026 11:37
Tested on FreeBSD/powerpc64le.
Tested on FreeBSD/powerpc64le.
@jit-ci

jit-ci Bot commented Jul 3, 2026

Copy link
Copy Markdown

Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset.

In case there are security findings, they will be communicated to you as a comment inside the PR.

Hope you’ll enjoy using Jit.

Questions? Comments? Want to learn more? Get in touch with us.

@CLAassistant

CLAassistant commented Jul 3, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@alonre24

Copy link
Copy Markdown
Collaborator

@pkubaj Thank you for the contribution. First, please sign the CLA. Second, did you confirm that this addition would enable SIMD optimizations on PPC?

@pkubaj

pkubaj commented Jul 15, 2026

Copy link
Copy Markdown
Author

No, it doesn't — and it isn't meant to. This is purely a build fix; PPC keeps using the scalar distance functions.
The SIMD selection is entirely gated behind CPU_FEATURES_ARCH_X86_64 and CPU_FEATURES_ARCH_AARCH64. For example in L2_space.cpp every optimized path sits inside those blocks:

#ifdef CPU_FEATURES_ARCH_AARCH64
    if (features.sve2) return Choose_..._SVE2(dim);
    if (features.asimd) return Choose_..._NEON(dim);
#endif
#ifdef CPU_FEATURES_ARCH_X86_64
    if (features.avx512f && ...) return Choose_..._AVX512...(dim)
    if (features.avx2) return Choose_..._AVX2(dim);
#endif
    // falls through to the scalar implementation

There are no CPU_FEATURES_ARCH_PPC dispatch blocks and no VSX/AltiVec kernels, so on PPC none of the features.* fields are ever read — the functions fall straight through to the scalar default.

What the change actually does is narrower: without it, getCpuOptimizationFeatures() on PPC falls into the #else and instantiates cpu_features::X86Features / GetX86Info, which don't exist on a PPC build (cpu_features compiles its PPC module there, not the x86 one) — that's the compile failure. Routing PPC to PPCFeatures/GetPPCInfo makes it build; the returned struct is simply never consulted, exactly like the scalar fallback intends.

Actually enabling SIMD on PPC would be a separate, much larger change — adding VSX implementations plus the OPT_* macros and Choose_* dispatch — which is out of scope for a build fix.

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.

3 participants