Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
QHyodaPapi.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7//#include <QtGui>
8#include <QtWidgets>
9
10#include "QHyoda.h"
11#include "QHyodaPapi.h"
12#include "QHyodaTool.h"
13
14#include "ui_hyodaPapi.h"
15
16#ifdef __GNUG__
17#include <cxxabi.h>
18#endif
19
20// tput reset && pkill gdbserver && pkill mpiexec && pkill mono && pkill ctest && pkill glvis ; m hyoda1
21
22
23// ****************************************************************************
24// * Constructeur/Destructeur
25// ****************************************************************************
26QHyodaPapi::QHyodaPapi(QHyodaTool *QTool):tool(QTool){
27 qDebug() << "[QHyodaPapi::QHyodaPapi]";
28 setupUi(this);
29}
30
31QHyodaPapi::~QHyodaPapi(){
32 qDebug() << "[QHyodaPapi::~QHyodaPapi]";
33}
34
35
36// ****************************************************************************
37// * Initialisation des progress bar et group boxes
38// ****************************************************************************
39void QHyodaPapi::ini(){
40 QVBoxLayout *profilerLayout = tool->papi->profilerLayout;
41 if (profilerLayout->count()==0){
42 for(int i=0;i<max_nb_func_to_profile;i+=1){
43 QGroupBox *box = new QGroupBox;
44 QVBoxLayout *vbox = new QVBoxLayout;
45 QProgressBar *bar = new QProgressBar;
46 vbox->addWidget(bar);
47 box->setLayout(vbox);
48 profilerLayout->addWidget(box);
49 }
50 }
51}
52
53
54// ****************************************************************************
55// * Update et lancement de l'init si besoin
56// ****************************************************************************
57void QHyodaPapi::update(QByteArray *read){
58 QVBoxLayout *profilerLayout = tool->papi->profilerLayout;
59
60 // Test s'il faut lancer l'init
61 if (profilerLayout->count()==0) ini();
62
63 //qDebug() << "\n[QHyodaPapi::update]";
64
65 // Et on dépile le TCP
66 const char *data=read->data();
67 const qint64 *pkt=(qint64*)&data[0];
68 const qint64 size=pkt[0];
69 const int capacity=read->capacity();
70
71 //qDebug() << "[QHyodaPapi::update] capacity: "<< capacity;
72 //printf("[QHyodaPapi::update] size %d\n",size);
73
74 if (capacity!=size<<3)
75 qFatal("[QHyodaPapi::update] capacity missmatch size !");
76
77 const qint64 total_event = pkt[1];
78 const qint64 total_fp = pkt[2];
79 const qint64 m_period = pkt[3];
80 const qint64 index = pkt[4];
81
82 //printf("[QHyodaPapi::update] total_event %d\n",total_event);
83 //printf("[QHyodaPapi::update] total_fp %d\n",total_fp);
84 //printf("[QHyodaPapi::update] m_period %d\n",m_period);
85 //qDebug() << "[QHyodaPapi::update] index"<<index;
86
87 int of7=5;
88 char demangled_func_name[8192];
89 for(int i=0;i<index;i+=1){
90 const qint64 nb_event = pkt[of7++];
91 const qint64 total_percent = pkt[of7++];
92 const qint64 m_counters_0 = pkt[of7++]; // PAPI_TOT_CYC Total cycles
93 const qint64 m_counters_1 = pkt[of7++]; // PAPI_RES_STL Cycles stalled on any resource
94 const qint64 m_counters_2 = pkt[of7++]; // PAPI_FP_INS Floating point instructions
95 const qint64 mx = pkt[of7++];
96 const char* func_name = (char*)&pkt[of7];
97
98 //qDebug() <<"[QHyodaPapi::update] nb_event %d\n", nb_event);
99 //printf("[QHyodaPapi::update] Total cycles %d\n", m_counters_0);
100 //printf("[QHyodaPapi::update] Stalled cycles %d\n", m_counters_1);
101 //printf("[QHyodaPapi::update] FP instructions %d\n", m_counters_2);
102 //qDebug() << "[QHyodaPapi::update] mx="<<mx<<", func_name="<<func_name;
103
104 size_t len = 8192;
105 int dstatus = 0;
106 const char* buf = 0;
107#ifdef __GNUG__
108 buf = abi::__cxa_demangle(func_name,demangled_func_name,&len,&dstatus);
109#endif
110 if (!buf) memcpy(&demangled_func_name[0],func_name,strlen(func_name)+1);
111
112 //qDebug() <<"[ProfInfos::getInfos] demangled_func_name="<<demangled_func_name;
113 //printf("[QHyodaPapi::update] func_name %s\n", demangled_func_name);
114
115 QGroupBox *box = static_cast<QGroupBox*>(profilerLayout->itemAt(i)->widget());
116
117 if (box->title() != demangled_func_name) box->setTitle(demangled_func_name);
118
119 QProgressBar *bar = box->findChild<QProgressBar*>();
120 int value = (nb_event*100)/total_event;
121 //qDebug() << "[QHyodaPapi::update] bar min= "<< bar->minimum() << "bar max= "<< bar->maximum();
122 if (bar->value() != value) bar->setValue(value);
123
124 of7+=1+(mx>>3);
125 //qDebug()<<"[ProfInfos::getInfos] nbPktForName="<<(mx>>3);
126
127 // On ne propose que les max_nb_func_to_profile premières fonction max
128 if (i==max_nb_func_to_profile-1){
129 //qDebug() << "[QHyodaPapi::update] max_nb_func_to_profile!, breaking!";
130 break;
131 }
132 }
133 delete read;
134}
Integer len(const char *s)
Retourne la longueur de la chaîne s.