Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Adding everything needed to develop GRAS benchmarking macros.
authoralegrand <alegrand@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 16 Feb 2005 22:58:31 +0000 (22:58 +0000)
committeralegrand <alegrand@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 16 Feb 2005 22:58:31 +0000 (22:58 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@1030 48e7efb5-ca39-0410-a469-dd3cf9ba447f

12 files changed:
examples/gras/Makefile.am
examples/gras/chrono/Makefile.am [new file with mode: 0644]
examples/gras/chrono/chrono.c [new file with mode: 0644]
examples/gras/chrono/chrono_deployment.xml [new file with mode: 0644]
examples/gras/chrono/test_rl.in [new file with mode: 0755]
examples/gras/chrono/test_sg.in [new file with mode: 0755]
include/Makefile.am
include/gras.h
include/gras/chrono.h [new file with mode: 0644]
include/xbt/dict.h
src/Makefile.am
src/gras/chrono.c [new file with mode: 0644]

index 57347f7..1d5ab97 100644 (file)
@@ -1 +1 @@
-SUBDIRS= ping timer # bandwidth alnem saturate
+SUBDIRS= ping timer chrono # bandwidth alnem saturate
diff --git a/examples/gras/chrono/Makefile.am b/examples/gras/chrono/Makefile.am
new file mode 100644 (file)
index 0000000..973e7ef
--- /dev/null
@@ -0,0 +1,24 @@
+INCLUDES= -I$(top_srcdir)/include
+AM_CFLAGS=-g
+#TESTS= test_rl test_sg
+EXTRA_DIST=chrono_deployment.xml
+
+# AUTOMAKE variable definition
+noinst_PROGRAMS=chrono_simulator chrono_multiplier
+
+chrono_simulator_SOURCES=      _chrono_simulator.c chrono.c
+chrono_simulator_LDADD=        $(top_builddir)/src/libsimgrid.la
+
+chrono_multiplier_SOURCES=     _chrono_multiplier.c chrono.c
+chrono_multiplier_LDADD=       $(top_builddir)/src/libgras.la
+
+
+# cleanup temps
+CLEANFILES= _chrono_simulator.c _chrono_multiplier.c
+
+# generate temps
+
+# A rule to generate the source file each time the deployment file changes
+_chrono_multiplier.c _chrono_simulator.c: chrono_deployment.xml $(top_srcdir)/tools/gras/gras_stub_generator
+       $(top_srcdir)/tools/gras/gras_stub_generator chrono chrono_deployment.xml >/dev/null
+
diff --git a/examples/gras/chrono/chrono.c b/examples/gras/chrono/chrono.c
new file mode 100644 (file)
index 0000000..c0c8888
--- /dev/null
@@ -0,0 +1,45 @@
+/* $Id$ */
+
+/* chrono - demo of GRAS benchmarking features                              */
+
+/* Copyright (c) 2005 Martin Quinson, Arnaud Legrand. All rights reserved.  */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include "gras.h"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(Chrono,"Messages specific to this example");
+
+
+/* Function prototypes */
+int multiplier (int argc,char *argv[]);
+
+int multiplier (int argc,char *argv[])
+{
+  int i,j,k;
+  double *A,*B,*C;
+  int n = 500;
+  gras_init(&argc, argv, NULL);
+  
+  A = malloc(n*n*sizeof(double));
+  B = malloc(n*n*sizeof(double));
+  C = malloc(n*n*sizeof(double));
+
+  INFO1("Before computation : %lg", gras_os_time());
+  for(i=0; i<n; i++)
+    for(j=0; j<n; j++) {
+      A[i*n+j]=2/n;
+      B[i*n+j]=1/n;
+      C[i*n+j]=0.0;
+    }
+
+  for(i=0; i<n; i++)
+    for(j=0; j<n; j++)
+      for(k=0; k<n; k++)       
+       C[i*n+j] += A[i*n+k]*B[k*n+j];
+
+  INFO1("After computation : %lg", gras_os_time());
+
+  return 0;
+}
diff --git a/examples/gras/chrono/chrono_deployment.xml b/examples/gras/chrono/chrono_deployment.xml
new file mode 100644 (file)
index 0000000..94adb0f
--- /dev/null
@@ -0,0 +1,5 @@
+<?xml version='1.0'?>
+<!DOCTYPE platform_description SYSTEM "surfxml.dtd">
+<platform_description>
+  <process host="Tremblay" function="multiplier"/>
+</platform_description>
diff --git a/examples/gras/chrono/test_rl.in b/examples/gras/chrono/test_rl.in
new file mode 100755 (executable)
index 0000000..8a36476
--- /dev/null
@@ -0,0 +1,10 @@
+#! @BASH@ -e
+if [ x@EXEEXT@ = x ] ; then 
+  wine=
+else
+  wine=wine
+fi
+    
+$wine ./chrono_server@EXEEXT@ $@ &
+sleep 1
+$wine ./chrono_client@EXEEXT@ $@
diff --git a/examples/gras/chrono/test_sg.in b/examples/gras/chrono/test_sg.in
new file mode 100755 (executable)
index 0000000..110ab6d
--- /dev/null
@@ -0,0 +1,5 @@
+#! @BASH@
+if test -x ./chrono_simulator ; then
+  exec ./chrono_simulator @top_srcdir@/examples/msg/small_platform.xml @srcdir@/chrono_deployment.xml
+fi
+exit 77
index 4cc2eb2..ae6403b 100644 (file)
@@ -17,7 +17,7 @@ nobase_include_HEADERS = \
        gras/datadesc.h gras/transport.h \
        gras/virtu.h gras/cond.h gras/process.h \
        \
-       gras/messages.h gras/timer.h\
+       gras/messages.h gras/timer.h gras/chrono.h\
        \
        amok/base.h \
        amok/bandwidth.h
index 90ae48f..fb90597 100644 (file)
@@ -16,6 +16,7 @@
 #include <gras/process.h>
 #include <gras/virtu.h>
 #include <gras/cond.h>
+#include <gras/chrono.h>
 
 #include <gras/transport.h>
 #include <gras/datadesc.h>
diff --git a/include/gras/chrono.h b/include/gras/chrono.h
new file mode 100644 (file)
index 0000000..9571e0c
--- /dev/null
@@ -0,0 +1,37 @@
+/*     $Id$     */
+
+/* chrono.h - timer macros for GRAS                                         */
+
+/* Copyright (c) 2005 Martin Quinson, Arnaud Legrand. All rights reserved.  */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+
+#ifndef GRAS_CHRONO_H
+#define GRAS_CHRONO_H
+
+#include "xbt/misc.h"
+
+BEGIN_DECL()
+
+void gras_bench_always_begin(const char *location);
+void gras_bench_always_end(void);
+
+/** \brief Start benchmark this part of the code
+    \hideinitializer */
+#define GRAS_BENCH_ALWAYS_BEGIN gras_bench_always_begin(__FILE__ __LINE__ __FUNCTION__)
+/** \brief Stop benchmark this part of the code
+    \hideinitializer */
+#define GRAS_BENCH_ALWAYS_END gras_bench_always_end()
+
+/** \brief Start benchmark this part of the code if it has never been benchmarked before
+    \hideinitializer */
+#define GRAS_BENCH_ONCE_BEGIN
+/** \brief Stop benchmarking this part of the code
+    \hideinitializer */
+#define GRAS_BENCH_ONCE_END
+
+END_DECL()
+
+#endif /* GRAS_CHRONO_H */
index e9fdb4c..bb45bef 100644 (file)
@@ -29,7 +29,7 @@ BEGIN_DECL()
  char buff[512];
 
  sprintf(buff,"some very precious data");
- xbt_dict_set(mydict,"my data", strdump(buff), free); 
+ xbt_dict_set(mydict,"my data", strdup(buff), free); 
 
  sprintf(buff,"another good stuff");
  xbt_dict_set(mydict,"my data", strdup(buff), free); // previous data gets erased (and freed) by second add \endverbatim
index f5f0223..57df049 100644 (file)
@@ -122,6 +122,7 @@ COMMON_SRC=\
   msg/global.c msg/environment.c msg/deployment.c  \
   \
   gras/gras.c \
+  gras/chrono.c \
   \
   gras/Transport/transport.c          gras/Transport/transport_private.h   gras/Transport/transport_plugin_buf.c  \
   \
diff --git a/src/gras/chrono.c b/src/gras/chrono.c
new file mode 100644 (file)
index 0000000..8a07a71
--- /dev/null
@@ -0,0 +1,18 @@
+/*     $Id$     */
+
+/* chrono.c - code benchmarking for emulation                               */
+
+/* Copyright (c) 2005 Martin Quinson, Arnaud Legrand. All rights reserved.  */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include "gras/chrono.h"
+
+void gras_bench_always_begin(const char *location)
+{
+}
+
+void gras_bench_always_end(void)
+{
+}