fix/implement missing broadcasts + fix at() for mrange/rrange
This commit is contained in:
parent
9b2b1be170
commit
236a5b1b81
4 changed files with 44 additions and 20 deletions
|
@ -60,8 +60,12 @@ namespace CNORXZ
|
||||||
template <class FormatT, class... Indices>
|
template <class FormatT, class... Indices>
|
||||||
inline void GMIndex<FormatT,Indices...>::mkPos()
|
inline void GMIndex<FormatT,Indices...>::mkPos()
|
||||||
{
|
{
|
||||||
|
bool outOfScope = false;
|
||||||
mLex = iter<0,NI>
|
mLex = iter<0,NI>
|
||||||
([&](auto i) { return mIPack[i]->lex() * mLexFormat[i].val(); },
|
([&](auto i) {
|
||||||
|
outOfScope |= mIPack[i]->lex() >= mIPack[i]->lmax().val();
|
||||||
|
return mIPack[i]->lex() * mLexFormat[i].val();
|
||||||
|
},
|
||||||
[](const auto&... e) { return (e + ...); });
|
[](const auto&... e) { return (e + ...); });
|
||||||
if constexpr(not std::is_same<FormatT,None>::value){
|
if constexpr(not std::is_same<FormatT,None>::value){
|
||||||
IB::mPos = iter<0,NI>
|
IB::mPos = iter<0,NI>
|
||||||
|
@ -71,6 +75,10 @@ namespace CNORXZ
|
||||||
else {
|
else {
|
||||||
IB::mPos = mLex;
|
IB::mPos = mLex;
|
||||||
}
|
}
|
||||||
|
if(outOfScope){
|
||||||
|
IB::mPos = pmax().val();
|
||||||
|
mLex = lmax().val();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class FormatT, class... Indices>
|
template <class FormatT, class... Indices>
|
||||||
|
@ -433,9 +441,7 @@ namespace CNORXZ
|
||||||
GMIndex<FormatT,Indices...>& GMIndex<FormatT,Indices...>::at(const MetaType& metaPos)
|
GMIndex<FormatT,Indices...>& GMIndex<FormatT,Indices...>::at(const MetaType& metaPos)
|
||||||
{
|
{
|
||||||
iter<0,NI>( [&](auto i) { mIPack[i]->at( std::get<i>(metaPos) ); }, NoF {} );
|
iter<0,NI>( [&](auto i) { mIPack[i]->at( std::get<i>(metaPos) ); }, NoF {} );
|
||||||
IB::mPos = iter<0,NI>
|
mkPos();
|
||||||
( [&](auto i) { return mIPack[i]->pos()*format()[i].val(); },
|
|
||||||
[](const auto&... xs) { return (xs + ...); });
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -221,24 +221,24 @@ namespace CNORXZ
|
||||||
}
|
}
|
||||||
bcast(o, r);
|
bcast(o, r);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// TODO: In general don't allow RIndices if broadcast for MetaType
|
||||||
|
// does not exitst (once DType broadcast is implemented)!!!
|
||||||
|
CXZ_ERROR("no broadcast implementation for given meta type ("
|
||||||
|
<< typeid(MetaType).name() << ") available");
|
||||||
|
}
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class IndexI, class IndexK>
|
template <class IndexI, class IndexK>
|
||||||
RIndex<IndexI,IndexK>& RIndex<IndexI,IndexK>::at(const MetaType& metaPos)
|
RIndex<IndexI,IndexK>& RIndex<IndexI,IndexK>::at(const MetaType& metaPos)
|
||||||
{
|
{
|
||||||
//VCHECK(toString(metaPos));
|
|
||||||
//VCHECK(toString(mI->meta()));
|
|
||||||
mI->at(metaPos);
|
mI->at(metaPos);
|
||||||
//VCHECK(toString(mI->meta()));
|
|
||||||
const size_t lex = mI->lex();
|
const size_t lex = mI->lex();
|
||||||
//VCHECK(lex);
|
|
||||||
Vector<size_t> lexs(mK->lmax().val());
|
Vector<size_t> lexs(mK->lmax().val());
|
||||||
MPI_Allgather(&lex, 1, MPI_UNSIGNED_LONG, lexs.data(), 1, MPI_UNSIGNED_LONG,
|
MPI_Allgather(&lex, 1, MPI_UNSIGNED_LONG, lexs.data(), 1, MPI_UNSIGNED_LONG,
|
||||||
MPI_COMM_WORLD);
|
MPI_COMM_WORLD);
|
||||||
VCHECK(toString(lexs));
|
|
||||||
SizeT root = 0;
|
SizeT root = 0;
|
||||||
VCHECK(mI->lmax().val());
|
|
||||||
for(; root != lexs.size() and lexs[root] == mI->lmax().val(); ++root) {}
|
for(; root != lexs.size() and lexs[root] == mI->lmax().val(); ++root) {}
|
||||||
if(root == lexs.size()){ // metaPos not in rrange
|
if(root == lexs.size()){ // metaPos not in rrange
|
||||||
*this = lmax().val();
|
*this = lmax().val();
|
||||||
|
@ -247,7 +247,6 @@ namespace CNORXZ
|
||||||
else {
|
else {
|
||||||
*mK = root;
|
*mK = root;
|
||||||
*mI = lexs[root];
|
*mI = lexs[root];
|
||||||
VCHECK(lexs[root]);
|
|
||||||
(*this)();
|
(*this)();
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -302,6 +301,9 @@ namespace CNORXZ
|
||||||
template <class IndexI, class IndexK>
|
template <class IndexI, class IndexK>
|
||||||
RIndex<IndexI,IndexK>& RIndex<IndexI,IndexK>::operator()()
|
RIndex<IndexI,IndexK>& RIndex<IndexI,IndexK>::operator()()
|
||||||
{
|
{
|
||||||
|
if(mI->lex() >= mI->lmax().val()){
|
||||||
|
IB::mPos = lmax().val();
|
||||||
|
}
|
||||||
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;
|
||||||
IB::mPos = iter<0,NI>
|
IB::mPos = iter<0,NI>
|
||||||
|
|
|
@ -12,6 +12,7 @@ namespace CNORXZ
|
||||||
struct Typemap
|
struct Typemap
|
||||||
{
|
{
|
||||||
static constexpr bool exists = false;
|
static constexpr bool exists = false;
|
||||||
|
static MPI_Datatype value() { return MPI_BYTE; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
|
@ -56,6 +57,28 @@ namespace CNORXZ
|
||||||
static MPI_Datatype value() { return MPI_FLOAT; }
|
static MPI_Datatype value() { return MPI_FLOAT; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename T, SizeT N>
|
||||||
|
struct Typemap<Arr<T,N>>
|
||||||
|
{
|
||||||
|
static constexpr bool exists = Typemap<T>::exists;
|
||||||
|
static MPI_Datatype value() { return Typemap<T>::value(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct Typemap<Vector<T>>
|
||||||
|
{
|
||||||
|
static constexpr bool exists = Typemap<T>::exists;
|
||||||
|
static MPI_Datatype value() { return Typemap<T>::value(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename... Ts>
|
||||||
|
struct Typemap<Tuple<Ts...>>
|
||||||
|
{
|
||||||
|
static constexpr bool exists = ( Typemap<Ts>::exists and ... );
|
||||||
|
static MPI_Datatype value() { return MPI_BYTE; }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// further !!!
|
// further !!!
|
||||||
|
|
||||||
} // namespace mpi
|
} // namespace mpi
|
||||||
|
|
|
@ -134,17 +134,11 @@ namespace
|
||||||
EXPECT_EQ(s1 ,s2);
|
EXPECT_EQ(s1 ,s2);
|
||||||
}
|
}
|
||||||
rgi = 0;
|
rgi = 0;
|
||||||
gi = 0;
|
|
||||||
auto xi = gi;
|
|
||||||
gi = 10;
|
|
||||||
xi.at( gi.meta() );
|
|
||||||
EXPECT_EQ( xi.lex(), gi.lex() );
|
|
||||||
//VCHECK(toString(rgi.local()->meta()));
|
|
||||||
VCHECK(rgi.local()->at( gi.meta() ).lex());
|
|
||||||
/*
|
|
||||||
auto j = rgi;
|
auto j = rgi;
|
||||||
for(auto i = rgi; i.lex() != i.lmax().val(); ++i){
|
for(auto i = rgi; i.lex() != i.lmax().val(); ++i){
|
||||||
j.at( i.meta() );
|
j.at( i.meta() );
|
||||||
|
//const auto imeta = toString(i.meta());
|
||||||
|
//const auto jmeta = toString(j.meta());
|
||||||
if(getRankNumber() == 0){
|
if(getRankNumber() == 0){
|
||||||
EXPECT_EQ(i.lex(), j.lex());
|
EXPECT_EQ(i.lex(), j.lex());
|
||||||
EXPECT_EQ(i.rank(), j.rank());
|
EXPECT_EQ(i.rank(), j.rank());
|
||||||
|
@ -154,7 +148,6 @@ namespace
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue