bootstrap: docker
from: ubuntu:latest

%arguments

  NPROCS=4
  MPICH_VERSION=3.1.4
  OSU_MICRO_BENCHMARKS_VERSION=7.4

%post

  ### Install MPICH dependencies

  apt-get update
  apt-get install -y file g++ gcc gfortran make gdb strace wget ca-certificates --no-install-recommends

  # Build MPICH

  wget -q http://www.mpich.org/static/downloads/{{ MPICH_VERSION }}/mpich-{{ MPICH_VERSION }}.tar.gz
  tar xf mpich-{{ MPICH_VERSION }}.tar.gz
  cd mpich-{{ MPICH_VERSION }}
  ./configure --disable-fortran --enable-fast=all,O3 --prefix=/usr
  make -j{{ NPROCS }}
  make install
  ldconfig

  # Build osu benchmarks
  cd /opt
  wget -q http://mvapich.cse.ohio-state.edu/download/mvapich/osu-micro-benchmarks-{{ OSU_MICRO_BENCHMARKS_VERSION }}.tar.gz
  tar xf osu-micro-benchmarks-{{ OSU_MICRO_BENCHMARKS_VERSION }}.tar.gz
  cd osu-micro-benchmarks-{{ OSU_MICRO_BENCHMARKS_VERSION }}
  ./configure --prefix=/opt/osu-micro-benchmarks CC=mpicc CFLAGS=-O3
  make -j{{ NPROCS }}
  make install
  cd ..
  rm -rf osu-micro-benchmarks-{{ OSU_MICRO_BENCHMARKS_VERSION }} osu-micro-benchmarks-{{ OSU_MICRO_BENCHMARKS_VERSION }}.tar.gz

%runscript
  /opt/osu-micro-benchmarks/libexec/osu-micro-benchmarks/mpi/pt2pt/osu_bw
