Comment pouvons-nous utiliser tous les processeurs à la fois pour exécuter le code en dessous du code openmp?Comment faire en tant que traitement parallèle en utilisant le drapeau OpenMP?
Si je suis en train de convertir en boucle en boucle en utilisant for(;!xml.atEnd();)
il affiche l'erreur:
need to initialisation and increment/decrements
//Need parallel processing for this code.
while (!xml.atEnd()) {
// cerr <<"while loop";
xml.readNext();
if (xml.isStartElement()) {
currentXmlElement = xml.name();
if (xml.name() == "sample") {
QString fname = xml.attributes().value("filename").toString();
QString sname = xml.attributes().value("name").toString();
QString setname = xml.attributes().value("setName").toString();
QString sampleOrder = xml.attributes().value("sampleOrder").toString();
QString isSelected = xml.attributes().value("isSelected").toString();
//_mainwindow->setStatusText(tr("Loading sample: %1").arg(sname));
//_mainwindow->setProgressBar(tr("Loading Sample Number %1").arg(++currentSampleCount),currentSampleCount,currentSampleCount+1);
bool checkLoaded=false;
Q_FOREACH(mzSample* loadedFile, _mainwindow->getSamples()) {
if (QString(loadedFile->fileName.c_str())== fname) checkLoaded=true;
}
if(checkLoaded == true) continue; // skip files that have been loaded already
// #pragma omp critical {
qDebug() << "Checking:" << fname;
QFileInfo sampleFile(fname);
if (!sampleFile.exists()) {
Q_FOREACH(QString path, pathlist) {
fname= path + QDir::separator() + sampleFile.fileName();
qDebug() << "Checking if exists:" << fname;
if (sampleFile.exists()) break;
}
}
if (!fname.isEmpty()) {
// mzFileIO* fileLoader = new mzFileIO(this);
// fileLoader->setMainWindow(_mainwindow);
// mzSample* sample = fileLoader->loadSample(fname);
// delete(fileLoader);
mzSample* sample = _mainwindow->fileLoader->loadSample(fname);
if (sample) {
_mainwindow->addSample(sample);
currentSample=sample;
if (!sname.isEmpty()) sample->sampleName = sname.toStdString();
if (!setname.isEmpty()) sample->setSetName(setname.toStdString());
if (!sampleOrder.isEmpty()) sample->setSampleOrder(sampleOrder.toInt());
if (!isSelected.isEmpty()) sample->isSelected = isSelected.toInt();
} else {
currentSample=NULL;
}
}
}
//change sample color
if (xml.name() == "color" && currentSample) {
currentSample->color[0] = xml.attributes().value("red").toString().toDouble();
currentSample->color[1] = xml.attributes().value("blue").toString().toDouble();
currentSample->color[2] = xml.attributes().value("green").toString().toDouble();
currentSample->color[3] = xml.attributes().value("alpha").toString().toDouble();
}
//polynomialAlignmentTransformation vector
if (xml.name() == "polynomialAlignmentTransformation" && currentSample) {
vector<double>transform;
Q_FOREACH(QXmlStreamAttribute coef, xml.attributes()) {
double coefValue =coef.value().toString().toDouble();
transform.push_back(coefValue);
}
qDebug() << "polynomialAlignmentTransformation: "; printF(transform);
currentSample->polynomialAlignmentTransformation = transform;
currentSample->saveOriginalRetentionTimes();
currentSample->applyPolynomialTransform();
}
}
if (xml.isCharacters() && currentXmlElement == "projectDescription") {
projectDescription.append(xml.text());
}
}
Réduction de l'indentation –