From: mquinson Date: Thu, 25 Jun 2009 13:31:20 +0000 (+0000) Subject: Compile about every existing SMPI examples (reduce don't compile) X-Git-Tag: SVN~1286 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/025965074dbe4c1b04466cc260260470f28b7472 Compile about every existing SMPI examples (reduce don't compile) git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6354 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/configure.ac b/configure.ac index 0f18311f8c..fda022753c 100644 --- a/configure.ac +++ b/configure.ac @@ -571,6 +571,7 @@ AC_CONFIG_FILES([ examples/gras/pmm/Makefile examples/gras/all2all/Makefile examples/amok/Makefile + examples/smpi/Makefile ]) AC_CONFIG_FILES([ diff --git a/examples/Makefile.am b/examples/Makefile.am index 58314129cf..80245b975e 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -7,6 +7,6 @@ EXTRA_DIST= platforms/prop.xml \ platforms/metaxml.xml platforms/metaxml-random.xml -SUBDIRS= msg gras amok simdag java +SUBDIRS= msg gras amok simdag java smpi include $(top_srcdir)/acmacro/dist-files.mk diff --git a/examples/smpi/Makefile.am b/examples/smpi/Makefile.am new file mode 100644 index 0000000000..45d03f48b2 --- /dev/null +++ b/examples/smpi/Makefile.am @@ -0,0 +1,49 @@ +# Copyright (c) 2004-2007. The SimGrid team. All right reserved. + +# This file is part of the SimGrid project. This is free software: +# You can redistribute and/or modify it under the terms of the +# GNU LGPL (v2.1) licence. + + +#INCLUDES = -I$(top_srcdir)/include +#AM_CFLAGS = -g + +# For each test and/or example: +# - add the binary name into the noinst_PROGRAMS variable +# - add a rule to compile the program, inspired from the existing ones + +noinst_PROGRAMS = bcast bcbench compute compute2 compute3 first second mvmul ring_c split +#reduce Not working yet (FIXME) + +bcast: bcast.c + $(top_builddir)/src/smpi/smpicc $^ -o $@ +bcbench: bcbench.c + $(top_builddir)/src/smpi/smpicc $^ -o $@ +compute: compute.c + $(top_builddir)/src/smpi/smpicc $^ -o $@ +compute2: compute2.c + $(top_builddir)/src/smpi/smpicc $^ -o $@ +compute3: compute3.c + $(top_builddir)/src/smpi/smpicc $^ -o $@ +first: mvmul.c + $(top_builddir)/src/smpi/smpicc $^ -o $@ +second: second.c + $(top_builddir)/src/smpi/smpicc $^ -o $@ +reduce: reduce.c + $(top_builddir)/src/smpi/smpicc $^ -o $@ +ring_c: ring_c.c + $(top_builddir)/src/smpi/smpicc $^ -o $@ +split: split.c + $(top_builddir)/src/smpi/smpicc $^ -o $@ +mvmul: mvmul.c + $(top_builddir)/src/smpi/smpicc $^ -o $@ + +# List the tesh files below +TESTS = + +# No need to change anything after that line +TESTS_ENVIRONMENT = $(top_builddir)/tools/tesh/tesh +EXTRA_DIST = $(TESTS) +CLEANFILES = *~ + +include $(top_srcdir)/acmacro/dist-files.mk diff --git a/examples/smpi/bcast.c b/examples/smpi/bcast.c new file mode 100644 index 0000000000..002061c1e4 --- /dev/null +++ b/examples/smpi/bcast.c @@ -0,0 +1,25 @@ +#include +#include + +#define INIT_VALUE 3 +#define TARGET_VALUE 42 + +int main (int argc, char **argv) { + int size, rank; + int value = INIT_VALUE; + MPI_Init(&argc, &argv); + MPI_Comm_size(MPI_COMM_WORLD, &size); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + if (0 == rank) { + value = TARGET_VALUE; + } + fprintf(stderr,"node %d has value %d before broadcast\n", rank, value); + MPI_Bcast(&value, 1, MPI_INT, 0, MPI_COMM_WORLD); + fprintf(stderr,"node %d has value %d after broadcast\n", rank, value); + if (value != TARGET_VALUE) { + fprintf(stderr,"node %d don't have the target value after broadcast!!\n", rank); + exit(1); + } + MPI_Finalize(); + return 0; +} diff --git a/examples/smpi/bcast.tesh b/examples/smpi/bcast.tesh new file mode 100644 index 0000000000..822b37a2c5 --- /dev/null +++ b/examples/smpi/bcast.tesh @@ -0,0 +1,23 @@ +# use the tested library, not the installed one +! setenv LD_LIBRARY_PATH=../../src/.libs +! setenv cmdline=../../src/smpi/smpirun -quiet -hostfile hostfile -platform ../msg/small_platform.xml + +! output ignore +p Test Broadcast with less processes than hosts +$ ${cmdline} -np 3 ./bcast +> [rank 0] -> Tremblay +> [rank 1] -> Jupiter +> [rank 2] -> Fafard +> node 1 has value 3 before broadcast +> node 0 has value 17 before broadcast +> node 2 has value 3 before broadcast +> node 1 has value 17 after broadcast +> node 0 has value 17 after broadcast +> node 2 has value 17 after broadcast +> [0.000000] [smpi_kernel/INFO] simulation time 0.00343892 + +p Test Broadcast with as much processes than hosts +$ ${cmdline} -np 6 ./bcast + +p Test Broadcast with more processes than hosts +$ ${cmdline} -np 12 ./bcast diff --git a/src/smpi/sample/bcbench.c b/examples/smpi/bcbench.c similarity index 100% rename from src/smpi/sample/bcbench.c rename to examples/smpi/bcbench.c diff --git a/src/smpi/sample/compute.c b/examples/smpi/compute.c similarity index 100% rename from src/smpi/sample/compute.c rename to examples/smpi/compute.c diff --git a/src/smpi/sample/compute2.c b/examples/smpi/compute2.c similarity index 100% rename from src/smpi/sample/compute2.c rename to examples/smpi/compute2.c diff --git a/src/smpi/sample/compute3.c b/examples/smpi/compute3.c similarity index 100% rename from src/smpi/sample/compute3.c rename to examples/smpi/compute3.c diff --git a/src/smpi/sample/first.c b/examples/smpi/first.c similarity index 100% rename from src/smpi/sample/first.c rename to examples/smpi/first.c diff --git a/examples/smpi/hostfile b/examples/smpi/hostfile new file mode 100644 index 0000000000..ee2e2815b7 --- /dev/null +++ b/examples/smpi/hostfile @@ -0,0 +1,6 @@ +Tremblay +Jupiter +Fafard +Ginette +Bourassa + \ No newline at end of file diff --git a/src/smpi/sample/mvmul.c b/examples/smpi/mvmul.c similarity index 100% rename from src/smpi/sample/mvmul.c rename to examples/smpi/mvmul.c diff --git a/src/smpi/sample/reduce.c b/examples/smpi/reduce.c similarity index 100% rename from src/smpi/sample/reduce.c rename to examples/smpi/reduce.c diff --git a/src/smpi/sample/ring_c.c b/examples/smpi/ring_c.c similarity index 100% rename from src/smpi/sample/ring_c.c rename to examples/smpi/ring_c.c diff --git a/src/smpi/sample/second.c b/examples/smpi/second.c similarity index 100% rename from src/smpi/sample/second.c rename to examples/smpi/second.c diff --git a/src/smpi/sample/split.c b/examples/smpi/split.c similarity index 100% rename from src/smpi/sample/split.c rename to examples/smpi/split.c diff --git a/include/smpi/smpi.h b/include/smpi/smpi.h index 67a740ef68..bf11472441 100644 --- a/include/smpi/smpi.h +++ b/include/smpi/smpi.h @@ -72,7 +72,7 @@ SG_BEGIN_DECL() #define MPI_INT (smpi_mpi_global->mpi_int) #define MPI_LAND (smpi_mpi_global->mpi_land) -#define MPI_SUM (smpi_mpi_glboal->mpi_sum) +#define MPI_SUM (smpi_mpi_global->mpi_sum) // MPI macros #define MPI_Init(a, b) SMPI_MPI_Init(a, b) diff --git a/src/Makefile.am b/src/Makefile.am index 3f42ae4c49..5fd51a917f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -82,7 +82,8 @@ EXTRA_DIST= \ include/simix/simix.h include/simix/datatypes.h \ simix/private.h \ \ - smpi/private.h + smpi/private.h \ + smpi/README #LIBRARY_VERSION= 0:0:0 # | | | diff --git a/src/smpi/sample/bcast.c b/src/smpi/sample/bcast.c deleted file mode 100644 index 2d84c1371e..0000000000 --- a/src/smpi/sample/bcast.c +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include - -int main (int argc, char **argv) { - int size, rank; - int value = 3; - MPI_Init(&argc, &argv); - MPI_Comm_size(MPI_COMM_WORLD, &size); - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - if (0 == rank) { - value = 17; - } - printf("node %d has value %d\n", rank, value); - MPI_Bcast(&value, 1, MPI_INT, 0, MPI_COMM_WORLD); - printf("node %d has value %d\n", rank, value); - MPI_Finalize(); - return 0; -} diff --git a/src/smpi/smpi_global.c b/src/smpi/smpi_global.c index fc9d793303..c853ce3dd8 100644 --- a/src/smpi/smpi_global.c +++ b/src/smpi/smpi_global.c @@ -154,7 +154,7 @@ void smpi_global_init() smpi_message_free, smpi_message_reset); smpi_global->process_count = SIMIX_process_count(); - fprintf(stderr,"There is %d processes\n",smpi_global->process_count); + DEBUG1("There is %d processes",smpi_global->process_count); // sender/receiver processes smpi_global->main_processes = xbt_new(smx_process_t, smpi_global->process_count); @@ -311,10 +311,10 @@ int smpi_run_simulation(int *argc, char **argv) xbt_fifo_free(actions_failed); xbt_fifo_free(actions_done); - INFO1("simulation time %g", SIMIX_get_clock()); - smpi_global_destroy(); + INFO1("simulation time %g", SIMIX_get_clock()); + SIMIX_clean(); return 0; diff --git a/src/smpi/smpicc.in b/src/smpi/smpicc.in index 999c1d8ce4..462a5c137a 100755 --- a/src/smpi/smpicc.in +++ b/src/smpi/smpicc.in @@ -25,6 +25,7 @@ function modsource { #include "xbt/asserts.h" #define sleep(x) smpi_sleep(x) #define gettimeofday(x, y) smpi_gettimeofday(x, y) +int smpi_run_simulation(int *argc, char **argv); HEADER # very simplistic transform, will probably want full parser for next version grep -v "mpi.h" < ${SOURCE} | perl -pe 's/main/smpi_simulated_main/;' >> ${TMPSOURCE} @@ -38,8 +39,8 @@ FOOTER fi } -INCLUDEARGS="" -LINKARGS="-L@libdir@ -lsimgrid -lsmpi " +INCLUDEARGS="-I @top_srcdir@/include " +LINKARGS="-L@top_builddir@/src/.libs -L@libdir@ -lsimgrid -lsmpi " CMDLINE="" while [ -n "$1" ]; do @@ -49,7 +50,7 @@ while [ -n "$1" ]; do LINKARGS="" CMDLINE="${CMDLINE} -c " elif [ "${ARG%.c}" != "${ARG}" ]; then - INCLUDEARGS="-I . -I .. -I ../include -I @includedir@ " + INCLUDEARGS="${INCLUDEARGS} -I . -I .. -I ../include -I @includedir@ " SRCFILE="$(realpath ${ARG})" modsource ${SRCFILE} CMDLINE="${CMDLINE} ${TMPDIR}${SRCFILE} " @@ -58,8 +59,8 @@ while [ -n "$1" ]; do fi done -CMDLINE="${CC} ${INCLUDEARGS} ${CMDLINE} ${LINKARGS}" +CMDLINE="${CC} ${INCLUDEARGS} ${CFLAGS} ${CMDLINE} ${LINKARGS}" -#echo "${CMDLINE}" +echo "${CMDLINE}" ${CMDLINE} -rm -rf ${TMPDIR} +echo rm -rf ${TMPDIR} diff --git a/src/smpi/smpirun.in b/src/smpi/smpirun.in index e9660c2300..d51b4d01f3 100755 --- a/src/smpi/smpirun.in +++ b/src/smpi/smpirun.in @@ -49,11 +49,16 @@ while true; do shift 1 ;; + "-quiet") + QUIET="true" + shift 1 + ;; + "-help" | "--help" | "-h") echo "usage:" - echo "$0 [-np ] -platform -hostfile [-map] program [program-options]" + echo "$0 [-quiet] [-np ] -platform -hostfile [-map] program [program-options]" echo "or (deprecated usage):" - echo "$0 [-np ] [-bandwidth ] [-latency ] program [program-options]" + echo "$0 [-quiet] [-np ] [-bandwidth ] [-latency ] program [program-options]" echo exit ;; @@ -160,10 +165,14 @@ cat >> ${APPLICATIONTMP} <