starpu_smpirun.in 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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=@mpiexec_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. EXTRA_OPT=""
  40. if [ "$SMPI_MAJOR" -ge 4 -o \( "$SMPI_MAJOR" = 3 -a "$SMPI_MINOR" -ge 16 \) ]
  41. then
  42. EXTRA_OPT+=" --cfg=smpi/privatization:yes"
  43. else
  44. EXTRA_OPT+=" --cfg=smpi/privatize${DASH}global${DASH}variables:yes"
  45. fi
  46. if [ -n "$TEST_LOGS" ]
  47. then
  48. # Testsuite, use our loader
  49. WRAPPER="-wrapper $BUILDDIR/../tests/loader"
  50. fi
  51. # When executed from source, take xslt from source
  52. [ "$0" -ef $BUILDDIR/starpu_smpirun ] && STARPU_XSLTDIR=$SOURCE_DATADIR
  53. MPI_PLATFORM=""
  54. MPI_HOSTFILE=""
  55. NP=""
  56. GDB=""
  57. while true; do
  58. case "$1" in
  59. "-platform")
  60. MPI_PLATFORM=$2
  61. if [ ! -r "$MPI_PLATFORM" ]; then
  62. echo "$MPI_PLATFORM can't be read"
  63. exit 1
  64. fi
  65. shift 2
  66. ;;
  67. "-hostfile")
  68. MPI_HOSTFILE=$2
  69. if [ ! -r "$MPI_HOSTFILE" ]; then
  70. echo "$MPI_HOSTFILE can't be read"
  71. exit 1
  72. fi
  73. shift 2
  74. ;;
  75. "-np")
  76. NP=$2
  77. shift 2
  78. ;;
  79. "-gdb")
  80. GDB="-gdb"
  81. shift 1
  82. ;;
  83. *)
  84. break
  85. ;;
  86. esac
  87. done
  88. if [ -z "$MPI_PLATFORM" ] || [ -z "$MPI_HOSTFILE" ]; then
  89. echo "$0 -platform PLATFORM -hostfile HOSTFILE [ -np N ] [ -gdb ] [ ... ] program [ args ]"
  90. exit 2
  91. fi
  92. PLATFORM=$(mktemp /tmp/StarPU-MPI-platform-XXXXXXXX.xml)
  93. [ -n "$STARPU_HOME" ] || STARPU_HOME=$HOME
  94. [ -n "$STARPU_PERF_MODEL_DIR" ] || STARPU_PERF_MODEL_DIR=$STARPU_HOME/.starpu/sampling
  95. [ -n "$STARPU_HOSTNAME" ] || STARPU_HOSTNAME=$(hostname)
  96. NODE_PLATFORM=$STARPU_PERF_MODEL_DIR/bus/${STARPU_HOSTNAME}.platform$VF.xml
  97. [ -n "$NP" ] || NP=$(grep -v "^$" $MPI_HOSTFILE | wc -l)
  98. if ! type xsltproc > /dev/null 2> /dev/null
  99. then
  100. echo xsltproc is needed for starpu simgrid mpi.
  101. exit 1
  102. fi
  103. (
  104. cat << EOF
  105. <?xml version='1.0'?>
  106. <!DOCTYPE platform SYSTEM "$DTD">
  107. <platform version="$V">
  108. <AS id="ASroot" routing="None">
  109. EOF
  110. tail -n +3 $MPI_PLATFORM | grep -v '<platform' | grep -v '</platform'
  111. for i in $(seq 0 $((NP - 1))) ; do
  112. xsltproc --novalid --stringparam ASname StarPU-MPI$i $STARPU_XSLTDIR/starpu_smpi.xslt $NODE_PLATFORM | grep -v network/ | tail -n +4 | head -n -1
  113. done
  114. cat << \EOF
  115. </AS>
  116. </platform>
  117. EOF
  118. ) > $PLATFORM
  119. STACKSIZE=$(ulimit -s)
  120. [ "$STACKSIZE" != unlimited ] || STACKSIZE=8192
  121. $SMPIRUN $WRAPPER $GDB -platform $PLATFORM -hostfile $MPI_HOSTFILE -np $NP "$@" $EXTRA_OPT --cfg=smpi/simulate${DASH}computation:no --cfg=contexts/stack${DASH}size:$STACKSIZE
  122. RET=$?
  123. rm -f $PLATFORM
  124. exit $RET