Improved Tensors #116
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
| name: Test C | |
| on: | |
| pull_request: | |
| branches: ["main", "main-*"] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| jobs: | |
| test_c: | |
| name: Test C on Linux | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Print Machine Specs | |
| shell: bash | |
| run: | | |
| echo "::group::Machine Information" | |
| uname -a || true | |
| cat /proc/cpuinfo 2>/dev/null | head -30 || sysctl -a machdep.cpu 2>/dev/null | head -30 || wmic cpu get Name,NumberOfCores,MaxClockSpeed 2>/dev/null || true | |
| free -h 2>/dev/null || vm_stat 2>/dev/null || systeminfo 2>/dev/null | head -20 || true | |
| echo "::endgroup::" | |
| - name: Install Dependencies | |
| run: | | |
| sudo apt update | |
| sudo apt install -y cmake gcc-14 g++-14 libjemalloc-dev libomp-dev libopenblas-dev | |
| - name: Build Locally | |
| run: | | |
| cmake -D CMAKE_BUILD_TYPE=Release -D NK_BUILD_TEST=1 -D NK_BUILD_BENCH=1 -D NK_COMPARE_TO_BLAS=1 \ | |
| -D CMAKE_C_COMPILER=gcc-14 -D CMAKE_CXX_COMPILER=g++-14 -B build_release | |
| cmake --build build_release --config Release | |
| - name: Test | |
| run: build_release/nk_test | |
| env: | |
| NK_BUDGET_SECS: 0.2 | |
| - name: Build Shared Library Test | |
| run: | | |
| cmake -D CMAKE_BUILD_TYPE=Release -D NK_BUILD_SHARED=1 -D NK_BUILD_SHARED_TEST=1 \ | |
| -D CMAKE_C_COMPILER=gcc-14 -D CMAKE_CXX_COMPILER=g++-14 -B build_shared | |
| cmake --build build_shared --config Release --target nk_shared_test | |
| - name: Test Shared Library | |
| run: LD_LIBRARY_PATH=build_shared build_shared/nk_shared_test | |
| test_macos_homebrew_llvm: | |
| name: Test macOS Homebrew LLVM | |
| runs-on: macos-15 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Install Homebrew LLVM | |
| run: brew install llvm | |
| # Record everything the runner CPU advertises so a future probe | |
| # mismatch can be diagnosed without repro-locally-only guesswork. | |
| - name: Print Machine Specs | |
| run: sysctl hw.optional.arm || true | |
| - name: Build | |
| run: | | |
| LLVM_PREFIX="$(brew --prefix llvm)" | |
| cmake -B build_brew_llvm \ | |
| -DCMAKE_BUILD_TYPE=Release \ | |
| -DCMAKE_C_COMPILER="${LLVM_PREFIX}/bin/clang" \ | |
| -DCMAKE_CXX_COMPILER="${LLVM_PREFIX}/bin/clang++" \ | |
| -DNK_BUILD_TEST=1 \ | |
| -DNK_BUILD_SHARED=1 | |
| cmake --build build_brew_llvm --config Release | |
| # Smoke test under lldb with an impossible NK_FILTER so no kernels run β | |
| # only `nk_capabilities()` / `nk_configure_thread()` and the suite's | |
| # argv/env setup. If a SIGILL fires during probing (as on Apple M1 with | |
| # Homebrew LLVM), lldb captures the backtrace, faulting PC symbol, and | |
| # 8 instructions around it so the offender is visible in the job log. | |
| - name: Smoke test under lldb (probing only) | |
| run: | | |
| DYLD_LIBRARY_PATH=build_brew_llvm \ | |
| lldb --batch \ | |
| -o run \ | |
| -k 'bt all' \ | |
| -k 'image lookup -a {frame.pc}' \ | |
| -k 'disassemble -c 8 -s {frame.pc}' \ | |
| -k 'quit' \ | |
| -- build_brew_llvm/nk_test | |
| env: | |
| NK_FILTER: __nk_impossible_filter__ | |
| NK_BUDGET_SECS: 0.05 | |
| - name: Test | |
| run: DYLD_LIBRARY_PATH=build_brew_llvm build_brew_llvm/nk_test | |
| env: | |
| NK_BUDGET_SECS: 0.2 | |
| test_windows: | |
| name: Test C on Windows | |
| runs-on: windows-2025 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Print Machine Specs | |
| shell: pwsh | |
| run: | | |
| Get-CimInstance Win32_Processor | Format-List Name,Manufacturer,NumberOfCores,NumberOfLogicalProcessors,Description,Architecture | |
| Get-ComputerInfo | Format-List CsProcessors,OsArchitecture,WindowsVersion | |
| - name: Set Up MSVC | |
| uses: microsoft/setup-msbuild@v3 | |
| - name: Build | |
| run: | | |
| cmake -G "Visual Studio 17 2022" -A x64 ` | |
| -DCMAKE_BUILD_TYPE=Release ` | |
| -DNK_BUILD_TEST=ON ` | |
| -DNK_BUILD_BENCH=OFF ` | |
| -B build_release | |
| cmake --build build_release --config Release | |
| - name: Test | |
| run: build_release\Release\nk_test.exe | |
| env: | |
| NK_BUDGET_SECS: 0.2 | |
| - name: Build Shared Library Test | |
| run: | | |
| cmake -G "Visual Studio 17 2022" -A x64 ` | |
| -DCMAKE_BUILD_TYPE=Release ` | |
| -DNK_BUILD_SHARED=ON ` | |
| -DNK_BUILD_SHARED_TEST=ON ` | |
| -B build_shared | |
| cmake --build build_shared --config Release --target nk_shared_test | |
| - name: Test Shared Library | |
| shell: cmd # PowerShell normalizes structured-exception exit codes to 1; cmd preserves the real code | |
| run: build_shared\Release\nk_shared_test.exe | |
| env: | |
| NK_BUDGET_SECS: 0.2 | |
| test_android: | |
| name: Test Android | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Print Machine Specs | |
| shell: bash | |
| run: | | |
| echo "::group::Machine Information" | |
| uname -a || true | |
| cat /proc/cpuinfo 2>/dev/null | head -30 || true | |
| free -h 2>/dev/null || true | |
| echo "::endgroup::" | |
| - name: Download Android NDK r29 | |
| run: | | |
| wget -q https://dl.google.com/android/repository/android-ndk-r29-linux.zip | |
| unzip -q android-ndk-r29-linux.zip -d ~/ | |
| echo "ANDROID_NDK_ROOT=$HOME/android-ndk-r29" >> "$GITHUB_ENV" | |
| - name: Build via CMake | |
| run: | | |
| cmake -B build_android \ | |
| -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-android-arm64.cmake \ | |
| -DNK_BUILD_SHARED=ON | |
| cmake --build build_android | |
| - name: Verify Binary | |
| run: | | |
| file build_android/libnumkong.so | |
| file build_android/libnumkong.so | grep -q "ELF 64-bit.*aarch64" | |
| readelf -d build_android/libnumkong.so | head -20 | |
| - name: Install Rust Toolchain | |
| uses: moonrepo/setup-rust@v1 | |
| - name: Install cargo-ndk and Target | |
| run: | | |
| cargo install cargo-ndk | |
| rustup target add aarch64-linux-android | |
| - name: Build via Cargo | |
| run: cargo ndk -t arm64-v8a build --release | |
| # 32-bit ARM Android β catches AArch64-only intrinsics leaking into | |
| # NEON code paths, like float64x2_t which doesn't exist on ARMv7. | |
| test_android_armv7: | |
| name: Test Android ARMv7 | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Download Android NDK r29 | |
| run: | | |
| wget -q https://dl.google.com/android/repository/android-ndk-r29-linux.zip | |
| unzip -q android-ndk-r29-linux.zip -d ~/ | |
| echo "ANDROID_NDK_ROOT=$HOME/android-ndk-r29" >> "$GITHUB_ENV" | |
| - name: Build via CMake | |
| run: | | |
| cmake -B build_android_armv7 \ | |
| -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-android-armv7.cmake \ | |
| -DNK_BUILD_SHARED=ON | |
| cmake --build build_android_armv7 | |
| - name: Verify Binary | |
| run: | | |
| file build_android_armv7/libnumkong.so | |
| file build_android_armv7/libnumkong.so | grep -q "ELF 32-bit.*ARM" | |
| - name: Install Rust Toolchain | |
| uses: moonrepo/setup-rust@v1 | |
| - name: Install cargo-ndk and Target | |
| run: | | |
| cargo install cargo-ndk | |
| rustup target add armv7-linux-androideabi | |
| - name: Build via Cargo | |
| run: cargo ndk -t armeabi-v7a build --release | |
| # 32-bit ARM Linux β validates the same AArch32 code paths as Android ARMv7 | |
| # but with the GNU toolchain instead of the NDK's Clang. | |
| test_armv7_linux: | |
| name: Test ARMv7 Linux | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Install Cross-Compiler | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-14-arm-linux-gnueabihf g++-14-arm-linux-gnueabihf | |
| - name: Build via CMake | |
| run: | | |
| cmake -B build_armv7 \ | |
| -DCMAKE_SYSTEM_NAME=Linux \ | |
| -DCMAKE_SYSTEM_PROCESSOR=arm \ | |
| -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc-14 \ | |
| -DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++-14 \ | |
| -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY \ | |
| -DNK_BUILD_SHARED=ON | |
| cmake --build build_armv7 | |
| - name: Verify Binary | |
| run: | | |
| file build_armv7/libnumkong.so | |
| file build_armv7/libnumkong.so | grep -q "ELF 32-bit.*ARM" | |
| - name: Install Rust Toolchain | |
| uses: moonrepo/setup-rust@v1 | |
| - name: Install Target | |
| run: rustup target add armv7-unknown-linux-gnueabihf | |
| - name: Build via Cargo | |
| env: | |
| CC_armv7_unknown_linux_gnueabihf: arm-linux-gnueabihf-gcc-14 | |
| CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-gcc-14 | |
| run: cargo build --target armv7-unknown-linux-gnueabihf --release | |
| test_riscv_llvm23: | |
| name: Test RISC-V LLVM 23 | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Install Dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y ca-certificates curl gnupg | |
| # Ubuntu 24.04 ships older LLVM in the default apt sources, but this | |
| # RISC-V validation needs Clang 23 for the portable `rv64gcv` baseline | |
| # while still compiling the richer RVV target-pragmas in our headers. | |
| curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key | sudo gpg --dearmor -o /usr/share/keyrings/llvm.gpg | |
| echo "deb [signed-by=/usr/share/keyrings/llvm.gpg] http://apt.llvm.org/noble/ llvm-toolchain-noble main" | sudo tee /etc/apt/sources.list.d/llvm.list > /dev/null | |
| sudo apt-get update | |
| sudo apt-get install -y cmake clang-23 lld-23 llvm-23 gcc-riscv64-linux-gnu libc6-dev-riscv64-cross | |
| - name: Configure Portable RISC-V Library Build | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| SYSROOT="$(riscv64-linux-gnu-gcc -print-sysroot)" | |
| cmake -B build_riscv \ | |
| -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-riscv64-llvm.cmake \ | |
| -DLLVM_ROOT=/usr/lib/llvm-23 \ | |
| -DRISCV_SYSROOT="${SYSROOT}" \ | |
| -DRISCV_MARCH=rv64gcv \ | |
| -DNK_BUILD_SHARED=ON | |
| - name: Build Portable RISC-V Library | |
| run: cmake --build build_riscv --parallel --target nk_shared | |
| test_loongarch: | |
| name: Test LoongArch (QEMU) | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Install Dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y cmake qemu-user \ | |
| gcc-14-loongarch64-linux-gnu g++-14-loongarch64-linux-gnu | |
| - name: Configure | |
| run: | | |
| SYSROOT="/usr/$(loongarch64-linux-gnu-gcc-14 -dumpmachine)" | |
| cmake -B build_loongarch \ | |
| -DCMAKE_SYSTEM_NAME=Linux \ | |
| -DCMAKE_SYSTEM_PROCESSOR=loongarch64 \ | |
| -DCMAKE_C_COMPILER=loongarch64-linux-gnu-gcc-14 \ | |
| -DCMAKE_CXX_COMPILER=loongarch64-linux-gnu-g++-14 \ | |
| -DCMAKE_CROSSCOMPILING_EMULATOR="qemu-loongarch64;-L;${SYSROOT};-cpu;max" \ | |
| -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY \ | |
| -DNK_BUILD_TEST=ON \ | |
| -DNK_BUILD_SHARED=ON | |
| - name: Build | |
| run: cmake --build build_loongarch --parallel | |
| - name: Test | |
| run: ctest --test-dir build_loongarch --output-on-failure | |
| env: | |
| NK_IN_QEMU: 1 | |
| NK_BUDGET_SECS: 0.1 | |
| test_power: | |
| name: Test Power (QEMU) | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Install Dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y cmake qemu-user \ | |
| gcc-14-powerpc64le-linux-gnu g++-14-powerpc64le-linux-gnu | |
| - name: Configure | |
| run: | | |
| SYSROOT="/usr/$(powerpc64le-linux-gnu-gcc-14 -dumpmachine)" | |
| cmake -B build_power \ | |
| -DCMAKE_SYSTEM_NAME=Linux \ | |
| -DCMAKE_SYSTEM_PROCESSOR=ppc64le \ | |
| -DCMAKE_C_COMPILER=powerpc64le-linux-gnu-gcc-14 \ | |
| -DCMAKE_CXX_COMPILER=powerpc64le-linux-gnu-g++-14 \ | |
| -DCMAKE_CROSSCOMPILING_EMULATOR="qemu-ppc64le;-L;${SYSROOT};-cpu;power10" \ | |
| -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY \ | |
| -DNK_BUILD_TEST=ON \ | |
| -DNK_BUILD_SHARED=ON | |
| - name: Build | |
| run: cmake --build build_power --parallel | |
| - name: Test | |
| run: ctest --test-dir build_power --output-on-failure | |
| env: | |
| NK_IN_QEMU: 1 | |
| NK_BUDGET_SECS: 0.1 | |
| test_x86_sde: | |
| name: Test x86 (Intel SDE) | |
| runs-on: ubuntu-24.04 | |
| env: | |
| SDE_VERSION: sde-external-9.44.0-2024-08-22-lin | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Install Dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y cmake build-essential | |
| - name: Download Intel SDE | |
| run: | | |
| curl -fsSL -o sde.tar.xz \ | |
| "https://downloadmirror.intel.com/831748/${SDE_VERSION}.tar.xz" | |
| tar -xf sde.tar.xz | |
| echo "$(pwd)/${SDE_VERSION}" >> "$GITHUB_PATH" | |
| - name: Build with All x86 ISAs | |
| run: | | |
| cmake -B build_sde \ | |
| -DCMAKE_BUILD_TYPE=Release \ | |
| -DNK_BUILD_TEST=ON | |
| cmake --build build_sde --config Release --parallel | |
| - name: Test Under Granite Rapids Emulation | |
| run: sde64 -gnr -- build_sde/nk_test | |
| env: | |
| NK_BUDGET_SECS: 0 |