Skip to content

Instantly share code, notes, and snippets.

@prnthh
Created January 20, 2019 08:39
Show Gist options
  • Select an option

  • Save prnthh/f49cdedd892ba0da50f2bb2d7eb4a635 to your computer and use it in GitHub Desktop.

Select an option

Save prnthh/f49cdedd892ba0da50f2bb2d7eb4a635 to your computer and use it in GitHub Desktop.
Script to run Game of Life on MPI
#!/bin/bash
testvalues=( 4 8 16 32 64 128 256 512 1024 2048 )
echo
echo "Conway's Game of Life Parallel Simulation"
echo "========================================="
echo
echo "========================================="
#for single threaded
echo "Linear Execution Time"
echo
for i in "${testvalues[@]}"
do
echo "size: $i x $i: " `./Linear/gameoflife -r $i -c $i | tr '\n' ' ' | awk 'NF{ print $NF }'`
done
echo
echo "========================================="
#for multiple threaded
echo "openMP Execution Time"
echo
for j in 4 16
do
for i in "${testvalues[@]}"
do
echo "size: $i x $i and threads: $j: " `mpiexec -n $j ./openMP/openmpMasterThreadCommunication/gameoflife -r $i -c $i | tr '\n' ' ' | awk 'NF{ print $NF }'`
done
done
echo
echo "========================================="
#for single host multi processor
echo "MPI Execution Time(Single Host)"
echo
for j in 4 16
do
for i in "${testvalues[@]}"
do
echo "size: $i x $i and threads: $j: " `mpirun -np $j --hosts thispc ~/GameOfLife-MPI-OpenMp-Cuda--master/MPI/gameoflife -r $i -c $i | tr '\n' ' ' | awk 'NF{ print $NF }'`
done
done
echo
echo "========================================="
#for multiple hosts
echo "MPI Execution Time(Multiple Hosts)"
echo
for j in 4 16
do
for i in "${testvalues[@]}"
do
echo "size: $i x $i and threads: $j: " `mpirun -np $j --hosts thispc,nextpc ~/GameOfLife-MPI-OpenMp-Cuda--master/MPI/gameoflife -r $i -c $i | tr '\n' ' ' | awk 'NF{ print $NF }'`
done
done
echo
echo "========================================="
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment