From: suter Date: Thu, 29 Oct 2009 20:59:50 +0000 (+0000) Subject: add a flat broadcast action X-Git-Tag: SVN~894 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/d69523bb9a7c8d5381d44e94f559337bc9745009?ds=sidebyside add a flat broadcast action requires a comm_size action to set the size of the MPI_COMM_WORLD communicator update the actions_with_isend.txt to include the Isend action git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6823 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/examples/msg/actions/actions.c b/examples/msg/actions/actions.c index 205aa75e43..e57369aaed 100644 --- a/examples/msg/actions/actions.c +++ b/examples/msg/actions/actions.c @@ -13,7 +13,11 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); +int communicator_size=0; +typedef struct coll_ctr_t{ + int bcast_counter; +} *coll_ctr; /* Helper function */ static double parse_double(const char *string) { @@ -45,8 +49,8 @@ static int spawned_send(int argc, char *argv[]) char *name = xbt_str_join(action, " "); char *to = xbt_dynar_get_as(action, 2, char *); char *size = xbt_dynar_get_as(action, 3, char *); - - INFO1("Sending on %s", name); + INFO3("name is %s, to is %s, sizeis %s", name, to, size); + INFO1("Sending on %s\n", name); MSG_task_send(MSG_task_create(name, 0, parse_double(size), NULL), to); INFO1("Sent %s", name); free(name); @@ -136,6 +140,83 @@ static void barrier (xbt_dynar_t action) free(name); } + +static int bcast_spawned_send(int argc, char *argv[]) +{ + char name[80]; + INFO3("%s: Sending %s on %s", MSG_process_self()->name, + argv[1],argv[0]); + MSG_task_send(MSG_task_create(argv[0], 0, parse_double(argv[1]), NULL), + argv[0]); + + sprintf(name,"%s_wait",argv[0]); + return 0; +} + +static void bcast (xbt_dynar_t action) +{ + int i; + char *name; + const char* process_name; + char task_name[80]; + char spawn_name[80]; + char **myargv; + m_process_t comm_helper=NULL; + m_task_t task=NULL; + char *size = xbt_dynar_get_as(action, 2, char *); + coll_ctr counters = (coll_ctr) MSG_process_get_data(MSG_process_self()); + + xbt_assert0(communicator_size, "Size of Communicator is not defined" + ", can't use collective operations"); + + MSG_process_self()->data=NULL; + + process_name = MSG_process_self()->name; + if (!counters){ + DEBUG0("Initialize the counters"); + counters = (coll_ctr) calloc (1, sizeof(struct coll_ctr_t)); + } + + name = bprintf("bcast_%d", counters->bcast_counter++); + if (!strcmp(process_name, "process0")){ + INFO2("%s: %s is the Root",name, process_name); + + for(i=1;i + + + + + +