.common-setup:
  stage: test
  before_script:
    - if [ ${CI_PIPELINE_SOURCE} == "schedule" ]; then
        export CDASH_MODEL="Nightly";
        export BUILD_TYPE="Debug";
      elif [ ${CI_COMMIT_REF_NAME} == "develop" ]; then
        export CDASH_MODEL="Continuous";
        export BUILD_TYPE="Release";
      else
        export CDASH_MODEL="Experimental";
        export BUILD_TYPE="RelWithDebInfo";
        export GITHUB_PR_ID=$(echo ${CI_COMMIT_BRANCH} | cut -d \_ -f 1 | cut -c 3-);
      fi

NVIDIA-RTX5080:
  extends: .common-setup
  tags: [nvidia-rtx5080, hpsf-gpu]
  image: nvcr.io/nvidia/cuda:12.8.0-devel-ubuntu24.04
  script:
    - apt-get update && apt-get install -y cmake git python3
    - export CMAKE_BUILD_PARALLEL_LEVEL=32
    - export ENV_CMAKE_OPTIONS=""
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D CMAKE_BUILD_TYPE=${BUILD_TYPE}"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D CMAKE_CXX_COMPILER=`pwd`/bin/nvcc_wrapper"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D CMAKE_CXX_FLAGS='-Werror=all-warnings -Werror'"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D CMAKE_CXX_STANDARD=20"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ARCH_BLACKWELL120=ON"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ENABLE_CUDA=ON;"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ENABLE_COMPILER_WARNINGS=ON;"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ENABLE_TESTS=ON"
    - export CTEST_BUILD_NAME="NVIDIA-RTX5080"
    - ctest -VV
        -D CDASH_MODEL=${CDASH_MODEL}
        -D GITHUB_PR_ID="${GITHUB_PR_ID}"
        -D CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS}"
        -D OUTPUT_JUNIT_FILE=result_rtx5080.xml
        -S scripts/CTestRun.cmake
        -D CTEST_SITE="gitlab.spack.io"
        -D CTEST_BUILD_NAME="${CTEST_BUILD_NAME}"
  artifacts:
    when: always
    paths:
      - build/result_rtx5080.xml
    reports:
      junit: build/result_rtx5080.xml

NVIDIA-GH200:
  extends: .common-setup
  tags: [nvidia-gh200]
  image: nvcr.io/nvidia/cuda:13.0.2-devel-ubuntu24.04
  script:
    - apt-get update && apt-get install -y cmake git python3
    - export CMAKE_BUILD_PARALLEL_LEVEL=48
    - export ENV_CMAKE_OPTIONS=""
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D CMAKE_BUILD_TYPE=${BUILD_TYPE}"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D CMAKE_CXX_COMPILER=`pwd`/bin/nvcc_wrapper"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D CMAKE_CXX_FLAGS='-Werror=all-warnings -Werror'"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D CMAKE_CXX_STANDARD=20"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ENABLE_DEBUG=ON"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ENABLE_DEBUG_BOUNDS_CHECK=ON"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ARCH_NATIVE=ON"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ARCH_HOPPER90=ON"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ENABLE_CUDA=ON"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ENABLE_OPENMP=ON"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ENABLE_COMPILER_WARNINGS=ON"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ENABLE_IMPL_CUDA_UNIFIED_MEMORY=ON"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ENABLE_LARGE_MEM_TESTS=ON"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ENABLE_LIBDL=OFF"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ENABLE_TESTS=ON"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ENABLE_BENCHMARKS=ON"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ENABLE_IMPL_CUDA_MALLOC_ASYNC=ON"
    - export CTEST_BUILD_NAME="NVIDIA-GH200"
    - ctest -VV
        -D CDASH_MODEL=${CDASH_MODEL}
        -D GITHUB_PR_ID="${GITHUB_PR_ID}"
        -D CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS}"
        -D OUTPUT_JUNIT_FILE=result_gh200.xml
        -S scripts/CTestRun.cmake
        -D CTEST_SITE="gitlab.spack.io"
        -D CTEST_BUILD_NAME="${CTEST_BUILD_NAME}"
  artifacts:
    when: always
    paths:
      - build/result_gh200.xml
    reports:
      junit: build/result_gh200.xml

NVIDIA-P100:
  extends: .common-setup
  tags: [nvidia-p100]
  image: nvcr.io/nvidia/cuda:12.3.2-devel-ubuntu22.04
  script:
    - apt-get update && apt-get install -y cmake git python3
    - export CMAKE_BUILD_PARALLEL_LEVEL=48
    - export ENV_CMAKE_OPTIONS=""
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D CMAKE_BUILD_TYPE=${BUILD_TYPE}"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D CMAKE_CXX_COMPILER=`pwd`/bin/nvcc_wrapper"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D CMAKE_CXX_FLAGS='-Werror=all-warnings -Werror'"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D CMAKE_CXX_STANDARD=20"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ARCH_PASCAL60=ON"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ENABLE_CUDA=ON"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ENABLE_COMPILER_WARNINGS=ON"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ENABLE_TESTS=ON"
    - export CTEST_BUILD_NAME="NVIDIA-P100"
    - ctest -VV
        -D CDASH_MODEL=${CDASH_MODEL}
        -D GITHUB_PR_ID="${GITHUB_PR_ID}"
        -D CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS}"
        -D OUTPUT_JUNIT_FILE=result_p100.xml
        -S scripts/CTestRun.cmake
        -D CTEST_SITE="gitlab.spack.io"
        -D CTEST_BUILD_NAME="${CTEST_BUILD_NAME}"
  artifacts:
    when: always
    paths:
      - build/result_p100.xml
    reports:
      junit: build/result_p100.xml

INTEL-DATA-CENTER-MAX-1100:
  extends: .common-setup
  tags: [intel-data-center-max-1100]
  image: intel/oneapi-basekit:2024.2.1-0-devel-ubuntu22.04
  script:
    - apt-get update && apt-get install -y git
    - sycl-ls
    - export ONEAPI_DEVICE_SELECTOR=level_zero:gpu
    - export CLANG_TIDY_EXE=$(dirname $(which icpx))/compiler/clang-tidy
    - export CMAKE_BUILD_PARALLEL_LEVEL=48
    - export ENV_CMAKE_OPTIONS=""
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D CMAKE_BUILD_TYPE=${BUILD_TYPE}"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D CMAKE_CXX_CLANG_TIDY='${CLANG_TIDY_EXE}\;-warnings-as-errors=*\;--checks=-bugprone-reserved-identifier'"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D CMAKE_CXX_COMPILER=icpx"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D CMAKE_CXX_FLAGS='-Wno-zero-length-array -Werror -fsycl-device-code-split=per_kernel -fp-model=precise'"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D CMAKE_CXX_STANDARD=20"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D CMAKE_EXE_LINKER_FLAGS=-fsycl -flink-huge-device-code"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D CMAKE_VERBOSE_MAKEFILE=ON"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ENABLE_SYCL=ON"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ARCH_INTEL_PVC=ON"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ENABLE_LARGE_MEM_TESTS=ON"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ENABLE_TESTS=ON"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ENABLE_COMPILER_WARNINGS=ON"
    - export CTEST_BUILD_NAME="INTEL-DATA-CENTER-MAX-1100"
    - ctest -VV
        -D CDASH_MODEL=${CDASH_MODEL}
        -D GITHUB_PR_ID="${GITHUB_PR_ID}"
        -D CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS}"
        -D OUTPUT_JUNIT_FILE=result_pvc1100.xml
        -S scripts/CTestRun.cmake
        -D CTEST_SITE="gitlab.spack.io"
        -D CTEST_BUILD_NAME="${CTEST_BUILD_NAME}"
  artifacts:
    when: always
    paths:
      - build/result_pvc1100.xml
    reports:
      junit: build/result_pvc1100.xml

INTEL-DATA-CENTER-MAX-1100-OUT-OF-ORDER:
  extends: .common-setup
  tags: [intel-data-center-max-1100]
  image: intel/oneapi-basekit:2024.2.1-0-devel-ubuntu22.04
  script:
    - apt-get update && apt-get install -y git
    - sycl-ls
    - export ONEAPI_DEVICE_SELECTOR=level_zero:gpu
    - export CLANG_TIDY_EXE=$(dirname $(which icpx))/compiler/clang-tidy
    - export CMAKE_BUILD_PARALLEL_LEVEL=48
    - export ENV_CMAKE_OPTIONS=""
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D CMAKE_BUILD_TYPE=${BUILD_TYPE}"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D CMAKE_CXX_COMPILER=icpx"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D CMAKE_CXX_FLAGS='-Wno-zero-length-array -Werror -fsycl-device-code-split=per_kernel -fp-model=precise'"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D CMAKE_CXX_STANDARD=20"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D CMAKE_EXE_LINKER_FLAGS=-fsycl -flink-huge-device-code"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D CMAKE_VERBOSE_MAKEFILE=ON"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ENABLE_SYCL=ON"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ENABLE_IMPL_SYCL_OUT_OF_ORDER_QUEUES=ON"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ARCH_INTEL_PVC=ON"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ENABLE_TESTS=ON"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ENABLE_COMPILER_WARNINGS=ON"
    - export CTEST_BUILD_NAME="INTEL-DATA-CENTER-MAX-1100-OUT-ORDER"
    - ctest -VV
        -D CDASH_MODEL=${CDASH_MODEL}
        -D GITHUB_PR_ID="${GITHUB_PR_ID}"
        -D CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS}"
        -D OUTPUT_JUNIT_FILE=result_pvc1100_out_of_order.xml
        -S scripts/CTestRun.cmake
        -D CTEST_SITE="gitlab.spack.io"
        -D CTEST_BUILD_NAME="${CTEST_BUILD_NAME}"
  artifacts:
    when: always
    paths:
      - build/result_pvc1100_out_of_order.xml
    reports:
      junit: build/result_pvc1100_out_of_order.xml

AMD-MI300A:
  extends: .common-setup
  tags: [uo-gpu, odyssey, amd-mi300]
  image: rocm/dev-ubuntu-24.04:6.2.4-complete
  script:
    - apt-get update && apt-get install -y cmake git
    - export CMAKE_BUILD_PARALLEL_LEVEL=48
    - export ENV_CMAKE_OPTIONS=""
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D CMAKE_PREFIX_PATH=/opt/rocm-6.2.4"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D CMAKE_BUILD_TYPE=${BUILD_TYPE}"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D CMAKE_CXX_COMPILER=hipcc"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D CMAKE_CXX_FLAGS='-Werror'"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D CMAKE_CXX_STANDARD=20"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ENABLE_HIP=ON"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ARCH_AMD_GFX942_APU=ON"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ARCH_ZEN4=ON"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ENABLE_LARGE_MEM_TESTS=ON"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ENABLE_TESTS=ON"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ENABLE_COMPILER_WARNINGS=ON"
    - export CTEST_BUILD_NAME="AMD-MI300A"
    - export HSA_XNACK=1
    - export KOKKOS_DEVICE_ID=3
    - ctest -VV
      -D CDASH_MODEL=${CDASH_MODEL}
      -D GITHUB_PR_ID="${GITHUB_PR_ID}"
      -D CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS}"
      -D OUTPUT_JUNIT_FILE=result_mi300a.xml
      -S scripts/CTestRun.cmake
      -D CTEST_SITE="gitlab.spack.io"
      -D CTEST_BUILD_NAME="${CTEST_BUILD_NAME}"
  artifacts:
    when: always
    paths:
      - build/result_mi300a.xml
    reports:
      junit: build/result_mi300a.xml

NVIDIA-GRACE-GRACE:
  extends: .common-setup
  tags: [grace, hpsf-neoverse_v2, hpsf-aarch64]
  image: ubuntu:latest
  script:
    - apt-get update && apt-get install -y cmake git g++
    - export OMP_NUM_THREADS=8
    - export OMP_PROC_BIND=close
    - export OMP_PLACES=cores
    - export CMAKE_BUILD_PARALLEL_LEVEL=48
    - export ENV_CMAKE_OPTIONS=""
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D CMAKE_BUILD_TYPE=${BUILD_TYPE}"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D CMAKE_CXX_COMPILER=g++"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D CMAKE_CXX_FLAGS='-Werror'"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D CMAKE_CXX_STANDARD=20"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ENABLE_OPENMP=ON"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ARCH_ARMV9_GRACE=ON"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ENABLE_TESTS=ON"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ENABLE_COMPILER_WARNINGS=ON"
    - export ENV_CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS};-D Kokkos_ENABLE_DEPRECATED_CODE_5=OFF"
    - export CTEST_BUILD_NAME="NVIDIA-GRACE-GRACE"
    - ctest -VV
        -D CDASH_MODEL=${CDASH_MODEL}
        -D GITHUB_PR_ID="${GITHUB_PR_ID}"
        -D CMAKE_OPTIONS="${ENV_CMAKE_OPTIONS}"
        -D OUTPUT_JUNIT_FILE=result_grace_grace.xml
        -S scripts/CTestRun.cmake
        -D CTEST_SITE="gitlab.spack.io"
        -D CTEST_BUILD_NAME="${CTEST_BUILD_NAME}"
  artifacts:
    when: always
    paths:
      - build/result_grace_grace.xml
    reports:
      junit: build/result_grace_grace.xml
