1 /* Copyright (c) 2009-2014. 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. */
8 #include "simgrid/msg.h" /* Yeah! If you want to use msg, you need to include simgrid/msg.h */
9 #include "xbt/sysdep.h" /* calloc, printf */
11 /* Create a log channel to have nice outputs. */
13 #include "xbt/asserts.h"
14 #include "smpi/smpi.h"
15 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
16 "Messages specific for this msg example");
18 static int smpi_replay(int argc, char *argv[]) {
19 smpi_replay_run(&argc, &argv);
23 int main(int argc, char *argv[]){
25 const char *platform_file;
26 const char *application_file;
27 const char *description_file;
29 MSG_init(&argc, argv);
32 printf("Usage: %s description_file platform_file deployment_file\n", argv[0]);
33 printf("example: %s smpi_multiple_apps msg_platform.xml msg_deployment.xml\n", argv[0]);
36 description_file = argv[1];
37 platform_file = argv[2];
38 application_file = argv[3];
41 /* Simulation setting */
42 MSG_create_environment(platform_file);
44 /* Application deployment: read the description file in order to identify instances to launch */
45 FILE* fp = fopen(description_file, "r");
47 xbt_die("Cannot open %s", description_file);
51 int instance_size = 0;
52 const char* instance_id = NULL;
53 while ((read = xbt_getline(&line, &n, fp)) != -1 ){
54 xbt_dynar_t elems = xbt_str_split_quoted_in_place(line);
55 if(xbt_dynar_length(elems)<3){
56 xbt_die ("Not enough elements in the line");
59 const char** line_char= xbt_dynar_to_array(elems);
60 instance_id = line_char[0];
61 instance_size = atoi(line_char[2]);
63 XBT_INFO("Initializing instance %s of size %d", instance_id, instance_size);
64 SMPI_app_instance_register(instance_id, smpi_replay,instance_size);
69 MSG_launch_application(application_file);
74 XBT_INFO("Simulation time %g", MSG_get_clock());