| 1/* 2 * Copyright (c) 2006 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */
|
1 2#include "base/timebuf.hh" 3#include "cpu/activity.hh" 4 5ActivityRecorder::ActivityRecorder(int num_stages, int longest_latency, 6 int activity) 7 : activityBuffer(longest_latency, 0), longestLatency(longest_latency), 8 activityCount(activity), numStages(num_stages) 9{ 10 stageActive = new bool[numStages]; 11 memset(stageActive, 0, numStages); 12} 13 14void 15ActivityRecorder::activity() 16{
| 28 29#include "base/timebuf.hh" 30#include "cpu/activity.hh" 31 32ActivityRecorder::ActivityRecorder(int num_stages, int longest_latency, 33 int activity) 34 : activityBuffer(longest_latency, 0), longestLatency(longest_latency), 35 activityCount(activity), numStages(num_stages) 36{ 37 stageActive = new bool[numStages]; 38 memset(stageActive, 0, numStages); 39} 40 41void 42ActivityRecorder::activity() 43{
|
| 44 // If we've already recorded activity for this cycle, we don't 45 // want to increment the count any more.
|
17 if (activityBuffer[0]) { 18 return; 19 } 20 21 activityBuffer[0] = true; 22 23 ++activityCount; 24 25 DPRINTF(Activity, "Activity: %i\n", activityCount); 26} 27 28void 29ActivityRecorder::advance() 30{
| 46 if (activityBuffer[0]) { 47 return; 48 } 49 50 activityBuffer[0] = true; 51 52 ++activityCount; 53 54 DPRINTF(Activity, "Activity: %i\n", activityCount); 55} 56 57void 58ActivityRecorder::advance() 59{
|
| 60 // If there's a 1 in the slot that is about to be erased once the 61 // time buffer advances, then decrement the activityCount.
|
31 if (activityBuffer[-longestLatency]) { 32 --activityCount; 33 34 assert(activityCount >= 0); 35 36 DPRINTF(Activity, "Activity: %i\n", activityCount); 37 38 if (activityCount == 0) { 39 DPRINTF(Activity, "No activity left!\n"); 40 } 41 } 42 43 activityBuffer.advance(); 44} 45 46void 47ActivityRecorder::activateStage(const int idx) 48{
| 62 if (activityBuffer[-longestLatency]) { 63 --activityCount; 64 65 assert(activityCount >= 0); 66 67 DPRINTF(Activity, "Activity: %i\n", activityCount); 68 69 if (activityCount == 0) { 70 DPRINTF(Activity, "No activity left!\n"); 71 } 72 } 73 74 activityBuffer.advance(); 75} 76 77void 78ActivityRecorder::activateStage(const int idx) 79{
|
| 80 // Increment the activity count if this stage wasn't already active.
|
49 if (!stageActive[idx]) { 50 ++activityCount; 51 52 stageActive[idx] = true; 53 54 DPRINTF(Activity, "Activity: %i\n", activityCount); 55 } else { 56 DPRINTF(Activity, "Stage %i already active.\n", idx); 57 } 58 59// assert(activityCount < longestLatency + numStages + 1); 60} 61 62void 63ActivityRecorder::deactivateStage(const int idx) 64{
| 81 if (!stageActive[idx]) { 82 ++activityCount; 83 84 stageActive[idx] = true; 85 86 DPRINTF(Activity, "Activity: %i\n", activityCount); 87 } else { 88 DPRINTF(Activity, "Stage %i already active.\n", idx); 89 } 90 91// assert(activityCount < longestLatency + numStages + 1); 92} 93 94void 95ActivityRecorder::deactivateStage(const int idx) 96{
|
| 97 // Decrement the activity count if this stage was active.
|
65 if (stageActive[idx]) { 66 --activityCount; 67 68 stageActive[idx] = false; 69 70 DPRINTF(Activity, "Activity: %i\n", activityCount); 71 } else { 72 DPRINTF(Activity, "Stage %i already inactive.\n", idx); 73 } 74 75 assert(activityCount >= 0); 76} 77 78void 79ActivityRecorder::reset() 80{ 81 activityCount = 0; 82 memset(stageActive, 0, numStages); 83 for (int i = 0; i < longestLatency + 1; ++i) 84 activityBuffer.advance(); 85} 86 87void 88ActivityRecorder::dump() 89{ 90 for (int i = 0; i <= longestLatency; ++i) { 91 cprintf("[Idx:%i %i] ", i, activityBuffer[-i]); 92 } 93 94 cprintf("\n"); 95 96 for (int i = 0; i < numStages; ++i) { 97 cprintf("[Stage:%i %i]\n", i, stageActive[i]); 98 } 99 100 cprintf("\n"); 101 102 cprintf("Activity count: %i\n", activityCount); 103} 104 105void 106ActivityRecorder::validate() 107{ 108 int count = 0; 109 for (int i = 0; i <= longestLatency; ++i) { 110 if (activityBuffer[-i]) { 111 count++; 112 } 113 } 114 115 for (int i = 0; i < numStages; ++i) { 116 if (stageActive[i]) { 117 count++; 118 } 119 } 120 121 assert(count == activityCount); 122}
| 98 if (stageActive[idx]) { 99 --activityCount; 100 101 stageActive[idx] = false; 102 103 DPRINTF(Activity, "Activity: %i\n", activityCount); 104 } else { 105 DPRINTF(Activity, "Stage %i already inactive.\n", idx); 106 } 107 108 assert(activityCount >= 0); 109} 110 111void 112ActivityRecorder::reset() 113{ 114 activityCount = 0; 115 memset(stageActive, 0, numStages); 116 for (int i = 0; i < longestLatency + 1; ++i) 117 activityBuffer.advance(); 118} 119 120void 121ActivityRecorder::dump() 122{ 123 for (int i = 0; i <= longestLatency; ++i) { 124 cprintf("[Idx:%i %i] ", i, activityBuffer[-i]); 125 } 126 127 cprintf("\n"); 128 129 for (int i = 0; i < numStages; ++i) { 130 cprintf("[Stage:%i %i]\n", i, stageActive[i]); 131 } 132 133 cprintf("\n"); 134 135 cprintf("Activity count: %i\n", activityCount); 136} 137 138void 139ActivityRecorder::validate() 140{ 141 int count = 0; 142 for (int i = 0; i <= longestLatency; ++i) { 143 if (activityBuffer[-i]) { 144 count++; 145 } 146 } 147 148 for (int i = 0; i < numStages; ++i) { 149 if (stageActive[i]) { 150 count++; 151 } 152 } 153 154 assert(count == activityCount); 155}
|