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

name: performance

permissions: read-all

on: 
  schedule:
    - cron:  '00 01 * * *'
  workflow_dispatch:

jobs:
  perf-linux-SYCL-DPCPP-build:
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    with:
      image: embree/ubuntu:22.04
      options: --device=/dev/dri:/dev/dri
      runs-on: '[ "Linux", "docker", "dg2" ]'
      project: embree
      env-from-files: ./.github/workflows/dpcpp-none.env ./.github/workflows/gfx-ubuntu22-public.env
      dpcpp-version: intel/2023.0
      artifact-out: perf-linux-SYCL-DPCPP
      artifact-path: ./build/*.tar.gz
      cmd: |
        module load cmake/3.25.3
        cmake --preset perf-linux-icx-sycl -DCMAKE_BUILD_TYPE=Release
        cmake --build build --config Release --target build

  perf-linux-DG2-A770-test:
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    needs: ["perf-linux-SYCL-DPCPP-build"]
    with:
      image: embree/ubuntu:22.04
      options: --device=/dev/dri:/dev/dri
      runs-on: '[ "Linux", "docker", "dg2", "perf", "A770" ]'
      project: embree
      env-from-files: ./.github/workflows/dpcpp-none.env ./.github/workflows/gfx-ubuntu22-public.env
      artifact-in: perf-linux-SYCL-DPCPP
      setup-benny: true
      cmd: |
        cd build
        ls *.tar.gz
        tar -xzf embree-?.?.?.sycl.x86_64.linux.tar.gz
        cd bin
        source ../embree-vars.sh
        $GITHUB_WORKSPACE/scripts/run-perf.sh gpu

  perf-linux-PVC-test:
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    needs: ["perf-linux-SYCL-DPCPP-build"]
    with:
      image: embree/ubuntu:22.04
      options: --device=/dev/dri:/dev/dri
      runs-on: '[ "Linux", "docker", "pvc", "perf" ]'
      project: embree
      env-from-files: ./.github/workflows/dpcpp-none.env ./.github/workflows/gfx-ubuntu22-public.env
      artifact-in: perf-linux-SYCL-DPCPP
      setup-benny: true
      cmd: |
        # Run it on single tile (disable implicit scaling)
        export EnableImplicitScaling=0
        export NEOReadDebugKeys=1
        export ZE_FLAT_DEVICE_HIERARCHY=COMPOSITE
        cd build
        ls *.tar.gz
        tar -xzf embree-?.?.?.sycl.x86_64.linux.tar.gz
        cd bin
        source ../embree-vars.sh
        $GITHUB_WORKSPACE/scripts/run-perf.sh gpu






  perf-linux-x86-ICX-ISPC-build:
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    with:
      image: embree/rockylinux:8.7
      runs-on: '[ "Linux", "docker", "avx512" ]'
      dpcpp-version: intel/2024.1.0
      artifact-out: perf-linux-x86-ICX-ISPC-build
      artifact-path: ./build/*.tar.gz
      cmd: |
        module load cmake/3.25.3
        cmake --preset perf-linux-icx -DCMAKE_BUILD_TYPE=Release
        cmake --build build --config Release --target build

  perf-linux-i9-12900k-test:
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/perf.yml@main
    needs: ["perf-linux-x86-ICX-ISPC-build"]
    with:
      runs-on: '[ "Linux", "perf", "vis-perf-i9-12900k-1" ]'
      artifact-in: perf-linux-x86-ICX-ISPC-build
      setup-benny: true
      cmd: |
        cd build
        tar -xzf embree-?.?.?.x86_64.linux.tar.gz
        cd bin
        $GITHUB_WORKSPACE/scripts/run-perf.sh cpu


  perf-linux-x8380-1-test:
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/perf.yml@main
    needs: ["perf-linux-x86-ICX-ISPC-build"]
    with:
      runs-on: '[ "Linux", "perf", "vis-perf-x8380-1" ]'
      artifact-in: perf-linux-x86-ICX-ISPC-build
      setup-benny: true
      cmd: |
        cd build
        tar -xzf embree-?.?.?.x86_64.linux.tar.gz
        cd bin
        $GITHUB_WORKSPACE/scripts/run-perf.sh cpu


  perf-linux-x8280-1-test:
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/perf.yml@main
    needs: ["perf-linux-x86-ICX-ISPC-build"]
    with:
      runs-on: '[ "Linux", "perf", "vis-perf-x8280-1" ]'
      artifact-in: perf-linux-x86-ICX-ISPC-build
      setup-benny: true
      cmd: |
        cd build
        tar -xzf embree-?.?.?.x86_64.linux.tar.gz
        cd bin
        $GITHUB_WORKSPACE/scripts/run-perf.sh cpu


  perf-linux-a3970x-1-test:
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/perf.yml@main
    needs: ["perf-linux-x86-ICX-ISPC-build"]
    with:
      runs-on: '[ "Linux", "perf", "vis-perf-a3970x-1" ]'
      artifact-in: perf-linux-x86-ICX-ISPC-build
      setup-benny: true
      cmd: |
        cd build
        tar -xzf embree-?.?.?.x86_64.linux.tar.gz
        cd bin
        $GITHUB_WORKSPACE/scripts/run-perf.sh cpu

  linux-DG2-A770-buildbench:
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    needs: ["perf-linux-SYCL-DPCPP-build"]
    with:
      image: embree/ubuntu:22.04
      options: --device=/dev/dri:/dev/dri
      runs-on: '[ "Linux", "docker", "dg2", "perf", "A770" ]'
      project: embree
      env-from-files: ./.github/workflows/dpcpp-none.env ./.github/workflows/gfx-ubuntu22-public.env
      artifact-in: perf-linux-SYCL-DPCPP
      setup-benny: true
      cmd: |
        cd build
        ls *.tar.gz
        tar -xzf embree-?.?.?.sycl.x86_64.linux.tar.gz
        git clone https://github.com/intel-innersource/libraries.graphics.renderkit.embree.models.git embree-models
        ls -al
        source embree-vars.sh
        echo "bin/embree_buildbench --legacy"
        bin/embree_buildbench --legacy
        echo "bin/embree_buildbench_sycl --legacy"
        bin/embree_buildbench_sycl --legacy
        echo "bin/embree_buildbench --legacy -c embree-models/crown/crown.ecs"
        bin/embree_buildbench --legacy -c embree-models/crown/crown.ecs
        echo "bin/embree_buildbench_sycl --legacy -c embree-models/crown/crown.ecs"
        bin/embree_buildbench_sycl --legacy -c embree-models/crown/crown.ecs