X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/c8d557e2067d5510c0c1f349699dba4294d3486c..eee4fd8a61935c3b7cbefe0768e040eeea1c9336:/examples/smpi/replay_multiple/replay_multiple.c diff --git a/examples/smpi/replay_multiple/replay_multiple.c b/examples/smpi/replay_multiple/replay_multiple.c index 9c1340f914..969fe9ac7a 100644 --- a/examples/smpi/replay_multiple/replay_multiple.c +++ b/examples/smpi/replay_multiple/replay_multiple.c @@ -1,11 +1,11 @@ -/* Copyright (c) 2009-2014. The SimGrid Team. +/* Copyright (c) 2009-2015. The SimGrid Team. * 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 -#include "msg/msg.h" /* Yeah! If you want to use msg, you need to include msg/msg.h */ +#include "simgrid/msg.h" /* Yeah! If you want to use msg, you need to include simgrid/msg.h */ #include "xbt/sysdep.h" /* calloc, printf */ #include "mpi.h" /* Create a log channel to have nice outputs. */ @@ -13,23 +13,15 @@ #include "xbt/asserts.h" #include "smpi/smpi.h" XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, - "Messages specific for this msg example"); - -int smpi_replay(int argc, char *argv[]); - -int smpi_replay(int argc, char *argv[]) -{ - smpi_replay_init(&argc, &argv); - - /* Actually do the simulation using smpi_action_trace_run */ - smpi_action_trace_run(NULL); - smpi_replay_finalize(); + "Messages specific for this msg example"); +static int smpi_replay(int argc, char *argv[]) { + smpi_replay_run(&argc, &argv); return 0; } int main(int argc, char *argv[]){ - msg_error_t res; + msg_error_t res; const char *platform_file; const char *application_file; const char *description_file; @@ -46,43 +38,41 @@ int main(int argc, char *argv[]){ application_file = argv[3]; - { /* Simulation setting */ - MSG_create_environment(platform_file); - } - { /* Application deployment */ - //read the description file in order to identify instances to launch - FILE* fp = fopen(description_file, "r"); - if (fp == NULL) - xbt_die("Cannot open %s", description_file); - ssize_t read; - char *line = NULL; - size_t n = 0; - int instance_size = 0; - const char* instance_id = NULL; - while ((read = xbt_getline(&line, &n, fp)) != -1 ){ - xbt_dynar_t elems = xbt_str_split_quoted_in_place(line); - if(xbt_dynar_length(elems)<3){ - xbt_die ("Not enough elements in the line"); - } - - const char** line_char= xbt_dynar_to_array(elems); - instance_id = line_char[0]; - instance_size = atoi(line_char[2]); - - XBT_INFO("Initializing instance %s of size %d", instance_id, instance_size); - SMPI_app_instance_register(instance_id, smpi_replay,instance_size); - - xbt_free(line_char); + /* Simulation setting */ + MSG_create_environment(platform_file); + + /* Application deployment: read the description file in order to identify instances to launch */ + FILE* fp = fopen(description_file, "r"); + if (fp == NULL) + xbt_die("Cannot open %s", description_file); + ssize_t read; + char *line = NULL; + size_t n = 0; + int instance_size = 0; + const char* instance_id = NULL; + while ((read = xbt_getline(&line, &n, fp)) != -1 ){ + xbt_dynar_t elems = xbt_str_split_quoted_in_place(line); + if(xbt_dynar_length(elems)<3){ + xbt_die ("Not enough elements in the line"); } - MSG_launch_application(application_file); - SMPI_init(); + const char** line_char= xbt_dynar_to_array(elems); + instance_id = line_char[0]; + instance_size = xbt_str_parse_int(line_char[2], "Invalid size: %s"); + + XBT_INFO("Initializing instance %s of size %d", instance_id, instance_size); + SMPI_app_instance_register(instance_id, smpi_replay,instance_size); + + xbt_free(line_char); } + + MSG_launch_application(application_file); + SMPI_init(); + res = MSG_main(); XBT_INFO("Simulation time %g", MSG_get_clock()); - SMPI_finalize(); if (res == MSG_OK) return 0;