use meta operation in fma (should be faster)
This commit is contained in:
parent
1aa5ed10d9
commit
ae534e2493
4 changed files with 37 additions and 28 deletions
|
@ -112,7 +112,7 @@ namespace MultiArrayTools
|
|||
return mkOperation( mFunc, ConstOperationRoot<typename SRanges::IndexType::MetaType,SRanges>( mkMAObject( inds ), inds ) ... );
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
template <typename T, class Function, class... SRanges>
|
||||
auto FunctionalMultiArray<T,Function,SRanges...>::
|
||||
exec(const std::shared_ptr<typename SRanges::IndexType>&... inds) const
|
||||
|
@ -120,5 +120,13 @@ namespace MultiArrayTools
|
|||
{
|
||||
return mkOperation( mFunc, mkOpObject(inds) ... );
|
||||
}
|
||||
|
||||
*/
|
||||
template <typename T, class Function, class... SRanges>
|
||||
auto FunctionalMultiArray<T,Function,SRanges...>::
|
||||
exec(const std::shared_ptr<typename SRanges::IndexType>&... inds) const
|
||||
-> Operation<T,Function,MetaOperationRoot<SRanges>...>
|
||||
{
|
||||
return mkOperation( mFunc, MetaOperationRoot<SRanges>( inds ) ... );
|
||||
}
|
||||
|
||||
} // namespace MultiArrayTools
|
||||
|
|
|
@ -133,8 +133,9 @@ namespace MultiArrayTools
|
|||
|
||||
auto exec(const std::shared_ptr<typename SRanges::IndexType>&... inds) const
|
||||
// -> decltype( mkOperation( mFunc, ConstOperationRoot<typename SRanges::IndexType::MetaType,SRanges>( mkMAObject( inds ), inds) ... ) );
|
||||
-> decltype( mkOperation( mFunc, mkOpObject(inds) ... ) );
|
||||
|
||||
//-> decltype( mkOperation( mFunc, mkOpObject(inds) ... ) );
|
||||
-> Operation<T,Function,MetaOperationRoot<SRanges>...>;
|
||||
|
||||
virtual ConstOperationRoot<T,SRanges...>
|
||||
operator()(const std::shared_ptr<typename SRanges::IndexType>&... inds) const override;
|
||||
|
||||
|
|
|
@ -261,41 +261,43 @@ namespace MultiArrayTools
|
|||
* MetaOperationRoot *
|
||||
****************************/
|
||||
|
||||
template <class... Ranges>
|
||||
MetaOperationRoot<Ranges...>::
|
||||
MetaOperationRoot(const IndexType& ind) :
|
||||
template <class Range>
|
||||
MetaOperationRoot<Range>::
|
||||
MetaOperationRoot(const std::shared_ptr<IndexType>& ind) :
|
||||
mIndex( ind ) { }
|
||||
|
||||
template <class... Ranges>
|
||||
|
||||
template <class Range>
|
||||
template <class ET>
|
||||
inline typename MetaOperationRoot<Ranges...>::value_type
|
||||
MetaOperationRoot<Ranges...>::get(ET pos) const
|
||||
inline typename MetaOperationRoot<Range>::value_type
|
||||
MetaOperationRoot<Range>::get(ET pos) const
|
||||
{
|
||||
//VCHECK(pos.val());
|
||||
//VCHECK(mDataPtr);
|
||||
//VCHECK(mDataPtr[pos.val()])
|
||||
return mIndex.meta(pos.val());
|
||||
return mIndex->range()->get( pos.val() );
|
||||
}
|
||||
|
||||
template <class... Ranges>
|
||||
template <class Range>
|
||||
template <class ET>
|
||||
inline const MetaOperationRoot<Ranges...>& MetaOperationRoot<Ranges...>::set(ET pos) const
|
||||
inline const MetaOperationRoot<Range>& MetaOperationRoot<Range>::set(ET pos) const
|
||||
{
|
||||
mIndex = pos.val();
|
||||
assert(0);
|
||||
//(*mIndex) = pos.val();
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class... Ranges>
|
||||
MExt<void> MetaOperationRoot<Ranges...>::rootSteps(std::intptr_t iPtrNum) const
|
||||
template <class Range>
|
||||
MExt<void> MetaOperationRoot<Range>::rootSteps(std::intptr_t iPtrNum) const
|
||||
{
|
||||
return MExt<void>(getStepSize( mIndex, iPtrNum ));
|
||||
return MExt<void>(getStepSize( *mIndex, iPtrNum ));
|
||||
//return MExt<void>(getStepSize( getRootIndices( mIndex->info() ), iPtrNum ));
|
||||
}
|
||||
|
||||
|
||||
template <class... Ranges>
|
||||
template <class Range>
|
||||
template <class Expr>
|
||||
Expr MetaOperationRoot<Ranges...>::loop(Expr exp) const
|
||||
Expr MetaOperationRoot<Range>::loop(Expr exp) const
|
||||
{
|
||||
return exp;
|
||||
}
|
||||
|
|
|
@ -217,21 +217,19 @@ namespace MultiArrayTools
|
|||
return StaticCast<T,Op>(op);
|
||||
}
|
||||
|
||||
template <class... Ranges>
|
||||
class MetaOperationRoot : public OperationTemplate<std::tuple<typename Ranges::IndexType...>,
|
||||
MetaOperationRoot<Ranges...> >
|
||||
template <class Range>
|
||||
class MetaOperationRoot : public OperationTemplate<typename Range::MetaType,
|
||||
MetaOperationRoot<Range> >
|
||||
{
|
||||
public:
|
||||
|
||||
typedef ContainerIndex<std::tuple<typename Ranges::IndexType::MetaType...>,
|
||||
typename Ranges::IndexType...> IndexType;
|
||||
typedef typename Range::IndexType IndexType;
|
||||
typedef typename IndexType::MetaType value_type;
|
||||
typedef OperationBase<value_type,MetaOperationRoot<Ranges...> > OT;
|
||||
typedef ContainerRange<value_type,Ranges...> CRange;
|
||||
typedef OperationBase<value_type,MetaOperationRoot<Range> > OT;
|
||||
|
||||
static constexpr size_t SIZE = 1;
|
||||
|
||||
MetaOperationRoot(const IndexType& ind);
|
||||
MetaOperationRoot(const std::shared_ptr<IndexType>& ind);
|
||||
|
||||
template <class ET>
|
||||
inline value_type get(ET pos) const;
|
||||
|
@ -248,7 +246,7 @@ namespace MultiArrayTools
|
|||
|
||||
//MultiArrayBase<T,Ranges...> const& mArrayRef;
|
||||
//const T* mDataPtr;
|
||||
IndexType mIndex;
|
||||
std::shared_ptr<IndexType> mIndex;
|
||||
};
|
||||
|
||||
template <typename T, class... Ranges>
|
||||
|
|
Loading…
Reference in a new issue