starpu_smpirun.in 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #!/bin/bash
  2. # StarPU --- Runtime system for heterogeneous multicore architectures.
  3. #
  4. # Copyright (C) 2014-2015 Université Bordeaux
  5. #
  6. # StarPU is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU Lesser General Public License as published by
  8. # the Free Software Foundation; either version 2.1 of the License, or (at
  9. # your option) any later version.
  10. #
  11. # StarPU is distributed in the hope that it will be useful, but
  12. # WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. #
  15. # See the GNU Lesser General Public License in COPYING.LGPL for more details.
  16. # Script for running starpu-mpi application in simgrid mode
  17. prefix=@prefix@
  18. SMPIRUN=@smpirun_path@
  19. STARPU_DATADIR=@datarootdir@
  20. SOURCE_DATADIR=@abs_srcdir@
  21. BUILDDIR=@abs_builddir@
  22. # When executed from source, take xslt from source
  23. [ "$(realpath $0)" = $BUILDDIR/starpu_smpirun ] && STARPU_DATADIR=$SOURCE_DATADIR
  24. MPI_PLATFORM=""
  25. MPI_HOSTFILE=""
  26. NP=""
  27. while true; do
  28. case "$1" in
  29. "-platform")
  30. MPI_PLATFORM=$2
  31. if [ ! -r "$MPI_PLATFORM" ]; then
  32. echo "$MPI_PLATFORM can't be read"
  33. exit 1
  34. fi
  35. shift 2
  36. ;;
  37. "-hostfile")
  38. MPI_HOSTFILE=$2
  39. if [ ! -r "$MPI_HOSTFILE" ]; then
  40. echo "$MPI_HOSTFILE can't be read"
  41. exit 1
  42. fi
  43. shift 2
  44. ;;
  45. "-np")
  46. NP=$2
  47. shift 2
  48. ;;
  49. *)
  50. break
  51. ;;
  52. esac
  53. done
  54. if [ -z "$MPI_PLATFORM" ] || [ -z "$MPI_HOSTFILE" ]; then
  55. echo "$0 -platform PLATFORM -hostfile HOSTFILE [ -np N ] [ ... ] program [ args ]"
  56. exit 2
  57. fi
  58. PLATFORM=$(mktemp /tmp/StarPU-MPI-platform-XXXXXXXX.xml)
  59. [ -n "$STARPU_PERF_MODEL_DIR" ] || STARPU_PERF_MODEL_DIR=$HOME/.starpu/sampling
  60. [ -n "$STARPU_HOSTNAME" ] || STARPU_HOSTNAME=$(hostname)
  61. NODE_PLATFORM=$STARPU_PERF_MODEL_DIR/bus/${STARPU_HOSTNAME}.platform.xml
  62. [ -n "$NP" ] || NP=$(grep -v "^$" $MPI_HOSTFILE | wc -l)
  63. (
  64. cat << \EOF
  65. <?xml version='1.0'?>
  66. <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
  67. <platform version="3">
  68. <AS id="ASroot" routing="None">
  69. EOF
  70. tail -n +3 $MPI_PLATFORM | grep -v '<platform' | grep -v '</platform'
  71. for i in $(seq 0 $((NP - 1))) ; do
  72. xsltproc --novalid --stringparam ASname StarPU-MPI$i $STARPU_DATADIR/starpu/starpu_smpi.xslt $NODE_PLATFORM | grep -v network/ | tail -n +4 | head -n -1
  73. done
  74. cat << \EOF
  75. </AS>
  76. </platform>
  77. EOF
  78. ) > $PLATFORM
  79. STACKSIZE=$(ulimit -s)
  80. [ "$STACKSIZE" != unlimited ] || STACKSIZE=8192
  81. $SMPIRUN -platform $PLATFORM -hostfile $MPI_HOSTFILE "$@" --cfg=smpi/privatize_global_variables:yes --cfg=contexts/stack_size:$STACKSIZE
  82. rm -f $PLATFORM