2 * Copyright (c) 1999-2012 Mark D. Hill and David A. Wood
3 * Copyright (c) 2010 Advanced Micro Devices, Inc.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer;
10 * redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution;
13 * neither the name of the copyright holders nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 * Recording cache requests made to a ruby cache at certain ruby
32 * time. Also dump the requests to a gziped file.
35 #ifndef __MEM_RUBY_RECORDER_CACHERECORDER_HH__
36 #define __MEM_RUBY_RECORDER_CACHERECORDER_HH__
40 #include "base/hashmap.hh"
41 #include "mem/protocol/RubyRequestType.hh"
42 #include "mem/ruby/common/Address.hh"
43 #include "mem/ruby/common/DataBlock.hh"
44 #include "mem/ruby/common/TypeDefines.hh"
49 * Class for recording cache contents. Note that the last element of the
50 * class is an array of length zero. It is used for creating variable
51 * length object, so that while writing the data to a file one does not
52 * need to copy the meta data and the actual data separately.
58 physical_address_t m_data_address;
59 physical_address_t m_pc_address;
60 RubyRequestType m_type;
63 void print(std::ostream& out) const;
72 CacheRecorder(uint8_t* uncompressed_trace,
73 uint64_t uncompressed_trace_size,
74 std::vector<Sequencer*>& SequencerMap);
75 void addRecord(int cntrl, const physical_address_t data_addr,
76 const physical_address_t pc_addr, RubyRequestType type,
77 Time time, DataBlock& data);
79 uint64 aggregateRecords(uint8_t** data, uint64 size);
82 * Function for flushing the memory contents of the caches to the
83 * main memory. It goes through the recorded contents of the caches,
84 * and issues flush requests. Except for the first one, a flush request
85 * is issued only after the previous one has completed. This currently
86 * requires use of MOESI Hammer protocol since only that protocol
87 * supports flush requests.
89 void enqueueNextFlushRequest();
92 * Function for fetching warming up the memory and the caches. It goes
93 * through the recorded contents of the caches, as available in the
94 * checkpoint and issues fetch requests. Except for the first one, a
95 * fetch request is issued only after the previous one has completed.
96 * It should be possible to use this with any protocol.
98 void enqueueNextFetchRequest();
101 // Private copy constructor and assignment operator
102 CacheRecorder(const CacheRecorder& obj);
103 CacheRecorder& operator=(const CacheRecorder& obj);
105 std::vector<TraceRecord*> m_records;
106 uint8_t* m_uncompressed_trace;
107 uint64_t m_uncompressed_trace_size;
108 std::vector<Sequencer*> m_seq_map;
109 uint64_t m_bytes_read;
110 uint64_t m_records_read;
111 uint64_t m_records_flushed;
115 compareTraceRecords(const TraceRecord* n1, const TraceRecord* n2)
117 return n1->m_time > n2->m_time;
121 operator<<(std::ostream& out, const TraceRecord& obj)
128 #endif // __MEM_RUBY_RECORDER_CACHERECORDER_HH__