ImProcCoordinator::updateVectorscope(): parallelize loops

This commit is contained in:
Ingo Weyrich 2020-08-16 11:46:17 +02:00
parent 3af822b6f7
commit 9e040b3bc2
2 changed files with 67 additions and 19 deletions

View File

@ -211,6 +211,24 @@ public:
} }
} }
array2D<T>& operator+=(const array2D<T>& rhs)
{
if (rhs.getWidth() == this->getWidth() && rhs.getHeight() == this->getHeight()) {
for (int i = 0; i < getHeight(); ++i) {
#ifdef _OPENMP
#pragma omp simd
#endif
for (int j = 0; j < getWidth(); ++j) {
rows[i][j] += rhs[i][j];
}
}
}
return *this;
}
int getWidth() const int getWidth() const
{ {
return width; return width;

View File

@ -1863,6 +1863,14 @@ BENCHFUN
vectorscopeScale = (x2 - x1) * (y2 - y1); vectorscopeScale = (x2 - x1) * (y2 - y1);
if (hListener->vectorscopeType() == 0) { // HS if (hListener->vectorscopeType() == 0) { // HS
#ifdef _OPENMP
#pragma omp parallel
#endif
{
array2D<int> vectorscopeThr(size, size, ARRAY2D_CLEAR_DATA);
#ifdef _OPENMP
#pragma omp for nowait
#endif
for (int i = y1; i < y2; ++i) { for (int i = y1; i < y2; ++i) {
int ofs = (i * pW + x1) * 3; int ofs = (i * pW + x1) * 3;
for (int j = x1; j < x2; ++j) { for (int j = x1; j < x2; ++j) {
@ -1875,24 +1883,46 @@ BENCHFUN
const int col = s * sincosval.y * (size / 2) + size / 2; const int col = s * sincosval.y * (size / 2) + size / 2;
const int row = s * sincosval.x * (size / 2) + size / 2; const int row = s * sincosval.x * (size / 2) + size / 2;
if (col >= 0 && col < size && row >= 0 && row < size) { if (col >= 0 && col < size && row >= 0 && row < size) {
vectorscope[row][col]++; vectorscopeThr[row][col]++;
} }
} }
} }
#ifdef _OPENMP
#pragma omp critical
#endif
{
vectorscope += vectorscopeThr;
}
}
} else if (hListener->vectorscopeType() == 1) { // CH } else if (hListener->vectorscopeType() == 1) { // CH
const std::unique_ptr<float[]> a(new float[vectorscopeScale]); const std::unique_ptr<float[]> a(new float[vectorscopeScale]);
const std::unique_ptr<float[]> b(new float[vectorscopeScale]); const std::unique_ptr<float[]> b(new float[vectorscopeScale]);
const std::unique_ptr<float[]> L(new float[vectorscopeScale]); const std::unique_ptr<float[]> L(new float[vectorscopeScale]);
ipf.rgb2lab(*workimg, x1, y1, x2 - x1, y2 - y1, L.get(), a.get(), b.get(), params->icm); ipf.rgb2lab(*workimg, x1, y1, x2 - x1, y2 - y1, L.get(), a.get(), b.get(), params->icm);
#ifdef _OPENMP
#pragma omp parallel
#endif
{
array2D<int> vectorscopeThr(size, size, ARRAY2D_CLEAR_DATA);
#ifdef _OPENMP
#pragma omp for nowait
#endif
for (int i = y1; i < y2; ++i) { for (int i = y1; i < y2; ++i) {
for (int j = x1, ofs_lab = (i - y1) * (x2 - x1); j < x2; ++j, ++ofs_lab) { for (int j = x1, ofs_lab = (i - y1) * (x2 - x1); j < x2; ++j, ++ofs_lab) {
const int col = (size / 96000.f) * a[ofs_lab] + size / 2; const int col = (size / 96000.f) * a[ofs_lab] + size / 2;
const int row = (size / 96000.f) * b[ofs_lab] + size / 2; const int row = (size / 96000.f) * b[ofs_lab] + size / 2;
if (col >= 0 && col < size && row >= 0 && row < size) { if (col >= 0 && col < size && row >= 0 && row < size) {
vectorscope[row][col]++; vectorscopeThr[row][col]++;
} }
} }
} }
#ifdef _OPENMP
#pragma omp critical
#endif
{
vectorscope += vectorscopeThr;
}
}
} }
} }