

.slurm_p9_cuda: &slurm_p9_cuda
    tags:
        - nmc
        - slurm
        - nmc-xxfe1-sched-001
        - xx-fe1
    variables:
        NMC_FE1_SLURM_PARAMETERS: " -N1 -p ecp-p9-4v100 --extra-node-info=*:*:* -t 1:30:00 "
        CC: "gcc"
        CXX: "g++"
        CUDAHOSTCXX: "g++"
    before_script:
        # We need gcc-4.8.5, which is the system default compiler but not a compiler
        # listed under the module system.
        #
        # That means to get this to work properly we explicitly do not request
        # any compiler.
        - module load cuda cmake/3.14.5


.slurm_p9_opemp: &slurm_p9_opemp
    tags:
        - nmc
        - slurm
        - nmc-xxfe1-sched-001
        - xx-fe1
    variables:
        NMC_FE1_SLURM_PARAMETERS: " -N1 -p ecp-p9-4v100 --extra-node-info=*:*:* -t 1:30:00 "
    before_script:
        - module load gcc/8.3.0 openmpi/3.1.4 cmake/3.14.5

.cmake_build_artifacts: &cmake_build_artifacts
    artifacts:
        expire_in: 24 hours
        when: always
        paths:
            # The artifacts of the build.
            - vtkm-build/bin/
            - vtkm-build/include/

            # CTest files.
            # XXX(globbing): Can be simplified with support from
            # https://gitlab.com/gitlab-org/gitlab-runner/issues/4840
            - vtkm-build/CTestCustom*.cmake
            - vtkm-build/CTestTestfile.cmake
            - vtkm-build/*/CTestTestfile.cmake
            - vtkm-build/*/*/CTestTestfile.cmake
            - vtkm-build/*/*/*/CTestTestfile.cmake
            - vtkm-build/*/*/*/*/CTestTestfile.cmake
            - vtkm-build/*/*/*/*/*/CTestTestfile.cmake
            - vtkm-build/Testing/

            # CDash files.
            - vtkm-build/DartConfiguration.tcl

.cmake_build_p9_cuda: &cmake_build_p9_cuda
    stage: build
    script:
        - srun env | grep SLURM_JOB_NAME
        - mkdir vtkm-build
        - pushd vtkm-build
        - cmake -DCMAKE_BUILD_TYPE=Release -DVTKm_ENABLE_CUDA=ON -S ../
        - cmake --build . -j20
        - popd

.cmake_build_p9_openmp: &cmake_build_p9_openmp
    stage: build
    script:
        - srun env | grep SLURM_JOB_NAME
        - mkdir vtkm-build
        - pushd vtkm-build
        - cmake -DCMAKE_BUILD_TYPE=Release -DVTKm_ENABLE_OPENMP=ON -S ../
        - cmake --build . -j20
        - popd



.cmake_test_p9: &cmake_test_p9
    stage: test
    script:
        - echo "running the test using artifacts of the build"
        - pushd vtkm-build
        # We need to exclude the following tests
        #   - CopyrightStatement
        #   - TestInstallSetup
        #   - SourceInInstall
        # Which we can do by using an exclude regex
        - ctest -E "Install|CopyrightStatement"
        - popd

stages:
    - build
    - test

build:p9_openmp:
    extends:
        - .slurm_p9_opemp
        - .cmake_build_artifacts
        - .cmake_build_p9_openmp

test:p9_openmp:
    extends:
        - .slurm_p9_opemp
        - .cmake_test_p9
    dependencies:
        - build:p9_openmp
    needs:
        - build:p9_openmp

build:p9_cuda:
    extends:
        - .slurm_p9_cuda
        - .cmake_build_artifacts
        - .cmake_build_p9_cuda

test:p9_cuda:
    extends:
        - .slurm_p9_cuda
        - .cmake_test_p9
    dependencies:
        - build:p9_cuda
    needs:
        - build:p9_cuda
