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