From: Roland Schulz Date: Tue, 26 Aug 2014 19:10:10 +0000 (-0400) Subject: Fix PRINT_ALLOC_KB output X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=bfd0962b09d966b8bcf118120a7d5c599e68df71;p=alexxy%2Fgromacs.git Fix PRINT_ALLOC_KB output Only an issue when compiled with -DPRINT_ALLOC_KB Change-Id: I0fed328ba8e8f943ece3b38f63ce5b6cf84f0f5e --- diff --git a/src/gromacs/utility/smalloc.c b/src/gromacs/utility/smalloc.c index 85ae9d0b14..3ec2536083 100644 --- a/src/gromacs/utility/smalloc.c +++ b/src/gromacs/utility/smalloc.c @@ -52,6 +52,7 @@ #include "gromacs/legacyheaders/gmx_fatal.h" #ifdef PRINT_ALLOC_KB +#include "gromacs/legacyheaders/network.h" #include "gromacs/utility/gmxmpi.h" #endif @@ -149,12 +150,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); } @@ -203,12 +201,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); } @@ -286,8 +281,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