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

name: CI Linux GPU

on:
  push:
  workflow_dispatch:

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

permissions: read-all

jobs:

### BUILD JOBS ###

  ubu22-mpi-dpcpp-build:
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    secrets: inherit
    with:
      image: ubuntu:22.04
      env-from-files: .github/workflows/dpcpp.env
      cmd: |
        module load cmake/3.25.3
        export CC=clang
        export CXX=clang++
        scripts/build/linux.sh -G Ninja -DBUILD_GLFW=OFF -DBUILD_GPU_SUPPORT=ON -DBUILD_OSPRAY_MODULE_MPI=ON -DBUILD_OSPRAY_MODULE_MULTIDEVICE=ON
      artifact-out: build-ubuntu2204-mpi-dpcpp
      artifact-path: build/install/ospray build/CMakeCache.txt build/*/build/CMakeCache.txt


  ubu22-mpi-icx-build:
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    secrets: inherit
    with:
      image: ubuntu:22.04
      env-from-files: .github/workflows/icx-linux.env .github/workflows/gfx-ubuntu22.env # OIDN AOT needs ocloc
      cmd: |
        module load cmake/3.25.3
        scripts/build/linux.sh -G Ninja -DBUILD_GLFW=OFF -DBUILD_GPU_SUPPORT=ON -DBUILD_OSPRAY_MODULE_MPI=ON -DBUILD_OSPRAY_MODULE_MULTIDEVICE=ON -DBUILD_EMBREE_FROM_SOURCE=ON -DBUILD_OPENVKL_FROM_SOURCE=ON -DBUILD_OIDN_FROM_SOURCE=ON
      artifact-out: build-ubuntu2204-mpi-icx
      artifact-path: build/install/ospray build/CMakeCache.txt build/*/build/CMakeCache.txt


  suse-icx-build:
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    secrets: inherit
    with:
      image: opensuse/leap:15.3
      env-from-files: .github/workflows/icx-linux.env
      cmd: |
        module load cmake/3.25.3
        scripts/build/linux.sh -DBUILD_GPU_SUPPORT=ON -DBUILD_EMBREE_FROM_SOURCE=ON -DBUILD_OPENVKL_FROM_SOURCE=ON

  rocky8-mpich-dpcpp-build:
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    secrets: inherit
    with:
      image: rockylinux:8
      env-from-files: .github/workflows/dpcpp.env
      cmd: |
        module load cmake/3.25.3
        module load mpi/mpich-x86_64
        export CC=clang
        export CXX=clang++
        scripts/build/linux.sh -DBUILD_GPU_SUPPORT=ON -DBUILD_OSPRAY_MODULE_MPI=ON -DBUILD_OSPRAY_MODULE_MULTIDEVICE=ON
      artifact-out: build-rocky8-mpich-dpcpp
      artifact-path: build/install/ospray build/CMakeCache.txt build/*/build/CMakeCache.txt



### TEST JOBS ###

  dpcpp-dg2-ubu22-test:
    needs: ubu22-mpi-dpcpp-build
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    secrets: inherit
    with:
      timeout-minutes: 100
      image: ubuntu:22.04
      env-from-files: .github/workflows/gfx-ubuntu22.env
      options: --device=/dev/dri:/dev/dri
      runs-on: '"dg2"'
      artifact-in: build-ubuntu2204-mpi-dpcpp
      artifact-out: test-ubuntu2204-dpcpp-dg2
      artifact-path: build_regression_tests/tests*.xml build_regression_tests/failed*
      artifact-on-failure: true
      cmd: |
        module load cmake/3.25.3
        export PATH="$GITHUB_WORKSPACE/build/install/ospray/bin:$PATH"
        scripts/tests/run_gpu_tests.sh "$GITHUB_WORKSPACE"

  dpcpp-pvc-ubu22-test:
    needs: ubu22-mpi-dpcpp-build
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    secrets: inherit
    with:
      timeout-minutes: 100
      image: ubuntu:22.04
      env-from-files: .github/workflows/gfx-ubuntu22.env
      options: --device=/dev/dri:/dev/dri
      runs-on: '"pvc"'
      artifact-in: build-ubuntu2204-mpi-dpcpp
      artifact-out: test-ubuntu2204-dpcpp-pvc
      artifact-path: build_regression_tests/tests*.xml build_regression_tests/failed*
      artifact-on-failure: true
      cmd: |
        module load cmake/3.25.3
        export PATH="$GITHUB_WORKSPACE/build/install/ospray/bin:$PATH"
        scripts/tests/run_gpu_tests.sh "$GITHUB_WORKSPACE"

  mpi-dpcpp-pvc-ubu22-test:
    needs: ubu22-mpi-dpcpp-build
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    secrets: inherit
    with:
      timeout-minutes: 100
      image: ubuntu:22.04
      env-from-files: .github/workflows/gfx-ubuntu22.env
      options: --device=/dev/dri:/dev/dri
      runs-on: '"pvc"'
      artifact-in: build-ubuntu2204-mpi-dpcpp
      artifact-out: test-ubuntu2204-mpi-dpcpp-pvc
      artifact-path: build_regression_tests/tests*.xml build_regression_tests/failed*
      artifact-on-failure: true
      cmd: |
        module load cmake/3.25.3
        export PATH="$GITHUB_WORKSPACE/build/install/ospray/bin:$PATH"
        OMPI_ALLOW_RUN_AS_ROOT=1 OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 scripts/tests/run_gpu_tests.sh "$GITHUB_WORKSPACE" SKIP_GPU TEST_MPI

  multidev-dpcpp-pvc-ubu22-test:
    needs: ubu22-mpi-dpcpp-build
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    secrets: inherit
    with:
      timeout-minutes: 100
      image: ubuntu:22.04
      env-from-files: .github/workflows/gfx-ubuntu22.env
      options: --device=/dev/dri:/dev/dri
      runs-on: '"pvc"'
      artifact-in: build-ubuntu2204-mpi-dpcpp
      artifact-out: test-ubuntu2204-multidev-dpcpp-pvc
      artifact-path: build_regression_tests/tests*.xml build_regression_tests/failed*
      artifact-on-failure: true
      cmd: |
        module load cmake/3.25.3
        export PATH="$GITHUB_WORKSPACE/build/install/ospray/bin:$PATH"
        scripts/tests/run_gpu_tests.sh "$GITHUB_WORKSPACE" SKIP_GPU TEST_MULTIDEVICE

  icx-dg2-ubu22-test:
    needs: ubu22-mpi-icx-build
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    secrets: inherit
    with:
      timeout-minutes: 100
      image: ubuntu:22.04
      env-from-files: .github/workflows/icx-linux.env .github/workflows/gfx-ubuntu22.env
      options: --device=/dev/dri:/dev/dri
      runs-on: '"dg2"'
      artifact-in: build-ubuntu2204-mpi-icx
      artifact-out: test-ubuntu2204-icx-dg2
      artifact-path: build_regression_tests/tests*.xml build_regression_tests/failed*
      artifact-on-failure: true
      cmd: |
        export PATH="$GITHUB_WORKSPACE/build/install/ospray/bin:$PATH"
        scripts/tests/run_gpu_tests.sh "$GITHUB_WORKSPACE"

  mpi-icx-dg2-ubu22-test:
    needs: ubu22-mpi-icx-build
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    secrets: inherit
    with:
      timeout-minutes: 100
      image: ubuntu:22.04
      env-from-files: .github/workflows/icx-linux.env .github/workflows/gfx-ubuntu22.env
      options: --device=/dev/dri:/dev/dri
      runs-on: '"dg2"'
      artifact-in: build-ubuntu2204-mpi-icx
      artifact-out: test-ubuntu2204-mpi-icx-dg2
      artifact-path: build_regression_tests/tests*.xml build_regression_tests/failed*
      artifact-on-failure: true
      cmd: |
        export PATH="$GITHUB_WORKSPACE/build/install/ospray/bin:$PATH"
        OMPI_ALLOW_RUN_AS_ROOT=1 OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 scripts/tests/run_gpu_tests.sh "$GITHUB_WORKSPACE" SKIP_GPU TEST_MPI

  icx-pvc-ubu22-test:
    needs: ubu22-mpi-icx-build
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    secrets: inherit
    with:
      timeout-minutes: 100
      image: ubuntu:22.04
      env-from-files: .github/workflows/icx-linux.env .github/workflows/gfx-ubuntu22.env
      options: --device=/dev/dri:/dev/dri
      runs-on: '"pvc"'
      artifact-in: build-ubuntu2204-mpi-icx
      artifact-out: test-ubuntu2204-icx-pvc
      artifact-path: build_regression_tests/tests*.xml build_regression_tests/failed*
      artifact-on-failure: true
      cmd: |
        export PATH="$GITHUB_WORKSPACE/build/install/ospray/bin:$PATH"
        scripts/tests/run_gpu_tests.sh "$GITHUB_WORKSPACE"

  mpi-icx-pvc-ubu22-test:
    needs: ubu22-mpi-icx-build
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    secrets: inherit
    with:
      timeout-minutes: 100
      image: ubuntu:22.04
      env-from-files: .github/workflows/icx-linux.env .github/workflows/gfx-ubuntu22.env
      options: --device=/dev/dri:/dev/dri
      runs-on: '"pvc"'
      artifact-in: build-ubuntu2204-mpi-icx
      artifact-out: test-ubuntu2204-mpi-icx-pvc
      artifact-path: build_regression_tests/tests*.xml build_regression_tests/failed*
      artifact-on-failure: true
      cmd: |
        export PATH="$GITHUB_WORKSPACE/build/install/ospray/bin:$PATH"
        OMPI_ALLOW_RUN_AS_ROOT=1 OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 scripts/tests/run_gpu_tests.sh "$GITHUB_WORKSPACE" SKIP_GPU TEST_MPI

  multidev-icx-pvc-ubu22-test:
    needs: ubu22-mpi-icx-build
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    secrets: inherit
    with:
      timeout-minutes: 100
      image: ubuntu:22.04
      env-from-files: .github/workflows/icx-linux.env .github/workflows/gfx-ubuntu22.env
      options: --device=/dev/dri:/dev/dri
      runs-on: '"pvc"'
      artifact-in: build-ubuntu2204-mpi-icx
      artifact-out: test-ubuntu2204-multidev-icx-pvc
      artifact-path: build_regression_tests/tests*.xml build_regression_tests/failed*
      artifact-on-failure: true
      cmd: |
        export PATH="$GITHUB_WORKSPACE/build/install/ospray/bin:$PATH"
        scripts/tests/run_gpu_tests.sh "$GITHUB_WORKSPACE" SKIP_GPU TEST_MULTIDEVICE

