X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/1837819a613b40836d1da43193d34f26ae094e86..4ad681b949af9540957937bbd661c01491248532:/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 39697b06ca..7c75a0bf80 100644 --- a/examples/smpi/replay_multiple/replay_multiple.c +++ b/examples/smpi/replay_multiple/replay_multiple.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2009-2015. The SimGrid Team. +/* Copyright (c) 2009-2017. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -7,6 +7,9 @@ #include "simgrid/msg.h" #include "mpi.h" +#include +#include + XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); static int smpi_replay(int argc, char *argv[]) { @@ -18,6 +21,7 @@ int main(int argc, char *argv[]){ msg_error_t res; MSG_init(&argc, argv); + SMPI_init(); xbt_assert(argc > 3, "Usage: %s description_file platform_file deployment_file\n" "\tExample: %s smpi_multiple_apps msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]); @@ -29,12 +33,10 @@ int main(int argc, char *argv[]){ FILE* fp = fopen(argv[1], "r"); if (fp == NULL) xbt_die("Cannot open %s", argv[1]); - ssize_t read; - char *line = NULL; - size_t n = 0; - int instance_size = 0; + char line[2048]; const char* instance_id = NULL; - while ((read = xbt_getline(&line, &n, fp)) != -1 ){ + while (fgets(line, sizeof line, fp)) { + xbt_assert(1 + strlen(line) < sizeof line, "input buffer too short (read: %s)", line); 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"); @@ -42,7 +44,7 @@ int main(int argc, char *argv[]){ 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"); + int 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); @@ -50,8 +52,9 @@ int main(int argc, char *argv[]){ xbt_free(line_char); } + fclose(fp); + MSG_launch_application(argv[3]); - SMPI_init(); res = MSG_main();