Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Compile about every existing SMPI examples (reduce don't compile)
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 25 Jun 2009 13:31:20 +0000 (13:31 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 25 Jun 2009 13:31:20 +0000 (13:31 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6354 48e7efb5-ca39-0410-a469-dd3cf9ba447f

22 files changed:
configure.ac
examples/Makefile.am
examples/smpi/Makefile.am [new file with mode: 0644]
examples/smpi/bcast.c [new file with mode: 0644]
examples/smpi/bcast.tesh [new file with mode: 0644]
examples/smpi/bcbench.c [moved from src/smpi/sample/bcbench.c with 100% similarity]
examples/smpi/compute.c [moved from src/smpi/sample/compute.c with 100% similarity]
examples/smpi/compute2.c [moved from src/smpi/sample/compute2.c with 100% similarity]
examples/smpi/compute3.c [moved from src/smpi/sample/compute3.c with 100% similarity]
examples/smpi/first.c [moved from src/smpi/sample/first.c with 100% similarity]
examples/smpi/hostfile [new file with mode: 0644]
examples/smpi/mvmul.c [moved from src/smpi/sample/mvmul.c with 100% similarity]
examples/smpi/reduce.c [moved from src/smpi/sample/reduce.c with 100% similarity]
examples/smpi/ring_c.c [moved from src/smpi/sample/ring_c.c with 100% similarity]
examples/smpi/second.c [moved from src/smpi/sample/second.c with 100% similarity]
examples/smpi/split.c [moved from src/smpi/sample/split.c with 100% similarity]
include/smpi/smpi.h
src/Makefile.am
src/smpi/sample/bcast.c [deleted file]
src/smpi/smpi_global.c
src/smpi/smpicc.in
src/smpi/smpirun.in

index 0f18311..fda0227 100644 (file)
@@ -571,6 +571,7 @@ AC_CONFIG_FILES([
       examples/gras/pmm/Makefile
       examples/gras/all2all/Makefile
     examples/amok/Makefile       
+    examples/smpi/Makefile       
 ])
 
 AC_CONFIG_FILES([
index 5831412..80245b9 100644 (file)
@@ -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 (file)
index 0000000..45d03f4
--- /dev/null
@@ -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 (file)
index 0000000..002061c
--- /dev/null
@@ -0,0 +1,25 @@
+#include <stdio.h>
+#include <mpi.h>
+
+#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 (file)
index 0000000..822b37a
--- /dev/null
@@ -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/examples/smpi/hostfile b/examples/smpi/hostfile
new file mode 100644 (file)
index 0000000..ee2e281
--- /dev/null
@@ -0,0 +1,6 @@
+Tremblay
+Jupiter
+Fafard
+Ginette
+Bourassa
+         
\ No newline at end of file
index 67a740e..bf11472 100644 (file)
@@ -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)
index 3f42ae4..5fd51a9 100644 (file)
@@ -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 (file)
index 2d84c13..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <stdio.h>
-#include <mpi.h>
-
-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;
-}
index fc9d793..c853ce3 100644 (file)
@@ -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;
index 999c1d8..462a5c1 100755 (executable)
@@ -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}
index e9660c2..d51b4d0 100755 (executable)
@@ -49,11 +49,16 @@ while true; do
       shift 1
    ;;
 
+   "-quiet")
+       QUIET="true"
+      shift 1
+   ;;
+
    "-help" | "--help" | "-h") 
       echo "usage:"
-      echo "$0 [-np <numprocs>] -platform <xmldesc> -hostfile <hostfile> [-map] program [program-options]"
+      echo "$0 [-quiet] [-np <numprocs>] -platform <xmldesc> -hostfile <hostfile> [-map] program [program-options]"
       echo "or (deprecated usage):"
-      echo "$0 [-np <numprocs>] [-bandwidth <bytes/sec>] [-latency <secs>] program [program-options]"
+      echo "$0 [-quiet] [-np <numprocs>] [-bandwidth <bytes/sec>] [-latency <secs>] program [program-options]"
       echo
       exit
    ;;
@@ -160,10 +165,14 @@ cat >> ${APPLICATIONTMP} <<APPLICATIONFOOT
 APPLICATIONFOOT
 ##-------------------------------- end DEFAULT APPLICATION --------------------------------------
 
-echo ${EXEC} ${PLATFORMTMP} ${APPLICATIONTMP}
+if [ -z "${QUIET}" ] ; then
+  echo ${EXEC} ${PLATFORMTMP} ${APPLICATIONTMP}
+fi
 ${EXEC} ${PLATFORMTMP} ${APPLICATIONTMP}
 
-echo "[$0] cleaning up temp files"
+if [ -z "${QUIET}" ] ; then
+  echo "[$0] cleaning up temp files"
+fi
 if [ -z "${PLATFORM}" ]; then
        rm ${PLATFORMTMP} 
 fi