corrections + remove old files + some todos
This commit is contained in:
parent
0e616f8370
commit
636c1d6407
12 changed files with 19 additions and 901 deletions
|
@ -56,20 +56,9 @@ namespace CNORXZ
|
|||
decltype(auto) xpr(const Sptr<I>& _this) const { return THIS().xpr(_this); }
|
||||
|
||||
RangePtr prange(const IndexInterface& end) const { return THIS().prange(end.THIS()); }
|
||||
/*
|
||||
template <class Index>
|
||||
decltype(auto) formatTo(const Sptr<Index>& ind) const { return ind->formatFrom(THIS()); }
|
||||
|
||||
template <class Index>
|
||||
decltype(auto) formatFrom(const Index& ind) const // yes this is const,
|
||||
// changes only MIndex/YIndex format, in this case we can just copy the pointers to the sub-index instances
|
||||
{ return THIS().formatFrom(ind); }
|
||||
*/
|
||||
decltype(auto) deepFormat() const { return THIS().deepFormat(); }
|
||||
|
||||
//template <class Index>
|
||||
//decltype(auto) slice(const Sptr<Index>& ind) const { return THIS().slice(ind); }
|
||||
|
||||
template <class Xpr, class F = NoF>
|
||||
decltype(auto) ifor(const Xpr& xpr, F&& f) const
|
||||
{ return THIS().ifor(xpr,std::forward<F>(f)); }
|
||||
|
|
|
@ -604,9 +604,21 @@ namespace CNORXZ
|
|||
template <class... Ranges>
|
||||
MArray<RangePtr> MRange<Ranges...>::sub() const
|
||||
{
|
||||
CXZ_ERROR("not implemented (SRange missing!!)"); //!!!
|
||||
// TODO: ZRange (meta and index pos static!)
|
||||
if constexpr(NR == 0) {
|
||||
return MArray<RangePtr>();
|
||||
}
|
||||
else {
|
||||
RangePtr sr = SRangeFactory<SizeT,NR>
|
||||
( iter<0,NR>
|
||||
( [](auto i) { return i; },
|
||||
[](auto... x) { return Arr<SizeT,NR> { x... }; } ) ).create();
|
||||
return MArray<RangePtr>
|
||||
( sr, iter<0,NR>
|
||||
( [&](auto i) { return std::get<i>(mRs); },
|
||||
[](auto... x) { return Vector<RangePtr> ({ x... }); } ) );
|
||||
}
|
||||
}
|
||||
|
||||
template <class... Ranges>
|
||||
SizeT MRange<Ranges...>::size() const
|
||||
|
|
|
@ -1,96 +0,0 @@
|
|||
|
||||
|
||||
#ifdef include_range_type
|
||||
include_range_type(NUL,-2)
|
||||
#else
|
||||
|
||||
#ifdef __cxz_ranges_header__
|
||||
// assert, that this is only used within range_types/header.h
|
||||
|
||||
#ifndef __cxz_range_type_null_def__
|
||||
#define __cxz_range_type_null_def__
|
||||
|
||||
namespace CNORXZ
|
||||
{
|
||||
typedef GenSingleIndex<size_t,SpaceType::NUL,0> NullIndex;
|
||||
|
||||
std::shared_ptr<GenSingleRange<size_t,SpaceType::NUL,0> > nullr();
|
||||
std::shared_ptr<NullIndex> nulli();
|
||||
|
||||
template <>
|
||||
class GenSingleRangeFactory<size_t,SpaceType::NUL,0> : public RangeFactoryBase
|
||||
{
|
||||
public:
|
||||
|
||||
typedef GenSingleRange<size_t,SpaceType::NUL,0> oType;
|
||||
|
||||
GenSingleRangeFactory();
|
||||
std::shared_ptr<RangeBase> create();
|
||||
|
||||
friend std::shared_ptr<oType> nullr();
|
||||
|
||||
private:
|
||||
static std::shared_ptr<oType> mRInstance;
|
||||
};
|
||||
|
||||
template <>
|
||||
class GenSingleRange<size_t,SpaceType::NUL,0> : public RangeInterface<NullIndex>
|
||||
{
|
||||
public:
|
||||
typedef RangeBase RB;
|
||||
typedef typename RangeInterface<GenSingleIndex<size_t,SpaceType::NUL,0> >::IndexType IndexType;
|
||||
typedef GenSingleRange<size_t,SpaceType::NUL,0> RangeType;
|
||||
typedef size_t MetaType;
|
||||
typedef GenSingleRangeFactory<size_t,SpaceType::NUL,0> FType;
|
||||
|
||||
virtual size_t size() const final;
|
||||
virtual size_t dim() const final;
|
||||
|
||||
virtual vector<size_t> typeNum() const final;
|
||||
virtual size_t cmeta(char* target, size_t pos) const final;
|
||||
virtual size_t cmetaSize() const final;
|
||||
virtual std::string stringMeta(size_t pos) const final;
|
||||
virtual vector<char> data() const final;
|
||||
|
||||
virtual SpaceType spaceType() const final;
|
||||
virtual DataHeader dataHeader() const final;
|
||||
|
||||
size_t get(size_t pos) const;
|
||||
size_t getMeta(size_t metapos) const;
|
||||
|
||||
virtual IndexType begin() const final;
|
||||
virtual IndexType end() const final;
|
||||
//virtual std::shared_ptr<VIWB> index() const final;
|
||||
|
||||
friend GenSingleRangeFactory<size_t,SpaceType::NUL,0>;
|
||||
|
||||
static constexpr bool defaultable = true;
|
||||
|
||||
static constexpr size_t ISSTATIC = 1;
|
||||
static constexpr size_t SIZE = 1;
|
||||
static constexpr bool HASMETACONT = false;
|
||||
|
||||
static GenSingleRangeFactory<size_t,SpaceType::NUL,0> factory()
|
||||
{ return GenSingleRangeFactory<size_t,SpaceType::NUL,0>(); }
|
||||
|
||||
protected:
|
||||
|
||||
GenSingleRange() = default;
|
||||
GenSingleRange(const GenSingleRange& in) = delete;
|
||||
|
||||
//GenSingleRange(size_t spinNum);
|
||||
};
|
||||
|
||||
typedef GenSingleRange<size_t,SpaceType::NUL,0> NullRange;
|
||||
typedef GenSingleRangeFactory<size_t,SpaceType::NUL,0> NullRF;
|
||||
|
||||
std::shared_ptr<NullRF> mkNUL(const char* dp, size_t size);
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // #ifndef __cxz_range_type_null_def__
|
||||
|
||||
#endif // #ifdef __cxz_ranges_header__
|
||||
|
||||
#endif // #ifdef include_range_type
|
|
@ -325,6 +325,8 @@ namespace CNORXZ
|
|||
RangePtr PRange<RangeT>::extend(const RangePtr& r) const
|
||||
{
|
||||
CXZ_ERROR("implement!!!");
|
||||
// if r is PRange of same Range, then just add parts
|
||||
// else derive and add meta of r
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,13 +51,7 @@ namespace CNORXZ
|
|||
|
||||
RangePtr prange(const SIndex<MetaType,S>& last) const;
|
||||
SizeT deepFormat() const;
|
||||
/*
|
||||
template <class Index>
|
||||
decltype(auto) formatFrom(const Index& ind) const;
|
||||
|
||||
template <class Index>
|
||||
decltype(auto) slice(const Sptr<Index>& ind) const;
|
||||
*/
|
||||
template <class Xpr, class F>
|
||||
decltype(auto) ifor(const Xpr& xpr, F&& f) const;
|
||||
|
||||
|
|
|
@ -147,69 +147,6 @@ namespace CNORXZ
|
|||
return toVec( mI->deepFormat() );
|
||||
}
|
||||
|
||||
/*
|
||||
template <class Index, typename Meta>
|
||||
Vector<XIndexPtr> XIndex<Index,Meta>::pack() const
|
||||
{
|
||||
if constexpr(has_static_sub<Index>::value){
|
||||
constexpr SizeT D = index_dim<Index>::value;
|
||||
return iter<0,D>
|
||||
( [&](auto i) { return xindexPtr(std::get<i>(mI->THIS().pack())); },
|
||||
[](const auto&... e) { return Vector<XIndexPtr>({ e ... }); } );
|
||||
}
|
||||
else if constexpr(has_sub<Index>::value){
|
||||
return mI->THIS().pack();
|
||||
}
|
||||
else {
|
||||
return Vector<XIndexPtr>();
|
||||
}
|
||||
}
|
||||
|
||||
template <class Index, typename Meta>
|
||||
Vector<SizeT> XIndex<Index,Meta>::blockSizes() const
|
||||
{
|
||||
if constexpr(has_static_sub<Index>::value){
|
||||
constexpr SizeT D = index_dim<Index>::value;
|
||||
const auto& bs = mI->THIS().blockSizes();
|
||||
return iter<0,D>
|
||||
( [&](auto i) { return std::get<i>(bs); },
|
||||
[](const auto&... e) { return Vector<SizeT>( { static_cast<SizeT>(e)... } ); } );
|
||||
}
|
||||
else if constexpr(has_sub<Index>::value) {
|
||||
return mI->THIS().blockSizes();
|
||||
}
|
||||
else {
|
||||
return Vector<SizeT>();
|
||||
}
|
||||
}
|
||||
|
||||
template <class Index, typename Meta>
|
||||
XIndexPtr XIndex<Index,Meta>::setBlockSizes(const Vector<SizeT>& bs)
|
||||
{
|
||||
if constexpr(has_static_sub<Index>::value){
|
||||
constexpr SizeT D = index_dim<Index>::value;
|
||||
CXZ_ASSERT(bs.size() == D,
|
||||
"got block sizes of wrong dimension: " << bs.size() << " vs " << D);
|
||||
typedef decltype(mI->THIS().blockSizes()) BT;
|
||||
Arr<UPos,D> arr;
|
||||
std::copy_n(bs.begin(), D, arr.begin());
|
||||
if constexpr(std::is_same<BT,Arr<UPos,D>>::value){
|
||||
mI->THIS().setBlockSizes(arr);
|
||||
return nullptr;
|
||||
}
|
||||
else {
|
||||
return xindexPtr(replaceBlockSizes(arr, std::static_pointer_cast<Index>(mI)));
|
||||
}
|
||||
}
|
||||
else if constexpr(has_sub<Index>::value) {
|
||||
mI->THIS().setBlockSizes(bs);
|
||||
return nullptr;
|
||||
}
|
||||
else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
*/
|
||||
template <class Index, typename Meta>
|
||||
String XIndex<Index,Meta>::stringMeta() const
|
||||
{
|
||||
|
@ -225,7 +162,6 @@ namespace CNORXZ
|
|||
template <class Index, typename Meta>
|
||||
XIndexBase& XIndex<Index,Meta>::at(const DType& meta)
|
||||
{
|
||||
// check!!!
|
||||
mI->at(std::any_cast<const Meta&>(meta.get()));
|
||||
return *this;
|
||||
}
|
||||
|
|
|
@ -41,9 +41,6 @@ namespace CNORXZ
|
|||
virtual UPos stepSize(const IndexId<0>& id) const = 0;
|
||||
virtual RangePtr prange(const XIndexPtr& last) const = 0;
|
||||
virtual Vector<SizeT> deepFormat() const = 0;
|
||||
//virtual Vector<XIndexPtr> pack() const = 0;
|
||||
//virtual Vector<SizeT> format() const = 0;
|
||||
//virtual XIndexPtr setBlockSizes(const Vector<SizeT>& bs) = 0;
|
||||
|
||||
virtual String stringMeta() const = 0;
|
||||
virtual DType meta() const = 0;
|
||||
|
@ -97,9 +94,6 @@ namespace CNORXZ
|
|||
virtual UPos stepSize(const IndexId<0>& id) const override final;
|
||||
virtual RangePtr prange(const XIndexPtr& last) const override final;
|
||||
virtual Vector<SizeT> deepFormat() const override final;
|
||||
//virtual Vector<XIndexPtr> pack() const override final;
|
||||
//virtual Vector<SizeT> format() const override final;
|
||||
//virtual XIndexPtr setBlockSizes(const Vector<SizeT>& bs) override final;
|
||||
|
||||
virtual String stringMeta() const override final;
|
||||
virtual DType meta() const override final;
|
||||
|
|
|
@ -179,7 +179,7 @@ namespace CNORXZ
|
|||
constexpr decltype(auto) operator<<(const PosT& a) const;
|
||||
};
|
||||
|
||||
// treat as scalar pos!!!
|
||||
// treat as scalar pos!
|
||||
class DPos : public ObjHandle<VPosBase>
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -1,567 +0,0 @@
|
|||
|
||||
#ifndef __cxz_xfor_h__
|
||||
#define __cxz_xfor_h__
|
||||
|
||||
#include <omp.h>
|
||||
|
||||
#include "base/base.h"
|
||||
#include "for_type.h"
|
||||
#include "for_utils.h"
|
||||
#include "exttype.h"
|
||||
|
||||
namespace CNORXZ
|
||||
{
|
||||
// 'HIDDEN FOR' CLASS for nested for loops in contractions a.s.o.
|
||||
// (NO COUNTING OF MASTER POSITION !!!!!)
|
||||
|
||||
|
||||
/*
|
||||
template <ForType FT = ForType::DEFAULT>
|
||||
struct PosForward
|
||||
{
|
||||
static inline size_t valuex(size_t last, size_t step, size_t pos)
|
||||
{
|
||||
return last + pos * step;
|
||||
}
|
||||
|
||||
static inline size_t value(size_t last, size_t max, size_t pos)
|
||||
{
|
||||
return last * max + pos;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct PosForward<ForType::HIDDEN>
|
||||
{
|
||||
static inline size_t valuex(size_t last, size_t step, size_t pos)
|
||||
{
|
||||
return last;
|
||||
}
|
||||
|
||||
static inline size_t value(size_t last, size_t max, size_t pos)
|
||||
{
|
||||
return last;
|
||||
}
|
||||
};
|
||||
|
||||
template <class IndexClass, class Expr>
|
||||
class SubExpr : public ExpressionBase
|
||||
{
|
||||
private:
|
||||
SubExpr() = default;
|
||||
|
||||
const IndexClass* mIndPtr;
|
||||
PtrId mSIPtr;
|
||||
size_t mSPos;
|
||||
size_t mMax;
|
||||
|
||||
Expr mExpr;
|
||||
typedef decltype(mkExt(0).extend(mExpr.rootSteps())) ExtType;
|
||||
ExtType mExt;
|
||||
|
||||
const Vector<SizeT>* mSubSet;
|
||||
|
||||
mutable ExtType mRootSteps;
|
||||
|
||||
public:
|
||||
typedef ExpressionBase EB;
|
||||
|
||||
static constexpr size_t LAYER = Expr::LAYER + 1;
|
||||
static constexpr size_t SIZE = Expr::SIZE + 1;
|
||||
//static constexpr size_t NHLAYER = Expr::NHLAYER + 1;
|
||||
|
||||
DEFAULT_MEMBERS_X(SubExpr);
|
||||
|
||||
SubExpr(const Sptr<IndexClass>& indPtr,
|
||||
std::intptr_t siptr,
|
||||
const vector<size_t>* subset, Expr expr);
|
||||
|
||||
SubExpr(const IndexClass* indPtr, std::intptr_t siptr,
|
||||
const vector<size_t>* subset, Expr expr);
|
||||
|
||||
inline void operator()(size_t mlast, DExt last) override final;
|
||||
inline void operator()(size_t mlast, ExtType last) ;
|
||||
inline void operator()(size_t mlast = 0) override final;
|
||||
|
||||
DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final;
|
||||
DExt dExtension() const override final;
|
||||
|
||||
auto rootSteps(std::intptr_t iPtrNum = 0) const -> ExtType;
|
||||
auto extension() const -> ExtType;
|
||||
};
|
||||
|
||||
template <ForType FT, size_t LAYER>
|
||||
struct NHLayer
|
||||
{
|
||||
template <class Expr>
|
||||
static constexpr size_t get()
|
||||
{
|
||||
return Expr::NHLAYER + 1;
|
||||
}
|
||||
};
|
||||
|
||||
template <size_t LAYER>
|
||||
struct NHLayer<ForType::HIDDEN,LAYER>
|
||||
{
|
||||
template <class Expr>
|
||||
static constexpr size_t get()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct NHLayer<ForType::DEFAULT,1>
|
||||
{
|
||||
template <class Expr>
|
||||
static constexpr size_t get()
|
||||
{
|
||||
return Expr::LAYER;
|
||||
}
|
||||
};
|
||||
|
||||
template <class IndexClass, class Expr, ForType FT, size_t DIV>
|
||||
class For : public ExpressionBase
|
||||
{
|
||||
private:
|
||||
For() = default;
|
||||
|
||||
typedef typename IndexClass::RangeType RangeType;
|
||||
const IndexClass* mIndPtr;
|
||||
size_t mSPos;
|
||||
size_t mMax;
|
||||
size_t mStep;
|
||||
|
||||
Expr mExpr;
|
||||
typedef decltype(mExpr.rootSteps()) ExtType;
|
||||
ExtType mExt;
|
||||
|
||||
mutable ExtType mRootSteps;
|
||||
|
||||
public:
|
||||
typedef ExpressionBase EB;
|
||||
|
||||
static constexpr size_t LAYER = Expr::LAYER + 1;
|
||||
static constexpr size_t SIZE = Expr::SIZE;
|
||||
//static constexpr size_t MAX = RangeType::SIZE / DIV;
|
||||
//static constexpr size_t NHLAYER = (FT == ForType::HIDDEN) ? 0 : Expr::NHLAYER + 1;
|
||||
|
||||
DEFAULT_MEMBERS(For);
|
||||
|
||||
For(const Sptr<IndexClass>& indPtr,
|
||||
size_t step, Expr expr);
|
||||
|
||||
For(const IndexClass* indPtr,
|
||||
size_t step, Expr expr);
|
||||
|
||||
inline void operator()(size_t mlast, DExt last) override final;
|
||||
inline void operator()(size_t mlast, ExtType last) ;
|
||||
inline void operator()(size_t mlast = 0) override final;
|
||||
|
||||
PFor<IndexClass,Expr> parallel() const;
|
||||
|
||||
DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final;
|
||||
DExt dExtension() const override final;
|
||||
|
||||
auto rootSteps(std::intptr_t iPtrNum = 0) const -> ExtType;
|
||||
auto extension() const -> ExtType;
|
||||
|
||||
};
|
||||
|
||||
class DynamicExpression : public ExpressionBase
|
||||
{
|
||||
private:
|
||||
|
||||
size_t mThreadId = 0;
|
||||
Sptr<ExpressionBase> mNext;
|
||||
|
||||
DynamicExpression() : mThreadId(omp_get_thread_num()) {}
|
||||
public:
|
||||
|
||||
static constexpr size_t LAYER = 0;
|
||||
static constexpr size_t SIZE = 0;
|
||||
static constexpr size_t NHLAYER = 0;
|
||||
|
||||
DynamicExpression(const DynamicExpression& in) :
|
||||
mThreadId(omp_get_thread_num()),
|
||||
mNext( (static_cast<int>(in.mThreadId) == omp_get_thread_num()) ?
|
||||
in.mNext : in.mNext->deepCopy()) {}
|
||||
DynamicExpression(DynamicExpression&& in) :
|
||||
mThreadId(omp_get_thread_num()),
|
||||
mNext( (static_cast<int>(in.mThreadId) == omp_get_thread_num()) ?
|
||||
in.mNext : in.mNext->deepCopy()) {}
|
||||
DynamicExpression& operator=(const DynamicExpression& in)
|
||||
{
|
||||
mThreadId = omp_get_thread_num();
|
||||
mNext = (static_cast<int>(in.mThreadId) == omp_get_thread_num()) ?
|
||||
in.mNext : in.mNext->deepCopy();
|
||||
return *this;
|
||||
}
|
||||
|
||||
DynamicExpression& operator=(DynamicExpression&& in)
|
||||
{
|
||||
mThreadId = omp_get_thread_num();
|
||||
mNext = (static_cast<int>(in.mThreadId) == omp_get_thread_num()) ?
|
||||
in.mNext : in.mNext->deepCopy();
|
||||
return *this;
|
||||
}
|
||||
|
||||
DynamicExpression(const Sptr<ExpressionBase>& next) :
|
||||
mNext(next)
|
||||
{}
|
||||
|
||||
template <class Expr>
|
||||
DynamicExpression(const ExpressionBase& next) :
|
||||
mNext(std::make_shared<Expr>(next))
|
||||
{}
|
||||
|
||||
template <class Expr>
|
||||
DynamicExpression(Expr ex) : mNext( std::make_shared<Expr>(ex) ) {}
|
||||
|
||||
virtual Sptr<ExpressionBase> deepCopy() const override final
|
||||
{
|
||||
return std::make_shared<DynamicExpression>(*this);
|
||||
}
|
||||
|
||||
inline void operator()(size_t mlast, DExt last) override final;
|
||||
inline void operator()(size_t mlast, DExtT last) { (*this)(mlast,last.get()); }
|
||||
inline void operator()(size_t mlast = 0) override final;
|
||||
|
||||
inline DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final;
|
||||
inline DExt dExtension() const override final;
|
||||
|
||||
inline DExtT rootSteps(std::intptr_t iPtrNum = 0) const { return DExtT(dRootSteps(iPtrNum)); }
|
||||
inline DExtT extension() const { return DExtT(dExtension()); }
|
||||
|
||||
};
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
/* ========================= *
|
||||
* --- TEMPLATE CODE --- *
|
||||
* ========================= */
|
||||
|
||||
|
||||
namespace CNORXZ
|
||||
{
|
||||
|
||||
/*****************
|
||||
* F o r *
|
||||
*****************/
|
||||
/*
|
||||
template <class IndexClass, class Expr, ForType FT, size_t DIV>
|
||||
For<IndexClass,Expr,FT,DIV>::For(const Sptr<IndexClass>& indPtr,
|
||||
size_t step, Expr expr) :
|
||||
mIndPtr(indPtr.get()), mSPos(mIndPtr->pos()), mMax(mIndPtr->max()), mStep(step),
|
||||
mExpr(expr), mExt(mExpr.rootSteps( reinterpret_cast<std::intptr_t>( mIndPtr )))
|
||||
{
|
||||
assert(mMax % DIV == 0);
|
||||
assert(mIndPtr != nullptr);
|
||||
}
|
||||
|
||||
template <class IndexClass, class Expr, ForType FT, size_t DIV>
|
||||
For<IndexClass,Expr,FT,DIV>::For(const IndexClass* indPtr,
|
||||
size_t step, Expr expr) :
|
||||
mIndPtr(indPtr), mSPos(mIndPtr->pos()), mMax(mIndPtr->max()), mStep(step),
|
||||
mExpr(expr), mExt(mExpr.rootSteps( reinterpret_cast<std::intptr_t>( mIndPtr )))
|
||||
{
|
||||
//VCHECK(mMax);
|
||||
//VCHECK(DIV);
|
||||
//assert(mMax % DIV == 0);
|
||||
assert(mIndPtr != nullptr);
|
||||
}
|
||||
|
||||
template <class IndexClass, class Expr, ForType FT, size_t DIV>
|
||||
inline void For<IndexClass,Expr,FT,DIV>::operator()(size_t mlast, DExt last)
|
||||
{
|
||||
operator()(mlast, std::dynamic_pointer_cast<ExtT<ExtType>>(last)->ext());
|
||||
//operator()(mlast, *reinterpret_cast<ExtType const*>(last.first));
|
||||
}
|
||||
|
||||
template <class IndexClass, class Expr, ForType FT, size_t DIV>
|
||||
inline void For<IndexClass,Expr,FT,DIV>::operator()(size_t mlast,
|
||||
ExtType last)
|
||||
{
|
||||
typedef typename IndexClass::RangeType RangeType;
|
||||
for(size_t pos = 0u; pos != ForBound<RangeType::ISSTATIC>::template bound<RangeType::SIZE,DIV>(mMax); ++pos){
|
||||
const size_t mnpos = PosForward<FT>::valuex(mlast, mStep, pos);
|
||||
const ExtType npos = last + mExt*pos;
|
||||
mExpr(mnpos, npos);
|
||||
}
|
||||
}
|
||||
|
||||
template <class IndexClass, class Expr, ForType FT, size_t DIV>
|
||||
inline void For<IndexClass,Expr,FT,DIV>::operator()(size_t mlast)
|
||||
{
|
||||
typedef typename IndexClass::RangeType RangeType;
|
||||
ExtType last = rootSteps();
|
||||
last.zero();
|
||||
for(size_t pos = 0u; pos != ForBound<RangeType::ISSTATIC>::template bound<RangeType::SIZE,DIV>(mMax); ++pos){
|
||||
const size_t mnpos = PosForward<FT>::valuex(mlast, mStep, pos);
|
||||
const ExtType npos = last + mExt*pos;
|
||||
mExpr(mnpos, npos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class IndexClass, class Expr, ForType FT, size_t DIV>
|
||||
auto For<IndexClass,Expr,FT,DIV>::rootSteps(std::intptr_t iPtrNum) const
|
||||
-> ExtType
|
||||
{
|
||||
return mExpr.rootSteps(iPtrNum);
|
||||
}
|
||||
|
||||
template <class IndexClass, class Expr, ForType FT, size_t DIV>
|
||||
auto For<IndexClass,Expr,FT,DIV>::extension() const
|
||||
-> ExtType
|
||||
{
|
||||
return mExt;
|
||||
}
|
||||
|
||||
template <class IndexClass, class Expr, ForType FT, size_t DIV>
|
||||
DExt For<IndexClass,Expr,FT,DIV>::dRootSteps(std::intptr_t iPtrNum) const
|
||||
{
|
||||
return std::make_shared<ExtT<ExtType>>(rootSteps(iPtrNum));
|
||||
//mRootSteps = rootSteps(iPtrNum);
|
||||
//return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mRootSteps),
|
||||
// sizeof(ExtType)/sizeof(size_t));
|
||||
}
|
||||
|
||||
template <class IndexClass, class Expr, ForType FT, size_t DIV>
|
||||
DExt For<IndexClass,Expr,FT,DIV>::dExtension() const
|
||||
{
|
||||
return std::make_shared<ExtT<ExtType>>(mExt);
|
||||
//return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mExt),
|
||||
// sizeof(ExtType)/sizeof(size_t));
|
||||
}
|
||||
|
||||
template <class IndexClass, class Expr, ForType FT, size_t DIV>
|
||||
PFor<IndexClass,Expr,DIV> For<IndexClass,Expr,FT,DIV>::parallel() const
|
||||
{
|
||||
static_assert(FT == ForType::DEFAULT, "hidden for not parallelizable");
|
||||
return PFor<IndexClass,Expr,DIV>(mIndPtr, mStep, mExpr);
|
||||
}
|
||||
*/
|
||||
/******************
|
||||
* P F o r *
|
||||
******************/
|
||||
/*
|
||||
template <class IndexClass, class Expr, size_t DIV>
|
||||
PFor<IndexClass,Expr,DIV>::PFor(const Sptr<IndexClass>& indPtr,
|
||||
size_t step, Expr expr) :
|
||||
mIndPtr(indPtr.get()), mSPos(mIndPtr->pos()), mMax(mIndPtr->max()), mStep(step),
|
||||
mExpr(expr), mExt(mExpr.rootSteps( reinterpret_cast<std::intptr_t>( mIndPtr )))
|
||||
{
|
||||
//assert(mMax % DIV == 0);
|
||||
assert(mIndPtr != nullptr);
|
||||
}
|
||||
|
||||
template <class IndexClass, class Expr, size_t DIV>
|
||||
PFor<IndexClass,Expr,DIV>::PFor(const IndexClass* indPtr,
|
||||
size_t step, Expr expr) :
|
||||
mIndPtr(indPtr), mSPos(mIndPtr->pos()), mMax(mIndPtr->max()), mStep(step),
|
||||
mExpr(expr), mExt(mExpr.rootSteps( reinterpret_cast<std::intptr_t>( mIndPtr )))
|
||||
{
|
||||
assert(mMax % DIV == 0);
|
||||
assert(mIndPtr != nullptr);
|
||||
}
|
||||
|
||||
template <class IndexClass, class Expr, size_t DIV>
|
||||
inline void PFor<IndexClass,Expr,DIV>::operator()(size_t mlast, DExt last)
|
||||
{
|
||||
operator()(mlast, std::dynamic_pointer_cast<ExtT<ExtType>>(last)->ext());
|
||||
//operator()(mlast, *reinterpret_cast<ExtType const*>(last.first));
|
||||
}
|
||||
|
||||
template <class IndexClass, class Expr, size_t DIV>
|
||||
inline void PFor<IndexClass,Expr,DIV>::operator()(size_t mlast,
|
||||
ExtType last)
|
||||
{
|
||||
CHECK;
|
||||
typedef typename IndexClass::RangeType RangeType;
|
||||
int pos = 0;
|
||||
size_t mnpos = 0;
|
||||
ExtType npos;
|
||||
#pragma omp parallel shared(mExpr) private(pos,mnpos,npos)
|
||||
{
|
||||
auto expr = mExpr;
|
||||
#pragma omp for nowait
|
||||
for(pos = 0; pos < static_cast<int>(ForBound<RangeType::ISSTATIC>::template bound<RangeType::SIZE,DIV>(mMax)); pos++){
|
||||
mnpos = PosForward<ForType::DEFAULT>::valuex(mlast, mStep, pos);
|
||||
npos = last + mExt*static_cast<size_t>(pos);
|
||||
expr(mnpos, npos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class IndexClass, class Expr, size_t DIV>
|
||||
inline void PFor<IndexClass,Expr,DIV>::operator()(size_t mlast)
|
||||
{
|
||||
CHECK;
|
||||
ExtType last = rootSteps();
|
||||
last.zero();
|
||||
int pos = 0;
|
||||
size_t mnpos = 0;
|
||||
ExtType npos = rootSteps();
|
||||
npos.zero();
|
||||
#pragma omp parallel shared(mExpr) private(pos,mnpos,npos)
|
||||
{
|
||||
auto expr = mExpr;
|
||||
#pragma omp for nowait
|
||||
for(pos = 0; pos < static_cast<int>(ForBound<RangeType::ISSTATIC>::template bound<RangeType::SIZE,DIV>(mMax)); pos++){
|
||||
mnpos = PosForward<ForType::DEFAULT>::valuex(mlast, mStep, pos);
|
||||
npos = last + mExt*static_cast<size_t>(pos);
|
||||
expr(mnpos, npos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class IndexClass, class Expr, size_t DIV>
|
||||
auto PFor<IndexClass,Expr,DIV>::rootSteps(std::intptr_t iPtrNum) const
|
||||
-> ExtType
|
||||
{
|
||||
return mExpr.rootSteps(iPtrNum);
|
||||
}
|
||||
|
||||
template <class IndexClass, class Expr, size_t DIV>
|
||||
auto PFor<IndexClass,Expr,DIV>::extension() const
|
||||
-> ExtType
|
||||
{
|
||||
return mExt;
|
||||
}
|
||||
|
||||
template <class IndexClass, class Expr, size_t DIV>
|
||||
DExt PFor<IndexClass,Expr,DIV>::dRootSteps(std::intptr_t iPtrNum) const
|
||||
{
|
||||
return std::make_shared<ExtT<ExtType>>(rootSteps(iPtrNum));
|
||||
//mRootSteps = rootSteps(iPtrNum);
|
||||
//return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mRootSteps),
|
||||
// sizeof(ExtType)/sizeof(size_t));
|
||||
}
|
||||
|
||||
template <class IndexClass, class Expr, size_t DIV>
|
||||
DExt PFor<IndexClass,Expr,DIV>::dExtension() const
|
||||
{
|
||||
return std::make_shared<ExtT<ExtType>>(mExt);
|
||||
//return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mExt),
|
||||
// sizeof(ExtType)/sizeof(size_t));
|
||||
}
|
||||
*/
|
||||
|
||||
/****************
|
||||
* SubExpr *
|
||||
****************/
|
||||
/*
|
||||
template <class IndexClass, class Expr>
|
||||
SubExpr<IndexClass,Expr>::SubExpr(const Sptr<IndexClass>& indPtr,
|
||||
std::intptr_t siptr,
|
||||
const vector<size_t>* subset, Expr expr) :
|
||||
mIndPtr(indPtr.get()), mSIPtr(siptr), mSPos(mIndPtr->pos()), mMax(mIndPtr->max()),
|
||||
mExpr(expr),
|
||||
mExt( mkExt(0).extend( mExpr.rootSteps( reinterpret_cast<std::intptr_t>( mIndPtr )) ) ),
|
||||
mSubSet(subset)
|
||||
{
|
||||
assert(mIndPtr != nullptr);
|
||||
}
|
||||
|
||||
template <class IndexClass, class Expr>
|
||||
SubExpr<IndexClass,Expr>::SubExpr(const IndexClass* indPtr, std::intptr_t siptr,
|
||||
const vector<size_t>* subset, Expr expr) :
|
||||
mIndPtr(indPtr), mSIPtr(siptr), mSPos(mIndPtr->pos()), mMax(mIndPtr->max()),
|
||||
mExpr(expr),
|
||||
mExt( mkExt(0).extend( mExpr.rootSteps( reinterpret_cast<std::intptr_t>( mIndPtr )) ) ),
|
||||
mSubSet(subset)
|
||||
{
|
||||
assert(mIndPtr != nullptr);
|
||||
}
|
||||
|
||||
template <class IndexClass, class Expr>
|
||||
inline void SubExpr<IndexClass,Expr>::operator()(size_t mlast, DExt last)
|
||||
{
|
||||
operator()(mlast, std::dynamic_pointer_cast<ExtT<ExtType>>(last)->ext());
|
||||
//operator()(mlast, *reinterpret_cast<ExtType const*>(last.first));
|
||||
}
|
||||
|
||||
template <class IndexClass, class Expr>
|
||||
inline void SubExpr<IndexClass,Expr>::operator()(size_t mlast,
|
||||
ExtType last)
|
||||
{
|
||||
const size_t pos = (*mSubSet)[last.val()];
|
||||
const size_t mnpos = mlast;
|
||||
const ExtType npos = last + mExt*pos;
|
||||
mExpr(mnpos, getX<1>( npos ));
|
||||
}
|
||||
|
||||
template <class IndexClass, class Expr>
|
||||
inline void SubExpr<IndexClass,Expr>::operator()(size_t mlast)
|
||||
{
|
||||
ExtType last = rootSteps();
|
||||
last.zero();
|
||||
const size_t pos = (*mSubSet)[last.val()];
|
||||
const size_t mnpos = mlast;
|
||||
const ExtType npos = last + mExt*pos;
|
||||
mExpr(mnpos, getX<1>( npos ));
|
||||
}
|
||||
|
||||
|
||||
template <class IndexClass, class Expr>
|
||||
auto SubExpr<IndexClass,Expr>::rootSteps(std::intptr_t iPtrNum) const
|
||||
-> ExtType
|
||||
{
|
||||
return mkExt(iPtrNum == mSIPtr ? 1 : 0).extend(mExpr.rootSteps(iPtrNum));
|
||||
}
|
||||
|
||||
template <class IndexClass, class Expr>
|
||||
auto SubExpr<IndexClass,Expr>::extension() const
|
||||
-> ExtType
|
||||
{
|
||||
return mExt;
|
||||
}
|
||||
|
||||
template <class IndexClass, class Expr>
|
||||
DExt SubExpr<IndexClass,Expr>::dRootSteps(std::intptr_t iPtrNum) const
|
||||
{
|
||||
return std::make_shared<ExtT<ExtType>>(rootSteps(iPtrNum));
|
||||
//mRootSteps = rootSteps(iPtrNum);
|
||||
//return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mRootSteps),
|
||||
//sizeof(ExtType)/sizeof(size_t));
|
||||
}
|
||||
|
||||
template <class IndexClass, class Expr>
|
||||
DExt SubExpr<IndexClass,Expr>::dExtension() const
|
||||
{
|
||||
return std::make_shared<ExtT<ExtType>>(mExt);
|
||||
//return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mExt),
|
||||
// sizeof(ExtType)/sizeof(size_t));
|
||||
}
|
||||
*/
|
||||
/***************************
|
||||
* DynamicExpression *
|
||||
***************************/
|
||||
/*
|
||||
inline void DynamicExpression::operator()(size_t mlast, DExt last)
|
||||
{
|
||||
(*mNext)(mlast,last);
|
||||
}
|
||||
|
||||
inline void DynamicExpression::operator()(size_t mlast)
|
||||
{
|
||||
(*mNext)(mlast);
|
||||
}
|
||||
|
||||
inline DExt DynamicExpression::dRootSteps(std::intptr_t iPtrNum) const
|
||||
{
|
||||
return mNext->dRootSteps(iPtrNum);
|
||||
}
|
||||
|
||||
inline DExt DynamicExpression::dExtension() const
|
||||
{
|
||||
return mNext->dExtension();
|
||||
}
|
||||
|
||||
*/
|
||||
} // namespace CNORXZInternal
|
||||
|
||||
#endif
|
|
@ -1,148 +0,0 @@
|
|||
|
||||
#include "ranges/rheader.h"
|
||||
#include "ranges/x_to_string.h"
|
||||
#include "ranges/ranges_header.cc.h"
|
||||
|
||||
namespace CNORXZ
|
||||
{
|
||||
std::shared_ptr<NullRF> mkNUL(const char* dp, size_t size)
|
||||
{
|
||||
return std::make_shared<NullRF>();
|
||||
}
|
||||
|
||||
/********************
|
||||
* GenSingleRange *
|
||||
********************/
|
||||
|
||||
std::shared_ptr<GenSingleRange<size_t,SpaceType::NUL,0>>
|
||||
GenSingleRangeFactory<size_t,SpaceType::NUL,0>::mRInstance = nullptr;
|
||||
|
||||
std::shared_ptr<NullRange> nullr()
|
||||
{
|
||||
static NullRF nrf; // just that mRInstance is initialized
|
||||
static auto nr = std::dynamic_pointer_cast<NullRange>( nrf.create() );
|
||||
return NullRF::mRInstance;
|
||||
}
|
||||
|
||||
std::shared_ptr<NullIndex> nulli()
|
||||
{
|
||||
return std::make_shared<NullIndex>(nullr());
|
||||
}
|
||||
|
||||
GenSingleRangeFactory<size_t,SpaceType::NUL,0>::GenSingleRangeFactory()
|
||||
{
|
||||
// Singleton
|
||||
if(not mRInstance){
|
||||
if(not mProd){
|
||||
mProd = std::shared_ptr<oType>( new GenSingleRange<size_t,SpaceType::NUL,0>() );
|
||||
setSelf();
|
||||
}
|
||||
mRInstance = std::dynamic_pointer_cast<NullRange>( mProd );
|
||||
} else {
|
||||
mProd = mRInstance;
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<RangeBase> GenSingleRangeFactory<size_t,SpaceType::NUL,0>::create()
|
||||
{
|
||||
return mProd;
|
||||
}
|
||||
|
||||
/********************
|
||||
* GenSingleRange *
|
||||
********************/
|
||||
|
||||
size_t GenSingleRange<size_t,SpaceType::NUL,0>::get(size_t pos) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t GenSingleRange<size_t,SpaceType::NUL,0>::getMeta(size_t metapos) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t GenSingleRange<size_t,SpaceType::NUL,0>::size() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
size_t GenSingleRange<size_t,SpaceType::NUL,0>::dim() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
SpaceType GenSingleRange<size_t,SpaceType::NUL,0>::spaceType() const
|
||||
{
|
||||
return SpaceType::NUL;
|
||||
}
|
||||
|
||||
vector<size_t> GenSingleRange<size_t,SpaceType::NUL,0>::typeNum() const
|
||||
{
|
||||
return {NumTypeMap<size_t>::num()};
|
||||
}
|
||||
|
||||
size_t GenSingleRange<size_t,SpaceType::NUL,0>::cmeta(char* target, size_t pos) const
|
||||
{
|
||||
*reinterpret_cast<size_t*>(target) = 0;
|
||||
return sizeof(size_t);
|
||||
}
|
||||
|
||||
size_t GenSingleRange<size_t,SpaceType::NUL,0>::cmetaSize() const
|
||||
{
|
||||
return sizeof(size_t);
|
||||
}
|
||||
|
||||
std::string GenSingleRange<size_t,SpaceType::NUL,0>::stringMeta(size_t pos) const
|
||||
{
|
||||
return std::to_string(get(pos));
|
||||
}
|
||||
|
||||
vector<char> GenSingleRange<size_t,SpaceType::NUL,0>::data() const
|
||||
{
|
||||
DataHeader h = dataHeader();
|
||||
vector<char> out;
|
||||
out.reserve(h.metaSize + sizeof(DataHeader));
|
||||
char* hcp = reinterpret_cast<char*>(&h);
|
||||
out.insert(out.end(), hcp, hcp + sizeof(DataHeader));
|
||||
return out;
|
||||
}
|
||||
|
||||
DataHeader GenSingleRange<size_t,SpaceType::NUL,0>::dataHeader() const
|
||||
{
|
||||
DataHeader h;
|
||||
h.spaceType = static_cast<int>( SpaceType::NUL );
|
||||
h.metaSize = 0;
|
||||
h.multiple = 0;
|
||||
return h;
|
||||
}
|
||||
|
||||
typename GenSingleRange<size_t,SpaceType::NUL,0>::IndexType GenSingleRange<size_t,SpaceType::NUL,0>::begin() const
|
||||
{
|
||||
GenSingleIndex<size_t,SpaceType::NUL,0> i( std::dynamic_pointer_cast<GenSingleRange<size_t,SpaceType::NUL,0> >
|
||||
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
|
||||
i = 0;
|
||||
return i;
|
||||
}
|
||||
|
||||
typename GenSingleRange<size_t,SpaceType::NUL,0>::IndexType GenSingleRange<size_t,SpaceType::NUL,0>::end() const
|
||||
{
|
||||
GenSingleIndex<size_t,SpaceType::NUL,0> i( std::dynamic_pointer_cast<GenSingleRange<size_t,SpaceType::NUL,0> >
|
||||
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
|
||||
i = size();
|
||||
return i;
|
||||
}
|
||||
|
||||
// put this in the interface class !!!
|
||||
/*
|
||||
std::shared_ptr<VIWB> GenSingleRange<size_t,SpaceType::NUL,0>::index() const
|
||||
{
|
||||
typedef IndexWrapper<IndexType> IW;
|
||||
return std::make_shared<IW>
|
||||
( std::make_shared<IndexType>
|
||||
( std::dynamic_pointer_cast<GenSingleRange<size_t,SpaceType::NUL,0> >
|
||||
( std::shared_ptr<RangeBase>( RB::mThis ) ) ) );
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "ranges/ranges.h"
|
||||
#include "operation/operation.h"
|
||||
#include "array/array.h"
|
||||
#include "test_numbers.h"
|
||||
|
||||
namespace
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
//#include "cnorxz.h"
|
||||
#include "ranges/ranges.h"
|
||||
#include "array/array.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue