fix: resolve build errors in zk_c_api.cpp #26
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: Matrix Test All Platforms | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| test-matrix: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # macOS ARM64 (M1/M2) | |
| - os: macos-14 | |
| backend: auto | |
| name: "macOS ARM64 - Auto" | |
| - os: macos-14 | |
| backend: metal | |
| name: "macOS ARM64 - Metal" | |
| - os: macos-14 | |
| backend: cpu | |
| name: "macOS ARM64 - CPU" | |
| # macOS x64 | |
| - os: macos-13 | |
| backend: cpu | |
| name: "macOS x64 - CPU" | |
| # Linux | |
| - os: ubuntu-latest | |
| backend: auto | |
| name: "Linux - Auto" | |
| - os: ubuntu-latest | |
| backend: cpu | |
| name: "Linux - CPU" | |
| # Windows | |
| - os: windows-latest | |
| backend: auto | |
| name: "Windows - Auto" | |
| - os: windows-latest | |
| backend: cpu | |
| name: "Windows - CPU" | |
| runs-on: ${{ matrix.os }} | |
| name: ${{ matrix.name }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.21' | |
| # macOS setup | |
| - name: Install macOS dependencies | |
| if: runner.os == 'macOS' | |
| run: | | |
| xcode-select --print-path | |
| - name: Download MLX (macOS) | |
| if: runner.os == 'macOS' | |
| run: | | |
| mkdir -p lib | |
| LATEST_TAG=$(gh release list --limit 1 --json tagName --jq '.[0].tagName' 2>/dev/null || echo "") | |
| if [ -n "$LATEST_TAG" ]; then | |
| ARCH=$(uname -m) | |
| if [ "$ARCH" = "arm64" ]; then | |
| gh release download "$LATEST_TAG" -p "libmlx-macos-arm64.tar.gz" 2>/dev/null && tar -xzf libmlx-macos-arm64.tar.gz -C lib/ && exit 0 | |
| else | |
| gh release download "$LATEST_TAG" -p "libmlx-macos-x64.tar.gz" 2>/dev/null && tar -xzf libmlx-macos-x64.tar.gz -C lib/ && exit 0 | |
| fi | |
| fi | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| continue-on-error: true | |
| - name: Build MLX (macOS fallback) | |
| if: runner.os == 'macOS' && hashFiles('lib/libmlx.a') == '' | |
| run: | | |
| mkdir -p build && cd build | |
| cmake .. -DCMAKE_BUILD_TYPE=Release -DMLX_BUILD_TESTS=OFF -DMLX_BUILD_EXAMPLES=OFF -DMLX_BUILD_PYTHON_BINDINGS=OFF -DMLX_BUILD_METAL=ON | |
| make -j$(sysctl -n hw.ncpu) mlx | |
| mkdir -p ../lib && cp libmlx.a ../lib/ | |
| # Linux setup | |
| - name: Install Linux dependencies | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y build-essential gcc g++ cmake | |
| # Check for NVIDIA GPU (won't exist in GitHub Actions) | |
| if command -v nvidia-smi &> /dev/null; then | |
| echo "CUDA available" | |
| else | |
| echo "No CUDA available - using CPU backend" | |
| fi | |
| - name: Download MLX (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| mkdir -p lib | |
| LATEST_TAG=$(gh release list --limit 1 --json tagName --jq '.[0].tagName' 2>/dev/null || echo "") | |
| if [ -n "$LATEST_TAG" ]; then | |
| gh release download "$LATEST_TAG" -p "libmlx-linux-x64.tar.gz" 2>/dev/null && tar -xzf libmlx-linux-x64.tar.gz -C lib/ && exit 0 | |
| fi | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| continue-on-error: true | |
| - name: Build MLX (Linux fallback) | |
| if: runner.os == 'Linux' && hashFiles('lib/libmlx.a') == '' | |
| run: | | |
| mkdir -p build && cd build | |
| cmake .. -DCMAKE_BUILD_TYPE=Release -DMLX_BUILD_TESTS=OFF -DMLX_BUILD_EXAMPLES=OFF -DMLX_BUILD_PYTHON_BINDINGS=OFF -DMLX_BUILD_METAL=OFF | |
| make -j$(nproc) mlx | |
| mkdir -p ../lib && cp libmlx.a ../lib/ | |
| # Windows setup | |
| - name: Install Windows dependencies | |
| if: runner.os == 'Windows' | |
| uses: egor-tensin/setup-mingw@v2 | |
| with: | |
| platform: x64 | |
| - name: Install CMake (Windows) | |
| if: runner.os == 'Windows' | |
| run: choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System' -y | |
| - name: Download MLX (Windows) | |
| if: runner.os == 'Windows' | |
| shell: bash | |
| run: | | |
| mkdir -p lib | |
| LATEST_TAG=$(gh release list --limit 1 --json tagName --jq '.[0].tagName' 2>/dev/null || echo "") | |
| if [ -n "$LATEST_TAG" ]; then | |
| gh release download "$LATEST_TAG" -p "libmlx-windows-x64.tar.gz" 2>/dev/null && tar -xzf libmlx-windows-x64.tar.gz -C lib/ && exit 0 | |
| fi | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| continue-on-error: true | |
| - name: Build MLX (Windows fallback) | |
| if: runner.os == 'Windows' && hashFiles('lib/libmlx.a') == '' | |
| shell: bash | |
| run: | | |
| mkdir -p build && cd build | |
| cmake .. -DCMAKE_BUILD_TYPE=Release -DMLX_BUILD_TESTS=OFF -DMLX_BUILD_EXAMPLES=OFF -DMLX_BUILD_PYTHON_BINDINGS=OFF -DMLX_BUILD_METAL=OFF -G "MinGW Makefiles" | |
| cmake --build . --target mlx -j | |
| mkdir -p ../lib && cp libmlx.a ../lib/ | |
| # Run tests | |
| - name: Run tests | |
| shell: bash | |
| run: | | |
| echo "Testing with backend: ${{ matrix.backend }}" | |
| export MLX_BACKEND="${{ matrix.backend }}" | |
| export CGO_ENABLED=1 | |
| go test -v -timeout 30s ./... | |
| # Run benchmarks (short) | |
| - name: Run benchmarks | |
| shell: bash | |
| run: | | |
| export MLX_BACKEND="${{ matrix.backend }}" | |
| export CGO_ENABLED=1 | |
| go test -bench=. -benchtime=100ms ./... | |
| # Verify backend selection | |
| - name: Verify backend | |
| shell: bash | |
| run: | | |
| export MLX_BACKEND="${{ matrix.backend }}" | |
| export CGO_ENABLED=1 | |
| go test -v -run TestBackendDetection ./... |