starpu_smpirun.in 3.4 KB

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