starpu_smpirun.in 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #!/bin/bash
  2. # StarPU --- Runtime system for heterogeneous multicore architectures.
  3. #
  4. # Copyright (C) 2014-2015 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. [ "$(realpath $0)" = $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_PERF_MODEL_DIR" ] || STARPU_PERF_MODEL_DIR=$HOME/.starpu/sampling
  61. [ -n "$STARPU_HOSTNAME" ] || STARPU_HOSTNAME=$(hostname)
  62. NODE_PLATFORM=$STARPU_PERF_MODEL_DIR/bus/${STARPU_HOSTNAME}.platform.xml
  63. [ -n "$NP" ] || NP=$(grep -v "^$" $MPI_HOSTFILE | wc -l)
  64. (
  65. cat << \EOF
  66. <?xml version='1.0'?>
  67. <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
  68. <platform version="3">
  69. <AS id="ASroot" routing="None">
  70. EOF
  71. tail -n +3 $MPI_PLATFORM | grep -v '<platform' | grep -v '</platform'
  72. for i in $(seq 0 $((NP - 1))) ; do
  73. xsltproc --novalid --stringparam ASname StarPU-MPI$i $STARPU_XSLTDIR/starpu_smpi.xslt $NODE_PLATFORM | grep -v network/ | tail -n +4 | head -n -1
  74. done
  75. cat << \EOF
  76. </AS>
  77. </platform>
  78. EOF
  79. ) > $PLATFORM
  80. STACKSIZE=$(ulimit -s)
  81. [ "$STACKSIZE" != unlimited ] || STACKSIZE=8192
  82. $SMPIRUN -platform $PLATFORM -hostfile $MPI_HOSTFILE "$@" --cfg=smpi/privatize_global_variables:yes --cfg=contexts/stack_size:$STACKSIZE
  83. RET=$?
  84. rm -f $PLATFORM
  85. exit $RET