我编写了以下代码并尝试使用openmp并行化它。但我编译程序并最终导致错误无效控制谓词错误
//它也在#pragma omp atomic
中显示错误int x;
//int currentSampleCount=0; //TODO: Sahil. removed while merging projectdockwidget
#pragma omp parallel for default(shared)
for (int i=1;x==0;i++) {
// cerr <<"while loop";
// cerr <<xml.atEnd();
// #pragma omp atomic
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() );
}
x =xml.atEnd();
}