Gate x86 SIMD detection by target architecture
## Summary
- recognize riscv32 / riscv64 explicitly in Fastor's architecture detection;
- keep riscv64 on the existing scalar SIMDVector backend instead of inheriting host x86 SIMD macros.#183
Open
carlosqwqqwq wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Fastor already has a scalar
SIMDVectorfallback, but its SIMD configuration logic currently derives SSE, AVX, AVX512, and FMA support directly from host compiler macros. In simulated or cross-targetriscv64builds this leaks hostx86_64SIMD state into the target configuration and prevents the existing scalar fallback from being selected.What changed
Fastor/config/config.hforriscv32,riscv64, and x86 targets.FASTOR_MIC_IMPL,FASTOR_SSE*,FASTOR_AVX*, andFASTOR_FMA*macros are only derived on x86 targets.riscv64, to reachFASTOR_SCALAR_IMPL.README.mdto document thatriscv64currently uses Fastor's scalarSIMDVectorbackend unless a dedicated RISC-V backend is added.Verification
cmake -S . -B build-native-min -G Ninja -DBUILD_TESTING=OFFcmake --build build-native-min --parallel 4cmake --install build-native-min --prefix build-native-min\installFastor/config/config.hwith forced__riscv=1and__riscv_xlen=64and confirmed the result definesFASTOR_ARCH_RISCV,FASTOR_ARCH_RISCV64, andFASTOR_SCALAR_IMPL, without definingFASTOR_SSE2_IMPLorFASTOR_AVX_IMPL.riscv64smoke translation unit includingFastor/Fastor.hand confirmedFastor::choose_best_simd_vector_t<float>resolves to the scalar ABI withSize == 1.x86_64host and confirmed the existing x86 path still definesFASTOR_ARCH_X86andFASTOR_SSE2_IMPL.riscv64cross-compilation and execution in Docker (ubuntu:24.04):Tensor<float,2,2>andmatmul(...)with hostg++;riscv64-linux-gnu-g++;ELF64/Machine: RISC-Vviafileandreadelf -h;riscv64binary successfully withqemu-riscv64-static -L /usr/riscv64-linux-gnu.Notes
This is a conservative portability patch. It does not add RVV or any other RISC-V SIMD backend. The goal is to make
riscv64use Fastor's existing scalar backend correctly and to stop host x86 SIMD macros from leaking into target selection.