[Darshan-commits] [Git][darshan/darshan][dev-stdio] move fclose wrapper to stdio module
Philip Carns
xgitlab at cels.anl.gov
Sun May 1 08:00:46 CDT 2016
Philip Carns pushed to branch dev-stdio at darshan / darshan
Commits:
29b23f7e by Phil Carns at 2016-05-01T09:00:35-04:00
move fclose wrapper to stdio module
- - - - -
7 changed files:
- darshan-runtime/lib/darshan-posix.c
- darshan-runtime/lib/darshan-stdio.c
- darshan-runtime/share/ld-opts/darshan-posix-ld-opts
- darshan-runtime/share/ld-opts/darshan-stdio-ld-opts
- darshan-stdio-log-format.h
- darshan-test/regression/test-cases/stdio-test.sh
- darshan-util/darshan-stdio-logutils.c
Changes:
=====================================
darshan-runtime/lib/darshan-posix.c
=====================================
--- a/darshan-runtime/lib/darshan-posix.c
+++ b/darshan-runtime/lib/darshan-posix.c
@@ -71,7 +71,6 @@ DARSHAN_FORWARD_DECL(mmap64, void*, (void *addr, size_t length, int prot, int fl
DARSHAN_FORWARD_DECL(fsync, int, (int fd));
DARSHAN_FORWARD_DECL(fdatasync, int, (int fd));
DARSHAN_FORWARD_DECL(close, int, (int fd));
-DARSHAN_FORWARD_DECL(fclose, int, (FILE *fp));
DARSHAN_FORWARD_DECL(aio_read, int, (struct aiocb *aiocbp));
DARSHAN_FORWARD_DECL(aio_write, int, (struct aiocb *aiocbp));
DARSHAN_FORWARD_DECL(aio_read64, int, (struct aiocb64 *aiocbp));
@@ -1162,38 +1161,6 @@ int DARSHAN_DECL(close)(int fd)
return(ret);
}
-int DARSHAN_DECL(fclose)(FILE *fp)
-{
- struct posix_file_runtime* file;
- int fd = fileno(fp);
- double tm1, tm2;
- int ret;
-
- MAP_OR_FAIL(fclose);
-
- tm1 = darshan_core_wtime();
- ret = __real_fclose(fp);
- tm2 = darshan_core_wtime();
-
- POSIX_LOCK();
- posix_runtime_initialize();
- file = posix_file_by_fd(fd);
- if(file)
- {
- file->last_byte_written = 0;
- file->last_byte_read = 0;
- file->file_record->fcounters[POSIX_F_CLOSE_TIMESTAMP] =
- darshan_core_wtime();
- DARSHAN_TIMER_INC_NO_OVERLAP(
- file->file_record->fcounters[POSIX_F_META_TIME],
- tm1, tm2, file->last_meta_end);
- posix_file_close_fd(fd);
- }
- POSIX_UNLOCK();
-
- return(ret);
-}
-
int DARSHAN_DECL(aio_read)(struct aiocb *aiocbp)
{
int ret;
=====================================
darshan-runtime/lib/darshan-stdio.c
=====================================
--- a/darshan-runtime/lib/darshan-stdio.c
+++ b/darshan-runtime/lib/darshan-stdio.c
@@ -33,6 +33,7 @@
DARSHAN_FORWARD_DECL(fopen, FILE*, (const char *path, const char *mode));
DARSHAN_FORWARD_DECL(fopen64, FILE*, (const char *path, const char *mode));
+DARSHAN_FORWARD_DECL(fclose, int, (FILE *fp));
/* The stdio_file_runtime structure maintains necessary runtime metadata
* for the STDIO file record (darshan_stdio_record structure, defined in
@@ -201,6 +202,39 @@ FILE* DARSHAN_DECL(fopen64)(const char *path, const char *mode)
return(ret);
}
+int DARSHAN_DECL(fclose)(FILE *fp)
+{
+ struct stdio_file_runtime* file;
+ double tm1, tm2;
+ int ret;
+
+ MAP_OR_FAIL(fclose);
+
+ tm1 = darshan_core_wtime();
+ ret = __real_fclose(fp);
+ tm2 = darshan_core_wtime();
+
+ STDIO_LOCK();
+ stdio_runtime_initialize();
+ file = stdio_file_by_stream(fp);
+ if(file)
+ {
+ file->last_byte_written = 0;
+ file->last_byte_read = 0;
+ if(file->file_record->fcounters[STDIO_F_CLOSE_START_TIMESTAMP] == 0 ||
+ file->file_record->fcounters[STDIO_F_CLOSE_START_TIMESTAMP] > tm1)
+ file->file_record->fcounters[STDIO_F_CLOSE_START_TIMESTAMP] = tm1;
+ file->file_record->fcounters[STDIO_F_CLOSE_END_TIMESTAMP] = tm2;
+ DARSHAN_TIMER_INC_NO_OVERLAP(
+ file->file_record->fcounters[STDIO_F_META_TIME],
+ tm1, tm2, file->last_meta_end);
+ stdio_file_close_stream(fp);
+ }
+ STDIO_UNLOCK();
+
+ return(ret);
+}
+
/**********************************************************
* Internal functions for manipulating STDIO module state *
**********************************************************/
=====================================
darshan-runtime/share/ld-opts/darshan-posix-ld-opts
=====================================
--- a/darshan-runtime/share/ld-opts/darshan-posix-ld-opts
+++ b/darshan-runtime/share/ld-opts/darshan-posix-ld-opts
@@ -30,7 +30,6 @@
--wrap=fsync
--wrap=fdatasync
--wrap=close
---wrap=fclose
--wrap=aio_read
--wrap=aio_write
--wrap=aio_read64
=====================================
darshan-runtime/share/ld-opts/darshan-stdio-ld-opts
=====================================
--- a/darshan-runtime/share/ld-opts/darshan-stdio-ld-opts
+++ b/darshan-runtime/share/ld-opts/darshan-stdio-ld-opts
@@ -1,3 +1,4 @@
--undefined=__wrap_fopen
--wrap=fopen
--wrap=fopen64
+--wrap=fclose
=====================================
darshan-stdio-log-format.h
=====================================
--- a/darshan-stdio-log-format.h
+++ b/darshan-stdio-log-format.h
@@ -66,6 +66,10 @@
X(STDIO_F_OPEN_START_TIMESTAMP) \
/* timestamp of last open completion */\
X(STDIO_F_OPEN_END_TIMESTAMP) \
+ /* timestamp of first close */\
+ X(STDIO_F_CLOSE_START_TIMESTAMP) \
+ /* timestamp of last close completion */\
+ X(STDIO_F_CLOSE_END_TIMESTAMP) \
/* cumulative meta time */\
X(STDIO_F_META_TIME) \
/* end of counters */\
=====================================
darshan-test/regression/test-cases/stdio-test.sh
=====================================
--- a/darshan-test/regression/test-cases/stdio-test.sh
+++ b/darshan-test/regression/test-cases/stdio-test.sh
@@ -57,6 +57,16 @@ if [ ! $(echo "$STDIO_F_META_TIME > 0" | bc -l) ]; then
echo "Error: counter is incorrect" 1>&2
exit 1
fi
+STDIO_F_CLOSE_START_TIMESTAMP=`grep STDIO_F_CLOSE_START_TIMESTAMP $DARSHAN_TMP/${PROG}.darshan.txt |tail -n 1 |cut -f 5`
+if [ ! $(echo "$STDIO_F_CLOSE_START_TIMESTAMP > 0" | bc -l) ]; then
+ echo "Error: counter is incorrect" 1>&2
+ exit 1
+fi
+STDIO_F_CLOSE_END_TIMESTAMP=`grep STDIO_F_CLOSE_END_TIMESTAMP $DARSHAN_TMP/${PROG}.darshan.txt |tail -n 1 |cut -f 5`
+if [ ! $(echo "$STDIO_F_CLOSE_END_TIMESTAMP > 0" | bc -l) ]; then
+ echo "Error: counter is incorrect" 1>&2
+ exit 1
+fi
exit 0
=====================================
darshan-util/darshan-stdio-logutils.c
=====================================
--- a/darshan-util/darshan-stdio-logutils.c
+++ b/darshan-util/darshan-stdio-logutils.c
@@ -146,6 +146,8 @@ static void darshan_log_print_stdio_description()
printf("# STDIO_FOPENS: number of 'fopen' function calls.\n");
printf("# STDIO_F_OPEN_START_TIMESTAMP: timestamp of the first call to function 'fopen'.\n");
printf("# STDIO_F_OPEN_END_TIMESTAMP: timestamp of the completion of the last call to 'fopen'.\n");
+ printf("# STDIO_F_CLOSE_START_TIMESTAMP: timestamp of the first call to function 'fclose'.\n");
+ printf("# STDIO_F_CLOSE_END_TIMESTAMP: timestamp of the completion of the last call to 'fclose'.\n");
printf("# STDIO_F_META_TIME: cumulative time spent in metadata operations.\n");
return;
View it on GitLab: https://xgitlab.cels.anl.gov/darshan/darshan/commit/29b23f7e94967b0638a1ac399a433ce3d46d9690
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/darshan-commits/attachments/20160501/fd4c00ca/attachment.html>
More information about the Darshan-commits
mailing list