Mercurial > hg > silvet
diff src/Silvet.cpp @ 123:230920148ee5 bqvec-openmp
Simplify omp loop, leaving more to the omp scheduler
author | Chris Cannam |
---|---|
date | Wed, 07 May 2014 11:06:18 +0100 |
parents | c4eae816bdb3 |
children | 450f9987f041 |
line wrap: on
line diff
--- a/src/Silvet.cpp Wed May 07 10:48:58 2014 +0100 +++ b/src/Silvet.cpp Wed May 07 11:06:18 2014 +0100 @@ -411,56 +411,44 @@ int iterations = 12; - int stride = 8; + Grid pitchMatrix(width, vector<double>(processingNotes)); - for (int i = 0; i < width; i += stride) { +#pragma omp parallel for + for (int i = 0; i < width; ++i) { - int chunk = stride; - if (i + chunk > width) { - chunk = width - i; + double sum = 0.0; + for (int j = 0; j < processingHeight; ++j) { + sum += filtered.at(i).at(j); } - vector<vector<double> > pitchSubMatrix - (chunk, vector<double>(processingNotes)); + if (sum < 1e-5) continue; -#pragma omp parallel for - for (int k = 0; k < chunk; ++k) { + EM em(m_hqMode); - double sum = 0.0; - for (int j = 0; j < processingHeight; ++j) { - sum += filtered[i + k][j]; - } - - if (sum < 1e-5) continue; - - EM em(m_hqMode); - for (int j = 0; j < iterations; ++j) { - em.iterate(filtered[i + k].data()); - } - - const double *pitches = em.getPitchDistribution(); - - for (int j = 0; j < processingNotes; ++j) { - pitchSubMatrix[k][j] = pitches[j] * sum; - } + for (int j = 0; j < iterations; ++j) { + em.iterate(filtered.at(i).data()); } - for (int k = 0; k < chunk; ++k) { + const double *pitches = em.getPitchDistribution(); + + for (int j = 0; j < processingNotes; ++j) { + pitchMatrix[i][j] = pitches[j] * sum; + } + } - const vector<double> &pitches = pitchSubMatrix[k]; + for (int i = 0; i < width; ++i) { + + Feature f; + for (int j = 0; j < processingNotes; ++j) { + f.values.push_back(float(pitchMatrix[i][j])); + } + fs[m_pitchOutputNo].push_back(f); - Feature f; - for (int j = 0; j < processingNotes; ++j) { - f.values.push_back(float(pitches[j])); - } - fs[m_pitchOutputNo].push_back(f); + FeatureList noteFeatures = postProcess(pitchMatrix[i]); - FeatureList noteFeatures = postProcess(pitches); - - for (FeatureList::const_iterator fi = noteFeatures.begin(); - fi != noteFeatures.end(); ++fi) { - fs[m_notesOutputNo].push_back(*fi); - } + for (FeatureList::const_iterator fi = noteFeatures.begin(); + fi != noteFeatures.end(); ++fi) { + fs[m_notesOutputNo].push_back(*fi); } }