1/* 2 * Copyright (c) 1999-2012 Mark D. Hill and David A. Wood 3 * Copyright (c) 2010 Advanced Micro Devices, Inc. 4 * All rights reserved. 5 * 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. 16 * 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. 28 */ 29 30/* 31 * Recording cache requests made to a ruby cache at certain ruby 32 * time. Also dump the requests to a gziped file. 33 */ 34 35#ifndef __MEM_RUBY_RECORDER_CACHERECORDER_HH__ 36#define __MEM_RUBY_RECORDER_CACHERECORDER_HH__ 37 38#include <vector> 39 40#include "base/hashmap.hh"
| 1/* 2 * Copyright (c) 1999-2012 Mark D. Hill and David A. Wood 3 * Copyright (c) 2010 Advanced Micro Devices, Inc. 4 * All rights reserved. 5 * 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. 16 * 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. 28 */ 29 30/* 31 * Recording cache requests made to a ruby cache at certain ruby 32 * time. Also dump the requests to a gziped file. 33 */ 34 35#ifndef __MEM_RUBY_RECORDER_CACHERECORDER_HH__ 36#define __MEM_RUBY_RECORDER_CACHERECORDER_HH__ 37 38#include <vector> 39 40#include "base/hashmap.hh"
|
| 41#include "base/types.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" 45 46class Sequencer; 47 48/*! 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. 53 */ 54class TraceRecord { 55 public: 56 int m_cntrl_id;
| 42#include "mem/protocol/RubyRequestType.hh" 43#include "mem/ruby/common/Address.hh" 44#include "mem/ruby/common/DataBlock.hh" 45#include "mem/ruby/common/TypeDefines.hh" 46 47class Sequencer; 48 49/*! 50 * Class for recording cache contents. Note that the last element of the 51 * class is an array of length zero. It is used for creating variable 52 * length object, so that while writing the data to a file one does not 53 * need to copy the meta data and the actual data separately. 54 */ 55class TraceRecord { 56 public: 57 int m_cntrl_id;
|
57 Time m_time;
| 58 Tick m_time;
|
58 physical_address_t m_data_address; 59 physical_address_t m_pc_address; 60 RubyRequestType m_type; 61 uint8_t m_data[0]; 62 63 void print(std::ostream& out) const; 64}; 65 66class CacheRecorder 67{ 68 public: 69 CacheRecorder(); 70 ~CacheRecorder(); 71 72 CacheRecorder(uint8_t* uncompressed_trace, 73 uint64_t uncompressed_trace_size, 74 std::vector<Sequencer*>& SequencerMap, 75 uint64_t block_size_bytes); 76 void addRecord(int cntrl, const physical_address_t data_addr, 77 const physical_address_t pc_addr, RubyRequestType type,
| 59 physical_address_t m_data_address; 60 physical_address_t m_pc_address; 61 RubyRequestType m_type; 62 uint8_t m_data[0]; 63 64 void print(std::ostream& out) const; 65}; 66 67class CacheRecorder 68{ 69 public: 70 CacheRecorder(); 71 ~CacheRecorder(); 72 73 CacheRecorder(uint8_t* uncompressed_trace, 74 uint64_t uncompressed_trace_size, 75 std::vector<Sequencer*>& SequencerMap, 76 uint64_t block_size_bytes); 77 void addRecord(int cntrl, const physical_address_t data_addr, 78 const physical_address_t pc_addr, RubyRequestType type,
|
78 Time time, DataBlock& data);
| 79 Tick time, DataBlock& data);
|
79 80 uint64 aggregateRecords(uint8_t** data, uint64 size); 81 82 /*! 83 * Function for flushing the memory contents of the caches to the 84 * main memory. It goes through the recorded contents of the caches, 85 * and issues flush requests. Except for the first one, a flush request 86 * is issued only after the previous one has completed. This currently 87 * requires use of MOESI Hammer protocol since only that protocol 88 * supports flush requests. 89 */ 90 void enqueueNextFlushRequest(); 91 92 /*! 93 * Function for fetching warming up the memory and the caches. It goes 94 * through the recorded contents of the caches, as available in the 95 * checkpoint and issues fetch requests. Except for the first one, a 96 * fetch request is issued only after the previous one has completed. 97 * It should be possible to use this with any protocol. 98 */ 99 void enqueueNextFetchRequest(); 100 101 private: 102 // Private copy constructor and assignment operator 103 CacheRecorder(const CacheRecorder& obj); 104 CacheRecorder& operator=(const CacheRecorder& obj); 105 106 std::vector<TraceRecord*> m_records; 107 uint8_t* m_uncompressed_trace; 108 uint64_t m_uncompressed_trace_size; 109 std::vector<Sequencer*> m_seq_map; 110 uint64_t m_bytes_read; 111 uint64_t m_records_read; 112 uint64_t m_records_flushed; 113 uint64_t m_block_size_bytes; 114}; 115 116inline bool 117compareTraceRecords(const TraceRecord* n1, const TraceRecord* n2) 118{ 119 return n1->m_time > n2->m_time; 120} 121 122inline std::ostream& 123operator<<(std::ostream& out, const TraceRecord& obj) 124{ 125 obj.print(out); 126 out << std::flush; 127 return out; 128} 129 130#endif // __MEM_RUBY_RECORDER_CACHERECORDER_HH__
| 80 81 uint64 aggregateRecords(uint8_t** data, uint64 size); 82 83 /*! 84 * Function for flushing the memory contents of the caches to the 85 * main memory. It goes through the recorded contents of the caches, 86 * and issues flush requests. Except for the first one, a flush request 87 * is issued only after the previous one has completed. This currently 88 * requires use of MOESI Hammer protocol since only that protocol 89 * supports flush requests. 90 */ 91 void enqueueNextFlushRequest(); 92 93 /*! 94 * Function for fetching warming up the memory and the caches. It goes 95 * through the recorded contents of the caches, as available in the 96 * checkpoint and issues fetch requests. Except for the first one, a 97 * fetch request is issued only after the previous one has completed. 98 * It should be possible to use this with any protocol. 99 */ 100 void enqueueNextFetchRequest(); 101 102 private: 103 // Private copy constructor and assignment operator 104 CacheRecorder(const CacheRecorder& obj); 105 CacheRecorder& operator=(const CacheRecorder& obj); 106 107 std::vector<TraceRecord*> m_records; 108 uint8_t* m_uncompressed_trace; 109 uint64_t m_uncompressed_trace_size; 110 std::vector<Sequencer*> m_seq_map; 111 uint64_t m_bytes_read; 112 uint64_t m_records_read; 113 uint64_t m_records_flushed; 114 uint64_t m_block_size_bytes; 115}; 116 117inline bool 118compareTraceRecords(const TraceRecord* n1, const TraceRecord* n2) 119{ 120 return n1->m_time > n2->m_time; 121} 122 123inline std::ostream& 124operator<<(std::ostream& out, const TraceRecord& obj) 125{ 126 obj.print(out); 127 out << std::flush; 128 return out; 129} 130 131#endif // __MEM_RUBY_RECORDER_CACHERECORDER_HH__
|