Skip to content

Commit

Permalink
Merge pull request Parallel-NetCDF#158 from Parallel-NetCDF/malloc
Browse files Browse the repository at this point in the history
Use C macros for malloc if debug and profile modes are disabled
  • Loading branch information
wkliao authored and Jonathanlyj committed Dec 1, 2024
1 parent edb95b1 commit c9cc541
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
8 changes: 5 additions & 3 deletions examples/C/nonblocking_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,12 @@ int main(int argc, char **argv)
MPI_Reduce(&put_size, &sum_put_size, 1, MPI_OFFSET, MPI_SUM, 0, MPI_COMM_WORLD);
MPI_Reduce(&write_timing, &max_write_timing, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD);

/* rank 0 also writes header and updates the record number in header NTIME times */
sum_write_size += header_size + NTIMES * 8;

/* rank 0 also writes header and updates the record number to the file
* header NTIME times
*/
if (rank == 0 && verbose) {
sum_write_size += header_size + NTIMES * 8;

printf("\n");
if (use_bput)
printf("Using PnetCDF nonblocking APIs: bput\n");
Expand Down
5 changes: 4 additions & 1 deletion src/drivers/common/utf8proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
* Copyright (C) 2012, Northwestern University and Argonne National Laboratory
* See COPYRIGHT notice in top-level directory.
*/
/* $Id$ */

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include <pnetcdf.h>
#include <pnc_debug.h>
Expand Down
9 changes: 7 additions & 2 deletions src/drivers/include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,17 @@ extern void
NCI_Free_fn(void *ptr, const int lineno, const char *func,
const char *filename);



#if defined(PNETCDF_DEBUG) || defined(PNC_MALLOC_TRACE)
#define NCI_Malloc(a) NCI_Malloc_fn(a,__LINE__,__func__,__FILE__)
#define NCI_Calloc(a,b) NCI_Calloc_fn(a,b,__LINE__,__func__,__FILE__)
#define NCI_Realloc(a,b) NCI_Realloc_fn(a,b,__LINE__,__func__,__FILE__)
#define NCI_Free(a) NCI_Free_fn(a,__LINE__,__func__,__FILE__)
#else
#define NCI_Malloc(a) malloc(a)
#define NCI_Calloc(a,b) calloc(a,b)
#define NCI_Realloc(a,b) realloc(a,b)
#define NCI_Free(a) free(a)
#endif

extern int
ncmpii_inq_malloc_size(size_t *size);
Expand Down

0 comments on commit c9cc541

Please sign in to comment.