Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove benchmarking calls in MPI functions that don't actually perform comms and...
[simgrid.git] / src / smpi / smpi_pmpi.c
index eaa00a5..5b51a9b 100644 (file)
@@ -1,8 +1,8 @@
-/* Copyright (c) 2007-2013. The SimGrid Team.
+/* Copyright (c) 2007-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. */
+ * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "private.h"
 #include "smpi_mpi_dt_private.h"
@@ -32,7 +32,7 @@ int PMPI_Init(int *argc, char ***argv)
   int rank = smpi_process_index();
   TRACE_smpi_init(rank);
   TRACE_smpi_computing_init(rank);
-  instr_extra_data extra = xbt_new(s_instr_extra_data_t,1);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
   extra->type = TRACING_INIT;
   TRACE_smpi_collective_in(rank, -1, __FUNCTION__, extra);
   TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
@@ -46,7 +46,7 @@ int PMPI_Finalize(void)
   smpi_bench_end();
 #ifdef HAVE_TRACING
   int rank = smpi_process_index();
-  instr_extra_data extra = xbt_new(s_instr_extra_data_t,1);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
   extra->type = TRACING_FINALIZE;
   TRACE_smpi_collective_in(rank, -1, __FUNCTION__, extra);
 #endif
@@ -93,14 +93,12 @@ int PMPI_Query_thread(int *provided)
 {
   int retval = 0;
 
-  smpi_bench_end();
   if (provided == NULL) {
     retval = MPI_ERR_ARG;
   } else {
     *provided = MPI_THREAD_MULTIPLE;
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
@@ -108,14 +106,12 @@ int PMPI_Is_thread_main(int *flag)
 {
   int retval = 0;
 
-  smpi_bench_end();
   if (flag == NULL) {
     retval = MPI_ERR_ARG;
   } else {
     *flag = smpi_process_index() == 0;
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
@@ -131,7 +127,7 @@ int PMPI_Abort(MPI_Comm comm, int errorcode)
 double PMPI_Wtime(void)
 {
   double time;
-  if (smpi_process_initialized() && !smpi_process_finalized() && !smpi_sample_is_running) {
+  if (smpi_process_initialized() && !smpi_process_finalized() && !smpi_process_get_sampling()) {
     smpi_bench_end();
     time = SIMIX_get_clock();
     smpi_bench_begin();
@@ -151,14 +147,12 @@ int PMPI_Address(void *location, MPI_Aint * address)
 {
   int retval = 0;
 
-  smpi_bench_end();
   if (!address) {
     retval = MPI_ERR_ARG;
   } else {
     *address = (MPI_Aint) location;
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
@@ -171,14 +165,12 @@ int PMPI_Type_free(MPI_Datatype * datatype)
 {
   int retval = 0;
 
-  smpi_bench_end();
   if (!datatype) {
     retval = MPI_ERR_ARG;
   } else {
     smpi_datatype_free(datatype);
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
@@ -186,7 +178,6 @@ int PMPI_Type_size(MPI_Datatype datatype, int *size)
 {
   int retval = 0;
 
-  smpi_bench_end();
   if (datatype == MPI_DATATYPE_NULL) {
     retval = MPI_ERR_TYPE;
   } else if (size == NULL) {
@@ -195,7 +186,6 @@ int PMPI_Type_size(MPI_Datatype datatype, int *size)
     *size = (int) smpi_datatype_size(datatype);
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
@@ -203,7 +193,6 @@ int PMPI_Type_get_extent(MPI_Datatype datatype, MPI_Aint * lb, MPI_Aint * extent
 {
   int retval = 0;
 
-  smpi_bench_end();
   if (datatype == MPI_DATATYPE_NULL) {
     retval = MPI_ERR_TYPE;
   } else if (lb == NULL || extent == NULL) {
@@ -211,7 +200,6 @@ int PMPI_Type_get_extent(MPI_Datatype datatype, MPI_Aint * lb, MPI_Aint * extent
   } else {
     retval = smpi_datatype_extent(datatype, lb, extent);
   }
-  smpi_bench_begin();
   return retval;
 }
 
@@ -224,7 +212,6 @@ int PMPI_Type_extent(MPI_Datatype datatype, MPI_Aint * extent)
 {
   int retval = 0;
 
-  smpi_bench_end();
   if (datatype == MPI_DATATYPE_NULL) {
     retval = MPI_ERR_TYPE;
   } else if (extent == NULL) {
@@ -233,7 +220,6 @@ int PMPI_Type_extent(MPI_Datatype datatype, MPI_Aint * extent)
     *extent = smpi_datatype_get_extent(datatype);
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
@@ -241,7 +227,6 @@ int PMPI_Type_lb(MPI_Datatype datatype, MPI_Aint * disp)
 {
   int retval = 0;
 
-  smpi_bench_end();
   if (datatype == MPI_DATATYPE_NULL) {
     retval = MPI_ERR_TYPE;
   } else if (disp == NULL) {
@@ -250,7 +235,6 @@ int PMPI_Type_lb(MPI_Datatype datatype, MPI_Aint * disp)
     *disp = smpi_datatype_lb(datatype);
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
@@ -258,7 +242,6 @@ int PMPI_Type_ub(MPI_Datatype datatype, MPI_Aint * disp)
 {
   int retval = 0;
 
-  smpi_bench_end();
   if (datatype == MPI_DATATYPE_NULL) {
     retval = MPI_ERR_TYPE;
   } else if (disp == NULL) {
@@ -267,7 +250,6 @@ int PMPI_Type_ub(MPI_Datatype datatype, MPI_Aint * disp)
     *disp = smpi_datatype_ub(datatype);
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
@@ -275,14 +257,12 @@ int PMPI_Op_create(MPI_User_function * function, int commute, MPI_Op * op)
 {
   int retval = 0;
 
-  smpi_bench_end();
   if (function == NULL || op == NULL) {
     retval = MPI_ERR_ARG;
   } else {
     *op = smpi_op_new(function, commute);
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
@@ -290,7 +270,6 @@ int PMPI_Op_free(MPI_Op * op)
 {
   int retval = 0;
 
-  smpi_bench_end();
   if (op == NULL) {
     retval = MPI_ERR_ARG;
   } else if (*op == MPI_OP_NULL) {
@@ -300,7 +279,6 @@ int PMPI_Op_free(MPI_Op * op)
     *op = MPI_OP_NULL;
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
@@ -308,7 +286,6 @@ int PMPI_Group_free(MPI_Group * group)
 {
   int retval = 0;
 
-  smpi_bench_end();
   if (group == NULL) {
     retval = MPI_ERR_ARG;
   } else {
@@ -316,7 +293,6 @@ int PMPI_Group_free(MPI_Group * group)
     *group = MPI_GROUP_NULL;
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
@@ -324,7 +300,6 @@ int PMPI_Group_size(MPI_Group group, int *size)
 {
   int retval = 0;
 
-  smpi_bench_end();
   if (group == MPI_GROUP_NULL) {
     retval = MPI_ERR_GROUP;
   } else if (size == NULL) {
@@ -333,7 +308,6 @@ int PMPI_Group_size(MPI_Group group, int *size)
     *size = smpi_group_size(group);
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
@@ -341,7 +315,6 @@ int PMPI_Group_rank(MPI_Group group, int *rank)
 {
   int retval = 0;
 
-  smpi_bench_end();
   if (group == MPI_GROUP_NULL) {
     retval = MPI_ERR_GROUP;
   } else if (rank == NULL) {
@@ -350,7 +323,6 @@ int PMPI_Group_rank(MPI_Group group, int *rank)
     *rank = smpi_group_rank(group, smpi_process_index());
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
@@ -358,7 +330,6 @@ int PMPI_Group_translate_ranks(MPI_Group group1, int n, int *ranks1,
                               MPI_Group group2, int *ranks2)
 {
   int retval, i, index;
-  smpi_bench_end();
   if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
     retval = MPI_ERR_GROUP;
   } else {
@@ -372,7 +343,6 @@ int PMPI_Group_translate_ranks(MPI_Group group1, int n, int *ranks1,
     }
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
@@ -380,7 +350,6 @@ int PMPI_Group_compare(MPI_Group group1, MPI_Group group2, int *result)
 {
   int retval = 0;
 
-  smpi_bench_end();
   if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
     retval = MPI_ERR_GROUP;
   } else if (result == NULL) {
@@ -389,7 +358,6 @@ int PMPI_Group_compare(MPI_Group group1, MPI_Group group2, int *result)
     *result = smpi_group_compare(group1, group2);
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
@@ -398,7 +366,6 @@ int PMPI_Group_union(MPI_Group group1, MPI_Group group2,
 {
   int retval, i, proc1, proc2, size, size2;
 
-  smpi_bench_end();
   if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
     retval = MPI_ERR_GROUP;
   } else if (newgroup == NULL) {
@@ -429,7 +396,6 @@ int PMPI_Group_union(MPI_Group group1, MPI_Group group2,
     }
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
@@ -438,7 +404,6 @@ int PMPI_Group_intersection(MPI_Group group1, MPI_Group group2,
 {
   int retval, i, proc1, proc2, size;
 
-  smpi_bench_end();
   if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
     retval = MPI_ERR_GROUP;
   } else if (newgroup == NULL) {
@@ -468,7 +433,6 @@ int PMPI_Group_intersection(MPI_Group group1, MPI_Group group2,
     }
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
@@ -476,7 +440,6 @@ int PMPI_Group_difference(MPI_Group group1, MPI_Group group2, MPI_Group * newgro
 {
   int retval, i, proc1, proc2, size, size2;
 
-  smpi_bench_end();
   if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
     retval = MPI_ERR_GROUP;
   } else if (newgroup == NULL) {
@@ -504,7 +467,6 @@ int PMPI_Group_difference(MPI_Group group1, MPI_Group group2, MPI_Group * newgro
     }
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
@@ -512,7 +474,6 @@ int PMPI_Group_incl(MPI_Group group, int n, int *ranks, MPI_Group * newgroup)
 {
   int retval, i, index;
 
-  smpi_bench_end();
   if (group == MPI_GROUP_NULL) {
     retval = MPI_ERR_GROUP;
   } else if (newgroup == NULL) {
@@ -536,7 +497,6 @@ int PMPI_Group_incl(MPI_Group group, int n, int *ranks, MPI_Group * newgroup)
     }
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
@@ -544,7 +504,6 @@ int PMPI_Group_excl(MPI_Group group, int n, int *ranks, MPI_Group * newgroup)
 {
   int retval, i, j, newsize, oldsize, index;
 
-  smpi_bench_end();
   if (group == MPI_GROUP_NULL) {
     retval = MPI_ERR_GROUP;
   } else if (newgroup == NULL) {
@@ -564,7 +523,7 @@ int PMPI_Group_excl(MPI_Group group, int n, int *ranks, MPI_Group * newgroup)
       newsize = oldsize - n;
       *newgroup = smpi_group_new(newsize);
 
-      int* to_exclude=xbt_new(int, smpi_group_size(group));
+      int* to_exclude=xbt_new0(int, smpi_group_size(group));
       for(i=0; i<oldsize; i++)
         to_exclude[i]=0;
       for(i=0; i<n; i++)
@@ -583,7 +542,6 @@ int PMPI_Group_excl(MPI_Group group, int n, int *ranks, MPI_Group * newgroup)
     }
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
@@ -592,7 +550,6 @@ int PMPI_Group_range_incl(MPI_Group group, int n, int ranges[][3],
 {
   int retval, i, j, rank, size, index;
 
-  smpi_bench_end();
   if (group == MPI_GROUP_NULL) {
     retval = MPI_ERR_GROUP;
   } else if (newgroup == NULL) {
@@ -641,7 +598,6 @@ int PMPI_Group_range_incl(MPI_Group group, int n, int ranges[][3],
     }
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
@@ -650,7 +606,6 @@ int PMPI_Group_range_excl(MPI_Group group, int n, int ranges[][3],
 {
   int retval, i, rank, newrank,oldrank, size, index, add;
 
-  smpi_bench_end();
   if (group == MPI_GROUP_NULL) {
     retval = MPI_ERR_GROUP;
   } else if (newgroup == NULL) {
@@ -719,15 +674,12 @@ int PMPI_Group_range_excl(MPI_Group group, int n, int ranges[][3],
 
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
 int PMPI_Comm_rank(MPI_Comm comm, int *rank)
 {
   int retval = 0;
-
-  smpi_bench_end();
   if (comm == MPI_COMM_NULL) {
     retval = MPI_ERR_COMM;
   } else if (rank == NULL) {
@@ -736,15 +688,12 @@ int PMPI_Comm_rank(MPI_Comm comm, int *rank)
     *rank = smpi_comm_rank(comm);
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
 int PMPI_Comm_size(MPI_Comm comm, int *size)
 {
   int retval = 0;
-
-  smpi_bench_end();
   if (comm == MPI_COMM_NULL) {
     retval = MPI_ERR_COMM;
   } else if (size == NULL) {
@@ -753,7 +702,6 @@ int PMPI_Comm_size(MPI_Comm comm, int *size)
     *size = smpi_comm_size(comm);
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
@@ -761,7 +709,6 @@ int PMPI_Comm_get_name (MPI_Comm comm, char* name, int* len)
 {
   int retval = 0;
 
-  smpi_bench_end();
   if (comm == MPI_COMM_NULL)  {
     retval = MPI_ERR_COMM;
   } else if (name == NULL || len == NULL)  {
@@ -770,7 +717,6 @@ int PMPI_Comm_get_name (MPI_Comm comm, char* name, int* len)
     smpi_comm_get_name(comm, name, len);
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
@@ -778,7 +724,6 @@ int PMPI_Comm_group(MPI_Comm comm, MPI_Group * group)
 {
   int retval = 0;
 
-  smpi_bench_end();
   if (comm == MPI_COMM_NULL) {
     retval = MPI_ERR_COMM;
   } else if (group == NULL) {
@@ -792,7 +737,6 @@ int PMPI_Comm_group(MPI_Comm comm, MPI_Group * group)
     smpi_group_use(*group);
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
@@ -800,7 +744,6 @@ int PMPI_Comm_compare(MPI_Comm comm1, MPI_Comm comm2, int *result)
 {
   int retval = 0;
 
-  smpi_bench_end();
   if (comm1 == MPI_COMM_NULL || comm2 == MPI_COMM_NULL) {
     retval = MPI_ERR_COMM;
   } else if (result == NULL) {
@@ -818,7 +761,6 @@ int PMPI_Comm_compare(MPI_Comm comm1, MPI_Comm comm2, int *result)
     }
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
@@ -826,7 +768,6 @@ int PMPI_Comm_dup(MPI_Comm comm, MPI_Comm * newcomm)
 {
   int retval = 0;
 
-  smpi_bench_end();
   if (comm == MPI_COMM_NULL) {
     retval = MPI_ERR_COMM;
   } else if (newcomm == NULL) {
@@ -835,7 +776,6 @@ int PMPI_Comm_dup(MPI_Comm comm, MPI_Comm * newcomm)
     *newcomm = smpi_comm_new(smpi_comm_group(comm));
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
@@ -843,7 +783,6 @@ int PMPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm * newcomm)
 {
   int retval = 0;
 
-  smpi_bench_end();
   if (comm == MPI_COMM_NULL) {
     retval = MPI_ERR_COMM;
   } else if (group == MPI_GROUP_NULL) {
@@ -858,7 +797,6 @@ int PMPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm * newcomm)
     *newcomm = smpi_comm_new(group);
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
@@ -866,7 +804,6 @@ int PMPI_Comm_free(MPI_Comm * comm)
 {
   int retval = 0;
 
-  smpi_bench_end();
   if (comm == NULL) {
     retval = MPI_ERR_ARG;
   } else if (*comm == MPI_COMM_NULL) {
@@ -876,7 +813,6 @@ int PMPI_Comm_free(MPI_Comm * comm)
     *comm = MPI_COMM_NULL;
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
@@ -885,7 +821,6 @@ int PMPI_Comm_disconnect(MPI_Comm * comm)
   /* TODO: wait until all communication in comm are done */
   int retval = 0;
 
-  smpi_bench_end();
   if (comm == NULL) {
     retval = MPI_ERR_ARG;
   } else if (*comm == MPI_COMM_NULL) {
@@ -895,15 +830,14 @@ int PMPI_Comm_disconnect(MPI_Comm * comm)
     *comm = MPI_COMM_NULL;
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
 int PMPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm* comm_out)
 {
   int retval = 0;
-
   smpi_bench_end();
+
   if (comm_out == NULL) {
     retval = MPI_ERR_ARG;
   } else if (comm == MPI_COMM_NULL) {
@@ -913,6 +847,7 @@ int PMPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm* comm_out)
     retval = MPI_SUCCESS;
   }
   smpi_bench_begin();
+
   return retval;
 }
 
@@ -1020,7 +955,6 @@ int PMPI_Request_free(MPI_Request * request)
   if (*request == MPI_REQUEST_NULL) {
     retval = MPI_ERR_ARG;
   } else {
-    if((*request)->flags & PERSISTENT)(*request)->refcount--;
     smpi_mpi_request_free(request);
     retval = MPI_SUCCESS;
   }
@@ -1058,7 +992,7 @@ int PMPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src,
     int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
     int src_traced = smpi_group_index(smpi_comm_group(comm), src);
 
-    instr_extra_data extra = xbt_new(s_instr_extra_data_t,1);
+    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
     extra->type = TRACING_IRECV;
     extra->send_size = count;
     extra->src = src_traced;
@@ -1112,7 +1046,7 @@ int PMPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst,
     int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
     int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
 
-    instr_extra_data extra = xbt_new(s_instr_extra_data_t,1);
+    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
     extra->type = TRACING_ISEND;
     extra->send_size = count;
     extra->src = rank;
@@ -1165,7 +1099,7 @@ int PMPI_Issend(void* buf, int count, MPI_Datatype datatype,
 #ifdef HAVE_TRACING
     int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
     int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
-    instr_extra_data extra = xbt_new(s_instr_extra_data_t,1);
+    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
     extra->type = TRACING_ISSEND;
     extra->send_size = count;
     extra->src = rank;
@@ -1216,7 +1150,7 @@ int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag,
 #ifdef HAVE_TRACING
   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
   int src_traced = smpi_group_index(smpi_comm_group(comm), src);
-  instr_extra_data extra = xbt_new(s_instr_extra_data_t,1);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
   extra->type = TRACING_RECV;
   extra->send_size = count;
   extra->src = src_traced;
@@ -1230,9 +1164,11 @@ int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag,
 
 #ifdef HAVE_TRACING
   //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
-  if(status!=MPI_STATUS_IGNORE)src_traced = smpi_group_index(smpi_comm_group(comm), status->MPI_SOURCE);
+  if(status!=MPI_STATUS_IGNORE){
+    src_traced = smpi_group_index(smpi_comm_group(comm), status->MPI_SOURCE);
+    TRACE_smpi_recv(rank, src_traced, rank);
+  }
   TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__);
-  TRACE_smpi_recv(rank, src_traced, rank);
 #endif
   }
 
@@ -1266,7 +1202,7 @@ int PMPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag,
 #ifdef HAVE_TRACING
   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
   int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
-  instr_extra_data extra = xbt_new(s_instr_extra_data_t,1);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
   extra->type = TRACING_SEND;
   extra->send_size = count;
   extra->src = rank;
@@ -1314,7 +1250,7 @@ int PMPI_Ssend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MP
  #ifdef HAVE_TRACING
    int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
    int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
-   instr_extra_data extra = xbt_new(s_instr_extra_data_t,1);
+   instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
    extra->type = TRACING_SSEND;
    extra->send_size = count;
    extra->src = rank;
@@ -1368,7 +1304,7 @@ int PMPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
   int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
   int src_traced = smpi_group_index(smpi_comm_group(comm), src);
-  instr_extra_data extra = xbt_new(s_instr_extra_data_t,1);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
   extra->type = TRACING_SENDRECV;
   extra->send_size = sendcount;
   extra->recv_size = recvcount;
@@ -1410,7 +1346,7 @@ int PMPI_Sendrecv_replace(void *buf, int count, MPI_Datatype datatype,
       retval = MPI_ERR_COUNT;
   } else {
     int size = smpi_datatype_get_extent(datatype) * count;
-    recvbuf = xbt_new(char, size);
+    recvbuf = xbt_new0(char, size);
     retval =
         MPI_Sendrecv(buf, count, datatype, dst, sendtag, recvbuf, count,
                      datatype, src, recvtag, comm, status);
@@ -1540,7 +1476,7 @@ int PMPI_Wait(MPI_Request * request, MPI_Status * status)
     int dst_traced = (*request)->dst;
     MPI_Comm comm = (*request)->comm;
     int is_wait_for_receive = (*request)->recv;
-    instr_extra_data extra = xbt_new(s_instr_extra_data_t,1);
+    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
     extra->type = TRACING_WAIT;
     TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__, extra);
 #endif
@@ -1568,16 +1504,17 @@ int PMPI_Wait(MPI_Request * request, MPI_Status * status)
 
 int PMPI_Waitany(int count, MPI_Request requests[], int *index, MPI_Status * status)
 {
-  int retval = 0;
+  if (index == NULL)
+    return MPI_ERR_ARG;
 
   smpi_bench_end();
 #ifdef HAVE_TRACING
   //save requests information for tracing
   int i;
-  int *srcs = xbt_new(int, count);
-  int *dsts = xbt_new(int, count);
-  int *recvs = xbt_new(int, count);
-  MPI_Comm *comms = xbt_new(MPI_Comm, count);
+  int *srcs = xbt_new0(int, count);
+  int *dsts = xbt_new0(int, count);
+  int *recvs = xbt_new0(int, count);
+  MPI_Comm *comms = xbt_new0(MPI_Comm, count);
 
   for (i = 0; i < count; i++) {
     MPI_Request req = requests[i];      //already received requests are no longer valid
@@ -1589,18 +1526,13 @@ int PMPI_Waitany(int count, MPI_Request requests[], int *index, MPI_Status * sta
     }
   }
   int rank_traced = smpi_process_index();
-  instr_extra_data extra = xbt_new(s_instr_extra_data_t,1);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
   extra->type = TRACING_WAITANY;
   extra->send_size=count;
   TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__,extra);
 
 #endif
-  if (index == NULL) {
-    retval = MPI_ERR_ARG;
-  } else {
-    *index = smpi_mpi_waitany(count, requests, status);
-    retval = MPI_SUCCESS;
-  }
+  *index = smpi_mpi_waitany(count, requests, status);
 #ifdef HAVE_TRACING
   if(*index!=MPI_UNDEFINED){
     int src_traced = srcs[*index];
@@ -1623,7 +1555,7 @@ int PMPI_Waitany(int count, MPI_Request requests[], int *index, MPI_Status * sta
   }
 #endif
   smpi_bench_begin();
-  return retval;
+  return MPI_SUCCESS;
 }
 
 int PMPI_Waitall(int count, MPI_Request requests[], MPI_Status status[])
@@ -1633,11 +1565,11 @@ int PMPI_Waitall(int count, MPI_Request requests[], MPI_Status status[])
 #ifdef HAVE_TRACING
   //save information from requests
   int i;
-  int *srcs = xbt_new(int, count);
-  int *dsts = xbt_new(int, count);
-  int *recvs = xbt_new(int, count);
-  int *valid = xbt_new(int, count);
-  MPI_Comm *comms = xbt_new(MPI_Comm, count);
+  int *srcs = xbt_new0(int, count);
+  int *dsts = xbt_new0(int, count);
+  int *recvs = xbt_new0(int, count);
+  int *valid = xbt_new0(int, count);
+  MPI_Comm *comms = xbt_new0(MPI_Comm, count);
 
   //int valid_count = 0;
   for (i = 0; i < count; i++) {
@@ -1653,7 +1585,7 @@ int PMPI_Waitall(int count, MPI_Request requests[], MPI_Status status[])
     }
   }
   int rank_traced = smpi_process_index();
-  instr_extra_data extra = xbt_new(s_instr_extra_data_t,1);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
   extra->type = TRACING_WAITALL;
   extra->send_size=count;
   TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__,extra);
@@ -1734,7 +1666,7 @@ int PMPI_Bcast(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm c
   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
   int root_traced = smpi_group_index(smpi_comm_group(comm), root);
 
-  instr_extra_data extra = xbt_new(s_instr_extra_data_t,1);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
   extra->type = TRACING_BCAST;
   extra->send_size = count;
   extra->root = root_traced;
@@ -1764,7 +1696,7 @@ int PMPI_Barrier(MPI_Comm comm)
   } else {
 #ifdef HAVE_TRACING
   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
-  instr_extra_data extra = xbt_new(s_instr_extra_data_t,1);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
   extra->type = TRACING_BARRIER;
   TRACE_smpi_collective_in(rank, -1, __FUNCTION__, extra);
 #endif
@@ -1807,7 +1739,7 @@ int PMPI_Gather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
 #ifdef HAVE_TRACING
   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
   int root_traced = smpi_group_index(smpi_comm_group(comm), root);
-  instr_extra_data extra = xbt_new(s_instr_extra_data_t,1);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
   extra->type = TRACING_GATHER;
   extra->send_size = sendtmpcount;
   extra->recv_size = recvcount;
@@ -1862,7 +1794,7 @@ int PMPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
   int root_traced = smpi_group_index(smpi_comm_group(comm), root);
   int i=0;
   int size = smpi_comm_size(comm);
-  instr_extra_data extra = xbt_new(s_instr_extra_data_t,1);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
   extra->type = TRACING_GATHERV;
   extra->send_size = sendtmpcount;
   extra->recvcounts= xbt_malloc(size*sizeof(int));
@@ -1911,7 +1843,7 @@ int PMPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
     }
 #ifdef HAVE_TRACING
   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
-  instr_extra_data extra = xbt_new(s_instr_extra_data_t,1);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
   extra->type = TRACING_ALLGATHER;
   extra->send_size = sendcount;
   extra->recv_size = recvcount;
@@ -1960,7 +1892,7 @@ int PMPI_Allgatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
   int i=0;
   int size = smpi_comm_size(comm);
-  instr_extra_data extra = xbt_new(s_instr_extra_data_t,1);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
   extra->type = TRACING_ALLGATHERV;
   extra->send_size = sendcount;
   extra->recvcounts= xbt_malloc(size*sizeof(int));
@@ -2006,7 +1938,7 @@ int PMPI_Scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype,
 #ifdef HAVE_TRACING
   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
   int root_traced = smpi_group_index(smpi_comm_group(comm), root);
-  instr_extra_data extra = xbt_new(s_instr_extra_data_t,1);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
   extra->type = TRACING_SCATTER;
   extra->send_size = sendcount;
   extra->recv_size= recvcount;
@@ -2053,7 +1985,7 @@ int PMPI_Scatterv(void *sendbuf, int *sendcounts, int *displs,
   int root_traced = smpi_group_index(smpi_comm_group(comm), root);
   int i=0;
   int size = smpi_comm_size(comm);
-  instr_extra_data extra = xbt_new(s_instr_extra_data_t,1);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
   extra->type = TRACING_SCATTERV;
   extra->recv_size = recvcount;
   extra->sendcounts= xbt_malloc(size*sizeof(int));
@@ -2094,7 +2026,7 @@ int PMPI_Reduce(void *sendbuf, void *recvbuf, int count,
 #ifdef HAVE_TRACING
   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
   int root_traced = smpi_group_index(smpi_comm_group(comm), root);
-  instr_extra_data extra = xbt_new(s_instr_extra_data_t,1);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
   extra->type = TRACING_REDUCE;
   extra->send_size = count;
   extra->datatype1 = encode_datatype(datatype);
@@ -2151,7 +2083,7 @@ int PMPI_Allreduce(void *sendbuf, void *recvbuf, int count,
     }
 #ifdef HAVE_TRACING
   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
-  instr_extra_data extra = xbt_new(s_instr_extra_data_t,1);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
   extra->type = TRACING_ALLREDUCE;
   extra->send_size = count;
   extra->datatype1 = encode_datatype(datatype);
@@ -2190,7 +2122,7 @@ int PMPI_Scan(void *sendbuf, void *recvbuf, int count,
   } else {
 #ifdef HAVE_TRACING
   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
-  instr_extra_data extra = xbt_new(s_instr_extra_data_t,1);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
   extra->type = TRACING_SCAN;
   extra->send_size = count;
   extra->datatype1 = encode_datatype(datatype);
@@ -2223,7 +2155,7 @@ int PMPI_Exscan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
   } else {
 #ifdef HAVE_TRACING
   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
-  instr_extra_data extra = xbt_new(s_instr_extra_data_t,1);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
   extra->type = TRACING_EXSCAN;
   extra->send_size = count;
   extra->datatype1 = encode_datatype(datatype);
@@ -2260,7 +2192,7 @@ int PMPI_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts,
   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
   int i=0;
   int size = smpi_comm_size(comm);
-  instr_extra_data extra = xbt_new(s_instr_extra_data_t,1);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
   extra->type = TRACING_REDUCE_SCATTER;
   extra->send_size = 0;
   extra->recvcounts= xbt_malloc(size*sizeof(int));
@@ -2307,7 +2239,7 @@ int PMPI_Reduce_scatter_block(void *sendbuf, void *recvbuf, int recvcount,
 
 #ifdef HAVE_TRACING
   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
-  instr_extra_data extra = xbt_new(s_instr_extra_data_t,1);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
   extra->type = TRACING_REDUCE_SCATTER;
   extra->send_size = 0;
   extra->recvcounts= xbt_malloc(count*sizeof(int));
@@ -2349,7 +2281,7 @@ int PMPI_Alltoall(void *sendbuf, int sendcount, MPI_Datatype sendtype,
   } else {
 #ifdef HAVE_TRACING
   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
-  instr_extra_data extra = xbt_new(s_instr_extra_data_t,1);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
   extra->type = TRACING_ALLTOALL;
   extra->send_size = sendcount;
   extra->recv_size = recvcount;
@@ -2389,7 +2321,7 @@ int PMPI_Alltoallv(void *sendbuf, int *sendcounts, int *senddisps,
   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
   int i=0;
   int size = smpi_comm_size(comm);
-  instr_extra_data extra = xbt_new(s_instr_extra_data_t,1);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
   extra->type = TRACING_ALLTOALLV;
   extra->send_size = 0;
   extra->recv_size = 0;
@@ -2428,7 +2360,6 @@ int PMPI_Get_processor_name(char *name, int *resultlen)
 {
   int retval = MPI_SUCCESS;
 
-  smpi_bench_end();
   strncpy(name, SIMIX_host_get_name(SIMIX_host_self()),
           strlen(SIMIX_host_get_name(SIMIX_host_self())) < MPI_MAX_PROCESSOR_NAME - 1 ?
           strlen(SIMIX_host_get_name(SIMIX_host_self())) +1 :
@@ -2437,7 +2368,6 @@ int PMPI_Get_processor_name(char *name, int *resultlen)
       strlen(name) >
       MPI_MAX_PROCESSOR_NAME ? MPI_MAX_PROCESSOR_NAME : strlen(name);
 
-  smpi_bench_begin();
   return retval;
 }
 
@@ -2446,7 +2376,6 @@ int PMPI_Get_count(MPI_Status * status, MPI_Datatype datatype, int *count)
   int retval = MPI_SUCCESS;
   size_t size;
 
-  smpi_bench_end();
   if (status == NULL || count == NULL) {
     retval = MPI_ERR_ARG;
   } else if (datatype == MPI_DATATYPE_NULL) {
@@ -2461,14 +2390,12 @@ int PMPI_Get_count(MPI_Status * status, MPI_Datatype datatype, int *count)
       *count = smpi_mpi_get_count(status, datatype);
     }
   }
-  smpi_bench_begin();
   return retval;
 }
 
 int PMPI_Type_contiguous(int count, MPI_Datatype old_type, MPI_Datatype* new_type) {
   int retval = 0;
 
-  smpi_bench_end();
   if (old_type == MPI_DATATYPE_NULL) {
     retval = MPI_ERR_TYPE;
   } else if (count<0){
@@ -2476,21 +2403,18 @@ int PMPI_Type_contiguous(int count, MPI_Datatype old_type, MPI_Datatype* new_typ
   } else {
     retval = smpi_datatype_contiguous(count, old_type, new_type, 0);
   }
-  smpi_bench_begin();
   return retval;
 }
 
 int PMPI_Type_commit(MPI_Datatype* datatype) {
   int retval = 0;
 
-  smpi_bench_end();
   if (datatype == NULL || *datatype == MPI_DATATYPE_NULL) {
     retval = MPI_ERR_TYPE;
   } else {
     smpi_datatype_commit(datatype);
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
@@ -2498,7 +2422,6 @@ int PMPI_Type_commit(MPI_Datatype* datatype) {
 int PMPI_Type_vector(int count, int blocklen, int stride, MPI_Datatype old_type, MPI_Datatype* new_type) {
   int retval = 0;
 
-  smpi_bench_end();
   if (old_type == MPI_DATATYPE_NULL) {
     retval = MPI_ERR_TYPE;
   } else if (count<0 || blocklen<0){
@@ -2506,14 +2429,12 @@ int PMPI_Type_vector(int count, int blocklen, int stride, MPI_Datatype old_type,
   } else {
     retval = smpi_datatype_vector(count, blocklen, stride, old_type, new_type);
   }
-  smpi_bench_begin();
   return retval;
 }
 
 int PMPI_Type_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* new_type) {
   int retval = 0;
 
-  smpi_bench_end();
   if (old_type == MPI_DATATYPE_NULL) {
     retval = MPI_ERR_TYPE;
   } else if (count<0 || blocklen<0){
@@ -2521,7 +2442,6 @@ int PMPI_Type_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old
   } else {
     retval = smpi_datatype_hvector(count, blocklen, stride, old_type, new_type);
   }
-  smpi_bench_begin();
   return retval;
 }
 
@@ -2532,7 +2452,6 @@ int PMPI_Type_create_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datat
 int PMPI_Type_indexed(int count, int* blocklens, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
   int retval = 0;
 
-  smpi_bench_end();
   if (old_type == MPI_DATATYPE_NULL) {
     retval = MPI_ERR_TYPE;
   } else if (count<0){
@@ -2540,14 +2459,12 @@ int PMPI_Type_indexed(int count, int* blocklens, int* indices, MPI_Datatype old_
   } else {
     retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type);
   }
-  smpi_bench_begin();
   return retval;
 }
 
 int PMPI_Type_create_indexed(int count, int* blocklens, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
   int retval = 0;
 
-  smpi_bench_end();
   if (old_type == MPI_DATATYPE_NULL) {
     retval = MPI_ERR_TYPE;
   } else if (count<0){
@@ -2555,14 +2472,12 @@ int PMPI_Type_create_indexed(int count, int* blocklens, int* indices, MPI_Dataty
   } else {
     retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type);
   }
-  smpi_bench_begin();
   return retval;
 }
 
 int PMPI_Type_create_indexed_block(int count, int blocklength, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
   int retval,i;
 
-  smpi_bench_end();
   if (old_type == MPI_DATATYPE_NULL) {
     retval = MPI_ERR_TYPE;
   } else if (count<0){
@@ -2573,7 +2488,6 @@ int PMPI_Type_create_indexed_block(int count, int blocklength, int* indices, MPI
     retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type);
     xbt_free(blocklens);
   }
-  smpi_bench_begin();
   return retval;
 }
 
@@ -2581,7 +2495,6 @@ int PMPI_Type_create_indexed_block(int count, int blocklength, int* indices, MPI
 int PMPI_Type_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
   int retval = 0;
 
-  smpi_bench_end();
   if (old_type == MPI_DATATYPE_NULL) {
     retval = MPI_ERR_TYPE;
   } else if (count<0){
@@ -2589,7 +2502,6 @@ int PMPI_Type_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Datatyp
   } else {
     retval = smpi_datatype_hindexed(count, blocklens, indices, old_type, new_type);
   }
-  smpi_bench_begin();
   return retval;
 }
 
@@ -2600,7 +2512,6 @@ int PMPI_Type_create_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_
 int PMPI_Type_create_hindexed_block(int count, int blocklength, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
   int retval,i;
 
-  smpi_bench_end();
   if (old_type == MPI_DATATYPE_NULL) {
     retval = MPI_ERR_TYPE;
   } else if (count<0){
@@ -2611,7 +2522,6 @@ int PMPI_Type_create_hindexed_block(int count, int blocklength, MPI_Aint* indice
     retval = smpi_datatype_hindexed(count, blocklens, indices, old_type, new_type);
     xbt_free(blocklens);
   }
-  smpi_bench_begin();
   return retval;
 }
 
@@ -2619,13 +2529,11 @@ int PMPI_Type_create_hindexed_block(int count, int blocklength, MPI_Aint* indice
 int PMPI_Type_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types, MPI_Datatype* new_type) {
   int retval = 0;
 
-  smpi_bench_end();
   if (count<0){
     retval = MPI_ERR_COUNT;
   } else {
     retval = smpi_datatype_struct(count, blocklens, indices, old_types, new_type);
   }
-  smpi_bench_begin();
   return retval;
 }