taichi-dev / taichi

Productive, portable, and performant GPU programming in Python.
https://taichi-lang.org
Apache License 2.0
25.51k stars 2.28k forks source link

Building on Arm64 (Jetpack 5.1.1) #7916

Open oliver-batchelor opened 1 year ago

oliver-batchelor commented 1 year ago

On a fresh install on a Jetson Xavier AGX with Jetpack 5.1.1-b56, I have installed llvm-15 via. conda (conda-forge) and built it in a conda environment with python 3.9. This same method has worked for building from source for me previously on x86. The error looks very similar to that in #3872

I'm getting this error, regardless if my compiler is gcc-12 or clang-15.

Any tips much appreciated, has anyone had experience building on ARM?

[395/565] cd /home/canterbury/taichi/taichi/runtime/llvm/runtime_module && /home/canterbury/mambafor...cpp -o runtime_cuda.bc -fno-exceptions -emit-llvm -std=c++17 -D ARCH_cuda -I /home/canterbury/taichi
FAILED: taichi/runtime/llvm/runtime_module/CMakeFiles/generate_llvm_runtime_cuda /home/canterbury/taichi/_skbuild/linux-aarch64-3.9/cmake-build/taichi/runtime/llvm/runtime_module/CMakeFiles/generate_llvm_runtime_cuda 
cd /home/canterbury/taichi/taichi/runtime/llvm/runtime_module && /home/canterbury/mambaforge/envs/conan_ros/bin/clang++ -c runtime.cpp -o runtime_cuda.bc -fno-exceptions -emit-llvm -std=c++17 -D ARCH_cuda -I /home/canterbury/taichi
runtime.cpp:1114:23: warning: value size does not match register size specified by the constraint and modifier [-Wasm-operand-widths]
               : "=r"(ret)
                      ^
runtime.cpp:1113:37: note: use constraint modifier "w"
  asm volatile("match.all.sync.b32  %0, %1, %2;"
                                    ^~
                                    %w0
runtime.cpp:1115:22: warning: value size does not match register size specified by the constraint and modifier [-Wasm-operand-widths]
               : "r"(value), "r"(mask));
                     ^
runtime.cpp:1113:41: note: use constraint modifier "w"
  asm volatile("match.all.sync.b32  %0, %1, %2;"
                                        ^~
                                        %w1
runtime.cpp:1115:34: warning: value size does not match register size specified by the constraint and modifier [-Wasm-operand-widths]
               : "r"(value), "r"(mask));
                                 ^
runtime.cpp:1113:45: note: use constraint modifier "w"
  asm volatile("match.all.sync.b32  %0, %1, %2;"
                                            ^~
                                            %w2
runtime.cpp:1127:18: error: invalid input constraint 'l' in asm
               : "l"(value), "r"(mask));
                 ^
runtime.cpp:1137:44: warning: value size does not match register size specified by the constraint and modifier [-Wasm-operand-widths]
  asm volatile("activemask.b32 %0;" : "=r"(mask));
                                           ^
runtime.cpp:1137:32: note: use constraint modifier "w"
  asm volatile("activemask.b32 %0;" : "=r"(mask));
                               ^~
                               %w0
4 warnings and 1 error generated.

/home/canterbury/mambaforge/envs/conan_ros/lib/python3.9/site-packages/cmake/data/bin/cmake /home/canterbury/taichi -G Ninja --no-warn-unused-cli -DCMAKE_INSTALL_PREFIX:PATH=/home/canterbury/taichi/_skbuild/linux-aarch64-3.9/cmake-install -DPYTHON_VERSION_STRING:STRING=3.9.16 -DSKBUILD:INTERNAL=TRUE -DCMAKE_MODULE_PATH:PATH=/home/canterbury/mambaforge/envs/conan_ros/lib/python3.9/site-packages/skbuild/resources/cmake -DPYTHON_EXECUTABLE:PATH=/home/canterbury/mambaforge/envs/conan_ros/bin/python -DPYTHON_INCLUDE_DIR:PATH=/home/canterbury/mambaforge/envs/conan_ros/include/python3.9 -DPYTHON_LIBRARY:PATH=/home/canterbury/mambaforge/envs/conan_ros/lib/libpython3.9.so -DPython_EXECUTABLE:PATH=/home/canterbury/mambaforge/envs/conan_ros/bin/python -DPython_ROOT_DIR:PATH=/home/canterbury/mambaforge/envs/conan_ros -DPython_FIND_REGISTRY:STRING=NEVER -DPython_INCLUDE_DIR:PATH=/home/canterbury/mambaforge/envs/conan_ros/include/python3.9 -DPython_NumPy_INCLUDE_DIRS:PATH=/home/canterbury/mambaforge/envs/conan_ros/lib/python3.9/site-packages/numpy/core/include -DPython3_EXECUTABLE:PATH=/home/canterbury/mambaforge/envs/conan_ros/bin/python -DPython3_ROOT_DIR:PATH=/home/canterbury/mambaforge/envs/conan_ros -DPython3_FIND_REGISTRY:STRING=NEVER -DPython3_INCLUDE_DIR:PATH=/home/canterbury/mambaforge/envs/conan_ros/include/python3.9 -DPython3_NumPy_INCLUDE_DIRS:PATH=/home/canterbury/mambaforge/envs/conan_ros/lib/python3.9/site-packages/numpy/core/include -DCMAKE_MAKE_PROGRAM:FILEPATH=/home/canterbury/mambaforge/envs/conan_ros/lib/python3.9/site-packages/ninja/data/bin/ninja -DTI_WITH_OPENGL=OFF -DTI_WITH_GGUI=OFF -DTI_VERSION_MAJOR=1 -DTI_VERSION_MINOR=7 -DTI_VERSION_PATCH=0 -DCMAKE_BUILD_TYPE:STRING=Release

houkensjtu commented 1 year ago

Hi @oliver-batchelor ! The warning seems to be related to a mismatch in the following inline assembly code in taichi/runtime/llvm/runtime_module/runtime.cpp

  asm volatile("match.any.sync.b64  %0, %1, %2;"
               : "=r"(ret)
               : "l"(value), "r"(mask));
  return ret;

Please try to change the "l" constraint to "i" and see if the warning resolves. BTW, I found using gcc might cause some weird issues after the compilation, so avoid gcc if you can.

oliver-batchelor commented 1 year ago

Thanks! It works like a charm.

oliver-batchelor commented 1 year ago

Is this a change which can be committed or will it break other architectures?

bobcao3 commented 1 year ago

Is this a change which can be committed or will it break other architectures?

You can submit a PR changing this and we can trigger a CI run for you

KuSunoKiAMe commented 10 months ago

Hello,Did you successfully compile the library under the ARM architecture in the end?