parallel Cluster update

This commit is contained in:
Matthias Hochsteger 2021-05-12 10:56:34 +02:00
parent db494f4239
commit d1ee6efc14
3 changed files with 15 additions and 13 deletions

View File

@ -16,7 +16,7 @@ namespace netgen
; ;
} }
void AnisotropicClusters :: Update(NgTaskManager tm, NgTracer tracer) void AnisotropicClusters :: Update()
{ {
static Timer timer("clusters"); static Timer timer("clusters");
// static int timer1 = NgProfiler::CreateTimer ("clusters1"); // static int timer1 = NgProfiler::CreateTimer ("clusters1");
@ -81,13 +81,14 @@ namespace netgen
cluster_reps.Elem(nnums[j]) = nnums[j]; cluster_reps.Elem(nnums[j]) = nnums[j];
} }
*/ */
ParallelForRange ngcore::ParallelForRange
(tm, ne, (mesh.VolumeElements().Range(),
[&] (size_t begin, size_t end) [&] (auto myrange)
{ {
NgArray<int> nnums, ednums, fanums; NgArray<int> nnums, ednums, fanums;
for (int i = begin+1; i <= end; i++) for (int i_ : myrange)
{ {
int i = i_+1;
const Element & el = mesh.VolumeElement(i); const Element & el = mesh.VolumeElement(i);
ELEMENT_TYPE typ = el.GetType(); ELEMENT_TYPE typ = el.GetType();
@ -110,7 +111,7 @@ namespace netgen
for (int j = 0; j < nnums.Size(); j++) for (int j = 0; j < nnums.Size(); j++)
cluster_reps.Elem(nnums[j]) = nnums[j]; cluster_reps.Elem(nnums[j]) = nnums[j];
} }
}); }, ngcore::TasksPerThread(4));
// NgProfiler::StopTimer(timer1); // NgProfiler::StopTimer(timer1);
// NgProfiler::StartTimer(timer2); // NgProfiler::StartTimer(timer2);
@ -137,13 +138,14 @@ namespace netgen
cluster_reps.Elem(nnums[j]) = nnums[j]; cluster_reps.Elem(nnums[j]) = nnums[j];
} }
*/ */
ParallelForRange ngcore::ParallelForRange
(tm, nse, (mesh.SurfaceElements().Range(),
[&] (size_t begin, size_t end) [&] (auto myrange)
{ {
NgArrayMem<int,9> nnums, ednums; NgArrayMem<int,9> nnums, ednums;
for (int i = begin+1; i <= end; i++) for (int i_ : myrange)
{ {
int i = i_+1;
const Element2d & el = mesh.SurfaceElement(i); const Element2d & el = mesh.SurfaceElement(i);
ELEMENT_TYPE typ = el.GetType(); ELEMENT_TYPE typ = el.GetType();
@ -163,7 +165,7 @@ namespace netgen
for (int j = 0; j < nnums.Size(); j++) for (int j = 0; j < nnums.Size(); j++)
cluster_reps.Elem(nnums[j]) = nnums[j]; cluster_reps.Elem(nnums[j]) = nnums[j];
} }
}); }, ngcore::TasksPerThread(4));
// NgProfiler::StopTimer(timer2); // NgProfiler::StopTimer(timer2);

View File

@ -27,7 +27,7 @@ public:
AnisotropicClusters (const Mesh & amesh); AnisotropicClusters (const Mesh & amesh);
~AnisotropicClusters(); ~AnisotropicClusters();
void Update(NgTaskManager tm = &DummyTaskManager, NgTracer trace = &DummyTracer); void Update();
int GetVertexRepresentant (int vnr) const int GetVertexRepresentant (int vnr) const
{ return cluster_reps.Get(vnr); } { return cluster_reps.Get(vnr); }

View File

@ -6706,7 +6706,7 @@ namespace netgen
static Timer t("Update Topology"); RegionTimer reg(t); static Timer t("Update Topology"); RegionTimer reg(t);
topology.Update(tm, tracer); topology.Update(tm, tracer);
(*tracer)("call update clusters", false); (*tracer)("call update clusters", false);
clusters->Update(tm, tracer); clusters->Update();
(*tracer)("call update clusters", true); (*tracer)("call update clusters", true);
#ifdef PARALLEL #ifdef PARALLEL
if (paralleltop) if (paralleltop)