starpu_smpirun.in 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #!/bin/bash
  2. # StarPU --- Runtime system for heterogeneous multicore architectures.
  3. #
  4. # Copyright (C) 2017 CNRS
  5. # Copyright (C) 2016 Inria
  6. # Copyright (C) 2014-2016,2019 Université de Bordeaux
  7. #
  8. # StarPU is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU Lesser General Public License as published by
  10. # the Free Software Foundation; either version 2.1 of the License, or (at
  11. # your option) any later version.
  12. #
  13. # StarPU is distributed in the hope that it will be useful, but
  14. # WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  16. #
  17. # See the GNU Lesser General Public License in COPYING.LGPL for more details.
  18. #
  19. # Script for running starpu-mpi application in simgrid mode
  20. prefix=@prefix@
  21. SMPIRUN=@smpirun_path@
  22. STARPU_DATADIR=@datarootdir@
  23. STARPU_XSLTDIR=$STARPU_DATADIR/starpu
  24. SOURCE_DATADIR=@abs_srcdir@
  25. BUILDDIR=@abs_builddir@
  26. SMPI_VERSION=$($SMPIRUN -version | grep " version " | sed -e 's/.* \([0-9]*\.[0-9]*\).*/\1/')
  27. SMPI_MAJOR=${SMPI_VERSION%.*}
  28. SMPI_MINOR=${SMPI_VERSION#*.}
  29. if [ "$SMPI_MAJOR" -ge 4 -o \( "$SMPI_MAJOR" = 3 -a "$SMPI_MINOR" -ge 13 \) ]
  30. then
  31. DTD=http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd
  32. V=4
  33. VF=.v4
  34. DASH=-
  35. else
  36. DTD=http://simgrid.gforge.inria.fr/simgrid.dtd
  37. V=3
  38. VF=""
  39. DASH=_
  40. fi
  41. if [ "$SMPI_MAJOR" -ge 4 -o \( "$SMPI_MAJOR" = 3 -a "$SMPI_MINOR" -ge 16 \) ]
  42. then
  43. PRIV_OPT="--cfg=smpi/privatization:yes"
  44. else
  45. PRIV_OPT="--cfg=smpi/privatize${DASH}global${DASH}variables:yes"
  46. fi
  47. # When executed from source, take xslt from source
  48. [ "$0" -ef $BUILDDIR/starpu_smpirun ] && STARPU_XSLTDIR=$SOURCE_DATADIR
  49. MPI_PLATFORM=""
  50. MPI_HOSTFILE=""
  51. NP=""
  52. while true; do
  53. case "$1" in
  54. "-platform")
  55. MPI_PLATFORM=$2
  56. if [ ! -r "$MPI_PLATFORM" ]; then
  57. echo "$MPI_PLATFORM can't be read"
  58. exit 1
  59. fi
  60. shift 2
  61. ;;
  62. "-hostfile")
  63. MPI_HOSTFILE=$2
  64. if [ ! -r "$MPI_HOSTFILE" ]; then
  65. echo "$MPI_HOSTFILE can't be read"
  66. exit 1
  67. fi
  68. shift 2
  69. ;;
  70. "-np")
  71. NP=$2
  72. shift 2
  73. ;;
  74. *)
  75. break
  76. ;;
  77. esac
  78. done
  79. if [ -z "$MPI_PLATFORM" ] || [ -z "$MPI_HOSTFILE" ]; then
  80. echo "$0 -platform PLATFORM -hostfile HOSTFILE [ -np N ] [ ... ] program [ args ]"
  81. exit 2
  82. fi
  83. PLATFORM=$(mktemp /tmp/StarPU-MPI-platform-XXXXXXXX.xml)
  84. [ -n "$STARPU_HOME" ] || STARPU_HOME=$HOME
  85. [ -n "$STARPU_PERF_MODEL_DIR" ] || STARPU_PERF_MODEL_DIR=$STARPU_HOME/.starpu/sampling
  86. [ -n "$STARPU_HOSTNAME" ] || STARPU_HOSTNAME=$(hostname)
  87. NODE_PLATFORM=$STARPU_PERF_MODEL_DIR/bus/${STARPU_HOSTNAME}.platform$VF.xml
  88. [ -n "$NP" ] || NP=$(grep -v "^$" $MPI_HOSTFILE | wc -l)
  89. if ! type xsltproc > /dev/null 2> /dev/null
  90. then
  91. echo xsltproc is needed for starpu simgrid mpi.
  92. exit 1
  93. fi
  94. (
  95. cat << EOF
  96. <?xml version='1.0'?>
  97. <!DOCTYPE platform SYSTEM "$DTD">
  98. <platform version="$V">
  99. <AS id="ASroot" routing="None">
  100. EOF
  101. tail -n +3 $MPI_PLATFORM | grep -v '<platform' | grep -v '</platform'
  102. for i in $(seq 0 $((NP - 1))) ; do
  103. xsltproc --novalid --stringparam ASname StarPU-MPI$i $STARPU_XSLTDIR/starpu_smpi.xslt $NODE_PLATFORM | grep -v network/ | tail -n +4 | head -n -1
  104. done
  105. cat << \EOF
  106. </AS>
  107. </platform>
  108. EOF
  109. ) > $PLATFORM
  110. STACKSIZE=$(ulimit -s)
  111. [ "$STACKSIZE" != unlimited ] || STACKSIZE=8192
  112. $SMPIRUN -platform $PLATFORM -hostfile $MPI_HOSTFILE -np $NP "$@" $PRIV_OPT --cfg=smpi/simulate${DASH}computation:no --cfg=contexts/stack${DASH}size:$STACKSIZE
  113. RET=$?
  114. rm -f $PLATFORM
  115. exit $RET