Monday, April 30, 2012

Parallel delaunay triangulation naive algorithm

The following code(Pg.187,Computational Geom in C by Rourke) takes same time to run serially as well as in parallel(2 proc).
Please help me identify the problem.
Here's the parallel portion



int chunk;
chunk=10;
#pragma omp parallel private(i,j,k,xn,yn,zn)
{
#pragma omp for schedule(static,chunk)
for(i=0;i<n-2;i++)
{
for(j=i+1;j<n;j++)
for(k=i+1;k<n;k++)
if(j!=k)
{
xn=(y[j]-y[i])*(z[k]-z[i])-(y[k]-y[i])*(z[j]-z[i]);
yn=(x[k]-x[i])*(z[j]-z[i])-(x[j]-x[i])*(z[k]-z[i]);
zn=(x[j]-x[i])*(y[k]-y[i])-(x[k]-x[i])*(y[j]-y[i]);
if(flag=(zn<0))
for(m=0;m<n;m++)
flag=flag && ((x[m]-x[i])*xn + (y[m]-y[i])*yn + (z[m]-z[i])*zn <=0);
if (flag)
printf("%d\t%d\t%d\n",i,j,k);
}
}
}




No comments:

Post a Comment