Skip to content

Commit bccd432

Browse files
committed
guard calls to ncmpi_inq_malloc_xxx with #ifdef PNC_MALLOC_TRACE
1 parent b5f4245 commit bccd432

File tree

8 files changed

+28
-5
lines changed

8 files changed

+28
-5
lines changed

test/largefile/high_dim_var.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ int main(int argc, char** argv) {
172172
err = ncmpi_open(MPI_COMM_WORLD, filename, NC_NOWRITE, MPI_INFO_NULL, &ncid); CHECK_ERR
173173
err = ncmpi_close(ncid); CHECK_ERR
174174

175+
#ifdef PNC_MALLOC_TRACE
175176
/* check if PnetCDF freed all internal malloc */
176177
MPI_Offset malloc_size, sum_size;
177178
err = ncmpi_inq_malloc_size(&malloc_size);
@@ -181,7 +182,7 @@ int main(int argc, char** argv) {
181182
printf("heap memory allocated by PnetCDF internally has %lld bytes yet to be freed\n",
182183
sum_size);
183184
}
184-
185+
#endif
185186
MPI_Allreduce(MPI_IN_PLACE, &nerrs, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
186187
if (rank == 0) {
187188
if (nerrs) printf(FAIL_STR,nerrs);

test/largefile/large_attr.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,13 @@ int main(int argc, char** argv)
3232
{
3333
char filename[256], *name, *buf;
3434
size_t i;
35-
int rank, nprocs, err, nerrs=0, verbose=0;
35+
int rank, nprocs, err, nerrs=0;
3636
int ncid, cmode, varid, dimid;
3737
MPI_Offset nelems, inq_nelems;
3838
MPI_Info info=MPI_INFO_NULL;
39+
#ifdef PNC_MALLOC_TRACE
40+
int verbose=0;
41+
#endif
3942

4043
MPI_Init(&argc, &argv);
4144
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
@@ -316,6 +319,7 @@ int main(int argc, char** argv)
316319

317320
free(buf);
318321

322+
#ifdef PNC_MALLOC_TRACE
319323
/* check if PnetCDF freed all internal malloc */
320324
MPI_Offset malloc_size, sum_size;
321325
err = ncmpi_inq_malloc_size(&malloc_size);
@@ -333,6 +337,7 @@ int main(int argc, char** argv)
333337
printf("\n%d: PnetCDF internal memory footprint high water mark %.2f MB\n",
334338
rank, (float)malloc_size/1048576);
335339
}
340+
#endif
336341

337342
err_out:
338343
MPI_Allreduce(MPI_IN_PLACE, &nerrs, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);

test/largefile/large_coalesce.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ int main(int argc, char** argv)
264264

265265
free(buf);
266266

267+
#ifdef PNC_MALLOC_TRACE
267268
/* check if PnetCDF freed all internal malloc */
268269
MPI_Offset malloc_size, sum_size;
269270
err = ncmpi_inq_malloc_size(&malloc_size);
@@ -273,6 +274,7 @@ int main(int argc, char** argv)
273274
printf("heap memory allocated by PnetCDF internally has %lld bytes yet to be freed\n",
274275
sum_size);
275276
}
277+
#endif
276278

277279
MPI_Allreduce(MPI_IN_PLACE, &nerrs, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
278280
if (rank == 0) {

test/largefile/large_dims_vars_attrs.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@
3030
int main(int argc, char** argv)
3131
{
3232
char filename[256], str[32];
33-
int i, rank, nprocs, err, nerrs=0, verbose=0;
33+
int i, rank, nprocs, err, nerrs=0;
3434
int ncid, cmode, *varid, *dimids, intBuf[1];
35+
#ifdef PNC_MALLOC_TRACE
36+
int verbose=0;
37+
#endif
3538

3639
MPI_Init(&argc, &argv);
3740
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
@@ -131,6 +134,7 @@ int main(int argc, char** argv)
131134
free(varid);
132135
free(dimids);
133136

137+
#ifdef PNC_MALLOC_TRACE
134138
/* check if PnetCDF freed all internal malloc */
135139
MPI_Offset malloc_size, sum_size;
136140
err = ncmpi_inq_malloc_size(&malloc_size);
@@ -148,6 +152,7 @@ int main(int argc, char** argv)
148152
printf("\n%d: PnetCDF internal memory footprint high water mark %.2f MB\n",
149153
rank, (float)malloc_size/1048576);
150154
}
155+
#endif
151156

152157
MPI_Allreduce(MPI_IN_PLACE, &nerrs, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
153158
if (rank == 0) {

test/largefile/large_header.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ int main(int argc, char** argv)
101101

102102
err = ncmpi_close(ncid); CHECK_ERR
103103

104+
#ifdef PNC_MALLOC_TRACE
104105
/* check if PnetCDF freed all internal malloc */
105106
MPI_Offset malloc_size, sum_size;
106107
err = ncmpi_inq_malloc_size(&malloc_size);
@@ -112,6 +113,7 @@ int main(int argc, char** argv)
112113
ncmpi_inq_malloc_list();
113114
}
114115
}
116+
#endif
115117

116118
err_out:
117119
MPI_Allreduce(MPI_IN_PLACE, &nerrs, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);

test/largefile/large_reqs.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,11 @@ int tst_vars(char *filename, MPI_Comm comm)
272272
int main(int argc, char** argv)
273273
{
274274
char filename[256];
275-
int rank, nprocs, err, nerrs=0, color;
275+
int rank, nprocs, nerrs=0, color;
276276
MPI_Comm comm;
277-
277+
#ifdef PNC_MALLOC_TRACE
278+
int err;
279+
#endif
278280
verbose = 0;
279281

280282
MPI_Init(&argc, &argv);
@@ -319,6 +321,7 @@ int main(int argc, char** argv)
319321

320322
if (comm != MPI_COMM_WORLD) MPI_Comm_free(&comm);
321323

324+
#ifdef PNC_MALLOC_TRACE
322325
/* check if PnetCDF freed all internal malloc */
323326
MPI_Offset malloc_size, sum_size;
324327
err = ncmpi_inq_malloc_size(&malloc_size);
@@ -328,6 +331,7 @@ int main(int argc, char** argv)
328331
printf("heap memory allocated by PnetCDF internally has %lld bytes yet to be freed\n",
329332
sum_size);
330333
}
334+
#endif
331335

332336
MPI_Allreduce(MPI_IN_PLACE, &nerrs, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
333337
if (rank == 0) {

test/largefile/large_var.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@ int main(int argc, char** argv)
547547
free(buf);
548548
MPI_Info_free(&info);
549549

550+
#ifdef PNC_MALLOC_TRACE
550551
/* check if PnetCDF freed all internal malloc */
551552
MPI_Offset malloc_size, sum_size;
552553
err = ncmpi_inq_malloc_size(&malloc_size);
@@ -556,6 +557,7 @@ int main(int argc, char** argv)
556557
printf("heap memory allocated by PnetCDF internally has %lld bytes yet to be freed\n",
557558
sum_size);
558559
}
560+
#endif
559561

560562
MPI_Allreduce(MPI_IN_PLACE, &nerrs, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
561563
if (rank == 0) {

test/largefile/tst_cdf5_begin.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,14 @@ int main(int argc, char** argv) {
149149
if (nerrs) printf("fail with %d mismatches\n",nerrs);
150150
else printf("pass\n");
151151
#else
152+
#ifdef PNC_MALLOC_TRACE
152153
/* check if PnetCDF freed all internal malloc */
153154
MPI_Offset malloc_size;
154155
err = ncmpi_inq_malloc_size(&malloc_size);
155156
if (err == NC_NOERR && malloc_size > 0) /* this test is for running 1 process */
156157
printf("heap memory allocated by PnetCDF internally has %lld bytes yet to be freed\n",
157158
malloc_size);
159+
#endif
158160

159161
MPI_Allreduce(MPI_IN_PLACE, &nerrs, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
160162
if (rank == 0) {

0 commit comments

Comments
 (0)