Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Cristian Simarro
darshan
Commits
0448ed3c
Commit
0448ed3c
authored
Mar 25, 2015
by
Shane Snyder
Browse files
code cleanup + posix read/write wrappers
parent
165a27fc
Changes
9
Hide whitespace changes
Inline
Side-by-side
darshan-posix-log-format.h
View file @
0448ed3c
...
...
@@ -8,121 +8,130 @@
#include "darshan-log-format.h"
/* TODO: DARSHAN_* OR CP_* */
enum
darshan_posix_indices
{
CP_POSIX_READS
,
/* count of posix reads */
CP_POSIX_WRITES
,
/* count of posix writes */
CP_POSIX_OPENS
,
/* count of posix opens */
CP_POSIX_SEEKS
,
/* count of posix seeks */
CP_POSIX_STATS
,
/* count of posix stat/lstat/fstats */
CP_POSIX_MMAPS
,
/* count of posix mmaps */
CP_POSIX_FREADS
,
CP_POSIX_FWRITES
,
CP_POSIX_FOPENS
,
CP_POSIX_FSEEKS
,
CP_POSIX_FSYNCS
,
CP_POSIX_FDSYNCS
,
CP_MODE
,
/* mode of file */
CP_BYTES_READ
,
/* total bytes read */
CP_BYTES_WRITTEN
,
/* total bytes written */
CP_MAX_BYTE_READ
,
/* highest offset byte read */
CP_MAX_BYTE_WRITTEN
,
/* highest offset byte written */
CP_CONSEC_READS
,
/* count of consecutive reads */
CP_CONSEC_WRITES
,
/* count of consecutive writes */
CP_SEQ_READS
,
/* count of sequential reads */
CP_SEQ_WRITES
,
/* count of sequential writes */
CP_RW_SWITCHES
,
/* number of times switched between read and write */
CP_MEM_NOT_ALIGNED
,
/* count of accesses not mem aligned */
CP_MEM_ALIGNMENT
,
/* mem alignment in bytes */
CP_FILE_NOT_ALIGNED
,
/* count of accesses not file aligned */
CP_FILE_ALIGNMENT
,
/* file alignment in bytes */
CP_MAX_READ_TIME_SIZE
,
CP_MAX_WRITE_TIME_SIZE
,
POSIX_OPENS
,
/* count of posix opens */
POSIX_READS
,
/* count of posix reads */
POSIX_WRITES
,
/* count of posix writes */
#if 0
POSIX_SEEKS, /* count of posix seeks */
POSIX_STATS, /* count of posix stat/lstat/fstats */
POSIX_MMAPS, /* count of posix mmaps */
#endif
POSIX_FOPENS
,
POSIX_FREADS
,
POSIX_FWRITES
,
#if 0
POSIX_FSEEKS,
POSIX_FSYNCS,
POSIX_FDSYNCS,
#endif
POSIX_MODE
,
/* mode of file */
#if 0
POSIX_BYTES_READ, /* total bytes read */
POSIX_BYTES_WRITTEN, /* total bytes written */
POSIX_MAX_BYTE_READ, /* highest offset byte read */
POSIX_MAX_BYTE_WRITTEN, /* highest offset byte written */
CONSEC_READS, /* count of consecutive reads */
CONSEC_WRITES, /* count of consecutive writes */
SEQ_READS, /* count of sequential reads */
SEQ_WRITES, /* count of sequential writes */
RW_SWITCHES, /* number of times switched between read and write */
MEM_NOT_ALIGNED, /* count of accesses not mem aligned */
MEM_ALIGNMENT, /* mem alignment in bytes */
FILE_NOT_ALIGNED, /* count of accesses not file aligned */
FILE_ALIGNMENT, /* file alignment in bytes */
#endif
POSIX_MAX_READ_TIME_SIZE
,
POSIX_MAX_WRITE_TIME_SIZE
,
#if 0
/* buckets */
CP_
SIZE_READ_0_100
,
/* count of posix read size ranges */
CP_
SIZE_READ_100_1K
,
CP_
SIZE_READ_1K_10K
,
CP_
SIZE_READ_10K_100K
,
CP_
SIZE_READ_100K_1M
,
CP_
SIZE_READ_1M_4M
,
CP_
SIZE_READ_4M_10M
,
CP_
SIZE_READ_10M_100M
,
CP_
SIZE_READ_100M_1G
,
CP_
SIZE_READ_1G_PLUS
,
SIZE_READ_0_100, /* count of posix read size ranges */
SIZE_READ_100_1K,
SIZE_READ_1K_10K,
SIZE_READ_10K_100K,
SIZE_READ_100K_1M,
SIZE_READ_1M_4M,
SIZE_READ_4M_10M,
SIZE_READ_10M_100M,
SIZE_READ_100M_1G,
SIZE_READ_1G_PLUS,
/* buckets */
CP_
SIZE_WRITE_0_100
,
/* count of posix write size ranges */
CP_
SIZE_WRITE_100_1K
,
CP_
SIZE_WRITE_1K_10K
,
CP_
SIZE_WRITE_10K_100K
,
CP_
SIZE_WRITE_100K_1M
,
CP_
SIZE_WRITE_1M_4M
,
CP_
SIZE_WRITE_4M_10M
,
CP_
SIZE_WRITE_10M_100M
,
CP_
SIZE_WRITE_100M_1G
,
CP_
SIZE_WRITE_1G_PLUS
,
SIZE_WRITE_0_100, /* count of posix write size ranges */
SIZE_WRITE_100_1K,
SIZE_WRITE_1K_10K,
SIZE_WRITE_10K_100K,
SIZE_WRITE_100K_1M,
SIZE_WRITE_1M_4M,
SIZE_WRITE_4M_10M,
SIZE_WRITE_10M_100M,
SIZE_WRITE_100M_1G,
SIZE_WRITE_1G_PLUS,
/* counters */
CP_STRIDE1_STRIDE
,
/* the four most frequently appearing strides */
CP_STRIDE2_STRIDE
,
CP_STRIDE3_STRIDE
,
CP_STRIDE4_STRIDE
,
CP_STRIDE1_COUNT
,
/* count of each of the most frequent strides */
CP_STRIDE2_COUNT
,
CP_STRIDE3_COUNT
,
CP_STRIDE4_COUNT
,
CP_ACCESS1_ACCESS
,
/* the four most frequently appearing access sizes */
CP_ACCESS2_ACCESS
,
CP_ACCESS3_ACCESS
,
CP_ACCESS4_ACCESS
,
CP_ACCESS1_COUNT
,
/* count of each of the most frequent access sizes */
CP_ACCESS2_COUNT
,
CP_ACCESS3_COUNT
,
CP_ACCESS4_COUNT
,
CP_DEVICE
,
/* device id reported by stat */
CP_SIZE_AT_OPEN
,
CP_FASTEST_RANK
,
CP_FASTEST_RANK_BYTES
,
CP_SLOWEST_RANK
,
CP_SLOWEST_RANK_BYTES
,
STRIDE1_STRIDE, /* the four most frequently appearing strides */
STRIDE2_STRIDE,
STRIDE3_STRIDE,
STRIDE4_STRIDE,
STRIDE1_COUNT, /* count of each of the most frequent strides */
STRIDE2_COUNT,
STRIDE3_COUNT,
STRIDE4_COUNT,
ACCESS1_ACCESS, /* the four most frequently appearing access sizes */
ACCESS2_ACCESS,
ACCESS3_ACCESS,
ACCESS4_ACCESS,
ACCESS1_COUNT, /* count of each of the most frequent access sizes */
ACCESS2_COUNT,
ACCESS3_COUNT,
ACCESS4_COUNT,
DEVICE, /* device id reported by stat */
SIZE_AT_OPEN,
FASTEST_RANK,
FASTEST_RANK_BYTES,
SLOWEST_RANK,
SLOWEST_RANK_BYTES,
#endif
C
P_NUM_INDICES
,
P
OSIX
_NUM_INDICES
,
};
/* floating point statistics */
enum
darshan_
f_
posix_indices
enum
darshan_posix_
f_
indices
{
/* NOTE: adjust cp_normalize_timestamps() function if any TIMESTAMPS are
* added or modified in this list
*/
CP_F_OPEN_TIMESTAMP
=
0
,
/* timestamp of first open */
CP_F_READ_START_TIMESTAMP
,
/* timestamp of first read */
CP_F_WRITE_START_TIMESTAMP
,
/* timestamp of first write */
CP_F_CLOSE_TIMESTAMP
,
/* timestamp of last close */
CP_F_READ_END_TIMESTAMP
,
/* timestamp of last read */
CP_F_WRITE_END_TIMESTAMP
,
/* timestamp of last write */
CP_F_POSIX_READ_TIME
,
/* cumulative posix read time */
CP_F_POSIX_WRITE_TIME
,
/* cumulative posix write time */
CP_F_POSIX_META_TIME
,
/* cumulative posix meta time */
CP_F_MAX_READ_TIME
,
CP_F_MAX_WRITE_TIME
,
POSIX_F_OPEN_TIMESTAMP
=
0
,
/* timestamp of first open */
POSIX_F_READ_START_TIMESTAMP
,
/* timestamp of first read */
POSIX_F_WRITE_START_TIMESTAMP
,
/* timestamp of first write */
POSIX_F_READ_END_TIMESTAMP
,
/* timestamp of last read */
POSIX_F_WRITE_END_TIMESTAMP
,
/* timestamp of last write */
POSIX_F_CLOSE_TIMESTAMP
,
/* timestamp of last close */
POSIX_F_READ_TIME
,
/* cumulative posix read time */
POSIX_F_WRITE_TIME
,
/* cumulative posix write time */
POSIX_F_META_TIME
,
/* cumulative posix meta time */
POSIX_F_MAX_READ_TIME
,
POSIX_F_MAX_WRITE_TIME
,
#if 0
/* Total I/O and meta time consumed by fastest and slowest ranks,
* reported in either MPI or POSIX time depending on how the file
* was accessed.
*/
CP_F_FASTEST_RANK_TIME
,
CP_F_SLOWEST_RANK_TIME
,
CP_F_VARIANCE_RANK_TIME
,
CP_F_VARIANCE_RANK_BYTES
,
F_FASTEST_RANK_TIME,
F_SLOWEST_RANK_TIME,
F_VARIANCE_RANK_TIME,
F_VARIANCE_RANK_BYTES,
#endif
C
P_F_NUM_INDICES
,
P
OSIX
_F_NUM_INDICES
,
};
struct
darshan_posix_file
{
darshan_record_id
f_id
;
int64_t
rank
;
int64_t
counters
[
C
P_NUM_INDICES
];
double
fcounters
[
C
P_F_NUM_INDICES
];
int64_t
counters
[
P
OSIX
_NUM_INDICES
];
double
fcounters
[
P
OSIX
_F_NUM_INDICES
];
};
#endif
/* __DARSHAN_POSIX_LOG_FORMAT_H */
darshan-runtime/configure
View file @
0448ed3c
...
...
@@ -4079,10 +4079,10 @@ fi
done
# libc functions wrapped by darshan
#CP_WRAPPERS="-Wl,-u,MPI_Init,-u,MPI_Wtime,-wrap,write,-wrap,open,-wrap,creat,-wrap,creat64,-wrap,open64,-wrap,close,-wrap,read,-wrap,lseek,-wrap,lseek64,-wrap,pread,-wrap,pwrite,-wrap,readv,-wrap,writev,-wrap,__xstat,-wrap,__lxstat,-wrap,__fxstat,-wrap,__xstat64,-wrap,__lxstat64,-wrap,__fxstat64,-wrap,mmap,-wrap,mmap64,-wrap,fopen,-wrap,fclose,-wrap,fread,-wrap,fwrite,-wrap,fseek,-wrap,fopen64,-wrap,pread64,-wrap,pwrite64,-wrap,fsync,-wrap,fdatasync,-wrap,ncmpi_create,-wrap,ncmpi_open,-wrap,ncmpi_close,-wrap,H5Fcreate,-wrap,H5Fopen,-wrap,H5Fclose,-wrap,aio_write,-wrap,aio_write64,-wrap,aio_read,-wrap,aio_read64,-wrap,lio_listio,-wrap,lio_listio64,-wrap,aio_return,-wrap,aio_return64,-wrap,mkstemp,-wrap,mkostemp,-wrap,mkstemps,-wrap,mkostemps"
CP_WRAPPERS
=
"-Wl,-u,MPI_Init,-u,MPI_Wtime,-wrap,open,-wrap,open64,-wrap,close"
# libc functions wrapped by darshan
CP_WRAPPERS
=
"-Wl,-u,MPI_Init,-u,MPI_Wtime,-wrap,open,-wrap,open64,-wrap,creat,-wrap,creat64,-wrap,read,-wrap,write,-wrap,pread,-wrap,pwrite,-wrap,pread64,-wrap,pwrite64,-wrap,readv,-wrap,writev,-wrap,close"
# We need to know the value of the $libdir and $bindir variables so that
# we can reference the correct path in the darshan compiler wrappers.
...
...
darshan-runtime/configure.in
View file @
0448ed3c
...
...
@@ -187,10 +187,10 @@ CFLAGS="$old_cflags"
AC_CHECK_HEADERS(mntent.h sys/mount.h)
# libc functions wrapped by darshan
#CP_WRAPPERS="-Wl,-u,MPI_Init,-u,MPI_Wtime,-wrap,write,-wrap,open,-wrap,creat,-wrap,creat64,-wrap,open64,-wrap,close,-wrap,read,-wrap,lseek,-wrap,lseek64,-wrap,pread,-wrap,pwrite,-wrap,readv,-wrap,writev,-wrap,__xstat,-wrap,__lxstat,-wrap,__fxstat,-wrap,__xstat64,-wrap,__lxstat64,-wrap,__fxstat64,-wrap,mmap,-wrap,mmap64,-wrap,fopen,-wrap,fclose,-wrap,fread,-wrap,fwrite,-wrap,fseek,-wrap,fopen64,-wrap,pread64,-wrap,pwrite64,-wrap,fsync,-wrap,fdatasync,-wrap,ncmpi_create,-wrap,ncmpi_open,-wrap,ncmpi_close,-wrap,H5Fcreate,-wrap,H5Fopen,-wrap,H5Fclose,-wrap,aio_write,-wrap,aio_write64,-wrap,aio_read,-wrap,aio_read64,-wrap,lio_listio,-wrap,lio_listio64,-wrap,aio_return,-wrap,aio_return64,-wrap,mkstemp,-wrap,mkostemp,-wrap,mkstemps,-wrap,mkostemps"
CP_WRAPPERS="-Wl,-u,MPI_Init,-u,MPI_Wtime,-wrap,open,-wrap,open64,-wrap,close"
# libc functions wrapped by darshan
CP_WRAPPERS="-Wl,-u,MPI_Init,-u,MPI_Wtime,-wrap,open,-wrap,open64,-wrap,creat,-wrap,creat64,-wrap,read,-wrap,write,-wrap,pread,-wrap,pwrite,-wrap,pread64,-wrap,pwrite64,-wrap,readv,-wrap,writev,-wrap,close"
# We need to know the value of the $libdir and $bindir variables so that
# we can reference the correct path in the darshan compiler wrappers.
...
...
darshan-runtime/darshan-config.in
View file @
0448ed3c
...
...
@@ -11,7 +11,6 @@ DARSHAN_LD_FLAGS="@LDFLAGS@"
# dependencies on PnetCDF and HDF5 symbols (if the app used a library which
# in turn used one of those HLLs).
# TODO: extra -lmpi in POST_LD_FLAGS -- link ordering issue
PRE_LD_FLAGS
=
"-L
$DARSHAN_LIB_PATH
$DARSHAN_LD_FLAGS
-ldarshan -lz
$CP_WRAPPERS
"
POST_LD_FLAGS
=
"-L
$DARSHAN_LIB_PATH
-ldarshan -lz -lrt -lpthread"
...
...
darshan-runtime/lib/darshan-core.c
View file @
0448ed3c
...
...
@@ -27,8 +27,8 @@
#include "uthash.h"
#include "darshan-core.h"
/* TODO is __progname_full needed here */
extern
char
*
__progname
;
extern
char
*
__progname_full
;
/* internal variable delcarations */
static
struct
darshan_core_runtime
*
darshan_core
=
NULL
;
...
...
@@ -193,7 +193,7 @@ static void darshan_core_initialize(int argc, char **argv)
if
(
argc
==
0
)
{
chars_left
=
DARSHAN_EXE_LEN
-
strlen
(
darshan_core
->
exe
);
strncat
(
darshan_core
->
exe
,
__progname
,
chars_left
);
strncat
(
darshan_core
->
exe
,
__progname
_full
,
chars_left
);
chars_left
=
DARSHAN_EXE_LEN
-
strlen
(
darshan_core
->
exe
);
strncat
(
darshan_core
->
exe
,
" <unknown args>"
,
chars_left
);
}
...
...
darshan-runtime/lib/darshan-posix.c
View file @
0448ed3c
...
...
@@ -69,31 +69,46 @@ typedef int64_t off64_t;
#endif
/* TODO: more libc, fgetc, etc etc etc. */
DARSHAN_FORWARD_DECL
(
open
,
int
,
(
const
char
*
path
,
int
flags
,
...));
DARSHAN_FORWARD_DECL
(
open64
,
int
,
(
const
char
*
path
,
int
flags
,
...));
DARSHAN_FORWARD_DECL
(
creat
,
int
,
(
const
char
*
path
,
mode_t
mode
));
DARSHAN_FORWARD_DECL
(
creat64
,
int
,
(
const
char
*
path
,
mode_t
mode
));
DARSHAN_FORWARD_DECL
(
read
,
ssize_t
,
(
int
fd
,
void
*
buf
,
size_t
count
));
DARSHAN_FORWARD_DECL
(
write
,
ssize_t
,
(
int
fd
,
const
void
*
buf
,
size_t
count
));
DARSHAN_FORWARD_DECL
(
pread
,
ssize_t
,
(
int
fd
,
void
*
buf
,
size_t
count
,
off_t
offset
));
DARSHAN_FORWARD_DECL
(
pwrite
,
ssize_t
,
(
int
fd
,
const
void
*
buf
,
size_t
count
,
off_t
offset
));
DARSHAN_FORWARD_DECL
(
pread64
,
ssize_t
,
(
int
fd
,
void
*
buf
,
size_t
count
,
off64_t
offset
));
DARSHAN_FORWARD_DECL
(
pwrite64
,
ssize_t
,
(
int
fd
,
const
void
*
buf
,
size_t
count
,
off64_t
offset
));
DARSHAN_FORWARD_DECL
(
readv
,
ssize_t
,
(
int
fd
,
const
struct
iovec
*
iov
,
int
iovcnt
));
DARSHAN_FORWARD_DECL
(
writev
,
ssize_t
,
(
int
fd
,
const
struct
iovec
*
iov
,
int
iovcnt
));
DARSHAN_FORWARD_DECL
(
close
,
int
,
(
int
fd
));
struct
posix_runtime
_file
struct
posix_
file_
runtime
{
struct
darshan_posix_file
*
file_record
;
double
last_meta_end
;
double
last_read_end
;
double
last_write_end
;
UT_hash_handle
hlink
;
};
struct
posix_runtime_
file_
ref
struct
posix_
file_
runtime_ref
{
struct
posix_runtime
_file
*
file
;
struct
posix_
file_
runtime
*
file
;
int
fd
;
UT_hash_handle
hlink
;
};
struct
posix_runtime
{
struct
posix_runtime
_file
*
file_runtime_array
;
struct
posix_
file_
runtime
*
file_runtime_array
;
struct
darshan_posix_file
*
file_record_array
;
int
file_array_size
;
int
file_array_ndx
;
struct
posix_runtime
_file
*
file_hash
;
struct
posix_runtime_
file_
ref
*
fd_hash
;
struct
posix_
file_
runtime
*
file_hash
;
struct
posix_
file_
runtime_ref
*
fd_hash
;
void
*
red_buf
;
int
shared_rec_count
;
};
...
...
@@ -120,9 +135,9 @@ NULL
};
static
void
posix_runtime_initialize
(
void
);
static
struct
posix_runtime
_file
*
posix_file_by_name
(
const
char
*
name
);
static
struct
posix_runtime
_file
*
posix_file_by_name_setfd
(
const
char
*
name
,
int
fd
);
static
struct
posix_runtime
_file
*
posix_file_by_fd
(
int
fd
);
static
struct
posix_
file_
runtime
*
posix_file_by_name
(
const
char
*
name
);
static
struct
posix_
file_
runtime
*
posix_file_by_name_setfd
(
const
char
*
name
,
int
fd
);
static
struct
posix_
file_
runtime
*
posix_file_by_fd
(
int
fd
);
static
void
posix_file_close_fd
(
int
fd
);
static
void
posix_disable_instrumentation
(
void
);
...
...
@@ -175,7 +190,7 @@ static void posix_shutdown(void);
} while(0)
#define POSIX_RECORD_OPEN(__ret, __path, __mode, __stream_flag, __tm1, __tm2) do { \
struct posix_runtime
_file
* file; \
struct posix_
file_
runtime* file; \
char* exclude; \
int tmp_index = 0; \
if(__ret < 0) break; \
...
...
@@ -187,15 +202,120 @@ static void posix_shutdown(void);
if(exclude) break; \
file = posix_file_by_name_setfd(__path, __ret); \
if(!file) break; \
/* CP_STAT_FILE(file, __path, __ret); */
\
file->file_record->rank = my_rank; \
if(__mode) \
POSIX_SET(file, CP_MODE, __mode); \
POSIX_SET(file, POSIX_MODE, __mode); \
/* file->offset = 0; */
\
/* file->last_byte_written = 0; */
\
/* file->last_byte_read = 0; */
\
if(__stream_flag)\
POSIX_INC(file, CP_POSIX_FOPENS, 1); \
POSIX_INC(file, POSIX_FOPENS, 1); \
else \
POSIX_INC(file, POSIX_OPENS, 1); \
if(POSIX_F_VALUE(file, POSIX_F_OPEN_TIMESTAMP) == 0) \
POSIX_F_SET(file, POSIX_F_OPEN_TIMESTAMP, __tm1); \
POSIX_F_INC_NO_OVERLAP(file, __tm1, __tm2, file->last_meta_end, POSIX_F_META_TIME); \
} while(0)
#define POSIX_RECORD_READ(__ret, __fd, __pread_flag, __pread_offset, __aligned, __stream_flag, __tm1, __tm2) do{ \
/* size_t stride; \
int64_t this_offset; */
\
struct posix_file_runtime* file; \
/* int64_t file_alignment; */
\
double __elapsed = __tm2-__tm1; \
if(__ret < 0) break; \
file = posix_file_by_fd(__fd); \
if(!file) break; \
/* if(__pread_flag) \
this_offset = __pread_offset; \
else \
this_offset = file->offset; \
file_alignment = CP_VALUE(file, CP_FILE_ALIGNMENT); \
if(this_offset > file->last_byte_read) \
CP_INC(file, CP_SEQ_READS, 1); \
if(this_offset == (file->last_byte_read + 1)) \
CP_INC(file, CP_CONSEC_READS, 1); \
if(this_offset > 0 && this_offset > file->last_byte_read \
&& file->last_byte_read != 0) \
stride = this_offset - file->last_byte_read - 1; \
else \
stride = 0; \
file->last_byte_read = this_offset + __ret - 1; \
file->offset = this_offset + __ret; \
CP_MAX(file, CP_MAX_BYTE_READ, (this_offset + __ret -1)); \
CP_INC(file, CP_BYTES_READ, __ret); */
\
if(__stream_flag)\
POSIX_INC(file, POSIX_FREADS, 1); \
else\
POSIX_INC(file, POSIX_READS, 1); \
/* CP_BUCKET_INC(file, CP_SIZE_READ_0_100, __ret); \
cp_access_counter(file, stride, CP_COUNTER_STRIDE); \
if(!__aligned) \
CP_INC(file, CP_MEM_NOT_ALIGNED, 1); \
if(file_alignment > 0 && (this_offset % file_alignment) != 0) \
CP_INC(file, CP_FILE_NOT_ALIGNED, 1); \
cp_access_counter(file, __ret, CP_COUNTER_ACCESS); \
if(file->last_io_type == CP_WRITE) \
CP_INC(file, CP_RW_SWITCHES, 1); \
file->last_io_type = CP_READ; */
\
POSIX_F_INC_NO_OVERLAP(file, __tm1, __tm2, file->last_read_end, POSIX_F_READ_TIME); \
if(POSIX_F_VALUE(file, POSIX_F_READ_START_TIMESTAMP) == 0) \
POSIX_F_SET(file, POSIX_F_READ_START_TIMESTAMP, __tm1); \
POSIX_F_SET(file, POSIX_F_READ_END_TIMESTAMP, __tm2); \
if(POSIX_F_VALUE(file, POSIX_F_MAX_READ_TIME) < __elapsed){ \
POSIX_F_SET(file, POSIX_F_MAX_READ_TIME, __elapsed); \
POSIX_SET(file, POSIX_MAX_READ_TIME_SIZE, __ret); } \
} while(0)
#define POSIX_RECORD_WRITE(__ret, __fd, __pwrite_flag, __pwrite_offset, __aligned, __stream_flag, __tm1, __tm2) do{ \
/* size_t stride; \
int64_t this_offset; */
\
struct posix_file_runtime* file; \
/* int64_t file_alignment; */
\
double __elapsed = __tm2-__tm1; \
if(__ret < 0) break; \
file = posix_file_by_fd(__fd); \
if(!file) break; \
/* if(__pwrite_flag) \
this_offset = __pwrite_offset; \
else \
this_offset = file->offset; \
file_alignment = CP_VALUE(file, CP_FILE_ALIGNMENT); \
if(this_offset > file->last_byte_written) \
CP_INC(file, CP_SEQ_WRITES, 1); \
if(this_offset == (file->last_byte_written + 1)) \
CP_INC(file, CP_CONSEC_WRITES, 1); \
if(this_offset > 0 && this_offset > file->last_byte_written \
&& file->last_byte_written != 0) \
stride = this_offset - file->last_byte_written - 1; \
else \
POSIX_INC(file, CP_POSIX_OPENS, 1); \
if(POSIX_F_VALUE(file, CP_F_OPEN_TIMESTAMP) == 0) \
POSIX_F_SET(file, CP_F_OPEN_TIMESTAMP, __tm1); \
stride = 0; \
file->last_byte_written = this_offset + __ret - 1; \
file->offset = this_offset + __ret; \
CP_MAX(file, CP_MAX_BYTE_WRITTEN, (this_offset + __ret -1)); \
CP_INC(file, CP_BYTES_WRITTEN, __ret); */
\
if(__stream_flag) \
POSIX_INC(file, POSIX_FWRITES, 1); \
else \
POSIX_INC(file, POSIX_WRITES, 1); \
/* CP_BUCKET_INC(file, CP_SIZE_WRITE_0_100, __ret); \
cp_access_counter(file, stride, CP_COUNTER_STRIDE); \
if(!__aligned) \
CP_INC(file, CP_MEM_NOT_ALIGNED, 1); \
if(file_alignment > 0 && (this_offset % file_alignment) != 0) \
CP_INC(file, CP_FILE_NOT_ALIGNED, 1); \
cp_access_counter(file, __ret, CP_COUNTER_ACCESS); \
if(file->last_io_type == CP_READ) \
CP_INC(file, CP_RW_SWITCHES, 1); \
file->last_io_type = CP_WRITE; */
\
POSIX_F_INC_NO_OVERLAP(file, __tm1, __tm2, file->last_write_end, POSIX_F_WRITE_TIME); \
if(POSIX_F_VALUE(file, POSIX_F_WRITE_START_TIMESTAMP) == 0) \
POSIX_F_SET(file, POSIX_F_WRITE_START_TIMESTAMP, __tm1); \
POSIX_F_SET(file, POSIX_F_WRITE_END_TIMESTAMP, __tm2); \
if(POSIX_F_VALUE(file, POSIX_F_MAX_WRITE_TIME) < __elapsed){ \
POSIX_F_SET(file, POSIX_F_MAX_WRITE_TIME, __elapsed); \
POSIX_SET(file, POSIX_MAX_WRITE_TIME_SIZE, __ret); } \
} while(0)
int
DARSHAN_DECL
(
open
)(
const
char
*
path
,
int
flags
,
...)
...
...
@@ -226,9 +346,7 @@ int DARSHAN_DECL(open)(const char *path, int flags, ...)
POSIX_LOCK
();
posix_runtime_initialize
();
POSIX_RECORD_OPEN
(
ret
,
path
,
mode
,
0
,
tm1
,
tm2
);
POSIX_UNLOCK
();
return
(
ret
);
...
...
@@ -262,16 +380,239 @@ int DARSHAN_DECL(open64)(const char *path, int flags, ...)
POSIX_LOCK
();
posix_runtime_initialize
();
POSIX_RECORD_OPEN
(
ret
,
path
,
mode
,
0
,
tm1
,
tm2
);
POSIX_UNLOCK
();
return
(
ret
);
}
int
DARSHAN_DECL
(
creat
)(
const
char
*
path
,
mode_t
mode
)
{
int
ret
;
double
tm1
,
tm2
;
MAP_OR_FAIL
(
creat
);
tm1
=
darshan_core_wtime
();
ret
=
__real_creat
(
path
,
mode
);
tm2
=
darshan_core_wtime
();
POSIX_LOCK
();
posix_runtime_initialize
();
POSIX_RECORD_OPEN
(
ret
,
path
,
mode
,
0
,
tm1
,
tm2
);
POSIX_UNLOCK
();
return
(
ret
);
}
int
DARSHAN_DECL
(
creat64
)(
const
char
*
path
,
mode_t
mode
)
{
int
ret
;
double
tm1
,
tm2
;
MAP_OR_FAIL
(
creat64
);
tm1
=
darshan_core_wtime
();
ret
=
__real_creat64
(
path
,
mode
);
tm2
=
darshan_core_wtime
();
POSIX_LOCK
();
posix_runtime_initialize
();
POSIX_RECORD_OPEN
(
ret
,
path
,
mode
,
0
,
tm1
,
tm2
);
POSIX_UNLOCK
();
return
(
ret
);
}
ssize_t
DARSHAN_DECL
(
read
)(
int
fd
,
void
*
buf
,
size_t
count
)
{
ssize_t
ret
;
int
aligned_flag
=
0
;
double
tm1
,
tm2
;
MAP_OR_FAIL
(
write
);
/* if((unsigned long)buf % darshan_mem_alignment == 0) aligned_flag = 1; */
tm1
=
darshan_core_wtime
();
ret
=
__real_read
(
fd
,
buf
,
count
);
tm2
=
darshan_core_wtime
();
POSIX_LOCK
();
posix_runtime_initialize
();
POSIX_RECORD_READ
(
ret
,
fd
,
0
,
0
,
aligned_flag
,
0
,
tm1
,
tm2
);
POSIX_UNLOCK
();
return
(
ret
);
}
ssize_t
DARSHAN_DECL
(
write
)(
int
fd
,
const
void
*
buf
,
size_t
count
)
{
ssize_t
ret
;
int
aligned_flag
=
0
;
double
tm1
,
tm2
;
MAP_OR_FAIL
(
write
);
/* if((unsigned long)buf % darshan_mem_alignment == 0) aligned_flag = 1; */
tm1
=
darshan_core_wtime
();
ret
=
__real_write
(
fd
,
buf
,
count
);
tm2
=
darshan_core_wtime
();
POSIX_LOCK
();
posix_runtime_initialize
();
POSIX_RECORD_WRITE
(
ret
,
fd
,
0
,
0
,
aligned_flag
,
0
,
tm1
,
tm2
);
POSIX_UNLOCK
();
return
(
ret
);
}
ssize_t
DARSHAN_DECL
(
pread
)(
int
fd
,
void
*
buf
,
size_t
count
,
off_t
offset
)
{
ssize_t
ret
;
int
aligned_flag
=
0
;
double
tm1
,
tm2
;
MAP_OR_FAIL
(
pread
);
/* if((unsigned long)buf % darshan_mem_alignment == 0) aligned_flag = 1; */
tm1
=
darshan_core_wtime
();
ret
=
__real_pread
(
fd
,
buf
,
count
,
offset
);
tm2
=
darshan_core_wtime
();
POSIX_LOCK
();
posix_runtime_initialize
();
POSIX_RECORD_READ
(
ret
,
fd
,
1
,
offset
,
aligned_flag
,
0
,
tm1
,
tm2
);
POSIX_UNLOCK
();
return
(
ret
);
}
ssize_t
DARSHAN_DECL
(
pwrite
)(
int
fd
,
const
void
*
buf
,
size_t
count
,
off_t
offset
)
{
ssize_t
ret
;
int
aligned_flag
=
0
;
double
tm1
,
tm2
;
MAP_OR_FAIL
(
pwrite
);
/* if((unsigned long)buf % darshan_mem_alignment == 0) aligned_flag = 1; */
tm1
=
darshan_core_wtime
();
ret
=
__real_pwrite
(
fd
,
buf
,
count
,
offset
);
tm2
=
darshan_core_wtime
();
POSIX_LOCK
();
posix_runtime_initialize
();
POSIX_RECORD_WRITE
(
ret
,
fd
,
1
,
offset
,
aligned_flag
,
0
,
tm1
,
tm2
);
POSIX_UNLOCK
();
return
(
ret
);
}
ssize_t
DARSHAN_DECL
(
pread64
)(
int
fd
,
void
*
buf
,
size_t
count
,
off64_t
offset
)
{