starpu_smpirun.in 2.3 KB

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