###############################################################################
##                                                                           ##
##    General settings                                                       ##
##                                                                           ##
###############################################################################

stages:
   - pretest
   - test
   - deploy
   - benchmark


###############################################################################
##                                                                           ##
##    Build templates                                                        ##
##                                                                           ##
###############################################################################

.build_template:
   script:
      - export NUM_CORES=$(nproc --all)
      - export MAX_BUILD_CORES=$(( $(awk '( $1 == "MemTotal:" ) { print $2 }' /proc/meminfo) / ( 4 * 1024 * 1024  ) ))
      - "[[ $MAX_BUILD_CORES -lt $NUM_CORES ]] && export NUM_BUILD_CORES=$MAX_BUILD_CORES || export NUM_BUILD_CORES=$NUM_CORES"
      - $CXX --version
      - cmake --version
      - ccache --version
      - mpirun --version
      - python3 --version
      - python3 python/mesa_pd.py -y .
      - export CCACHE_BASEDIR=$CI_PROJECT_DIR
      - mkdir $CI_PROJECT_DIR/build
      - cd $CI_PROJECT_DIR/build
      - if dpkg --compare-versions `ompi_info | head -2 | tail -1 | sed 's/[^0-9.]*\([0-9.]*\).*/\1/'` ge 1.10; then export MPIEXEC_PREFLAGS="--allow-run-as-root" ; fi
      - cmake ..
        -DWALBERLA_BUFFER_DEBUG=$WALBERLA_BUFFER_DEBUG
        -DWALBERLA_BUILD_TESTS=ON
        -DWALBERLA_BUILD_BENCHMARKS=ON
        -DWALBERLA_BUILD_TUTORIALS=ON
        -DWALBERLA_BUILD_TOOLS=ON
        -DWALBERLA_BUILD_WITH_MPI=$WALBERLA_BUILD_WITH_MPI
        -DWALBERLA_BUILD_WITH_CUDA=$WALBERLA_BUILD_WITH_CUDA
        -DWALBERLA_BUILD_WITH_PYTHON=$WALBERLA_BUILD_WITH_PYTHON
        -DWALBERLA_BUILD_WITH_OPENMP=$WALBERLA_BUILD_WITH_OPENMP
        -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -DMPIEXEC_PREFLAGS=$MPIEXEC_PREFLAGS
        -DWALBERLA_DOUBLE_ACCURACY=$WALBERLA_DOUBLE_ACCURACY
        -DWARNING_ERROR=ON
        -DWALBERLA_BUILD_WITH_METIS=$WALBERLA_BUILD_WITH_METIS
        -DWALBERLA_BUILD_WITH_PARMETIS=$WALBERLA_BUILD_WITH_PARMETIS
        -DWALBERLA_ENABLE_GUI=$WALBERLA_ENABLE_GUI
        -DWALBERLA_BUILD_WITH_CODEGEN=$WALBERLA_BUILD_WITH_CODEGEN
        -DWALBERLA_STL_BOUNDS_CHECKS=$WALBERLA_STL_BOUNDS_CHECKS
      - cmake . -LA
      - make -j $NUM_BUILD_CORES -l $NUM_CORES
      - ctest -LE $CTEST_EXCLUDE_LABELS -C $CMAKE_BUILD_TYPE --output-on-failure -j $NUM_CORES
   tags:
      - docker
   variables:
      CTEST_EXCLUDE_LABELS: "longrun"
      WALBERLA_BUILD_WITH_MPI: "ON"
      WALBERLA_BUILD_WITH_OPENMP: "ON"
      OMP_NUM_THREADS: "4"
      OMP_WAIT_POLICY: "PASSIVE"
      CMAKE_BUILD_TYPE: "Release"
      WALBERLA_BUFFER_DEBUG: "OFF"
      WALBERLA_DOUBLE_ACCURACY: "ON"
      WALBERLA_BUILD_WITH_METIS: "ON"
      WALBERLA_BUILD_WITH_PARMETIS: "ON"
      WALBERLA_ENABLE_GUI: "OFF"


###############################################################################
##                                                                           ##
##    Linux builds                                                           ##
##                                                                           ##
###############################################################################



intel_19_serial:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/intel:19
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      WALBERLA_BUILD_WITH_MPI: "OFF"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_PARMETIS: "OFF"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker
      - intel

intel_19_mpionly:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/intel:19
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker
      - intel

intel_19_hybrid:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/intel:19
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   tags:
      - cuda
      - docker
      - intel

intel_19_serial_dbg:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/intel:19
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      WALBERLA_BUILD_WITH_MPI: "OFF"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_PARMETIS: "OFF"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   tags:
      - cuda
      - docker
      - intel

intel_19_mpionly_dbg:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/intel:19
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   tags:
      - cuda
      - docker
      - intel

intel_19_hybrid_dbg:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/intel:19
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   tags:
      - cuda
      - docker
      - intel

intel_19_hybrid_dbg_sp:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/intel:19
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_DOUBLE_ACCURACY: "OFF"
      WALBERLA_BUILD_WITH_PARMETIS: "OFF"
      WALBERLA_BUILD_WITH_METIS: "OFF"
   tags:
      - cuda
      - docker
      - intel

gcc_7_serial:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:7
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      WALBERLA_BUILD_WITH_MPI: "OFF"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_PARMETIS: "OFF"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

gcc_7_mpionly:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:7
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

gcc_7_hybrid:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:7
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

gcc_7_serial_dbg:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:7
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      WALBERLA_BUILD_WITH_MPI: "OFF"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_PARMETIS: "OFF"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_ENABLE_GUI: "ON"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

gcc_7_mpionly_dbg:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:7
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

gcc_7_hybrid_dbg:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:7
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   tags:
      - cuda
      - docker

gcc_7_hybrid_dbg_sp:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:7
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_DOUBLE_ACCURACY: "OFF"
      WALBERLA_BUILD_WITH_PARMETIS: "OFF"
      WALBERLA_BUILD_WITH_METIS: "OFF"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

gcc_8_serial:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:8
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      WALBERLA_BUILD_WITH_MPI: "OFF"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_PARMETIS: "OFF"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

gcc_8_mpionly:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:8
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

gcc_8_hybrid:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:8
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

gcc_8_serial_dbg:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:8
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      WALBERLA_BUILD_WITH_MPI: "OFF"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_PARMETIS: "OFF"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

gcc_8_mpionly_dbg:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:8
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

gcc_8_hybrid_dbg:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:8
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

gcc_8_hybrid_dbg_sp:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:8
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_DOUBLE_ACCURACY: "OFF"
      WALBERLA_BUILD_WITH_PARMETIS: "OFF"
      WALBERLA_BUILD_WITH_METIS: "OFF"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

gcc_9_serial:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:9
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
   variables:
      WALBERLA_BUILD_WITH_CUDA: "OFF"
      WALBERLA_BUILD_WITH_MPI: "OFF"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_PARMETIS: "OFF"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - docker

gcc_9_mpionly:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:9
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
   variables:
      WALBERLA_BUILD_WITH_CUDA: "OFF"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - docker

gcc_9_hybrid:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:9
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
   variables:
      WALBERLA_BUILD_WITH_CUDA: "OFF"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - docker

gcc_9_serial_dbg:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:9
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
   variables:
      WALBERLA_BUILD_WITH_CUDA: "OFF"
      WALBERLA_BUILD_WITH_MPI: "OFF"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_PARMETIS: "OFF"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - docker

gcc_9_mpionly_dbg:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:9
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
   variables:
      WALBERLA_BUILD_WITH_CUDA: "OFF"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - docker

gcc_9_hybrid_dbg:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:9
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
   variables:
      WALBERLA_BUILD_WITH_CUDA: "OFF"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - docker

gcc_9_hybrid_dbg_sp:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:9
   variables:
      WALBERLA_BUILD_WITH_CUDA: "OFF"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_DOUBLE_ACCURACY: "OFF"
      WALBERLA_BUILD_WITH_PARMETIS: "OFF"
      WALBERLA_BUILD_WITH_METIS: "OFF"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - docker

gcc_10_serial:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:10
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
   variables:
      WALBERLA_BUILD_WITH_CUDA: "OFF"
      WALBERLA_BUILD_WITH_MPI: "OFF"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_PARMETIS: "OFF"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - docker

gcc_10_mpionly:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:10
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
   variables:
      WALBERLA_BUILD_WITH_CUDA: "OFF"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - docker

gcc_10_hybrid:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:10
   stage: pretest
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
   variables:
      WALBERLA_BUILD_WITH_CUDA: "OFF"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   tags:
      - docker

gcc_10_serial_dbg:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:10
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
   variables:
      WALBERLA_BUILD_WITH_CUDA: "OFF"
      WALBERLA_BUILD_WITH_MPI: "OFF"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_PARMETIS: "OFF"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   tags:
      - docker

gcc_10_mpionly_dbg:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:10
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
   variables:
      WALBERLA_BUILD_WITH_CUDA: "OFF"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   tags:
      - docker

gcc_10_hybrid_dbg:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:10
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
   variables:
      WALBERLA_BUILD_WITH_CUDA: "OFF"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   tags:
      - docker

gcc_10_hybrid_dbg_sp:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:10
   variables:
      WALBERLA_BUILD_WITH_CUDA: "OFF"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_DOUBLE_ACCURACY: "OFF"
      WALBERLA_BUILD_WITH_PARMETIS: "OFF"
      WALBERLA_BUILD_WITH_METIS: "OFF"
   tags:
      - docker

clang_6.0_serial:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:6.0
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      WALBERLA_BUILD_WITH_MPI: "OFF"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_PARMETIS: "OFF"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

clang_6.0_mpionly:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:6.0
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

clang_6.0_hybrid:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:6.0
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

clang_6.0_serial_dbg:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:6.0
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      WALBERLA_BUILD_WITH_MPI: "OFF"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_PARMETIS: "OFF"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

clang_6.0_mpionly_dbg:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:6.0
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

clang_6.0_hybrid_dbg:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:6.0
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   tags:
      - cuda
      - docker

clang_6.0_hybrid_dbg_sp:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:6.0
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_DOUBLE_ACCURACY: "OFF"
      WALBERLA_BUILD_WITH_PARMETIS: "OFF"
      WALBERLA_BUILD_WITH_METIS: "OFF"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

clang_7.0_serial:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:7.0
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      WALBERLA_BUILD_WITH_MPI: "OFF"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_PARMETIS: "OFF"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

clang_7.0_mpionly:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:7.0
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

clang_7.0_hybrid:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:7.0
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

clang_7.0_serial_dbg:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:7.0
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      WALBERLA_BUILD_WITH_MPI: "OFF"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_PARMETIS: "OFF"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

clang_7.0_mpionly_dbg:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:7.0
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

clang_7.0_hybrid_dbg:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:7.0
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

clang_7.0_hybrid_dbg_sp:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:7.0
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_DOUBLE_ACCURACY: "OFF"
      WALBERLA_BUILD_WITH_PARMETIS: "OFF"
      WALBERLA_BUILD_WITH_METIS: "OFF"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

clang_8.0_serial:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:8.0
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      WALBERLA_BUILD_WITH_MPI: "OFF"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_PARMETIS: "OFF"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

clang_8.0_mpionly:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:8.0
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

clang_8.0_hybrid:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:8.0
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

clang_8.0_serial_dbg:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:8.0
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      WALBERLA_BUILD_WITH_MPI: "OFF"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_PARMETIS: "OFF"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

clang_8.0_mpionly_dbg:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:8.0
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

clang_8.0_hybrid_dbg:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:8.0
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

clang_8.0_hybrid_dbg_sp:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:8.0
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_DOUBLE_ACCURACY: "OFF"
      WALBERLA_BUILD_WITH_PARMETIS: "OFF"
      WALBERLA_BUILD_WITH_METIS: "OFF"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

clang_9.0_serial:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:9.0
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      WALBERLA_BUILD_WITH_MPI: "OFF"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_PARMETIS: "OFF"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

clang_9.0_mpionly:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:9.0
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

clang_9.0_hybrid:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:9.0
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

clang_9.0_serial_dbg:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:9.0
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      WALBERLA_BUILD_WITH_MPI: "OFF"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_PARMETIS: "OFF"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

clang_9.0_mpionly_dbg:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:9.0
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

clang_9.0_hybrid_dbg:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:9.0
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

clang_9.0_hybrid_dbg_sp:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:9.0
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_DOUBLE_ACCURACY: "OFF"
      WALBERLA_BUILD_WITH_PARMETIS: "OFF"
      WALBERLA_BUILD_WITH_METIS: "OFF"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

clang_10.0_serial:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:10.0
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      WALBERLA_BUILD_WITH_MPI: "OFF"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_PARMETIS: "OFF"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

clang_10.0_mpionly:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:10.0
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   
   tags:
      - cuda
      - docker

clang_10.0_hybrid:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:10.0
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   tags:
      - cuda
      - docker

clang_10.0_serial_dbg:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:10.0
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      WALBERLA_BUILD_WITH_MPI: "OFF"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_PARMETIS: "OFF"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   tags:
      - cuda
      - docker

clang_10.0_mpionly_dbg:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:10.0
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   tags:
      - cuda
      - docker

clang_10.0_hybrid_dbg:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:10.0
   before_script:
      - pip3 install lbmpy jinja2
      - cd python
      - python3 -m unittest discover pystencils_walberla/
      - python3 -m unittest discover lbmpy_walberla/
      - cd ..
      - CC=gcc CXX=g++ pip3 install pycuda
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_BUILD_WITH_CODEGEN: "ON"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
   tags:
      - cuda
      - docker

clang_10.0_hybrid_dbg_sp:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:10.0
   stage: pretest
   variables:
      WALBERLA_BUILD_WITH_CUDA: "ON"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_DOUBLE_ACCURACY: "OFF"
      WALBERLA_BUILD_WITH_PARMETIS: "OFF"
      WALBERLA_BUILD_WITH_METIS: "OFF"
   tags:
      - cuda
      - docker



gcc_8_hybrid_dbg_noboost:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:8
   before_script:
      - rm -rf /opt/boost /usr/include/boost
   variables:
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_BUILD_WITH_CUDA: "OFF"
      WALBERLA_ENABLE_GUI: "OFF"
      WALBERLA_BUILD_WITH_PYTHON: "OFF"
   tags:
      - docker



###############################################################################
##                                                                           ##
##    STL Debug Build                                                        ##
##                                                                           ##
###############################################################################

gcc_10_stl_debug:
   extends: .build_template
   image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc-debug-stl:10
   before_script:
      - rm -rf /opt/boost /usr/include/boost
   variables:
      CTEST_EXCLUDE_LABELS: "longrun"
      WALBERLA_BUILD_WITH_MPI: "ON"
      WALBERLA_BUILD_WITH_OPENMP: "ON"
      OMP_NUM_THREADS: "4"
      OMP_WAIT_POLICY: "PASSIVE"
      CMAKE_BUILD_TYPE: "DebugOptimized"
      WALBERLA_BUFFER_DEBUG: "OFF"
      WALBERLA_DOUBLE_ACCURACY: "ON"
      WALBERLA_BUILD_WITH_CUDA: "OFF"
      WALBERLA_BUILD_WITH_METIS: "OFF"
      WALBERLA_BUILD_WITH_PARMETIS: "OFF"
      WALBERLA_BUILD_WITH_PYTHON: "OFF"
      WALBERLA_STL_BOUNDS_CHECKS: "ON"
   tags:
      - docker



###############################################################################
##                                                                           ##
##    Documentation                                                         ##
##                                                                           ##
###############################################################################

doc:
   image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:9
   script:
      - cmake --version
      - doxygen --version
      - mkdir $CI_PROJECT_DIR/build
      - cd $CI_PROJECT_DIR/build
      - cmake ..
      - cmake . -LA
      - make doc
   tags:
      - docker
   artifacts:
      paths:
        - build/doc
      expire_in: 1 weeks



###############################################################################
##                                                                           ##
##    Code analysis                                                          ##
##                                                                           ##
###############################################################################

clang-tidy:
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:11.0
   script:
      - $CXX --version
      - clang-tidy -version
      - cmake --version
      - mkdir $CI_PROJECT_DIR/build
      - cd $CI_PROJECT_DIR/build
      - cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DWALBERLA_BUFFER_DEBUG=ON -DWALBERLA_BUILD_TESTS=ON -DWALBERLA_BUILD_BENCHMARKS=ON -DWALBERLA_BUILD_TUTORIALS=ON -DWALBERLA_BUILD_TOOLS=ON -DWALBERLA_BUILD_WITH_MPI=ON -DWALBERLA_BUILD_WITH_OPENMP=ON -DCMAKE_BUILD_TYPE=Debug -DWALBERLA_BUILD_WITH_METIS=ON -DWALBERLA_BUILD_WITH_PARMETIS=ON -DWALBERLA_BUILD_WITH_OPENMESH=ON -DWALBERLA_DOUBLE_ACCURACY=ON
      - cmake . -LA
      - utilities/filterCompileCommands.py compile_commands.json
      - run-clang-tidy.py -quiet | tee clang-tidy-output.txt
   artifacts:
      paths:
         - $CI_PROJECT_DIR/build/clang-tidy-output.txt
   tags:
      - docker


cppcheck:
   image: i10git.cs.fau.de:5005/walberla/buildenvs/cppcheck
   script:
      - cppcheck --version
      - cppcheck . --max-configs=10 --enable=warning --enable=style --enable=performance --enable=portability -i src/gui/extern -i src/geometry/structured/extern -i sqlite3.c -i StackWalker.cpp -I src/ -I tests/ -I apps/ -D WALBERLA_BUILD_WITH_MPI -D WALBERLA_BUILD_WITH_METIS -D WALBERLA_BUILD_WITH_PYTHON --xml 2> report.xml
      - cppcheck-htmlreport --file=report.xml --report-dir=html_report --source-dir=.
   artifacts:
      untracked: true
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   tags:
      - docker


coverage:
   image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:9
   script:
      - pip3 install gcovr
      - export NUM_CORES=$(nproc --all)
      - export MAX_BUILD_CORES=$(( $(awk '( $1 == "MemTotal:" ) { print $2 }' /proc/meminfo) / ( 4 * 1024 * 1024  ) ))
      - $CXX --version
      - cmake --version
      - gcovr --version
      - mkdir build
      - cd build
      - if dpkg --compare-versions `ompi_info | head -2 | tail -1 | sed 's/[^0-9.]*\([0-9.]*\).*/\1/'` ge 1.10; then export MPIEXEC_PREFLAGS="--allow-run-as-root" ; fi
      - cmake .. -DWALBERLA_BUILD_TESTS=ON -DWALBERLA_BUILD_BENCHMARKS=ON -DWALBERLA_BUILD_TUTORIALS=ON -DWALBERLA_BUILD_WITH_MPI=ON -DWALBERLA_BUILD_WITH_OPENMP=OFF -DCMAKE_BUILD_TYPE=Debug -DMPIEXEC_PREFLAGS=$MPIEXEC_PREFLAGS -DWALBERLA_BUILD_WITH_CODEGEN=OFF -DWALBERLA_BUILD_WITH_GCOV=ON
      - cmake . -LA
      - make -j $NUM_BUILD_CORES -l $NUM_CORES
      - ctest -LE longrun --output-on-failure -j $NUM_CORES --timeout 3000
      - cd ..
      - mkdir coverage
      - pwd
      - gcovr -r $CI_PROJECT_DIR -k build -f "src" --print-summary --html coverage/coverage.html --html-details --xml coverage/coverage.xml
   artifacts:
      paths:
         - coverage/
      reports:
        cobertura: coverage/coverage.xml
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   tags:
      - docker


###############################################################################
##                                                                           ##
##    Windows Builds                                                         ##
##                                                                           ##
###############################################################################


.win_build_template:
   tags:
      - win
   script:
      - export PreferredToolArchitecture=x64
      - export OMP_NUM_THREADS=4
      - export OMP_WAIT_POLICY="PASSIVE"
      - export MSMPI_DISABLE_SHM=1
      - cmake --version
      - mkdir build
      - cd build
      - cmake -LA -DWALBERLA_BUILD_TESTS=ON -DWALBERLA_BUILD_BENCHMARKS=ON -DWALBERLA_BUILD_TUTORIALS=ON -DWALBERLA_BUILD_WITH_MPI=$WALBERLA_BUILD_WITH_MPI -DWALBERLA_BUILD_WITH_OPENMP=$WALBERLA_BUILD_WITH_OPENMP -DWALBERLA_DOUBLE_ACCURACY=$WALBERLA_DOUBLE_ACCURACY -DWARNING_ERROR=ON -G "$CMAKE_GENERATOR" -DCMAKE_DISABLE_FIND_PACKAGE_Boost=TRUE ..
      - MSBuild.exe walberla.sln /property:Configuration=$BUILD_CONFIGURATION /verbosity:minimal /maxcpucount:4
      - ctest -LE $CTEST_EXCLUDE_LABELS -C $BUILD_CONFIGURATION --output-on-failure -j 4
   variables:
      CMAKE_GENERATOR: "Visual Studio 15 2017 Win64"
      BUILD_CONFIGURATION: "Release"
      CTEST_EXCLUDE_LABELS: "longrun"
      WALBERLA_BUILD_WITH_MPI: "ON"
      WALBERLA_BUILD_WITH_OPENMP: "ON"
      WALBERLA_DOUBLE_ACCURACY: "ON"



msvc-14.1_Hybrid_dbg:
   extends: .win_build_template
   variables:
      WALBERLA_BUILD_WITH_CUDA: "OFF"
      CMAKE_GENERATOR: "Visual Studio 15 2017 Win64"
      BUILD_CONFIGURATION: "DebugOptimized"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   


msvc-14.1_Hybrid_sp_dbg:
   extends: .win_build_template
   variables:
      WALBERLA_BUILD_WITH_CUDA: "OFF"
      CMAKE_GENERATOR: "Visual Studio 15 2017 Win64"
      BUILD_CONFIGURATION: "DebugOptimized"
      WALBERLA_DOUBLE_ACCURACY: "OFF"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   


msvc-14.1_Hybrid:
   extends: .win_build_template
   variables:
      WALBERLA_BUILD_WITH_CUDA: "OFF"
      CMAKE_GENERATOR: "Visual Studio 15 2017 Win64"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   


msvc-14.1_serial_dbg:
   extends: .win_build_template
   variables:
      WALBERLA_BUILD_WITH_CUDA: "OFF"
      CMAKE_GENERATOR: "Visual Studio 15 2017 Win64"
      WALBERLA_BUILD_WITH_MPI: "OFF"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      BUILD_CONFIGURATION: "DebugOptimized"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   


msvc-14.1_serial:
   extends: .win_build_template
   variables:
      WALBERLA_BUILD_WITH_CUDA: "OFF"
      CMAKE_GENERATOR: "Visual Studio 15 2017 Win64"
      WALBERLA_BUILD_WITH_MPI: "OFF"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   


msvc-14.1_mpionly_dbg:
   extends: .win_build_template
   variables:
      WALBERLA_BUILD_WITH_CUDA: "OFF"
      CMAKE_GENERATOR: "Visual Studio 15 2017 Win64"
      BUILD_CONFIGURATION: "DebugOptimized"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   


msvc-14.1_mpionly:
   extends: .win_build_template
   variables:
      WALBERLA_BUILD_WITH_CUDA: "OFF"
      CMAKE_GENERATOR: "Visual Studio 15 2017 Win64"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
   only:
      variables:
         - $ENABLE_NIGHTLY_BUILDS
   


msvc-14.2_Hybrid_dbg:
   extends: .win_build_template
   variables:
      WALBERLA_BUILD_WITH_CUDA: "OFF"
      CMAKE_GENERATOR: "Visual Studio 16 2019"
      BUILD_CONFIGURATION: "DebugOptimized"


msvc-14.2_Hybrid_sp_dbg:
   extends: .win_build_template
   variables:
      WALBERLA_BUILD_WITH_CUDA: "OFF"
      CMAKE_GENERATOR: "Visual Studio 16 2019"
      BUILD_CONFIGURATION: "DebugOptimized"
      WALBERLA_DOUBLE_ACCURACY: "OFF"


msvc-14.2_Hybrid:
   extends: .win_build_template
   variables:
      WALBERLA_BUILD_WITH_CUDA: "OFF"
      CMAKE_GENERATOR: "Visual Studio 16 2019"


msvc-14.2_serial_dbg:
   extends: .win_build_template
   variables:
      WALBERLA_BUILD_WITH_CUDA: "OFF"
      CMAKE_GENERATOR: "Visual Studio 16 2019"
      WALBERLA_BUILD_WITH_MPI: "OFF"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      BUILD_CONFIGURATION: "DebugOptimized"


msvc-14.2_serial:
   extends: .win_build_template
   variables:
      WALBERLA_BUILD_WITH_CUDA: "OFF"
      CMAKE_GENERATOR: "Visual Studio 16 2019"
      WALBERLA_BUILD_WITH_MPI: "OFF"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"


msvc-14.2_mpionly_dbg:
   extends: .win_build_template
   variables:
      WALBERLA_BUILD_WITH_CUDA: "OFF"
      CMAKE_GENERATOR: "Visual Studio 16 2019"
      BUILD_CONFIGURATION: "DebugOptimized"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"


msvc-14.2_mpionly:
   extends: .win_build_template
   variables:
      WALBERLA_BUILD_WITH_CUDA: "OFF"
      CMAKE_GENERATOR: "Visual Studio 16 2019"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"



###############################################################################
##                                                                           ##
##    macOS Builds                                                           ##
##                                                                           ##
###############################################################################


.mac_build_template: &mac_build_definition
   script:
      - export NUM_CORES=$(system_profiler SPHardwareDataType | grep 'Total Number of Cores' | awk '{print $5}')
      - export MAX_BUILD_CORES=$(( $(system_profiler SPHardwareDataType | grep 'Memory' | awk '{print $2}') / 4 ))
      - "[[ $MAX_BUILD_CORES -lt $NUM_CORES ]] && export NUM_BUILD_CORES=$MAX_BUILD_CORES || export NUM_BUILD_CORES=$NUM_CORES"
      - c++ --version
      - cmake --version
      - mpirun --version
      - mkdir build
      - cd build
      - cmake .. -DWALBERLA_BUILD_TESTS=ON -DWALBERLA_BUILD_BENCHMARKS=ON -DWALBERLA_BUILD_TUTORIALS=ON -DWALBERLA_BUILD_TOOLS=ON -DWALBERLA_BUILD_WITH_MPI=$WALBERLA_BUILD_WITH_MPI -DWALBERLA_BUILD_WITH_PYTHON=$WALBERLA_BUILD_WITH_PYTHON -DWALBERLA_BUILD_WITH_OPENMP=$WALBERLA_BUILD_WITH_OPENMP -DWALBERLA_BUILD_WITH_CUDA=$WALBERLA_BUILD_WITH_CUDA -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -DWARNING_ERROR=ON
      - cmake . -LA
      - make -j $NUM_BUILD_CORES -l $NUM_CORES
      - ctest -LE "$CTEST_EXCLUDE_LABELS|cuda" -C $CMAKE_BUILD_TYPE --output-on-failure -j $NUM_CORES
   tags:
      - mac

mac_Serial_Dbg:
   <<: *mac_build_definition
   variables:
      CMAKE_BUILD_TYPE: "DebugOptimized"
      CTEST_EXCLUDE_LABELS: "longrun"
      WALBERLA_BUILD_WITH_MPI: "OFF"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_PYTHON: "ON"

mac_Serial:
   <<: *mac_build_definition
   variables:
      CMAKE_BUILD_TYPE: "Release"
      CTEST_EXCLUDE_LABELS: "longrun"
      WALBERLA_BUILD_WITH_MPI: "OFF"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_PYTHON: "ON"

mac_MpiOnly_Dbg:
   <<: *mac_build_definition
   variables:
      CMAKE_BUILD_TYPE: "DebugOptimized"
      CTEST_EXCLUDE_LABELS: "longrun"
      WALBERLA_BUILD_WITH_MPI: "ON"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
      OMPI_MCA_btl: "self,tcp"

mac_MpiOnly:
   <<: *mac_build_definition
   variables:
      CMAKE_BUILD_TYPE: "Release"
      CTEST_EXCLUDE_LABELS: "longrun"
      WALBERLA_BUILD_WITH_MPI: "ON"
      WALBERLA_BUILD_WITH_OPENMP: "OFF"
      WALBERLA_BUILD_WITH_PYTHON: "ON"
      OMPI_MCA_btl: "self,tcp"

###############################################################################
##                                                                           ##
##    Deploy jobs                                                            ##
##                                                                           ##
###############################################################################

.conda-deploy: &conda_deploy_definition
   stage: deploy
   before_script:
      - conda install -y conda-build anaconda-client
      - anaconda login --username $CONDA_DEPLOY_USER --password $CONDA_DEPLOY_PASSWORD --hostname $CI_JOB_ID
      - conda config --set anaconda_upload yes
      - conda config --add channels lssfau
   after_script:
      - anaconda logout
   dependencies: []
   when: manual
   only:
      - master@walberla/walberla
      - tags@walberla/walberla

conda-py36-win:
   <<: *conda_deploy_definition
   tags:
      - win
   script:
      - conda build --python=3.6 --user=lssfau utilities\\conda\\walberla

conda-py37-win:
   <<: *conda_deploy_definition
   tags:
      - win
   script:
      - conda build --python=3.7 --user=lssfau utilities\\conda\\walberla

conda-py37-linux:
   <<: *conda_deploy_definition
   tags:
      - docker
   image: continuumio/miniconda3
   script:
      - apt-get update
      - apt-get install -y build-essential
      - conda build --python=3.7 --user=lssfau utilities/conda/walberla

conda-py36-linux:
   <<: *conda_deploy_definition
   tags:
      - docker
   image: continuumio/miniconda3
   script:
      - apt-get update
      - apt-get install -y build-essential
      - conda build --python=3.6 --user=lssfau utilities/conda/walberla


###############################################################################
##                                                                           ##
##    Benchmarks                                                             ##
##                                                                           ##
###############################################################################

.benchmark_template: &benchmark_definition
   script:
      - apt-get update --fix-missing
      - apt-get install -y python3-influxdb python3-git
      - $CXX --version
      - cmake --version
      - ccache --version
      - mpirun --version
      - export CCACHE_BASEDIR=$CI_PROJECT_DIR
      - mkdir $CI_PROJECT_DIR/build
      - cd $CI_PROJECT_DIR/build
      - cmake .. -DWALBERLA_BUFFER_DEBUG=OFF -DWALBERLA_BUILD_TESTS=OFF -DWALBERLA_BUILD_BENCHMARKS=ON -DWALBERLA_BUILD_TUTORIALS=OFF -DWALBERLA_BUILD_TOOLS=OFF -DWALBERLA_BUILD_WITH_MPI=ON -DWALBERLA_BUILD_WITH_CUDA=OFF -DWALBERLA_BUILD_WITH_PYTHON=OFF -DWALBERLA_BUILD_WITH_OPENMP=OFF -DCMAKE_BUILD_TYPE=RELEASE -DMPIEXEC_PREFLAGS=$MPIEXEC_PREFLAGS -DWALBERLA_DOUBLE_ACCURACY=ON -DWARNING_ERROR=ON -DWALBERLA_BUILD_WITH_METIS=OFF -DWALBERLA_BUILD_WITH_PARMETIS=OFF -DWALBERLA_OPTIMIZE_FOR_LOCALHOST=ON -DWALBERLA_BUILD_WITH_FASTMATH=ON -DWALBERLA_BUILD_WITH_LTO=ON
      - cmake . -LA
      - cd apps/benchmarks/GranularGas
      - make -j 20
      - export PATH=$PATH:/usr/local/likwid/bin
      - likwid-setFrequencies -t 0
      - likwid-setFrequencies -g performance
      - likwid-setFrequencies -f 3.3 # set frequency to 3.3
      - mpirun --allow-run-as-root -np 8 --map-by core --bind-to core --report-bindings ./PE_GranularGas PE_Benchmark.cfg --DEM --syncNextNeighbor | tee GranularGas_DEM_NN.txt
      - mpirun --allow-run-as-root -np 8 --map-by core --bind-to core --report-bindings ./PE_GranularGas PE_Benchmark.cfg --DEM --syncShadowOwners | tee GranularGas_DEM_SO.txt
      - mpirun --allow-run-as-root -np 8 --map-by core --bind-to core --report-bindings ./PE_GranularGas PE_Benchmark.cfg --HCSITS --syncNextNeighbor --InelasticFrictionlessContact | tee GranularGas_HCSITS_NN_IFC.txt
      - mpirun --allow-run-as-root -np 8 --map-by core --bind-to core --report-bindings ./PE_GranularGas PE_Benchmark.cfg --HCSITS --syncNextNeighbor --ApproximateInelasticCoulombContactByDecoupling | tee GranularGas_HCSITS_NN_AICCBD.txt
      - mpirun --allow-run-as-root -np 8 --map-by core --bind-to core --report-bindings ./PE_GranularGas PE_Benchmark.cfg --HCSITS --syncNextNeighbor --InelasticCoulombContactByDecoupling | tee GranularGas_HCSITS_NN_ICCBD.txt
      - mpirun --allow-run-as-root -np 8 --map-by core --bind-to core --report-bindings ./PE_GranularGas PE_Benchmark.cfg --HCSITS --syncNextNeighbor --InelasticGeneralizedMaximumDissipationContact | tee GranularGas_HCSITS_NN_IGMDC.txt
      - mpirun --allow-run-as-root -np 8 --map-by core --bind-to core --report-bindings ./PE_GranularGas PE_Benchmark.cfg --HCSITS --syncShadowOwners --InelasticFrictionlessContact | tee GranularGas_HCSITS_SO_IFC.txt
      - python3 pe_upload.py
      - mpirun --allow-run-as-root -np 8 --map-by core --bind-to core --report-bindings ./MESA_PD_KernelBenchmark MESA_PD_Benchmark.cfg | tee mesa_pd.txt
      - python3 mesa_pd_upload.py
   when: manual
   needs: [ ]
   stage: benchmark
   tags:
      - docker-benchmark
   artifacts:
      paths:
         - $CI_PROJECT_DIR/build/apps/benchmarks/GranularGas/*.txt
         - $CI_PROJECT_DIR/build/apps/benchmarks/GranularGas/*.sqlite

benchmark_intel19:
   <<: *benchmark_definition
   image: i10git.cs.fau.de:5005/walberla/buildenvs/intel:19

benchmark_gcc8:
   <<: *benchmark_definition
   image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:8

benchmark_clang8:
   <<: *benchmark_definition
   image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:8.0

benchmark_ClangBuildAnalyzer:
  script:
    - apt-get update --fix-missing
    - apt-get -y install apt-transport-https ca-certificates gnupg software-properties-common wget
    - wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | apt-key add -
    - apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main'
    - apt-get -y install cmake ninja-build
    - cmake --version
    - ccache --version
    - mpirun --version
    - export CC=clang
    - export CXX=clang++
    - $CXX --version
    - cd /tmp
    - git clone https://github.com/aras-p/ClangBuildAnalyzer.git
    - cd ClangBuildAnalyzer
    - cmake .
    - make
    - export PATH+=:$(pwd)
    - mkdir $CI_PROJECT_DIR/build
    - cd $CI_PROJECT_DIR/build
    - cmake .. -DWALBERLA_BUFFER_DEBUG=OFF -DWALBERLA_BUILD_TESTS=ON -DWALBERLA_BUILD_BENCHMARKS=ON -DWALBERLA_BUILD_TUTORIALS=ON -DWALBERLA_BUILD_TOOLS=OFF -DWALBERLA_BUILD_WITH_MPI=ON -DWALBERLA_BUILD_WITH_CUDA=OFF -DWALBERLA_BUILD_WITH_PYTHON=OFF -DWALBERLA_BUILD_WITH_OPENMP=OFF -DCMAKE_BUILD_TYPE=RELEASE -DMPIEXEC_PREFLAGS=$MPIEXEC_PREFLAGS -DWALBERLA_DOUBLE_ACCURACY=ON -DWARNING_ERROR=ON -DWALBERLA_BUILD_WITH_METIS=OFF -DWALBERLA_BUILD_WITH_PARMETIS=OFF -DWALBERLA_OPTIMIZE_FOR_LOCALHOST=ON -DWALBERLA_BUILD_WITH_FASTMATH=ON -DWALBERLA_BUILD_WITH_LTO=ON -DCMAKE_CXX_FLAGS=-ftime-trace -G Ninja
    - cmake . -LA
    - ClangBuildAnalyzer --start .
    - ninja all
    - ClangBuildAnalyzer --stop . CBA
    - ClangBuildAnalyzer --analyze CBA
  image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:9.0
  tags:
    - docker-benchmark
  only:
     variables:
        - $ENABLE_NIGHTLY_BUILDS
