From cb8d854f88a60d65d4b52eb360b8452fe58a9650 Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Sun, 1 Dec 2024 22:39:03 -0800 Subject: [PATCH] various fixes + rindex: clear() --- src/include/base/types.h | 4 ++++ src/include/ranges/crange.h | 2 +- src/lib/ranges/crange.cc | 12 ++---------- src/lib/ranges/yrange.cc | 20 ++++++++++++++------ src/opt/mpi/include/rarray.cc.h | 7 +++++++ src/opt/mpi/include/rarray.h | 4 ++++ 6 files changed, 32 insertions(+), 17 deletions(-) diff --git a/src/include/base/types.h b/src/include/base/types.h index 53a360b..b028895 100644 --- a/src/include/base/types.h +++ b/src/include/base/types.h @@ -302,6 +302,10 @@ namespace CNORXZ template class OpRoot; + // definition: operation/op_types.h + template + class PosOp; + // definition: operation/op_types.h template class Operation; diff --git a/src/include/ranges/crange.h b/src/include/ranges/crange.h index b9c8166..48966c5 100644 --- a/src/include/ranges/crange.h +++ b/src/include/ranges/crange.h @@ -117,7 +117,7 @@ namespace CNORXZ bool formatIsTrivial() const; /** @copydoc IndexInterface::xpr() */ - COpRoot xpr(const Sptr& _this) const; + PosOp xpr(const Sptr& _this) const; private: Sptr mRangePtr; diff --git a/src/lib/ranges/crange.cc b/src/lib/ranges/crange.cc index da89ea9..2aed10f 100644 --- a/src/lib/ranges/crange.cc +++ b/src/lib/ranges/crange.cc @@ -119,17 +119,9 @@ namespace CNORXZ return *this; } - COpRoot CIndex::xpr(const Sptr& _this) const + PosOp CIndex::xpr(const Sptr& _this) const { - // preliminary solution (TODO: implement xpr that simply returns PosT value): - static Vector m; - if(m.size() < _this->lmax().val()){ - m.resize(_this->lmax().val()); - for(SizeT i = 0; i != m.size(); ++i) { - m[i] = i; - } - } - return coproot(m.data(), _this); + return posop(_this); } RangePtr CIndex::prange(const CIndex& last) const diff --git a/src/lib/ranges/yrange.cc b/src/lib/ranges/yrange.cc index 57ff714..94b981f 100644 --- a/src/lib/ranges/yrange.cc +++ b/src/lib/ranges/yrange.cc @@ -110,7 +110,10 @@ namespace CNORXZ inline decltype(auto) YIndex::mkIFor(SizeT i, const DXpr& xpr, NoF&& f) const { - if(i == mIs.size()-1){ + if(i == mIs.size()){ + return DXpr(xpr); + } + else if(i == mIs.size()-1){ return mIs[i]->ifor( xpr, std::forward(f) ); } else { @@ -335,11 +338,16 @@ namespace CNORXZ const String blim = "["; const String elim = "]"; const String dlim = ","; - return blim + - std::accumulate(std::next(mIs.all().begin()), mIs.all().end(), mIs[0]->stringMeta(), - [&](const auto& s, const auto& e) - { return s + dlim + e->stringMeta(); } ) + - elim; + if(mIs.size() == 0){ + return blim + elim; + } + else { + return blim + + std::accumulate(std::next(mIs.all().begin()), mIs.all().end(), mIs[0]->stringMeta(), + [&](const auto& s, const auto& e) + { return s + dlim + e->stringMeta(); } ) + + elim; + } } Vector YIndex::meta() const diff --git a/src/opt/mpi/include/rarray.cc.h b/src/opt/mpi/include/rarray.cc.h index d64b306..3b28503 100644 --- a/src/opt/mpi/include/rarray.cc.h +++ b/src/opt/mpi/include/rarray.cc.h @@ -248,6 +248,13 @@ namespace CNORXZ const SizeT blocks = i->pmax().val(); setupBuffer(ai, required, *mA, mBuf, mMap, blocks); } + + template + void RCArray::clear() const + { + mBuf.resize(0); + mMap.resize(0); + } /*==============+ | RArray | diff --git a/src/opt/mpi/include/rarray.h b/src/opt/mpi/include/rarray.h index 0782f7b..e73e000 100644 --- a/src/opt/mpi/include/rarray.h +++ b/src/opt/mpi/include/rarray.h @@ -134,6 +134,9 @@ namespace CNORXZ const Sptr& i, const Vector& required) const; + /** Clear data loaded from other ranks. */ + void clear() const; + protected: ObjHandle> mA; RangePtr mGeom; @@ -165,6 +168,7 @@ namespace CNORXZ using RCA::cbegin; using RCA::cend; using RCA::sl; + using RCA::local; DEFAULT_C(RArray); DEFAULT_MOVE(RArray);