From d7e5098639104cea5515a8dd991f7d6d0df1cb44 Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Thu, 15 Feb 2018 16:24:54 +0100 Subject: [PATCH] remove VIWB stuff --- src/include/helper_tools.h | 9 ++-- src/include/ranges/anonymous_range.h | 3 +- src/include/ranges/container_range.h | 25 ----------- src/include/ranges/index_base.h | 8 ---- src/include/ranges/index_info.h | 1 - src/include/ranges/multi_range.h | 28 +----------- src/include/ranges/range_base.h | 3 -- .../ranges/range_types/classic_range.h | 2 +- src/include/ranges/range_types/spin_range.h | 2 +- src/include/ranges/rbase_def.h | 8 ---- src/include/ranges/rpack_num.h | 34 --------------- src/include/ranges/single_range.h | 22 +--------- src/include/ranges/vindex_base.h | 35 --------------- src/include/ranges/vindex_wrapper.h | 43 ------------------- src/lib/ranges/anonymous_range.cc | 7 +-- src/lib/ranges/range_types/classic_range.cc | 3 +- src/lib/ranges/range_types/spin_range.cc | 3 +- src/tests/op_perf_test.cc | 2 - src/tests/op_unit_test.cc | 2 - 19 files changed, 18 insertions(+), 222 deletions(-) delete mode 100644 src/include/ranges/vindex_base.h delete mode 100644 src/include/ranges/vindex_wrapper.h diff --git a/src/include/helper_tools.h b/src/include/helper_tools.h index 8f53e4e..e133713 100644 --- a/src/include/helper_tools.h +++ b/src/include/helper_tools.h @@ -36,19 +36,18 @@ namespace MultiArrayTools auto getIndex(std::shared_ptr range) -> std::shared_ptr { - return std::dynamic_pointer_cast > - ( range->index() )->get(); + return std::make_shared(range); } template - auto getIndex() -> std::shared_ptr + auto getIndex() + -> std::shared_ptr { static_assert( RangeType::defaultable, /*typeid(typename RangeType).name() + */" is not defaultable" ); static auto f = RangeType::factory(); static auto r = std::dynamic_pointer_cast( f.create() ); - return std::dynamic_pointer_cast > - ( r->index() )->get(); + return std::make_shared(r); } template diff --git a/src/include/ranges/anonymous_range.h b/src/include/ranges/anonymous_range.h index 55d43e8..8f0a8bc 100644 --- a/src/include/ranges/anonymous_range.h +++ b/src/include/ranges/anonymous_range.h @@ -44,8 +44,7 @@ namespace MultiArrayTools virtual IndexType begin() const override; virtual IndexType end() const override; - virtual std::shared_ptr index() const override; - + friend AnonymousRangeFactory; protected: diff --git a/src/include/ranges/container_range.h b/src/include/ranges/container_range.h index f2f0c8c..fa9240d 100644 --- a/src/include/ranges/container_range.h +++ b/src/include/ranges/container_range.h @@ -81,7 +81,6 @@ namespace MultiArrayTools template auto getPtr() -> decltype( std::get( mIPack ) )&; - std::shared_ptr getVPtr(size_t n); size_t getStepSize(size_t n); std::vector infoVec() const; @@ -153,8 +152,6 @@ namespace MultiArrayTools virtual IndexType begin() const override; virtual IndexType end() const override; - - virtual std::shared_ptr index() const override; friend ContainerRangeFactory; @@ -329,17 +326,6 @@ namespace MultiArrayTools return std::get( mIPack ); } - template - std::shared_ptr ContainerIndex::getVPtr(size_t n) - { - if(n >= sizeof...(Indices)){ - assert(0); - // throw !! - } - ContainerIndex const* t = this; - return RPackNum::getIndexPtr(*t, n); - } - template size_t ContainerIndex::getStepSize(size_t n) { @@ -480,17 +466,6 @@ namespace MultiArrayTools i = size(); return i; } - - template - std::shared_ptr ContainerRange::index() const - { - typedef IndexWrapper IW; - return std::make_shared - ( std::make_shared - ( std::dynamic_pointer_cast > - ( std::shared_ptr( RB::mThis ) ) ) ); - } - } // end namespace MultiArrayTools diff --git a/src/include/ranges/index_base.h b/src/include/ranges/index_base.h index 99b6b0f..0fc2b2e 100644 --- a/src/include/ranges/index_base.h +++ b/src/include/ranges/index_base.h @@ -10,7 +10,6 @@ #include "rbase_def.h" #include "range_base.h" #include "index_type.h" -#include "vindex_wrapper.h" #include "index_info.h" #include "xfor/xfor.h" @@ -52,13 +51,6 @@ namespace MultiArrayTools std::shared_ptr vrange() const { return mRangePtr; } - /*auto range() const -> decltype( I::S_range(THIS()) ) { return I::S_range(THIS()); } - - template - auto getPtr() const -> decltype(I::template S_get(THIS())) - { return I::template S_get(THIS()); } - */ - std::shared_ptr getVPtr(size_t n) const { return THIS().getVPtr(n); } std::vector infoVec() const { return THIS().infoVec(); } diff --git a/src/include/ranges/index_info.h b/src/include/ranges/index_info.h index 01efba3..8e0d4a1 100644 --- a/src/include/ranges/index_info.h +++ b/src/include/ranges/index_info.h @@ -7,7 +7,6 @@ #include #include #include -#include "vindex_base.h" #include "index_type.h" namespace MultiArrayTools diff --git a/src/include/ranges/multi_range.h b/src/include/ranges/multi_range.h index c6d27fe..c58839d 100644 --- a/src/include/ranges/multi_range.h +++ b/src/include/ranges/multi_range.h @@ -96,8 +96,7 @@ namespace MultiArrayTools template auto getPtr() -> decltype( std::get( mIPack ) )&; - - std::shared_ptr getVPtr(size_t n); + size_t getStepSize(size_t n); std::vector infoVec() const; @@ -174,8 +173,6 @@ namespace MultiArrayTools virtual IndexType begin() const override; virtual IndexType end() const override; - virtual std::shared_ptr index() const override; - friend MultiRangeFactory; static constexpr bool defaultable = false; @@ -373,18 +370,7 @@ namespace MultiArrayTools { return std::get(mIPack); } - - template - std::shared_ptr MultiIndex::getVPtr(size_t n) - { - if(n >= sizeof...(Indices)){ - assert(0); - // throw !! - } - MultiIndex const* t = this; - return RPackNum::getIndexPtr(*t, n); - } - + template size_t MultiIndex::getStepSize(size_t n) { @@ -528,16 +514,6 @@ namespace MultiArrayTools i = size(); return i; } - - template - std::shared_ptr MultiRange::index() const - { - typedef IndexWrapper IW; - return std::make_shared - ( std::make_shared - ( std::dynamic_pointer_cast > - ( std::shared_ptr( RB::mThis ) ) ) ); - } } #endif diff --git a/src/include/ranges/range_base.h b/src/include/ranges/range_base.h index a0f38c4..e10f847 100644 --- a/src/include/ranges/range_base.h +++ b/src/include/ranges/range_base.h @@ -13,7 +13,6 @@ namespace MultiArrayTools { class RangeBase; } -#include "vindex_base.h" namespace MultiArrayTools { @@ -55,8 +54,6 @@ namespace MultiArrayTools virtual size_t size() const = 0; virtual size_t dim() const = 0; - - virtual std::shared_ptr index() const = 0; bool operator==(const RangeBase& in) const; bool operator!=(const RangeBase& in) const; diff --git a/src/include/ranges/range_types/classic_range.h b/src/include/ranges/range_types/classic_range.h index c2cc71c..5ff0649 100644 --- a/src/include/ranges/range_types/classic_range.h +++ b/src/include/ranges/range_types/classic_range.h @@ -37,7 +37,7 @@ namespace MultiArrayTools virtual IndexType begin() const override; virtual IndexType end() const override; - virtual std::shared_ptr index() const override; + //virtual std::shared_ptr index() const override; friend SingleRangeFactory; diff --git a/src/include/ranges/range_types/spin_range.h b/src/include/ranges/range_types/spin_range.h index 2e330ed..c9215f2 100644 --- a/src/include/ranges/range_types/spin_range.h +++ b/src/include/ranges/range_types/spin_range.h @@ -41,7 +41,7 @@ namespace MultiArrayTools virtual IndexType begin() const override; virtual IndexType end() const override; - virtual std::shared_ptr index() const override; + //virtual std::shared_ptr index() const override; friend SingleRangeFactory; diff --git a/src/include/ranges/rbase_def.h b/src/include/ranges/rbase_def.h index 5521720..5d0cc67 100644 --- a/src/include/ranges/rbase_def.h +++ b/src/include/ranges/rbase_def.h @@ -22,14 +22,6 @@ namespace MultiArrayTools template class RangeInterface; - // index_base.h - class VirtualIndexWrapperBase; - typedef VirtualIndexWrapperBase VIWB; - - // index_base.h - template - class IndexWrapper; - // index_base.h template class IndexInterface; diff --git a/src/include/ranges/rpack_num.h b/src/include/ranges/rpack_num.h index e41f3b3..ab76076 100644 --- a/src/include/ranges/rpack_num.h +++ b/src/include/ranges/rpack_num.h @@ -3,7 +3,6 @@ #define __rpack_num_h__ #include -#include "vindex_wrapper.h" #include "index_info.h" namespace MultiArrayHelper @@ -41,28 +40,6 @@ namespace MultiArrayHelper template struct RPackNum { - template - static std::shared_ptr getIndex(const IndexType& in, size_t n) - { - if(n == N){ - return make_viwb( in.template get() ); - } - else { - return RPackNum::getIndex(in, n); - } - } - - template - static std::shared_ptr getIndexPtr(const IndexType& in, size_t n) - { - if(n == N){ - return make_viwb( in.template getPtr() ); - } - else { - return RPackNum::getIndexPtr(in, n); - } - } - template static void initBlockSizes(std::array& bs, std::tuple...>& ip) @@ -271,17 +248,6 @@ namespace MultiArrayHelper template<> struct RPackNum<0> { - template - static std::shared_ptr getIndex(const IndexType& in, size_t n) - { - return make_viwb( in.template get<0>() ); - } - - template - static std::shared_ptr getIndexPtr(const IndexType& in, size_t n) - { - return make_viwb( in.template getPtr<0>() ); - } template static void initBlockSizes(std::array& bs, diff --git a/src/include/ranges/single_range.h b/src/include/ranges/single_range.h index f85f7b4..73df9a0 100644 --- a/src/include/ranges/single_range.h +++ b/src/include/ranges/single_range.h @@ -57,7 +57,6 @@ namespace MultiArrayTools template void getPtr(); - std::shared_ptr getVPtr(size_t n); size_t getStepSize(size_t n); std::vector infoVec() const; @@ -104,8 +103,7 @@ namespace MultiArrayTools virtual IndexType begin() const override; virtual IndexType end() const override; - virtual std::shared_ptr index() const override; - + friend SingleRangeFactory; static constexpr bool defaultable = false; @@ -221,12 +219,6 @@ namespace MultiArrayTools template void SingleIndex::getPtr() {} - template - std::shared_ptr SingleIndex::getVPtr(size_t n) - { - return std::shared_ptr(); - } - template std::vector SingleIndex::infoVec() const { @@ -348,18 +340,6 @@ namespace MultiArrayTools i = size(); return i; } - - // put this in the interface class !!! - template - std::shared_ptr SingleRange::index() const - { - typedef IndexWrapper IW; - return std::make_shared - ( std::make_shared - ( std::dynamic_pointer_cast > - ( std::shared_ptr( RB::mThis ) ) ) ); - } - } #include "range_types/header.h" diff --git a/src/include/ranges/vindex_base.h b/src/include/ranges/vindex_base.h deleted file mode 100644 index 114d2e1..0000000 --- a/src/include/ranges/vindex_base.h +++ /dev/null @@ -1,35 +0,0 @@ - -#ifndef __vindex_base_h__ -#define __vindex_base_h__ - -//#include "ranges/range_base.h" -#include "ranges/index_type.h" -#include "base_def.h" - -namespace MultiArrayTools -{ - -#ifndef __range_base_h__ - class RangeBase; -#endif - - class VirtualIndexWrapperBase - { - public: - DEFAULT_MEMBERS(VirtualIndexWrapperBase); - - virtual IndexType type() const = 0; - virtual size_t dim() const = 0; - virtual size_t pos() const = 0; - virtual size_t max() const = 0; - virtual std::shared_ptr rangePtr() const = 0; - virtual std::shared_ptr getPtr(size_t n) const = 0; - virtual std::intptr_t getPtrNum() const = 0; - virtual size_t getStepSize(size_t n) const = 0; - }; - - typedef VirtualIndexWrapperBase VIWB; - -} // end namespace MultiArrayTools - -#endif diff --git a/src/include/ranges/vindex_wrapper.h b/src/include/ranges/vindex_wrapper.h deleted file mode 100644 index 705269f..0000000 --- a/src/include/ranges/vindex_wrapper.h +++ /dev/null @@ -1,43 +0,0 @@ - -#ifndef __vindex_wrapper_h__ -#define __vindex_wrapper_h__ - -#include "ranges/vindex_base.h" - -namespace MultiArrayTools -{ - - template - std::shared_ptr > make_viwb(std::shared_ptr idxPtr) - { - return std::make_shared >(idxPtr); - } - - template - class IndexWrapper : public VirtualIndexWrapperBase - { - public: - - DEFAULT_MEMBERS(IndexWrapper); - - IndexWrapper(std::shared_ptr idxPtr) : mIdxPtr(idxPtr) {} - - virtual IndexType type() const override { return mIdxPtr->type(); } - virtual size_t dim() const override { return mIdxPtr->dim(); } - virtual size_t pos() const override { return mIdxPtr->pos(); } - virtual size_t max() const override { return mIdxPtr->max(); } - virtual std::shared_ptr rangePtr() const override { return mIdxPtr->vrange(); } - virtual std::shared_ptr getPtr(size_t n) const override - { return mIdxPtr->getVPtr(n); } - virtual std::intptr_t getPtrNum() const override { return reinterpret_cast( mIdxPtr.get() ); } - virtual size_t getStepSize(size_t n) const override { return mIdxPtr->getStepSize(n); } - - std::shared_ptr get() const { return mIdxPtr; } // unwrap - - private: - std::shared_ptr mIdxPtr; - }; - -} - -#endif diff --git a/src/lib/ranges/anonymous_range.cc b/src/lib/ranges/anonymous_range.cc index f0ce0fc..0d3bdd5 100644 --- a/src/lib/ranges/anonymous_range.cc +++ b/src/lib/ranges/anonymous_range.cc @@ -56,16 +56,17 @@ namespace MultiArrayTools } // put this in the interface class !!! + /* std::shared_ptr AnonymousRange::index() const { //typedef IndexWrapper IW; return std::shared_ptr(); - /* std::make_shared + std::make_shared (std::make_shared ( std::dynamic_pointer_cast - ( std::shared_ptr( RB::mThis ) ) ) ); */ //!!!! + ( std::shared_ptr( RB::mThis ) ) ) ); //!!!! } - + */ /***************** * Functions * diff --git a/src/lib/ranges/range_types/classic_range.cc b/src/lib/ranges/range_types/classic_range.cc index 7641e24..97038bb 100644 --- a/src/lib/ranges/range_types/classic_range.cc +++ b/src/lib/ranges/range_types/classic_range.cc @@ -64,6 +64,7 @@ namespace MultiArrayTools } // put this in the interface class !!! + /* std::shared_ptr SingleRange::index() const { typedef IndexWrapper IW; @@ -72,6 +73,6 @@ namespace MultiArrayTools ( std::dynamic_pointer_cast > ( std::shared_ptr( RB::mThis ) ) ) ); } - + */ } diff --git a/src/lib/ranges/range_types/spin_range.cc b/src/lib/ranges/range_types/spin_range.cc index cdc8f5f..83b0e55 100644 --- a/src/lib/ranges/range_types/spin_range.cc +++ b/src/lib/ranges/range_types/spin_range.cc @@ -62,6 +62,7 @@ namespace MultiArrayTools } // put this in the interface class !!! + /* std::shared_ptr SingleRange::index() const { typedef IndexWrapper IW; @@ -70,6 +71,6 @@ namespace MultiArrayTools ( std::dynamic_pointer_cast > ( std::shared_ptr( RB::mThis ) ) ) ); } - + */ } diff --git a/src/tests/op_perf_test.cc b/src/tests/op_perf_test.cc index ab100d9..b08775e 100644 --- a/src/tests/op_perf_test.cc +++ b/src/tests/op_perf_test.cc @@ -162,12 +162,10 @@ namespace { auto gamma = MAT::getIndex(); auto delta = MAT::getIndex(); auto deltap = MAT::getIndex(); - auto vdeltap = MAT::make_viwb(deltap); auto mix = MAT::mkMIndex( alpha, beta, gamma ); std::clock_t begin = std::clock(); - //res1(delta, deltap).set(vdeltap) = ma(delta, alpha, alpha, beta, beta, gamma, gamma, deltap).c(mix); for(size_t i = 0; i != 1000; ++i){ res1(delta, deltap) = ma(delta, alpha, alpha, beta, beta, gamma, gamma, deltap).c(mix); } diff --git a/src/tests/op_unit_test.cc b/src/tests/op_unit_test.cc index 394de0f..83b6e04 100644 --- a/src/tests/op_unit_test.cc +++ b/src/tests/op_unit_test.cc @@ -215,12 +215,10 @@ namespace { auto gamma = MAT::getIndex(); auto delta = MAT::getIndex(); auto deltap = MAT::getIndex(); - auto vdeltap = MAT::make_viwb(deltap); auto mix = MAT::mkMIndex( alpha, beta, gamma ); std::clock_t begin = std::clock(); - //res1(delta, deltap).set(vdeltap) = ma(delta, alpha, alpha, beta, beta, gamma, gamma, deltap).c(mix); res1(delta, deltap) = ma(delta, alpha, alpha, beta, beta, gamma, gamma, deltap).c(mix); std::clock_t end = std::clock(); std::cout << "MultiArray time: " << static_cast( end - begin ) / CLOCKS_PER_SEC