Skip to content

Commit 60e73ca

Browse files
committed
PNETCDF_PROFILING: print profiling timings by world rank 0 only
1 parent 5b7eb2a commit 60e73ca

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

src/drivers/pncio/pncio_close.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ int PNCIO_File_close(PNCIO_File *fh)
3838
NCI_Free(fh->io_buf);
3939

4040
#if defined(PNETCDF_PROFILING) && (PNETCDF_PROFILING == 1)
41-
int i, rank;
41+
int i, world_rank;
4242
double timing[NMEASURES*2], max_t[NMEASURES*2], pread_t;
4343
MPI_Count max_ntimes, counter[NMEASURES*2], max_c[NMEASURES*2];
4444

4545
/* print two-phase I/O timing breakdown */
46-
MPI_Comm_rank(fh->comm, &rank);
46+
MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
4747
for (i=0; i<NMEASURES; i++) {
4848
timing[i] = fh->write_timing[i];
4949
counter[i] = fh->write_counter[i];
@@ -56,7 +56,7 @@ int PNCIO_File_close(PNCIO_File *fh)
5656
pread_t = max_t[NMEASURES+2];
5757
max_ntimes = max_c[0];
5858

59-
if (rank == 0 && max_ntimes > 0) {
59+
if (world_rank == 0 && max_ntimes > 0) {
6060
printf("%s: TWO-PHASE write init %5.2f pwrite %5.2f pread %5.2f post %5.2f hsort %5.2f comm %5.2f collw %5.2f\n",
6161
__func__, max_t[1], max_t[2], pread_t, max_t[4], max_t[5], max_t[3], max_t[0]);
6262
printf("%s: TWO-PHASE write ntimes %lld check_hole %lld (total_num %lld nrecv %lld) no check %lld (total_num %lld nrecv %lld)\n",
@@ -65,7 +65,7 @@ int PNCIO_File_close(PNCIO_File *fh)
6565

6666
max_ntimes = max_c[NMEASURES];
6767

68-
if (rank == 0 && max_ntimes > 0)
68+
if (world_rank == 0 && max_ntimes > 0)
6969
printf("%s: TWO-PHASE read init %5.2f pread %5.2f post %5.2f wait %5.2f collr %5.2f ntimes %lld\n",
7070
__func__, max_t[NMEASURES+1], max_t[NMEASURES+2], max_t[NMEASURES+4], max_t[NMEASURES+3], max_t[NMEASURES+0], max_ntimes);
7171
#endif

src/drivers/pncio/pncio_lustre_open.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,8 @@ first_ost_id = -1;
791791
MPI_Comm_rank(fd->comm, &rank);
792792

793793
#if defined(PNETCDF_PROFILING) && (PNETCDF_PROFILING == 1)
794-
static int wkl=0; if (wkl == 0 && rank == 0) { printf("\nxxxx %s at %d: %s ---- %s\n",__func__,__LINE__,(fd->file_system == PNCIO_LUSTRE)?"PNCIO_LUSTRE":"PNCIO_UFS",fd->filename); wkl++; fflush(stdout);}
794+
int world_rank; MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
795+
static int wkl=0; if (wkl == 0 && world_rank == 0) { printf("\nxxxx %s at %d: %s ---- %s\n",__func__,__LINE__,(fd->file_system == PNCIO_LUSTRE)?"PNCIO_LUSTRE":"PNCIO_UFS",fd->filename); wkl++; fflush(stdout);}
795796
#endif
796797

797798
#if defined(HAVE_LUSTRE) || defined(MIMIC_LUSTRE)
@@ -1066,7 +1067,8 @@ first_ost_id = -1;
10661067
MPI_Comm_rank(fd->comm, &rank);
10671068

10681069
#if defined(PNETCDF_PROFILING) && (PNETCDF_PROFILING == 1)
1069-
static int wkl=0; if (wkl == 0 && rank == 0) { printf("\nxxxx %s at %d: %s ---- %s\n",__func__,__LINE__,(fd->file_system == PNCIO_LUSTRE)?"PNCIO_LUSTRE":"PNCIO_UFS",fd->filename); wkl++; fflush(stdout);}
1070+
int world_rank; MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
1071+
static int wkl=0; if (wkl == 0 && world_rank == 0) { printf("\nxxxx %s at %d: %s ---- %s\n",__func__,__LINE__,(fd->file_system == PNCIO_LUSTRE)?"PNCIO_LUSTRE":"PNCIO_UFS",fd->filename); wkl++; fflush(stdout);}
10701072
#endif
10711073

10721074
old_mask = umask(022);

src/drivers/pncio/pncio_open.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ GEN_create(PNCIO_File *fd,
117117
MPI_Comm_rank(fd->comm, &rank);
118118

119119
#if defined(PNETCDF_PROFILING) && (PNETCDF_PROFILING == 1)
120-
if (rank == 0) { printf("\nxxxx %s at %d: ---- %s\n",__func__,__LINE__,fd->filename); fflush(stdout);}
120+
int world_rank; MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
121+
if (world_rank == 0) { printf("\nxxxx %s at %d: ---- %s\n",__func__,__LINE__,fd->filename); fflush(stdout);}
121122
#endif
122123

123124
amode = O_CREAT;
@@ -178,7 +179,8 @@ GEN_open(PNCIO_File *fd)
178179
MPI_Comm_rank(fd->comm, &rank);
179180

180181
#if defined(PNETCDF_PROFILING) && (PNETCDF_PROFILING == 1)
181-
if (rank == 0) { printf("\nxxxx %s at %d: ---- %s\n",__func__,__LINE__,fd->filename); fflush(stdout);}
182+
int world_rank; MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
183+
if (world_rank == 0) { printf("\nxxxx %s at %d: ---- %s\n",__func__,__LINE__,fd->filename); fflush(stdout);}
182184
#endif
183185

184186
old_mask = umask(022);

0 commit comments

Comments
 (0)