Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[REPLAY] Remove C-based Replay API
[simgrid.git] / examples / smpi / replay / replay.cpp
1 /* Copyright (c) 2009-2017. 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 "xbt/replay.hpp"
7 #include "smpi/smpi.h"
8
9 /* This shows how to extend the trace format by adding a new kind of events.
10    This function is registered through xbt_replay_action_register() below. */
11 static void action_blah(simgrid::xbt::ReplayAction& args)
12 {
13   /* Add your answer to the blah event here.
14      args is a strings array containing the blank-separated parameters found in the trace for this event instance. */
15 }
16
17 action_fun previous_send;
18 static void overriding_send(simgrid::xbt::ReplayAction& args)
19 {
20   (*previous_send)(args); // Just call the overriden symbol. That's a toy example.
21 }
22
23 int main(int argc, char* argv[])
24 {
25   /* Setup things and register default actions */
26   smpi_replay_init(&argc, &argv);
27
28   /* Connect your callback function to the "blah" event in the trace files */
29   xbt_replay_action_register("blah", action_blah);
30
31   /* The send action is an override, so we have to first save its previous value in a global */
32   int rank;
33   MPI_Comm_rank(MPI_COMM_WORLD, &rank);
34   if (rank == 0) {
35     previous_send = xbt_replay_action_get("send");
36     xbt_replay_action_register("send", overriding_send);
37   }
38   /* The regular run of the replayer */
39   smpi_replay_main(&argc, &argv);
40   return 0;
41 }