1 /* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved. */
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. */
6 #include <xbt/config.hpp>
10 #include "xbt/virtu.h"
12 #include "src/mc/mc_replay.h"
14 #include "src/simix/smx_private.h"
15 #include "surf/surf.h"
16 #include "simgrid/sg_config.h"
17 #include "smpi/smpi_utils.hpp"
18 #include "colls/colls.h"
19 #include <simgrid/s4u/host.hpp>
21 #include "src/kernel/activity/SynchroComm.hpp"
23 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_base, smpi, "Logging specific to SMPI (base)");
25 static simgrid::config::Flag<double> smpi_wtime_sleep(
26 "smpi/wtime", "Minimum time to inject inside a call to MPI_Wtime", 0.0);
27 static simgrid::config::Flag<double> smpi_init_sleep(
28 "smpi/init", "Time to inject inside a call to MPI_Init", 0.0);
30 void smpi_mpi_init() {
31 if(smpi_init_sleep > 0)
32 simcall_process_sleep(smpi_init_sleep);
35 double smpi_mpi_wtime(){
37 if (smpi_process_initialized() != 0 && smpi_process_finalized() == 0 && smpi_process_get_sampling() == 0) {
39 time = SIMIX_get_clock();
40 // to avoid deadlocks if used as a break condition, such as
41 // while (MPI_Wtime(...) < time_limit) {
44 // because the time will not normally advance when only calls to MPI_Wtime
45 // are made -> deadlock (MPI_Wtime never reaches the time limit)
46 if(smpi_wtime_sleep > 0)
47 simcall_process_sleep(smpi_wtime_sleep);
50 time = SIMIX_get_clock();
55 void smpi_empty_status(MPI_Status * status)
57 if(status != MPI_STATUS_IGNORE) {
58 status->MPI_SOURCE = MPI_ANY_SOURCE;
59 status->MPI_TAG = MPI_ANY_TAG;
60 status->MPI_ERROR = MPI_SUCCESS;
65 int smpi_mpi_get_count(MPI_Status * status, MPI_Datatype datatype)
67 return status->count / datatype->size();