00001 /* 00002 File: InstArray.cc 00003 00004 Function: Template definitions for InstArray.h 00005 00006 Author(s): Andrew Willmott 00007 00008 Copyright: (c) 1995-2000, Andrew Willmott 00009 00010 Notes: 00011 00012 */ 00013 00014 #include "cl/InstArray.h" 00015 00026 InstArrayStats::InstArrayStats() : 00027 reads(0), 00028 writes(0), 00029 accesses(0), 00030 trace(0) 00031 { 00032 00033 } 00034 00035 Void InstArrayStats::Reset() 00036 { 00037 reads = 0; 00038 writes = 0; 00039 } 00040 00041 Void InstArrayStats::StartTrace(const FileName &fname) 00042 { 00043 trace = fopen(fname.GetPath(), "w"); 00044 } 00045 00046 Void InstArrayStats::StopTrace() 00047 { 00048 fclose(trace); 00049 trace = 0; 00050 } 00051 00052 Void InstArrayStats::Read(Int i) 00053 { 00054 reads++; 00055 if (accesses) 00056 accesses[i]++; 00057 if (trace) 00058 fprintf(trace, "%d\n", i); 00059 } 00060 00061 Void InstArrayStats::Write(Int i) 00062 { 00063 writes++; 00064 if (accesses) 00065 accesses[i]++; 00066 if (trace) 00067 fprintf(trace, "%d\n", i); 00068 } 00069 00070 Void InstArrayStats::Dump() 00071 { 00072 cout << "reads " << reads << endl; 00073 cout << "writes " << writes << endl; 00074 cout << "total accesses " << reads + writes << endl; 00075 }