char* instance_id;
int replaying; /* is the process replaying a trace */
xbt_bar_t finalization_barrier;
+ int return_value;
} s_smpi_process_data_t;
static smpi_process_data_t *process_data = NULL;
process_data[i]->state = SMPI_UNINITIALIZED;
process_data[i]->sampling = 0;
process_data[i]->finalization_barrier = NULL;
+ process_data[i]->return_value = 0;
}
//if the process was launched through smpirun script we generate a global mpi_comm_world
//if not, we let MPI_COMM_NULL, and the comm world will be private to each mpi instance
xbt_free(process_data);
process_data = NULL;
- if (MPI_COMM_WORLD != MPI_COMM_UNINITIALIZED)
+ if (MPI_COMM_WORLD != MPI_COMM_UNINITIALIZED){
+ smpi_comm_cleanup_smp(MPI_COMM_WORLD);
+ smpi_comm_cleanup_attributes(MPI_COMM_WORLD);
xbt_free(MPI_COMM_WORLD);
+ }
+
MPI_COMM_WORLD = MPI_COMM_NULL;
xbt_free(index_to_process_data);
}
#ifndef WIN32
+
void __attribute__ ((weak)) user_main_()
{
xbt_die("Should not be in this smpi_simulated_main");
return 0;
}
+inline static int smpi_main_wrapper(int argc, char **argv){
+ int ret = smpi_simulated_main_(argc,argv);
+ if(ret !=0){
+ XBT_WARN("SMPI process did not return 0. Return value : %d", ret);
+ smpi_process_data()->return_value=ret;
+ }
+ return 0;
+}
+
int __attribute__ ((weak)) main(int argc, char **argv)
{
- return smpi_main(smpi_simulated_main_, argc, argv);
+ return smpi_main(smpi_main_wrapper, argc, argv);
}
#endif
int reduce_scatter_id =
find_coll_description(mpi_coll_reduce_scatter_description,
- xbt_cfg_get_string("smpi/reduce_scatter"),"reduce_scatter");
+ xbt_cfg_get_string("smpi/reduce-scatter"),"reduce_scatter");
mpi_coll_reduce_scatter_fun = (int (*)(void *sbuf, void *rbuf, int *rcounts,MPI_Datatype dtype, MPI_Op op,
MPI_Comm comm)) mpi_coll_reduce_scatter_description[reduce_scatter_id].coll;
"You may want to use sampling functions or trace replay to reduce this.");
}
}
+ int count = smpi_process_count();
+ int i, ret=0;
+ for (i = 0; i < count; i++) {
+ if(process_data[i]->return_value!=0){
+ ret=process_data[i]->return_value;//return first non 0 value
+ break;
+ }
+ }
smpi_global_destroy();
TRACE_end();
- return 0;
+ return ret;
}
// This function can be called from extern file, to initialize logs, options, and processes of smpi