1 /* Copyright (c) 2009-2015. 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"
10 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
12 static int smpi_replay(int argc, char *argv[]) {
13 smpi_replay_run(&argc, &argv);
17 int main(int argc, char *argv[]){
20 MSG_init(&argc, argv);
22 xbt_assert(argc > 3, "Usage: %s description_file platform_file deployment_file\n"
23 "\tExample: %s smpi_multiple_apps msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]);
25 /* Simulation setting */
26 MSG_create_environment(argv[2]);
28 /* Application deployment: read the description file in order to identify instances to launch */
29 FILE* fp = fopen(argv[1], "r");
31 xbt_die("Cannot open %s", argv[1]);
34 int instance_size = 0;
35 const char* instance_id = NULL;
36 while (xbt_getline(&line, &n, fp) != -1 ){
37 xbt_dynar_t elems = xbt_str_split_quoted_in_place(line);
38 if(xbt_dynar_length(elems)<3){
39 xbt_die ("Not enough elements in the line");
42 const char** line_char= xbt_dynar_to_array(elems);
43 instance_id = line_char[0];
44 instance_size = xbt_str_parse_int(line_char[2], "Invalid size: %s");
46 XBT_INFO("Initializing instance %s of size %d", instance_id, instance_size);
47 SMPI_app_instance_register(instance_id, smpi_replay,instance_size);
55 MSG_launch_application(argv[3]);
60 XBT_INFO("Simulation time %g", MSG_get_clock());