Commit 9a4acb38 authored by Philip Carns's avatar Philip Carns

bug fix: don't double-count overlapping read/write/meta operation times


git-svn-id: https://svn.mcs.anl.gov/repos/darshan/trunk@564 3b7491f3-a168-0410-bf4b-c445ed680a29
parent b59326f4
......@@ -74,6 +74,12 @@ struct darshan_file_runtime
int64_t last_byte_written;
int64_t offset;
enum cp_io_type last_io_type;
double last_posix_write_end;
double last_mpi_write_end;
double last_posix_read_end;
double last_mpi_read_end;
double last_posix_meta_end;
double last_mpi_meta_end;
};
/* handles used by various APIs to refer to files */
......@@ -133,6 +139,15 @@ extern pthread_mutex_t cp_mutex;
(__file)->log_file->fcounters[__counter] += __value; \
} while(0)
#define CP_F_INC_NO_OVERLAP(__file, __tm1, __tm2, __last, __counter) do { \
if(__tm1 > __last) \
CP_F_INC(__file, __counter, (__tm2-__tm1)); \
else \
CP_F_INC(__file, __counter, (__tm2 - __last)); \
if(__tm2 > __last) \
__last = __tm2; \
} while(0)
#define CP_VALUE(__file, __counter) \
((__file)->log_file->counters[__counter])
......
......@@ -152,7 +152,7 @@ extern char* __progname;
CP_BUCKET_INC(file, CP_EXTENT_WRITE_0_100, extent); \
CP_INC(file, __counter, 1); \
CP_DATATYPE_INC(file, __datatype); \
CP_F_INC(file, CP_F_MPI_WRITE_TIME, (__tm2-__tm1)); \
CP_F_INC_NO_OVERLAP(file, __tm1, __tm2, file->last_mpi_write_end, CP_F_MPI_WRITE_TIME); \
if(CP_F_VALUE(file, CP_F_WRITE_START_TIMESTAMP) == 0) \
CP_F_SET(file, CP_F_WRITE_START_TIMESTAMP, __tm1); \
CP_F_SET(file, CP_F_WRITE_END_TIMESTAMP, __tm2); \
......@@ -172,7 +172,7 @@ extern char* __progname;
CP_BUCKET_INC(file, CP_EXTENT_READ_0_100, extent); \
CP_INC(file, __counter, 1); \
CP_DATATYPE_INC(file, __datatype); \
CP_F_INC(file, CP_F_MPI_READ_TIME, (__tm2-__tm1)); \
CP_F_INC_NO_OVERLAP(file, __tm1, __tm2, file->last_mpi_read_end, CP_F_MPI_READ_TIME); \
if(CP_F_VALUE(file, CP_F_READ_START_TIMESTAMP) == 0) \
CP_F_SET(file, CP_F_READ_START_TIMESTAMP, __tm1); \
CP_F_SET(file, CP_F_READ_END_TIMESTAMP, __tm2); \
......@@ -721,7 +721,7 @@ int MPI_File_open(MPI_Comm comm, char *filename, int amode, MPI_Info info, MPI_F
if(file)
{
CP_SET(file, CP_MODE, amode);
CP_F_INC(file, CP_F_MPI_META_TIME, (tm2-tm1));
CP_F_INC_NO_OVERLAP(file, tm1, tm2, file->last_mpi_meta_end, CP_F_MPI_META_TIME);
if(CP_F_VALUE(file, CP_F_OPEN_TIMESTAMP) == 0)
CP_F_SET(file, CP_F_OPEN_TIMESTAMP,
DARSHAN_MPI_CALL(PMPI_Wtime)());
......@@ -762,7 +762,7 @@ int MPI_File_close(MPI_File *fh)
if(file)
{
CP_F_SET(file, CP_F_CLOSE_TIMESTAMP, DARSHAN_MPI_CALL(PMPI_Wtime)());
CP_F_INC(file, CP_F_MPI_META_TIME, (tm2-tm1));
CP_F_INC_NO_OVERLAP(file, tm1, tm2, file->last_mpi_meta_end, CP_F_MPI_META_TIME);
darshan_file_close_fh(tmp_fh);
}
CP_UNLOCK();
......@@ -785,7 +785,8 @@ int MPI_File_sync(MPI_File fh)
file = darshan_file_by_fh(fh);
if(file)
{
CP_F_INC(file, CP_F_MPI_WRITE_TIME, (tm2-tm1));
fprintf(stderr, "FOO: BOOM.\n");
CP_F_INC_NO_OVERLAP(file, tm1, tm2, file->last_mpi_write_end, CP_F_MPI_WRITE_TIME);
CP_INC(file, CP_SYNCS, 1);
}
CP_UNLOCK();
......@@ -815,7 +816,7 @@ int MPI_File_set_view(MPI_File fh, MPI_Offset disp, MPI_Datatype etype,
CP_INC(file, CP_VIEWS, 1);
if(info != MPI_INFO_NULL)
{
CP_F_INC(file, CP_F_MPI_META_TIME, (tm2-tm1));
CP_F_INC_NO_OVERLAP(file, tm1, tm2, file->last_mpi_meta_end, CP_F_MPI_META_TIME);
CP_INC(file, CP_HINTS, 1);
}
CP_DATATYPE_INC(file, filetype);
......
......@@ -176,7 +176,7 @@ static struct darshan_file_runtime* darshan_file_by_name_setfd(const char* name,
if(file->last_io_type == CP_READ) \
CP_INC(file, CP_RW_SWITCHES, 1); \
file->last_io_type = CP_WRITE; \
CP_F_INC(file, CP_F_POSIX_WRITE_TIME, (__elapsed)); \
CP_F_INC_NO_OVERLAP(file, __tm1, __tm2, file->last_posix_write_end, CP_F_POSIX_WRITE_TIME); \
if(CP_F_VALUE(file, CP_F_WRITE_START_TIMESTAMP) == 0) \
CP_F_SET(file, CP_F_WRITE_START_TIMESTAMP, __tm1); \
CP_F_SET(file, CP_F_WRITE_END_TIMESTAMP, __tm2); \
......@@ -226,7 +226,7 @@ static struct darshan_file_runtime* darshan_file_by_name_setfd(const char* name,
if(file->last_io_type == CP_WRITE) \
CP_INC(file, CP_RW_SWITCHES, 1); \
file->last_io_type = CP_READ; \
CP_F_INC(file, CP_F_POSIX_READ_TIME, (__elapsed)); \
CP_F_INC_NO_OVERLAP(file, __tm1, __tm2, file->last_posix_read_end, CP_F_POSIX_READ_TIME); \
if(CP_F_VALUE(file, CP_F_READ_START_TIMESTAMP) == 0) \
CP_F_SET(file, CP_F_READ_START_TIMESTAMP, __tm1); \
CP_F_SET(file, CP_F_READ_END_TIMESTAMP, __tm2); \
......@@ -260,7 +260,7 @@ static struct darshan_file_runtime* darshan_file_by_name_setfd(const char* name,
CP_SET((__file), CP_SIZE_AT_OPEN, (__statbuf)->st_size); \
}\
(__file)->log_file->rank = my_rank; \
CP_F_INC(__file, CP_F_POSIX_META_TIME, (__tm2-__tm1)); \
CP_F_INC_NO_OVERLAP(file, __tm1, __tm2, file->last_posix_meta_end, CP_F_POSIX_META_TIME); \
CP_INC(__file, CP_POSIX_STATS, 1); \
} while(0)
......@@ -314,7 +314,7 @@ static inline dev_t get_device(const char* path, struct stat64* statbuf)
CP_INC(file, CP_POSIX_OPENS, 1); \
if(CP_F_VALUE(file, CP_F_OPEN_TIMESTAMP) == 0) \
CP_F_SET(file, CP_F_OPEN_TIMESTAMP, posix_wtime()); \
CP_F_INC(file, CP_F_POSIX_META_TIME, (__tm2-__tm1)); \
CP_F_INC_NO_OVERLAP(file, __tm1, __tm2, file->last_posix_meta_end, CP_F_POSIX_META_TIME); \
} while (0)
int DARSHAN_DECL(close)(int fd)
......@@ -337,7 +337,7 @@ int DARSHAN_DECL(close)(int fd)
file->last_byte_written = 0;
file->last_byte_read = 0;
CP_F_SET(file, CP_F_CLOSE_TIMESTAMP, posix_wtime());
CP_F_INC(file, CP_F_POSIX_META_TIME, (tm2-tm1));
CP_F_INC_NO_OVERLAP(file, tm1, tm2, file->last_posix_meta_end, CP_F_POSIX_META_TIME);
darshan_file_close_fd(tmp_fd);
}
CP_UNLOCK();
......@@ -365,7 +365,7 @@ int DARSHAN_DECL(fclose)(FILE *fp)
file->last_byte_written = 0;
file->last_byte_read = 0;
CP_F_SET(file, CP_F_CLOSE_TIMESTAMP, posix_wtime());
CP_F_INC(file, CP_F_POSIX_META_TIME, (tm2-tm1));
CP_F_INC_NO_OVERLAP(file, tm1, tm2, file->last_posix_meta_end, CP_F_POSIX_META_TIME);
darshan_file_close_fd(tmp_fd);
}
CP_UNLOCK();
......@@ -393,7 +393,7 @@ int DARSHAN_DECL(fsync)(int fd)
file = darshan_file_by_fd(fd);
if(file)
{
CP_F_INC(file, CP_F_POSIX_WRITE_TIME, (tm2-tm1));
CP_F_INC_NO_OVERLAP(file, tm1, tm2, file->last_posix_write_end, CP_F_POSIX_WRITE_TIME); \
CP_INC(file, CP_POSIX_FSYNCS, 1);
}
CP_UNLOCK();
......@@ -419,7 +419,7 @@ int DARSHAN_DECL(fdatasync)(int fd)
file = darshan_file_by_fd(fd);
if(file)
{
CP_F_INC(file, CP_F_POSIX_WRITE_TIME, (tm2-tm1));
CP_F_INC_NO_OVERLAP(file, tm1, tm2, file->last_posix_write_end, CP_F_POSIX_WRITE_TIME); \
CP_INC(file, CP_POSIX_FDSYNCS, 1);
}
CP_UNLOCK();
......@@ -995,7 +995,7 @@ off64_t DARSHAN_DECL(lseek64)(int fd, off64_t offset, int whence)
if(file)
{
file->offset = ret;
CP_F_INC(file, CP_F_POSIX_META_TIME, (tm2-tm1));
CP_F_INC_NO_OVERLAP(file, tm1, tm2, file->last_posix_meta_end, CP_F_POSIX_META_TIME);
CP_INC(file, CP_POSIX_SEEKS, 1);
}
CP_UNLOCK();
......@@ -1021,7 +1021,7 @@ off_t DARSHAN_DECL(lseek)(int fd, off_t offset, int whence)
if(file)
{
file->offset = ret;
CP_F_INC(file, CP_F_POSIX_META_TIME, (tm2-tm1));
CP_F_INC_NO_OVERLAP(file, tm1, tm2, file->last_posix_meta_end, CP_F_POSIX_META_TIME);
CP_INC(file, CP_POSIX_SEEKS, 1);
}
CP_UNLOCK();
......@@ -1047,7 +1047,7 @@ int DARSHAN_DECL(fseek)(FILE *stream, long offset, int whence)
if(file)
{
file->offset = ret;
CP_F_INC(file, CP_F_POSIX_META_TIME, (tm2-tm1));
CP_F_INC_NO_OVERLAP(file, tm1, tm2, file->last_posix_meta_end, CP_F_POSIX_META_TIME);
CP_INC(file, CP_POSIX_FSEEKS, 1);
}
CP_UNLOCK();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment