Commit 91921dc1 authored by Kirill Terekhov's avatar Kirill Terekhov
Browse files

Remove non-local mapping in RowMerger that slows down automatic differentiation

parent 5baef6f1
......@@ -249,7 +249,7 @@ namespace INMOST
}
}
}
std::set<INMOST_DATA_ENUM_TYPE> Pre, Post; //Nonlocal indices
//~ std::set<INMOST_DATA_ENUM_TYPE> Pre, Post; //Nonlocal indices
#if defined(USE_MPI)
int size;
MPI_Comm_size(MPI_COMM_WORLD,&size);
......@@ -283,6 +283,7 @@ namespace INMOST
for(std::map<Mesh *,std::vector<Tag> >::iterator it = exch_tags.begin(); it != exch_tags.end(); ++it)
it->first->ExchangeData(it->second, exch_mask,0);
}
#if 0
//compute out-of-bounds indices
for (unsigned it = 0; it < reg_blocks.size(); ++it) if( act_blocks[it] )
{
......@@ -309,6 +310,7 @@ namespace INMOST
}
} //etype
} //it
#endif
// after cycle
}
#endif
......@@ -324,7 +326,8 @@ namespace INMOST
{
merger.resize(MAX_THREADS);
}
merger[OMP_THREAD].Resize(first_num,last_num,std::vector<INMOST_DATA_ENUM_TYPE>(Pre.begin(),Pre.end()),std::vector<INMOST_DATA_ENUM_TYPE>(Post.begin(),Post.end()),false);
//~ merger[OMP_THREAD].Resize(first_num,last_num,std::vector<INMOST_DATA_ENUM_TYPE>(Pre.begin(),Pre.end()),std::vector<INMOST_DATA_ENUM_TYPE>(Post.begin(),Post.end()),false);
merger[OMP_THREAD].Resize(first_num,last_num,false);
}
}
......
......@@ -192,43 +192,45 @@ namespace INMOST
INMOST_DATA_ENUM_TYPE RowMerger::MapIndex(INMOST_DATA_ENUM_TYPE pos) const
{
if( pos < IntervalBeg )
{
//return ENUMUNDEF;
//assert(!NonlocalPre.empty()); //there are indices provided
std::vector< INMOST_DATA_ENUM_TYPE >::const_iterator search = std::lower_bound(NonlocalPre.begin(),NonlocalPre.end(),pos);
//assert(*search == pos); //is there such index?
if( search != NonlocalPre.end() && *search == pos )
return static_cast<INMOST_DATA_ENUM_TYPE>(IntervalBeg - NonlocalPre.size() + static_cast<INMOST_DATA_ENUM_TYPE>(search - NonlocalPre.begin()));
else
return ENUMUNDEF;
}
else if( pos >= IntervalEnd )
{
//return ENUMUNDEF;
//assert(!NonlocalPost.empty()); //there are indices provided
std::vector< INMOST_DATA_ENUM_TYPE >::const_iterator search = std::lower_bound(NonlocalPost.begin(),NonlocalPost.end(),pos);
//assert(*search == pos); //is there such index?
if( search != NonlocalPost.end() && *search == pos )
return IntervalEnd + static_cast<INMOST_DATA_ENUM_TYPE>(search-NonlocalPost.begin());
else
return ENUMUNDEF;
}
//~ if( pos < IntervalBeg )
//~ {
//~ //return ENUMUNDEF;
//~ //assert(!NonlocalPre.empty()); //there are indices provided
//~ std::vector< INMOST_DATA_ENUM_TYPE >::const_iterator search = std::lower_bound(NonlocalPre.begin(),NonlocalPre.end(),pos);
//~ //assert(*search == pos); //is there such index?
//~ if( search != NonlocalPre.end() && *search == pos )
//~ return static_cast<INMOST_DATA_ENUM_TYPE>(IntervalBeg - NonlocalPre.size() + static_cast<INMOST_DATA_ENUM_TYPE>(search - NonlocalPre.begin()));
//~ else
//~ return ENUMUNDEF;
//~ }
//~ else if( pos >= IntervalEnd )
//~ {
//~ //return ENUMUNDEF;
//~ //assert(!NonlocalPost.empty()); //there are indices provided
//~ std::vector< INMOST_DATA_ENUM_TYPE >::const_iterator search = std::lower_bound(NonlocalPost.begin(),NonlocalPost.end(),pos);
//~ //assert(*search == pos); //is there such index?
//~ if( search != NonlocalPost.end() && *search == pos )
//~ return IntervalEnd + static_cast<INMOST_DATA_ENUM_TYPE>(search-NonlocalPost.begin());
//~ else
//~ return ENUMUNDEF;
//~ }
if( pos < IntervalBeg || pos >= IntervalEnd )
return ENUMUNDEF;
return pos;
}
INMOST_DATA_ENUM_TYPE RowMerger::UnmapIndex(INMOST_DATA_ENUM_TYPE pos) const
{
if( pos < IntervalBeg )
{
assert(pos >= IntervalBeg-NonlocalPre.size());
return NonlocalPre[pos+NonlocalPre.size()-IntervalBeg];
}
else if( pos >= IntervalEnd )
{
assert(pos < IntervalEnd+NonlocalPost.size());
return NonlocalPost[pos-IntervalEnd];
}
//~ if( pos < IntervalBeg )
//~ {
//~ assert(pos >= IntervalBeg-NonlocalPre.size());
//~ return NonlocalPre[pos+NonlocalPre.size()-IntervalBeg];
//~ }
//~ else if( pos >= IntervalEnd )
//~ {
//~ assert(pos < IntervalEnd+NonlocalPost.size());
//~ return NonlocalPost[pos-IntervalEnd];
//~ }
return pos;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment