Commit c903e491 authored by fisaila's avatar fisaila

Corrected a bug with the trace file name.

Updated the trace parser. 



git-svn-id: https://svn.mcs.anl.gov/repos/darshan/branches/darshan-florin-extensions-addcounters-datatypes@872 3b7491f3-a168-0410-bf4b-c445ed680a29
parent 60a4e16a
......@@ -172,31 +172,39 @@ void darshan_trace_log_record(int rank, int epoch, int op, double tm1, double tm
void darshan_trace_log_write() {
char *filename;
//if ((filename=getenv("DARSHAN_TRACING"))!=NULL) {
if (getenv("DARSHAN_TRACING")){
char *dir;
if ((dir=getenv("DARSHAN_TRACING"))!=NULL) {
//if (getenv("DARSHAN_TRACING")){
MPI_Offset offset;
int rank;
MPI_File fh;
MPI_Status status;
struct tm* my_tm;
time_t tm;
filename = (char*) malloc(PATH_MAX);
tm = time(NULL);
my_tm = localtime(&tm);
snprintf(filename, PATH_MAX,
"%s_%d-%d-%d.darshan_trace",
filename = (char*) malloc(PATH_MAX);
DARSHAN_MPI_CALL(PMPI_Comm_rank)(MPI_COMM_WORLD, &rank);
if (rank == 0) {
struct tm* my_tm;
time_t tm;
tm = time(NULL);
my_tm = localtime(&tm);
snprintf(filename, PATH_MAX,
"%s/%s_%d-%d-%d.darshan_trace",
dir,
__progname,
(my_tm->tm_mon+1),
my_tm->tm_mday,
(my_tm->tm_hour*60*60 + my_tm->tm_min*60 + my_tm->tm_sec));
DARSHAN_MPI_CALL(PMPI_Comm_rank)(MPI_COMM_WORLD, &rank);
if (rank == 0)
fprintf(stdout, "DARSHAN_TRACEFILE:%s\n", filename);
fprintf(stdout, "DARSHAN_TRACEFILE:%s\n", filename);
}
DARSHAN_MPI_CALL(PMPI_Bcast)(filename, PATH_MAX, MPI_CHAR, 0,
MPI_COMM_WORLD);
MPI_Scan(&darshan_log_ptr, &offset, 1, MPI_LONG_LONG_INT, MPI_SUM, MPI_COMM_WORLD);
PMPI_Scan(&darshan_log_ptr, &offset, 1, MPI_LONG_LONG_INT, MPI_SUM, MPI_COMM_WORLD);
// printf("%d: darshan_log_ptr=%lld offset=%lld\n", rank, darshan_log_ptr, offset-darshan_log_ptr);
DARSHAN_MPI_CALL(PMPI_File_open)(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_WRONLY | MPI_MODE_EXCL,
MPI_INFO_NULL, &fh);
......
......@@ -22,12 +22,13 @@ struct darshan_trace_record {
*/
void read_log(char *filename, char* csvfile) {
void read_log(char *filename, char* csvfile, int epoch, char* counter) {
int fd;
ssize_t bytes_read;
FILE *fout;
struct darshan_trace_record d;
int flag = 1;
if ((fd=open(filename,O_RDONLY))<0){
perror("Open Failed");
......@@ -45,9 +46,29 @@ void read_log(char *filename, char* csvfile) {
fprintf(fout, "rank,epoch,counter,start_time,end_time,write_count,read_count,offset\n");
while ((bytes_read = read(fd,&d,sizeof(struct darshan_trace_record)))>0) {
fprintf(fout, "%d,%d,%s,%.6f,%.6f,%d,%d,%lld\n",
if (epoch < 0) {
if (counter) {
if (strcmp(counter, darshan_names[d.op])) {
flag = 0;
}
}
}
else {
if (epoch != d.epoch)
flag = 0;
else {
if (counter) {
if (strcmp(counter, darshan_names[d.op])) {
flag = 0;
}
}
}
}
if (flag)
fprintf(fout, "%d,%d,%s,%.6f,%.6f,%d,%d,%lld\n",
d.rank, d.epoch, darshan_names[d.op],d.tm1,d.tm2,d.send_count, d.recv_count,d.offset);
flag = 1;
}
close(fd);
......@@ -59,12 +80,21 @@ void read_log(char *filename, char* csvfile) {
int main(int argc, char **argv)
{
if (argc != 2) {
printf("Call %s darshan_trace_file_name", argv[0]);
int epoch = -1;
char *counter = NULL;
if (argc < 2) {
printf("Call %s darshan_trace_file_name [epoch] [counter] \n", argv[0]);
exit(1);
}
read_log(argv[1], NULL);
else {
if (argc > 2) {
epoch = atoi(argv[2]);
if (argc > 3)
counter = argv[3];
}
}
read_log(argv[1], NULL, epoch, counter);
return 0;
}
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