1 /* Copyright (c) 2009-2018. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "simgrid/msg.h"
13 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
15 static int smpi_replay(int argc, char *argv[]) {
16 smpi_replay_run(&argc, &argv);
20 int main(int argc, char *argv[]){
23 MSG_init(&argc, argv);
26 xbt_assert(argc > 3, "Usage: %s description_file platform_file deployment_file\n"
27 "\tExample: %s smpi_multiple_apps msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]);
29 /* Simulation setting */
30 MSG_create_environment(argv[2]);
32 /* Application deployment: read the description file in order to identify instances to launch */
33 FILE* fp = fopen(argv[1], "r");
35 xbt_die("Cannot open %s", argv[1]);
37 const char* instance_id = NULL;
38 while (fgets(line, sizeof line, fp)) {
39 xbt_assert(1 + strlen(line) < sizeof line, "input buffer too short (read: %s)", line);
40 xbt_dynar_t elems = xbt_str_split_quoted_in_place(line);
41 if(xbt_dynar_length(elems)<3){
42 xbt_die ("Not enough elements in the line");
45 const char** line_char= xbt_dynar_to_array(elems);
46 instance_id = line_char[0];
47 int instance_size = xbt_str_parse_int(line_char[2], "Invalid size: %s");
49 XBT_INFO("Initializing instance %s of size %d", instance_id, instance_size);
50 SMPI_app_instance_register(instance_id, smpi_replay,instance_size);
57 MSG_launch_application(argv[3]);
61 XBT_INFO("Simulation time %g", MSG_get_clock());