# Copyright 2025-2026, Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause

name: JIT Mode

permissions: read-all

on:
  pull_request:
  workflow_dispatch:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  linux:
    runs-on: ubuntu-22.04

    steps:
    - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
      with:
        submodules: true

    - name: Install dependencies
      run: |
        .github/workflows/scripts/install-build-deps.sh

    - name: Check environment
      run: |
        which -a clang
        cat /proc/cpuinfo

    - name: Build ISPC
      run: |
        .github/workflows/scripts/build-ispc.sh -DISPC_LIBRARY_JIT=ON -DISPC_INCLUDE_BENCHMARKS=OFF

    - name: Runtime tests
      run: |
        PATH=$(pwd)/build/bin:$PATH ./scripts/run_tests.py --jit --target=avx2-i32x8 --arch=x86-64

  macos:
    runs-on: macos-14

    steps:
    - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
      with:
        submodules: true

    - name: Install dependencies
      run: |
        .github/workflows/scripts/install-build-deps.sh macos-14

    - name: Check environment
      run: |
        which -a clang
        llvm-config --system-libs
        sysctl -n machdep.cpu.brand_string

    - name: Build ISPC
      run: |
        .github/workflows/scripts/build-ispc.sh -DISPC_LIBRARY_JIT=ON -DISPC_INCLUDE_BENCHMARKS=OFF

    - name: Runtime tests
      run: |
        PATH=$(pwd)/build/bin:$PATH ./scripts/run_tests.py --jit --target=neon-i32x4 --arch=aarch64

  windows:
    runs-on: windows-2022

    steps:
    - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
      with:
        submodules: true

    - name: Add msbuild to PATH
      uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # v2.0.0

    - name: Install dependencies
      run: |
        pwsh .github/workflows/scripts/install-build-deps.ps1

    - name: Check environment
      run: |
        wmic cpu get caption, deviceid, name, numberofcores, maxclockspeed, status

    - name: Build ISPC
      shell: cmd
      run: |
        set VSVARS="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
        call %VSVARS%
        pwsh -File .github/workflows/scripts/build-ispc.ps1 -DISPC_LIBRARY_JIT=ON -DISPC_INCLUDE_BENCHMARKS=OFF

    - name: Runtime tests
      shell: pwsh
      run: |
        $env:ISPC_HOME = "$pwd"
        $env:PATH = "$pwd/build/bin/Release;$env:PATH"
        .github/workflows/scripts/load-vs-env.ps1 x86-64
        python .\scripts\run_tests.py --jit --target=avx2-i32x8 --arch=x86-64 --jit-lib-path="$pwd/build/Release"