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 <simgrid/s4u/host.hpp>
20 #include "src/kernel/activity/SynchroComm.hpp"
22 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_base, smpi, "Logging specific to SMPI (base)");
24 static simgrid::config::Flag<double> smpi_wtime_sleep(
25 "smpi/wtime", "Minimum time to inject inside a call to MPI_Wtime", 0.0);
26 static simgrid::config::Flag<double> smpi_init_sleep(
27 "smpi/init", "Time to inject inside a call to MPI_Init", 0.0);
29 void smpi_mpi_init() {
30 if(smpi_init_sleep > 0)
31 simcall_process_sleep(smpi_init_sleep);
34 double smpi_mpi_wtime(){
36 if (smpi_process()->initialized() != 0 && smpi_process()->finalized() == 0 && smpi_process()->sampling() == 0) {
38 time = SIMIX_get_clock();
39 // to avoid deadlocks if used as a break condition, such as
40 // while (MPI_Wtime(...) < time_limit) {
43 // because the time will not normally advance when only calls to MPI_Wtime
44 // are made -> deadlock (MPI_Wtime never reaches the time limit)
45 if(smpi_wtime_sleep > 0)
46 simcall_process_sleep(smpi_wtime_sleep);
49 time = SIMIX_get_clock();
54 void smpi_empty_status(MPI_Status * status)
56 if(status != MPI_STATUS_IGNORE) {
57 status->MPI_SOURCE = MPI_ANY_SOURCE;
58 status->MPI_TAG = MPI_ANY_TAG;
59 status->MPI_ERROR = MPI_SUCCESS;
64 int smpi_mpi_get_count(MPI_Status * status, MPI_Datatype datatype)
66 return status->count / datatype->size();