-
-#include <stdio.h>
-#include <mpi.h>
-#include <xbt.h>
-#include <xbt/replay.h>
-
-XBT_LOG_NEW_DEFAULT_CATEGORY(smpi_replay,"Trace Replay with SMPI");
-
-/* Helper function */
-static double parse_double(const char *string)
-{
- double value;
- char *endptr;
- value = strtod(string, &endptr);
- if (*endptr != '\0')
- THROWF(unknown_error, 0, "%s is not a double", string);
- return value;
-}
-
-static void action_compute(const char *const *action)
-{
- XBT_DEBUG("Start to compute %.0f flops", parse_double(action[2]));
- smpi_sample_flops(parse_double(action[2]));
-}
-
-static void action_send(const char *const *action)
-{
- int to = atoi(action[2]);
- const char *size_str = action[3];
- double size=parse_double(size_str);
- char *buffer = (char*) malloc (size);
-
- XBT_DEBUG("send %.0f bytes to rank%d (%s)",size, to, action[2]);
-
- MPI_Send(buffer, size, MPI_BYTE, to, 0, MPI_COMM_WORLD);
-
- free(buffer);
-}
-
-static void action_Isend(const char *const *action)
-{
- int to = atoi(action[2]);
- const char *size_str = action[3];
- double size=parse_double(size_str);
- char *buffer = (char*) malloc (size);
-
- MPI_Request request;
-
- MPI_Isend(buffer, size, MPI_BYTE, to, 0, MPI_COMM_WORLD, &request);
-
- free(buffer);
-}
-
-static void action_recv(const char *const *action)
-{
- int from = atoi(action[2]);
- XBT_DEBUG("receive from rank%d (%s)",from, action[2]);
- char *buffer = (char*) malloc (1e9);
-
- MPI_Status status;
-
- MPI_Recv(buffer, 1e9, MPI_BYTE, from, 0, MPI_COMM_WORLD, &status);
-
- free(buffer);
-}
-
-static void action_Irecv(const char *const *action)
-{
- int from = atoi(action[2]);
- char *buffer = (char*) malloc (1e9);
- MPI_Request request;
-
- XBT_DEBUG("Asynchronous receive from rank%d (%s)",from, action[2]);
-
- MPI_Irecv(buffer, 1e9, MPI_BYTE, from, 0, MPI_COMM_WORLD, &request);
-
- free(buffer);
-}
-
-static void action_wait(const char *const *action)
-{
- MPI_Request request;
- MPI_Status status;
-
- MPI_Wait(&request, &status);
-}
-
-