Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[SMPI] Add caller location to tracefiles
[simgrid.git] / src / smpi / smpi_bench.cpp
index e5d3510..f4404d5 100644 (file)
@@ -11,6 +11,7 @@
 
 #include "src/internal_config.h"
 #include "private.h"
+#include "private.hpp"
 #include "xbt/dict.h"
 #include "xbt/sysdep.h"
 #include "xbt/ex.h"
@@ -261,9 +262,8 @@ void smpi_bench_end(void)
     xbt_die("Aborting.");
   }
   // Simulate the benchmarked computation unless disabled via command-line argument
-  if (sg_cfg_get_boolean("smpi/simulate_computation")) {
+  if (xbt_cfg_get_boolean("smpi/simulate-computation")) 
     smpi_execute(xbt_os_timer_elapsed(timer));
-  }
 
   smpi_total_benched_time += xbt_os_timer_elapsed(timer);
 }
@@ -481,7 +481,7 @@ void smpi_sample_3(int global, const char *file, int line)
 void *smpi_shared_malloc(size_t size, const char *file, int line)
 {
   void* mem;
-  if (sg_cfg_get_boolean("smpi/use_shared_malloc")){
+  if (xbt_cfg_get_boolean("smpi/use-shared-malloc")){
     int fd;
     smpi_source_location loc(file, line);
     auto res = allocs.insert(std::make_pair(loc, shared_data_t()));
@@ -497,7 +497,7 @@ void *smpi_shared_malloc(size_t size, const char *file, int line)
           case EEXIST:
             xbt_die("Please cleanup /dev/shm/%s", shmname);
           default:
-            xbt_die("An unhandled error occured while opening %s. shm_open: %s", shmname, strerror(errno));
+            xbt_die("An unhandled error occurred while opening %s. shm_open: %s", shmname, strerror(errno));
         }
       }
       data->second.fd = fd;
@@ -524,7 +524,7 @@ void smpi_shared_free(void *ptr)
 {
   char loc[PTR_STRLEN];
 
-  if (sg_cfg_get_boolean("smpi/use_shared_malloc")){
+  if (xbt_cfg_get_boolean("smpi/use-shared-malloc")){
     snprintf(loc, PTR_STRLEN, "%p", ptr);
     auto meta = allocs_metadata.find(ptr);
     if (meta == allocs_metadata.end()) {
@@ -616,7 +616,7 @@ void smpi_really_switch_data_segment(int dest) {
   if(smpi_size_data_exe == 0)//no need to switch
     return;
 
-#ifdef HAVE_PRIVATIZATION
+#if HAVE_PRIVATIZATION
   if(smpi_loaded_page==-1){//initial switch, do the copy from the real page here
     for (int i=0; i< smpi_process_count(); i++){
       memcpy(smpi_privatisation_regions[i].address, TOPAGE(smpi_start_data_exe), smpi_size_data_exe);
@@ -641,7 +641,7 @@ int smpi_is_privatisation_file(char* file)
 
 void smpi_initialize_global_memory_segments(){
 
-#ifndef HAVE_PRIVATIZATION
+#if !HAVE_PRIVATIZATION
   smpi_privatize_global_variables=0;
   xbt_die("You are trying to use privatization on a system that does not support it. Don't.");
   return;
@@ -712,7 +712,7 @@ Ask the Internet about tutorials on how to increase the files limit such as: htt
 void smpi_destroy_global_memory_segments(){
   if (smpi_size_data_exe == 0)//no need to switch
     return;
-#ifdef HAVE_PRIVATIZATION
+#if HAVE_PRIVATIZATION
   int i;
   for (i=0; i< smpi_process_count(); i++){
     if(munmap(smpi_privatisation_regions[i].address, smpi_size_data_exe) < 0) {
@@ -723,3 +723,35 @@ void smpi_destroy_global_memory_segments(){
   xbt_free(smpi_privatisation_regions);
 #endif
 }
+
+extern "C" {
+
+  smpi_trace_call_location_t trace_call_location;
+
+  smpi_trace_call_location_t* smpi_trace_get_call_location() {
+    return smpi_process_get_call_location();
+  }
+
+  void smpi_trace_set_call_location(const char* file, int line) {
+    smpi_trace_call_location_t* loc = smpi_process_get_call_location();
+
+    loc->previous_filename   = loc->filename;
+    loc->previous_linenumber = loc->linenumber;
+    loc->filename            = file;
+    loc->linenumber          = line;
+  }
+
+  /**
+   * Required for Fortran bindings
+   */
+  void smpi_trace_set_call_location_(const char* file, int* line) {
+    smpi_trace_set_call_location(file, *line);
+  }
+
+  /** 
+   * Required for Fortran if -fsecond-underscore is activated
+   */
+  void smpi_trace_set_call_location__(const char* file, int* line) {
+    smpi_trace_set_call_location(file, *line);
+  }
+}