From d1ee6efc14d42241f0bfceee8085f4fdb6bb609d Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Wed, 12 May 2021 10:56:34 +0200 Subject: [PATCH] parallel Cluster update --- libsrc/meshing/clusters.cpp | 24 +++++++++++++----------- libsrc/meshing/clusters.hpp | 2 +- libsrc/meshing/meshclass.cpp | 2 +- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/libsrc/meshing/clusters.cpp b/libsrc/meshing/clusters.cpp index c01d1db3..97e77e36 100644 --- a/libsrc/meshing/clusters.cpp +++ b/libsrc/meshing/clusters.cpp @@ -16,7 +16,7 @@ namespace netgen ; } - void AnisotropicClusters :: Update(NgTaskManager tm, NgTracer tracer) + void AnisotropicClusters :: Update() { static Timer timer("clusters"); // static int timer1 = NgProfiler::CreateTimer ("clusters1"); @@ -81,13 +81,14 @@ namespace netgen cluster_reps.Elem(nnums[j]) = nnums[j]; } */ - ParallelForRange - (tm, ne, - [&] (size_t begin, size_t end) + ngcore::ParallelForRange + (mesh.VolumeElements().Range(), + [&] (auto myrange) { NgArray 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); ELEMENT_TYPE typ = el.GetType(); @@ -110,7 +111,7 @@ namespace netgen for (int j = 0; j < nnums.Size(); j++) cluster_reps.Elem(nnums[j]) = nnums[j]; } - }); + }, ngcore::TasksPerThread(4)); // NgProfiler::StopTimer(timer1); // NgProfiler::StartTimer(timer2); @@ -137,13 +138,14 @@ namespace netgen cluster_reps.Elem(nnums[j]) = nnums[j]; } */ - ParallelForRange - (tm, nse, - [&] (size_t begin, size_t end) + ngcore::ParallelForRange + (mesh.SurfaceElements().Range(), + [&] (auto myrange) { NgArrayMem nnums, ednums; - for (int i = begin+1; i <= end; i++) + for (int i_ : myrange) { + int i = i_+1; const Element2d & el = mesh.SurfaceElement(i); ELEMENT_TYPE typ = el.GetType(); @@ -163,7 +165,7 @@ namespace netgen for (int j = 0; j < nnums.Size(); j++) cluster_reps.Elem(nnums[j]) = nnums[j]; } - }); + }, ngcore::TasksPerThread(4)); // NgProfiler::StopTimer(timer2); diff --git a/libsrc/meshing/clusters.hpp b/libsrc/meshing/clusters.hpp index 21e122fb..21854f39 100644 --- a/libsrc/meshing/clusters.hpp +++ b/libsrc/meshing/clusters.hpp @@ -27,7 +27,7 @@ public: AnisotropicClusters (const Mesh & amesh); ~AnisotropicClusters(); - void Update(NgTaskManager tm = &DummyTaskManager, NgTracer trace = &DummyTracer); + void Update(); int GetVertexRepresentant (int vnr) const { return cluster_reps.Get(vnr); } diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index 1d325d8a..c31a6a2c 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -6706,7 +6706,7 @@ namespace netgen static Timer t("Update Topology"); RegionTimer reg(t); topology.Update(tm, tracer); (*tracer)("call update clusters", false); - clusters->Update(tm, tracer); + clusters->Update(); (*tracer)("call update clusters", true); #ifdef PARALLEL if (paralleltop)