Browse Source

starpupy/examples: launch with mpiexec when mpi master slave mode is enabled

Nathalie Furmento 4 years ago
parent
commit
f00bc36dc7
2 changed files with 39 additions and 23 deletions
  1. 5 1
      starpupy/examples/Makefile.am
  2. 34 22
      starpupy/examples/execute.sh.in

+ 5 - 1
starpupy/examples/Makefile.am

@@ -1,6 +1,6 @@
 # StarPU --- Runtime system for heterogeneous multicore architectures.
 #
-# Copyright (C) 2020       Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
+# Copyright (C) 2020-2021  Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
 #
 # StarPU is free software; you can redistribute it and/or modify
 # it under the terms of the GNU Lesser General Public License as published by
@@ -20,6 +20,10 @@ SUBDIRS =
 
 CLEANFILES = *.gcno *.gcda *.linkinfo
 
+if STARPU_USE_MPI_MASTER_SLAVE
+TESTS_ENVIRONMENT	=	$(MPI_RUN_ARGS) MPI_LAUNCHER="$(MPI_LAUNCHER)" LOADER_ARGS="--mpirun"
+endif
+
 TESTS	=
 TESTS	+=	starpu_py.sh
 TESTS	+=	starpu_py_parallel.sh

+ 34 - 22
starpupy/examples/execute.sh.in

@@ -1,7 +1,7 @@
 #!@REALBASH@
 # StarPU --- Runtime system for heterogeneous multicore architectures.
 #
-# Copyright (C) 2020       Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
+# Copyright (C) 2020-2021  Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
 #
 # StarPU is free software; you can redistribute it and/or modify
 # it under the terms of the GNU Lesser General Public License as published by
@@ -20,18 +20,38 @@ exampledir=@STARPU_SRC_DIR@/starpupy/examples
 modpath=@STARPU_BUILD_DIR@/src/.libs:
 pypath=@STARPU_BUILD_DIR@/starpupy/src/build:$PYTHONPATH
 
-valgrind=""
-gdb=""
-if test "$1" == "--valgrind"
-then
-    valgrind=1
-    shift
-fi
-if test "$1" == "--gdb"
-then
-    gdb=1
-    shift
-fi
+LOADER=@PYTHON@
+
+read_arg()
+{
+    if test "$1" == "--valgrind"
+    then
+	export PYTHONMALLOC=malloc
+	LOADER="valgrind --track-origins=yes @PYTHON@"
+	if test "$2" = "shift" ; then shift ; fi
+    elif test "$1" == "--gdb"
+    then
+	LOADER="gdb --args @PYTHON@"
+	if test "$2" = "shift" ; then shift ; fi
+    elif test "$1" == "--mpirun"
+    then
+	if test "$MPI_LAUNCHER"
+	then
+	    LOADER="$MPI_LAUNCHER @PYTHON@"
+	else
+	    LOADER="mpiexec -np 2 @PYTHON@"
+	fi
+	if test "$2" = "shift" ; then shift ; fi
+    fi
+}
+for x in $@
+do
+    read_arg $x "shift"
+done
+for x in $LOADER_ARGS
+do
+    read_arg $x
+done
 
 examplefile=$1
 if test -f $examplefile
@@ -47,13 +67,5 @@ fi
 shift
 
 set -x
-if test "$valgrind" == "1"
-then
-    PYTHONPATH=$pypath LD_LIBRARY_PATH=$modpath PYTHONMALLOC=malloc valgrind --track-origins=yes @PYTHON@ $pythonscript $*
-elif test "$gdb" == "1"
-then
-    PYTHONPATH=$pypath LD_LIBRARY_PATH=$modpath gdb --args @PYTHON@ $pythonscript $*
-else
-    PYTHONPATH=$pypath LD_LIBRARY_PATH=$modpath @PYTHON@ $pythonscript $*
-fi
+PYTHONPATH=$pypath LD_LIBRARY_PATH=$modpath $LOADER $pythonscript $*