# ====================
# UtilXlib UnitTesting
# ====================

build:cudampiomp:
  tags: [galileo]
  only:
    - /utilxlib/i
  script:
    - module load profile/advanced pgi/17.10 cuda/8.0.61
    - ./configure --enable-openmp
    - cd UtilXlib/tests
    - bash compile_and_run_tests.sh -smcn

build:intelmpiomp:
  tags: [galileo]
  only:
    - /utilxlib/i
  script:
    - module load profile/advanced intel intelmpi
    - ./configure --enable-openmp
    - cd UtilXlib/tests
    - bash compile_and_run_tests.sh -sm

build:cudampi:
  tags: [galileo]
  only:
    - /utilxlib/i
  script:
    - module load profile/advanced pgi/17.10 cuda/8.0.61
    - ./configure
    - cd UtilXlib/tests
    - bash compile_and_run_tests.sh -smcn

build:intelmpi:
  tags: [galileo]
  only:
    - /utilxlib/i
  script:
    - module load profile/advanced intel intelmpi
    - ./configure
    - cd UtilXlib/tests
    - bash compile_and_run_tests.sh -sm

build:pw:
  image: ubuntu:latest
  script:
    - apt-get update
    - apt-get install --yes build-essential gfortran wget python
    - apt-get install --yes libopenmpi-dev openmpi-bin
    - apt-get install --yes libblas-dev liblapack-dev fftw3 fftw3-dev pkg-config
    - ./configure
    - make pw
  #  - export OMP_NUM_THREADS=1
  #  - cd test-suite
  #  - mkdir /tmp/save
  #  - make run-tests-pw-serial
  #  - rm -r /tmp/save

build:cp:
  image: ubuntu:latest
  script:
    - apt-get update
    - apt-get install --yes build-essential gfortran wget python
    - apt-get install --yes libopenmpi-dev openmpi-bin
    - apt-get install --yes libblas-dev liblapack-dev fftw3 fftw3-dev pkg-config
    - ./configure
    - make cp
  #  - export OMP_NUM_THREADS=1
  #  - cd test-suite
  #  - mkdir /tmp/save
  #  - make run-tests-cp-serial
  #  - rm -r /tmp/save



#### BUILDS ON GALILEO ####

build:intel:
  tags: [galileo]
  script:
    - module purge
    - module load intel/pe-xe-2018--binary intelmpi/2018--binary mkl/2018--binary
    - module list
    - ./configure --enable-openmp
    - make pw cp
    - export OMP_NUM_THREADS=2
    - cd test-suite
    - mkdir -p /tmp/save
    - make run-tests-pw-parallel
    - make run-tests-cp-parallel
    - rm -r /tmp/save


pgi cuda mpi:
  tags: [k80]
  script:
    - module purge
    - module load profile/global pgi/17.10 mkl/2018--binary cuda/8.0.61
    - ./configure --enable-openmp --with-cuda-runtime=8.0 --with-cuda-cc=35 --with-cuda=$CUDA_HOME --with-scalapack=no
    - make -j pw
    - if [ -z ${SLURM_CPUS_PER_TASK} ]; then export OMP_NUM_THREADS=1; else export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK; fi
    - echo "Using $SLURM_NTASKS procs and $OMP_NUM_THREADS threads"
    - cd test-suite
    - sed -i "s/TESTCODE_NPROCS=4/TESTCODE_NPROCS=$SLURM_NTASKS/" ENVIRONMENT
    - make clean
    - make run-tests-pw-parallel
    - sed -i 's/export PARA_POSTFIX=" "/export PARA_POSTFIX=" -pd=.true."/g' run-pw.sh
    - make clean && make run-tests-pw-parallel
