Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use a global variable to cache the rank of currently running process.
authorPierre-Nicolas Clauss <pini@tuxfamily.org>
Wed, 4 May 2011 13:12:33 +0000 (15:12 +0200)
committerPierre-Nicolas Clauss <pini@tuxfamily.org>
Wed, 4 May 2011 13:12:33 +0000 (15:12 +0200)
include/smpi/smpif.h.in
src/smpi/smpi_bench.c
src/smpi/smpif2c.in

index 3e8ddf7..915d13e 100644 (file)
@@ -17,6 +17,8 @@
 #include <smpi/smpi.h>
 #include <f2c.h>
 
+XBT_PUBLIC(int) smpi_current_rank;
+
 XBT_PUBLIC(int) smpi_process_argc(void);
 XBT_PUBLIC(int) smpi_process_getarg(integer* index, char* dst, ftnlen len);
 XBT_PUBLIC(int) smpi_global_size(void);
index 8c81580..6dcff87 100644 (file)
@@ -14,6 +14,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_bench, smpi,
 
 xbt_dict_t allocs = NULL;       /* Allocated on first use */
 xbt_dict_t samples = NULL;      /* Allocated on first use */
+int smpi_current_rank = 0;      /* Updated after each MPI call */
 
 typedef struct {
   int count;
@@ -68,6 +69,7 @@ static void smpi_execute(double duration)
 void smpi_bench_begin(void)
 {
   xbt_os_timer_start(smpi_process_timer());
+  smpi_current_rank = smpi_process_index();
 }
 
 void smpi_bench_end(void)
index 67ebfc3..bdcbe86 100755 (executable)
@@ -31,7 +31,7 @@ foreach my $fortran (@ARGV) {
          if(/^} (.*?);/) {
             $_ = "}* __attribute__((weak)) $1 = NULL;\n";
          } elsif(/^#define\s*(\S*)\s*\(?([^.]*)(\..*?)?\)?$/) {
-            $_ = "#define $1 $2\[smpi_process_index()\]";
+            $_ = "#define $1 $2\[smpi_current_rank\]";
             if(defined $3) {
                $_ .= $3;
             }