Andrea Di Biagio | 0cc66c7 | 2018-03-09 13:52:03 +0000 | [diff] [blame] | 1 | //===--------------------- SummaryView.cpp -------------------*- C++ -*-===// |
| 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 |
| 10 | /// |
| 11 | /// This file implements the functionalities used by the SummaryView to print |
| 12 | /// the report information. |
| 13 | /// |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | |
| 16 | #include "SummaryView.h" |
Andrea Di Biagio | df5d948 | 2018-03-23 19:40:04 +0000 | [diff] [blame^] | 17 | #include "llvm/Support/Format.h" |
Andrea Di Biagio | 0cc66c7 | 2018-03-09 13:52:03 +0000 | [diff] [blame] | 18 | |
| 19 | namespace mca { |
| 20 | |
Andrea Di Biagio | df5d948 | 2018-03-23 19:40:04 +0000 | [diff] [blame^] | 21 | #define DEBUG_TYPE "llvm-mca" |
| 22 | |
Andrea Di Biagio | 0cc66c7 | 2018-03-09 13:52:03 +0000 | [diff] [blame] | 23 | using namespace llvm; |
| 24 | |
Andrea Di Biagio | df5d948 | 2018-03-23 19:40:04 +0000 | [diff] [blame^] | 25 | void SummaryView::printView(raw_ostream &OS) const { |
Andrea Di Biagio | b522975 | 2018-03-13 17:24:32 +0000 | [diff] [blame] | 26 | unsigned Iterations = Source.getNumIterations(); |
| 27 | unsigned Instructions = Source.size(); |
Andrea Di Biagio | 0cc66c7 | 2018-03-09 13:52:03 +0000 | [diff] [blame] | 28 | unsigned TotalInstructions = Instructions * Iterations; |
| 29 | double IPC = (double)TotalInstructions / TotalCycles; |
| 30 | |
| 31 | std::string Buffer; |
| 32 | raw_string_ostream TempStream(Buffer); |
| 33 | TempStream << "Iterations: " << Iterations; |
| 34 | TempStream << "\nInstructions: " << TotalInstructions; |
| 35 | TempStream << "\nTotal Cycles: " << TotalCycles; |
| 36 | TempStream << "\nDispatch Width: " << DispatchWidth; |
| 37 | TempStream << "\nIPC: " << format("%.2f", IPC) << '\n'; |
| 38 | TempStream.flush(); |
| 39 | OS << Buffer; |
| 40 | } |
| 41 | |
Andrea Di Biagio | 0cc66c7 | 2018-03-09 13:52:03 +0000 | [diff] [blame] | 42 | } // namespace mca. |