Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
e6175e437f3c8c0a644bba411256340ab24880b9
[simgrid.git] / examples / smpi / replay / replay.cpp
1 /* Copyright (c) 2009-2018. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include <simgrid/plugins/load_balancer.h>
7 #include "xbt/replay.hpp"
8 #include "smpi/smpi.h"
9
10 /* This shows how to extend the trace format by adding a new kind of events.
11    This function is registered through xbt_replay_action_register() below. */
12 static void action_blah(simgrid::xbt::ReplayAction& args)
13 {
14   /* Add your answer to the blah event here.
15      args is a strings array containing the blank-separated parameters found in the trace for this event instance. */
16 }
17
18 action_fun previous_send;
19 static void overriding_send(simgrid::xbt::ReplayAction& args)
20 {
21   previous_send(args); // Just call the overriden symbol. That's a toy example.
22 }
23
24 int main(int argc, char* argv[])
25 {
26   /* Setup things and register default actions */
27   smpi_replay_init(&argc, &argv);
28
29   /* Connect your callback function to the "blah" event in the trace files */
30   xbt_replay_action_register("blah", action_blah);
31
32   /* The send action is an override, so we have to first save its previous value in a global */
33   int rank;
34   MPI_Comm_rank(MPI_COMM_WORLD, &rank);
35   if (rank == 0) {
36     previous_send = xbt_replay_action_get("send");
37     xbt_replay_action_register("send", overriding_send);
38   }
39   /* The regular run of the replayer */
40   smpi_replay_main(&argc, &argv);
41   return 0;
42 }