starpu_smpirun.in 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #!/bin/bash
  2. # StarPU --- Runtime system for heterogeneous multicore architectures.
  3. #
  4. # Copyright (C) 2014-2016 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. STARPU_XSLTDIR=$STARPU_DATADIR/starpu
  21. SOURCE_DATADIR=@abs_srcdir@
  22. BUILDDIR=@abs_builddir@
  23. SMPI_VERSION=$($SMPIRUN -version | grep " version " | sed -e 's/.* \([0-9]*\.[0-9]*\).*/\1/')
  24. SMPI_MAJOR=${SMPI_VERSION%.*}
  25. SMPI_MINOR=${SMPI_VERSION#*.}
  26. if [ "$SMPI_MAJOR" -ge 4 -o \( "$SMPI_MAJOR" = 3 -a "$SMPI_MINOR" -ge 13 \) ]
  27. then
  28. DTD=http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd
  29. V=4
  30. VF=.v4
  31. DASH=-
  32. else
  33. DTD=http://simgrid.gforge.inria.fr/simgrid.dtd
  34. V=3
  35. VF=""
  36. DASH=_
  37. fi
  38. # When executed from source, take xslt from source
  39. [ "$0" -ef $BUILDDIR/starpu_smpirun ] && STARPU_XSLTDIR=$SOURCE_DATADIR
  40. MPI_PLATFORM=""
  41. MPI_HOSTFILE=""
  42. NP=""
  43. while true; do
  44. case "$1" in
  45. "-platform")
  46. MPI_PLATFORM=$2
  47. if [ ! -r "$MPI_PLATFORM" ]; then
  48. echo "$MPI_PLATFORM can't be read"
  49. exit 1
  50. fi
  51. shift 2
  52. ;;
  53. "-hostfile")
  54. MPI_HOSTFILE=$2
  55. if [ ! -r "$MPI_HOSTFILE" ]; then
  56. echo "$MPI_HOSTFILE can't be read"
  57. exit 1
  58. fi
  59. shift 2
  60. ;;
  61. "-np")
  62. NP=$2
  63. shift 2
  64. ;;
  65. *)
  66. break
  67. ;;
  68. esac
  69. done
  70. if [ -z "$MPI_PLATFORM" ] || [ -z "$MPI_HOSTFILE" ]; then
  71. echo "$0 -platform PLATFORM -hostfile HOSTFILE [ -np N ] [ ... ] program [ args ]"
  72. exit 2
  73. fi
  74. PLATFORM=$(mktemp /tmp/StarPU-MPI-platform-XXXXXXXX.xml)
  75. [ -n "$STARPU_HOME" ] || STARPU_HOME=$HOME
  76. [ -n "$STARPU_PERF_MODEL_DIR" ] || STARPU_PERF_MODEL_DIR=$STARPU_HOME/.starpu/sampling
  77. [ -n "$STARPU_HOSTNAME" ] || STARPU_HOSTNAME=$(hostname)
  78. NODE_PLATFORM=$STARPU_PERF_MODEL_DIR/bus/${STARPU_HOSTNAME}.platform$VF.xml
  79. [ -n "$NP" ] || NP=$(grep -v "^$" $MPI_HOSTFILE | wc -l)
  80. if ! type xsltproc > /dev/null 2> /dev/null
  81. then
  82. echo xsltproc is needed for starpu simgrid mpi.
  83. exit 1
  84. fi
  85. (
  86. cat << EOF
  87. <?xml version='1.0'?>
  88. <!DOCTYPE platform SYSTEM "$DTD">
  89. <platform version="$V">
  90. <AS id="ASroot" routing="None">
  91. EOF
  92. tail -n +3 $MPI_PLATFORM | grep -v '<platform' | grep -v '</platform'
  93. for i in $(seq 0 $((NP - 1))) ; do
  94. xsltproc --novalid --stringparam ASname StarPU-MPI$i $STARPU_XSLTDIR/starpu_smpi.xslt $NODE_PLATFORM | grep -v network/ | tail -n +4 | head -n -1
  95. done
  96. cat << \EOF
  97. </AS>
  98. </platform>
  99. EOF
  100. ) > $PLATFORM
  101. STACKSIZE=$(ulimit -s)
  102. [ "$STACKSIZE" != unlimited ] || STACKSIZE=8192
  103. $SMPIRUN -platform $PLATFORM -hostfile $MPI_HOSTFILE -np $NP "$@" --cfg=smpi/privatize${DASH}global${DASH}variables:yes --cfg=smpi/simulate${DASH}computation:no --cfg=contexts/stack${DASH}size:$STACKSIZE
  104. RET=$?
  105. rm -f $PLATFORM
  106. exit $RET