1
我正在做一些图像处理,并有一个嵌套for循环。我想要使用OpenMP实现多处理。 for循环看起来像这样,我已经添加了pragma标签并声明了一些私有变量。OpenMP:嵌套for循环,几乎没有任何执行时间的差异
int a,b,j, idx;
#pragma omp parallel for private(b,j,sumG,sumGI)
for(a = 0; a < ny; ++a)
{
for(b = 0; b < nx; ++b)
{
idx = a*ny+b;
if (imMask[idx] == 0)
{
Wshw[idx] = 0;
continue;
}
sumG = 0;
sumGI = 0;
for(j = a; j < ny; ++j)
{
sumG += shadowM[j-a];
sumGI += shadowM[j-a] * imBlurred[nx*j + b];
}
Wshw[idx] = sumGI/sumG;
}
}
两个NX的大小和纽约大,我认为,使用OpenMP,我会得到执行时间的下降减少,取而代之的是几乎没有区别。当我实现多线程时,我会做错什么?
您还需要使'idx'专用。 –