starpu_smpirun.in 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. # When executed from source, take xslt from source
  24. [ "$0" -ef $BUILDDIR/starpu_smpirun ] && STARPU_XSLTDIR=$SOURCE_DATADIR
  25. MPI_PLATFORM=""
  26. MPI_HOSTFILE=""
  27. NP=""
  28. while true; do
  29. case "$1" in
  30. "-platform")
  31. MPI_PLATFORM=$2
  32. if [ ! -r "$MPI_PLATFORM" ]; then
  33. echo "$MPI_PLATFORM can't be read"
  34. exit 1
  35. fi
  36. shift 2
  37. ;;
  38. "-hostfile")
  39. MPI_HOSTFILE=$2
  40. if [ ! -r "$MPI_HOSTFILE" ]; then
  41. echo "$MPI_HOSTFILE can't be read"
  42. exit 1
  43. fi
  44. shift 2
  45. ;;
  46. "-np")
  47. NP=$2
  48. shift 2
  49. ;;
  50. *)
  51. break
  52. ;;
  53. esac
  54. done
  55. if [ -z "$MPI_PLATFORM" ] || [ -z "$MPI_HOSTFILE" ]; then
  56. echo "$0 -platform PLATFORM -hostfile HOSTFILE [ -np N ] [ ... ] program [ args ]"
  57. exit 2
  58. fi
  59. PLATFORM=$(mktemp /tmp/StarPU-MPI-platform-XXXXXXXX.xml)
  60. [ -n "$STARPU_HOME" ] || STARPU_HOME=$HOME
  61. [ -n "$STARPU_PERF_MODEL_DIR" ] || STARPU_PERF_MODEL_DIR=$STARPU_HOME/.starpu/sampling
  62. [ -n "$STARPU_HOSTNAME" ] || STARPU_HOSTNAME=$(hostname)
  63. NODE_PLATFORM=$STARPU_PERF_MODEL_DIR/bus/${STARPU_HOSTNAME}.platform.xml
  64. [ -n "$NP" ] || NP=$(grep -v "^$" $MPI_HOSTFILE | wc -l)
  65. if ! type xsltproc > /dev/null 2> /dev/null
  66. then
  67. echo xsltproc is needed for starpu simgrid mpi.
  68. exit 1
  69. fi
  70. (
  71. cat << \EOF
  72. <?xml version='1.0'?>
  73. <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
  74. <platform version="3">
  75. <AS id="ASroot" routing="None">
  76. EOF
  77. tail -n +3 $MPI_PLATFORM | grep -v '<platform' | grep -v '</platform'
  78. for i in $(seq 0 $((NP - 1))) ; do
  79. xsltproc --novalid --stringparam ASname StarPU-MPI$i $STARPU_XSLTDIR/starpu_smpi.xslt $NODE_PLATFORM | grep -v network/ | tail -n +4 | head -n -1
  80. done
  81. cat << \EOF
  82. </AS>
  83. </platform>
  84. EOF
  85. ) > $PLATFORM
  86. STACKSIZE=$(ulimit -s)
  87. [ "$STACKSIZE" != unlimited ] || STACKSIZE=8192
  88. $SMPIRUN -platform $PLATFORM -hostfile $MPI_HOSTFILE "$@" --cfg=smpi/privatize_global_variables:yes --cfg=smpi/simulate_computation:no --cfg=contexts/stack_size:$STACKSIZE
  89. RET=$?
  90. rm -f $PLATFORM
  91. exit $RET