Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[SMPI] Code beautification.
[simgrid.git] / src / smpi / smpi_global.cpp
index bf3b7cf..9feadcd 100644 (file)
@@ -82,7 +82,7 @@ void smpi_process_init(int *argc, char ***argv)
     //FIXME: dirty cleanup method to avoid using msg cleanup functions on these processes when using MSG+SMPI
     SIMIX_process_set_cleanup_function(proc, SIMIX_process_cleanup);
     char* instance_id = (*argv)[1];
-    int rank = atoi((*argv)[2]);
+    int rank = xbt_str_parse_int((*argv)[2], "Invalid rank: %s");
     index = smpi_process_index_of_smx_process(proc);
 
     if(!index_to_process_data){
@@ -99,16 +99,16 @@ void smpi_process_init(int *argc, char ***argv)
     MPI_Comm* temp_comm_world;
     xbt_bar_t temp_bar;
     smpi_deployment_register_process(instance_id, rank, index, &temp_comm_world ,&temp_bar);
-    data = smpi_process_remote_data(index);
-    data->comm_world = temp_comm_world;
+    data              = smpi_process_remote_data(index);
+    data->comm_world  = temp_comm_world;
     if(temp_bar != NULL) data->finalization_barrier = temp_bar;
-    data->index = index;
+    data->index       = index;
     data->instance_id = instance_id;
-    data->replaying = 0;
+    data->replaying   = 0;
     //xbt_free(simcall_process_get_data(proc));
 
-  simdata_process_t simdata = static_cast<simdata_process_t>(simcall_process_get_data(proc));
-  simdata->data = data;
+    simdata_process_t simdata = static_cast<simdata_process_t>(simcall_process_get_data(proc));
+    simdata->data             = data;
 
     if (*argc > 3) {
       free((*argv)[1]);
@@ -207,13 +207,9 @@ int smpi_process_get_replaying(){
 int smpi_global_size(void)
 {
   char *value = getenv("SMPI_GLOBAL_SIZE");
+  xbt_assert(value,"Please set env var SMPI_GLOBAL_SIZE to the expected number of processes.");
 
-  if (!value) {
-    fprintf(stderr,
-            "Please set env var SMPI_GLOBAL_SIZE to expected number of processes.\n");
-    xbt_abort();
-  }
-  return atoi(value);
+  return xbt_str_parse_int(value, "SMPI_GLOBAL_SIZE contains a non-numerical value: %s");
 }
 
 smpi_process_data_t smpi_process_data(void)
@@ -443,15 +439,15 @@ void smpi_global_init(void)
   smpi_universe_size = process_count;
   process_data = xbt_new0(smpi_process_data_t, process_count);
   for (i = 0; i < process_count; i++) {
-    process_data[i] = xbt_new(s_smpi_process_data_t, 1);
-    //process_data[i]->index = i;
-    process_data[i]->argc    = NULL;
-    process_data[i]->argv    = NULL;
-    process_data[i]->mailbox = simcall_rdv_create(get_mailbox_name(name, i));
-    process_data[i]->mailbox_small =
+    process_data[i]                       = xbt_new(s_smpi_process_data_t, 1);
+    //process_data[i]->index              = i;
+    process_data[i]->argc                 = NULL;
+    process_data[i]->argv                 = NULL;
+    process_data[i]->mailbox              = simcall_rdv_create(get_mailbox_name(name, i));
+    process_data[i]->mailbox_small        =
         simcall_rdv_create(get_mailbox_name_small(name, i));
-    process_data[i]->mailboxes_mutex = xbt_mutex_init();
-    process_data[i]->timer           = xbt_os_timer_new();
+    process_data[i]->mailboxes_mutex      = xbt_mutex_init();
+    process_data[i]->timer                = xbt_os_timer_new();
     if (MC_is_active())
       MC_ignore_heap(process_data[i]->timer, xbt_os_timer_size());
     process_data[i]->comm_self            = MPI_COMM_NULL;