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,43 +70,57 @@ namespace CNORXZ
mLex = lmax().val(); mLex = lmax().val();
return *this; return *this;
} }
// pos is the lexicographic position of the global range. if constexpr(index_is_multi<IndexI>::value and index_is_multi<IndexK>::value) {
// Hence, have to consider the rank geometry.
const auto& i = mI->pack(); // pos is the lexicographic position of the global range.
const auto& k = mK->pack(); // Hence, have to consider the rank geometry.
const auto& ilf = mI->lexFormat(); const auto& i = mI->pack();
const auto& klf = mK->lexFormat(); const auto& k = mK->pack();
SizeT r = 0; const auto& ilf = mI->lexFormat();
SizeT l = 0; const auto& klf = mK->lexFormat();
if constexpr(has_static_sub<IndexI>::value){ SizeT r = 0;
constexpr SizeT NI = index_dim<IndexI>::value; SizeT l = 0;
iter<0,NI>( [&](auto mu) { if constexpr(has_static_sub<IndexI>::value){
const SizeT jmu = (mLex / (ilf[mu].val()*klf[mu].val())) % constexpr SizeT NI = index_dim<IndexI>::value;
(i[mu]->lmax().val() * k[mu]->lmax().val()); iter<0,NI>( [&](auto mu) {
r += ( jmu / i[mu]->lmax().val() ) * klf[mu].val(); const SizeT jmu = (mLex / (ilf[mu].val()*klf[mu].val())) %
l += ( jmu % i[mu]->lmax().val() ) * ilf[mu].val(); (i[mu]->lmax().val() * k[mu]->lmax().val());
}, NoF{} ); r += ( jmu / i[mu]->lmax().val() ) * klf[mu].val();
} l += ( jmu % i[mu]->lmax().val() ) * ilf[mu].val();
else if constexpr( has_static_sub<IndexK>::value){ }, NoF{} );
constexpr SizeT NI = index_dim<IndexK>::value; }
iter<0,NI>( [&](auto mu) { else if constexpr( has_static_sub<IndexK>::value){
const SizeT jmu = (mLex / (ilf[mu].val()*klf[mu].val())) % constexpr SizeT NI = index_dim<IndexK>::value;
(i[mu]->lmax().val() * k[mu]->lmax().val()); iter<0,NI>( [&](auto mu) {
r += ( jmu / i[mu]->lmax().val() ) * klf[mu].val(); const SizeT jmu = (mLex / (ilf[mu].val()*klf[mu].val())) %
l += ( jmu % i[mu]->lmax().val() ) * ilf[mu].val(); (i[mu]->lmax().val() * k[mu]->lmax().val());
}, NoF{} ); r += ( jmu / i[mu]->lmax().val() ) * klf[mu].val();
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){
const SizeT jmu = (mLex / (ilf[mu].val()*klf[mu].val())) %
(i[mu]->lmax().val() * k[mu]->lmax().val());
r += ( jmu / i[mu]->lmax().val() ) * klf[mu].val();
l += ( jmu % i[mu]->lmax().val() ) * ilf[mu].val();
}
}
}
*mI = l;
*mK = r;
} }
else { else {
const SizeT NI = mI->dim(); *mK = pos / mI->lmax().val();
for(SizeT mu = 0; mu != NI; ++mu){ *mI = pos % mI->lmax().val();
const SizeT jmu = (mLex / (ilf[mu].val()*klf[mu].val())) %
(i[mu]->lmax().val() * k[mu]->lmax().val());
r += ( jmu / i[mu]->lmax().val() ) * klf[mu].val();
l += ( jmu % i[mu]->lmax().val() ) * ilf[mu].val();
}
} }
*mI = l;
*mK = r;
IB::mPos = mK->pos() * mI->pmax().val() + mI->pos(); IB::mPos = mK->pos() * mI->pmax().val() + mI->pos();
return *this; return *this;
} }
@ -330,34 +344,38 @@ namespace CNORXZ
if(mI->lex() >= mI->lmax().val()){ if(mI->lex() >= mI->lmax().val()){
mLex = lmax().val(); mLex = lmax().val();
} }
if constexpr(has_static_sub<IndexI>::value){ if constexpr(index_is_multi<IndexI>::value and index_is_multi<IndexK>::value){
constexpr SizeT NI = index_dim<IndexI>::value; if constexpr(has_static_sub<IndexI>::value){
mLex = iter<0,NI> constexpr SizeT NI = index_dim<IndexI>::value;
([&](auto i) { mLex = iter<0,NI>
return mK->pack()[i]->lex() * mK->lexFormat()[i].val() * ([&](auto i) {
mI->lexFormat()[i].val() * mI->pack()[i]->lmax().val() + return mK->pack()[i]->lex() * mK->lexFormat()[i].val() *
mI->pack()[i]->lex() * mI->lexFormat()[i].val() * mI->lexFormat()[i].val() * mI->pack()[i]->lmax().val() +
mK->lexFormat()[i].val(); mI->pack()[i]->lex() * mI->lexFormat()[i].val() *
}, [](const auto&... e) { return (e + ...); }); mK->lexFormat()[i].val();
} }, [](const auto&... e) { return (e + ...); });
else if constexpr( has_static_sub<IndexK>::value){ }
constexpr SizeT NI = index_dim<IndexK>::value; else if constexpr( has_static_sub<IndexK>::value){
mLex = iter<0,NI> constexpr SizeT NI = index_dim<IndexK>::value;
([&](auto i) { mLex = iter<0,NI>
return mK->pack()[i]->lex() * mK->lexFormat()[i].val() * ([&](auto i) {
mI->lexFormat()[i].val() * mI->pack()[i]->lmax().val() + return mK->pack()[i]->lex() * mK->lexFormat()[i].val() *
mI->pack()[i]->lex() * mI->lexFormat()[i].val() * mI->lexFormat()[i].val() * mI->pack()[i]->lmax().val() +
mK->lexFormat()[i].val(); mI->pack()[i]->lex() * mI->lexFormat()[i].val() *
}, [](const auto&... e) { return (e + ...); }); mK->lexFormat()[i].val();
} }, [](const auto&... e) { return (e + ...); });
else { }
const SizeT NI = mI->dim(); else {
mLex = 0; if(mI->pack().size() != 0){
for(SizeT i = 0; i != NI; ++i){ const SizeT NI = mI->dim();
mLex += mK->pack()[i]->lex() * mK->lexFormat()[i].val() * mLex = 0;
mI->lexFormat()[i].val() * mI->pack()[i]->lmax().val() + for(SizeT i = 0; i != NI; ++i){
mI->pack()[i]->lex() * mI->lexFormat()[i].val() * mLex += mK->pack()[i]->lex() * mK->lexFormat()[i].val() *
mK->lexFormat()[i].val(); mI->lexFormat()[i].val() * mI->pack()[i]->lmax().val() +
mI->pack()[i]->lex() * mI->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();