diff --git a/src/opt/hdf5/COMMENT b/src/opt/hdf5/COMMENT deleted file mode 100644 index 6ed9dd6..0000000 --- a/src/opt/hdf5/COMMENT +++ /dev/null @@ -1 +0,0 @@ -coming soon diff --git a/src/opt/mpi/include/raindex.h b/src/opt/mpi/include/raindex.h new file mode 100644 index 0000000..2992c0d --- /dev/null +++ b/src/opt/mpi/include/raindex.h @@ -0,0 +1,208 @@ +// -*- C++ -*- +/** + + @file opt/mpi/include/raindex.h + @brief RAIndex declarations. + + Copyright (c) 2024 Christian Zimmermann. All rights reserved. + Mail: chizeta@f3l.de + +**/ + +#ifndef __cxz_mpi_raindex_h__ +#define __cxz_mpi_raindex_h__ + +#include "cnorxz.h" + +namespace CNORXZ +{ + + /** **** + Index for multi-ranked array. + This is meant to be a global index. For local iterations + a YIndex is sufficient. + @tparam T data type. + */ + template + class RAIndex : public IndexInterface>> + { + public: + typedef IndexInterface>> IB; + typedef MRange RangeType; + typedef Tuple> MetaType; + + INDEX_RANDOM_ACCESS_ITERATOR_DEFS(MetaType); + + /** Default constructor. */ + RAIndex() = default; + + /** Move constructor. */ + RAIndex(RAIndex&& i) = default; + + /** Move assignment. */ + RAIndex& operator=(RAIndex&& i) = default; + + /** Copy constructor. + No default copy: Have to copy sub-index instances + */ + RAIndex(const RAIndex& i); + + /** Copy assigment. + No default copy: Have to copy sub-index instances + */ + RAIndex& operator=(const RAIndex& i); + + /** Construct from sub-index pointers. + @param is Vector of XIndex pointers. + @param geom Rank geometry. + */ + RAIndex(const Vector& is, const Vector& geom); + + /** Construct from sub-index pointers, specify index format. + @param bs Index format (YFormat). + @param is Vector of XIndex pointers. + @param geom Rank geometry. + */ + RAIndex(const YFormat& bs, const Vector& is, const Vector& geom); + + /** Construct from a range and an initial lexicographic position + @param range Range to iterate over. + @param geom Rank geometry. + @param lexpos Initial lexicographic position. + */ + RAIndex(const RangePtr& range, const Vector& geom, SizeT lexpos = 0); + + /** Construct from a range and an initial lexicographic position, specify format. + @param range Range to iterate over. + @param bs Index format. + @param geom Rank geometry. + @param lexpos Initial lexicographic position. + */ + RAIndex(const RangePtr& range, const YFormat& bs, const Vector& geom, SizeT lexpos = 0); + + /** @copydoc IndexInterface::operator=(SizeT) */ + RAIndex& operator=(SizeT lexpos); + + /** @copydoc IndexInterface::operator++() */ + RAIndex& operator++(); + + /** @copydoc IndexInterface::operator--() */ + RAIndex& operator--(); + + /** @copydoc IndexInterface::operator+() */ + RAIndex operator+(Int n) const; + + /** @copydoc IndexInterface::operator-() */ + RAIndex operator-(Int n) const; + + /** @copydoc IndexInterface::operator-(CIndex) */ + SizeT operator-(const RAIndex& i) const; + + /** @copydoc IndexInterface::operator+=() */ + RAIndex& operator+=(Int n); + + /** @copydoc IndexInterface::operator-=() */ + RAIndex& operator-=(Int n); + + /** @copydoc IndexInterface::lex() */ + SizeT lex() const; + + /** @copydoc IndexInterface::pmax() */ + UPos pmax() const; + + /** @copydoc IndexInterface::lmax() */ + UPos lmax() const; + + /** @copydoc IndexInterface::id() */ + IndexId<0> id() const; + + const T& operator*() const; + + const T* operator->() const; + + /** @copydoc IndexInterface::dim() */ + SizeT dim() const; + + /** @copydoc IndexInterface::range() */ + Sptr range() const; + + /** @copydoc IndexInterface::stepSize() */ + UPos stepSize(const IndexId<0> id) const; + + /** @copydoc IndexInterface::stringMeta() */ + String stringMeta() const; + + /** @copydoc IndexInterface::meta() */ + Vector meta() const; + + /** @copydoc IndexInterface::at() */ + RAIndex& at(const Vector& meta); + + /** @copydoc IndexInterface::prange() */ + RangePtr prange(const RAIndex& last) const; + + /** @copydoc IndexInterface::deepFormat() */ + Vector deepFormat() const; + + /** @copydoc IndexInterface::deepMax() */ + Vector deepMax() const; + + /** @copydoc IndexInterface::reformat() */ + RAIndex& reformat(const Vector& f, const Vector& s); + + /** @copydoc IndexInterface::ifor() */ + DXpr ifor(const DXpr& xpr, NoF&& f) const; + + /** @copydoc IndexInterface::formatIsTrivial() */ + bool formatIsTrivial() const; + + /** Replace sub-index instances. + All linearized positions are updated accordingly. + @param i DPack which provides the new sub-index instance + */ + RAIndex& operator()(const DPack& i); + + /** Update all linearized positions. */ + RAIndex& operator()(); + + /** Get all sub-indices + @return Pack of sub-indices + */ + const DPack& pack() const; + + /** Get index format. + @return The format. + */ + const YFormat& format() const; + + /** Get lexicographic (trivial) index format. + @return The lexicographic format. + */ + const YFormat& lexFormat() const; + + /** Set the index format. + @param bs The new format. + */ + RAIndex& setFormat(const YFormat& bs); + + /** Set position of given sub index and update total index position. + @param ind Sub-index number [0,dim()-1]. + @param lex Lexicographic position to be assigned to the index. + */ + RAIndex& setSub(SizeT ind, SizeT lex); + + private: + Sptr mRange; + MIndex mI; + MFormat<2> mFormat; + MFormat<2> mLexFormat; + SizeT mLex = 0; + UPos mPMax = 0; + UPos mLMax = 0; + const T* mLoc = nullptr; + Vector mBuf; // used if iterating over content on different rank + }; + +} + +#endif diff --git a/src/opt/mpi/include/rarray.h b/src/opt/mpi/include/rarray.h new file mode 100644 index 0000000..4f743bb --- /dev/null +++ b/src/opt/mpi/include/rarray.h @@ -0,0 +1,50 @@ +// -*- C++ -*- +/** + + @file opt/mpi/include/rarray.h + @brief RArray declarations. + + Copyright (c) 2024 Christian Zimmermann. All rights reserved. + Mail: chizeta@f3l.de + +**/ + +#ifndef __cxz_mpi_rarray_h__ +#define __cxz_mpi_rarray_h__ + +#include "cnorxz.h" + +namespace CNORXZ +{ + /** **** + Multi-dimensional multi-rank array. + @tparam T data type. + */ + template + class RArray : public ArrayBase + { + public: + typedef CArrayBase AB; + typedef typename RAIndex const_iterator; + + using CArrayBase::operator[]; + using ArrayBase::operator[]; + + DEFAULT_MEMBERS(RArray); + + virtual const T* data() const override; + virtual T* data() override; + virtual const_iterator cbegin() const override; + virtual const_iterator cend() const override; + virtual bool isView() const override; + + protected: + virtual bool formatIsTrivial() const override final; + + private: + Vector mCont; + RangePtr mRRange; + }; +} + +#endif