starpu_smpirun.in 3.4 KB

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