mpi: rindex: consider the case of one-dimensional multi-ranking

This commit is contained in:
Christian Zimmermann 2024-07-03 22:17:22 +02:00
parent 215c2c4f55
commit 8bf9699ad3

View file

@ -70,6 +70,8 @@ namespace CNORXZ
mLex = lmax().val(); mLex = lmax().val();
return *this; return *this;
} }
if constexpr(index_is_multi<IndexI>::value and index_is_multi<IndexK>::value) {
// pos is the lexicographic position of the global range. // pos is the lexicographic position of the global range.
// Hence, have to consider the rank geometry. // Hence, have to consider the rank geometry.
const auto& i = mI->pack(); const auto& i = mI->pack();
@ -96,6 +98,12 @@ namespace CNORXZ
l += ( jmu % i[mu]->lmax().val() ) * ilf[mu].val(); l += ( jmu % i[mu]->lmax().val() ) * ilf[mu].val();
}, NoF{} ); }, NoF{} );
} }
else {
if(i.size() == 0){ // yindices / dindices with no lower instance:
*mK = pos / mI->lmax().val();
*mI = pos % mI->lmax().val();
}
else { else {
const SizeT NI = mI->dim(); const SizeT NI = mI->dim();
for(SizeT mu = 0; mu != NI; ++mu){ for(SizeT mu = 0; mu != NI; ++mu){
@ -105,8 +113,14 @@ namespace CNORXZ
l += ( jmu % i[mu]->lmax().val() ) * ilf[mu].val(); l += ( jmu % i[mu]->lmax().val() ) * ilf[mu].val();
} }
} }
}
*mI = l; *mI = l;
*mK = r; *mK = r;
}
else {
*mK = pos / mI->lmax().val();
*mI = pos % mI->lmax().val();
}
IB::mPos = mK->pos() * mI->pmax().val() + mI->pos(); IB::mPos = mK->pos() * mI->pmax().val() + mI->pos();
return *this; return *this;
} }
@ -330,6 +344,7 @@ namespace CNORXZ
if(mI->lex() >= mI->lmax().val()){ if(mI->lex() >= mI->lmax().val()){
mLex = lmax().val(); mLex = lmax().val();
} }
if constexpr(index_is_multi<IndexI>::value and index_is_multi<IndexK>::value){
if constexpr(has_static_sub<IndexI>::value){ if constexpr(has_static_sub<IndexI>::value){
constexpr SizeT NI = index_dim<IndexI>::value; constexpr SizeT NI = index_dim<IndexI>::value;
mLex = iter<0,NI> mLex = iter<0,NI>
@ -351,6 +366,7 @@ namespace CNORXZ
}, [](const auto&... e) { return (e + ...); }); }, [](const auto&... e) { return (e + ...); });
} }
else { else {
if(mI->pack().size() != 0){
const SizeT NI = mI->dim(); const SizeT NI = mI->dim();
mLex = 0; mLex = 0;
for(SizeT i = 0; i != NI; ++i){ for(SizeT i = 0; i != NI; ++i){
@ -360,6 +376,8 @@ namespace CNORXZ
mK->lexFormat()[i].val(); mK->lexFormat()[i].val();
} }
} }
}
}
IB::mPos = mK->pos() * mI->pmax().val() + mI->pos(); IB::mPos = mK->pos() * mI->pmax().val() + mI->pos();
return *this; return *this;
} }