Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
new owner processor for sets exchange in Redistribute
  • Loading branch information
kirill-terekhov committed Apr 21, 2019
1 parent cb08886 commit 436c032
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 25 deletions.
8 changes: 4 additions & 4 deletions Examples/AdaptiveMesh/main.cpp
Expand Up @@ -3,9 +3,9 @@
using namespace INMOST;

bool output_file = false;
bool balance_mesh = true;
bool balance_mesh = false;
bool balance_mesh_refine = true;
bool balance_mesh_coarse = false;
bool balance_mesh_coarse = true;
std::string file_format = ".pmf";

int main(int argc, char ** argv)
Expand Down Expand Up @@ -266,10 +266,10 @@ int main(int argc, char ** argv)
{
//m.Barrier();
p.SetWeight(Tag());
//std::fill(nc.begin(),nc.end(),0); nc[m.GetProcessorRank()] = m.NumberOfCells(); m.Integrate(&nc[0],nc.size()); if( !m.GetProcessorRank() ) {std::cout << "finish before "; for(unsigned q = 0; q < nc.size(); ++q) std::cout << nc[q] << " "; std::cout << std::endl;}
std::fill(nc.begin(),nc.end(),0); nc[m.GetProcessorRank()] = m.NumberOfCells(); m.Integrate(&nc[0],nc.size()); if( !m.GetProcessorRank() ) {std::cout << "finish before "; for(unsigned q = 0; q < nc.size(); ++q) std::cout << nc[q] << " "; std::cout << std::endl;}
p.Evaluate();
m.Redistribute();
//std::fill(nc.begin(),nc.end(),0); nc[m.GetProcessorRank()] = m.NumberOfCells(); m.Integrate(&nc[0],nc.size()); if( !m.GetProcessorRank() ) {std::cout << "finish after "; for(unsigned q = 0; q < nc.size(); ++q) std::cout << nc[q] << " "; std::cout << std::endl;}
std::fill(nc.begin(),nc.end(),0); nc[m.GetProcessorRank()] = m.NumberOfCells(); m.Integrate(&nc[0],nc.size()); if( !m.GetProcessorRank() ) {std::cout << "finish after "; for(unsigned q = 0; q < nc.size(); ++q) std::cout << nc[q] << " "; std::cout << std::endl;}
//m.Barrier();
}
#endif
Expand Down
49 changes: 28 additions & 21 deletions Source/Mesh/parallel.cpp
Expand Up @@ -5936,7 +5936,7 @@ namespace INMOST
void Mesh::ExchangeMarked(enum Action action)
{
ENTER_FUNC();
bool dely_delete = true;
bool dely_delete = false;
if( m_state == Serial ) return;
#if defined(USE_MPI)
INMOST_DATA_BIG_ENUM_TYPE num_wait;
Expand Down Expand Up @@ -6194,28 +6194,33 @@ namespace INMOST
}
}
}
for(ElementType etype = ESET; etype >= NODE; etype = PrevElementType(etype)) if( tag_new_owner.isDefined(etype) && tag_new_processors.isDefined(etype) )
for(iteratorElement it = BeginElement(etype); it != EndElement(); it++)
for(ElementType etype = ESET; etype >= NODE; etype = PrevElementType(etype))
{
Storage::integer_array new_procs = it->IntegerArray(tag_new_processors);
Storage::integer_array old_procs = it->IntegerArrayDV(tag_processors);
if( new_procs.empty() ) continue;
Storage::integer new_owner = it->Integer(tag_new_owner);
it->IntegerDF(tag_owner) = new_owner;
old_procs.replace(old_procs.begin(),old_procs.end(),new_procs.begin(),new_procs.end());
if( new_owner == mpirank )
if( tag_new_owner.isDefined(etype) && tag_new_processors.isDefined(etype) )
{
if( old_procs.size() == 1 ) //there is only one processors and that's me
SetStatus(*it,Element::Owned);
else
SetStatus(*it,Element::Shared);
}
else SetStatus(*it,Element::Ghost);
if( dely_delete && !std::binary_search(old_procs.begin(),old_procs.end(),mpirank) )
{
if( etype == ESET )
ElementSet(this,*it).DeleteSet();
else Delete(*it);
for(iteratorElement it = BeginElement(etype); it != EndElement(); it++)
{
Storage::integer_array new_procs = it->IntegerArray(tag_new_processors);
Storage::integer_array old_procs = it->IntegerArrayDV(tag_processors);
if( new_procs.empty() ) continue;
Storage::integer new_owner = it->Integer(tag_new_owner);
it->IntegerDF(tag_owner) = new_owner;
old_procs.replace(old_procs.begin(),old_procs.end(),new_procs.begin(),new_procs.end());
if( new_owner == mpirank )
{
if( old_procs.size() == 1 ) //there is only one processors and that's me
SetStatus(*it,Element::Owned);
else
SetStatus(*it,Element::Shared);
}
else SetStatus(*it,Element::Ghost);
if( dely_delete && !std::binary_search(old_procs.begin(),old_procs.end(),mpirank) )
{
if( etype == ESET )
ElementSet(this,*it).DeleteSet();
else Delete(*it);
}
}
}
}
EXIT_BLOCK();
Expand Down Expand Up @@ -7149,6 +7154,8 @@ namespace INMOST
if( !new_procs.empty() )
it->Integer(tag_new_owner) = new_procs[0];
}

ExchangeData(tag_new_owner,ESET,0);
/*
{
std::fstream fout("file"+std::to_string(GetProcessorRank())+".txt",std::ios::out);
Expand Down

0 comments on commit 436c032

Please sign in to comment.