1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679
|
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2009-2022, Intel Corporation
//
// monitor CPU conters for ksysguard
//
// contact: Thomas Willhalm, Patrick Ungerer, Roman Dementiev
//
// This program is not a tutorial on how to write nice interpreters
// but a proof of concept on using ksysguard with performance counters
//
/*! \file pcm-sensor.cpp
\brief Example of using CPU counters: implements a graphical plugin for KDE ksysguard
*/
#include <iostream>
#include <string>
#include <sstream>
#include "cpuasynchcounter.h"
#include "utils.h"
using namespace std;
using namespace pcm;
PCM_MAIN_NOTHROW;
int mainThrows(int /* argc */, char * /*argv*/ [])
{
set_signal_handlers();
AsynchronCounterState counters;
cout << "CPU counter sensor " << PCM_VERSION << "\n";
cout << "ksysguardd 1.2.0\n";
cout << "ksysguardd> ";
while (1)
{
string s;
cin >> s;
const auto xpi = counters.getXpi();
// list counters
if (s == "monitors") {
for (uint32 i = 0; i < counters.getNumCores(); ++i) {
for (uint32 a = 0; a < counters.getNumSockets(); ++a)
if (a == counters.getSocketId(i)) {
cout << "Socket" << a << "/CPU" << i << "/Frequency\tfloat\n";
cout << "Socket" << a << "/CPU" << i << "/IPC\tfloat\n";
cout << "Socket" << a << "/CPU" << i << "/L2CacheHitRatio\tfloat\n";
cout << "Socket" << a << "/CPU" << i << "/L3CacheHitRatio\tfloat\n";
cout << "Socket" << a << "/CPU" << i << "/L2CacheMisses\tinteger\n";
cout << "Socket" << a << "/CPU" << i << "/L3CacheMisses\tinteger\n";
cout << "Socket" << a << "/CPU" << i << "/L3Occupancy\tfloat\n";
cout << "Socket" << a << "/CPU" << i << "/LocalMemoryBandwidth\tfloat\n";
cout << "Socket" << a << "/CPU" << i << "/RemoteMemoryBandwidth\tfloat\n";
cout << "Socket" << a << "/CPU" << i << "/CoreC0StateResidency\tfloat\n";
cout << "Socket" << a << "/CPU" << i << "/CoreC3StateResidency\tfloat\n";
cout << "Socket" << a << "/CPU" << i << "/CoreC6StateResidency\tfloat\n";
cout << "Socket" << a << "/CPU" << i << "/CoreC7StateResidency\tfloat\n";
cout << "Socket" << a << "/CPU" << i << "/ThermalHeadroom\tinteger\n";
}
}
for (uint32 a = 0; a < counters.getNumSockets(); ++a) {
cout << "Socket" << a << "/BytesReadFromMC\tfloat\n";
cout << "Socket" << a << "/BytesWrittenToMC\tfloat\n";
cout << "Socket" << a << "/BytesReadFromPMM\tfloat\n";
cout << "Socket" << a << "/BytesWrittenToPMM\tfloat\n";
cout << "Socket" << a << "/Frequency\tfloat\n";
cout << "Socket" << a << "/IPC\tfloat\n";
cout << "Socket" << a << "/L2CacheHitRatio\tfloat\n";
cout << "Socket" << a << "/L3CacheHitRatio\tfloat\n";
cout << "Socket" << a << "/L2CacheMisses\tinteger\n";
cout << "Socket" << a << "/L3CacheMisses\tinteger\n";
cout << "Socket" << a << "/L3Occupancy\tfloat\n";
cout << "Socket" << a << "/LocalMemoryBandwidth\tfloat\n";
cout << "Socket" << a << "/RemoteMemoryBandwidth\tfloat\n";
cout << "Socket" << a << "/CoreC0StateResidency\tfloat\n";
cout << "Socket" << a << "/CoreC3StateResidency\tfloat\n";
cout << "Socket" << a << "/CoreC6StateResidency\tfloat\n";
cout << "Socket" << a << "/CoreC7StateResidency\tfloat\n";
cout << "Socket" << a << "/PackageC2StateResidency\tfloat\n";
cout << "Socket" << a << "/PackageC3StateResidency\tfloat\n";
cout << "Socket" << a << "/PackageC6StateResidency\tfloat\n";
cout << "Socket" << a << "/PackageC7StateResidency\tfloat\n";
cout << "Socket" << a << "/ThermalHeadroom\tinteger\n";
cout << "Socket" << a << "/CPUEnergy\tfloat\n";
cout << "Socket" << a << "/DRAMEnergy\tfloat\n";
}
for (uint32 a = 0; a < counters.getNumSockets(); ++a) {
for (uint32 l = 0; l < counters.getQPILinksPerSocket(); ++l)
cout << "Socket" << a << "/BytesIncomingTo" << xpi << l << "\tfloat\n";
}
cout << xpi << "_Traffic\tfloat\n";
cout << "Frequency\tfloat\n";
cout << "IPC\tfloat\n"; //double check output
cout << "L2CacheHitRatio\tfloat\n";
cout << "L3CacheHitRatio\tfloat\n";
cout << "L2CacheMisses\tinteger\n";
cout << "L3CacheMisses\tinteger\n";
cout << "CoreC0StateResidency\tfloat\n";
cout << "CoreC3StateResidency\tfloat\n";
cout << "CoreC6StateResidency\tfloat\n";
cout << "CoreC7StateResidency\tfloat\n";
cout << "PackageC2StateResidency\tfloat\n";
cout << "PackageC3StateResidency\tfloat\n";
cout << "PackageC6StateResidency\tfloat\n";
cout << "PackageC7StateResidency\tfloat\n";
cout << "CPUEnergy\tfloat\n";
cout << "DRAMEnergy\tfloat\n";
}
// provide metadata
for (uint32 i = 0; i < counters.getNumCores(); ++i) {
for (uint32 a = 0; a < counters.getNumSockets(); ++a)
if (a == counters.getSocketId(i)) {
{
stringstream c;
c << "Socket" << a << "/CPU" << i << "/Frequency?";
if (s == c.str()) {
cout << "FREQ. CPU" << i << "\t\t\tMHz\n";
}
}
{
stringstream c;
c << "Socket" << a << "/CPU" << i << "/ThermalHeadroom?";
if (s == c.str()) {
cout << "Temperature reading in 1 degree Celsius relative to the TjMax temperature (thermal headroom) for CPU" << i << "\t\t\t°C\n";
}
}
{
stringstream c;
c << "Socket" << a << "/CPU" << i << "/CoreC0StateResidency?";
if (s == c.str()) {
cout << "core C0-state residency for CPU" << i << "\t\t\t%\n";
}
}
{
stringstream c;
c << "Socket" << a << "/CPU" << i << "/CoreC3StateResidency?";
if (s == c.str()) {
cout << "core C3-state residency for CPU" << i << "\t\t\t%\n";
}
}
{
stringstream c;
c << "Socket" << a << "/CPU" << i << "/CoreC6StateResidency?";
if (s == c.str()) {
cout << "core C6-state residency for CPU" << i << "\t\t\t%\n";
}
}
{
stringstream c;
c << "Socket" << a << "/CPU" << i << "/CoreC7StateResidency?";
if (s == c.str()) {
cout << "core C7-state residency for CPU" << i << "\t\t\t%\n";
}
}
}
}
for (uint32 i = 0; i < counters.getNumCores(); ++i) {
for (uint32 a = 0; a < counters.getNumSockets(); ++a)
if (a == counters.getSocketId(i)) {
stringstream c;
c << "Socket" << a << "/CPU" << i << "/IPC?";
if (s == c.str()) {
cout << "IPC CPU" << i << "\t0\t\t\n";
//cout << "CPU" << i << "\tInstructions per Cycle\t0\t1\t \n";
}
}
}
for (uint32 i = 0; i < counters.getNumCores(); ++i) {
for (uint32 a = 0; a < counters.getNumSockets(); ++a)
if (a == counters.getSocketId(i)) {
stringstream c;
c << "Socket" << a << "/CPU" << i << "/L2CacheHitRatio?";
if (s == c.str()) {
cout << "L2 Cache Hit Ratio CPU" << i << "\t0\t\t\n";
// cout << "CPU" << i << "\tL2 Cache Hit Ratio\t0\t1\t \n";
}
}
}
for (uint32 i = 0; i < counters.getNumCores(); ++i) {
for (uint32 a = 0; a < counters.getNumSockets(); ++a)
if (a == counters.getSocketId(i)) {
stringstream c;
c << "Socket" << a << "/CPU" << i << "/L3CacheHitRatio?";
if (s == c.str()) {
cout << "L3 Cache Hit Ratio CPU" << i << "\t0\t\t \n";
}
}
}
for (uint32 i = 0; i < counters.getNumCores(); ++i) {
for (uint32 a = 0; a < counters.getNumSockets(); ++a)
if (a == counters.getSocketId(i)) {
stringstream c;
c << "Socket" << a << "/CPU" << i << "/L2CacheMisses?";
if (s == c.str()) {
cout << "L2 Cache Misses CPU" << i << "\t0\t\t \n";
//cout << "CPU" << i << "\tL2 Cache Misses\t0\t1\t \n";
}
}
}
for (uint32 i = 0; i < counters.getNumCores(); ++i) {
for (uint32 a = 0; a < counters.getNumSockets(); ++a)
if (a == counters.getSocketId(i)) {
stringstream c;
c << "Socket" << a << "/CPU" << i << "/L3CacheMisses?";
if (s == c.str()) {
cout << "L3 Cache Misses CPU" << i << "\t0\t\t \n";
//cout << "CPU" << i << "\tL3 Cache Misses\t0\t1\t \n";
}
}
}
for (uint32 i = 0; i < counters.getNumCores(); ++i) {
for (uint32 a = 0; a < counters.getNumSockets(); ++a)
if (a == counters.getSocketId(i)) {
stringstream c;
c << "Socket" << a << "/CPU" << i << "/L3Occupancy?";
if (s == c.str()) {
cout << "L3 Cache Occupancy CPU " << i << "\t0\t\t \n";
//cout << "CPU" << i << "\tL3 Cache Occupancy\t0\t1\t \n";
}
}
}
for (uint32 i = 0; i < counters.getNumCores(); ++i) {
for (uint32 a = 0; a < counters.getNumSockets(); ++a)
if (a == counters.getSocketId(i)) {
stringstream c;
c << "Socket" << a << "/CPU" << i << "/LocalMemoryBandwidth?";
if (s == c.str()) {
cout << "Local Memory Bandwidth CPU " << i << "\t0\t\t \n";
//cout << "CPU" << i << "\tLocal Memory Bandwidth\t0\t1\t \n";
}
}
}
for (uint32 i = 0; i < counters.getNumCores(); ++i) {
for (uint32 a = 0; a < counters.getNumSockets(); ++a)
if (a == counters.getSocketId(i)) {
stringstream c;
c << "Socket" << a << "/CPU" << i << "/RemoteMemoryBandwidth?";
if (s == c.str()) {
cout << "Remote Memory Bandwidth CPU " << i << "\t0\t\t \n";
//cout << "CPU" << i << "\tRemote Memory Bandwidth\t0\t1\t \n";
}
}
}
for (uint32 i = 0; i < counters.getNumSockets(); ++i) {
stringstream c;
c << "Socket" << i << "/BytesReadFromMC?";
if (s == c.str()) {
cout << "read from MC Socket" << i << "\t0\t\tGB\n";
}
}
for (uint32 i = 0; i < counters.getNumSockets(); ++i) {
stringstream c;
c << "Socket" << i << "/BytesReadFromPMM?";
if (s == c.str()) {
cout << "read from PMM memory on Socket" << i << "\t0\t\tGB\n";
}
}
for (uint32 i = 0; i < counters.getNumSockets(); ++i) {
stringstream c;
c << "Socket" << i << "/DRAMEnergy?";
if (s == c.str()) {
cout << "Energy consumed by DRAM on socket " << i << "\t0\t\tJoule\n";
}
}
for (uint32 i = 0; i < counters.getNumSockets(); ++i) {
stringstream c;
c << "Socket" << i << "/CPUEnergy?";
if (s == c.str()) {
cout << "Energy consumed by CPU package " << i << "\t0\t\tJoule\n";
}
}
for (uint32 i = 0; i < counters.getNumSockets(); ++i) {
stringstream c;
c << "Socket" << i << "/ThermalHeadroom?";
if (s == c.str()) {
cout << "Temperature reading in 1 degree Celsius relative to the TjMax temperature (thermal headroom) for CPU package " << i << "\t0\t\t°C\n";
}
}
for (uint32 i = 0; i < counters.getNumSockets(); ++i) {
stringstream c;
c << "Socket" << i << "/CoreC0StateResidency?";
if (s == c.str()) {
cout << "core C0-state residency for CPU package " << i << "\t0\t\t%\n";
}
}
for (uint32 i = 0; i < counters.getNumSockets(); ++i) {
stringstream c;
c << "Socket" << i << "/CoreC3StateResidency?";
if (s == c.str()) {
cout << "core C3-state residency for CPU package " << i << "\t0\t\t%\n";
}
}
for (uint32 i = 0; i < counters.getNumSockets(); ++i) {
stringstream c;
c << "Socket" << i << "/CoreC6StateResidency?";
if (s == c.str()) {
cout << "core C6-state residency for CPU package " << i << "\t0\t\t%\n";
}
}
for (uint32 i = 0; i < counters.getNumSockets(); ++i) {
stringstream c;
c << "Socket" << i << "/CoreC7StateResidency?";
if (s == c.str()) {
cout << "core C7-state residency for CPU package " << i << "\t0\t\t%\n";
}
}
for (uint32 i = 0; i < counters.getNumSockets(); ++i) {
stringstream c;
c << "Socket" << i << "/PackageC2StateResidency?";
if (s == c.str()) {
cout << "package C2-state residency for CPU package " << i << "\t0\t\t%\n";
}
}
for (uint32 i = 0; i < counters.getNumSockets(); ++i) {
stringstream c;
c << "Socket" << i << "/PackageC3StateResidency?";
if (s == c.str()) {
cout << "package C3-state residency for CPU package " << i << "\t0\t\t%\n";
}
}
for (uint32 i = 0; i < counters.getNumSockets(); ++i) {
stringstream c;
c << "Socket" << i << "/PackageC6StateResidency?";
if (s == c.str()) {
cout << "package C6-state residency for CPU package " << i << "\t0\t\t%\n";
}
}
for (uint32 i = 0; i < counters.getNumSockets(); ++i) {
stringstream c;
c << "Socket" << i << "/PackageC7StateResidency?";
if (s == c.str()) {
cout << "package C7-state residency for CPU package " << i << "\t0\t\t%\n";
}
}
for (uint32 i = 0; i < counters.getNumSockets(); ++i) {
stringstream c;
c << "Socket" << i << "/BytesWrittenToPMM?";
if (s == c.str()) {
cout << "written to PMM memory on Socket" << i << "\t0\t\tGB\n";
//cout << "CPU" << i << "\tBytes written to memory channel\t0\t1\t GB\n";
}
}
for (uint32 l = 0; l < counters.getQPILinksPerSocket(); ++l) {
for (uint32 i = 0; i < counters.getNumSockets(); ++i) {
stringstream c;
c << "Socket" << i << "/BytesIncomingTo" << xpi << l << "?";
if (s == c.str()) {
//cout << "Socket" << i << "\tBytes incoming to QPI link\t" << l<< "\t\t GB\n";
cout << "incoming to Socket" << i << " " << xpi << " Link" << l << "\t0\t\tGB\n";
}
}
}
{
stringstream c;
c << xpi << "_Traffic?";
if (s == c.str()) {
cout << "Traffic on all " << xpi << " links\t0\t\tGB\n";
}
}
for (uint32 i = 0; i < counters.getNumSockets(); ++i) {
stringstream c;
c << "Socket" << i << "/Frequency?";
if (s == c.str()) {
cout << "Socket" << i << " Frequency\t0\t\tMHz\n";
}
}
for (uint32 i = 0; i < counters.getNumSockets(); ++i) {
stringstream c;
c << "Socket" << i << "/IPC?";
if (s == c.str()) {
cout << "Socket" << i << " IPC\t0\t\t\n";
}
}
for (uint32 i = 0; i < counters.getNumSockets(); ++i) {
stringstream c;
c << "Socket" << i << "/L2CacheHitRatio?";
if (s == c.str()) {
cout << "Socket" << i << " L2 Cache Hit Ratio\t0\t\t\n";
}
}
for (uint32 i = 0; i < counters.getNumSockets(); ++i) {
stringstream c;
c << "Socket" << i << "/L3CacheHitRatio?";
if (s == c.str()) {
cout << "Socket" << i << " L3 Cache Hit Ratio\t0\t\t\n";
}
}
for (uint32 i = 0; i < counters.getNumSockets(); ++i) {
stringstream c;
c << "Socket" << i << "/L2CacheMisses?";
if (s == c.str()) {
cout << "Socket" << i << " L2 Cache Misses\t0\t\t\n";
}
}
for (uint32 i = 0; i < counters.getNumSockets(); ++i) {
stringstream c;
c << "Socket" << i << "/L3CacheMisses?";
if (s == c.str()) {
cout << "Socket" << i << " L3 Cache Misses\t0\t\t\n";
}
}
for (uint32 i = 0; i < counters.getNumSockets(); ++i) {
stringstream c;
c << "Socket" << i << "/L3Occupancy";
if (s == c.str()) {
cout << "Socket" << i << " L3 Cache Occupancy\t0\t\t\n";
}
}
for (uint32 i = 0; i < counters.getNumSockets(); ++i) {
stringstream c;
c << "Socket" << i << "/LocalMemoryBandwidth";
if (s == c.str()) {
cout << "Socket" << i << " Local Memory Bandwidth\t0\t\t\n";
}
}
for (uint32 i = 0; i < counters.getNumSockets(); ++i) {
stringstream c;
c << "Socket" << i << "/RemoteMemoryBandwidth";
if (s == c.str()) {
cout << "Socket" << i << " Remote Memory Bandwidth\t0\t\t\n";
}
}
{
stringstream c;
c << "Frequency?";
if (s == c.str()) {
cout << "Frequency system wide\t0\t\tMhz\n";
}
}
{
stringstream c;
c << "IPC?";
if (s == c.str()) {
cout << "IPC system wide\t0\t\t\n";
}
}
{
stringstream c;
c << "L2CacheHitRatio?";
if (s == c.str()) {
cout << "System wide L2 Cache Hit Ratio\t0\t\t\n";
}
}
{
stringstream c;
c << "L3CacheHitRatio?";
if (s == c.str()) {
cout << "System wide L3 Cache Hit Ratio\t0\t\t\n";
}
}
{
stringstream c;
c << "L2CacheMisses?";
if (s == c.str()) {
cout << "System wide L2 Cache Misses\t0\t\t\n";
}
}
{
stringstream c;
c << "L3CacheMisses?";
if (s == c.str()) {
cout << "System wide L3 Cache Misses\t0\t\t\n";
}
}
{
stringstream c;
c << "L3CacheMisses?";
if (s == c.str()) {
cout << "System wide L3 Cache Misses\t0\t\t\n";
}
}
{
stringstream c;
c << "DRAMEnergy?";
if (s == c.str()) {
cout << "System wide energy consumed by DRAM \t0\t\tJoule\n";
}
}
{
stringstream c;
c << "CPUEnergy?";
if (s == c.str()) {
cout << "System wide energy consumed by CPU packages \t0\t\tJoule\n";
}
}
{
stringstream c;
c << "CoreC0StateResidency?";
if (s == c.str()) {
cout << "System wide core C0-state residency \t0\t\t%\n";
}
}
{
stringstream c;
c << "CoreC3StateResidency?";
if (s == c.str()) {
cout << "System wide core C3-state residency \t0\t\t%\n";
}
}
{
stringstream c;
c << "CoreC6StateResidency?";
if (s == c.str()) {
cout << "System wide core C6-state residency \t0\t\t%\n";
}
}
{
stringstream c;
c << "CoreC7StateResidency?";
if (s == c.str()) {
cout << "System wide core C7-state residency \t0\t\t%\n";
}
}
{
stringstream c;
c << "PackageC2StateResidency?";
if (s == c.str()) {
cout << "System wide package C2-state residency \t0\t\t%\n";
}
}
{
stringstream c;
c << "PackageC3StateResidency?";
if (s == c.str()) {
cout << "System wide package C3-state residency \t0\t\t%\n";
}
}
{
stringstream c;
c << "PackageC6StateResidency?";
if (s == c.str()) {
cout << "System wide package C6-state residency \t0\t\t%\n";
}
}
{
stringstream c;
c << "PackageC7StateResidency?";
if (s == c.str()) {
cout << "System wide package C7-state residency \t0\t\t%\n";
}
}
// sensors
#define OUTPUT_CORE_METRIC(name, function) \
for (uint32 i = 0; i<counters.getNumCores(); ++i) { \
for (uint32 a = 0; a<counters.getNumSockets(); ++a) \
if (a == counters.getSocketId(i)) { \
stringstream c; \
c << "Socket" << a << "/CPU" << i << name; \
if (s == c.str()) { \
cout << function << "\n"; \
} \
} \
}
OUTPUT_CORE_METRIC("/Frequency", (counters.get<double, ::getAverageFrequency>(i) / 1000000))
OUTPUT_CORE_METRIC("/IPC", (counters.get<double, ::getIPC>(i)))
OUTPUT_CORE_METRIC("/L2CacheHitRatio", (counters.get<double, ::getL2CacheHitRatio>(i)))
OUTPUT_CORE_METRIC("/L3CacheHitRatio", (counters.get<double, ::getL3CacheHitRatio>(i)))
OUTPUT_CORE_METRIC("/L2CacheMisses", (counters.get<uint64, ::getL2CacheMisses>(i)))
OUTPUT_CORE_METRIC("/L3CacheMisses", (counters.get<uint64, ::getL3CacheMisses>(i)))
OUTPUT_CORE_METRIC("/L3Occupancy", (counters.get<uint64, ::getL3CacheOccupancy>(i)))
OUTPUT_CORE_METRIC("/LocalMemoryBandwidth", (counters.get<uint64, ::getLocalMemoryBW>(i)))
OUTPUT_CORE_METRIC("/RemoteMemoryBandwidth", (counters.get<uint64, ::getRemoteMemoryBW>(i)))
OUTPUT_CORE_METRIC("/CoreC0StateResidency", (counters.get<double, ::getCoreCStateResidency>(0, i) * 100.))
OUTPUT_CORE_METRIC("/CoreC3StateResidency", (counters.get<double, ::getCoreCStateResidency>(3, i) * 100.))
OUTPUT_CORE_METRIC("/CoreC6StateResidency", (counters.get<double, ::getCoreCStateResidency>(6, i) * 100.))
OUTPUT_CORE_METRIC("/CoreC7StateResidency", (counters.get<double, ::getCoreCStateResidency>(7, i) * 100.))
OUTPUT_CORE_METRIC("/ThermalHeadroom", (counters.get<int32, ::getThermalHeadroom>(i)))
#define OUTPUT_SOCKET_METRIC(name, function) \
for (uint32 i = 0; i<counters.getNumSockets(); ++i) { \
stringstream c; \
c << "Socket" << i << name; \
if (s == c.str()) { \
cout << function << "\n"; \
} \
}
OUTPUT_SOCKET_METRIC("/DRAMEnergy", (counters.getSocket<double, ::getDRAMConsumedJoules>(i)))
OUTPUT_SOCKET_METRIC("/CPUEnergy", (counters.getSocket<double, ::getConsumedJoules>(i)))
OUTPUT_SOCKET_METRIC("/CoreC0StateResidency", (counters.getSocket<double, ::getCoreCStateResidency>(0, i) * 100.))
OUTPUT_SOCKET_METRIC("/CoreC3StateResidency", (counters.getSocket<double, ::getCoreCStateResidency>(3, i) * 100.))
OUTPUT_SOCKET_METRIC("/CoreC6StateResidency", (counters.getSocket<double, ::getCoreCStateResidency>(6, i) * 100.))
OUTPUT_SOCKET_METRIC("/CoreC7StateResidency", (counters.getSocket<double, ::getCoreCStateResidency>(7, i) * 100.))
OUTPUT_SOCKET_METRIC("/PackageC2StateResidency", (counters.getSocket<double, ::getPackageCStateResidency>(2, i) * 100.))
OUTPUT_SOCKET_METRIC("/PackageC3StateResidency", (counters.getSocket<double, ::getPackageCStateResidency>(3, i) * 100.))
OUTPUT_SOCKET_METRIC("/PackageC6StateResidency", (counters.getSocket<double, ::getPackageCStateResidency>(6, i) * 100.))
OUTPUT_SOCKET_METRIC("/PackageC7StateResidency", (counters.getSocket<double, ::getPackageCStateResidency>(7, i) * 100.))
OUTPUT_SOCKET_METRIC("/ThermalHeadroom", (counters.getSocket<int32, ::getThermalHeadroom>(i)))
OUTPUT_SOCKET_METRIC("/BytesReadFromMC", (double(counters.getSocket<uint64, ::getBytesReadFromMC>(i)) / 1024 / 1024 / 1024))
OUTPUT_SOCKET_METRIC("/BytesWrittenToMC", (double(counters.getSocket<uint64, ::getBytesWrittenToMC>(i)) / 1024 / 1024 / 1024))
OUTPUT_SOCKET_METRIC("/BytesReadFromPMM", (double(counters.getSocket<uint64, ::getBytesReadFromPMM>(i)) / 1024 / 1024 / 1024))
OUTPUT_SOCKET_METRIC("/BytesWrittenToPMM", (double(counters.getSocket<uint64, ::getBytesWrittenToPMM>(i)) / 1024 / 1024 / 1024))
OUTPUT_SOCKET_METRIC("/Frequency", (counters.getSocket<double, ::getAverageFrequency>(i) / 1000000))
OUTPUT_SOCKET_METRIC("/IPC", (counters.getSocket<double, ::getIPC>(i)))
OUTPUT_SOCKET_METRIC("/L2CacheHitRatio", (counters.getSocket<double, ::getL2CacheHitRatio>(i)))
OUTPUT_SOCKET_METRIC("/L3CacheHitRatio", (counters.getSocket<double, ::getL3CacheHitRatio>(i)))
OUTPUT_SOCKET_METRIC("/L2CacheMisses", (counters.getSocket<uint64, ::getL2CacheMisses>(i)))
OUTPUT_SOCKET_METRIC("/L3CacheMisses", (counters.getSocket<uint64, ::getL3CacheMisses>(i)))
OUTPUT_SOCKET_METRIC("/L3Occupancy", (counters.getSocket<uint64, ::getL3CacheOccupancy>(i)))
OUTPUT_SOCKET_METRIC("/LocalMemoryBandwidth", (counters.getSocket<uint64, ::getLocalMemoryBW>(i)))
OUTPUT_SOCKET_METRIC("/RemoteMemoryBandwidth", (counters.getSocket<uint64, ::getRemoteMemoryBW>(i)))
for (uint32 l = 0; l < counters.getQPILinksPerSocket(); ++l) {
for (uint32 i = 0; i < counters.getNumSockets(); ++i) {
stringstream c;
c << "Socket" << i << "/BytesIncomingTo" << xpi << l;
if (s == c.str()) {
cout << double(counters.getSocket<uint64, ::getIncomingQPILinkBytes>(i, l)) / 1024 / 1024 / 1024 << "\n";
}
}
}
#define OUTPUT_SYSTEM_METRIC(name, function) \
{ \
stringstream c; \
c << name; \
if (s == c.str()) { \
cout << function << "\n"; \
} \
}
OUTPUT_SYSTEM_METRIC("DRAMEnergy", (counters.getSystem<double, ::getDRAMConsumedJoules>()))
OUTPUT_SYSTEM_METRIC("CPUEnergy", (counters.getSystem<double, ::getConsumedJoules>()))
OUTPUT_SYSTEM_METRIC("CoreC0StateResidency", (counters.getSystem<double, ::getCoreCStateResidency>(0) * 100.))
OUTPUT_SYSTEM_METRIC("CoreC3StateResidency", (counters.getSystem<double, ::getCoreCStateResidency>(3) * 100.))
OUTPUT_SYSTEM_METRIC("CoreC6StateResidency", (counters.getSystem<double, ::getCoreCStateResidency>(6) * 100.))
OUTPUT_SYSTEM_METRIC("CoreC7StateResidency", (counters.getSystem<double, ::getCoreCStateResidency>(7) * 100.))
OUTPUT_SYSTEM_METRIC("PackageC2StateResidency", (counters.getSystem<double, ::getPackageCStateResidency>(2) * 100.))
OUTPUT_SYSTEM_METRIC("PackageC3StateResidency", (counters.getSystem<double, ::getPackageCStateResidency>(3) * 100.))
OUTPUT_SYSTEM_METRIC("PackageC6StateResidency", (counters.getSystem<double, ::getPackageCStateResidency>(6) * 100.))
OUTPUT_SYSTEM_METRIC("PackageC7StateResidency", (counters.getSystem<double, ::getPackageCStateResidency>(7) * 100.))
OUTPUT_SYSTEM_METRIC("Frequency", (double(counters.getSystem<double, ::getAverageFrequency>()) / 1000000))
OUTPUT_SYSTEM_METRIC("IPC", (double(counters.getSystem<double, ::getIPC>())))
OUTPUT_SYSTEM_METRIC("L2CacheHitRatio", (double(counters.getSystem<double, ::getL2CacheHitRatio>())))
OUTPUT_SYSTEM_METRIC("L3CacheHitRatio", (double(counters.getSystem<double, ::getL3CacheHitRatio>())))
OUTPUT_SYSTEM_METRIC("L2CacheMisses", (double(counters.getSystem<uint64, ::getL2CacheMisses>())))
OUTPUT_SYSTEM_METRIC("L3CacheMisses", (double(counters.getSystem<uint64, ::getL3CacheMisses>())))
OUTPUT_SYSTEM_METRIC(std::string(xpi + std::string("_Traffic")),
(double(counters.getSystem<uint64, ::getAllIncomingQPILinkBytes>()) / 1024 / 1024 / 1024))
// exit
if (s == "quit" || s == "exit" || s == "") {
break;
}
cout << "ksysguardd> ";
}
return 0;
}
|