Skip to content

Commit

Permalink
Update Linux MPI sample (Azure-Samples#254)
Browse files Browse the repository at this point in the history
* Update Linux MPI sample

* Update based on feedback.

* fix travis-ci own issue
  • Loading branch information
xingwu1 authored and matthchr committed Oct 17, 2018
1 parent 52de52d commit 651e250
Show file tree
Hide file tree
Showing 13 changed files with 125 additions and 999 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* text=auto
# Set the default behavior of Linux shell scripts to lf
*.sh text eol=lf
Python/Batch/article_samples/mpi/data/* text eol=lf
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ language: python
cache: pip
python:
- 2.7
- 3.3
- 3.4
- 3.5
# disable pypy until travis upgrades to at least pypy2.6 due to cryptography
Expand All @@ -11,6 +10,9 @@ python:
#- pypy3
addons:
apt:
config:
retries: true
update: true
packages:
- oracle-java8-installer
env:
Expand Down
25 changes: 25 additions & 0 deletions Python/Batch/article_samples/mpi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## Azure Batch Python Article Samples

### Configuring the samples
In order to run the Python samples, they must be updated with Azure Batch
and Azure Storage credentials.

### Setting up the Python environment
In order to run the samples, you will need a Python interpreter compatible
with version 2.7 or 3.3+. You will also need to install the
[Azure Batch](https://pypi.python.org/pypi/azure-batch) and
[Azure Storage](https://pypi.python.org/pypi/azure-storage) python packages.
Installation can be performed using the [requirements.txt](./requirements.txt)
file via the command `pip install -r requirements.txt`

### MPI sample
The MPI sample is an introduction to running an MPI command in Azure Batch in a
Linux environment. It creates a pool with RDMA enabled virtual machines (You can
use STANDARD_A8 to replace the virtual machine size if you don't have enough
core quota). It submits a job to the pool, and then submits a task which
performs a simple MPI pingpong command. The files required by the task are
automatically uploaded to Azure Storage and then downloaded onto the nodes via
Batch resource files. When the task is done, the console output of the MPI
pingpong command is uploaded back to Azure Storage.

For more details on MPI/RDMA, visit [here](https://docs.microsoft.com/en-us/azure/virtual-machines/linux/classic/rdma-cluster).
75 changes: 0 additions & 75 deletions Python/Batch/article_samples/mpi/azure_storage_helper.py

This file was deleted.

15 changes: 15 additions & 0 deletions Python/Batch/article_samples/mpi/data/application-cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
#Command script to run pingpong performance testing on multiple machines as MPI task on Azure Batch.
#Usage: application-cmd [nodes]

#For more details of MPI/RDMA, visit: https://docs.microsoft.com/en-us/azure/virtual-machines/linux/classic/rdma-cluster

#Use the intel mpi exists in CentOS-HPC 7.4 image
source /opt/intel/impi/5.1.3.223/bin64/mpivars.sh
#prepare environment variables for intel mpi to use RDMA
export I_MPI_FABRICS=shm:dapl
export I_MPI_DAPL_PROVIDER=ofa-v2-ib0
export I_MPI_DYNAMIC_CONNECTION=0

# Run mpi application with appropriate parameters
mpirun -n $1 -ppn 1 -hosts $AZ_BATCH_HOST_LIST IMB-MPI1 pingpong
7 changes: 7 additions & 0 deletions Python/Batch/article_samples/mpi/data/coordination-cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
#Command script to run pingpong performance testing on multiple machines as MPI task on Azure Batch.
#Usage: coordination-cmd

#For more details of MPI/RDMA, visit: https://docs.microsoft.com/en-us/azure/virtual-machines/linux/classic/rdma-cluster

#Prepare environment
Original file line number Diff line number Diff line change
@@ -1,43 +1,7 @@
#!/usr/bin/env bash
#Command script to run OpenFoam application on multiple machines as MPI task on Azure Batch.
#Usage: application [nodes] [cores_per_node] [CFD iterations]

#prepare environment variables for intel mpi and openfoam
mnt=$4
source /opt/intel/impi/5.1.3.181/bin64/mpivars.sh
export MPI_ROOT=$I_MPI_ROOT
export FOAM_INST_DIR=$mnt/share/OpenFOAM
source $mnt/share/OpenFOAM/OpenFOAM-2.3.x/etc/bashrc
source /opt/intel/impi/5.1.3.223/bin64/mpivars.sh
export I_MPI_FABRICS=shm:dapl
export I_MPI_DAPL_PROVIDER=ofa-v2-ib0
export I_MPI_DYNAMIC_CONNECTION=0
export LD_LIBRARY_PATH=$mnt/share/OpenFOAM/intel64_lin:$LD_LIBRARY_PATH
# total number of processes is number of nodes multipled by number of processes per node
(( numProc = $1 * $2 ))

#prepare decomposition mesh as per total number of nodes, processes and number of iterations for openfoam
cd $mnt/share/OpenFOAM/motorBike
echo $numProc
sed -i.bak "s/SUB1/$numProc/g" system/decomposeParDict
sed -i.bak2 "s/SUB2/$1/g" system/decomposeParDict
sed -i.bak "s/SUB1/$3/g" system/controlDict
decomposePar
ls -d processor* | xargs -I {} rm -rf ./{}/0
ls -d processor* | xargs -I {} cp -r 0.org ./{}/0

# Run mpi application with appropriate parameters
mpirun -np $numProc -ppn $2 --host $5 -wdir $mnt/share/OpenFOAM/motorBike simpleFoam -parallel

# process the output
reconstructPar -latestTime
foamToVTK -latestTime

# prepare the output and compress it as result
cp $4/genimages.py VTK/
cp $4/stdout.txt VTK/
cp $4/stderr.txt VTK/
cd VTK
mv motorBike*/*.vtk .
mmv "*:*.vtk" "#1#2.vtk"
mmv "*%*.vtk" "#1#2.vtk"
tar -czf $4/VTK.tgz ../VTK/
mpirun -n $1 -ppn `nproc` --host $AZ_BATCH_HOST_LIST IMB-MPI1 pingpong

This file was deleted.

Loading

0 comments on commit 651e250

Please sign in to comment.