Skip to content
Snippets Groups Projects
Commit 2841f4ba authored by Markus Blatt's avatar Markus Blatt
Browse files

[bugfix] Cater for the case that we load balance to more processes.

One of the use cases for load balancing a matrix is reading it globally
on one process and then calling the load balancer to distribute it among
the processes. Unfortunately this did not work due to a bug that prevented
the correct remapping of the domain numbers from the load balancers. This
lead to negative rank numbers.

With this commit we use yet unassigned process numbers for domains that
are not yet mapped (due to having no dofs before the load balancing).
parent 1ccf3a47
No related branches found
No related tags found
1 merge request!28Matrix loadbalance to more
......@@ -405,7 +405,7 @@ namespace Dune
int j=0;
std::vector<int> domain(nparts, 0);
std::vector<int> assigned(npes, -0);
std::vector<int> assigned(npes, 0);
// init domain Mapping
domainMapping.assign(domainMapping.size(), -1);
......@@ -442,6 +442,8 @@ namespace Dune
// particular domain is selected to choose it's favorate domain
int maxOccurance = 0;
pe = -1;
std::set<std::size_t> unassigned;
for(i=0; i<nparts; i++) {
for(j=0; j<npes; j++) {
// process has no domain assigned
......@@ -463,10 +465,23 @@ namespace Dune
}
pe = -1;
}
else
{
unassigned.insert(i);
}
maxOccurance = 0;
}
typename std::vector<int>::iterator next_free = assigned.begin();
for(typename std::set<std::size_t>::iterator domain = unassigned.begin(),
end = unassigned.end(); domain != end; ++domain)
{
next_free = std::find_if(next_free, assigned.end(), std::bind2nd(std::less<int>(), 1));
assert(next_free != assigned.end());
domainMapping[*domain] = next_free-assigned.begin();
*next_free = 1;
}
}
struct SortFirst
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment