Matt Davis | 248acf6 | 2018-06-14 20:58:54 +0000 | [diff] [blame] | 1 | //===--------------------- RetireControlUnitStatistics.cpp ------*- C++ -*-===// |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | /// \file |
Andrea Di Biagio | 53e6ade | 2018-03-09 12:50:42 +0000 | [diff] [blame] | 10 | /// |
Andrea Di Biagio | f41ad5c | 2018-04-11 12:12:53 +0000 | [diff] [blame] | 11 | /// This file implements the RetireControlUnitStatistics interface. |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 12 | /// |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Matt Davis | 10aa09f | 2018-08-24 20:24:53 +0000 | [diff] [blame] | 15 | #include "Views/RetireControlUnitStatistics.h" |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 16 | #include "llvm/Support/Format.h" |
| 17 | |
| 18 | using namespace llvm; |
| 19 | |
| 20 | namespace mca { |
| 21 | |
Matt Davis | 0906a7f | 2018-07-12 16:56:17 +0000 | [diff] [blame] | 22 | void RetireControlUnitStatistics::onEvent(const HWInstructionEvent &Event) { |
Andrea Di Biagio | 1cc29c0 | 2018-04-11 11:37:46 +0000 | [diff] [blame] | 23 | if (Event.Type == HWInstructionEvent::Retired) |
Clement Courbet | 844f22d | 2018-03-13 13:11:01 +0000 | [diff] [blame] | 24 | ++NumRetired; |
Clement Courbet | 844f22d | 2018-03-13 13:11:01 +0000 | [diff] [blame] | 25 | } |
| 26 | |
Andrea Di Biagio | db158be | 2018-10-22 16:28:07 +0000 | [diff] [blame] | 27 | void RetireControlUnitStatistics::printView(raw_ostream &OS) const { |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 28 | std::string Buffer; |
| 29 | raw_string_ostream TempStream(Buffer); |
| 30 | TempStream << "\n\nRetire Control Unit - " |
| 31 | << "number of cycles where we saw N instructions retired:\n"; |
| 32 | TempStream << "[# retired], [# cycles]\n"; |
| 33 | |
| 34 | for (const std::pair<unsigned, unsigned> &Entry : RetiredPerCycle) { |
| 35 | TempStream << " " << Entry.first; |
| 36 | if (Entry.first < 10) |
| 37 | TempStream << ", "; |
| 38 | else |
| 39 | TempStream << ", "; |
| 40 | TempStream << Entry.second << " (" |
| 41 | << format("%.1f", ((double)Entry.second / NumCycles) * 100.0) |
| 42 | << "%)\n"; |
| 43 | } |
| 44 | |
| 45 | TempStream.flush(); |
| 46 | OS << Buffer; |
| 47 | } |
| 48 | |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 49 | } // namespace mca |