From ef99a405745deb2eaaa8fd1539fa6377495f9217 Mon Sep 17 00:00:00 2001 From: alegrand Date: Wed, 16 Feb 2005 22:58:31 +0000 Subject: [PATCH] Adding everything needed to develop GRAS benchmarking macros. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@1030 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- examples/gras/Makefile.am | 2 +- examples/gras/chrono/Makefile.am | 24 ++++++++++++ examples/gras/chrono/chrono.c | 45 ++++++++++++++++++++++ examples/gras/chrono/chrono_deployment.xml | 5 +++ examples/gras/chrono/test_rl.in | 10 +++++ examples/gras/chrono/test_sg.in | 5 +++ include/Makefile.am | 2 +- include/gras.h | 1 + include/gras/chrono.h | 37 ++++++++++++++++++ include/xbt/dict.h | 2 +- src/Makefile.am | 1 + src/gras/chrono.c | 18 +++++++++ 12 files changed, 149 insertions(+), 3 deletions(-) create mode 100644 examples/gras/chrono/Makefile.am create mode 100644 examples/gras/chrono/chrono.c create mode 100644 examples/gras/chrono/chrono_deployment.xml create mode 100755 examples/gras/chrono/test_rl.in create mode 100755 examples/gras/chrono/test_sg.in create mode 100644 include/gras/chrono.h create mode 100644 src/gras/chrono.c diff --git a/examples/gras/Makefile.am b/examples/gras/Makefile.am index 57347f7ea0..1d5ab97cb7 100644 --- a/examples/gras/Makefile.am +++ b/examples/gras/Makefile.am @@ -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 index 0000000000..973e7efb6f --- /dev/null +++ b/examples/gras/chrono/Makefile.am @@ -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 index 0000000000..c0c888834e --- /dev/null +++ b/examples/gras/chrono/chrono.c @@ -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 + + + + diff --git a/examples/gras/chrono/test_rl.in b/examples/gras/chrono/test_rl.in new file mode 100755 index 0000000000..8a364767a7 --- /dev/null +++ b/examples/gras/chrono/test_rl.in @@ -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 index 0000000000..110ab6d524 --- /dev/null +++ b/examples/gras/chrono/test_sg.in @@ -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 diff --git a/include/Makefile.am b/include/Makefile.am index 4cc2eb29c8..ae6403b8e4 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -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 diff --git a/include/gras.h b/include/gras.h index 90ae48fd5c..fb905970ba 100644 --- a/include/gras.h +++ b/include/gras.h @@ -16,6 +16,7 @@ #include #include #include +#include #include #include diff --git a/include/gras/chrono.h b/include/gras/chrono.h new file mode 100644 index 0000000000..9571e0c6cb --- /dev/null +++ b/include/gras/chrono.h @@ -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 */ diff --git a/include/xbt/dict.h b/include/xbt/dict.h index e9fdb4cc8f..bb45bef50d 100644 --- a/include/xbt/dict.h +++ b/include/xbt/dict.h @@ -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 diff --git a/src/Makefile.am b/src/Makefile.am index f5f0223594..57df049f87 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 index 0000000000..8a07a71827 --- /dev/null +++ b/src/gras/chrono.c @@ -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) +{ +} -- 2.20.1