## Copyright 2023 Intel Corporation
## SPDX-License-Identifier: Apache-2.0

name: CI Windows GPU

on:
  push:
  workflow_dispatch:

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

permissions: read-all

jobs:

### BUILD JOBS ###

  dpcpp-build:
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/windows.yml@main
    secrets: inherit
    with:
      runs-on: '["build", "mpi"]'
      env-from-files: .github/workflows/dpcpp.env
      cmd: |
        $env:SYCL_BUNDLE_ROOT = $env:DPCPP_ROOT
        # disable warnings which lead to excessively large log files
        $env:CXXFLAGS = '-w'
        $env:CFLAGS = '-w'
        scripts\build\win.ps1 -G Ninja -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_COMPILER=clang-cl -DBUILD_GPU_SUPPORT=ON -DBUILD_OSPRAY_MODULE_MPI=ON
      artifact-out: build-windows-dpcpp
      artifact-path: build/install/ospray build/CMakeCache.txt build/ospray/build/CMakeCache.txt

  icx-build:
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/windows.yml@main
    secrets: inherit
    with:
      runs-on: '["build", "mpi"]'
      env-from-files: .github/workflows/icx-windows.env
      ocloc-version: 77a13ae6-6100-4ddc-b069-0086ff44730c/ocloc_win_101.5082
      cmd: |
        # disable warnings which lead to excessively large log files
        $env:CXXFLAGS = '-w'
        $env:CFLAGS = '-w'
        scripts\build\win.ps1 -G Ninja -DCMAKE_CXX_COMPILER=icx -DCMAKE_C_COMPILER=icx -DBUILD_GPU_SUPPORT=ON -DBUILD_OSPRAY_MODULE_MPI=ON -DBUILD_EMBREE_FROM_SOURCE=ON -DBUILD_OPENVKL_FROM_SOURCE=ON -DBUILD_OIDN_FROM_SOURCE=ON
      artifact-out: build-windows-icx
      artifact-path: build/install/ospray build/CMakeCache.txt build/ospray/build/CMakeCache.txt



### TEST JOBS ###

  dpcpp-test:
    needs: dpcpp-build
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/windows.yml@main
    secrets: inherit
    with:
      timeout-minutes: 100
      runs-on: '"dg2"'
      env-from-files: .github/workflows/gfx-windows.env
      cmd: |
        $env:Path += ";$env:GITHUB_WORKSPACE\build\install\ospray\bin"
        scripts\tests\run_gpu_tests.ps1 "$env:GITHUB_WORKSPACE"
      artifact-in: build-windows-dpcpp
      artifact-out: test-windows-dpcpp
      artifact-path: build_regression_tests/tests*.xml build_regression_tests/failed*
      artifact-on-failure: true

  mpi-dpcpp-test:
    needs: dpcpp-build
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/windows.yml@main
    secrets: inherit
    with:
      timeout-minutes: 100
      runs-on: '["dg2"]' # FIXME, "mpi"
      env-from-files: .github/workflows/gfx-windows.env
      cmd: |
        $env:Path += ";C:\Program Files (x86)\Intel\oneAPI\mpi\latest\libfabric\bin\utils;C:\Program Files (x86)\Intel\oneAPI\mpi\latest\libfabric\bin;C:\Program Files (x86)\Intel\oneAPI\mpi\latest\bin\release;C:\Program Files (x86)\Intel\oneAPI\mpi\latest\bin"
        $env:Path += ";$env:GITHUB_WORKSPACE\build\install\ospray\bin"
        scripts\tests\run_gpu_tests.ps1 "$env:GITHUB_WORKSPACE" SKIP_GPU TEST_MPI
      artifact-in: build-windows-dpcpp
      artifact-out: test-windows-dpcpp-mpi
      artifact-path: build_regression_tests/tests*.xml build_regression_tests/failed*
      artifact-on-failure: true

  icx-test:
    needs: icx-build
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/windows.yml@main
    secrets: inherit
    with:
      timeout-minutes: 100
      runs-on: '"dg2"'
      env-from-files: .github/workflows/icx-windows.env .github/workflows/gfx-windows.env
      cmd: |
        $env:Path += ";$env:GITHUB_WORKSPACE\build\install\ospray\bin"
        scripts\tests\run_gpu_tests.ps1 "$env:GITHUB_WORKSPACE"
      artifact-in: build-windows-icx
      artifact-out: test-windows-icx
      artifact-path: build_regression_tests/tests*.xml build_regression_tests/failed*
      artifact-on-failure: true

  mpi-icx-test:
    needs: icx-build
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/windows.yml@main
    secrets: inherit
    with:
      timeout-minutes: 100
      runs-on: '["dg2"]' # FIXME, "mpi"
      env-from-files: .github/workflows/icx-windows.env .github/workflows/gfx-windows.env
      cmd: |
        $env:Path += ";C:\Program Files (x86)\Intel\oneAPI\mpi\latest\libfabric\bin\utils;C:\Program Files (x86)\Intel\oneAPI\mpi\latest\libfabric\bin;C:\Program Files (x86)\Intel\oneAPI\mpi\latest\bin\release;C:\Program Files (x86)\Intel\oneAPI\mpi\latest\bin"
        $env:Path += ";$env:GITHUB_WORKSPACE\build\install\ospray\bin"
        scripts\tests\run_gpu_tests.ps1 "$env:GITHUB_WORKSPACE" SKIP_GPU TEST_MPI
      artifact-in: build-windows-icx
      artifact-out: test-windows-icx-mpi
      artifact-path: build_regression_tests/tests*.xml build_regression_tests/failed*
      artifact-on-failure: true
