Merge release-5-0 into master
[alexxy/gromacs.git] / src / gromacs / utility / smalloc.c
index 3580a0e0a0c9c8460d7e8f8a4553cbe5830dbd82..6b45a99a82be08246483cfa8eb7035a6d6cfbf4a 100644 (file)
@@ -53,6 +53,7 @@
 
 #include "gromacs/utility/fatalerror.h"
 #ifdef PRINT_ALLOC_KB
+#include "gromacs/utility/basenetwork.h"
 #include "gromacs/utility/gmxmpi.h"
 #endif
 
@@ -151,12 +152,9 @@ void *save_calloc(const char *name, const char *file, int line,
     else
     {
 #ifdef PRINT_ALLOC_KB
-        int rank = 0;
         if (nelem*elsize >= PRINT_ALLOC_KB*1024)
         {
-#ifdef GMX_MPI
-            MPI_Comm_rank(MPI_COMM_WORLD, &rank);
-#endif
+            int rank = gmx_node_rank();
             printf("Allocating %.1f MB for %s (called from file %s, line %d on %d)\n",
                    nelem*elsize/1048576.0, name, file, line, rank);
         }
@@ -205,12 +203,9 @@ void *save_realloc(const char *name, const char *file, int line, void *ptr,
     else
     {
 #ifdef PRINT_ALLOC_KB
-        int rank = 0;
         if (size >= PRINT_ALLOC_KB*1024)
         {
-#ifdef GMX_MPI
-            MPI_Comm_rank(MPI_COMM_WORLD, &rank);
-#endif
+            int rank = gmx_node_rank();
             printf("Reallocating %.1f MB for %s (called from file %s, line %d on %d)\n",
                    size/1048576.0, name, file, line, rank);
         }
@@ -288,8 +283,9 @@ void *save_malloc_aligned(const char *name, const char *file, int line,
 #ifdef PRINT_ALLOC_KB
         if (nelem*elsize >= PRINT_ALLOC_KB*1024)
         {
-            printf("Allocating %.1f MB for %s\n",
-                   nelem*elsize/(PRINT_ALLOC_KB*1024.0), name);
+            int rank = gmx_node_rank();
+            printf("Allocating %.1f MB for %s (called from file %s, line %d on %d)\n",
+                   nelem*elsize/1048576.0, name, file, line, rank);
         }
 #endif