Skip to content

Commit cba500f

Browse files
committed
TRACE_IO name of MPI-IO API called
1 parent c695d41 commit cba500f

File tree

11 files changed

+172
-133
lines changed

11 files changed

+172
-133
lines changed

src/drivers/ncmpio/ncmpio_close.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,29 +60,30 @@ ncmpio_free_NC(NC *ncp)
6060
/*----< ncmpio_close_files() >-----------------------------------------------*/
6161
int
6262
ncmpio_close_files(NC *ncp, int doUnlink) {
63+
char *mpi_name;
6364
int mpireturn;
6465

6566
assert(ncp != NULL); /* this should never occur */
6667

6768
if (ncp->independent_fh != MPI_FILE_NULL) {
68-
TRACE_IO(MPI_File_close)(&ncp->independent_fh);
69+
TRACE_IO(MPI_File_close, (&ncp->independent_fh));
6970
if (mpireturn != MPI_SUCCESS)
70-
return ncmpii_error_mpi2nc(mpireturn, "MPI_File_close");
71+
return ncmpii_error_mpi2nc(mpireturn, mpi_name);
7172
}
7273

7374
if (ncp->nprocs > 1 && ncp->collective_fh != MPI_FILE_NULL) {
74-
TRACE_IO(MPI_File_close)(&ncp->collective_fh);
75+
TRACE_IO(MPI_File_close, (&ncp->collective_fh));
7576
if (mpireturn != MPI_SUCCESS)
76-
return ncmpii_error_mpi2nc(mpireturn, "MPI_File_close");
77+
return ncmpii_error_mpi2nc(mpireturn, mpi_name);
7778
}
7879

7980
if (doUnlink) {
8081
/* called from ncmpi_abort, if the file is being created and is still
8182
* in define mode, the file is deleted */
8283
if (ncp->rank == 0) {
83-
TRACE_IO(MPI_File_delete)((char *)ncp->path, ncp->mpiinfo);
84+
TRACE_IO(MPI_File_delete, ((char *)ncp->path, ncp->mpiinfo));
8485
if (mpireturn != MPI_SUCCESS)
85-
return ncmpii_error_mpi2nc(mpireturn, "MPI_File_delete");
86+
return ncmpii_error_mpi2nc(mpireturn, mpi_name);
8687
}
8788
if (ncp->nprocs > 1)
8889
MPI_Barrier(ncp->comm);
@@ -186,31 +187,31 @@ ncmpio_close(void *ncdp)
186187
#else
187188
MPI_File fh;
188189
int mpireturn;
189-
mpireturn = MPI_File_open(MPI_COMM_SELF, ncp->path, MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
190+
TRACE_IO(MPI_File_open, (MPI_COMM_SELF, ncp->path, MPI_MODE_RDWR, MPI_INFO_NULL, &fh));
190191
if (mpireturn == MPI_SUCCESS) {
191192
/* obtain file size */
192193
MPI_Offset *file_size;
193-
mpireturn = MPI_File_get_size(fh, &file_size);
194+
TRACE_IO(MPI_File_get_size, (fh, &file_size));
194195
if (mpireturn != MPI_SUCCESS) {
195-
err = ncmpii_error_mpi2nc(mpireturn,"MPI_File_get_size");
196+
err = ncmpii_error_mpi2nc(mpireturn, mpi_name);
196197
if (status == NC_NOERR) status = err;
197198
}
198199
/* truncate file size to header size, if larger than header */
199200
if (file_size > ncp->xsz) {
200-
mpireturn = MPI_File_set_size(fh, ncp->xsz);
201+
TRACE_IO(MPI_File_set_size, (fh, ncp->xsz));
201202
if (mpireturn != MPI_SUCCESS) {
202-
err = ncmpii_error_mpi2nc(mpireturn,"MPI_File_set_size");
203+
err = ncmpii_error_mpi2nc(mpireturn, mpi_name);
203204
if (status == NC_NOERR) status = err;
204205
}
205206
}
206-
mpireturn = MPI_File_close(&fh);
207+
TRACE_IO(MPI_File_close, (&fh));
207208
if (mpireturn != MPI_SUCCESS) {
208-
err = ncmpii_error_mpi2nc(mpireturn,"MPI_File_close");
209+
err = ncmpii_error_mpi2nc(mpireturn, mpi_name);
209210
if (status == NC_NOERR) status = err;
210211
}
211212
}
212213
else {
213-
err = ncmpii_error_mpi2nc(mpireturn,"MPI_File_open");
214+
err = ncmpii_error_mpi2nc(mpireturn, mpi_name);
214215
if (status == NC_NOERR) status = err;
215216
}
216217
#endif

src/drivers/ncmpio/ncmpio_create.c

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ ncmpio_create(MPI_Comm comm,
4242
MPI_Info user_info, /* user's and env info combined */
4343
void **ncpp)
4444
{
45-
char *env_str, *filename;
45+
char *env_str, *filename, *mpi_name;
4646
int rank, nprocs, mpiomode, err, mpireturn, default_format, file_exist=1;
4747
int use_trunc=1;
4848
MPI_File fh;
@@ -138,25 +138,28 @@ ncmpio_create(MPI_Comm comm,
138138
* expensive
139139
*/
140140
err = unlink(filename);
141-
if (err < 0 && errno != ENOENT) /* ignore ENOENT: file not exist */
141+
if (err < 0 && errno != ENOENT)
142+
/* ignore ENOENT: file not exist */
142143
DEBUG_ASSIGN_ERROR(err, NC_EFILE) /* other error */
143144
else
144145
err = NC_NOERR;
145146
#else
146147
err = NC_NOERR;
147-
TRACE_IO(MPI_File_delete)((char *)path, MPI_INFO_NULL);
148+
TRACE_IO(MPI_File_delete, ((char *)path, MPI_INFO_NULL));
148149
if (mpireturn != MPI_SUCCESS) {
149150
int errorclass;
150151
MPI_Error_class(mpireturn, &errorclass);
151-
if (errorclass != MPI_ERR_NO_SUCH_FILE) /* ignore file not exist */
152-
err = ncmpii_error_mpi2nc(mpireturn, "MPI_File_delete");
152+
if (errorclass != MPI_ERR_NO_SUCH_FILE)
153+
/* ignore file not exist */
154+
err = ncmpii_error_mpi2nc(mpireturn, mpi_name);
153155
}
154156
#endif
155157
}
156158
else { /* file is not a regular file, truncate it to zero size */
157159
#ifdef HAVE_TRUNCATE
158160
err = truncate(filename, 0); /* can be expensive */
159-
if (err < 0 && errno != ENOENT) /* ignore ENOENT: file not exist */
161+
if (err < 0 && errno != ENOENT)
162+
/* ignore ENOENT: file not exist */
160163
DEBUG_ASSIGN_ERROR(err, NC_EFILE) /* other error */
161164
else
162165
err = NC_NOERR;
@@ -174,26 +177,25 @@ ncmpio_create(MPI_Comm comm,
174177
* be expensive.
175178
*/
176179
err = NC_NOERR;
177-
TRACE_IO(MPI_File_open)(MPI_COMM_SELF, (char *)path, MPI_MODE_RDWR,
178-
MPI_INFO_NULL, &fh);
180+
TRACE_IO(MPI_File_open, (MPI_COMM_SELF, (char *)path, MPI_MODE_RDWR, MPI_INFO_NULL, &fh));
179181
if (mpireturn != MPI_SUCCESS) {
180182
int errorclass;
181183
MPI_Error_class(mpireturn, &errorclass);
182-
err = ncmpii_error_mpi2nc(mpireturn, "MPI_File_open");
184+
err = ncmpii_error_mpi2nc(mpireturn, mpi_name);
183185
}
184186
else {
185-
TRACE_IO(MPI_File_set_size)(fh, 0); /* can be expensive */
187+
TRACE_IO(MPI_File_set_size, (fh, 0)); /* can be expensive */
186188
if (mpireturn != MPI_SUCCESS) {
187189
int errorclass;
188190
MPI_Error_class(mpireturn, &errorclass);
189-
err = ncmpii_error_mpi2nc(mpireturn, "MPI_File_set_size");
191+
err = ncmpii_error_mpi2nc(mpireturn, mpi_name);
190192
}
191193
else {
192-
TRACE_IO(MPI_File_close)(&fh);
194+
TRACE_IO(MPI_File_close, (&fh));
193195
if (mpireturn != MPI_SUCCESS) {
194196
int errorclass;
195197
MPI_Error_class(mpireturn, &errorclass);
196-
err = ncmpii_error_mpi2nc(mpireturn, "MPI_File_close");
198+
err = ncmpii_error_mpi2nc(mpireturn, mpi_name);
197199
}
198200
}
199201
}
@@ -208,7 +210,7 @@ ncmpio_create(MPI_Comm comm,
208210
}
209211

210212
/* create file collectively -------------------------------------------- */
211-
TRACE_IO(MPI_File_open)(comm, (char *)path, mpiomode, user_info, &fh);
213+
TRACE_IO(MPI_File_open, (comm, (char *)path, mpiomode, user_info, &fh));
212214
if (mpireturn != MPI_SUCCESS) {
213215
#ifndef HAVE_ACCESS
214216
if (fIsSet(cmode, NC_NOCLOBBER)) {
@@ -226,7 +228,7 @@ ncmpio_create(MPI_Comm comm,
226228
if (errno == EEXIST) DEBUG_RETURN_ERROR(NC_EEXIST)
227229
}
228230
#endif
229-
return ncmpii_error_mpi2nc(mpireturn, "MPI_File_open");
231+
return ncmpii_error_mpi2nc(mpireturn, mpi_name);
230232
/* for NC_NOCLOBBER, MPI_MODE_EXCL was added to mpiomode. If the file
231233
* already exists, MPI-IO should return error class MPI_ERR_FILE_EXISTS
232234
* which PnetCDF will return error code NC_EEXIST. This is checked
@@ -238,9 +240,9 @@ ncmpio_create(MPI_Comm comm,
238240
errno = 0;
239241

240242
/* get the I/O hints used/modified by MPI-IO */
241-
mpireturn = MPI_File_get_info(fh, &info_used);
243+
TRACE_IO(MPI_File_get_info, (fh, &info_used));
242244
if (mpireturn != MPI_SUCCESS)
243-
return ncmpii_error_mpi2nc(mpireturn, "MPI_File_get_info");
245+
return ncmpii_error_mpi2nc(mpireturn, mpi_name);
244246

245247
/* Now the file has been successfully created, allocate/set NC object */
246248

src/drivers/ncmpio/ncmpio_enddef.c

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ move_file_block(NC *ncp,
167167
MPI_Offset from, /* source starting file offset */
168168
MPI_Offset nbytes) /* amount to be moved */
169169
{
170+
char *mpi_name;
170171
int rank, nprocs, mpireturn, err, status=NC_NOERR, do_coll;
171172
void *buf;
172173
size_t num_moves, mv_amnt, p_units;
@@ -239,14 +240,16 @@ move_file_block(NC *ncp,
239240
mpireturn = MPI_SUCCESS;
240241

241242
/* read from file at off_from for amount of chunk_size */
242-
if (do_coll)
243-
TRACE_IO(MPI_File_read_at_all)(fh, off_from, buf, chunk_size,
244-
MPI_BYTE, &mpistatus);
245-
else if (chunk_size > 0)
246-
TRACE_IO(MPI_File_read_at)(fh, off_from, buf, chunk_size,
247-
MPI_BYTE, &mpistatus);
243+
if (do_coll) {
244+
TRACE_IO(MPI_File_read_at_all, (fh, off_from, buf, chunk_size,
245+
MPI_BYTE, &mpistatus));
246+
}
247+
else if (chunk_size > 0) {
248+
TRACE_IO(MPI_File_read_at, (fh, off_from, buf, chunk_size,
249+
MPI_BYTE, &mpistatus));
250+
}
248251
if (mpireturn != MPI_SUCCESS) {
249-
err = ncmpii_error_mpi2nc(mpireturn, "MPI_File_read_at_all");
252+
err = ncmpii_error_mpi2nc(mpireturn, mpi_name);
250253
if (status == NC_NOERR && err == NC_EFILE)
251254
DEBUG_ASSIGN_ERROR(status, NC_EREAD)
252255
get_size = chunk_size;
@@ -282,16 +285,18 @@ move_file_block(NC *ncp,
282285
* call to MPI_Get_count() above returns the actual amount of data read
283286
* from the file, i.e. get_size.
284287
*/
285-
if (do_coll)
286-
TRACE_IO(MPI_File_write_at_all)(fh, off_to, buf,
287-
get_size /* NOT chunk_size */,
288-
MPI_BYTE, &mpistatus);
289-
else if (get_size > 0)
290-
TRACE_IO(MPI_File_write_at)(fh, off_to, buf,
291-
get_size /* NOT chunk_size */,
292-
MPI_BYTE, &mpistatus);
288+
if (do_coll) {
289+
TRACE_IO(MPI_File_write_at_all, (fh, off_to, buf,
290+
get_size /* NOT chunk_size */,
291+
MPI_BYTE, &mpistatus));
292+
}
293+
else if (get_size > 0) {
294+
TRACE_IO(MPI_File_write_at, (fh, off_to, buf,
295+
get_size /* NOT chunk_size */,
296+
MPI_BYTE, &mpistatus));
297+
}
293298
if (mpireturn != MPI_SUCCESS) {
294-
err = ncmpii_error_mpi2nc(mpireturn, "MPI_File_write_at_all");
299+
err = ncmpii_error_mpi2nc(mpireturn, mpi_name);
295300
if (status == NC_NOERR && err == NC_EFILE)
296301
DEBUG_ASSIGN_ERROR(status, NC_EWRITE)
297302
}
@@ -597,6 +602,7 @@ NC_begins(NC *ncp)
597602
static int
598603
write_NC(NC *ncp)
599604
{
605+
char *mpi_name;
600606
int status=NC_NOERR, mpireturn, err, is_coll;
601607
MPI_Offset i, header_wlen, ntimes;
602608
MPI_File fh;
@@ -680,14 +686,16 @@ write_NC(NC *ncp)
680686
buf_ptr = buf;
681687
for (i=0; i<ntimes; i++) {
682688
int bufCount = (int) MIN(remain, NC_MAX_INT);
683-
if (is_coll)
684-
TRACE_IO(MPI_File_write_at_all)(fh, offset, buf_ptr, bufCount,
685-
MPI_BYTE, &mpistatus);
686-
else
687-
TRACE_IO(MPI_File_write_at)(fh, offset, buf_ptr, bufCount,
688-
MPI_BYTE, &mpistatus);
689+
if (is_coll) {
690+
TRACE_IO(MPI_File_write_at_all, (fh, offset, buf_ptr, bufCount,
691+
MPI_BYTE, &mpistatus));
692+
}
693+
else {
694+
TRACE_IO(MPI_File_write_at, (fh, offset, buf_ptr, bufCount,
695+
MPI_BYTE, &mpistatus));
696+
}
689697
if (mpireturn != MPI_SUCCESS) {
690-
err = ncmpii_error_mpi2nc(mpireturn, "MPI_File_write_at");
698+
err = ncmpii_error_mpi2nc(mpireturn, mpi_name);
691699
/* write has failed, which is more serious than inconsistency */
692700
if (err == NC_EFILE) DEBUG_ASSIGN_ERROR(status, NC_EWRITE)
693701
}
@@ -711,9 +719,9 @@ write_NC(NC *ncp)
711719
}
712720
else if (fIsSet(ncp->flags, NC_HCOLL)) {
713721
/* other processes participate the collective call */
714-
for (i=0; i<ntimes; i++)
715-
TRACE_IO(MPI_File_write_at_all)(fh, 0, NULL, 0, MPI_BYTE,
716-
&mpistatus);
722+
for (i=0; i<ntimes; i++) {
723+
TRACE_IO(MPI_File_write_at_all, (fh, 0, NULL, 0, MPI_BYTE, &mpistatus));
724+
}
717725
}
718726

719727
fn_exit:

src/drivers/ncmpio/ncmpio_file_misc.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ dup_NC(const NC *ref)
8181
int
8282
ncmpio_redef(void *ncdp)
8383
{
84+
char *mpi_name;
8485
int err, status=NC_NOERR, mpireturn;
8586
NC *ncp = (NC*)ncdp;
8687

@@ -107,18 +108,18 @@ ncmpio_redef(void *ncdp)
107108
fSet(ncp->flags, NC_MODE_DEF);
108109

109110
/* must reset fileview as header extent may later change in enddef() */
110-
TRACE_IO(MPI_File_set_view)(ncp->collective_fh, 0, MPI_BYTE,
111-
MPI_BYTE, "native", MPI_INFO_NULL);
111+
TRACE_IO(MPI_File_set_view, (ncp->collective_fh, 0, MPI_BYTE,
112+
MPI_BYTE, "native", MPI_INFO_NULL));
112113
if (mpireturn != MPI_SUCCESS) {
113-
err = ncmpii_error_mpi2nc(mpireturn, "MPI_File_set_view");
114+
err = ncmpii_error_mpi2nc(mpireturn, mpi_name);
114115
DEBUG_ASSIGN_ERROR(status, err)
115116
}
116117

117118
if (ncp->independent_fh != MPI_FILE_NULL) {
118-
TRACE_IO(MPI_File_set_view)(ncp->independent_fh, 0, MPI_BYTE,
119-
MPI_BYTE, "native", MPI_INFO_NULL);
119+
TRACE_IO(MPI_File_set_view, (ncp->independent_fh, 0, MPI_BYTE,
120+
MPI_BYTE, "native", MPI_INFO_NULL));
120121
if (mpireturn != MPI_SUCCESS) {
121-
err = ncmpii_error_mpi2nc(mpireturn, "MPI_File_set_view");
122+
err = ncmpii_error_mpi2nc(mpireturn, mpi_name);
122123
DEBUG_ASSIGN_ERROR(status, err)
123124
}
124125
}
@@ -131,6 +132,7 @@ ncmpio_redef(void *ncdp)
131132
int
132133
ncmpio_begin_indep_data(void *ncdp)
133134
{
135+
char *mpi_name;
134136
NC *ncp = (NC*)ncdp;
135137

136138
if (NC_indef(ncp)) /* must not be in define mode */
@@ -158,11 +160,11 @@ ncmpio_begin_indep_data(void *ncdp)
158160
*/
159161
if (ncp->independent_fh == MPI_FILE_NULL) {
160162
int mpireturn;
161-
TRACE_IO(MPI_File_open)(MPI_COMM_SELF, ncp->path,
162-
ncp->mpiomode, ncp->mpiinfo,
163-
&ncp->independent_fh);
163+
TRACE_IO(MPI_File_open, (MPI_COMM_SELF, ncp->path,
164+
ncp->mpiomode, ncp->mpiinfo,
165+
&ncp->independent_fh));
164166
if (mpireturn != MPI_SUCCESS)
165-
return ncmpii_error_mpi2nc(mpireturn, "MPI_File_open");
167+
return ncmpii_error_mpi2nc(mpireturn, mpi_name);
166168
}
167169
return NC_NOERR;
168170
}
@@ -442,11 +444,12 @@ int
442444
ncmpi_delete(const char *filename,
443445
MPI_Info info)
444446
{
447+
char *mpi_name;
445448
int err=NC_NOERR, mpireturn;
446449

447-
TRACE_IO(MPI_File_delete)((char*)filename, info);
450+
TRACE_IO(MPI_File_delete, ((char*)filename, info));
448451
if (mpireturn != MPI_SUCCESS)
449-
err = ncmpii_error_mpi2nc(mpireturn, "MPI_File_delete");
452+
err = ncmpii_error_mpi2nc(mpireturn, mpi_name);
450453
return err;
451454
}
452455

0 commit comments

Comments
 (0)