Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
A value of -1 for smpi/cpu_threshold means infinity.
[simgrid.git] / src / smpi / smpi_global.c
index 27a53de..718d079 100644 (file)
@@ -1,13 +1,9 @@
-/* Copyright (c) 2007, 2008, 2009, 2010. The SimGrid Team.
+/* Copyright (c) 2007-2013. 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 <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-
 #include "private.h"
 #include "smpi_mpi_dt_private.h"
 #include "mc/mc.h"
 #include "simix/smx_private.h"
 #include "simgrid/sg_config.h"
 
+#include <float.h> // DBL_MAX
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_kernel, smpi,
                                 "Logging specific to SMPI (kernel)");
@@ -120,7 +120,7 @@ int smpi_process_initialized(void)
 void smpi_process_mark_as_initialized(void)
 {
   int index = smpi_process_index();
-  if(index != -100)process_data[index]->initialized=1;
+  if((index != -100)&& (index!=MPI_UNDEFINED))process_data[index]->initialized=1;
 }
 
 
@@ -281,6 +281,8 @@ void smpi_global_init(void)
     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]->timer = xbt_os_timer_new();
+    if(MC_is_active())
+      MC_ignore_heap(process_data[i]->timer, xbt_os_timer_size());
     group = smpi_group_new(1);
     process_data[i]->comm_self = smpi_comm_new(group);
     process_data[i]->initialized =0;
@@ -293,6 +295,10 @@ void smpi_global_init(void)
   for (i = 0; i < process_count; i++) {
     smpi_group_set_mapping(group, i, i);
   }
+
+  //check correctness of MPI parameters
+
+  xbt_assert(sg_cfg_get_int("smpi/async_small_thres")<=sg_cfg_get_int("smpi/send_is_detached_thres"));
 }
 
 void smpi_global_destroy(void)
@@ -301,8 +307,8 @@ void smpi_global_destroy(void)
   int i;
 
   smpi_bench_destroy();
-  smpi_group_unuse(smpi_comm_group(MPI_COMM_WORLD));
-  smpi_comm_destroy(MPI_COMM_WORLD);
+  while(smpi_group_unuse(smpi_comm_group(MPI_COMM_WORLD))>0);
+  xbt_free(MPI_COMM_WORLD);
   MPI_COMM_WORLD = MPI_COMM_NULL;
   for (i = 0; i < count; i++) {
     smpi_group_unuse(smpi_comm_group(process_data[i]->comm_self));
@@ -459,6 +465,11 @@ int smpi_main(int (*realmain) (int argc, char *argv[]),int argc, char *argv[])
   mpi_coll_barrier_fun = (int (*)(MPI_Comm comm))
                           mpi_coll_barrier_description[barrier_id].coll;
 
+  smpi_cpu_threshold = sg_cfg_get_double("smpi/cpu_threshold");
+  smpi_running_power = sg_cfg_get_double("smpi/running_power");
+  if (smpi_cpu_threshold < 0)
+    smpi_cpu_threshold = DBL_MAX;
+
   smpi_global_init();
 
   /* Clean IO before the run */
@@ -466,7 +477,7 @@ int smpi_main(int (*realmain) (int argc, char *argv[]),int argc, char *argv[])
   fflush(stderr);
 
   if (MC_is_active())
-    MC_modelcheck_safety();
+    MC_do_the_modelcheck_for_real();
   else
     SIMIX_run();