8#include <QHyodaMachine.h>
15static double rawStringToDouble(QString);
16static unsigned long long rawStringToULongLong(QString);
28, has_been_broadcasted(false)
32, iceWidthHeight(0x04000300ul)
33, gdb(new
QHyodaGdb(this,machine,0x100007Ful,tcpPort,tcpPyld))
34, gdbserver(new QProcess())
38, arcane_variables_names(new QStringList())
40 qDebug() <<
"\33[36m[QHyodaJob::QHyodaJob] NEW @"<<machine->localHostName<<
"\33[m";
44 jobSplitter->setSizes(QList<int>()<<128<<1024);
46 gdbSplitter->setSizes(QList<int>()<<128<<1024);
49 toolsSplitter->setSizes(QList<int>()<<512<<256);
50 topToolsSplitter->setSizes(QList<int>()<<512<<512);
51 bottomToolsSplitter->setSizes(QList<int>()<<512<<512);
54 topRightTools->hide();
55 bottomLeftTools->hide();
56 bottomRightTools->hide();
58 host=machine->localHostName;
60 topLeftTools->setJob(
this);
61 topRightTools->setJob(
this);
62 bottomLeftTools->setJob(
this);
63 bottomRightTools->setJob(
this);
66 connect(tackButton,SIGNAL(clicked()),
this,SLOT(tack_slot()));
67 connect(startButton,SIGNAL(clicked()),
this,SLOT(start_slot()));
68 connect(stepButton,SIGNAL(clicked()),
this,SLOT(step_slot()));
69 connect(stopButton,SIGNAL(clicked()),
this,SLOT(stop_slot()));
71 connect(matrixButton,SIGNAL(clicked()),
this,SLOT(matrix_slot()));
72 connect(logButton,SIGNAL(clicked()),
this,SLOT(log_slot()));
73 connect(srcButton,SIGNAL(clicked()),
this,SLOT(src_slot()));
74 connect(meshButton,SIGNAL(clicked()),
this,SLOT(mesh_slot()));
75 connect(cellButton,SIGNAL(clicked()),
this,SLOT(cell_slot()));
76 connect(papiButton,SIGNAL(clicked()),
this,SLOT(papi_slot()));
79 qFatal(
"\33[36m[QHyodaJob::QHyodaJob] Could not allocate data space for hook\33[m");
82 bottomLeftTools->show();
83 bottomLeftTools->add_log();
99QHyodaJob::~QHyodaJob(
void){
100 qDebug() <<
"\33[36m[QHyodaJob::~QHyodaJob] DELETE\33[m";
104 delete arcane_variables_names;
112void QHyodaJob::gdbserver_hook(
void){
113 gdbServerGroupBox->setEnabled(
true);
114 qDebug() <<
"\33[36m[QHyodaJob::gdbserver_hook] #### LOCAL gdbserver ####\33[m";
116 QString command(
"/usr/bin/gdbserver");
117 QStringList args = QStringList() <<
"--attach"
120 gdbserver->setProcessChannelMode(QProcess::MergedChannels);
121 connect(gdbserver,SIGNAL(readyReadStandardOutput()),
this,SLOT(gdbserver_slot()));
122 gdbserver->start(command, args);
123 if (!gdbserver->waitForStarted())
124 qFatal(
"\33[36m[QHyodaJob::gdbserver_hook] NOT started!\33[m");
133void QHyodaJob::gdbserver_slot(
void){
134 QString output=QString(gdbserver->readAllStandardOutput());
136 if (output.endsWith(
'\n'))
137 output.replace(output.length()-1,1,
' ');
138 gdbServerTextEdit->append(output);
139 if (output.contains(
"Listening")){
140 qDebug() <<
"\33[33m[QHyodaJob::gdbserver_slot] Launching gdb_hook\33[m";
149void QHyodaJob::gdb_hook(
void){
150 gdb->cmdline=(has_been_broadcasted==
true)?broadcasted_cmdline:cmdline;
151 qDebug() <<
"\33[36m[QHyodaJob::gdb_hook] Now launching\33[m";
153 gdbGroupBox->setEnabled(
true);
154 jobButtons->setEnabled(
true);
160void QHyodaJob::stop_slot(
void){
161 gdb->state=QHyodaGdb::Interrupt;
162 startButton->setEnabled(
true);
163 stepButton->setEnabled(
true);
166void QHyodaJob::step_slot(
void){
167 stepButton->setEnabled(
false);
168 startButton->setEnabled(
false);
169 tackButton->setEnabled(
false);
170 if (gdb->state!=QHyodaGdb::Step)
171 gdb->state=QHyodaGdb::Step;
173 gdb->enqueue(
"-exec-continue");
176void QHyodaJob::start_slot(
void){
177 gdb->state=QHyodaGdb::Continue;
178 gdb->enqueue(
"-break-disable 3");
179 gdb->enqueue(
"-break-disable 4");
180 gdb->enqueue(
"-exec-continue");
181 tackButton->setEnabled(
true);
182 startButton->setEnabled(
false);
185void QHyodaJob::tack_slot(
void){
186 tack_toggle=(tack_toggle+1)%2;
188 gdb->state=QHyodaGdb::Untack;
189 arcaneCommonVariablesGroupBox->setEnabled(
false);
191 stopButton->setEnabled(
false);
192 stepButton->setEnabled(
false);
194 gdb->state=QHyodaGdb::Retack;
195 gdb->enqueue(
"-exec-interrupt");
196 arcaneCommonVariablesGroupBox->setEnabled(
true);
198 stopButton->setEnabled(
true);
199 stepButton->setEnabled(
true);
205void QHyodaJob::log_slot(
void){
207 if (bottomLeftTools->isHidden())
208 bottomLeftTools->show();
210 bottomLeftTools->hide();
212void QHyodaJob::cell_slot(
void){
213 qDebug() <<
"\33[36m[QHyodaJob::cell_slot]\33[m";
214 if (!bottomRightTools->cell) bottomRightTools->add_cell();
215 bottomRightTools->show();
219void QHyodaJob::mesh_slot(
void){
220 qDebug() <<
"\33[36m[QHyodaJob::mesh_slot]\33[m";
221 if (!topRightTools->mesh) topRightTools->add_mesh();
222 if (topRightTools->isHidden()) topRightTools->show();
223 else topRightTools->hide();
226void QHyodaJob::src_slot(
void){
227 qDebug() <<
"\33[36m[QHyodaJob::src_slot]\33[m";
228 topLeftTools->show();
229 topLeftTools->add_src();
232void QHyodaJob::matrix_slot(
void){
233 qDebug() <<
"\33[36m[QHyodaJob::matrix_slot]\33[m";
234 topLeftTools->show();
235 topLeftTools->add_matrix();
238void QHyodaJob::papi_slot(
void){
239 if (!bottomRightTools->papi) bottomRightTools->add_papi();
240 if (bottomRightTools->isHidden()) bottomRightTools->show();
241 else bottomRightTools->hide();
249 qDebug() <<
"\33[36m[QHyodaJob::detach] Queuing Detach and interrupting job\33[m";
250 gdb->state=QHyodaGdb::Detach;
251 gdb->enqueue(
"-exec-interrupt");
259 qDebug() <<
"\33[36m[QHyodaJob::quit]\33[m";
260 gdb->process->close();
261 if (gdb->process->state()!=QProcess::NotRunning)
262 qDebug() <<
"\33[36m[QHyodaJob::quit] GDB NOT closed\33[m";
264 qDebug() <<
"\33[36m[QHyodaJob::quit] GDB closed\33[m";
267 if (gdbserver->state()!=QProcess::NotRunning)
268 qDebug() <<
"\33[36m[QHyodaJob::quit] GDBSERVER NOT closed\33[m";
270 qDebug() <<
"\33[36m[QHyodaJob::quit] GDBSERVER closed\33[m";
273 machine->hyoda->quit();
280void QHyodaJob::refresh_common_variables(
const QStringList &splitted_output){
283 quint64 global_iteration=rawStringToULongLong(splitted_output.at(17));
284 globalIterationLine->setText(QString(
"%1").arg(global_iteration));
286 double global_time=rawStringToDouble(splitted_output.at(19));
287 globalTimeLine->setText(QString(
"%1").arg(global_time));
289 double global_deltat=rawStringToDouble(splitted_output.at(21));
290 globalDeltaTLine->setText(QString(
"%1").arg(global_deltat));
292 double global_cpu_time=rawStringToDouble(splitted_output.at(23));
293 globalCPUTimeLine->setText(QString(
"%1").arg(global_cpu_time));
295 quint64 mesh_total_nb_cell=rawStringToULongLong(splitted_output.at(25));
296 if (mesh_total_nb_cell!=data->mesh_total_nb_cell){
297 data->mesh_total_nb_cell=mesh_total_nb_cell;
300 unsigned long long got_target_cell_nb_nodes=rawStringToULongLong(splitted_output.at(31));
311static double rawStringToDouble(QString qStr){
312 const char *s=qStr.toLocal8Bit().constData();
314 sscanf(s,
"%llx", (
unsigned long long *)&ret);
318static unsigned long long rawStringToULongLong(QString qStr){
319 const char *s=qStr.toLocal8Bit().constData();
320 unsigned long long ret=0;
321 sscanf(s,
"%llx", &ret);