This commit is contained in:
Christian Zimmermann 2024-03-11 19:11:38 +01:00
parent 5db90864c7
commit 6bfba5cdd9
2 changed files with 423 additions and 142 deletions

View file

@ -0,0 +1,243 @@
// -*- C++ -*-
/**
@file opt/mpi/include/rrange.cc.h
@brief RRange and RIndex declaration.
Copyright (c) 2024 Christian Zimmermann. All rights reserved.
Mail: chizeta@f3l.de
**/
#ifndef __cxz_mpi_rrange_cc_h__
#define __cxz_mpi_rrange_cc_h__
#include "rrange.h"
namespace CNORXZ
{
namespace mpi
{
template <class IndexI, class IndexK>
RIndex<IndexI,IndexK>::RIndex(const RIndex& in) :
mRange(in.mRange),
mI(std::make_shared<Index>(mRange->local())),
mK(std::make_shared<YIndex>(mRange->geom()))
{
*this = in.lex();
}
template <class IndexI, class IndexK>
RIndex& RIndex<IndexI,IndexK>::operator=(const RIndex& in)
{
mRange = in.mRange;
mI = std::make_shared<Index>(mRange->local());
mK = std::make_shared<YIndex>(mRange->geom());
*this = in.lex();
return *this;
}
template <class IndexI, class IndexK>
RIndex<IndexI,IndexK>::RIndex(const RangePtr& global, SizeT lexpos = 0) :
mRange(rangeCast<RangeType>(global)),
mI(std::make_shared<Index>(mRange->local())),
mK(std::make_shared<YIndex>(mRange->geom()))
{
*this = lexpos;
}
template <class IndexI, class IndexK>
RIndex<IndexI,IndexK>::RIndex(const Sptr<Index>& local) :
{
//!!!
}
template <class IndexI, class IndexK>
RIndex<IndexI,IndexK>& RIndex<IndexI,IndexK>::operator=(SizeT pos)
{
// pos is the lexicographic position of the global range.
// Hence, have to consider the rank geometry.
if constexpr(has_static_sub<IndexI>::value or has_static_sub<IndexK>::value){
}
else {
}
return *this;
}
template <class IndexI, class IndexK>
RIndex<IndexI,IndexK>& RIndex<IndexI,IndexK>::operator++()
{
return *this;
}
template <class IndexI, class IndexK>
RIndex<IndexI,IndexK>& RIndex<IndexI,IndexK>::operator--()
{
return *this;
}
template <class IndexI, class IndexK>
RIndex<IndexI,IndexK> RIndex<IndexI,IndexK>::operator+(Int n) const
{
}
template <class IndexI, class IndexK>
RIndex<IndexI,IndexK> RIndex<IndexI,IndexK>::operator-(Int n) const
{
}
template <class IndexI, class IndexK>
SizeT RIndex<IndexI,IndexK>::operator-(const RIndex& i) const
{
}
template <class IndexI, class IndexK>
RIndex<IndexI,IndexK>& RIndex<IndexI,IndexK>::operator+=(Int n)
{
return *this;
}
template <class IndexI, class IndexK>
RIndex<IndexI,IndexK>& RIndex<IndexI,IndexK>::operator-=(Int n)
{
return *this;
}
template <class IndexI, class IndexK>
SizeT RIndex<IndexI,IndexK>::lex() const
{
}
template <class IndexI, class IndexK>
constexpr RIndex<IndexI,IndexK>::decltype(auto) pmax() const
{
}
template <class IndexI, class IndexK>
constexpr RIndex<IndexI,IndexK>::decltype(auto) lmax() const
{
}
template <class IndexI, class IndexK>
IndexId<0> RIndex<IndexI,IndexK>::id() const
{
}
template <class IndexI, class IndexK>
MetaType RIndex<IndexI,IndexK>::operator*() const
{
}
template <class IndexI, class IndexK>
constexpr SizeT RIndex<IndexI,IndexK>::dim() const
{
}
template <class IndexI, class IndexK>
Sptr<RangeType> RIndex<IndexI,IndexK>::range() const
{
}
template <class IndexI, class IndexK>
template <SizeT I>
decltype(auto) RIndex<IndexI,IndexK>::stepSize(const IndexId<I>& id) const
{
}
template <class IndexI, class IndexK>
String RIndex<IndexI,IndexK>::stringMeta() const
{
}
template <class IndexI, class IndexK>
MetaType RIndex<IndexI,IndexK>::meta() const
{
}
template <class IndexI, class IndexK>
RIndex<IndexI,IndexK>& RIndex<IndexI,IndexK>::at(const MetaType& metaPos)
{
}
template <class IndexI, class IndexK>
RangePtr RIndex<IndexI,IndexK>::prange(const RIndex<IndexI,IndexK>& last) const
{
}
template <class IndexI, class IndexK>
auto RIndex<IndexI,IndexK>::deepFormat() const
{
}
template <class IndexI, class IndexK>
auto RIndex<IndexI,IndexK>::deepMax() const
{
}
template <class IndexI, class IndexK>
RIndex<IndexI,IndexK>& RIndex<IndexI,IndexK>::reformat(const Vector<SizeT>& f, const Vector<SizeT>& s)
{
}
template <class IndexI, class IndexK>
template <class Xpr, class F>
constexpr decltype(auto) RIndex<IndexI,IndexK>::ifor(const Xpr& xpr, F&& f) const
{
}
template <class IndexI, class IndexK>
bool RIndex<IndexI,IndexK>::formatIsTrivial() const
{
}
template <class IndexI, class IndexK>
decltype(auto) RIndex<IndexI,IndexK>::xpr(const Sptr<RIndex<IndexI,IndexK>>& _this) const
{
}
template <class IndexI, class IndexK>
int RIndex<IndexI,IndexK>::rank() const
{
}
template <class IndexI, class IndexK>
Sptr<Index> RIndex<IndexI,IndexK>::local() const
{
}
} // namespace mpi
} // namespace CNORXZ
#endif

View file

@ -1,7 +1,7 @@
// -*- C++ -*- // -*- C++ -*-
/** /**
@file opt/include/rrange.h @file opt/mpi/include/rrange.h
@brief RRange and RIndex declaration. @brief RRange and RIndex declaration.
Copyright (c) 2024 Christian Zimmermann. All rights reserved. Copyright (c) 2024 Christian Zimmermann. All rights reserved.
@ -15,23 +15,50 @@
#include "cnorxz.h" #include "cnorxz.h"
namespace CNORXZ namespace CNORXZ
{
namespace mpi
{ {
/** **** /** ****
Specific index for RRange. Specific index for RRange.
@tparam Index Local index type. Every call on an instance of this class has to be done on each rank.
@tparam IndexI Index type used to indicate local position.
@tparam IndexK Index type used to indicate the rank.
*/ */
template <class Index> template <class IndexI, class IndexK>
class RIndex : public IndexInterface<RIndex<Index>,typename Index::MetaType> class RIndex : public IndexInterface<RIndex<IndexI,IndexK>,typename Index::MetaType>
{ {
public: public:
typedef IndexInterface<RIndex<Index>,typename Index::MetaType> IB; typedef IndexInterface<RIndex<IndexI,IndexK>,typename Index::MetaType> IB;
typedef typename Index::MetaType MetaType; typedef typename Index::MetaType MetaType;
typedef RRange<typename Index::RangeType> RangeType; typedef RRange<typename Index::RangeType> RangeType;
INDEX_RANDOM_ACCESS_ITERATOR_DEFS(MetaType); INDEX_RANDOM_ACCESS_ITERATOR_DEFS(MetaType);
// constructors!!! // constructors!!!
/** Default constructor. */
RIndex() = default;
/** Move constructor (default). */
RIndex(RIndex&& in) = default;
/** Move assignment (default). */
RIndex& operator=(RIndex&& in) = default;
/** Copy constructor (no default, copy local index instance). */
RIndex(const RIndex& in);
/** Copy assignment (no default, copy local index instance). */
RIndex& operator=(const RIndex& in);
/** Construct from global range and format.
@param global Pointer to global range; this can be a RRange or the bare range (will be converted to a RRange).
@param lexpos Start position.
*/
RIndex(const RangePtr& global, SizeT lexpos = 0);
/** Construct from local index. */
RIndex(const Sptr<IndexI,IndexK>& local);
/** @copydoc IndexInterface::operator=(SizeT) */ /** @copydoc IndexInterface::operator=(SizeT) */
RIndex& operator=(SizeT pos); RIndex& operator=(SizeT pos);
@ -92,7 +119,7 @@ namespace CNORXZ
RIndex& at(const MetaType& metaPos); RIndex& at(const MetaType& metaPos);
/** @copydoc IndexInterface::prange() */ /** @copydoc IndexInterface::prange() */
RangePtr prange(const RIndex<Index>& last) const; RangePtr prange(const RIndex<IndexI,IndexK>& last) const;
/** @copydoc IndexInterface::deepFormat() */ /** @copydoc IndexInterface::deepFormat() */
auto deepFormat() const; auto deepFormat() const;
@ -111,13 +138,19 @@ namespace CNORXZ
bool formatIsTrivial() const; bool formatIsTrivial() const;
/** @copydoc IndexInterface::xpr() */ /** @copydoc IndexInterface::xpr() */
decltype(auto) xpr(const Sptr<MIndex<Indices...>>& _this) const; decltype(auto) xpr(const Sptr<RIndex<IndexI,IndexK>>& _this) const;
/** Get the current rank. */
int rank() const;
/** Get the local index on THIS rank. */
Sptr<IndexI,IndexK> local() const;
//!!! //!!!
private: private:
Sptr<RangeType> mRange; Sptr<RangeType> mRange; /**< RRange. */
Sptr<Index> mLocalI; Sptr<IndexI> mJ; /**< Index on the local range of the THIS rank. */
Sptr<IndexK> mK; /**< Multi-index indicating the current rank. */
//!!! //!!!
}; };
@ -149,6 +182,9 @@ namespace CNORXZ
/** Get local range. */ /** Get local range. */
Sptr<Range> local() const; Sptr<Range> local() const;
/** Get range of the rank geometry. */
Sptr<YRange> geom() const;
/** Get meta data for given lexicographic position. /** Get meta data for given lexicographic position.
@param pos Lexicographic position. @param pos Lexicographic position.
*/ */
@ -189,6 +225,8 @@ namespace CNORXZ
*/ */
template <class GRange> template <class GRange>
RangePtr rrange(const Sptr<GRange>& global, const Sptr<YRange>& geom); RangePtr rrange(const Sptr<GRange>& global, const Sptr<YRange>& geom);
}
} // namespace mpi
} // namespace CNORXZ
#endif #endif