diff --git a/src/include/allocator.h b/src/include/allocator.h index a118eef..5d66dac 100644 --- a/src/include/allocator.h +++ b/src/include/allocator.h @@ -9,6 +9,9 @@ #include #include +#define MIB_SIZE 1024*1024 // 1MiB +#define WARN_SIZE MIB_SIZE*100 // 100 MiB + namespace MultiArrayHelper { @@ -32,6 +35,9 @@ namespace MultiArrayHelper T* allocate(size_t n) { const size_t nn = n*type_size; + if(nn >= WARN_SIZE){ + std::cout << __func__ << ": WARNING: allocating " << nn/(MIB_SIZE) << " MiB" << std::endl; + } const size_t off = nn%N; const size_t nnx = (off == 0) ? nn : nn + N - off; const size_t nnd = nnx/N; diff --git a/src/include/multi_array.cc.h b/src/include/multi_array.cc.h index facf01b..bff9f42 100644 --- a/src/include/multi_array.cc.h +++ b/src/include/multi_array.cc.h @@ -24,7 +24,7 @@ namespace MultiArrayTools template MultiArray::MultiArray(const typename CRange::Space& space, - vector&& vec) : + const vector& vec) : MutableMultiArrayBase(space), mCont(vec) { @@ -65,7 +65,7 @@ namespace MultiArrayTools template MultiArray::MultiArray(const std::shared_ptr&... ranges, vector&& vec) : MutableMultiArrayBase(ranges...), - mCont(vec) + mCont(std::forward>(vec)) { MAB::mInit = true; if(mCont.size() > MAB::mRange->size()){ @@ -82,6 +82,7 @@ namespace MultiArrayTools // maybe some checks here in the future... assert(mCont.size() == MAB::mRange->size()); MAB::mInit = true; + in.mInit = false; } template @@ -91,6 +92,7 @@ namespace MultiArrayTools mCont( std::move( ama.mCont ) ) { MAB::mInit = true; + ama.mInit = false; } /* @@ -163,16 +165,16 @@ namespace MultiArrayTools template MultiArray MultiArray::format(const std::shared_ptr&... nrs) { - MAB::mInit = false; - return MultiArray( nrs... , std::move(mCont) ); + //MAB::mInit = false; + return MultiArray( nrs... , mCont ); } template template MultiArray MultiArray::format(const std::tuple...>& nrs) { - MAB::mInit = false; - return MultiArray( nrs , std::move(mCont) ); + //MAB::mInit = false; + return MultiArray( nrs , mCont ); } template @@ -215,8 +217,9 @@ namespace MultiArrayTools ( std::dynamic_pointer_cast( arf.create() ), mCont ); } - } + } + /* template std::shared_ptr > MultiArray::anonymousMove() { @@ -226,7 +229,7 @@ namespace MultiArrayTools ( std::dynamic_pointer_cast( arf.create() ), std::move(mCont) ); } - + */ template MultiArray& MultiArray::operator=(const T& in) { diff --git a/src/include/multi_array.h b/src/include/multi_array.h index 955fe44..2e70431 100644 --- a/src/include/multi_array.h +++ b/src/include/multi_array.h @@ -47,7 +47,7 @@ namespace MultiArrayTools MultiArray(const std::shared_ptr&... ranges, MultiArray&& in); // same effect as format MultiArray(const typename CRange::Space& space); - MultiArray(const typename CRange::Space& space, vector&& vec); + MultiArray(const typename CRange::Space& space, const vector& vec); MultiArray(MultiArray&& ama, SIZET... sizes); // Only if ALL ranges have default extensions: @@ -90,7 +90,7 @@ namespace MultiArrayTools vector&& vmove() { MAB::mInit = false; return std::move(mCont); } virtual std::shared_ptr > anonymous(bool slice = false) const override; - virtual std::shared_ptr > anonymousMove() override; + //virtual std::shared_ptr > anonymousMove() override; auto cat() const -> decltype(ArrayCatter::cat(*this)); diff --git a/src/include/multi_array_base.h b/src/include/multi_array_base.h index da4b8f7..b04ed8d 100644 --- a/src/include/multi_array_base.h +++ b/src/include/multi_array_base.h @@ -153,7 +153,7 @@ namespace MultiArrayTools virtual bool isConst() const override; - virtual std::shared_ptr > anonymousMove() = 0; + //virtual std::shared_ptr > anonymousMove() = 0; virtual ConstOperationRoot op(const std::shared_ptr& ind) const override; diff --git a/src/include/slice.cc.h b/src/include/slice.cc.h index 64cae6a..3d302f7 100644 --- a/src/include/slice.cc.h +++ b/src/include/slice.cc.h @@ -213,14 +213,14 @@ namespace MultiArrayTools assert(0); // think about carefully!!!! return nullptr; } - + /* template std::shared_ptr > Slice::anonymousMove() { assert(0); // think about carefully!!!! return nullptr; } - + */ template auto Slice::define(const std::shared_ptr&... inds) -> SliceDef diff --git a/src/include/slice.h b/src/include/slice.h index b801562..bd79d83 100644 --- a/src/include/slice.h +++ b/src/include/slice.h @@ -86,7 +86,7 @@ namespace MultiArrayTools virtual auto end() const -> IType override; virtual std::shared_ptr > anonymous(bool slice = false) const override; - virtual std::shared_ptr > anonymousMove() override; + //virtual std::shared_ptr > anonymousMove() override; auto define(const std::shared_ptr&... inds) -> SliceDef;