Use ParallelFor instead of ParallelForRange

better readability and no performance difference (if using
        NETGEN_LAMBDA_INLINE)
This commit is contained in:
Matthias Hochsteger 2019-10-09 09:57:37 +02:00
parent 95df0ea73e
commit 6e5d806d92

View File

@ -7,11 +7,6 @@
namespace netgen
{
using ngcore::ParallelForRange;
class trionedge
{
public:
@ -191,15 +186,12 @@ namespace netgen
if(faceindex==0)
{
seia.SetSize(mesh.GetNSE());
ParallelForRange( Range(seia), [&] (auto myrange)
{
for (auto i : myrange)
ParallelFor( Range(seia), [&] (auto i) NETGEN_LAMBDA_INLINE
{
SurfaceElementIndex sei(i);
seia[i] = sei;
if (mesh[sei].GetNP() != 3)
mixed = true;
}
});
}
else
@ -225,28 +217,22 @@ namespace netgen
if(faceindex == 0)
{
ParallelForRange( Range(pangle), [&] (auto myrange)
ParallelFor( Range(pangle), [&] (auto i) NETGEN_LAMBDA_INLINE
{
for (auto i : myrange)
pangle[i] = 0.0;
});
}
else
{
ParallelForRange( Range(seia), [&] (auto myrange)
{
for (auto i : myrange)
ParallelFor( Range(seia), [&] (auto i) NETGEN_LAMBDA_INLINE
{
const Element2d & sel = mesh[seia[i]];
for (int j = 0; j < 3; j++)
pangle[sel[j]] = 0.0;
}
});
}
ParallelForRange( Range(seia), [&] (auto myrange)
{
for (auto i : myrange)
ParallelFor( Range(seia), [&] (auto i) NETGEN_LAMBDA_INLINE
{
const Element2d & sel = mesh[seia[i]];
for (int j = 0; j < 3; j++)
@ -259,12 +245,9 @@ namespace netgen
mesh[sel[(j+2)%3]] - mesh[sel[j]]));
}
}
}
});
ParallelForRange( Range(seia), [&] (auto myrange)
{
for (auto i : myrange)
ParallelFor( Range(seia), [&] (auto i) NETGEN_LAMBDA_INLINE
{
const Element2d & sel = mesh[seia[i]];
for (int j = 0; j < 3; j++)
@ -277,12 +260,9 @@ namespace netgen
if (pangle[pi] >= minangle[j])
pdef[pi] = -1-j;
}
}
});
ParallelForRange( Range(seia), [&pdef, &neighbors, &mesh, &seia, &elements_on_node] (auto myrange)
{
for (auto i : myrange)
ParallelFor( Range(seia), [&pdef, &neighbors, &mesh, &seia, &elements_on_node] (auto i) NETGEN_LAMBDA_INLINE
{
auto sei = seia[i];
for (PointIndex pi : mesh[sei].template PNums<3>())
@ -324,7 +304,6 @@ namespace netgen
}
}
}
}
});
@ -343,17 +322,15 @@ namespace netgen
while (!done && t >= 2)
{
cnt = 0;
ParallelForRange( Range(seia), [&] (auto myrange)
{
for (auto i : myrange)
ParallelFor( Range(seia), [&] (auto i) NETGEN_LAMBDA_INLINE
{
SurfaceElementIndex t1 = seia[i];
if (mesh[t1].IsDeleted())
continue;
return;
if (mesh[t1].GetIndex() != faceindex)
continue;
return;
if (multithread.terminate)
throw NgException ("Meshing stopped");
@ -361,7 +338,6 @@ namespace netgen
for (int o1 = 0; o1 < 3; o1++)
if(EdgeSwapping(mesh, usemetric, neighbors, swapped, t1, o1, t, pdef, true))
improvement_candidates[cnt++]= std::make_pair(t1,o1);
}
});
auto elements_with_improvement = improvement_candidates.Range(cnt.load());