text.cc revision 5887
1695SN/A/* 21762SN/A * Copyright (c) 2004-2005 The Regents of The University of Michigan 3695SN/A * All rights reserved. 4695SN/A * 5695SN/A * Redistribution and use in source and binary forms, with or without 6695SN/A * modification, are permitted provided that the following conditions are 7695SN/A * met: redistributions of source code must retain the above copyright 8695SN/A * notice, this list of conditions and the following disclaimer; 9695SN/A * redistributions in binary form must reproduce the above copyright 10695SN/A * notice, this list of conditions and the following disclaimer in the 11695SN/A * documentation and/or other materials provided with the distribution; 12695SN/A * neither the name of the copyright holders nor the names of its 13695SN/A * contributors may be used to endorse or promote products derived from 14695SN/A * this software without specific prior written permission. 15695SN/A * 16695SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17695SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18695SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19695SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20695SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21695SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22695SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23695SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24695SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25695SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26695SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665Ssaidi@eecs.umich.edu * 282665Ssaidi@eecs.umich.edu * Authors: Nathan Binkert 29695SN/A */ 30695SN/A 31873SN/A#if defined(__APPLE__) 32873SN/A#define _GLIBCPP_USE_C99 1 33873SN/A#endif 34873SN/A 353918Ssaidi@eecs.umich.edu#if defined(__sun) 363918Ssaidi@eecs.umich.edu#include <math.h> 373918Ssaidi@eecs.umich.edu#endif 383918Ssaidi@eecs.umich.edu 39695SN/A#include <iostream> 402621SN/A#include <sstream> 41695SN/A#include <fstream> 42695SN/A#include <string> 43695SN/A 44695SN/A#include "base/misc.hh" 45695SN/A#include "base/statistics.hh" 46695SN/A#include "base/stats/text.hh" 47695SN/A#include "base/stats/visit.hh" 48695SN/A 49695SN/Ausing namespace std; 50695SN/A 51695SN/A#ifndef NAN 52695SN/Afloat __nan(); 53695SN/A/** Define Not a number. */ 54695SN/A#define NAN (__nan()) 55695SN/A/** Need to define __nan() */ 56695SN/A#define __M5_NAN 57695SN/A#endif 58695SN/A 59695SN/A#ifdef __M5_NAN 60695SN/Afloat 61695SN/A__nan() 62695SN/A{ 63695SN/A union { 64695SN/A uint32_t ui; 65695SN/A float f; 66695SN/A } nan; 67695SN/A 68695SN/A nan.ui = 0x7fc00000; 69695SN/A return nan.f; 70695SN/A} 71695SN/A#endif 72695SN/A 73729SN/Anamespace Stats { 74695SN/A 75695SN/AText::Text() 76695SN/A : mystream(false), stream(NULL), compat(false), descriptions(false) 77695SN/A{ 78695SN/A} 79695SN/A 80695SN/AText::Text(std::ostream &stream) 81695SN/A : mystream(false), stream(NULL), compat(false), descriptions(false) 82695SN/A{ 83695SN/A open(stream); 84695SN/A} 85695SN/A 86695SN/AText::Text(const std::string &file) 87695SN/A : mystream(false), stream(NULL), compat(false), descriptions(false) 88695SN/A{ 89695SN/A open(file); 90695SN/A} 91695SN/A 92695SN/A 93695SN/AText::~Text() 94695SN/A{ 95695SN/A if (mystream) { 96695SN/A assert(stream); 97695SN/A delete stream; 98695SN/A } 99695SN/A} 100695SN/A 101695SN/Avoid 102695SN/AText::open(std::ostream &_stream) 103695SN/A{ 104695SN/A if (stream) 105695SN/A panic("stream already set!"); 106695SN/A 107695SN/A mystream = false; 108695SN/A stream = &_stream; 1095581Ssaidi@eecs.umich.edu if (!valid()) 1105581Ssaidi@eecs.umich.edu fatal("Unable to open output stream for writing\n"); 111695SN/A} 112695SN/A 113695SN/Avoid 114695SN/AText::open(const std::string &file) 115695SN/A{ 116695SN/A if (stream) 117695SN/A panic("stream already set!"); 118695SN/A 119695SN/A mystream = true; 120695SN/A stream = new ofstream(file.c_str(), ios::trunc); 1215581Ssaidi@eecs.umich.edu if (!valid()) 1225581Ssaidi@eecs.umich.edu fatal("Unable to open statistics file for writing\n"); 123695SN/A} 124695SN/A 125695SN/Abool 126695SN/AText::valid() const 127695SN/A{ 1285581Ssaidi@eecs.umich.edu return stream != NULL && stream->good(); 129695SN/A} 130695SN/A 131695SN/Avoid 132695SN/AText::output() 133695SN/A{ 134695SN/A ccprintf(*stream, "\n---------- Begin Simulation Statistics ----------\n"); 1355887Snate@binkert.org list<Info *>::const_iterator i, end = statsList().end(); 1365887Snate@binkert.org for (i = statsList().begin(); i != end; ++i) 1372343SN/A (*i)->visit(*this); 138695SN/A ccprintf(*stream, "\n---------- End Simulation Statistics ----------\n"); 139695SN/A stream->flush(); 140695SN/A} 141695SN/A 142695SN/Abool 1435886Snate@binkert.orgText::noOutput(const Info &info) 144695SN/A{ 1455886Snate@binkert.org if (!(info.flags & print)) 146695SN/A return true; 147695SN/A 1485886Snate@binkert.org if (info.prereq && info.prereq->zero()) 149695SN/A return true; 150695SN/A 151695SN/A return false; 152695SN/A} 153695SN/A 154695SN/Astring 155695SN/AValueToString(Result value, int precision, bool compat) 156695SN/A{ 157695SN/A stringstream val; 158695SN/A 159695SN/A if (!isnan(value)) { 160695SN/A if (precision != -1) 161695SN/A val.precision(precision); 162695SN/A else if (value == rint(value)) 163695SN/A val.precision(0); 164695SN/A 165695SN/A val.unsetf(ios::showpoint); 166695SN/A val.setf(ios::fixed); 167695SN/A val << value; 168695SN/A } else { 169695SN/A val << (compat ? "<err: div-0>" : "no value"); 170695SN/A } 171695SN/A 172695SN/A return val.str(); 173695SN/A} 174695SN/A 175695SN/Astruct ScalarPrint 176695SN/A{ 177695SN/A Result value; 178695SN/A string name; 179695SN/A string desc; 180695SN/A StatFlags flags; 181695SN/A bool compat; 182695SN/A bool descriptions; 183695SN/A int precision; 184695SN/A Result pdf; 185695SN/A Result cdf; 186695SN/A 187695SN/A void operator()(ostream &stream) const; 188695SN/A}; 189695SN/A 190695SN/Avoid 191695SN/AScalarPrint::operator()(ostream &stream) const 192695SN/A{ 1935570Snate@binkert.org if ((flags & nozero && value == 0.0) || 1945570Snate@binkert.org (flags & nonan && isnan(value))) 195695SN/A return; 196695SN/A 197695SN/A stringstream pdfstr, cdfstr; 198695SN/A 199695SN/A if (!isnan(pdf)) 200695SN/A ccprintf(pdfstr, "%.2f%%", pdf * 100.0); 201695SN/A 202695SN/A if (!isnan(cdf)) 203695SN/A ccprintf(cdfstr, "%.2f%%", cdf * 100.0); 204695SN/A 205695SN/A if (compat && flags & __substat) { 206695SN/A ccprintf(stream, "%32s %12s %10s %10s", name, 207695SN/A ValueToString(value, precision, compat), pdfstr, cdfstr); 208695SN/A } else { 209695SN/A ccprintf(stream, "%-40s %12s %10s %10s", name, 210695SN/A ValueToString(value, precision, compat), pdfstr, cdfstr); 211695SN/A } 212695SN/A 213695SN/A if (descriptions) { 214695SN/A if (!desc.empty()) 215695SN/A ccprintf(stream, " # %s", desc); 216695SN/A } 217695SN/A stream << endl; 218695SN/A} 219695SN/A 220695SN/Astruct VectorPrint 221695SN/A{ 222695SN/A string name; 223695SN/A string desc; 224695SN/A vector<string> subnames; 225695SN/A vector<string> subdescs; 226695SN/A StatFlags flags; 227695SN/A bool compat; 228695SN/A bool descriptions; 229695SN/A int precision; 230695SN/A VResult vec; 231695SN/A Result total; 232695SN/A 233695SN/A void operator()(ostream &stream) const; 234695SN/A}; 235695SN/A 236695SN/Avoid 237695SN/AVectorPrint::operator()(std::ostream &stream) const 238695SN/A{ 2395599Snate@binkert.org size_type _size = vec.size(); 240695SN/A Result _total = 0.0; 241695SN/A 242695SN/A if (flags & (pdf | cdf)) { 2435599Snate@binkert.org for (off_type i = 0; i < _size; ++i) { 244695SN/A _total += vec[i]; 245695SN/A } 246695SN/A } 247695SN/A 248695SN/A string base = name + (compat ? "_" : "::"); 249695SN/A 250695SN/A ScalarPrint print; 251695SN/A print.name = name; 252695SN/A print.desc = desc; 2534209Ssaidi@eecs.umich.edu print.compat = compat; 254695SN/A print.precision = precision; 255695SN/A print.descriptions = descriptions; 256695SN/A print.flags = flags; 257695SN/A print.pdf = NAN; 258695SN/A print.cdf = NAN; 259695SN/A 260695SN/A bool havesub = !subnames.empty(); 261695SN/A 262695SN/A if (_size == 1) { 263695SN/A print.value = vec[0]; 264695SN/A print(stream); 265695SN/A } else if (!compat) { 2665599Snate@binkert.org for (off_type i = 0; i < _size; ++i) { 267695SN/A if (havesub && (i >= subnames.size() || subnames[i].empty())) 268695SN/A continue; 269695SN/A 270695SN/A print.name = base + (havesub ? subnames[i] : to_string(i)); 271695SN/A print.desc = subdescs.empty() ? desc : subdescs[i]; 272695SN/A print.value = vec[i]; 273695SN/A 274695SN/A if (_total && (flags & pdf)) { 275695SN/A print.pdf = vec[i] / _total; 276695SN/A print.cdf += print.pdf; 277695SN/A } 278695SN/A 279695SN/A print(stream); 280695SN/A } 281695SN/A 282729SN/A if (flags & ::Stats::total) { 283695SN/A print.name = base + "total"; 284695SN/A print.desc = desc; 285695SN/A print.value = total; 286695SN/A print(stream); 287695SN/A } 288695SN/A } else { 289729SN/A if (flags & ::Stats::total) { 290695SN/A print.value = total; 291695SN/A print(stream); 292695SN/A } 293695SN/A 294695SN/A Result _pdf = 0.0; 295695SN/A Result _cdf = 0.0; 296695SN/A if (flags & dist) { 297695SN/A ccprintf(stream, "%s.start_dist\n", name); 2985599Snate@binkert.org for (off_type i = 0; i < _size; ++i) { 299695SN/A print.name = havesub ? subnames[i] : to_string(i); 300695SN/A print.desc = subdescs.empty() ? desc : subdescs[i]; 301695SN/A print.flags |= __substat; 302695SN/A print.value = vec[i]; 303695SN/A 304695SN/A if (_total) { 305695SN/A _pdf = vec[i] / _total; 306695SN/A _cdf += _pdf; 307695SN/A } 308695SN/A 309695SN/A if (flags & pdf) 310695SN/A print.pdf = _pdf; 311695SN/A if (flags & cdf) 312695SN/A print.cdf = _cdf; 313695SN/A 314695SN/A print(stream); 315695SN/A } 316695SN/A ccprintf(stream, "%s.end_dist\n", name); 317695SN/A } else { 3185599Snate@binkert.org for (off_type i = 0; i < _size; ++i) { 319695SN/A if (havesub && subnames[i].empty()) 320695SN/A continue; 321695SN/A 322695SN/A print.name = base; 323695SN/A print.name += havesub ? subnames[i] : to_string(i); 324695SN/A print.desc = subdescs.empty() ? desc : subdescs[i]; 325695SN/A print.value = vec[i]; 326695SN/A 327695SN/A if (_total) { 328695SN/A _pdf = vec[i] / _total; 329695SN/A _cdf += _pdf; 330695SN/A } else { 331695SN/A _pdf = _cdf = NAN; 332695SN/A } 333695SN/A 334695SN/A if (flags & pdf) { 335695SN/A print.pdf = _pdf; 336695SN/A print.cdf = _cdf; 337695SN/A } 338695SN/A 339695SN/A print(stream); 340695SN/A } 341695SN/A } 342695SN/A } 343695SN/A} 344695SN/A 345695SN/Astruct DistPrint 346695SN/A{ 347695SN/A string name; 348695SN/A string desc; 349695SN/A StatFlags flags; 350695SN/A bool compat; 351695SN/A bool descriptions; 352695SN/A int precision; 353695SN/A 354695SN/A Result min_val; 355695SN/A Result max_val; 356695SN/A Result underflow; 357695SN/A Result overflow; 358695SN/A VResult vec; 359695SN/A Result sum; 360695SN/A Result squares; 361695SN/A Result samples; 362695SN/A 363695SN/A Counter min; 364695SN/A Counter max; 365695SN/A Counter bucket_size; 3665599Snate@binkert.org size_type size; 367695SN/A bool fancy; 368695SN/A 369695SN/A void operator()(ostream &stream) const; 370695SN/A}; 371695SN/A 372695SN/Avoid 373695SN/ADistPrint::operator()(ostream &stream) const 374695SN/A{ 375695SN/A if (fancy) { 376695SN/A ScalarPrint print; 377695SN/A string base = name + (compat ? "_" : "::"); 378695SN/A 379695SN/A print.precision = precision; 380695SN/A print.flags = flags; 381695SN/A print.compat = compat; 382695SN/A print.descriptions = descriptions; 383695SN/A print.desc = desc; 384695SN/A print.pdf = NAN; 385695SN/A print.cdf = NAN; 386695SN/A 387695SN/A print.name = base + "mean"; 388695SN/A print.value = samples ? sum / samples : NAN; 389695SN/A print(stream); 390695SN/A 391695SN/A print.name = base + "stdev"; 392695SN/A print.value = samples ? sqrt((samples * squares - sum * sum) / 393695SN/A (samples * (samples - 1.0))) : NAN; 394695SN/A print(stream); 395695SN/A 396695SN/A print.name = "**Ignore: " + base + "TOT"; 397695SN/A print.value = samples; 398695SN/A print(stream); 399695SN/A return; 400695SN/A } 401695SN/A 402695SN/A assert(size == vec.size()); 403695SN/A 404695SN/A Result total = 0.0; 405695SN/A 406695SN/A total += underflow; 4075599Snate@binkert.org for (off_type i = 0; i < size; ++i) 408695SN/A total += vec[i]; 409695SN/A total += overflow; 410695SN/A 411695SN/A string base = name + (compat ? "." : "::"); 412695SN/A 413695SN/A ScalarPrint print; 414695SN/A print.desc = compat ? "" : desc; 415695SN/A print.flags = flags; 416695SN/A print.compat = compat; 417695SN/A print.descriptions = descriptions; 418695SN/A print.precision = precision; 419695SN/A print.pdf = NAN; 420695SN/A print.cdf = NAN; 421695SN/A 422695SN/A if (compat) { 423695SN/A ccprintf(stream, "%-42s", base + "start_dist"); 424695SN/A if (descriptions && !desc.empty()) 425695SN/A ccprintf(stream, " # %s", desc); 426695SN/A stream << endl; 427695SN/A } 428695SN/A 429695SN/A print.name = base + "samples"; 430695SN/A print.value = samples; 431695SN/A print(stream); 432695SN/A 433695SN/A print.name = base + "min_value"; 434695SN/A print.value = min_val; 435695SN/A print(stream); 436695SN/A 437695SN/A if (!compat || underflow > 0.0) { 438695SN/A print.name = base + "underflows"; 439695SN/A print.value = underflow; 440695SN/A if (!compat && total) { 441695SN/A print.pdf = underflow / total; 442695SN/A print.cdf += print.pdf; 443695SN/A } 444695SN/A print(stream); 445695SN/A } 446695SN/A 447695SN/A if (!compat) { 4485599Snate@binkert.org for (off_type i = 0; i < size; ++i) { 449695SN/A stringstream namestr; 4505884Snate@binkert.org namestr << base; 451695SN/A 452695SN/A Counter low = i * bucket_size + min; 453695SN/A Counter high = ::min(low + bucket_size, max); 454695SN/A namestr << low; 455695SN/A if (low < high) 456695SN/A namestr << "-" << high; 457695SN/A 458695SN/A print.name = namestr.str(); 459695SN/A print.value = vec[i]; 460695SN/A if (total) { 461695SN/A print.pdf = vec[i] / total; 462695SN/A print.cdf += print.pdf; 463695SN/A } 464695SN/A print(stream); 465695SN/A } 466695SN/A } else { 467695SN/A Counter _min; 468695SN/A Result _pdf; 469695SN/A Result _cdf = 0.0; 470695SN/A 471695SN/A print.flags = flags | __substat; 472695SN/A 4735599Snate@binkert.org for (off_type i = 0; i < size; ++i) { 4745570Snate@binkert.org if ((flags & nozero && vec[i] == 0.0) || 4755570Snate@binkert.org (flags & nonan && isnan(vec[i]))) 476695SN/A continue; 477695SN/A 478695SN/A _min = i * bucket_size + min; 479695SN/A _pdf = vec[i] / total * 100.0; 480695SN/A _cdf += _pdf; 481695SN/A 482695SN/A 483695SN/A print.name = ValueToString(_min, 0, compat); 484695SN/A print.value = vec[i]; 485695SN/A print.pdf = (flags & pdf) ? _pdf : NAN; 486695SN/A print.cdf = (flags & cdf) ? _cdf : NAN; 487695SN/A print(stream); 488695SN/A } 489695SN/A 490695SN/A print.flags = flags; 491695SN/A } 492695SN/A 493695SN/A if (!compat || overflow > 0.0) { 494695SN/A print.name = base + "overflows"; 495695SN/A print.value = overflow; 496695SN/A if (!compat && total) { 497695SN/A print.pdf = overflow / total; 498695SN/A print.cdf += print.pdf; 499695SN/A } else { 500695SN/A print.pdf = NAN; 501695SN/A print.cdf = NAN; 502695SN/A } 503695SN/A print(stream); 504695SN/A } 505695SN/A 506695SN/A print.pdf = NAN; 507695SN/A print.cdf = NAN; 508695SN/A 509695SN/A if (!compat) { 510695SN/A print.name = base + "total"; 511695SN/A print.value = total; 512695SN/A print(stream); 513695SN/A } 514695SN/A 515695SN/A print.name = base + "max_value"; 516695SN/A print.value = max_val; 517695SN/A print(stream); 518695SN/A 519695SN/A if (!compat && samples != 0) { 520695SN/A print.name = base + "mean"; 521695SN/A print.value = sum / samples; 522695SN/A print(stream); 523695SN/A 524695SN/A print.name = base + "stdev"; 525695SN/A print.value = sqrt((samples * squares - sum * sum) / 526695SN/A (samples * (samples - 1.0))); 527695SN/A print(stream); 528695SN/A } 529695SN/A 530695SN/A if (compat) 531695SN/A ccprintf(stream, "%send_dist\n\n", base); 532695SN/A} 533695SN/A 534695SN/Avoid 5355886Snate@binkert.orgText::visit(const ScalarInfoBase &info) 536695SN/A{ 5375886Snate@binkert.org if (noOutput(info)) 538695SN/A return; 539695SN/A 540695SN/A ScalarPrint print; 5415886Snate@binkert.org print.value = info.result(); 5425886Snate@binkert.org print.name = info.name; 5435886Snate@binkert.org print.desc = info.desc; 5445886Snate@binkert.org print.flags = info.flags; 545695SN/A print.compat = compat; 546695SN/A print.descriptions = descriptions; 5475886Snate@binkert.org print.precision = info.precision; 548695SN/A print.pdf = NAN; 549695SN/A print.cdf = NAN; 550695SN/A 551695SN/A print(*stream); 552695SN/A} 553695SN/A 554695SN/Avoid 5555886Snate@binkert.orgText::visit(const VectorInfoBase &info) 556695SN/A{ 5575886Snate@binkert.org if (noOutput(info)) 558695SN/A return; 559695SN/A 5605886Snate@binkert.org size_type size = info.size(); 561695SN/A VectorPrint print; 562695SN/A 5635886Snate@binkert.org print.name = info.name; 5645886Snate@binkert.org print.desc = info.desc; 5655886Snate@binkert.org print.flags = info.flags; 566695SN/A print.compat = compat; 567695SN/A print.descriptions = descriptions; 5685886Snate@binkert.org print.precision = info.precision; 5695886Snate@binkert.org print.vec = info.result(); 5705886Snate@binkert.org print.total = info.total(); 571695SN/A 5725886Snate@binkert.org if (!info.subnames.empty()) { 5735599Snate@binkert.org for (off_type i = 0; i < size; ++i) { 5745886Snate@binkert.org if (!info.subnames[i].empty()) { 5755886Snate@binkert.org print.subnames = info.subnames; 576695SN/A print.subnames.resize(size); 5775599Snate@binkert.org for (off_type i = 0; i < size; ++i) { 5785886Snate@binkert.org if (!info.subnames[i].empty() && 5795886Snate@binkert.org !info.subdescs[i].empty()) { 5805886Snate@binkert.org print.subdescs = info.subdescs; 581695SN/A print.subdescs.resize(size); 582695SN/A break; 583695SN/A } 584695SN/A } 585695SN/A break; 586695SN/A } 587695SN/A } 588695SN/A } 589695SN/A 590695SN/A print(*stream); 591695SN/A} 592695SN/A 593695SN/Avoid 5945886Snate@binkert.orgText::visit(const Vector2dInfoBase &info) 595695SN/A{ 5965886Snate@binkert.org if (noOutput(info)) 597695SN/A return; 598695SN/A 599695SN/A bool havesub = false; 600695SN/A VectorPrint print; 601695SN/A 6025886Snate@binkert.org print.subnames = info.y_subnames; 6035886Snate@binkert.org print.flags = info.flags; 604695SN/A print.compat = compat; 605695SN/A print.descriptions = descriptions; 6065886Snate@binkert.org print.precision = info.precision; 607695SN/A 6085886Snate@binkert.org if (!info.subnames.empty()) { 6095886Snate@binkert.org for (off_type i = 0; i < info.x; ++i) 6105886Snate@binkert.org if (!info.subnames[i].empty()) 611695SN/A havesub = true; 612695SN/A } 613695SN/A 6145886Snate@binkert.org VResult tot_vec(info.y); 615695SN/A Result super_total = 0.0; 6165886Snate@binkert.org for (off_type i = 0; i < info.x; ++i) { 6175886Snate@binkert.org if (havesub && (i >= info.subnames.size() || info.subnames[i].empty())) 618695SN/A continue; 619695SN/A 6205886Snate@binkert.org off_type iy = i * info.y; 6215886Snate@binkert.org VResult yvec(info.y); 622695SN/A 623695SN/A Result total = 0.0; 6245886Snate@binkert.org for (off_type j = 0; j < info.y; ++j) { 6255886Snate@binkert.org yvec[j] = info.cvec[iy + j]; 626695SN/A tot_vec[j] += yvec[j]; 627695SN/A total += yvec[j]; 628695SN/A super_total += yvec[j]; 629695SN/A } 630695SN/A 6315886Snate@binkert.org print.name = info.name + "_" + 6325886Snate@binkert.org (havesub ? info.subnames[i] : to_string(i)); 6335886Snate@binkert.org print.desc = info.desc; 634695SN/A print.vec = yvec; 635695SN/A print.total = total; 636695SN/A print(*stream); 637695SN/A } 638695SN/A 6395886Snate@binkert.org if ((info.flags & ::Stats::total) && (info.x > 1)) { 6405886Snate@binkert.org print.name = info.name; 6415886Snate@binkert.org print.desc = info.desc; 642695SN/A print.vec = tot_vec; 643695SN/A print.total = super_total; 644695SN/A print(*stream); 645695SN/A } 646695SN/A} 647695SN/A 648695SN/Avoid 6495886Snate@binkert.orgText::visit(const DistInfoBase &info) 650695SN/A{ 6515886Snate@binkert.org if (noOutput(info)) 652695SN/A return; 653695SN/A 654695SN/A DistPrint print; 655695SN/A 6565886Snate@binkert.org print.name = info.name; 6575886Snate@binkert.org print.desc = info.desc; 6585886Snate@binkert.org print.flags = info.flags; 659695SN/A print.compat = compat; 660695SN/A print.descriptions = descriptions; 6615886Snate@binkert.org print.precision = info.precision; 662695SN/A 6635886Snate@binkert.org const DistData &data = info.data; 6645886Snate@binkert.org 6655886Snate@binkert.org print.min_val = data.min_val; 6665886Snate@binkert.org print.max_val = data.max_val; 6675886Snate@binkert.org print.underflow = data.underflow; 6685886Snate@binkert.org print.overflow = data.overflow; 6695886Snate@binkert.org print.vec.resize(data.cvec.size()); 6705599Snate@binkert.org for (off_type i = 0; i < print.vec.size(); ++i) 6715886Snate@binkert.org print.vec[i] = (Result)data.cvec[i]; 6725886Snate@binkert.org print.sum = data.sum; 6735886Snate@binkert.org print.squares = data.squares; 6745886Snate@binkert.org print.samples = data.samples; 675695SN/A 6765886Snate@binkert.org print.min = data.min; 6775886Snate@binkert.org print.max = data.max; 6785886Snate@binkert.org print.bucket_size = data.bucket_size; 6795886Snate@binkert.org print.size = data.size; 6805886Snate@binkert.org print.fancy = data.fancy; 681695SN/A 682695SN/A print(*stream); 683695SN/A} 684695SN/A 685695SN/Avoid 6865886Snate@binkert.orgText::visit(const VectorDistInfoBase &info) 687695SN/A{ 6885886Snate@binkert.org if (noOutput(info)) 689695SN/A return; 690695SN/A 6915886Snate@binkert.org for (off_type i = 0; i < info.size(); ++i) { 692695SN/A DistPrint print; 693695SN/A 6945886Snate@binkert.org print.name = info.name + "_" + 6955886Snate@binkert.org (info.subnames[i].empty() ? (to_string(i)) : info.subnames[i]); 6965886Snate@binkert.org print.desc = info.subdescs[i].empty() ? info.desc : info.subdescs[i]; 6975886Snate@binkert.org print.flags = info.flags; 698695SN/A print.compat = compat; 699695SN/A print.descriptions = descriptions; 7005886Snate@binkert.org print.precision = info.precision; 701695SN/A 7025886Snate@binkert.org print.min_val = info.data[i].min_val; 7035886Snate@binkert.org print.max_val = info.data[i].max_val; 7045886Snate@binkert.org print.underflow = info.data[i].underflow; 7055886Snate@binkert.org print.overflow = info.data[i].overflow; 7065886Snate@binkert.org print.vec.resize(info.data[i].cvec.size()); 7075599Snate@binkert.org for (off_type j = 0; j < print.vec.size(); ++j) 7085886Snate@binkert.org print.vec[j] = (Result)info.data[i].cvec[j]; 7095886Snate@binkert.org print.sum = info.data[i].sum; 7105886Snate@binkert.org print.squares = info.data[i].squares; 7115886Snate@binkert.org print.samples = info.data[i].samples; 712695SN/A 7135886Snate@binkert.org print.min = info.data[i].min; 7145886Snate@binkert.org print.max = info.data[i].max; 7155886Snate@binkert.org print.bucket_size = info.data[i].bucket_size; 7165886Snate@binkert.org print.size = info.data[i].size; 7175886Snate@binkert.org print.fancy = info.data[i].fancy; 718695SN/A 719695SN/A print(*stream); 720695SN/A } 721695SN/A} 722695SN/A 723695SN/Avoid 7245886Snate@binkert.orgText::visit(const FormulaInfoBase &info) 725695SN/A{ 7265886Snate@binkert.org visit((const VectorInfoBase &)info); 727695SN/A} 728695SN/A 7294078Sbinkertn@umich.edubool 7304078Sbinkertn@umich.eduinitText(const string &filename, bool desc, bool compat) 7314078Sbinkertn@umich.edu{ 7324078Sbinkertn@umich.edu static Text text; 7334078Sbinkertn@umich.edu static bool connected = false; 7344078Sbinkertn@umich.edu 7354078Sbinkertn@umich.edu if (connected) 7364078Sbinkertn@umich.edu return false; 7374078Sbinkertn@umich.edu 7384078Sbinkertn@umich.edu extern list<Output *> OutputList; 7394078Sbinkertn@umich.edu 7404078Sbinkertn@umich.edu text.open(*simout.find(filename)); 7414078Sbinkertn@umich.edu text.descriptions = desc; 7424078Sbinkertn@umich.edu text.compat = compat; 7434078Sbinkertn@umich.edu OutputList.push_back(&text); 7444078Sbinkertn@umich.edu connected = true; 7454078Sbinkertn@umich.edu 7464078Sbinkertn@umich.edu return true; 7474078Sbinkertn@umich.edu} 7484078Sbinkertn@umich.edu 749729SN/A/* namespace Stats */ } 750