From 0af8d0982609bcfba725db6201333a4514216685 Mon Sep 17 00:00:00 2001 From: ocramz Date: Fri, 8 Jul 2016 17:30:38 +0200 Subject: [PATCH 01/56] automating a few things --- .travis.yml | 24 ++++++++++++++++++++++++ Dockerfile | 3 ++- docker-compose.yml | 12 +++++++----- makefile | 10 ++++++++++ 4 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 .travis.yml create mode 100644 makefile diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..230fa71 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,24 @@ +sudo: + required + +language: + c + +services: + - docker + +before_install: + # # update Docker + - sudo apt-get update + - sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-engine wget + - wget https://github.com/docker/compose/releases/download/1.7.1/docker-compose-`uname -s`-`uname -m` + - sudo mv docker-compose-`uname -s`-`uname -m` /usr/local/bin/docker-compose + - sudo chmod +x /usr/local/bin/docker-compose + +script: + - docker-compose up &> logfile & + - sleep 60 + - docker network ls + # # # shut down docker-compose + - docker-compose down + - cat logfile \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index a0d20df..f466e20 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,8 @@ # Build this image: docker build -t mpi . # -FROM ubuntu:14.04 +# FROM ubuntu:14.04 +FROM phusion/baseimage MAINTAINER Ole Weidner ENV DEBIAN_FRONTEND noninteractive diff --git a/docker-compose.yml b/docker-compose.yml index c62faf5..a7dfa3a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,10 +1,12 @@ mpi_head: - image: openmpi + build: . + # image: openmpi ports: - - "22" + - "22" links: - - mpi_node + - mpi_node -mpi_node: - image: openmpi +mpi_node: + build: . + # image: openmpi diff --git a/makefile b/makefile new file mode 100644 index 0000000..dbca811 --- /dev/null +++ b/makefile @@ -0,0 +1,10 @@ +AUTH=ocramz +NAME=docker-openmpi +TAG=${AUTH}/${NAME} + +build: + docker build -t $(TAG) + +main: + docker-compose scale mpi_head=1 mpi_worker=3 + # docker-compose down From 7965eca96af733b19ab3d157e09be068f880284c Mon Sep 17 00:00:00 2001 From: ocramz Date: Fri, 8 Jul 2016 17:34:30 +0200 Subject: [PATCH 02/56] trying out compose in travis --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 230fa71..9993e24 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,8 @@ before_install: - sudo chmod +x /usr/local/bin/docker-compose script: - - docker-compose up &> logfile & + - docker-compose scale mpi_head=1 mpi_worker=3 &> logfile & + # - docker-compose up &> logfile & - sleep 60 - docker network ls # # # shut down docker-compose From a8b8a9dddde2f83a78a0f506048e1ae34fa90f6c Mon Sep 17 00:00:00 2001 From: ocramz Date: Fri, 8 Jul 2016 17:40:58 +0200 Subject: [PATCH 03/56] typo --- .travis.yml | 2 +- Dockerfile | 4 ++-- makefile | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9993e24..c040895 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ before_install: - sudo chmod +x /usr/local/bin/docker-compose script: - - docker-compose scale mpi_head=1 mpi_worker=3 &> logfile & + - docker-compose scale mpi_head=1 mpi_node=3 &> logfile & # - docker-compose up &> logfile & - sleep 60 - docker network ls diff --git a/Dockerfile b/Dockerfile index f466e20..252d81c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ # Build this image: docker build -t mpi . # -# FROM ubuntu:14.04 -FROM phusion/baseimage +FROM ubuntu:14.04 +# FROM phusion/baseimage MAINTAINER Ole Weidner ENV DEBIAN_FRONTEND noninteractive diff --git a/makefile b/makefile index dbca811..ae3c04a 100644 --- a/makefile +++ b/makefile @@ -6,5 +6,5 @@ build: docker build -t $(TAG) main: - docker-compose scale mpi_head=1 mpi_worker=3 + docker-compose scale mpi_head=1 mpi_node=3 # docker-compose down From 2d4769c84bbc5081d46a51c89abe2883ea0bd96d Mon Sep 17 00:00:00 2001 From: ocramz Date: Fri, 8 Jul 2016 17:45:53 +0200 Subject: [PATCH 04/56] typo --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 252d81c..22a7206 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,8 +9,7 @@ ENV DEBIAN_FRONTEND noninteractive RUN apt-get update -y && \ apt-get upgrade -y && \ - apt-get install -y openssh-server python-mpi4py python-numpy \ - python-virtualenv python-scipy gcc gfortran openmpi-checkpoint binutils + apt-get install -y --no-install-recommends openssh-server python-mpi4py python-numpy python-virtualenv python-scipy gcc gfortran openmpi-checkpoint binutils RUN mkdir /var/run/sshd RUN echo 'root:mpirun' | chpasswd From f00556ff248ca466639e6f25e4d3db9924601ed3 Mon Sep 17 00:00:00 2001 From: ocramz Date: Fri, 8 Jul 2016 17:46:30 +0200 Subject: [PATCH 05/56] typo --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index c040895..0580c25 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,10 +16,10 @@ before_install: - sudo chmod +x /usr/local/bin/docker-compose script: - - docker-compose scale mpi_head=1 mpi_node=3 &> logfile & + - docker-compose scale mpi_head=1 mpi_node=3 # &> logfile & # - docker-compose up &> logfile & - - sleep 60 + # - sleep 240 - docker network ls # # # shut down docker-compose - docker-compose down - - cat logfile \ No newline at end of file + # - cat logfile \ No newline at end of file From 0accdb4d8efab247ef3cf2936e326ec1adb5303f Mon Sep 17 00:00:00 2001 From: ocramz Date: Fri, 8 Jul 2016 17:48:47 +0200 Subject: [PATCH 06/56] typo --- makefile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/makefile b/makefile index ae3c04a..f862840 100644 --- a/makefile +++ b/makefile @@ -2,8 +2,16 @@ AUTH=ocramz NAME=docker-openmpi TAG=${AUTH}/${NAME} +.DEFAULT_GOAL := help + +help: + @echo "Use \`make \` where is one of" + @echo " help display this help message" + @echo " build build from Dockerfile" + @echo " main build and docker-compose the whole thing" + build: - docker build -t $(TAG) + docker build -t $(TAG) . main: docker-compose scale mpi_head=1 mpi_node=3 From 7462c6c8479e1f4be123cafc25ec5017b85b96a9 Mon Sep 17 00:00:00 2001 From: ocramz Date: Fri, 8 Jul 2016 18:00:15 +0200 Subject: [PATCH 07/56] typo --- docker-compose.yml | 39 +++++++++++++++++++++++++++++++-------- makefile | 1 + 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index a7dfa3a..f643435 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,12 +1,35 @@ mpi_head: - build: . - # image: openmpi - ports: - - "22" - links: - - mpi_node + build: . + # image: openmpi + ports: + - "22" + links: + - mpi_node mpi_node: - build: . - # image: openmpi + build: . + # image: openmpi + +# version: "2" + +# services: +# mpi_head: +# build: . +# # image: openmpi +# ports: +# - "22" +# links: +# - mpi_node +# networks: +# - net + +# mpi_node: +# build: . +# # image: openmpi +# networks: +# - net + +# networks: +# net: +# driver: bridge \ No newline at end of file diff --git a/makefile b/makefile index f862840..33fdf87 100644 --- a/makefile +++ b/makefile @@ -14,5 +14,6 @@ build: docker build -t $(TAG) . main: + # docker network create -d bridge mynet docker-compose scale mpi_head=1 mpi_node=3 # docker-compose down From aa31067314f91aebc7ba011a2a651e896802d438 Mon Sep 17 00:00:00 2001 From: ocramz Date: Fri, 8 Jul 2016 18:15:53 +0200 Subject: [PATCH 08/56] trying out everything together --- Dockerfile | 36 +++++++++++++--------- makefile | 3 +- mpi4py_benchmarks/matrix_vector_product.py | 4 +-- run_tests.sh | 13 ++++++++ 4 files changed, 39 insertions(+), 17 deletions(-) create mode 100755 run_tests.sh diff --git a/Dockerfile b/Dockerfile index 22a7206..8e24d69 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,9 +3,15 @@ FROM ubuntu:14.04 # FROM phusion/baseimage -MAINTAINER Ole Weidner -ENV DEBIAN_FRONTEND noninteractive +MAINTAINER Marco Zocca +# based on `docker.openmpi` by Ole Weidner + +ENV USER mpirun + +ENV DEBIAN_FRONTEND=noninteractive \ + HOME=/home/${USER} + RUN apt-get update -y && \ apt-get upgrade -y && \ @@ -25,29 +31,31 @@ RUN echo "export VISIBLE=now" >> /etc/profile # Add an 'mpirun' user # ------------------------------------------------------------ -RUN adduser --disabled-password --gecos "" mpirun && \ - echo "mpirun ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers -ENV HOME /home/mpirun +RUN adduser --disabled-password --gecos "" ${USER} && \ + echo "${USER} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers # ------------------------------------------------------------ # Set-Up SSH with our Github deploy key # ------------------------------------------------------------ -RUN mkdir /home/mpirun/.ssh/ -ADD ssh/config /home/mpirun/.ssh/config -ADD ssh/id_rsa.mpi /home/mpirun/.ssh/id_rsa -ADD ssh/id_rsa.mpi.pub /home/mpirun/.ssh/id_rsa.pub -ADD ssh/id_rsa.mpi.pub /home/mpirun/.ssh/authorized_keys +ENV SSHDIR ${HOME}/.ssh/ + +RUN mkdir -p ${SSHDIR} + +ADD ssh/config ${SSHDIR}/config +ADD ssh/id_rsa.mpi ${SSHDIR}/id_rsa +ADD ssh/id_rsa.mpi.pub ${SSHDIR}/id_rsa.pub +ADD ssh/id_rsa.mpi.pub ${SSHDIR}/authorized_keys -RUN chmod -R 600 /home/mpirun/.ssh/* && \ - chown -R mpirun:mpirun /home/mpirun/.ssh +RUN chmod -R 600 ${SSHDIR}* && \ + chown -R ${USER}:${USER} ${SSHDIR} # ------------------------------------------------------------ # Copy Rosa's MPI4PY example scripts # ------------------------------------------------------------ -ADD mpi4py_benchmarks /home/mpirun/mpi4py_benchmarks -RUN chown mpirun:mpirun /home/mpirun/mpi4py_benchmarks +ADD mpi4py_benchmarks ${HOME}/mpi4py_benchmarks +RUN chown ${USER}:${USER} ${HOME}/mpi4py_benchmarks EXPOSE 22 CMD ["/usr/sbin/sshd", "-D"] diff --git a/makefile b/makefile index 33fdf87..bff33f2 100644 --- a/makefile +++ b/makefile @@ -16,4 +16,5 @@ build: main: # docker network create -d bridge mynet docker-compose scale mpi_head=1 mpi_node=3 - # docker-compose down + docker-compose exec --privileged mpi_head ./run_tests + docker-compose down diff --git a/mpi4py_benchmarks/matrix_vector_product.py b/mpi4py_benchmarks/matrix_vector_product.py index 7a6aecf..bb084fa 100644 --- a/mpi4py_benchmarks/matrix_vector_product.py +++ b/mpi4py_benchmarks/matrix_vector_product.py @@ -33,8 +33,8 @@ def pprint(str="", end="\n", comm=MPI.COMM_WORLD): #============================================================================= # Main -size = 10000 # lengt of vector v -iter = 2000 # number of iterations to run +size = 10000 # length of vector v +iter = 20 # number of iterations to run counter = 0 diff --git a/run_tests.sh b/run_tests.sh new file mode 100755 index 0000000..02de445 --- /dev/null +++ b/run_tests.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +NNODES=2 + +echo ${HOME} + +cd ${HOME}/mpi4py_benchmarks +ls -lsA + +mpirun -n ${NNODES} python matrix_vector_product.py +mpirun -n ${NNODES} python osu_bibw.py +mpirun -n ${NNODES} python osu_bw.py +mpirun -n ${NNODES} python osu_latency.py From a7ed3c426f9c2318b9c79678042597c1e757d841 Mon Sep 17 00:00:00 2001 From: ocramz Date: Fri, 8 Jul 2016 18:16:46 +0200 Subject: [PATCH 09/56] trying out everything together --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0580c25..34eb95d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,9 +17,10 @@ before_install: script: - docker-compose scale mpi_head=1 mpi_node=3 # &> logfile & + - docker-compose exec --privileged mpi_head ./run_tests # - docker-compose up &> logfile & # - sleep 240 - - docker network ls + # - docker network ls # # # shut down docker-compose - docker-compose down # - cat logfile \ No newline at end of file From 1540474bc22c70a0e48ebd29f188d0d2f0d0a8b5 Mon Sep 17 00:00:00 2001 From: ocramz Date: Fri, 8 Jul 2016 18:17:25 +0200 Subject: [PATCH 10/56] trying out everything together --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 34eb95d..043894c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ before_install: script: - docker-compose scale mpi_head=1 mpi_node=3 # &> logfile & - - docker-compose exec --privileged mpi_head ./run_tests + - docker-compose exec --privileged mpi_head /bin/bash -c ./run_tests # - docker-compose up &> logfile & # - sleep 240 # - docker network ls From d873eab6167fae290656b0cfd78f76bf5104ce9b Mon Sep 17 00:00:00 2001 From: ocramz Date: Fri, 8 Jul 2016 18:17:36 +0200 Subject: [PATCH 11/56] trying out everything together --- makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makefile b/makefile index bff33f2..f62cac4 100644 --- a/makefile +++ b/makefile @@ -16,5 +16,5 @@ build: main: # docker network create -d bridge mynet docker-compose scale mpi_head=1 mpi_node=3 - docker-compose exec --privileged mpi_head ./run_tests + docker-compose exec --privileged mpi_head /bin/bash -c ./run_tests docker-compose down From 60d2240abc9f5a7f18fd5411cfb267d1e4bd67f0 Mon Sep 17 00:00:00 2001 From: ocramz Date: Fri, 8 Jul 2016 18:18:02 +0200 Subject: [PATCH 12/56] trying out everything together --- .travis.yml | 2 +- makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 043894c..4503496 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ before_install: script: - docker-compose scale mpi_head=1 mpi_node=3 # &> logfile & - - docker-compose exec --privileged mpi_head /bin/bash -c ./run_tests + - docker-compose exec --privileged mpi_head /bin/bash -c run_tests.sh # - docker-compose up &> logfile & # - sleep 240 # - docker network ls diff --git a/makefile b/makefile index f62cac4..888f031 100644 --- a/makefile +++ b/makefile @@ -16,5 +16,5 @@ build: main: # docker network create -d bridge mynet docker-compose scale mpi_head=1 mpi_node=3 - docker-compose exec --privileged mpi_head /bin/bash -c ./run_tests + docker-compose exec --privileged mpi_head /bin/bash -c run_tests.sh docker-compose down From 0d18ac6631a95071be403ca870fa736e8c421fff Mon Sep 17 00:00:00 2001 From: ocramz Date: Fri, 8 Jul 2016 18:20:19 +0200 Subject: [PATCH 13/56] trying out everything together --- .travis.yml | 2 +- makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4503496..14a84f0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ before_install: script: - docker-compose scale mpi_head=1 mpi_node=3 # &> logfile & - - docker-compose exec --privileged mpi_head /bin/bash -c run_tests.sh + - docker-compose exec --privileged mpi_head /bin/bash -c ./run_tests.sh # - docker-compose up &> logfile & # - sleep 240 # - docker network ls diff --git a/makefile b/makefile index 888f031..a007844 100644 --- a/makefile +++ b/makefile @@ -16,5 +16,5 @@ build: main: # docker network create -d bridge mynet docker-compose scale mpi_head=1 mpi_node=3 - docker-compose exec --privileged mpi_head /bin/bash -c run_tests.sh + docker-compose exec --privileged mpi_head /bin/bash -c ./run_tests.sh docker-compose down From dbd1e58a2f65e0c4b8523cf13c1d89e76d6c3a99 Mon Sep 17 00:00:00 2001 From: ocramz Date: Fri, 8 Jul 2016 19:28:59 +0200 Subject: [PATCH 14/56] trying out everything together --- Dockerfile | 6 ++++++ makefile | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8e24d69..c735092 100644 --- a/Dockerfile +++ b/Dockerfile @@ -47,6 +47,8 @@ ADD ssh/id_rsa.mpi ${SSHDIR}/id_rsa ADD ssh/id_rsa.mpi.pub ${SSHDIR}/id_rsa.pub ADD ssh/id_rsa.mpi.pub ${SSHDIR}/authorized_keys + + RUN chmod -R 600 ${SSHDIR}* && \ chown -R ${USER}:${USER} ${SSHDIR} @@ -57,5 +59,9 @@ RUN chmod -R 600 ${SSHDIR}* && \ ADD mpi4py_benchmarks ${HOME}/mpi4py_benchmarks RUN chown ${USER}:${USER} ${HOME}/mpi4py_benchmarks +ADD run_rests.sh ${HOME}/mpi4py_benchmarks + + + EXPOSE 22 CMD ["/usr/sbin/sshd", "-D"] diff --git a/makefile b/makefile index a007844..888f031 100644 --- a/makefile +++ b/makefile @@ -16,5 +16,5 @@ build: main: # docker network create -d bridge mynet docker-compose scale mpi_head=1 mpi_node=3 - docker-compose exec --privileged mpi_head /bin/bash -c ./run_tests.sh + docker-compose exec --privileged mpi_head /bin/bash -c run_tests.sh docker-compose down From 93eac5f73734c80f6ccb2db4d4a34c66b8fd398c Mon Sep 17 00:00:00 2001 From: ocramz Date: Fri, 8 Jul 2016 19:31:54 +0200 Subject: [PATCH 15/56] typo --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c735092..3b07308 100644 --- a/Dockerfile +++ b/Dockerfile @@ -59,7 +59,7 @@ RUN chmod -R 600 ${SSHDIR}* && \ ADD mpi4py_benchmarks ${HOME}/mpi4py_benchmarks RUN chown ${USER}:${USER} ${HOME}/mpi4py_benchmarks -ADD run_rests.sh ${HOME}/mpi4py_benchmarks +ADD run_tests.sh ${HOME}/mpi4py_benchmarks From 607b21aac6fbd634f0b0aabcbf165aeff6d18828 Mon Sep 17 00:00:00 2001 From: ocramz Date: Fri, 8 Jul 2016 19:39:51 +0200 Subject: [PATCH 16/56] typo --- .travis.yml | 2 +- Dockerfile | 1 + makefile | 6 ++++-- run_tests.sh | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 14a84f0..04f61e3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ before_install: script: - docker-compose scale mpi_head=1 mpi_node=3 # &> logfile & - - docker-compose exec --privileged mpi_head /bin/bash -c ./run_tests.sh + - docker-compose exec --privileged mpi_head /bin/bash -c ./home/mpirun/mpi4py_benchmarks/run_tests.sh # - docker-compose up &> logfile & # - sleep 240 # - docker network ls diff --git a/Dockerfile b/Dockerfile index 3b07308..7f24d49 100644 --- a/Dockerfile +++ b/Dockerfile @@ -59,6 +59,7 @@ RUN chmod -R 600 ${SSHDIR}* && \ ADD mpi4py_benchmarks ${HOME}/mpi4py_benchmarks RUN chown ${USER}:${USER} ${HOME}/mpi4py_benchmarks + ADD run_tests.sh ${HOME}/mpi4py_benchmarks diff --git a/makefile b/makefile index 888f031..eca6e15 100644 --- a/makefile +++ b/makefile @@ -2,6 +2,8 @@ AUTH=ocramz NAME=docker-openmpi TAG=${AUTH}/${NAME} +NNODES=2 + .DEFAULT_GOAL := help help: @@ -15,6 +17,6 @@ build: main: # docker network create -d bridge mynet - docker-compose scale mpi_head=1 mpi_node=3 - docker-compose exec --privileged mpi_head /bin/bash -c run_tests.sh + docker-compose scale mpi_head=1 mpi_node=${NNODES} + docker-compose exec --privileged mpi_head /bin/bash -c run_tests.sh ${NNODES} docker-compose down diff --git a/run_tests.sh b/run_tests.sh index 02de445..817737d 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -1,6 +1,6 @@ #!/bin/bash -NNODES=2 +NNODES=$1 echo ${HOME} From 368d57c10b49c6794389360cc2ca305369178c31 Mon Sep 17 00:00:00 2001 From: ocramz Date: Fri, 8 Jul 2016 19:48:17 +0200 Subject: [PATCH 17/56] typo --- makefile | 2 +- run_tests.sh | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/makefile b/makefile index eca6e15..f6ebe34 100644 --- a/makefile +++ b/makefile @@ -18,5 +18,5 @@ build: main: # docker network create -d bridge mynet docker-compose scale mpi_head=1 mpi_node=${NNODES} - docker-compose exec --privileged mpi_head /bin/bash -c run_tests.sh ${NNODES} + docker-compose exec --privileged mpi_head /bin/bash -c ./home/mpirun/mpi4py_benchmarks/run_tests.sh ${NNODES} docker-compose down diff --git a/run_tests.sh b/run_tests.sh index 817737d..40b51bc 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -2,11 +2,6 @@ NNODES=$1 -echo ${HOME} - -cd ${HOME}/mpi4py_benchmarks -ls -lsA - mpirun -n ${NNODES} python matrix_vector_product.py mpirun -n ${NNODES} python osu_bibw.py mpirun -n ${NNODES} python osu_bw.py From b5fe7ceaf34abfccf0d8bc72610d6730283f60ff Mon Sep 17 00:00:00 2001 From: ocramz Date: Fri, 8 Jul 2016 20:27:11 +0200 Subject: [PATCH 18/56] typo --- run_tests.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/run_tests.sh b/run_tests.sh index 40b51bc..0e92fda 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -2,6 +2,9 @@ NNODES=$1 +pwd +ls -lsA + mpirun -n ${NNODES} python matrix_vector_product.py mpirun -n ${NNODES} python osu_bibw.py mpirun -n ${NNODES} python osu_bw.py From 246353bce36965abec7f5e1eba6fa33c5713c1ad Mon Sep 17 00:00:00 2001 From: ocramz Date: Fri, 8 Jul 2016 20:32:17 +0200 Subject: [PATCH 19/56] typo --- .travis.yml | 6 ++++-- makefile | 3 +-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 04f61e3..e06ba5b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ services: - docker before_install: + - export NNODES 4 # # update Docker - sudo apt-get update - sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-engine wget @@ -16,8 +17,9 @@ before_install: - sudo chmod +x /usr/local/bin/docker-compose script: - - docker-compose scale mpi_head=1 mpi_node=3 # &> logfile & - - docker-compose exec --privileged mpi_head /bin/bash -c ./home/mpirun/mpi4py_benchmarks/run_tests.sh + - cd /home/mpirun/mpi4py_benchmarks + - docker-compose scale mpi_head=1 mpi_node=${NNODES} # &> logfile & + - docker-compose exec --privileged mpi_head /bin/bash -c ./home/mpirun/mpi4py_benchmarks/run_tests.sh ${NNODES} # - docker-compose up &> logfile & # - sleep 240 # - docker network ls diff --git a/makefile b/makefile index f6ebe34..cf11ceb 100644 --- a/makefile +++ b/makefile @@ -2,7 +2,7 @@ AUTH=ocramz NAME=docker-openmpi TAG=${AUTH}/${NAME} -NNODES=2 +NNODES=4 .DEFAULT_GOAL := help @@ -16,7 +16,6 @@ build: docker build -t $(TAG) . main: - # docker network create -d bridge mynet docker-compose scale mpi_head=1 mpi_node=${NNODES} docker-compose exec --privileged mpi_head /bin/bash -c ./home/mpirun/mpi4py_benchmarks/run_tests.sh ${NNODES} docker-compose down From 7409059fde13a9436eb4a61b6ff4795207979573 Mon Sep 17 00:00:00 2001 From: ocramz Date: Fri, 8 Jul 2016 20:44:38 +0200 Subject: [PATCH 20/56] typo --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e06ba5b..9196d81 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ services: - docker before_install: - - export NNODES 4 + - export NNODES=4 # # update Docker - sudo apt-get update - sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-engine wget From e1086a72541b4cd905ada5f85192984ef8e325ce Mon Sep 17 00:00:00 2001 From: ocramz Date: Fri, 8 Jul 2016 20:54:19 +0200 Subject: [PATCH 21/56] typo --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9196d81..bfba15a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,8 +17,8 @@ before_install: - sudo chmod +x /usr/local/bin/docker-compose script: - - cd /home/mpirun/mpi4py_benchmarks - docker-compose scale mpi_head=1 mpi_node=${NNODES} # &> logfile & + - cd /home/mpirun/mpi4py_benchmarks - docker-compose exec --privileged mpi_head /bin/bash -c ./home/mpirun/mpi4py_benchmarks/run_tests.sh ${NNODES} # - docker-compose up &> logfile & # - sleep 240 From 73096653d306d6f365935b11f50a84e09557a5ae Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 09:00:55 +0200 Subject: [PATCH 22/56] typo --- .travis.yml | 12 ++++-------- run_tests.sh | 8 ++++---- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index bfba15a..badf23c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,8 +7,10 @@ language: services: - docker +env: + - NNODES=4 + before_install: - - export NNODES=4 # # update Docker - sudo apt-get update - sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-engine wget @@ -18,11 +20,5 @@ before_install: script: - docker-compose scale mpi_head=1 mpi_node=${NNODES} # &> logfile & - - cd /home/mpirun/mpi4py_benchmarks - docker-compose exec --privileged mpi_head /bin/bash -c ./home/mpirun/mpi4py_benchmarks/run_tests.sh ${NNODES} - # - docker-compose up &> logfile & - # - sleep 240 - # - docker network ls - # # # shut down docker-compose - - docker-compose down - # - cat logfile \ No newline at end of file + - docker-compose down \ No newline at end of file diff --git a/run_tests.sh b/run_tests.sh index 0e92fda..36e4edd 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -5,7 +5,7 @@ NNODES=$1 pwd ls -lsA -mpirun -n ${NNODES} python matrix_vector_product.py -mpirun -n ${NNODES} python osu_bibw.py -mpirun -n ${NNODES} python osu_bw.py -mpirun -n ${NNODES} python osu_latency.py +mpirun -n ${NNODES} python ${HOME}/mpi4py_benchmarks/matrix_vector_product.py +mpirun -n ${NNODES} python ${HOME}/mpi4py_benchmarks/osu_bibw.py +mpirun -n ${NNODES} python ${HOME}/mpi4py_benchmarks/osu_bw.py +mpirun -n ${NNODES} python ${HOME}/mpi4py_benchmarks/osu_latency.py From 030d41e7c13d0f3d11c7d92ea92ccce13bcaafc9 Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 09:02:16 +0200 Subject: [PATCH 23/56] typo --- makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/makefile b/makefile index cf11ceb..047600e 100644 --- a/makefile +++ b/makefile @@ -10,11 +10,15 @@ help: @echo "Use \`make \` where is one of" @echo " help display this help message" @echo " build build from Dockerfile" + @echo " build rebuild from Dockerfile (ignores cached layers)" @echo " main build and docker-compose the whole thing" build: docker build -t $(TAG) . +rebuild: + docker build --no-cache -t $(TAG) . + main: docker-compose scale mpi_head=1 mpi_node=${NNODES} docker-compose exec --privileged mpi_head /bin/bash -c ./home/mpirun/mpi4py_benchmarks/run_tests.sh ${NNODES} From d89a42f829f3dbc28d690ba64305bfd673193733 Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 09:07:10 +0200 Subject: [PATCH 24/56] typo --- makefile | 2 +- run_tests.sh | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/makefile b/makefile index 047600e..80ee765 100644 --- a/makefile +++ b/makefile @@ -10,7 +10,7 @@ help: @echo "Use \`make \` where is one of" @echo " help display this help message" @echo " build build from Dockerfile" - @echo " build rebuild from Dockerfile (ignores cached layers)" + @echo " rebuild rebuild from Dockerfile (ignores cached layers)" @echo " main build and docker-compose the whole thing" build: diff --git a/run_tests.sh b/run_tests.sh index 36e4edd..07378d5 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -2,10 +2,12 @@ NNODES=$1 +cd ${HOME}/mpi4py_benchmarks/ + pwd ls -lsA -mpirun -n ${NNODES} python ${HOME}/mpi4py_benchmarks/matrix_vector_product.py -mpirun -n ${NNODES} python ${HOME}/mpi4py_benchmarks/osu_bibw.py -mpirun -n ${NNODES} python ${HOME}/mpi4py_benchmarks/osu_bw.py -mpirun -n ${NNODES} python ${HOME}/mpi4py_benchmarks/osu_latency.py +mpirun -n ${NNODES} python matrix_vector_product.py +mpirun -n ${NNODES} python osu_bibw.py +mpirun -n ${NNODES} python osu_bw.py +mpirun -n ${NNODES} python osu_latency.py From 350e93a39abbba394215734d4e10b7fd81fb9dcb Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 09:56:20 +0200 Subject: [PATCH 25/56] typo --- run_tests.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/run_tests.sh b/run_tests.sh index 07378d5..b5bf449 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -7,7 +7,7 @@ cd ${HOME}/mpi4py_benchmarks/ pwd ls -lsA -mpirun -n ${NNODES} python matrix_vector_product.py -mpirun -n ${NNODES} python osu_bibw.py -mpirun -n ${NNODES} python osu_bw.py -mpirun -n ${NNODES} python osu_latency.py +mpirun -n ${NNODES} python ./matrix_vector_product.py +mpirun -n ${NNODES} python ./osu_bibw.py +mpirun -n ${NNODES} python ./osu_bw.py +mpirun -n ${NNODES} python ./osu_latency.py From 0878595072206c0a0c451bc71132a0c0f5a0596a Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 10:25:24 +0200 Subject: [PATCH 26/56] typo --- run_tests.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run_tests.sh b/run_tests.sh index b5bf449..9116839 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -1,8 +1,8 @@ -#!/bin/bash +#!/bin/sh NNODES=$1 -cd ${HOME}/mpi4py_benchmarks/ +export P=${HOME}/mpi4py_benchmarks/ pwd ls -lsA From 57bbcefe995a669a07f9d877339a00671502e715 Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 10:28:59 +0200 Subject: [PATCH 27/56] absolute python script paths --- run_tests.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/run_tests.sh b/run_tests.sh index 9116839..49f1d81 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -2,12 +2,10 @@ NNODES=$1 -export P=${HOME}/mpi4py_benchmarks/ - pwd ls -lsA -mpirun -n ${NNODES} python ./matrix_vector_product.py -mpirun -n ${NNODES} python ./osu_bibw.py -mpirun -n ${NNODES} python ./osu_bw.py -mpirun -n ${NNODES} python ./osu_latency.py +mpirun -n ${NNODES} python /home/mpirun/mpi4py_benchmarks/matrix_vector_product.py +mpirun -n ${NNODES} python /home/mpirun/mpi4py_benchmarks/osu_bibw.py +mpirun -n ${NNODES} python /home/mpirun/mpi4py_benchmarks/osu_bw.py +mpirun -n ${NNODES} python /home/mpirun/mpi4py_benchmarks/osu_latency.py From 7592ed2e1c1d342ca351d29d4c82ac562cdbefee Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 11:23:18 +0200 Subject: [PATCH 28/56] all mpi4py tests in a single py file --- .travis.yml | 2 +- Dockerfile | 2 +- makefile | 2 +- mpi4py_benchmarks/matrix_vector_product.py | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index badf23c..580bfdd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,5 +20,5 @@ before_install: script: - docker-compose scale mpi_head=1 mpi_node=${NNODES} # &> logfile & - - docker-compose exec --privileged mpi_head /bin/bash -c ./home/mpirun/mpi4py_benchmarks/run_tests.sh ${NNODES} + - docker-compose exec --privileged mpi_head mpirun -n ${NNODES} python /home/mpirun/mpi4py_benchmarks/all_tests.py - docker-compose down \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 7f24d49..feeac2c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -53,7 +53,7 @@ RUN chmod -R 600 ${SSHDIR}* && \ chown -R ${USER}:${USER} ${SSHDIR} # ------------------------------------------------------------ -# Copy Rosa's MPI4PY example scripts +# Copy MPI4PY example scripts # ------------------------------------------------------------ ADD mpi4py_benchmarks ${HOME}/mpi4py_benchmarks diff --git a/makefile b/makefile index 80ee765..2dfd069 100644 --- a/makefile +++ b/makefile @@ -21,5 +21,5 @@ rebuild: main: docker-compose scale mpi_head=1 mpi_node=${NNODES} - docker-compose exec --privileged mpi_head /bin/bash -c ./home/mpirun/mpi4py_benchmarks/run_tests.sh ${NNODES} + docker-compose exec --privileged mpi_head mpirun -n ${NNODES} python /home/mpirun/mpi4py_benchmarks/all_tests.py docker-compose down diff --git a/mpi4py_benchmarks/matrix_vector_product.py b/mpi4py_benchmarks/matrix_vector_product.py index bb084fa..b9e1e7d 100644 --- a/mpi4py_benchmarks/matrix_vector_product.py +++ b/mpi4py_benchmarks/matrix_vector_product.py @@ -18,7 +18,7 @@ from __future__ import division import numpy as np -from numpy.fft import fft2, ifft2 +# from numpy.fft import fft2, ifft2 from math import ceil, fabs from mpi4py import MPI @@ -34,7 +34,7 @@ def pprint(str="", end="\n", comm=MPI.COMM_WORLD): # Main size = 10000 # length of vector v -iter = 20 # number of iterations to run +iter = 2000 # number of iterations to run counter = 0 From 45bf7eb87f205dd30d867642e4d737735a8729d4 Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 11:25:23 +0200 Subject: [PATCH 29/56] all mpi4py tests in a single py file --- Dockerfile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index feeac2c..63006ba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -54,15 +54,12 @@ RUN chmod -R 600 ${SSHDIR}* && \ # ------------------------------------------------------------ # Copy MPI4PY example scripts -# ------------------------------------------------------------ +# # ------------------------------------------------------------ ADD mpi4py_benchmarks ${HOME}/mpi4py_benchmarks RUN chown ${USER}:${USER} ${HOME}/mpi4py_benchmarks -ADD run_tests.sh ${HOME}/mpi4py_benchmarks - - EXPOSE 22 CMD ["/usr/sbin/sshd", "-D"] From a18ec497294c456223c784b866e1d4d23db86c00 Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 11:25:57 +0200 Subject: [PATCH 30/56] all mpi4py tests in a single py file --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 63006ba..92fcd2b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -54,7 +54,9 @@ RUN chmod -R 600 ${SSHDIR}* && \ # ------------------------------------------------------------ # Copy MPI4PY example scripts -# # ------------------------------------------------------------ +# ------------------------------------------------------------ + +ENV TRIGGER 1 ADD mpi4py_benchmarks ${HOME}/mpi4py_benchmarks RUN chown ${USER}:${USER} ${HOME}/mpi4py_benchmarks From aea6f48f90c14e647fb0d24614deb650b54f6005 Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 11:27:32 +0200 Subject: [PATCH 31/56] all mpi4py tests in a single py file --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 92fcd2b..217abac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ RUN apt-get update -y && \ apt-get install -y --no-install-recommends openssh-server python-mpi4py python-numpy python-virtualenv python-scipy gcc gfortran openmpi-checkpoint binutils RUN mkdir /var/run/sshd -RUN echo 'root:mpirun' | chpasswd +RUN echo 'root:${USER}' | chpasswd RUN sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config # SSH login fix. Otherwise user is kicked off after login From 89b0aae11e4a900d8916be7bc34d149183cc1d39 Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 11:33:57 +0200 Subject: [PATCH 32/56] all mpi4py tests in a single py file --- mpi4py_benchmarks/all_tests.py | 162 +++++++++++++++++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 mpi4py_benchmarks/all_tests.py diff --git a/mpi4py_benchmarks/all_tests.py b/mpi4py_benchmarks/all_tests.py new file mode 100644 index 0000000..ab71a82 --- /dev/null +++ b/mpi4py_benchmarks/all_tests.py @@ -0,0 +1,162 @@ +""" +MVP : Demonstrating a MPI parallel Matrix-Vector Multiplication. +This code will run *iter* iterations of + v(t+1) = M * v(t) +where v is a vector of length *size* and M a dense size*size +matrix. *size* must be an integer multiple of comm.size. +v is initialized to be zero except of v[0] = 1.0 +M is a "off-by-one" diagonal matrix M[i, i+1] = 1.0 +In effect, after *iter* iterations, the vector v should look like +v[iter] = 1. (all others zero). +In this example every MPI process is responsible for calculating a +different portion of v. Every process only knows the stripe of M, that +is relevant for it's calculation. At the end of every iteration, +Allgather is used to distribute the partial vectors v to all other +processes. +""" + +from __future__ import division + +import numpy as np +# from numpy.fft import fft2, ifft2 +from math import ceil, fabs +from mpi4py import MPI + +#============================================================================= +# I/O Utilities + +def pprint(str="", end="\n", comm=MPI.COMM_WORLD): + """Print for MPI parallel programs: Only rank 0 prints *str*.""" + if comm.rank == 0: + print str+end, + +#============================================================================= +# Main + +def mvp_main(size=10000, iter=2000): + # size = 10000 # length of vector v + # iter = 2000 # number of iterations to run + + counter = 0 + + comm = MPI.COMM_WORLD + + pprint("============================================================================") + pprint(" Running %d parallel MPI processes" % comm.size) + + my_size = size // comm.size # Every process computes a vector of lenth *my_size* + size = comm.size*my_size # Make sure size is a integer multiple of comm.size + my_offset = comm.rank*my_size + + # This is the complete vector + vec = np.zeros(size) # Every element zero... + vec[0] = 1.0 # ... besides vec[0] + + # Create my (local) slice of the matrix + my_M = np.zeros((my_size, size)) + for i in xrange(my_size): + j = (my_offset+i-1) % size + my_M[i,j] = 1.0 + + + while counter < iter: + comm.Barrier() ### Start stopwatch ### + t_start = MPI.Wtime() + + for t in xrange(20): + my_new_vec = np.inner(my_M, vec) + + comm.Allgather( + [my_new_vec, MPI.DOUBLE], + [vec, MPI.DOUBLE] + ) + + comm.Barrier() + t_diff = MPI.Wtime() - t_start ### Stop stopwatch ### + + # if fabs(vec[iter]-1.0) > 0.01: + # pprint("!! Error: Wrong result!") + + pprint(" %d iterations of size %d in %5.2fs: %5.2f iterations per second" % + (20, size, t_diff, 20/t_diff) + ) + + counter += 20 + + + + +def osu_latency( + BENCHMARH = "MPI Latency Test", + skip = 1000, + loop = 10000, + skip_large = 10, + loop_large = 100, + large_message_size = 8192, + MAX_MSG_SIZE = 1<<22, + ): + + comm = MPI.COMM_WORLD + myid = comm.Get_rank() + numprocs = comm.Get_size() + + if numprocs != 2: + if myid == 0: + errmsg = "This test requires exactly two processes" + else: + errmsg = None + raise SystemExit(errmsg) + + s_buf = allocate(MAX_MSG_SIZE) + r_buf = allocate(MAX_MSG_SIZE) + + if myid == 0: + print ('# %s' % (BENCHMARH,)) + if myid == 0: + print ('# %-8s%20s' % ("Size [B]", "Latency [us]")) + + message_sizes = [0] + [2**i for i in range(30)] + for size in message_sizes: + if size > MAX_MSG_SIZE: + break + if size > large_message_size: + skip = skip_large + loop = loop_large + iterations = list(range(loop+skip)) + s_msg = [s_buf, size, MPI.BYTE] + r_msg = [r_buf, size, MPI.BYTE] + # + comm.Barrier() + if myid == 0: + for i in iterations: + if i == skip: + t_start = MPI.Wtime() + comm.Send(s_msg, 1, 1) + comm.Recv(r_msg, 1, 1) + t_end = MPI.Wtime() + elif myid == 1: + for i in iterations: + comm.Recv(r_msg, 0, 1) + comm.Send(s_msg, 0, 1) + # + if myid == 0: + latency = (t_end - t_start) * 1e6 / (2 * loop) + print ('%-10d%20.2f' % (size, latency)) + + +def allocate(n): + try: + import mmap + return mmap.mmap(-1, n) + except (ImportError, EnvironmentError): + try: + from numpy import zeros + return zeros(n, 'B') + except ImportError: + from array import array + return array('B', [0]) * n + + +if __name__ == '__main__': + mvp_main() + osu_latency() From a627ad34eafcc746fa7c913fe1e3a488f501e1a4 Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 11:44:53 +0200 Subject: [PATCH 33/56] all mpi4py tests in a single py file --- .travis.yml | 2 +- mpi4py_benchmarks/all_tests.py | 151 ++++++++++++++++++++++++++++++++- 2 files changed, 150 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 580bfdd..2a80e22 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ services: - docker env: - - NNODES=4 + - NNODES=2 before_install: # # update Docker diff --git a/mpi4py_benchmarks/all_tests.py b/mpi4py_benchmarks/all_tests.py index ab71a82..0359954 100644 --- a/mpi4py_benchmarks/all_tests.py +++ b/mpi4py_benchmarks/all_tests.py @@ -33,9 +33,9 @@ def pprint(str="", end="\n", comm=MPI.COMM_WORLD): #============================================================================= # Main -def mvp_main(size=10000, iter=2000): +def mvp_main(size=10000, iter=200): # size = 10000 # length of vector v - # iter = 2000 # number of iterations to run + # iter = 200 # number of iterations to run counter = 0 @@ -143,6 +143,151 @@ def osu_latency( latency = (t_end - t_start) * 1e6 / (2 * loop) print ('%-10d%20.2f' % (size, latency)) +def osu_bibw( + BENCHMARH = "MPI Bi-Directional Bandwidth Test", + skip = 10, + loop = 100, + window_size = 64, + skip_large = 2, + loop_large = 20, + window_size_large = 64, + large_message_size = 8192, + MAX_MSG_SIZE = 1<<22, + ): + + comm = MPI.COMM_WORLD + myid = comm.Get_rank() + numprocs = comm.Get_size() + + if numprocs != 2: + if myid == 0: + errmsg = "This test requires exactly two processes" + else: + errmsg = None + raise SystemExit(errmsg) + + s_buf = allocate(MAX_MSG_SIZE) + r_buf = allocate(MAX_MSG_SIZE) + + if myid == 0: + print ('# %s' % (BENCHMARH,)) + if myid == 0: + print ('# %-8s%20s' % ("Size [B]", "Bandwidth [MB/s]")) + + message_sizes = [2**i for i in range(30)] + for size in message_sizes: + if size > MAX_MSG_SIZE: + break + if size > large_message_size: + skip = skip_large + loop = loop_large + window_size = window_size_large + + iterations = list(range(loop+skip)) + window_sizes = list(range(window_size)) + s_msg = [s_buf, size, MPI.BYTE] + r_msg = [r_buf, size, MPI.BYTE] + send_request = [MPI.REQUEST_NULL] * window_size + recv_request = [MPI.REQUEST_NULL] * window_size + # + comm.Barrier() + if myid == 0: + for i in iterations: + if i == skip: + t_start = MPI.Wtime() + for j in window_sizes: + recv_request[j] = comm.Irecv(r_msg, 1, 10) + for j in window_sizes: + send_request[j] = comm.Isend(s_msg, 1, 100) + MPI.Request.Waitall(send_request) + MPI.Request.Waitall(recv_request) + t_end = MPI.Wtime() + elif myid == 1: + for i in iterations: + for j in window_sizes: + recv_request[j] = comm.Irecv(r_msg, 0, 100) + for j in window_sizes: + send_request[j] = comm.Isend(s_msg, 0, 10) + MPI.Request.Waitall(send_request) + MPI.Request.Waitall(recv_request) + # + if myid == 0: + MB = size / 1e6 * loop * window_size + s = t_end - t_start + print ('%-10d%20.2f' % (size, MB/s)) + + +def osu_bw( + BENCHMARH = "MPI Bandwidth Test", + skip = 10, + loop = 100, + window_size = 64, + skip_large = 2, + loop_large = 20, + window_size_large = 64, + large_message_size = 8192, + MAX_MSG_SIZE = 1<<22, + ): + + comm = MPI.COMM_WORLD + myid = comm.Get_rank() + numprocs = comm.Get_size() + + if numprocs != 2: + if myid == 0: + errmsg = "This test requires exactly two processes" + else: + errmsg = None + raise SystemExit(errmsg) + + s_buf = allocate(MAX_MSG_SIZE) + r_buf = allocate(MAX_MSG_SIZE) + + if myid == 0: + print ('# %s' % (BENCHMARH,)) + if myid == 0: + print ('# %-8s%20s' % ("Size [B]", "Bandwidth [MB/s]")) + + message_sizes = [2**i for i in range(30)] + for size in message_sizes: + if size > MAX_MSG_SIZE: + break + if size > large_message_size: + skip = skip_large + loop = loop_large + window_size = window_size_large + + iterations = list(range(loop+skip)) + window_sizes = list(range(window_size)) + requests = [MPI.REQUEST_NULL] * window_size + # + comm.Barrier() + if myid == 0: + s_msg = [s_buf, size, MPI.BYTE] + r_msg = [r_buf, 4, MPI.BYTE] + for i in iterations: + if i == skip: + t_start = MPI.Wtime() + for j in window_sizes: + requests[j] = comm.Isend(s_msg, 1, 100) + MPI.Request.Waitall(requests) + comm.Recv(r_msg, 1, 101) + t_end = MPI.Wtime() + elif myid == 1: + s_msg = [s_buf, 4, MPI.BYTE] + r_msg = [r_buf, size, MPI.BYTE] + for i in iterations: + for j in window_sizes: + requests[j] = comm.Irecv(r_msg, 0, 100) + MPI.Request.Waitall(requests) + comm.Send(s_msg, 0, 101) + # + if myid == 0: + MB = size / 1e6 * loop * window_size + s = t_end - t_start + print ('%-10d%20.2f' % (size, MB/s)) + + def allocate(n): try: @@ -160,3 +305,5 @@ def allocate(n): if __name__ == '__main__': mvp_main() osu_latency() + osu_bw() + osu_bibw() From a95236ede2db9b326663b187b0ce33e698d834d6 Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 11:46:45 +0200 Subject: [PATCH 34/56] all mpi4py tests in a single py file --- .travis.yml | 4 +--- makefile | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2a80e22..bcef401 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,4 @@ before_install: - sudo chmod +x /usr/local/bin/docker-compose script: - - docker-compose scale mpi_head=1 mpi_node=${NNODES} # &> logfile & - - docker-compose exec --privileged mpi_head mpirun -n ${NNODES} python /home/mpirun/mpi4py_benchmarks/all_tests.py - - docker-compose down \ No newline at end of file + - make main \ No newline at end of file diff --git a/makefile b/makefile index 2dfd069..e5f636f 100644 --- a/makefile +++ b/makefile @@ -2,7 +2,7 @@ AUTH=ocramz NAME=docker-openmpi TAG=${AUTH}/${NAME} -NNODES=4 +export NNODES=2 .DEFAULT_GOAL := help From c40bb6f83c316ff16e28ca5d5f6a94888c60731a Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 11:50:22 +0200 Subject: [PATCH 35/56] all mpi4py tests in a single py file --- mpi4py_benchmarks/all_tests.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mpi4py_benchmarks/all_tests.py b/mpi4py_benchmarks/all_tests.py index 0359954..4a0633c 100644 --- a/mpi4py_benchmarks/all_tests.py +++ b/mpi4py_benchmarks/all_tests.py @@ -33,17 +33,23 @@ def pprint(str="", end="\n", comm=MPI.COMM_WORLD): #============================================================================= # Main -def mvp_main(size=10000, iter=200): +def mvp_main(BENCHMARH="Matrix-vector multiplication", + size=10000, + iter=200): # size = 10000 # length of vector v # iter = 200 # number of iterations to run counter = 0 comm = MPI.COMM_WORLD + myid = comm.Get_rank() pprint("============================================================================") pprint(" Running %d parallel MPI processes" % comm.size) + if myid == 0: + print ('# %s' % (BENCHMARH,)) + my_size = size // comm.size # Every process computes a vector of lenth *my_size* size = comm.size*my_size # Make sure size is a integer multiple of comm.size my_offset = comm.rank*my_size From 886af12431aaa3a1e3c854267be752599a47f7e1 Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 12:26:45 +0200 Subject: [PATCH 36/56] fixed matvec test output --- mpi4py_benchmarks/all_tests.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/mpi4py_benchmarks/all_tests.py b/mpi4py_benchmarks/all_tests.py index 4a0633c..23643ad 100644 --- a/mpi4py_benchmarks/all_tests.py +++ b/mpi4py_benchmarks/all_tests.py @@ -47,12 +47,20 @@ def mvp_main(BENCHMARH="Matrix-vector multiplication", pprint("============================================================================") pprint(" Running %d parallel MPI processes" % comm.size) + + my_size = size // comm.size # Every process computes a vector of lenth *my_size* + size = comm.size*my_size # size must be integer multiple of comm.size + my_offset = comm.rank*my_size + + bs = 20 # batch size + if myid == 0: print ('# %s' % (BENCHMARH,)) + print ('# %-8s%20s' % ("Duration [s]", "Throughput [#/s]")) + + pprint(" %d iterations of size %d " % (bs, size)) - my_size = size // comm.size # Every process computes a vector of lenth *my_size* - size = comm.size*my_size # Make sure size is a integer multiple of comm.size - my_offset = comm.rank*my_size + # This is the complete vector vec = np.zeros(size) # Every element zero... @@ -83,11 +91,13 @@ def mvp_main(BENCHMARH="Matrix-vector multiplication", # if fabs(vec[iter]-1.0) > 0.01: # pprint("!! Error: Wrong result!") - pprint(" %d iterations of size %d in %5.2fs: %5.2f iterations per second" % - (20, size, t_diff, 20/t_diff) - ) + # pprint(" %d iterations of size %d in %5.2fs: %5.2f iterations per second" % + # (bs, size, t_diff, bs/t_diff) + # ) + if myid == 0: + print ('%-10d%20.2f' % (t_diff, bs/t_diff)) - counter += 20 + counter += bs From 5d66fd30ea25ffefe157af1385e8e19263da58c4 Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 12:33:00 +0200 Subject: [PATCH 37/56] fixed matvec test output --- mpi4py_benchmarks/all_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mpi4py_benchmarks/all_tests.py b/mpi4py_benchmarks/all_tests.py index 23643ad..f2f7e00 100644 --- a/mpi4py_benchmarks/all_tests.py +++ b/mpi4py_benchmarks/all_tests.py @@ -95,7 +95,7 @@ def mvp_main(BENCHMARH="Matrix-vector multiplication", # (bs, size, t_diff, bs/t_diff) # ) if myid == 0: - print ('%-10d%20.2f' % (t_diff, bs/t_diff)) + print ('%-10.1f%20.2f' % (t_diff, bs/t_diff)) counter += bs From d0bdf45ec607b10ffc50bba86fe132460966741c Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 12:33:59 +0200 Subject: [PATCH 38/56] fixed matvec test output --- mpi4py_benchmarks/all_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mpi4py_benchmarks/all_tests.py b/mpi4py_benchmarks/all_tests.py index f2f7e00..619b77b 100644 --- a/mpi4py_benchmarks/all_tests.py +++ b/mpi4py_benchmarks/all_tests.py @@ -95,7 +95,7 @@ def mvp_main(BENCHMARH="Matrix-vector multiplication", # (bs, size, t_diff, bs/t_diff) # ) if myid == 0: - print ('%-10.1f%20.2f' % (t_diff, bs/t_diff)) + print ('%-10.3f%20.2f' % (t_diff, bs/t_diff)) counter += bs From ef7a42808b7d1bd849f1ffe1662b880dda847dd0 Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 12:36:19 +0200 Subject: [PATCH 39/56] fixed matvec test output --- mpi4py_benchmarks/all_tests.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mpi4py_benchmarks/all_tests.py b/mpi4py_benchmarks/all_tests.py index 619b77b..e91e339 100644 --- a/mpi4py_benchmarks/all_tests.py +++ b/mpi4py_benchmarks/all_tests.py @@ -56,9 +56,10 @@ def mvp_main(BENCHMARH="Matrix-vector multiplication", if myid == 0: print ('# %s' % (BENCHMARH,)) + print(" %d iterations of size %d " % (bs, size)) print ('# %-8s%20s' % ("Duration [s]", "Throughput [#/s]")) - pprint(" %d iterations of size %d " % (bs, size)) + # pprint(" %d iterations of size %d " % (bs, size)) From 585bd073b4be454a7c094525167784a546cce7f2 Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 12:41:10 +0200 Subject: [PATCH 40/56] fixed matvec test output --- mpi4py_benchmarks/all_tests.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mpi4py_benchmarks/all_tests.py b/mpi4py_benchmarks/all_tests.py index e91e339..e169636 100644 --- a/mpi4py_benchmarks/all_tests.py +++ b/mpi4py_benchmarks/all_tests.py @@ -33,7 +33,7 @@ def pprint(str="", end="\n", comm=MPI.COMM_WORLD): #============================================================================= # Main -def mvp_main(BENCHMARH="Matrix-vector multiplication", +def mvp_main(BENCHMARH="MPI Matrix action on a vector", size=10000, iter=200): # size = 10000 # length of vector v @@ -55,8 +55,7 @@ def mvp_main(BENCHMARH="Matrix-vector multiplication", bs = 20 # batch size if myid == 0: - print ('# %s' % (BENCHMARH,)) - print(" %d iterations of size %d " % (bs, size)) + print ('# %s, %d iterations of size %d' % (BENCHMARH, bs, size)) print ('# %-8s%20s' % ("Duration [s]", "Throughput [#/s]")) # pprint(" %d iterations of size %d " % (bs, size)) From a0a16bd9e0079495caa28bc3321457fa8615fbd9 Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 13:01:44 +0200 Subject: [PATCH 41/56] fixed all_tests.py --- makefile | 5 +++ mpi4py_benchmarks/all_tests.py | 63 +++++++++++++--------------------- 2 files changed, 28 insertions(+), 40 deletions(-) diff --git a/makefile b/makefile index e5f636f..3a45f97 100644 --- a/makefile +++ b/makefile @@ -20,6 +20,11 @@ rebuild: docker build --no-cache -t $(TAG) . main: + # 1 worker node + docker-compose scale mpi_head=1 mpi_node=1 + docker-compose exec --privileged mpi_head mpirun -n 1 python /home/mpirun/mpi4py_benchmarks/all_tests.py + docker-compose down + # 2 worker nodes docker-compose scale mpi_head=1 mpi_node=${NNODES} docker-compose exec --privileged mpi_head mpirun -n ${NNODES} python /home/mpirun/mpi4py_benchmarks/all_tests.py docker-compose down diff --git a/mpi4py_benchmarks/all_tests.py b/mpi4py_benchmarks/all_tests.py index e169636..d581b2e 100644 --- a/mpi4py_benchmarks/all_tests.py +++ b/mpi4py_benchmarks/all_tests.py @@ -116,19 +116,11 @@ def osu_latency( myid = comm.Get_rank() numprocs = comm.Get_size() - if numprocs != 2: - if myid == 0: - errmsg = "This test requires exactly two processes" - else: - errmsg = None - raise SystemExit(errmsg) - s_buf = allocate(MAX_MSG_SIZE) r_buf = allocate(MAX_MSG_SIZE) if myid == 0: print ('# %s' % (BENCHMARH,)) - if myid == 0: print ('# %-8s%20s' % ("Size [B]", "Latency [us]")) message_sizes = [0] + [2**i for i in range(30)] @@ -141,23 +133,23 @@ def osu_latency( iterations = list(range(loop+skip)) s_msg = [s_buf, size, MPI.BYTE] r_msg = [r_buf, size, MPI.BYTE] - # + comm.Barrier() if myid == 0: - for i in iterations: - if i == skip: - t_start = MPI.Wtime() - comm.Send(s_msg, 1, 1) - comm.Recv(r_msg, 1, 1) - t_end = MPI.Wtime() + for i in iterations: + if i == skip: + t_start = MPI.Wtime() + comm.Send(s_msg, 1, 1) + comm.Recv(r_msg, 1, 1) + t_end = MPI.Wtime() elif myid == 1: - for i in iterations: - comm.Recv(r_msg, 0, 1) - comm.Send(s_msg, 0, 1) - # + for i in iterations: + comm.Recv(r_msg, 0, 1) + comm.Send(s_msg, 0, 1) + if myid == 0: - latency = (t_end - t_start) * 1e6 / (2 * loop) - print ('%-10d%20.2f' % (size, latency)) + latency = (t_end - t_start) * 1e6 / (2 * loop) + print ('%-10d%20.2f' % (size, latency)) def osu_bibw( BENCHMARH = "MPI Bi-Directional Bandwidth Test", @@ -175,19 +167,11 @@ def osu_bibw( myid = comm.Get_rank() numprocs = comm.Get_size() - if numprocs != 2: - if myid == 0: - errmsg = "This test requires exactly two processes" - else: - errmsg = None - raise SystemExit(errmsg) - s_buf = allocate(MAX_MSG_SIZE) r_buf = allocate(MAX_MSG_SIZE) if myid == 0: print ('# %s' % (BENCHMARH,)) - if myid == 0: print ('# %-8s%20s' % ("Size [B]", "Bandwidth [MB/s]")) message_sizes = [2**i for i in range(30)] @@ -249,19 +233,11 @@ def osu_bw( myid = comm.Get_rank() numprocs = comm.Get_size() - if numprocs != 2: - if myid == 0: - errmsg = "This test requires exactly two processes" - else: - errmsg = None - raise SystemExit(errmsg) - s_buf = allocate(MAX_MSG_SIZE) r_buf = allocate(MAX_MSG_SIZE) if myid == 0: print ('# %s' % (BENCHMARH,)) - if myid == 0: print ('# %-8s%20s' % ("Size [B]", "Bandwidth [MB/s]")) message_sizes = [2**i for i in range(30)] @@ -320,6 +296,13 @@ def allocate(n): if __name__ == '__main__': mvp_main() - osu_latency() - osu_bw() - osu_bibw() + comm = MPI.COMM_WORLD + myid = comm.Get_rank() + numprocs = comm.Get_size() + if numprocs==2 : + osu_latency() + osu_bw() + osu_bibw() + else: + if myid==0: + print ("OSU examples require exactly 2 compute nodes") From c9683f57430a8fce495ea6f6bc65aa9cc7117071 Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 13:04:48 +0200 Subject: [PATCH 42/56] fixed all_tests.py --- mpi4py_benchmarks/all_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mpi4py_benchmarks/all_tests.py b/mpi4py_benchmarks/all_tests.py index d581b2e..13415fa 100644 --- a/mpi4py_benchmarks/all_tests.py +++ b/mpi4py_benchmarks/all_tests.py @@ -305,4 +305,4 @@ def allocate(n): osu_bibw() else: if myid==0: - print ("OSU examples require exactly 2 compute nodes") + print ("# Warning ! OSU examples require MPI rank size == 2. Not running since rank size = %d" % (numprocs)) From cb9d1e9d29a329149bada697570c2eb66e55b31b Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 13:14:00 +0200 Subject: [PATCH 43/56] upd readme --- Readme.md | 15 +++++---------- makefile | 2 +- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Readme.md b/Readme.md index dd993ee..fd5e4a9 100644 --- a/Readme.md +++ b/Readme.md @@ -10,8 +10,7 @@ so that multiple containers can be linked together and used via `mpirun`. While containers can in principle be started manually via `docker run`, we suggest that your use [Docker Compose](https://docs.docker.com/compose/), a simple command-line tool -to define and run multi-container applications. We provde a sample `docker-compose.yml` -file in the repository: +to define and run multi-container applications. We provde a sample `docker-compose.yml` file in the repository: ``` mpi_head: @@ -19,7 +18,7 @@ mpi_head: ports: - "22" links: - - mpi_worker + - mpi_node mpi_node: image: openmpi @@ -27,7 +26,7 @@ mpi_node: ``` The file defines an `mpi_head` and an `mpi_node`. Both containers run the same `openmpi` image. -The only difference is, that the `mpi_head` container exposes its SHH server to +The only difference is, that the `mpi_head` container exposes its SSH server to the host system, so you can log into it to start your MPI applications. @@ -42,10 +41,6 @@ Once all containers are running, figure out the host port on which Docker expose $> ``` -Now you know the port, you can login to the `mpi_head` conatiner. The username is `mpirun`: +You can spin up a docker-compose cluster, run a battery of MPI4py tests and remove the cluster using a recipe provided in the included Makefile: -> TODO: Password - - ``` - $> ssh -p 23227 mpirun@localhost - ``` \ No newline at end of file + make main diff --git a/makefile b/makefile index 3a45f97..93f8b3d 100644 --- a/makefile +++ b/makefile @@ -2,7 +2,7 @@ AUTH=ocramz NAME=docker-openmpi TAG=${AUTH}/${NAME} -export NNODES=2 +export NNODES=4 .DEFAULT_GOAL := help From 5d22b76b1fce73e5f85a38a60cecd858e94fc57a Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 13:15:48 +0200 Subject: [PATCH 44/56] upd readme --- makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makefile b/makefile index 93f8b3d..72d06e3 100644 --- a/makefile +++ b/makefile @@ -24,7 +24,7 @@ main: docker-compose scale mpi_head=1 mpi_node=1 docker-compose exec --privileged mpi_head mpirun -n 1 python /home/mpirun/mpi4py_benchmarks/all_tests.py docker-compose down - # 2 worker nodes + # ${NNODES} worker nodes docker-compose scale mpi_head=1 mpi_node=${NNODES} docker-compose exec --privileged mpi_head mpirun -n ${NNODES} python /home/mpirun/mpi4py_benchmarks/all_tests.py docker-compose down From caec28809ac38ebc0610968ee2aa3ef21fb78dbd Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 13:16:35 +0200 Subject: [PATCH 45/56] upd makefile --- makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/makefile b/makefile index 72d06e3..d422c5f 100644 --- a/makefile +++ b/makefile @@ -24,6 +24,12 @@ main: docker-compose scale mpi_head=1 mpi_node=1 docker-compose exec --privileged mpi_head mpirun -n 1 python /home/mpirun/mpi4py_benchmarks/all_tests.py docker-compose down + + # 2 worker nodes + docker-compose scale mpi_head=1 mpi_node=2 + docker-compose exec --privileged mpi_head mpirun -n 2 python /home/mpirun/mpi4py_benchmarks/all_tests.py + docker-compose down + # ${NNODES} worker nodes docker-compose scale mpi_head=1 mpi_node=${NNODES} docker-compose exec --privileged mpi_head mpirun -n ${NNODES} python /home/mpirun/mpi4py_benchmarks/all_tests.py From 174d4f7fbd47473ced680872afdcb17c288eea32 Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 13:21:46 +0200 Subject: [PATCH 46/56] upd readme --- Readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Readme.md b/Readme.md index fd5e4a9..1191feb 100644 --- a/Readme.md +++ b/Readme.md @@ -1,5 +1,7 @@ ## docker.openmpi +Travis CI: [![Build Status](https://travis-ci.org/ocramz/docker.openmpi.svg?branch=master)](https://travis-ci.org/ocramz/docker.openmpi) + With the code in this repository, you can build a Docker container that provides the OpenMPI runtime and tools along with various supporting libaries, including the MPI4Py Python bindings. The container also runs an OpenSSH server From cfa7d9224e7965517d0343493affa6cc54f101e9 Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 13:28:14 +0200 Subject: [PATCH 47/56] upd readme --- Readme.md | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Readme.md b/Readme.md index 1191feb..cfd2b2b 100644 --- a/Readme.md +++ b/Readme.md @@ -8,11 +8,11 @@ including the MPI4Py Python bindings. The container also runs an OpenSSH server so that multiple containers can be linked together and used via `mpirun`. -## Start an MPI Container Cluster +## MPI Container Cluster with `docker-compose` While containers can in principle be started manually via `docker run`, we suggest that your use [Docker Compose](https://docs.docker.com/compose/), a simple command-line tool -to define and run multi-container applications. We provde a sample `docker-compose.yml` file in the repository: +to define and run multi-container applications. We provide a sample `docker-compose.yml` file in the repository: ``` mpi_head: @@ -26,23 +26,32 @@ mpi_node: image: openmpi ``` +(Note: the above is docker-compose API version 1) The file defines an `mpi_head` and an `mpi_node`. Both containers run the same `openmpi` image. The only difference is, that the `mpi_head` container exposes its SSH server to the host system, so you can log into it to start your MPI applications. +## Usage + The following command will start one `mpi_head` container and three `mpi_node` containers: ``` $> docker-compose scale mpi_head=1 mpi_worker=3 ``` -Once all containers are running, figure out the host port on which Docker exposes the SSH server of the `mpi_head` container: +Once all containers are running, you can login into the `mpi_head` node and start MPI jobs with `mpirun`. Alternatively, you can execute a one-shot + + docker-compose exec --privileged mpi_head mpirun -n 1 python /home/mpirun/mpi4py_benchmarks/all_tests.py -``` -$> -``` + +## Testing You can spin up a docker-compose cluster, run a battery of MPI4py tests and remove the cluster using a recipe provided in the included Makefile: make main + + +## Credits + +This repository draws from work on https://github.com/dispel4py/ by O. Weidner and R. Filgueira \ No newline at end of file From 0cde14f0fd015843e5a5ec0dbf6ad9541ee51dbb Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 13:30:45 +0200 Subject: [PATCH 48/56] upd readme --- Readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Readme.md b/Readme.md index cfd2b2b..0174304 100644 --- a/Readme.md +++ b/Readme.md @@ -40,14 +40,14 @@ The following command will start one `mpi_head` container and three `mpi_node` c ``` $> docker-compose scale mpi_head=1 mpi_worker=3 ``` -Once all containers are running, you can login into the `mpi_head` node and start MPI jobs with `mpirun`. Alternatively, you can execute a one-shot +Once all containers are running, you can login into the `mpi_head` node and start MPI jobs with `mpirun`. Alternatively, you can execute a one-shot command on that container with the `docker-compose exec` syntax, as follows: - docker-compose exec --privileged mpi_head mpirun -n 1 python /home/mpirun/mpi4py_benchmarks/all_tests.py + docker-compose exec --privileged mpi_head mpirun -n 2 python /home/mpirun/mpi4py_benchmarks/all_tests.py ## Testing -You can spin up a docker-compose cluster, run a battery of MPI4py tests and remove the cluster using a recipe provided in the included Makefile: +You can spin up a docker-compose cluster, run a battery of MPI4py tests and remove the cluster using a recipe provided in the included Makefile (handy for development): make main From f6cee0af25cd7aeb4fb9d9bb7824bf794b6bff8f Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 13:35:13 +0200 Subject: [PATCH 49/56] upd readme --- Readme.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 0174304..5ae9d2c 100644 --- a/Readme.md +++ b/Readme.md @@ -43,7 +43,12 @@ $> docker-compose scale mpi_head=1 mpi_worker=3 Once all containers are running, you can login into the `mpi_head` node and start MPI jobs with `mpirun`. Alternatively, you can execute a one-shot command on that container with the `docker-compose exec` syntax, as follows: docker-compose exec --privileged mpi_head mpirun -n 2 python /home/mpirun/mpi4py_benchmarks/all_tests.py - + ----------------------------------------- + Execute command on node `mpi-head` + ----------- + run on 2 MPI ranks + -------------------------------------------------- + Command to run (NB: the Python script needs to import MPI bindings) ## Testing From 78165e1f90beab7d8e884b4ac3948882755952e9 Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 13:35:51 +0200 Subject: [PATCH 50/56] upd readme --- Readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 5ae9d2c..80de3c3 100644 --- a/Readme.md +++ b/Readme.md @@ -46,9 +46,9 @@ Once all containers are running, you can login into the `mpi_head` node and star ----------------------------------------- Execute command on node `mpi-head` ----------- - run on 2 MPI ranks + run on 2 MPI ranks -------------------------------------------------- - Command to run (NB: the Python script needs to import MPI bindings) + Command to run (NB: the Python script needs to import MPI bindings) ## Testing From 0ddbe4398c58d8582f32bc347e85a06efc78a3b1 Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 13:37:43 +0200 Subject: [PATCH 51/56] upd readme --- Readme.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Readme.md b/Readme.md index 80de3c3..d2a44f1 100644 --- a/Readme.md +++ b/Readme.md @@ -43,12 +43,14 @@ $> docker-compose scale mpi_head=1 mpi_worker=3 Once all containers are running, you can login into the `mpi_head` node and start MPI jobs with `mpirun`. Alternatively, you can execute a one-shot command on that container with the `docker-compose exec` syntax, as follows: docker-compose exec --privileged mpi_head mpirun -n 2 python /home/mpirun/mpi4py_benchmarks/all_tests.py - ----------------------------------------- - Execute command on node `mpi-head` - ----------- - run on 2 MPI ranks - -------------------------------------------------- - Command to run (NB: the Python script needs to import MPI bindings) + ----------------------------------------- ----------- -------------------------------------------------- + 1. 2. 3. + +Breaking the above command down: + + 1. Execute command on node `mpi-head` + 2. run on 2 MPI ranks + 3. Command to run (NB: the Python script needs to import MPI bindings) ## Testing From 2a80e7da1f0a8bb08d4d783df01b5ff2abf52919 Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 13:38:07 +0200 Subject: [PATCH 52/56] upd readme --- Readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Readme.md b/Readme.md index d2a44f1..26b7609 100644 --- a/Readme.md +++ b/Readme.md @@ -48,9 +48,9 @@ Once all containers are running, you can login into the `mpi_head` node and star Breaking the above command down: - 1. Execute command on node `mpi-head` - 2. run on 2 MPI ranks - 3. Command to run (NB: the Python script needs to import MPI bindings) +1. Execute command on node `mpi-head` +2. run on 2 MPI ranks +3. Command to run (NB: the Python script needs to import MPI bindings) ## Testing From 8ef570b9244ce283372dea0825a5165636be4fd8 Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 13:41:05 +0200 Subject: [PATCH 53/56] upd dockerfile --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 217abac..0db31f2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,8 +4,7 @@ FROM ubuntu:14.04 # FROM phusion/baseimage -MAINTAINER Marco Zocca -# based on `docker.openmpi` by Ole Weidner +MAINTAINER Ole Weidner ENV USER mpirun @@ -15,7 +14,8 @@ ENV DEBIAN_FRONTEND=noninteractive \ RUN apt-get update -y && \ apt-get upgrade -y && \ - apt-get install -y --no-install-recommends openssh-server python-mpi4py python-numpy python-virtualenv python-scipy gcc gfortran openmpi-checkpoint binutils + apt-get install -y --no-install-recommends openssh-server python-mpi4py python-numpy python-virtualenv python-scipy gcc gfortran openmpi-checkpoint binutils && \ + apt-get clean && apt-get purge && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* RUN mkdir /var/run/sshd RUN echo 'root:${USER}' | chpasswd From a64cd193cec264df9e6f41a454576f462486a030 Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 13:41:16 +0200 Subject: [PATCH 54/56] upd dockerfile, using Phusion --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0db31f2..3f919b2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ # Build this image: docker build -t mpi . # -FROM ubuntu:14.04 -# FROM phusion/baseimage +# FROM ubuntu:14.04 +FROM phusion/baseimage MAINTAINER Ole Weidner From a872d59f0244c5e419d648d0d2291c9650b3b6b0 Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 13:43:23 +0200 Subject: [PATCH 55/56] rm run_tests.sh --- run_tests.sh | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100755 run_tests.sh diff --git a/run_tests.sh b/run_tests.sh deleted file mode 100755 index 49f1d81..0000000 --- a/run_tests.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -NNODES=$1 - -pwd -ls -lsA - -mpirun -n ${NNODES} python /home/mpirun/mpi4py_benchmarks/matrix_vector_product.py -mpirun -n ${NNODES} python /home/mpirun/mpi4py_benchmarks/osu_bibw.py -mpirun -n ${NNODES} python /home/mpirun/mpi4py_benchmarks/osu_bw.py -mpirun -n ${NNODES} python /home/mpirun/mpi4py_benchmarks/osu_latency.py From 7bfce30f0cf70185b0be3e5f10dfcbaae460fa9a Mon Sep 17 00:00:00 2001 From: ocramz Date: Sat, 9 Jul 2016 14:18:43 +0200 Subject: [PATCH 56/56] openmpi-checkpoint not present for phusion/baseimage --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3f919b2..0db31f2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ # Build this image: docker build -t mpi . # -# FROM ubuntu:14.04 -FROM phusion/baseimage +FROM ubuntu:14.04 +# FROM phusion/baseimage MAINTAINER Ole Weidner