Keep RISC-V targets on the scalar path - #165
Conversation
|
Can you explain personnally (no AI generated reply) what error your pull request fixes and provide the logs of the error you encountered on your RISC-V system? |
|
Thanks for asking, and sorry for the unclear words. I should correct that: this was not tested on a physical RISC-V machine. My validation was done with a riscv64 cross-compilation setup plus qemu. The issue this PR fixes is that a riscv64-targeted CMake configuration still runs ARM/x86 SIMD auto-detection probes on upstream master, and that breaks configuration in my setup. The relevant errors were: |
|
OK. Ideally I would like you to fix this by only modifying CMakeLists.txt. I think your libdivide.h (and the other files you modified) changes are not needed. Please try to keep your changes minimal. |
|
Thanks, I reduced the patch and pushed an update in 4349780. The PR now only modifies I re-tested it on my side with the same cross-compilation setup as before:
Thanks for pointing me to the smaller fix. |
|
Your new fix is already much better than your first version. However it is not optimal since you have now basically hardcoded a workaround for RISC-V. The issue is still present for other CPU architectures. I think the right fix is to use proper cross compilation detection for SSE2, AVX2, AVX512 similar to how we handle LIBDIVIDE_SVE2 in CMakeLists.txt. |
|
Ok, please give me some time to think about what to do. This might take a while. |
|
I think this code can be used to fix the issue: if (CMAKE_CROSSCOMPILING)
check_cxx_source_compiles("${NEON_TEST}" LIBDIVIDE_NEON_ENABLED)
else()
check_cxx_source_runs("${NEON_TEST}" LIBDIVIDE_NEON_ENABLED)
endif() |
|
Thanks, your suggestion was right. I removed the RISC-V-specific workaround and updated the SSE2, AVX2, and AVX512 autodetection to follow the same cross-compiling pattern as NEON/SVE/SVE2: I also re-validated this with a real Please take another look when you have time. thank you very much. |
|
Thanks! |
Why
libdividealready has a portable scalar implementation, but its current CMake auto-detection logic still probes x86 and ARM vector backends even when the configured target isriscv64.On a RISC-V target, that is not target-correct:
This change keeps
riscv64on libdivide's existing scalar path unless a vector option is enabled manually.What changed
CMakeLists.txtonly.CMAKE_SYSTEM_PROCESSORmatchesriscv*, any SIMD option that is stillAUTOis set toOFFbefore the existing autodetection probes run.ONorOFF) and for non-RISC-V targets.Verification
masterwith ariscv64cross-compiling configure:riscv64configure:cmake -S . -B build-riscv-sim-review -G Ninja -DCMAKE_BUILD_TYPE=Release -DLIBDIVIDE_BUILD_TESTS=ON -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=riscv64 -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARYRISC-V target detected; libdivide will use the scalar path unless vector macros are enabled manually.riscv64build files:build-riscv-sim-review/build.ninjacontains noLIBDIVIDE_SSE2,LIBDIVIDE_AVX2,LIBDIVIDE_AVX512,LIBDIVIDE_NEON, orLIBDIVIDE_SVE;-march=native,-mavx,-msse,arm_neon, orarm_sve.testerpassed;test_c99passed;test_divlupassed.Notes