From 1210f6edb4a08e7ad2c4b8fa8aa3a4d74183deb5 Mon Sep 17 00:00:00 2001 From: amad206 Date: Tue, 9 May 2006 15:53:48 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@2198 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- .../gras/alltoall/alltoall.Makefile.local | 90 ++++++++++ .../gras/alltoall/alltoall.Makefile.remote | 29 +++ examples/gras/alltoall/alltoall.c | 167 ++++++++++++++++++ examples/gras/alltoall/alltoall.deploy.sh | 41 +++++ examples/gras/alltoall/small_platform.xml | 90 ++++++++++ examples/gras/alltoall/test_rl | 11 ++ examples/gras/alltoall/test_rl.in | 11 ++ examples/gras/alltoall/test_sg | 9 + examples/gras/alltoall/test_sg.in | 9 + 9 files changed, 457 insertions(+) create mode 100644 examples/gras/alltoall/alltoall.Makefile.local create mode 100644 examples/gras/alltoall/alltoall.Makefile.remote create mode 100644 examples/gras/alltoall/alltoall.c create mode 100644 examples/gras/alltoall/alltoall.deploy.sh create mode 100644 examples/gras/alltoall/small_platform.xml create mode 100755 examples/gras/alltoall/test_rl create mode 100755 examples/gras/alltoall/test_rl.in create mode 100755 examples/gras/alltoall/test_sg create mode 100755 examples/gras/alltoall/test_sg.in diff --git a/examples/gras/alltoall/alltoall.Makefile.local b/examples/gras/alltoall/alltoall.Makefile.local new file mode 100644 index 0000000000..04cbaff94f --- /dev/null +++ b/examples/gras/alltoall/alltoall.Makefile.local @@ -0,0 +1,90 @@ +############ PROJECT COMPILING AND ARCHIVING ######### +PROJECT_NAME=alltoall +DISTDIR=gras-$(PROJECT_NAME) + +GRAS_ROOT?= $(shell echo "\"<<<< GRAS_ROOT undefined !!! >>>>\"") +CFLAGS = -O3 -w -g +INCLUDES = -I$(GRAS_ROOT)/include +LIBS_SIM = -lm -L$(GRAS_ROOT)/lib/ -lsimgrid +LIBS_RL = -lm -L$(GRAS_ROOT)/lib/ -lgras +LIBS = + +C_FILES = _alltoall_simulator.c _alltoall_node.c alltoall.c +OBJ_FILES = +BIN_FILES = alltoall_simulator alltoall_node + +all: $(BIN_FILES) + +alltoall_simulator: _alltoall_simulator.o alltoall.o + $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) $^ $(LIBS_SIM) $(LIBS) $(LDADD) -o $@ +alltoall_node : _alltoall_node.o alltoall.o + $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) $^ $(LIBS_RL) $(LIBS) $(LDADD) -o $@ + +%: %.o + $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) $^ $(LIBS) $(LDADD) -o $@ + +%.o: %.c + $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) -c -o $@ $< + +DIST_FILES= $(C_FILES) alltoall.Makefile.local alltoall.Makefile.remote +distdir: $(DIST_FILES) + rm -rf $(DISTDIR) + mkdir -p $(DISTDIR) + cp $^ $(DISTDIR) + +dist: clean distdir + tar c $(DISTDIR) | gzip -c > $(DISTDIR).tar.gz + +clean: + rm -f $(BIN_FILES) $(OBJ_FILES) *~ alltoall.o _alltoall_simulator.o _alltoall_node.o + rm -rf $(DISTDIR) + +.SUFFIXES: +.PHONY : clean + +############ REMOTE COMPILING ######### +MACHINES ?= Bourassa Fafard Ginette Jupiter Tremblay +INSTALL_PATH ?='$$HOME/tmp/src' ### Has to be an absolute path !!! +GRAS_ROOT ?='$(INSTALL_PATH)' ### Has to be an absolute path !!! +SRCDIR ?= ./ +SIMGRID_URL ?=http://gcl.ucsd.edu/simgrid/dl/ +SIMGRID_VERSION ?=2.92 +GRAS_PROJECT ?= alltoall +GRAS_PROJECT_URL ?= http://www-id.imag.fr/Laboratoire/Membres/Legrand_Arnaud/gras_test/ + +remote: + @echo;echo "----[ Compile the package on remote hosts ]----" + @test -e $(SRCDIR)/buildlogs/ || mkdir -p $(SRCDIR)/buildlogs/ + for site in $(MACHINES) ; do \ + machine=`echo $$site |sed 's/^\([^%]*\)%.*$$/\1/'`;\ + machine2=`echo $$site |sed 's/^\([^%]*\)%\(.*\)$$/\2/'`;\ + cmd_mkdir="\"sh -c 'env INSTALL_PATH=$(INSTALL_PATH) GRAS_ROOT=$(GRAS_ROOT) \ + SIMGRID_URL=$(SIMGRID_URL) SIMGRID_VERSION=$(SIMGRID_VERSION) GRAS_PROJECT=$(GRAS_PROJECT) \ + GRAS_PROJECT_URL=$(GRAS_PROJECT_URL) mkdir -p $(INSTALL_PATH) 2>&1'\"";\ + cmd_make="\"sh -c 'env INSTALL_PATH=$(INSTALL_PATH) GRAS_ROOT=$(GRAS_ROOT) \ + SIMGRID_URL=$(SIMGRID_URL) SIMGRID_VERSION=$(SIMGRID_VERSION) GRAS_PROJECT=$(GRAS_PROJECT) \ + GRAS_PROJECT_URL=$(GRAS_PROJECT_URL) make -C $(INSTALL_PATH) -f alltoall.Makefile.remote $(ACTION) 2>&1'\"";\ + if echo $$site | grep '%' >/dev/null ; then \ + echo "----[ Compile on $$machine2 (behind $$machine) ]----";\ + else \ + machine=$$site;\ + echo "----[ Compile on $$machine ]----";\ + fi;\ + if echo $$site | grep '%' >/dev/null ; then \ + if ssh $$machine "ssh -A $$machine2 $$cmd_mkdir" 2>&1 > $(SRCDIR)/buildlogs/$$site.log;\ + then true; else failed=1;echo "Failed (check $(SRCDIR)/buildlogs/$$site.log)"; fi;\ + else \ + if ssh $$machine "eval $$cmd_mkdir" 2>&1 > $(SRCDIR)/buildlogs/$$site.log ;\ + then true; else failed=1;echo "Failed (check $(SRCDIR)/buildlogs/$$site.log)"; fi; \ + fi;\ + echo "-- Copy the data over"; \ + scp alltoall.Makefile.remote $$site:$(INSTALL_PATH) ;\ + echo "-- Compiling... (the output gets into $(SRCDIR)/buildlogs/$$site.log)"; \ + if echo $$site | grep '%' >/dev/null ; then \ + if ssh $$machine "ssh -A $$machine2 $$cmd_make" 2>&1 >> $(SRCDIR)/buildlogs/$$site.log;\ + then echo "Sucessful"; else failed=1;echo "Failed (check $(SRCDIR)/buildlogs/$$site.log)"; fi;echo; \ + else \ + if ssh $$machine "eval $$cmd_make" 2>&1 >> $(SRCDIR)/buildlogs/$$site.log ;\ + then echo "Sucessful"; else failed=1;echo "Failed (check $(SRCDIR)/buildlogs/$$site.log)"; fi;echo; \ + fi;\ + done; diff --git a/examples/gras/alltoall/alltoall.Makefile.remote b/examples/gras/alltoall/alltoall.Makefile.remote new file mode 100644 index 0000000000..2a27356357 --- /dev/null +++ b/examples/gras/alltoall/alltoall.Makefile.remote @@ -0,0 +1,29 @@ +INSTALL_PATH ?= $(shell pwd) + +compile-simgrid: + cd $$GRAS_ROOT ; \ + retrieved=`LANG=C;wget -N $(SIMGRID_URL)/simgrid-$(SIMGRID_VERSION).tar.gz 2>&1 | grep newer | sed 's/.*no newer.*/yes/'`; \ + echo $$retrieved; \ + if test "x$$retrieved" = x; then \ + tar zxf simgrid-$(SIMGRID_VERSION).tar.gz ; \ + cd simgrid-$(SIMGRID_VERSION)/; \ + ./configure --prefix=$$GRAS_ROOT ; \ + make all install ;\ + fi + +compile-gras: compile-simgrid + not_retrieved=`LANG=C;wget -N $(GRAS_PROJECT_URL)/gras-$(GRAS_PROJECT).tar.gz 2>&1 | grep newer | sed 's/.*no newer.*/yes/'`; \ + echo $$not_retrieved; \ + if test "x$$not_retrieved" != xyes; then \ + tar zxf gras-$(GRAS_PROJECT).tar.gz ; \ + make -C gras-$(GRAS_PROJECT)/ -f $(GRAS_PROJECT).Makefile.local all ; \ + fi + +clean-simgrid: + rm -rf simgrid-$(SIMGRID_VERSION)* +clean-gras clean-gras-$(GRAS_PROJECT): + rm -rf gras-$(GRAS_PROJECT)* +clean: clean-simgrid clean-gras-$(GRAS_PROJECT) + +.PHONY: clean clean-simgrid clean-gras clean-gras-$(GRAS_PROJECT) \ + compile-simgrid compile-gras diff --git a/examples/gras/alltoall/alltoall.c b/examples/gras/alltoall/alltoall.c new file mode 100644 index 0000000000..dd5862b46a --- /dev/null +++ b/examples/gras/alltoall/alltoall.c @@ -0,0 +1,167 @@ +/* $Id$ */ + +/* ALLTOALL - alltoall of GRAS features */ + +/* Copyright (c) 2006 Ahmed Harbaoui. 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" +#include "xbt/ex.h" + +XBT_LOG_NEW_DEFAULT_CATEGORY(alltoall,"Messages specific to this example"); + +/* register data which may be sent (common to client and server) */ +static void register_messages(void) { + gras_msgtype_declare("data", gras_datadesc_by_name("int")); +} + +/* Function prototypes */ +int node (int argc,char *argv[]); + + +/* ********************************************************************** + * node code + * **********************************************************************/ + +/* Global private data */ +typedef struct { + gras_socket_t sock; + int done; +} node_data_t; + +static void free_host(void *d){ + xbt_host_t h=*(xbt_host_t*)d; + free(h->name); + free(h); +} + +static void kill_buddy(char *name,int port){ + gras_socket_t sock=gras_socket_client(name,port); + gras_msg_send(sock,gras_msgtype_by_name("kill"),NULL); + gras_socket_close(sock); +} + +static void kill_buddy_dynar(void *b) { + xbt_host_t buddy=*(xbt_host_t*)b; + kill_buddy(buddy->name,buddy->port); +} + +static int node_cb_data_handler(gras_msg_cb_ctx_t ctx, + void *payload_data) { + + /* Get the payload into the msg variable */ + int data=*(int*)payload_data; + + gras_socket_t expeditor = gras_msg_cb_ctx_from(ctx); + + /* Retrieve the server's state (globals) */ + + node_data_t *globals=(node_data_t*)gras_userdata_get(); + globals->done = 0; + + /* Log which client connected */ + INFO3(">>>>>>>> Got Data(%d) from %s:%d <<<<<<<<", + data, + gras_socket_peer_name(expeditor), gras_socket_peer_port(expeditor)); + + /* Set the done boolean to true (and make sure the server stops after receiving it). */ + globals->done = 1; + + /* Make sure we don't leak sockets */ + //gras_socket_close(expeditor); + + /* Tell GRAS that we consummed this message */ + return 1; +} /* end_of_server_cb_ping_handler */ + +int node (int argc,char *argv[]) { + + xbt_ex_t e; + + int port,nb_hosts,data, + i,done; + + xbt_host_t h1; + + gras_socket_t peer; /* socket to node */ + + node_data_t *globals; + + /* xbt_dynar for hosts */ + xbt_dynar_t hosts = xbt_dynar_new(sizeof(xbt_host_t),&free_host); + + /* Init the GRAS infrastructure and declare my globals */ + gras_init(&argc,argv); + + globals=gras_userdata_new(node_data_t *); + + /* Get the port I should listen on from the command line, if specified */ + if (argc > 2) { + port=atoi(argv[1]); + } + + /* Get the node location from argc/argv */ + for (i=2; iname=strdup(argv[i]); + host->port=atoi(argv[1]); + INFO2("New node : %s:%d",host->name,host->port); + xbt_dynar_push(hosts,&host); + } + nb_hosts = xbt_dynar_length(hosts); + + INFO1("Launch current node (port=%d)", port); + + /* Create my master socket */ + globals->sock = gras_socket_server(port); + + /* Register the known messages */ + register_messages(); + register_messages(); + + /* 3. Wait for others nodesthe startup */ + gras_os_sleep(1); + + + /* Register my callback */ + gras_cb_register(gras_msgtype_by_name("data"),&node_cb_data_handler); + + INFO1(">>>>>>>> Listening on port %d <<<<<<<<", gras_socket_my_port(globals->sock)); + globals->done=0; + + data =1000; + xbt_dynar_foreach(hosts,i,h1) { + peer = gras_socket_client(h1->name,h1->port); + done=0; + while (!done){ + TRY { + gras_msg_handle(0); + }CATCH(e){ + if (e.category != timeout_error) + RETHROW; + xbt_ex_free(e); + done = 1; + } + } + + gras_msg_send(peer,gras_msgtype_by_name("data"),&data); + INFO3(">>>>>>>> Send Data (%d) from %s to %s <<<<<<<<", + data,argv[0],h1->name); + } + + if (!globals->done) + WARN0("An error occured, the done was not set by the callback"); + + /* Free the allocated resources, and shut GRAS down */ + gras_socket_close(globals->sock); + free(globals); + gras_exit(); + + //xbt_dynar_map(hosts,kill_buddy_dynar); + //xbt_dynar_free(&hosts); + + INFO0("Done."); + return 0; +} /* end_of_node */ \ No newline at end of file diff --git a/examples/gras/alltoall/alltoall.deploy.sh b/examples/gras/alltoall/alltoall.deploy.sh new file mode 100644 index 0000000000..9ff16097c9 --- /dev/null +++ b/examples/gras/alltoall/alltoall.deploy.sh @@ -0,0 +1,41 @@ +#!/bin/sh +############ DEPLOYMENT FILE ######### +if test "${MACHINES+set}" != set; then + export MACHINES='Bourassa Fafard Ginette Jupiter Tremblay '; +fi +if test "${INSTALL_PATH+set}" != set; then + export INSTALL_PATH='`echo $HOME`/tmp/src' +fi +if test "${GRAS_ROOT+set}" != set; then + export GRAS_ROOT='`echo $INSTALL_PATH`' +fi +if test "${SRCDIR+set}" != set; then + export SRCDIR=./ +fi +if test "${SIMGRID_URL+set}" != set; then + export SIMGRID_URL=http://gcl.ucsd.edu/simgrid/dl/ +fi +if test "${SIMGRID_VERSION+set}" != set; then + export SIMGRID_VERSION=2.91 +fi +if test "${GRAS_PROJECT+set}" != set; then + export GRAS_PROJECT=alltoall +fi +if test "${GRAS_PROJECT_URL+set}" != set; then + export GRAS_PROJECT_URL=http://www-id.imag.fr/Laboratoire/Membres/Legrand_Arnaud/gras_test/ +fi + +test -e runlogs/ || mkdir -p runlogs/ +cmd_prolog="env INSTALL_PATH=$INSTALL_PATH GRAS_ROOT=$GRAS_ROOT \ + SIMGRID_URL=$SIMGRID_URL SIMGRID_VERSION=$SIMGRID_VERSION GRAS_PROJECT=$GRAS_PROJECT \ + GRAS_PROJECT_URL=$GRAS_PROJECT_URL LD_LIBRARY_PATH=$GRAS_ROOT/lib/ sh -c "; +cmd="\$INSTALL_PATH/gras-alltoall/alltoall_node 4000 Jupiter Fafard Ginette Bourassa "; +ssh Tremblay "$cmd_prolog 'export LD_LIBRARY_PATH=\$INSTALL_PATH/lib:\$LD_LIBRARY_PATH; echo \"$cmd\" ; $cmd 2>&1'" > runlogs/Tremblay_0.log & +cmd="\$INSTALL_PATH/gras-alltoall/alltoall_node 4000 Tremblay Fafard Ginette Bourassa "; +ssh Jupiter "$cmd_prolog 'export LD_LIBRARY_PATH=\$INSTALL_PATH/lib:\$LD_LIBRARY_PATH; echo \"$cmd\" ; $cmd 2>&1'" > runlogs/Jupiter_1.log & +cmd="\$INSTALL_PATH/gras-alltoall/alltoall_node 4000 Tremblay Jupiter Ginette Bourassa "; +ssh Fafard "$cmd_prolog 'export LD_LIBRARY_PATH=\$INSTALL_PATH/lib:\$LD_LIBRARY_PATH; echo \"$cmd\" ; $cmd 2>&1'" > runlogs/Fafard_2.log & +cmd="\$INSTALL_PATH/gras-alltoall/alltoall_node 4000 Tremblay Jupiter Fafard Bourassa "; +ssh Ginette "$cmd_prolog 'export LD_LIBRARY_PATH=\$INSTALL_PATH/lib:\$LD_LIBRARY_PATH; echo \"$cmd\" ; $cmd 2>&1'" > runlogs/Ginette_3.log & +cmd="\$INSTALL_PATH/gras-alltoall/alltoall_node 4000 Tremblay Jupiter Fafard Ginette "; +ssh Bourassa "$cmd_prolog 'export LD_LIBRARY_PATH=\$INSTALL_PATH/lib:\$LD_LIBRARY_PATH; echo \"$cmd\" ; $cmd 2>&1'" > runlogs/Bourassa_4.log & diff --git a/examples/gras/alltoall/small_platform.xml b/examples/gras/alltoall/small_platform.xml new file mode 100644 index 0000000000..9779e70d27 --- /dev/null +++ b/examples/gras/alltoall/small_platform.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/gras/alltoall/test_rl b/examples/gras/alltoall/test_rl new file mode 100755 index 0000000000..f1eea58dcc --- /dev/null +++ b/examples/gras/alltoall/test_rl @@ -0,0 +1,11 @@ +#! /bin/sh -e +if [ x = x ] ; then +# exenv="libtool --mode=execute valgrind --show-reachable=yes --run-libc-freeres=no " + exenv=$SG_TEST_EXENV +else + exenv=wine +fi + +$exenv ./ping_server 4002 $@ & +sleep 1 +$exenv ./ping_client 127.0.0.1 4002 $@ diff --git a/examples/gras/alltoall/test_rl.in b/examples/gras/alltoall/test_rl.in new file mode 100755 index 0000000000..3e325f5062 --- /dev/null +++ b/examples/gras/alltoall/test_rl.in @@ -0,0 +1,11 @@ +#! @BASH@ -e +if [ x@EXEEXT@ = x ] ; then +# exenv="libtool --mode=execute valgrind --show-reachable=yes --run-libc-freeres=no " + exenv=$SG_TEST_EXENV +else + exenv=wine +fi + +$exenv ./ping_server@EXEEXT@ 4002 $@ & +sleep 1 +$exenv ./ping_client@EXEEXT@ 127.0.0.1 4002 $@ diff --git a/examples/gras/alltoall/test_sg b/examples/gras/alltoall/test_sg new file mode 100755 index 0000000000..dc4d857502 --- /dev/null +++ b/examples/gras/alltoall/test_sg @@ -0,0 +1,9 @@ +#! /bin/sh +if [ x = x ] ; then + exenv=$SG_TEST_EXENV +else + exenv=wine +fi + +exec $exenv ./alltoall_simulator ./small_platform.xml ./alltoall_deployment.xml $@ + diff --git a/examples/gras/alltoall/test_sg.in b/examples/gras/alltoall/test_sg.in new file mode 100755 index 0000000000..0a9ca61828 --- /dev/null +++ b/examples/gras/alltoall/test_sg.in @@ -0,0 +1,9 @@ +#! @BASH@ +if [ x@EXEEXT@ = x ] ; then + exenv=$SG_TEST_EXENV +else + exenv=wine +fi + +exec $exenv ./alltoall_simulator@EXEEXT@ @top_srcdir@/examples/msg/small_platform.xml @srcdir@/alltoall_deployment.xml $@ + -- 2.20.1