im com (vectorization (wrong access instance) + parallel not working)
This commit is contained in:
parent
a841782115
commit
bba1c6944a
2 changed files with 116 additions and 75 deletions
|
@ -181,46 +181,46 @@ namespace MultiArrayTools
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class IOp, class AT, class Target, class OpClass, OpIndexAff OIA>
|
template <typename T, class Func, class AT, class Target, class OpClass, OpIndexAff OIA>
|
||||||
AssignmentExpr<T,IOp,AT,Target,OpClass,OIA>::AssignmentExpr(const AccessTemplate<AT>& dataAcc, const Target& tar, const OpClass& sec) :
|
AssignmentExpr<T,Func,AT,Target,OpClass,OIA>::AssignmentExpr(const AccessTemplate<AT>& dataAcc, const Target& tar, const OpClass& sec) :
|
||||||
mTar(tar), mSec(sec), mDataAcc(static_cast<const AT&>(dataAcc)) {}
|
mTar(tar), mSec(sec), mDataAcc(static_cast<const AT&>(dataAcc)) {}
|
||||||
|
|
||||||
template <typename T, class IOp, class AT, class Target, class OpClass, OpIndexAff OIA>
|
template <typename T, class Func, class AT, class Target, class OpClass, OpIndexAff OIA>
|
||||||
inline void AssignmentExpr<T,IOp,AT,Target,OpClass,OIA>::operator()(size_t start)
|
inline void AssignmentExpr<T,Func,AT,Target,OpClass,OIA>::operator()(size_t start)
|
||||||
{
|
{
|
||||||
ExtType last = rootSteps();
|
ExtType last = rootSteps();
|
||||||
last.zero();
|
last.zero();
|
||||||
// TODO: ask MA container for data (ptr)!!!
|
// TODO: ask MA container for data (ptr)!!!
|
||||||
mDataAcc.template exec<typename IOp::Func>(opIndexResolve<OIA>(start,last),mSec,last.next());
|
mDataAcc.template exec<Func>(opIndexResolve<OIA>(start,last),mSec,last.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class IOp, class AT, class Target, class OpClass, OpIndexAff OIA>
|
template <typename T, class Func, class AT, class Target, class OpClass, OpIndexAff OIA>
|
||||||
inline void AssignmentExpr<T,IOp,AT,Target,OpClass,OIA>::operator()(size_t start, ExtType last)
|
inline void AssignmentExpr<T,Func,AT,Target,OpClass,OIA>::operator()(size_t start, ExtType last)
|
||||||
{
|
{
|
||||||
mDataAcc.template exec<typename IOp::Func>(opIndexResolve<OIA>(start,last),mSec,last.next());
|
mDataAcc.template exec<Func>(opIndexResolve<OIA>(start,last),mSec,last.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class IOp, class AT, class Target, class OpClass, OpIndexAff OIA>
|
template <typename T, class Func, class AT, class Target, class OpClass, OpIndexAff OIA>
|
||||||
typename AssignmentExpr<T,IOp,AT,Target,OpClass,OIA>::ExtType
|
typename AssignmentExpr<T,Func,AT,Target,OpClass,OIA>::ExtType
|
||||||
AssignmentExpr<T,IOp,AT,Target,OpClass,OIA>::rootSteps(std::intptr_t iPtrNum) const
|
AssignmentExpr<T,Func,AT,Target,OpClass,OIA>::rootSteps(std::intptr_t iPtrNum) const
|
||||||
{
|
{
|
||||||
return mTar.rootSteps(iPtrNum).extend( mSec.rootSteps(iPtrNum) );
|
return mTar.rootSteps(iPtrNum).extend( mSec.rootSteps(iPtrNum) );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class IOp, class AT, class Target, class OpClass, OpIndexAff OIA>
|
template <typename T, class Func, class AT, class Target, class OpClass, OpIndexAff OIA>
|
||||||
inline void AssignmentExpr<T,IOp,AT,Target,OpClass,OIA>::operator()(size_t mlast, DExt last)
|
inline void AssignmentExpr<T,Func,AT,Target,OpClass,OIA>::operator()(size_t mlast, DExt last)
|
||||||
{
|
{
|
||||||
(*this)(mlast, std::dynamic_pointer_cast<ExtT<ExtType>>(last)->ext());
|
(*this)(mlast, std::dynamic_pointer_cast<ExtT<ExtType>>(last)->ext());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class IOp, class AT, class Target, class OpClass, OpIndexAff OIA>
|
template <typename T, class Func, class AT, class Target, class OpClass, OpIndexAff OIA>
|
||||||
inline DExt AssignmentExpr<T,IOp,AT,Target,OpClass,OIA>::dRootSteps(std::intptr_t iPtrNum) const
|
inline DExt AssignmentExpr<T,Func,AT,Target,OpClass,OIA>::dRootSteps(std::intptr_t iPtrNum) const
|
||||||
{
|
{
|
||||||
return std::make_shared<ExtT<ExtType>>(rootSteps(iPtrNum));
|
return std::make_shared<ExtT<ExtType>>(rootSteps(iPtrNum));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class IOp, class AT, class Target, class OpClass, OpIndexAff OIA>
|
template <typename T, class Func, class AT, class Target, class OpClass, OpIndexAff OIA>
|
||||||
inline DExt AssignmentExpr<T,IOp,AT,Target,OpClass,OIA>::dExtension() const
|
inline DExt AssignmentExpr<T,Func,AT,Target,OpClass,OIA>::dExtension() const
|
||||||
{
|
{
|
||||||
return nullptr; //???!!!
|
return nullptr; //???!!!
|
||||||
}
|
}
|
||||||
|
@ -556,87 +556,87 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
template <class IOp, class OpClass>
|
template <class Func, class Access, class OpClass>
|
||||||
auto OperationRoot<T,Ranges...>::asx(const OpClass& in) const
|
auto OperationRoot<T,Ranges...>::asx(const OpClass& in) const
|
||||||
{
|
{
|
||||||
static_assert( OpClass::SIZE == decltype(in.rootSteps())::SIZE, "Ext Size mismatch" );
|
static_assert(Access::VSIZE > 0, "Access::VSIZE failed");
|
||||||
return mIndex.ifor(1,in.loop(AssignmentExpr<T,IOp,PointerAccess<T>,OperationRoot<T,Ranges...>,OpClass,OpIndexAff::TARGET>
|
return mIndex.ifor(1,this->template asxExpr<Func,Access>(in)).template vec<Access::VSIZE>();
|
||||||
(mDataAcc,*this,in))).template vec<IOp::VSIZE>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
template <class IOp, class OpClass>
|
template <class Func, class Access, class OpClass>
|
||||||
auto OperationRoot<T,Ranges...>::asxExpr(const OpClass& in) const
|
auto OperationRoot<T,Ranges...>::asxExpr(const OpClass& in) const
|
||||||
{
|
{
|
||||||
static_assert( OpClass::SIZE == decltype(in.rootSteps())::SIZE, "Ext Size mismatch" );
|
static_assert( OpClass::SIZE == decltype(in.rootSteps())::SIZE, "Ext Size mismatch" );
|
||||||
return in.loop(AssignmentExpr<T,IOp,PointerAccess<T>,OperationRoot<T,Ranges...>,OpClass>
|
return in.loop(AssignmentExpr<T,Func,PointerAccess<T>,OperationRoot<T,Ranges...>,OpClass>
|
||||||
(mDataAcc,*this,in));
|
(mDataAcc,*this,in));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
template <class IOp, class OpClass, class Index>
|
template <class Func, class Access, class OpClass, class Index>
|
||||||
auto OperationRoot<T,Ranges...>::asx(const OpClass& in, const std::shared_ptr<Index>& i) const
|
auto OperationRoot<T,Ranges...>::asx(const OpClass& in, const std::shared_ptr<Index>& i) const
|
||||||
{
|
{
|
||||||
static_assert( OpClass::SIZE == decltype(in.rootSteps())::SIZE, "Ext Size mismatch" );
|
static_assert(Access::VSIZE > 0, "Access::VSIZE failed");
|
||||||
return i->ifor(1,in.loop(AssignmentExpr<T,IOp,PointerAccess<T>,OperationRoot<T,Ranges...>,OpClass>
|
return i->ifor(1,this->template asxExpr<Func,Access>(in)).template vec<Access::VSIZE>();
|
||||||
(mDataAcc,*this,in))).template vec<IOp::VSIZE>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
template <class OpClass>
|
template <class OpClass>
|
||||||
auto OperationRoot<T,Ranges...>::assign(const OpClass& in) const
|
auto OperationRoot<T,Ranges...>::assign(const OpClass& in) const
|
||||||
{
|
{
|
||||||
return this->template asx<IAssign<T>>(in);
|
return this->template asx<identity<T>,PointerAccess<T>>(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
template <class OpClass>
|
template <class OpClass>
|
||||||
auto OperationRoot<T,Ranges...>::assignExpr(const OpClass& in) const
|
auto OperationRoot<T,Ranges...>::assignExpr(const OpClass& in) const
|
||||||
{
|
{
|
||||||
return this->template asxExpr<IAssign<T>>(in);
|
return this->template asxExpr<identity<T>,PointerAccess<T>>(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
template <class OpClass, class Index>
|
template <class OpClass, class Index>
|
||||||
auto OperationRoot<T,Ranges...>::assign(const OpClass& in, const std::shared_ptr<Index>& i) const
|
auto OperationRoot<T,Ranges...>::assign(const OpClass& in, const std::shared_ptr<Index>& i) const
|
||||||
{
|
{
|
||||||
return this->template asx<IAssign<T>>(in,i);
|
return this->template asx<identity<T>,PointerAccess<T>>(in,i);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
template <class OpClass>
|
template <class OpClass>
|
||||||
auto OperationRoot<T,Ranges...>::plus(const OpClass& in) const
|
auto OperationRoot<T,Ranges...>::plus(const OpClass& in) const
|
||||||
{
|
{
|
||||||
return this->template asx<IPlus<T>>(in);
|
return this->template asx<xxxplus<T>,PointerAccess<T>>(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
template <class OpClass, class Index>
|
template <class OpClass, class Index>
|
||||||
auto OperationRoot<T,Ranges...>::plus(const OpClass& in, const std::shared_ptr<Index>& i) const
|
auto OperationRoot<T,Ranges...>::plus(const OpClass& in, const std::shared_ptr<Index>& i) const
|
||||||
{
|
{
|
||||||
return this->template asx<IPlus<T>>(in,i);
|
return this->template asx<xxxplus<T>,PointerAccess<T>>(in,i);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <bool VABLE, template <typename> class F, typename TarOp, class OpClass>
|
template <bool VABLE, class Func, typename TarOp, class OpClass>
|
||||||
inline void vexec(TarOp& th, const OpClass& in)
|
inline void vexec(TarOp& th, const OpClass& in)
|
||||||
{
|
{
|
||||||
|
// VECTORIZATION!!!
|
||||||
|
// PARALLEL!!!
|
||||||
if constexpr(VABLE){
|
if constexpr(VABLE){
|
||||||
CHECK;
|
CHECK;
|
||||||
typedef typename TarOp::value_type T;
|
typedef typename TarOp::value_type T;
|
||||||
auto x = th.template asx<IVAccess<T,F<T>>>(in);
|
auto x = th.template asx<Func,VPointerAccess<T>>(in);
|
||||||
if(x.rootSteps(x.vI()) == 1){
|
//if(x.rootSteps(x.vI()) == 1){
|
||||||
//if(0){
|
if(0){
|
||||||
CHECK;
|
CHECK;
|
||||||
x();
|
x();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
th.template asx<IAccess<T,F<T>>>(in)();
|
th.template asx<Func,PointerAccess<T>>(in)();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
typedef typename TarOp::value_type T;
|
typedef typename TarOp::value_type T;
|
||||||
IAccess<T,F<T>> tmp;
|
//IAccess<T,F<T>> tmp;
|
||||||
th.template asx<decltype(tmp)>(in)();
|
th.template asx<Func,PointerAccess<T>>(in)();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -644,7 +644,8 @@ namespace MultiArrayTools
|
||||||
template <class OpClass>
|
template <class OpClass>
|
||||||
OperationRoot<T,Ranges...>& OperationRoot<T,Ranges...>::operator=(const OpClass& in)
|
OperationRoot<T,Ranges...>& OperationRoot<T,Ranges...>::operator=(const OpClass& in)
|
||||||
{
|
{
|
||||||
vexec<OpClass::VABLE,identity>(*this,in);
|
//asx<identity<T>>(in)();
|
||||||
|
vexec<OpClass::VABLE,identity<T>>(*this,in);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -652,7 +653,8 @@ namespace MultiArrayTools
|
||||||
template <class OpClass>
|
template <class OpClass>
|
||||||
OperationRoot<T,Ranges...>& OperationRoot<T,Ranges...>::operator+=(const OpClass& in)
|
OperationRoot<T,Ranges...>& OperationRoot<T,Ranges...>::operator+=(const OpClass& in)
|
||||||
{
|
{
|
||||||
vexec<OpClass::VABLE,xxxplus>(*this,in);
|
//asx<xxxplus<T>>(in)();
|
||||||
|
vexec<OpClass::VABLE,xxxplus<T>>(*this,in);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -661,13 +663,13 @@ namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
return operator=<OperationRoot<T,Ranges...> >(in);
|
return operator=<OperationRoot<T,Ranges...> >(in);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
ParallelOperationRoot<T,Ranges...> OperationRoot<T,Ranges...>::par()
|
ParallelOperationRoot<T,Ranges...> OperationRoot<T,Ranges...>::par()
|
||||||
{
|
{
|
||||||
return ParallelOperationRoot<T,Ranges...>(mOrigDataPtr, mIndex);
|
return ParallelOperationRoot<T,Ranges...>(mOrigDataPtr, mIndex);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline T& OperationRoot<T,Ranges...>::get(ET pos) const
|
inline T& OperationRoot<T,Ranges...>::get(ET pos) const
|
||||||
|
@ -722,7 +724,7 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
/*******************************
|
/*******************************
|
||||||
* ParallelOperationRoot *
|
* ParallelOperationRoot *
|
||||||
*******************************/
|
******************************
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
ParallelOperationRoot<T,Ranges...>::
|
ParallelOperationRoot<T,Ranges...>::
|
||||||
|
@ -749,30 +751,30 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
template <class IOp, class OpClass>
|
template <class Func, class OpClass>
|
||||||
auto ParallelOperationRoot<T,Ranges...>::asx(const OpClass& in) const
|
auto ParallelOperationRoot<T,Ranges...>::asx(const OpClass& in) const
|
||||||
{
|
{
|
||||||
static_assert( OpClass::SIZE == decltype(in.rootSteps())::SIZE, "Ext Size mismatch" );
|
static_assert( OpClass::SIZE == decltype(in.rootSteps())::SIZE, "Ext Size mismatch" );
|
||||||
return mIndex.pifor(1,in.loop(AssignmentExpr<T,IOp,PointerAccess<T>,ParallelOperationRoot<T,Ranges...>,OpClass,OpIndexAff::TARGET>
|
return mIndex.pifor(1,in.loop(AssignmentExpr<T,Func,PointerAccess<T>,ParallelOperationRoot<T,Ranges...>,OpClass,OpIndexAff::TARGET>
|
||||||
(mDataAcc,*this,in))).template vec<IOp::VSIZE>();
|
(mDataAcc,*this,in))).template vec<Access::VSIZE>();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
template <class IOp, class OpClass>
|
template <class Func, class OpClass>
|
||||||
auto ParallelOperationRoot<T,Ranges...>::asxExpr(const OpClass& in) const
|
auto ParallelOperationRoot<T,Ranges...>::asxExpr(const OpClass& in) const
|
||||||
{
|
{
|
||||||
static_assert( OpClass::SIZE == decltype(in.rootSteps())::SIZE, "Ext Size mismatch" );
|
static_assert( OpClass::SIZE == decltype(in.rootSteps())::SIZE, "Ext Size mismatch" );
|
||||||
return in.loop(AssignmentExpr<T,IOp,PointerAccess<T>,ParallelOperationRoot<T,Ranges...>,OpClass>
|
return in.loop(AssignmentExpr<T,Func,PointerAccess<T>,ParallelOperationRoot<T,Ranges...>,OpClass>
|
||||||
(mDataAcc,*this,in));
|
(mDataAcc,*this,in));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
template <class IOp, class OpClass, class Index>
|
template <class Func, class OpClass, class Index>
|
||||||
auto ParallelOperationRoot<T,Ranges...>::asx(const OpClass& in, const std::shared_ptr<Index>& i) const
|
auto ParallelOperationRoot<T,Ranges...>::asx(const OpClass& in, const std::shared_ptr<Index>& i) const
|
||||||
{
|
{
|
||||||
static_assert( OpClass::SIZE == decltype(in.rootSteps())::SIZE, "Ext Size mismatch" );
|
static_assert( OpClass::SIZE == decltype(in.rootSteps())::SIZE, "Ext Size mismatch" );
|
||||||
return i->pifor(1,in.loop(AssignmentExpr<T,IOp,PointerAccess<T>,ParallelOperationRoot<T,Ranges...>,OpClass>
|
return i->pifor(1,in.loop(AssignmentExpr<T,Func,PointerAccess<T>,ParallelOperationRoot<T,Ranges...>,OpClass>
|
||||||
(mDataAcc,*this,in))).template vec<IOp::VSIZE>();
|
(mDataAcc,*this,in))).template vec<Access::VSIZE>();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
|
@ -837,7 +839,7 @@ namespace MultiArrayTools
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline T& ParallelOperationRoot<T,Ranges...>::get(ET pos) const
|
inline T& ParallelOperationRoot<T,Ranges...>::get(ET pos) const
|
||||||
{
|
{
|
||||||
return mDataPtr[pos.val()/*+mOff*/];
|
return mDataPtr[pos.val()+mOff];
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
|
@ -875,7 +877,7 @@ namespace MultiArrayTools
|
||||||
auto i = mIndex;
|
auto i = mIndex;
|
||||||
return mOrigDataPtr + i().pos();
|
return mOrigDataPtr + i().pos();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/************************
|
/************************
|
||||||
* OperationValue *
|
* OperationValue *
|
||||||
|
|
|
@ -133,12 +133,12 @@ namespace MultiArrayTools
|
||||||
// empty, implement corresponding constructors...!!!
|
// empty, implement corresponding constructors...!!!
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
template <class F>
|
template <class F>
|
||||||
using VFunc = decltype(mkVFunc(std::declval<F>()));
|
using VFunc = decltype(mkVFunc(std::declval<F>()));
|
||||||
*/
|
|
||||||
template <class F>
|
//template <class F>
|
||||||
using VFunc = F;
|
//using VFunc = F;
|
||||||
|
|
||||||
template <typename T, class F, class... Indices>
|
template <typename T, class F, class... Indices>
|
||||||
class OpAccess
|
class OpAccess
|
||||||
|
@ -177,9 +177,9 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T, class F>
|
//template <typename T, class F>
|
||||||
using IVAccess = IAccess<T,F>;
|
//using IVAccess = IAccess<T,F>;
|
||||||
/*
|
|
||||||
template <typename T, class F>
|
template <typename T, class F>
|
||||||
struct IVAccess
|
struct IVAccess
|
||||||
{
|
{
|
||||||
|
@ -196,7 +196,7 @@ namespace MultiArrayTools
|
||||||
VFunc<F>::selfApply(*reinterpret_cast<value_type*>(t+pos),op.template vget<value_type>(e));
|
VFunc<F>::selfApply(*reinterpret_cast<value_type*>(t+pos),op.template vget<value_type>(e));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
*/
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using xxxplus = plus<T>;
|
using xxxplus = plus<T>;
|
||||||
|
@ -246,6 +246,8 @@ namespace MultiArrayTools
|
||||||
typedef T value_type;
|
typedef T value_type;
|
||||||
typedef T in_type;
|
typedef T in_type;
|
||||||
|
|
||||||
|
static constexpr size_t VSIZE = sizeof(value_type) / sizeof(in_type);
|
||||||
|
|
||||||
friend class AccessTemplate<PointerAccess<T>>;
|
friend class AccessTemplate<PointerAccess<T>>;
|
||||||
private:
|
private:
|
||||||
PointerAccess() = default;
|
PointerAccess() = default;
|
||||||
|
@ -273,8 +275,45 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
class VPointerAccess : public AccessTemplate<VPointerAccess<T>>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef typename VType<T>::type value_type;
|
||||||
|
typedef T in_type;
|
||||||
|
|
||||||
template <typename T, class IOp, class AT, class Target, class OpClass, OpIndexAff OIA=OpIndexAff::EXTERN>
|
static constexpr size_t VSIZE = sizeof(value_type) / sizeof(in_type);
|
||||||
|
|
||||||
|
friend class AccessTemplate<VPointerAccess<T>>;
|
||||||
|
private:
|
||||||
|
VPointerAccess() = default;
|
||||||
|
|
||||||
|
T* mPtr = nullptr;
|
||||||
|
T* mOrigPtr = nullptr;
|
||||||
|
|
||||||
|
public:
|
||||||
|
VPointerAccess(T* ptr, T* origPtr) : mPtr(ptr), mOrigPtr(origPtr) {}
|
||||||
|
|
||||||
|
VPointerAccess(const VPointerAccess& in) = default;
|
||||||
|
VPointerAccess(VPointerAccess&& in) = default;
|
||||||
|
VPointerAccess& operator=(const VPointerAccess& in) = default;
|
||||||
|
VPointerAccess& operator=(VPointerAccess&& in) = default;
|
||||||
|
|
||||||
|
VType<T>* get(size_t pos) { return reinterpret_cast<VType<T>*>(mPtr+pos); }
|
||||||
|
VType<T>* get(size_t pos) const { return reinterpret_cast<VType<T>*>(mPtr+pos); }
|
||||||
|
VPointerAccess<T>& set(size_t pos) { mPtr = mOrigPtr + pos; return *this; }
|
||||||
|
VType<T>* oget(size_t pos) const { return reinterpret_cast<VType<T>*>(mOrigPtr+pos); }
|
||||||
|
|
||||||
|
template <class F, typename Op, class ExtType>
|
||||||
|
inline void exec(size_t pos, const Op& op, ExtType e) const
|
||||||
|
{
|
||||||
|
CHECK;
|
||||||
|
F::selfApply(*get(pos),op.vget(e));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T, class Func, class AT, class Target, class OpClass, OpIndexAff OIA=OpIndexAff::EXTERN>
|
||||||
class AssignmentExpr : public ExpressionBase
|
class AssignmentExpr : public ExpressionBase
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -299,7 +338,7 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
virtual std::shared_ptr<ExpressionBase> deepCopy() const override final
|
virtual std::shared_ptr<ExpressionBase> deepCopy() const override final
|
||||||
{
|
{
|
||||||
return std::make_shared<AssignmentExpr<T,IOp,PointerAccess<T>,Target,OpClass,OIA>>(*this);
|
return std::make_shared<AssignmentExpr<T,Func,PointerAccess<T>,Target,OpClass,OIA>>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void operator()(size_t start = 0);
|
inline void operator()(size_t start = 0);
|
||||||
|
@ -578,13 +617,13 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
OperationRoot(T* data, const IndexType& ind);
|
OperationRoot(T* data, const IndexType& ind);
|
||||||
|
|
||||||
template <class IOp, class OpClass>
|
template <class Func, class Access, class OpClass>
|
||||||
auto asx(const OpClass& in) const;
|
auto asx(const OpClass& in) const;
|
||||||
|
|
||||||
template <class IOp, class OpClass>
|
template <class Func, class Access, class OpClass>
|
||||||
auto asxExpr(const OpClass& in) const;
|
auto asxExpr(const OpClass& in) const;
|
||||||
|
|
||||||
template <class IOp, class OpClass, class Index>
|
template <class Func, class Access, class OpClass, class Index>
|
||||||
auto asx(const OpClass& in, const std::shared_ptr<Index>& i) const;
|
auto asx(const OpClass& in, const std::shared_ptr<Index>& i) const;
|
||||||
|
|
||||||
template <class OpClass>
|
template <class OpClass>
|
||||||
|
@ -610,7 +649,7 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
OperationRoot& operator=(const OperationRoot& in);
|
OperationRoot& operator=(const OperationRoot& in);
|
||||||
|
|
||||||
ParallelOperationRoot<T,Ranges...> par();
|
auto par() { return *this; }
|
||||||
|
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline T& get(ET pos) const;
|
inline T& get(ET pos) const;
|
||||||
|
@ -633,7 +672,7 @@ namespace MultiArrayTools
|
||||||
-> Slice<T,typename Indices::RangeType...>;
|
-> Slice<T,typename Indices::RangeType...>;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
/*
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
class ParallelOperationRoot : public OperationTemplate<T,ParallelOperationRoot<T,Ranges...> >
|
class ParallelOperationRoot : public OperationTemplate<T,ParallelOperationRoot<T,Ranges...> >
|
||||||
{
|
{
|
||||||
|
@ -661,13 +700,13 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
ParallelOperationRoot(T* data, const IndexType& ind);
|
ParallelOperationRoot(T* data, const IndexType& ind);
|
||||||
|
|
||||||
template <class IOp, class OpClass>
|
template <class Func, class OpClass>
|
||||||
auto asx(const OpClass& in) const;
|
auto asx(const OpClass& in) const;
|
||||||
|
|
||||||
template <class IOp, class OpClass>
|
template <class Func, class OpClass>
|
||||||
auto asxExpr(const OpClass& in) const;
|
auto asxExpr(const OpClass& in) const;
|
||||||
|
|
||||||
template <class IOp, class OpClass, class Index>
|
template <class Func, class OpClass, class Index>
|
||||||
auto asx(const OpClass& in, const std::shared_ptr<Index>& i) const;
|
auto asx(const OpClass& in, const std::shared_ptr<Index>& i) const;
|
||||||
|
|
||||||
template <class OpClass>
|
template <class OpClass>
|
||||||
|
@ -710,7 +749,7 @@ namespace MultiArrayTools
|
||||||
T* data() const;
|
T* data() const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class OperationValue : public OperationTemplate<T,OperationValue<T> >
|
class OperationValue : public OperationTemplate<T,OperationValue<T> >
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue