build:ubuntu2004_gcc9:
  tags:
    - build
    - vtkm
    - docker
    - linux
  extends:
    - .ubuntu2004
    - .cmake_build_linux
    - .run_automatically
  variables:
    CMAKE_BUILD_TYPE: Debug
    VTKM_SETTINGS: "benchmarks+tbb+openmp+mpi+shared+hdf5+min_build"

test:ubuntu2004_gcc9:
  tags:
    - test
    - vtkm
    - docker
    - linux
  extends:
    - .ubuntu2004
    - .cmake_test_linux
    - .run_automatically
  variables:
    #Restrict OpenMP number of threads since multiple test stages
    #execute on the same hardware concurrently
    OMP_NUM_THREADS: 4
  dependencies:
    - build:ubuntu2004_gcc9
  needs:
    - build:ubuntu2004_gcc9

build:ubuntu2004_kokkos:
  tags:
    - build
    - vtkm
    - docker
    - linux
  extends:
    - .ubuntu2004_kokkos
    - .cmake_build_linux
    - .run_automatically
  variables:
    CMAKE_BUILD_TYPE: RelWithDebInfo
    VTKM_SETTINGS: "kokkos+shared+64bit_floats"

test:ubuntu2004_kokkos:
  tags:
    - test
    - vtkm
    - docker
    - linux
  extends:
    - .ubuntu2004_kokkos
    - .cmake_test_linux
    - .run_automatically
  dependencies:
    - build:ubuntu2004_kokkos
  needs:
    - build:ubuntu2004_kokkos

build:ubuntu2004_hip_kokkos:
  tags:
    - build
    - vtkm
    - docker
    - radeon
  extends:
    - .ubuntu2004_hip_kokkos
    - .cmake_build_linux
    - .run_automatically
  variables:
    CMAKE_BUILD_TYPE:        "RelWithDebInfo"
    VTKM_SETTINGS:           "benchmarks+kokkos+hip+no_rendering+ccache"

    CMAKE_PREFIX_PATH:       "/opt/rocm/lib/cmake"
    LD_LIBRARY_PATH:         "/opt/rocm/lib"
    CMAKE_HIP_COMPILER:      "/opt/rocm/llvm/bin/clang++"
    Kokkos_CXX_COMPILER:     "/opt/rocm/llvm/bin/clang++"
    CMAKE_HIP_ARCHITECTURES: "gfx900"

    # -isystem= is not affected by CCACHE_BASEDIR, thus we must ignore it
    CCACHE_IGNOREOPTIONS:    "-isystem=*"
    CCACHE_BASEDIR:          "$CI_PROJECT_DIR"
    CCACHE_COMPILERCHECK:    "content"
    CCACHE_NOHASHDIR:        "true"
    CCACHE_RESHARE:          "true"
  after_script:
    - ccache -v -s
    - ccache -z

test:ubuntu2004_hip_kokkos:
  tags:
    - build
    - vtkm
    - docker
    - radeon
  extends:
    - .ubuntu2004_hip_kokkos
    - .cmake_test_linux
    - .run_upstream_branches
  variables:
    CTEST_MAX_PARALLELISM: 1
  dependencies:
    - build:ubuntu2004_hip_kokkos
  needs:
    - build:ubuntu2004_hip_kokkos
  timeout: 3 hours

# This is only for merge-requests
build:ascent:
  stage: build
  variables:
    BRANCH_NAME:     "mr${CI_MERGE_REQUEST_IID}-${CI_COMMIT_REF_NAME}"
    ASCENT_REST_URL: "https://code.ornl.gov/api/v4/projects/7035"
    ASCENT_GIT_URL:  "https://vbolea:${ECPTEST_TOKEN}@code.ornl.gov/ecpcitest/vtk-m.git"
  tags:
    - vtkm
    - docker
  extends:
    - .ubuntu2004
    - .run_only_merge_requests
  script:
    # A new commit is needed to symbolize a restart of a build from the same original commit
    - .gitlab/ci/config/ecpci-amend-commit.sh "NEW_COMMIT_SHA"
    - .gitlab/ci/config/ecpci-push-branch.sh "$ASCENT_GIT_URL" "$BRANCH_NAME"
    - timeout 130m .gitlab/ci/config/ecpci-wait-commit-status.sh "$ASCENT_REST_URL" "$(cat NEW_COMMIT_SHA)"
  after_script:
    - .gitlab/ci/config/ecpci-remove-branch.sh "$ASCENT_GIT_URL" "$BRANCH_NAME" || true
    - .gitlab/ci/config/ecpci-fetch-commit-trace.py "$ASCENT_REST_URL" "$(cat NEW_COMMIT_SHA)" "$ECPTEST_TOKEN"
  timeout: 150 minutes
  interruptible: true
