diff --git a/tools/build_offset_intervals.cpp b/tools/build_offset_intervals.cpp index 519085f..53bce52 100644 --- a/tools/build_offset_intervals.cpp +++ b/tools/build_offset_intervals.cpp @@ -48,7 +48,7 @@ size_t get_eof(string filename, unordered_map local_eof, unorder * This function must be called after intervals of IntervalsMap have been filled. * Also, records need to be sorted by tstart, which we did in build_offset_intervals(). */ -void setup_open_close_commit(vector records, int nprocs, IntervalsMap *IM, int num_files, int semantics) { +void setup_open_close_commit(RecorderReader &reader, vector records, int nprocs, IntervalsMap *IM, int num_files, int semantics) { int i, j, rank; unordered_map> topens[nprocs]; unordered_map> tcloses[nprocs]; @@ -59,7 +59,7 @@ void setup_open_close_commit(vector records, int nprocs, IntervalsMap * for(i = 0; i < records.size(); i++) { RRecord rr = records[i]; Record *R = rr.record; - const char* func = func_list[R->func_id]; + const char* func = reader.func_list[R->func_id]; int fd = -1; string filename; @@ -130,7 +130,7 @@ void setup_open_close_commit(vector records, int nprocs, IntervalsMap * } } -void handle_data_operation(RRecord &rr, +void handle_data_operation(RecorderReader &reader, RRecord &rr, unordered_map &filemap, // unordered_map &offset_book, // unordered_map &local_eof, // (locally) @@ -139,7 +139,7 @@ void handle_data_operation(RRecord &rr, int semantics ) { Record *R = rr.record; - const char* func = func_list[R->func_id]; + const char* func = reader.func_list[R->func_id]; if(!strstr(func, "read") && !strstr(func, "write")) return; @@ -193,7 +193,7 @@ void handle_data_operation(RRecord &rr, } -void handle_metadata_operation(RRecord &rr, +void handle_metadata_operation(RecorderReader &reader, RRecord &rr, unordered_map &filemap, // unordered_map &offset_book, // unordered_map &local_eof, // (locally) @@ -203,7 +203,7 @@ void handle_metadata_operation(RRecord &rr, int rank = rr.rank; Record *R = rr.record; - const char* func = func_list[R->func_id]; + const char* func = reader.func_list[R->func_id]; string filename; @@ -236,10 +236,11 @@ void handle_metadata_operation(RRecord &rr, if(flag & O_APPEND) offset_book[fd] = get_eof(filename, local_eof, global_eof); - } else if(strstr(func, "seek")) { + } else if(strstr(func, "seek") || strstr(func, "seeko")) { int fd = atoi(R->args[0]); int offset = atoi(R->args[1]); int whence = atoi(R->args[2]); + if(filemap.find(fd) == filemap.end()) return; filename = filemap[fd]; @@ -287,7 +288,7 @@ vector flatten_and_sort_records(RecorderReader reader) { for(j = 0; j < reader.RLDs[rank].total_records; j++) { Record *r = &(reader.records[rank][j]); - const char* func = func_list[r->func_id]; + const char* func = reader.func_list[r->func_id]; if(strstr(func,"MPI") || strstr(func, "H5") || strstr(func, "dir") || strstr(func, "link")) continue; @@ -323,15 +324,13 @@ IntervalsMap* build_offset_intervals(RecorderReader reader, int *num_files, int RRecord rr = records[i]; - handle_metadata_operation(rr, filemaps[rr.rank], offset_books[rr.rank], + handle_metadata_operation(reader, rr, filemaps[rr.rank], offset_books[rr.rank], local_eofs[rr.rank], global_eof); - handle_data_operation(rr, filemaps[rr.rank], offset_books[rr.rank], + handle_data_operation(reader, rr, filemaps[rr.rank], offset_books[rr.rank], local_eofs[rr.rank], global_eof, intervals, semantics); } - - // Now we have the list of intervals for all files // We copy it from the vector to a C style pointer // The vector and the memory it allocated will be @@ -357,19 +356,7 @@ IntervalsMap* build_offset_intervals(RecorderReader reader, int *num_files, int } // Fill in topens, tcloses and tcommits - setup_open_close_commit(records, reader.RGD.total_ranks, IM, *num_files, semantics); + setup_open_close_commit(reader, records, reader.RGD.total_ranks, IM, *num_files, semantics); return IM; } - -/* -int main(int argc, char* argv[]) { - RecorderReader reader; - int num_files; - recorder_read_traces(argv[1], &reader); - - build_offset_intervals(reader, &num_files); - - return 0; -} -*/ diff --git a/tools/overlap_conflict.c b/tools/overlap_conflict.c index ac789a2..e0599b0 100644 --- a/tools/overlap_conflict.c +++ b/tools/overlap_conflict.c @@ -64,7 +64,7 @@ void detect_overlaps(IntervalsMap *IM, int num_files) { if(i1->offset+i1->count <= i2->offset) continue; - printf("%s, i1(%d, %d, %d, %d), i2(%d, %d, %d, %d) \n", filename, i1->rank, i1->offset, i1->count, i1->isRead, i2->rank, i2->offset, i2->count, i2->isRead); + printf("%s, i1(%d, %ld, %ld, %d), i2(%d, %ld, %ld, %d) \n", filename, i1->rank, i1->offset, i1->count, i1->isRead, i2->rank, i2->offset, i2->count, i2->isRead); int same_rank = (i1->rank == i2->rank)? 1 : 0; if(i1->isRead && i2->isRead) // RAR overlaps[same_rank][0] += 1; @@ -153,6 +153,9 @@ void detect_conflicts(IntervalsMap *IM, int num_files) { } if(!conflict) continue; + + printf("%s, i1(%d, %ld, %ld, %d), i2(%d, %ld, %ld, %d) \n", filename, i1->rank, i1->offset, i1->count, i1->isRead, i2->rank, i2->offset, i2->count, i2->isRead); + int same_rank = (i1->rank == i2->rank)? 1 : 0; if(starts_later->isRead) // RAW @@ -193,7 +196,7 @@ int main(int argc, char* argv[]) { access_patterns(IM, num_files); //detect_overlaps(IM, num_files); - detect_conflicts(IM, num_files); + //detect_conflicts(IM, num_files); for(i = 0; i < num_files; i++) { free(IM[i].filename);