Преглед изворни кода

Move xsltproc call to before running smpirun, because simgrid doesn't like building several platforms

Samuel Thibault пре 10 година
родитељ
комит
b0b3dbf227
5 измењених фајлова са 74 додато и 42 уклоњено
  1. 0 4
      src/Makefile.am
  2. 0 38
      src/core/simgrid.c
  3. 4 0
      tools/Makefile.am
  4. 0 0
      tools/starpu_smpi.xslt
  5. 70 0
      tools/starpu_smpirun.in

+ 0 - 4
src/Makefile.am

@@ -339,9 +339,5 @@ endif
 
 #########################################
 
-if STARPU_SIMGRID
-dist_pkgdata_DATA = starpu_smpi.xslt
-endif
-
 showcheck:
 	-cat /dev/null

+ 0 - 38
src/core/simgrid.c

@@ -214,47 +214,9 @@ void _starpu_simgrid_init()
 #ifdef HAVE_MSG_ENVIRONMENT_GET_ROUTING_ROOT
 	if (_starpu_simgrid_running_smpi())
 	{
-		/* Take back hand to create the local platform for this MPI
-		 * node */
-
 		char asname[32];
-		char path[256];
-		char cmdline[1024];
-		FILE *in;
-		int out;
-#ifdef HAVE_MKSTEMPS
-		char template[] = "/tmp/"STARPU_MPI_AS_PREFIX"-platform-XXXXXX.xml";
-#else
-		char template[] = "/tmp/"STARPU_MPI_AS_PREFIX"-platform-XXXXXX";
-#endif
-		int ret;
-
 		STARPU_ASSERT(starpu_mpi_world_rank);
 		snprintf(asname, sizeof(asname), STARPU_MPI_AS_PREFIX"%u", starpu_mpi_world_rank());
-
-		/* Get XML platform */
-		_starpu_simgrid_get_platform_path(path, sizeof(path));
-		in = fopen(path, "r");
-		_starpu_frdlock(in);
-		STARPU_ASSERT_MSG(in, "Could not open platform file %s", path);
-#ifdef HAVE_MKSTEMPS
-		out = mkstemps(template, strlen(".xml"));
-#else
-		out = mkstemp(template);
-#endif
-
-		/* Generate modified XML platform */
-		STARPU_ASSERT_MSG(out >= 0, "Could not create temporary file like %s", template);
-		close(out);
-		snprintf(cmdline, sizeof(cmdline), "xsltproc --novalid --stringparam ASname %s -o %s "STARPU_DATADIR"/starpu/starpu_smpi.xslt %s", asname, template, path);
-		ret = system(cmdline);
-		STARPU_ASSERT_MSG(ret == 0, "running xsltproc to generate SMPI platforms %s from %s failed", template, path);
-		_starpu_frdunlock(in);
-		fclose(in);
-
-		/* And create it */
-		MSG_create_environment(template);
-		unlink(template);
 		hosts = MSG_environment_as_get_hosts(_starpu_simgrid_get_as_by_name(asname));
 	}
 	else

+ 4 - 0
tools/Makefile.am

@@ -245,5 +245,9 @@ clean-local:
 
 endif
 
+if STARPU_SIMGRID
+dist_pkgdata_DATA = starpu_smpi.xslt
+endif
+
 showcheck:
 	-cat $(TEST_LOGS) /dev/null

src/starpu_smpi.xslt → tools/starpu_smpi.xslt


+ 70 - 0
tools/starpu_smpirun.in

@@ -0,0 +1,70 @@
+#!/bin/bash
+
+prefix=@prefix@
+SMPIRUN=@smpirun_path@
+STARPU_DATADIR=@datadir@
+
+MPI_PLATFORM=""
+MPI_HOSTFILE=""
+NP=""
+while true; do
+	case "$1" in
+		"-platform")
+			MPI_PLATFORM=$2
+			if [ ! -r "$MPI_PLATFORM" ]; then
+				echo "$MPI_PLATFORM can't be read"
+				exit 1
+			fi
+			shift 2
+			;;
+		"-hostfile")
+			MPI_HOSTFILE=$2
+			if [ ! -r "$MPI_HOSTFILE" ]; then
+				echo "$MPI_HOSTFILE can't be read"
+				exit 1
+			fi
+			shift 2
+			;;
+		"-np")
+			NP=$2
+			shift 2
+			;;
+		*)
+			break
+			;;
+	esac
+done
+
+if [ -z "$MPI_PLATFORM" ] || [ -z "$MPI_HOSTFILE" ]; then
+	echo "$0 -platform PLATFORM -hostfile HOSTFILE [ -np N ] [ ... ] program [ args ]"
+	exit 2
+fi
+
+PLATFORM=$(mktemp /tmp/StarPU-MPI-platform-XXXXXXXX.xml)
+
+[ -n "$STARPU_PERF_MODEL_DIR" ] || STARPU_PERF_MODEL_DIR=$HOME/.starpu/sampling
+[ -n "$STARPU_HOSTNAME" ] || STARPU_HOSTNAME=$(hostname)
+NODE_PLATFORM=$STARPU_PERF_MODEL_DIR/bus/${STARPU_HOSTNAME}.platform.xml
+
+[ -n "$NP" ] || NP=$(grep -v "^$" $MPI_HOSTFILE | wc -l)
+
+(
+	cat << \EOF
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+<platform version="3">
+<AS id="ASroot" routing="None">
+EOF
+	tail -n +3 $MPI_PLATFORM | grep -v '<platform' | grep -v '</platform'
+	for i in $(seq 0 $((NP - 1))) ; do
+		xsltproc --novalid --stringparam ASname StarPU-MPI$i $STARPU_DATADIR/starpu/starpu_smpi.xslt $NODE_PLATFORM | tail -n +4 | head -n -1
+	done
+	cat << \EOF
+</AS>
+</platform>
+EOF
+) > $PLATFORM
+
+$SMPIRUN -platform $PLATFORM -hostfile $MPI_HOSTFILE "$@" --cfg=smpi/privatize_global_variables:yes
+
+rm -f $TEMP