-/* Copyright (c) 2009-2013. The SimGrid Team.
+/* Copyright (c) 2009-2014. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-
#include "private.h"
#include <stdio.h>
#include <xbt.h>
TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, extra);
#endif
+ //unknow size from the receiver pov
+ if(size==-1){
+ smpi_mpi_probe(from, 0, MPI_COMM_WORLD, &status);
+ size=status.count;
+ }
+
smpi_mpi_recv(NULL, size, MPI_CURRENT_TYPE, from, 0, MPI_COMM_WORLD, &status);
#ifdef HAVE_TRACING
extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE);
TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, extra);
#endif
+ MPI_Status status;
+ //unknow size from the receiver pov
+ if(size==-1){
+ smpi_mpi_probe(from, 0, MPI_COMM_WORLD, &status);
+ size=status.count;
+ }
request = smpi_mpi_irecv(NULL, size, MPI_CURRENT_TYPE, from, 0, MPI_COMM_WORLD);
int smpi_replay_finalize(){
double sim_time= 1.;
/* One active process will stop. Decrease the counter*/
- active_processes--;
XBT_DEBUG("There are %lu elements in reqq[*]",
xbt_dynar_length(reqq[smpi_comm_rank(MPI_COMM_WORLD)]));
- xbt_dynar_free(&reqq[smpi_comm_rank(MPI_COMM_WORLD)]);
+ if (!xbt_dynar_is_empty(reqq[smpi_comm_rank(MPI_COMM_WORLD)])){
+ int count_requests=xbt_dynar_length(reqq[smpi_comm_rank(MPI_COMM_WORLD)]);
+ MPI_Request requests[count_requests];
+ MPI_Status status[count_requests];
+ unsigned int i;
+
+ xbt_dynar_foreach(reqq[smpi_comm_rank(MPI_COMM_WORLD)],i,requests[i]);
+ smpi_mpi_waitall(count_requests, requests, status);
+ active_processes--;
+ } else {
+ active_processes--;
+ }
+
+ xbt_dynar_free_container(&(reqq[smpi_comm_rank(MPI_COMM_WORLD)]));
+
if(!active_processes){
/* Last process alive speaking */
/* end the simulated timer */
sim_time = smpi_process_simulated_elapsed();
- XBT_INFO("Simulation time %g", sim_time);
+ XBT_INFO("Simulation time %f", sim_time);
_xbt_replay_action_exit();
xbt_free(reqq);
reqq = NULL;