From 4ab1e07cfa2e48d0232c0c1373d891a9e9bb4072 Mon Sep 17 00:00:00 2001 From: Tobias Fuchs Date: Fri, 17 Mar 2017 22:38:15 +0100 Subject: [PATCH 01/12] GlobPtr depending on global memory space, added GlobConstPtr --- dash/examples/app.01.mindeg/main.cpp | 6 +- dash/examples/bench.04.histo/main.cpp | 10 +- dash/examples/ex.04.memalloc/main.cpp | 18 +- dash/include/dash/Array.h | 9 + dash/include/dash/GlobAsyncRef.h | 20 +- dash/include/dash/GlobMem.h | 70 +++-- dash/include/dash/GlobPtr.h | 279 +++++++++++++++++--- dash/include/dash/GlobRef.h | 67 +++-- dash/include/dash/GlobSharedRef.h | 44 +-- dash/include/dash/Shared.h | 2 +- dash/include/dash/iterator/GlobIter.h | 22 +- dash/include/dash/iterator/GlobViewIter.h | 35 +-- dash/test/algorithm/CopyTest.cc | 6 +- dash/test/container/MatrixTest.cc | 11 +- dash/test/memory/CollectiveAllocatorTest.cc | 4 +- dash/test/memory/LocalAllocatorTest.cc | 4 +- 16 files changed, 448 insertions(+), 159 deletions(-) diff --git a/dash/examples/app.01.mindeg/main.cpp b/dash/examples/app.01.mindeg/main.cpp index ce4c5ab7f..51b1cdbc5 100644 --- a/dash/examples/app.01.mindeg/main.cpp +++ b/dash/examples/app.01.mindeg/main.cpp @@ -55,10 +55,12 @@ int read_adj( int read_mtx(const std::string & fname, nodearray_t & nodes); +#if 0 int init_nodes( nodearray_t & nodes, std::deque & xadj, std::deque & local_adj); +#endif void get_reach( nodearray_t & nodes, @@ -283,7 +285,9 @@ int read_mtx(const std::string & fname, // allocate memory of adjacency list in parallel for (size_t i = 0; i < nodes.lsize(); ++i) { - nodes.local[i].adj = dash::memalloc(nodes.local[i].adj_sz); + nodes.local[i].adj = dash::memalloc( + nodes.globmem(), + nodes.local[i].adj_sz); } nodes.barrier(); diff --git a/dash/examples/bench.04.histo/main.cpp b/dash/examples/bench.04.histo/main.cpp index 9318cc8a7..01380e5d3 100644 --- a/dash/examples/bench.04.histo/main.cpp +++ b/dash/examples/bench.04.histo/main.cpp @@ -29,11 +29,11 @@ int main(int argc, char **argv) dash::Array key_array(NUM_KEYS, dash::BLOCKED); dash::Array key_histo(MAX_KEY, dash::BLOCKED); - dash::Array> work_buffers(size, dash::CYCLIC); + dash::Array> work_buffers(size, dash::CYCLIC); work_buffers[myid] = dash::memalloc(MAX_KEY); - dash::GlobPtr gptr = work_buffers[myid]; - int* work_buf = (int*) gptr; + dash::GlobConstPtr gptr = work_buffers[myid]; + int * work_buf = static_cast(gptr); if(myid==0) { for(int i=0; i remote = work_buffers[(myid+unit)%size]; + dash::GlobConstPtr remote = work_buffers[(myid+unit)%size]; for(int i=0; i(remote)[goffs+i]; } } dash::barrier(); diff --git a/dash/examples/ex.04.memalloc/main.cpp b/dash/examples/ex.04.memalloc/main.cpp index f0f87cbb8..6f21f3f31 100644 --- a/dash/examples/ex.04.memalloc/main.cpp +++ b/dash/examples/ex.04.memalloc/main.cpp @@ -15,25 +15,23 @@ int main(int argc, char* argv[]) dash::Array< dash::GlobPtr > arr(size); - arr[myid] = dash::memalloc(SIZE); + arr[myid] = dash::memalloc(arr.globmem(), SIZE); - for(int i=0; i ptr = arr[myid]; - ptr[i]=myid; + ptr[i] = myid; } dash::barrier(); - cout< ptr = arr[(myid+1)%size]; - cout<<(int)ptr[i]<<" "; + cout << myid << ": "; + for (int i = 0; i < SIZE; i++) { + dash::GlobPtr ptr = arr[(myid+1) % size]; + cout << (int)ptr[i] << " "; } - cout<(pattern().block(block_gindex))); } + /** + * The instance of \c GlobMem used by this iterator to resolve addresses + * in global memory. + */ + constexpr const glob_mem_type & globmem() const noexcept + { + return *m_globmem; + } + /** * Global const pointer to the beginning of the array. */ diff --git a/dash/include/dash/GlobAsyncRef.h b/dash/include/dash/GlobAsyncRef.h index d39a78f5a..90400810f 100644 --- a/dash/include/dash/GlobAsyncRef.h +++ b/dash/include/dash/GlobAsyncRef.h @@ -99,15 +99,15 @@ class GlobAsyncRef * Conctructor, creates an GlobRefAsync object referencing an element in * global memory. */ - template + template GlobAsyncRef( /// Instance of GlobMem that issued this global reference GlobMem_t * globmem, /// Pointer to referenced object in global memory - GlobPtr & gptr) - : _gptr(gptr.dart_gptr()), - _is_local(gptr.is_local()) + GlobPtr & gptr) + : _gptr(gptr.dart_gptr()) { + _is_local = gptr.is_local(); if (_is_local) { _value = *gptr; _lptr = (T*)(gptr); @@ -119,13 +119,13 @@ class GlobAsyncRef * Conctructor, creates an GlobRefAsync object referencing an element in * global memory. */ - template + template GlobAsyncRef( /// Pointer to referenced object in global memory - GlobPtr & gptr) - : _gptr(gptr.dart_gptr()), - _is_local(gptr.is_local()) + GlobPtr & gptr) + : _gptr(gptr.dart_gptr()) { + _is_local = gptr.is_local(); if (_is_local) { _value = *gptr; _lptr = (T*)(gptr); @@ -144,7 +144,7 @@ class GlobAsyncRef dart_gptr_t dart_gptr) : _gptr(dart_gptr) { - GlobPtr gptr(dart_gptr); + GlobConstPtr gptr(dart_gptr); _is_local = gptr.is_local(); if (_is_local) { _value = *gptr; @@ -162,7 +162,7 @@ class GlobAsyncRef dart_gptr_t dart_gptr) : _gptr(dart_gptr) { - GlobPtr gptr(dart_gptr); + GlobConstPtr gptr(dart_gptr); _is_local = gptr.is_local(); if (_is_local) { _value = *gptr; diff --git a/dash/include/dash/GlobMem.h b/dash/include/dash/GlobMem.h index 9dc35b475..97d5724b7 100644 --- a/dash/include/dash/GlobMem.h +++ b/dash/include/dash/GlobMem.h @@ -85,16 +85,25 @@ class GlobMem public: typedef AllocatorType allocator_type; - typedef ElementType value_type; +//typedef ElementType value_type; + typedef typename std::decay::type value_type; typedef typename allocator_type::size_type size_type; typedef typename allocator_type::difference_type difference_type; typedef typename allocator_type::difference_type index_type; + +#if 0 typedef typename allocator_type::pointer pointer; - typedef typename allocator_type::void_pointer void_pointer; typedef typename allocator_type::const_pointer const_pointer; + typedef typename allocator_type::void_pointer void_pointer; typedef typename allocator_type::const_void_pointer const_void_pointer; - typedef value_type * local_pointer; - typedef const value_type * local_const_pointer; +#else + typedef GlobPtr pointer; + typedef const GlobPtr const_pointer; + typedef GlobPtr void_pointer; + typedef const GlobPtr const_void_pointer; +#endif + typedef value_type * local_pointer; + typedef value_type * const const_local_pointer; public: /** @@ -228,24 +237,24 @@ class GlobMem /** * Global pointer of the initial address of the global memory. */ - inline const GlobPtr begin() const + constexpr const_pointer begin() const { - return GlobPtr(_begptr); + return const_pointer(*this, _begptr); } /** * Global pointer of the initial address of the global memory. */ - inline GlobPtr begin() + inline pointer begin() { - return GlobPtr(_begptr); + return pointer(*this, _begptr); } /** * Native pointer of the initial address of the local memory of * the unit that initialized this GlobMem instance. */ - constexpr local_const_pointer lbegin() const + constexpr const_local_pointer lbegin() const { return _lbegin; } @@ -264,7 +273,7 @@ class GlobMem * Native pointer of the initial address of the local memory of * the unit that initialized this GlobMem instance. */ - constexpr local_const_pointer lend() const + constexpr const_local_pointer lend() const { return _lend; } @@ -289,7 +298,10 @@ class GlobMem index_type global_index) { DASH_LOG_TRACE("GlobMem.put_value(newval, gidx = %d)", global_index); - dash::put_value(newval, GlobPtr(_begptr) + global_index); + dash::put_value(newval, + GlobPtr( + *this, _begptr + ) + global_index); } /** @@ -303,7 +315,10 @@ class GlobMem index_type global_index) const { DASH_LOG_TRACE("GlobMem.get_value(newval, gidx = %d)", global_index); - dash::get_value(ptr, GlobPtr(_begptr) + global_index); + dash::get_value(ptr, + GlobPtr( + *this, _begptr + ) + global_index); } /** @@ -347,7 +362,7 @@ class GlobMem * local memory. */ template - dash::GlobPtr at( + pointer at( /// The unit id team_unit_t unit, /// The unit's local address offset @@ -357,7 +372,7 @@ class GlobMem if (_nunits == 0 || DART_GPTR_ISNULL(_begptr)) { DASH_LOG_DEBUG("GlobMem.at(unit,l_idx) >", "global memory not allocated"); - return dash::GlobPtr(nullptr); + return pointer(nullptr); } // Initialize with global pointer to start address: dart_gptr_t gptr = _begptr; @@ -371,7 +386,7 @@ class GlobMem // Apply global unit to global pointer: dart_gptr_setunit(&gptr, lunit); // Apply local offset to global pointer: - dash::GlobPtr res_gptr(gptr); + pointer res_gptr(*this, gptr); res_gptr += local_index; DASH_LOG_DEBUG("GlobMem.at (+g_unit) >", res_gptr); return res_gptr; @@ -389,7 +404,7 @@ class GlobMem void *addr; dart_gptr_t gptr = _begptr; DASH_LOG_TRACE_VAR("GlobMem.update_lbegin", - GlobPtr((dart_gptr_t)gptr)); + pointer(*this, gptr)); DASH_ASSERT_RETURNS( dart_gptr_setunit(&gptr, _team.myid()), DART_OK); @@ -430,21 +445,32 @@ class GlobMem local_pointer _lend = nullptr; }; -template -GlobPtr memalloc(size_t nelem) +template +GlobPtr memalloc(const MemSpaceT & mspace, size_t nelem) { dart_gptr_t gptr; dart_storage_t ds = dart_storage(nelem); if (dart_memalloc(ds.nelem, ds.dtype, &gptr) != DART_OK) { - return GlobPtr(nullptr); + return GlobPtr(nullptr); } - return GlobPtr(gptr); + return GlobPtr(mspace, gptr); } template -void memfree(GlobPtr ptr) +GlobConstPtr memalloc(size_t nelem) +{ + dart_gptr_t gptr; + dart_storage_t ds = dart_storage(nelem); + if (dart_memalloc(ds.nelem, ds.dtype, &gptr) != DART_OK) { + return GlobConstPtr(nullptr); + } + return GlobConstPtr(gptr); +} + +template +void memfree(GlobPtrT gptr) { - dart_memfree(ptr.dart_gptr()); + dart_memfree(gptr.dart_gptr()); } } // namespace dash diff --git a/dash/include/dash/GlobPtr.h b/dash/include/dash/GlobPtr.h index 25d3c4dbc..23c4cd643 100644 --- a/dash/include/dash/GlobPtr.h +++ b/dash/include/dash/GlobPtr.h @@ -10,6 +10,8 @@ #include #include #include +#include + std::ostream & operator<<( std::ostream & os, @@ -26,12 +28,25 @@ bool operator!=( namespace dash { // Forward-declarations -template class GlobRef; -template class GlobPtr; -template +template class GlobRef; +template + > class GlobMem; +#if 0 +template::type, + dash::allocator::CollectiveAllocator< + typename std::remove_const::type > > + > class GlobPtr; + +template std::ostream & operator<<( - std::ostream & os, - const GlobPtr & it); + std::ostream & os, + const GlobPtr & it); +#endif +template class GlobConstPtr; /** * Pointer in global memory space. @@ -55,79 +70,136 @@ std::ostream & operator<<( */ template< typename ElementType, - class PatternType = Pattern<1> > + class MemorySpace = GlobMem< + typename std::remove_const::type, + dash::allocator::CollectiveAllocator< + typename std::remove_const::type + > > +> class GlobPtr { private: - typedef GlobPtr self_t; - typedef typename PatternType::index_type IndexType; + typedef GlobPtr self_t; public: - typedef GlobPtr const_type; - typedef IndexType index_type; - typedef PatternType pattern_type; - typedef IndexType gptrdiff_t; + typedef ElementType value_type; + typedef GlobPtr const_type; + typedef typename dash::default_index_t index_type; +//typedef PatternType pattern_type; + + typedef index_type gptrdiff_t; public: - /// Convert GlobPtr to GlobPtr. - template + /// Convert GlobPtr to GlobPtr. + template struct rebind { - typedef GlobPtr other; + typedef GlobPtr other; }; private: - dart_gptr_t _dart_gptr; + dart_gptr_t _dart_gptr = DART_GPTR_NULL; + const MemorySpace * _mem_space = nullptr; public: - template + template + friend class GlobPtr; + + template friend std::ostream & operator<<( - std::ostream & os, - const GlobPtr & gptr); + std::ostream & os, + const GlobPtr & gptr); + +protected: + /** + * Constructor, specifies underlying global address. + * + * Allows to instantiate GlobPtr without a valid memory + * space reference. + */ + constexpr GlobPtr( + const MemorySpace * mem_space, + dart_gptr_t gptr) + : _dart_gptr(gptr) + , _mem_space(reinterpret_cast(mem_space)) + { } public: /** * Default constructor, underlying global address is unspecified. */ - constexpr explicit GlobPtr() = default; + constexpr GlobPtr() = default; /** * Constructor, specifies underlying global address. */ - constexpr explicit GlobPtr(dart_gptr_t gptr) : _dart_gptr(gptr) + constexpr GlobPtr( + const MemorySpace & mem_space, + dart_gptr_t gptr) + : _dart_gptr(gptr) + , _mem_space(reinterpret_cast(&mem_space)) { } /** * Constructor for conversion of std::nullptr_t. */ - constexpr explicit GlobPtr(std::nullptr_t p) : _dart_gptr(DART_GPTR_NULL) + explicit constexpr GlobPtr(std::nullptr_t p) + : _dart_gptr(DART_GPTR_NULL) + , _mem_space(nullptr) { } /** * Copy constructor. */ - constexpr GlobPtr(const self_t & other) = default; + constexpr GlobPtr(const self_t & other) = default; + + /** + * Copy constructor. + */ + template + constexpr GlobPtr(const GlobPtr & other) + : _dart_gptr(other._dart_gptr) + , _mem_space(reinterpret_cast(other._mem_space)) + { } + + /** + * Assignment operator. + */ + self_t & operator=(const self_t & rhs) = default; /** * Assignment operator. */ - self_t & operator=(const self_t & rhs) = default; + template + self_t & operator=(const GlobPtr & other) + { + _dart_gptr = other._dart_gptr; + _mem_space = reinterpret_cast(other._mem_space); + } + + /** + * Move constructor. + */ + constexpr GlobPtr(self_t && other) = default; + + /** + * Move-assignment operator. + */ + self_t & operator=(self_t && rhs) = default; /** * Converts pointer to its underlying global address. */ - constexpr operator dart_gptr_t() const noexcept + explicit constexpr operator dart_gptr_t() const noexcept { return _dart_gptr; } /** - * Converts pointer to its referenced native pointer or - * \c nullptr if the \c GlobPtr does not point to a local - * address. + * Converts global pointer to global const pointer. */ - explicit constexpr operator ElementType*() const noexcept + explicit constexpr operator GlobConstPtr() const noexcept { - return local(); + return GlobConstPtr(_dart_gptr); } /** @@ -138,6 +210,16 @@ class GlobPtr return _dart_gptr; } + /** + * Converts pointer to its referenced native pointer or + * \c nullptr if the \c GlobPtr does not point to a local + * address. + */ + explicit constexpr operator value_type *() const noexcept + { + return local(); + } + /** * Prefix increment operator. */ @@ -170,7 +252,7 @@ class GlobPtr DASH_ASSERT_RETURNS( dart_gptr_incaddr(&gptr, n * sizeof(ElementType)), DART_OK); - return self_t(gptr); + return self_t(*_mem_space, gptr); } /** @@ -229,7 +311,7 @@ class GlobPtr DASH_ASSERT_RETURNS( dart_gptr_incaddr(&gptr, -(n * sizeof(ElementType))), DART_OK); - return self_t(gptr); + return self_t(*_mem_space, gptr); } /** @@ -401,7 +483,7 @@ class GlobPtr * GlobPtr instance, or \c nullptr if the referenced element * is not local to the calling unit. */ - explicit operator ElementType*() { + explicit operator value_type*() { void *addr = 0; DASH_ASSERT_RETURNS( dart_gptr_getaddr(_dart_gptr, &addr), @@ -416,7 +498,7 @@ class GlobPtr * GlobPtr instance, or \c nullptr if the referenced element * is not local to the calling unit. */ - ElementType * local() { + value_type * local() { void *addr = 0; DASH_ASSERT_RETURNS( dart_gptr_getaddr(_dart_gptr, &addr), @@ -431,7 +513,7 @@ class GlobPtr * GlobPtr instance, or \c nullptr if the referenced element * is not local to the calling unit. */ - const ElementType * local() const { + const value_type * local() const { void *addr = 0; DASH_ASSERT_RETURNS( dart_gptr_getaddr(_dart_gptr, &addr), @@ -459,10 +541,10 @@ class GlobPtr } }; -template +template std::ostream & operator<<( - std::ostream & os, - const GlobPtr & gptr) + std::ostream & os, + const GlobPtr & gptr) { std::ostringstream ss; char buf[100]; @@ -477,6 +559,127 @@ std::ostream & operator<<( return operator<<(os, ss.str()); } + +/** + * Wraps underlying global address as global const pointer. + * + * As pointer arithmetics are inaccessible for const pointer types, + * no coupling to global memory space is required. + */ +template +class GlobConstPtr +: GlobPtr // NOTE: non-public subclassing +{ + typedef GlobConstPtr self_t; + typedef GlobPtr base_t; + public: + typedef T value_type; + typedef typename base_t::const_type const_type; + typedef typename base_t::index_type index_type; + typedef typename base_t::gptrdiff_t gptrdiff_t; + + template + friend std::ostream & operator<<( + std::ostream & os, + const GlobConstPtr & gptr); + + public: + /** + * Default constructor. + * + * Pointer arithmetics are undefined for the created instance. + */ + constexpr GlobConstPtr() + : base_t(nullptr, DART_GPTR_NULL) + { } + + /** + * Constructor for conversion of std::nullptr_t. + */ + explicit constexpr GlobConstPtr(std::nullptr_t p) + : base_t(nullptr, DART_GPTR_NULL) + { } + + /** + * Constructor, wraps underlying global address without coupling + * to global memory space. + * + * Pointer arithmetics are undefined for the created instance. + */ + explicit constexpr GlobConstPtr(dart_gptr_t gptr) + : base_t(nullptr, gptr) + { } + + /** + * Move constructor. + */ + constexpr GlobConstPtr(self_t && other) = default; + + /** + * Move-assignment operator. + */ + self_t & operator=(self_t && rhs) = default; + + value_type * local() { + return base_t::local(); + } + + const value_type * local() const { + return base_t::local(); + } + + bool is_local() const { + return base_t::is_local(); + } + + explicit constexpr operator dart_gptr_t() const noexcept + { + return base_t::dart_gptr(); + } + + constexpr dart_gptr_t dart_gptr() const noexcept + { + return base_t::dart_gptr(); + } + + explicit constexpr operator value_type *() const noexcept + { + return local(); + } + + explicit operator value_type*() { + return local(); + } + + GlobRef operator*() + { + return base_t::operator*(); + } + + constexpr GlobRef operator*() const + { + return base_t::operator*(); + } +}; + +template +std::ostream & operator<<( + std::ostream & os, + const GlobConstPtr & gptr) +{ + std::ostringstream ss; + char buf[100]; + sprintf(buf, + "%06X|%02X|%04X|%04X|%016lX", + gptr.dart_gptr().unitid, + gptr.dart_gptr().flags, + gptr.dart_gptr().segid, + gptr.dart_gptr().teamid, + gptr.dart_gptr().addr_or_offs.offset); + ss << "dash::GlobConstPtr<" << typeid(T).name() << ">(" << buf << ")"; + return operator<<(os, ss.str()); +} + } // namespace dash #endif // DASH__GLOB_PTR_H_ diff --git a/dash/include/dash/GlobRef.h b/dash/include/dash/GlobRef.h index a7a65bd15..cdfe4c403 100644 --- a/dash/include/dash/GlobRef.h +++ b/dash/include/dash/GlobRef.h @@ -7,17 +7,22 @@ namespace dash { -// Forward declaration +// Forward declarations template class GlobMem; -// Forward declaration -template class GlobPtr; -// Forward declaration -template -void put_value(const T & newval, const GlobPtr & gptr); -// Forward declaration -template -void get_value(T* ptr, const GlobPtr & gptr); +template class GlobConstPtr; +template class GlobPtr; +#if 0 +template +void put_value(const T & newval, const GlobConstPtr & gptr); +template +void put_value(const T & newval, const GlobPtr & gptr); + +template +void get_value(T* ptr, const GlobConstPtr & gptr); +template +void get_value(T* ptr, const GlobPtr & gptr); +#endif template struct has_subscript_operator @@ -69,10 +74,32 @@ class GlobRef * Constructor, creates an GlobRef object referencing an element in global * memory. */ - template + template + explicit constexpr GlobRef( + /// Pointer to referenced object in global memory + GlobPtr & gptr) + : GlobRef(gptr.dart_gptr()) + { } + + /** + * Constructor, creates an GlobRef object referencing an element in global + * memory. + */ + template + explicit constexpr GlobRef( + /// Pointer to referenced object in global memory + GlobConstPtr & gptr) + : GlobRef(gptr.dart_gptr()) + { } + + /** + * Constructor, creates an GlobRef object referencing an element in global + * memory. + */ + template explicit constexpr GlobRef( /// Pointer to referenced object in global memory - GlobPtr & gptr) + const GlobPtr & gptr) : GlobRef(gptr.dart_gptr()) { } @@ -80,10 +107,10 @@ class GlobRef * Constructor, creates an GlobRef object referencing an element in global * memory. */ - template + template explicit constexpr GlobRef( /// Pointer to referenced object in global memory - const GlobPtr & gptr) + const GlobConstPtr & gptr) : GlobRef(gptr.dart_gptr()) { } @@ -300,10 +327,10 @@ class GlobRef return *this; } - template - explicit constexpr operator GlobPtr() const { - return GlobPtr(_gptr); - } +// template +// explicit constexpr operator GlobPtr() const { +// return GlobPtr(_gptr); +// } constexpr dart_gptr_t dart_gptr() const noexcept { return _gptr; @@ -327,7 +354,9 @@ class GlobRef * the calling unit's local memory. */ bool is_local() const { - return GlobPtr(_gptr).is_local(); + dart_team_unit_t luid; + dart_team_myid(_gptr.teamid, &luid); + return _gptr.unitid == luid.id; } /** @@ -340,7 +369,7 @@ class GlobRef DASH_ASSERT_RETURNS( dart_gptr_incaddr(&dartptr, offs), DART_OK); - GlobPtr gptr(dartptr); + GlobConstPtr gptr(dartptr); return GlobRef(gptr); } diff --git a/dash/include/dash/GlobSharedRef.h b/dash/include/dash/GlobSharedRef.h index e046cc31b..1ae08902e 100644 --- a/dash/include/dash/GlobSharedRef.h +++ b/dash/include/dash/GlobSharedRef.h @@ -10,13 +10,13 @@ namespace dash { // Forward declaration template class GlobMem; // Forward declaration -template class GlobPtr; +template class GlobPtr; // Forward declaration -template -void put_value(const T & newval, const GlobPtr & gptr); +template +void put_value(const T & newval, const GlobPtr & gptr); // Forward declaration -template -void get_value(T* ptr, const GlobPtr & gptr); +template +void get_value(T* ptr, const GlobPtr & gptr); template< typename T, @@ -30,7 +30,7 @@ class GlobSharedRef private: - typedef GlobSharedRef + typedef GlobSharedRef self_t; public: @@ -54,6 +54,10 @@ class GlobSharedRef > other; }; +private: + dart_gptr_t _gptr; + local_pointer _lptr; + public: /** * Default constructor, creates an GlobSharedRef object referencing an @@ -210,11 +214,11 @@ class GlobSharedRef DASH_LOG_TRACE("GlobSharedRef.put >"); } - explicit operator global_pointer() const { - DASH_LOG_TRACE("GlobSharedRef.global_pointer()", "conversion operator"); - DASH_LOG_TRACE_VAR("GlobSharedRef.T()", _gptr); - return global_pointer(_gptr); - } +// explicit operator global_pointer() const { +// DASH_LOG_TRACE("GlobSharedRef.global_pointer()", "conversion operator"); +// DASH_LOG_TRACE_VAR("GlobSharedRef.T()", _gptr); +// return global_pointer(_gptr); +// } self_t & operator=(const T val) { DASH_LOG_TRACE_VAR("GlobSharedRef.=()", val); @@ -224,7 +228,11 @@ class GlobSharedRef } else if (!DART_GPTR_ISNULL(_gptr)) { DASH_LOG_TRACE_VAR("GlobSharedRef.=", _gptr); dart_storage_t ds = dash::dart_storage(1); - dart_put_blocking(_gptr, static_cast(&val), ds.nelem, ds.dtype); + dart_put_blocking( + _gptr, + static_cast(&val), + ds.nelem, + ds.dtype); } DASH_LOG_TRACE("GlobSharedRef.= >"); return *this; @@ -323,14 +331,14 @@ class GlobSharedRef */ bool is_local() const { - return _lptr != nullptr || global_pointer(_gptr).is_local(); + if (_lptr == nullptr) { + return false; + } + dart_team_unit_t luid; + dart_team_myid(_gptr.teamid, &luid); + return _gptr.unitid == luid.id; } -private: - - dart_gptr_t _gptr; - local_pointer _lptr; - }; template diff --git a/dash/include/dash/Shared.h b/dash/include/dash/Shared.h index 8547e9690..3bd21bc70 100644 --- a/dash/include/dash/Shared.h +++ b/dash/include/dash/Shared.h @@ -63,7 +63,7 @@ class Shared { Team & team = dash::Team::All()) : _team(&team), _owner(owner), - _ptr(DART_GPTR_NULL) + _ptr(nullptr) { DASH_LOG_DEBUG_VAR("Shared.Shared(team,owner)()", owner); // Shared value is only allocated at unit 0: diff --git a/dash/include/dash/iterator/GlobIter.h b/dash/include/dash/iterator/GlobIter.h index 3b9768123..b066636ca 100644 --- a/dash/include/dash/iterator/GlobIter.h +++ b/dash/include/dash/iterator/GlobIter.h @@ -56,9 +56,10 @@ class GlobViewIter; template< typename ElementType, class PatternType, - class GlobMemType - = GlobMem< typename std::remove_const::type >, - class PointerType = GlobPtr, + class GlobMemType = GlobMem< + typename std::decay::type + >, + class PointerType = typename GlobMemType::pointer, class ReferenceType = GlobRef > class GlobIter : public std::iterator< @@ -287,7 +288,7 @@ class GlobIter * \return A global reference to the element at the iterator's position */ explicit operator const_pointer() const { - DASH_LOG_TRACE_VAR("GlobIter.GlobPtr()", _idx); + DASH_LOG_TRACE_VAR("GlobIter.const_pointer()", _idx); typedef typename pattern_type::local_index_t local_pos_t; index_type idx = _idx; @@ -301,8 +302,8 @@ class GlobIter } // Global index to local index and unit: local_pos_t local_pos = _pattern->local(idx); - DASH_LOG_TRACE_VAR("GlobIter.GlobPtr >", local_pos.unit); - DASH_LOG_TRACE_VAR("GlobIter.GlobPtr >", local_pos.index); + DASH_LOG_TRACE_VAR("GlobIter.const_pointer >", local_pos.unit); + DASH_LOG_TRACE_VAR("GlobIter.const_pointer >", local_pos.index); // Create global pointer from unit and local offset: const_pointer gptr( _globmem->at(team_unit_t(local_pos.unit), local_pos.index) @@ -318,7 +319,7 @@ class GlobIter * \return A global reference to the element at the iterator's position */ explicit operator pointer() { - DASH_LOG_TRACE_VAR("GlobIter.GlobPtr()", _idx); + DASH_LOG_TRACE_VAR("GlobIter.pointer()", _idx); typedef typename pattern_type::local_index_t local_pos_t; index_type idx = _idx; @@ -332,8 +333,8 @@ class GlobIter } // Global index to local index and unit: local_pos_t local_pos = _pattern->local(idx); - DASH_LOG_TRACE_VAR("GlobIter.GlobPtr >", local_pos.unit); - DASH_LOG_TRACE_VAR("GlobIter.GlobPtr >", local_pos.index); + DASH_LOG_TRACE_VAR("GlobIter.pointer >", local_pos.unit); + DASH_LOG_TRACE_VAR("GlobIter.pointer >", local_pos.index); // Create global pointer from unit and local offset: pointer gptr( _globmem->at(team_unit_t(local_pos.unit), local_pos.index) @@ -728,7 +729,8 @@ std::ostream & operator<<( ElementType, Pattern, GlobMem, Pointer, Reference> & it) { std::ostringstream ss; - dash::GlobPtr ptr(it.dart_gptr()); + dash::GlobPtr ptr(*it._globmem, + it.dart_gptr()); ss << "dash::GlobIter<" << typeid(ElementType).name() << ">(" << "idx:" << it._idx << ", " << "gptr:" << ptr << ")"; diff --git a/dash/include/dash/iterator/GlobViewIter.h b/dash/include/dash/iterator/GlobViewIter.h index 2b8c3d714..89ca3f95d 100644 --- a/dash/include/dash/iterator/GlobViewIter.h +++ b/dash/include/dash/iterator/GlobViewIter.h @@ -43,9 +43,10 @@ class GlobStencilIter; template< typename ElementType, class PatternType, - class GlobMemType - = GlobMem< typename std::remove_const::type >, - class PointerType = GlobPtr, + class GlobMemType = GlobMem< + typename std::decay::type + >, + class PointerType = typename GlobMemType::pointer, class ReferenceType = GlobRef > class GlobViewIter : public std::iterator< @@ -357,12 +358,12 @@ class GlobViewIter */ explicit operator const_pointer() const { - DASH_LOG_TRACE_VAR("GlobViewIter.GlobPtr()", _idx); + DASH_LOG_TRACE_VAR("GlobViewIter.const_pointer()", _idx); typedef typename pattern_type::local_index_t local_pos_t; IndexType idx = _idx; IndexType offset = 0; - DASH_LOG_TRACE_VAR("GlobViewIter.GlobPtr", _max_idx); + DASH_LOG_TRACE_VAR("GlobViewIter.const_pointer", _max_idx); // Convert iterator position (_idx) to local index and unit. if (_idx > _max_idx) { // Global iterator pointing past the range indexed by the pattern @@ -370,8 +371,8 @@ class GlobViewIter idx = _max_idx; offset += _idx - _max_idx; } - DASH_LOG_TRACE_VAR("GlobViewIter.GlobPtr", idx); - DASH_LOG_TRACE_VAR("GlobViewIter.GlobPtr", offset); + DASH_LOG_TRACE_VAR("GlobViewIter.const_pointer", idx); + DASH_LOG_TRACE_VAR("GlobViewIter.const_pointer", offset); // Global index to local index and unit: local_pos_t local_pos; if (_viewspec == nullptr) { @@ -382,8 +383,10 @@ class GlobViewIter auto glob_coords = coords(idx); local_pos = _pattern->local_index(glob_coords); } - DASH_LOG_TRACE_VAR("GlobViewIter.GlobPtr >", local_pos.unit); - DASH_LOG_TRACE_VAR("GlobViewIter.GlobPtr >", local_pos.index + offset); + DASH_LOG_TRACE_VAR("GlobViewIter.const_pointer >", + local_pos.unit); + DASH_LOG_TRACE_VAR("GlobViewIter.const_pointer >", + local_pos.index + offset); // Create global pointer from unit and local offset: const_pointer gptr( _globmem->at(local_pos.unit, local_pos.index) @@ -399,12 +402,12 @@ class GlobViewIter */ explicit operator pointer() { - DASH_LOG_TRACE_VAR("GlobViewIter.GlobPtr()", _idx); + DASH_LOG_TRACE_VAR("GlobViewIter.pointer()", _idx); typedef typename pattern_type::local_index_t local_pos_t; IndexType idx = _idx; IndexType offset = 0; - DASH_LOG_TRACE_VAR("GlobViewIter.GlobPtr", _max_idx); + DASH_LOG_TRACE_VAR("GlobViewIter.pointer", _max_idx); // Convert iterator position (_idx) to local index and unit. if (_idx > _max_idx) { // Global iterator pointing past the range indexed by the pattern @@ -412,8 +415,8 @@ class GlobViewIter idx = _max_idx; offset += _idx - _max_idx; } - DASH_LOG_TRACE_VAR("GlobViewIter.GlobPtr", idx); - DASH_LOG_TRACE_VAR("GlobViewIter.GlobPtr", offset); + DASH_LOG_TRACE_VAR("GlobViewIter.pointer", idx); + DASH_LOG_TRACE_VAR("GlobViewIter.pointer", offset); // Global index to local index and unit: local_pos_t local_pos; if (_viewspec == nullptr) { @@ -424,8 +427,8 @@ class GlobViewIter auto glob_coords = coords(idx); local_pos = _pattern->local_index(glob_coords); } - DASH_LOG_TRACE_VAR("GlobViewIter.GlobPtr >", local_pos.unit); - DASH_LOG_TRACE_VAR("GlobViewIter.GlobPtr >", local_pos.index + offset); + DASH_LOG_TRACE_VAR("GlobViewIter.pointer >", local_pos.unit); + DASH_LOG_TRACE_VAR("GlobViewIter.pointer >", local_pos.index + offset); // Create global pointer from unit and local offset: pointer gptr( _globmem->at(local_pos.unit, local_pos.index) @@ -1088,7 +1091,7 @@ std::ostream & operator<<( ElementType, Pattern, GlobMem, Pointer, Reference> & it) { std::ostringstream ss; - dash::GlobPtr ptr(it); + dash::GlobPtr ptr(it); ss << "dash::GlobViewIter<" << typeid(ElementType).name() << ">(" << "idx:" << it._idx << ", " << "gptr:" << ptr << ")"; diff --git a/dash/test/algorithm/CopyTest.cc b/dash/test/algorithm/CopyTest.cc index 267782af7..c27b60f70 100644 --- a/dash/test/algorithm/CopyTest.cc +++ b/dash/test/algorithm/CopyTest.cc @@ -438,7 +438,11 @@ TEST_F(CopyTest, AsyncLocalToGlobPtr) auto block_offset = (dash::myid() + 1) % dash::size(); auto global_offset = block_offset * num_elem_per_unit; - dash::GlobPtr gptr_dest((array.begin() + global_offset).dart_gptr()); + using glob_it_t = decltype(array.begin()); + using glob_ptr_t = typename glob_it_t::pointer; + + glob_ptr_t gptr_dest = static_cast( + array.begin() + global_offset); LOG_MESSAGE("CopyTest.AsyncLocalToGlobPtr: call copy_async"); auto copy_fut = dash::copy_async(local_range, diff --git a/dash/test/container/MatrixTest.cc b/dash/test/container/MatrixTest.cc index 0384d9221..470f5c79a 100644 --- a/dash/test/container/MatrixTest.cc +++ b/dash/test/container/MatrixTest.cc @@ -645,12 +645,15 @@ TEST_F(MatrixTest, ViewIteration) int gcoord_x = block_base_coord_x + phase_x; int gcoord_y = block_base_coord_y + phase_y; ASSERT_EQ_U(phase, (b_it.pos() - block_index_offset)); + + using glob_it_t = decltype(matrix.begin()); + using glob_ptr_t = typename glob_it_t::pointer; + // Apply view projection by converting to GlobPtr: - dash::GlobPtr block_elem_gptr = - (dash::GlobPtr)(b_it); + glob_ptr_t block_elem_gptr = static_cast(b_it); // Compare with GlobPtr from global iterator without view projection: - dash::GlobPtr glob_elem_gptr = - static_cast>(matrix[gcoord_x][gcoord_y]); + glob_ptr_t glob_elem_gptr = static_cast( + matrix[gcoord_x].begin() + gcoord_y); int block_value = *block_elem_gptr; int glob_value = *glob_elem_gptr; ASSERT_EQ_U(glob_value, diff --git a/dash/test/memory/CollectiveAllocatorTest.cc b/dash/test/memory/CollectiveAllocatorTest.cc index 523b44fb0..834e7c5ba 100644 --- a/dash/test/memory/CollectiveAllocatorTest.cc +++ b/dash/test/memory/CollectiveAllocatorTest.cc @@ -33,7 +33,7 @@ TEST_F(CollectiveAllocatorTest, TeamAlloc) TEST_F(CollectiveAllocatorTest, MoveAssignment) { - using GlobPtr_t = dash::GlobPtr>; + using GlobPtr_t = dash::GlobConstPtr; using Alloc_t = dash::allocator::CollectiveAllocator; GlobPtr_t gptr; Alloc_t target_new; @@ -65,7 +65,7 @@ TEST_F(CollectiveAllocatorTest, MoveAssignment) TEST_F(CollectiveAllocatorTest, MoveCtor) { - using GlobPtr_t = dash::GlobPtr>; + using GlobPtr_t = dash::GlobConstPtr; using Alloc_t = dash::allocator::CollectiveAllocator; GlobPtr_t gptr; Alloc_t target_new; diff --git a/dash/test/memory/LocalAllocatorTest.cc b/dash/test/memory/LocalAllocatorTest.cc index fb0f3b720..2af85192d 100644 --- a/dash/test/memory/LocalAllocatorTest.cc +++ b/dash/test/memory/LocalAllocatorTest.cc @@ -18,7 +18,7 @@ TEST_F(LocalAllocatorTest, Constructor) TEST_F(LocalAllocatorTest, MoveAssignment) { - using GlobPtr_t = dash::GlobPtr>; + using GlobPtr_t = dash::GlobConstPtr; using Alloc_t = dash::allocator::LocalAllocator; GlobPtr_t gptr; Alloc_t target_new; @@ -50,7 +50,7 @@ TEST_F(LocalAllocatorTest, MoveAssignment) TEST_F(LocalAllocatorTest, MoveCtor) { - using GlobPtr_t = dash::GlobPtr>; + using GlobPtr_t = dash::GlobConstPtr; using Alloc_t = dash::allocator::LocalAllocator; GlobPtr_t gptr; Alloc_t target_new; From d07ca2ed8161f8482fcac5db255ed60c2631a8c3 Mon Sep 17 00:00:00 2001 From: Tobias Fuchs Date: Sat, 18 Mar 2017 00:11:58 +0100 Subject: [PATCH 02/12] Pointer type defs in GlobMem, fix in MatrixTest --- dash/include/dash/GlobMem.h | 13 +++--- dash/include/dash/GlobPtr.h | 71 ++++++++++++++++++++++++++++++- dash/test/container/MatrixTest.cc | 10 ++--- 3 files changed, 81 insertions(+), 13 deletions(-) diff --git a/dash/include/dash/GlobMem.h b/dash/include/dash/GlobMem.h index 97d5724b7..5f5902c64 100644 --- a/dash/include/dash/GlobMem.h +++ b/dash/include/dash/GlobMem.h @@ -85,7 +85,6 @@ class GlobMem public: typedef AllocatorType allocator_type; -//typedef ElementType value_type; typedef typename std::decay::type value_type; typedef typename allocator_type::size_type size_type; typedef typename allocator_type::difference_type difference_type; @@ -97,13 +96,13 @@ class GlobMem typedef typename allocator_type::void_pointer void_pointer; typedef typename allocator_type::const_void_pointer const_void_pointer; #else - typedef GlobPtr pointer; - typedef const GlobPtr const_pointer; - typedef GlobPtr void_pointer; - typedef const GlobPtr const_void_pointer; + typedef GlobPtr< value_type, self_t> pointer; + typedef GlobPtr const_pointer; + typedef GlobPtr< void, self_t> void_pointer; + typedef GlobPtr const_void_pointer; #endif - typedef value_type * local_pointer; - typedef value_type * const const_local_pointer; + typedef value_type * local_pointer; + typedef const value_type * const_local_pointer; public: /** diff --git a/dash/include/dash/GlobPtr.h b/dash/include/dash/GlobPtr.h index 23c4cd643..031385303 100644 --- a/dash/include/dash/GlobPtr.h +++ b/dash/include/dash/GlobPtr.h @@ -85,7 +85,6 @@ class GlobPtr typedef ElementType value_type; typedef GlobPtr const_type; typedef typename dash::default_index_t index_type; -//typedef PatternType pattern_type; typedef index_type gptrdiff_t; @@ -660,6 +659,76 @@ class GlobConstPtr { return base_t::operator*(); } + + /** + * Equality comparison operator. + */ + template + constexpr bool operator==(const GlobPtrT & other) const noexcept + { + return base_t::operator==(other); + } + + /** + * Inequality comparison operator. + */ + template + constexpr bool operator!=(const GlobPtrT & other) const noexcept + { + return base_t::operator!=(other); + } + + /** + * Less comparison operator. + * + * \note + * Distance between two global pointers is not well-defined, yet. + * This method is only provided to comply to the pointer concept. + */ + template + constexpr bool operator<(const GlobPtrT & other) const noexcept + { + return base_t::operator<(other); + } + + /** + * Less-equal comparison operator. + * + * \note + * Distance between two global pointers is not well-defined, yet. + * This method is only provided to comply to the pointer concept. + */ + template + constexpr bool operator<=(const GlobPtrT & other) const noexcept + { + return base_t::operator<=(other); + } + + /** + * Greater comparison operator. + * + * \note + * Distance between two global pointers is not well-defined, yet. + * This method is only provided to comply to the pointer concept. + */ + template + constexpr bool operator>(const GlobPtrT & other) const noexcept + { + return base_t::operator>(other); + } + + /** + * Greater-equal comparison operator. + * + * \note + * Distance between two global pointers is not well-defined, yet. + * This method is only provided to comply to the pointer concept. + */ + template + constexpr bool operator>=(const GlobPtrT & other) const noexcept + { + return base_t::operator>=(other); + } }; template diff --git a/dash/test/container/MatrixTest.cc b/dash/test/container/MatrixTest.cc index 470f5c79a..68d167ec7 100644 --- a/dash/test/container/MatrixTest.cc +++ b/dash/test/container/MatrixTest.cc @@ -646,14 +646,14 @@ TEST_F(MatrixTest, ViewIteration) int gcoord_y = block_base_coord_y + phase_y; ASSERT_EQ_U(phase, (b_it.pos() - block_index_offset)); - using glob_it_t = decltype(matrix.begin()); - using glob_ptr_t = typename glob_it_t::pointer; + using glob_it_t = decltype(matrix.begin()); + using glob_ptr_t = typename glob_it_t::pointer; + using glob_cptr_t = dash::GlobConstPtr; // Apply view projection by converting to GlobPtr: - glob_ptr_t block_elem_gptr = static_cast(b_it); + glob_ptr_t block_elem_gptr = static_cast(b_it); // Compare with GlobPtr from global iterator without view projection: - glob_ptr_t glob_elem_gptr = static_cast( - matrix[gcoord_x].begin() + gcoord_y); + glob_cptr_t glob_elem_gptr(matrix[gcoord_x][gcoord_y].dart_gptr()); int block_value = *block_elem_gptr; int glob_value = *glob_elem_gptr; ASSERT_EQ_U(glob_value, From 3279cf9cf75509b75f65e1cc3f44d590adfb05fd Mon Sep 17 00:00:00 2001 From: Tobias Fuchs Date: Sat, 18 Mar 2017 01:16:42 +0100 Subject: [PATCH 03/12] Added skip check in TeamLocalityTest::SplitGroups --- dash/test/team/TeamLocalityTest.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/dash/test/team/TeamLocalityTest.cc b/dash/test/team/TeamLocalityTest.cc index f8b13a02f..d805f893a 100644 --- a/dash/test/team/TeamLocalityTest.cc +++ b/dash/test/team/TeamLocalityTest.cc @@ -306,6 +306,25 @@ TEST_F(TeamLocalityTest, SplitGroups) DASH_LOG_DEBUG("TeamLocalityTest.SplitGroups", "group 1:", group_1_tags); DASH_LOG_DEBUG("TeamLocalityTest.SplitGroups", "group 2:", group_2_tags); + std::vector unit_core_ids; + + for (dash::global_unit_t u : group_1_units) { + const auto & unit_loc = tloc.unit_locality(u); + group_1_tags.push_back(unit_loc.domain_tag()); + unit_core_ids.push_back(unit_loc.hwinfo().core_id); + } + for (dash::global_unit_t u : group_2_units) { + const auto & unit_loc = tloc.unit_locality(u); + group_2_tags.push_back(unit_loc.domain_tag()); + unit_core_ids.push_back(unit_loc.hwinfo().core_id); + } + + std::sort(unit_core_ids.begin(), unit_core_ids.end()); + if (std::unique(unit_core_ids.begin(), unit_core_ids.end()) + != unit_core_ids.end()) { + SKIP_TEST_MSG("Multiple units mapped to same core is not supported yet"); + } + if (group_1_tags.size() > 1) { DASH_LOG_DEBUG("TeamLocalityTest.SplitGroups", "group:", group_1_tags); const auto & group_1 = tloc.group(group_1_tags); From c20d87623816abbd718a4e8ac852378eb1c2d1e2 Mon Sep 17 00:00:00 2001 From: Tobias Fuchs Date: Sat, 18 Mar 2017 01:38:03 +0100 Subject: [PATCH 04/12] Added missing return statement in GlobPtr --- dash/include/dash/GlobPtr.h | 1 + dash/include/dash/GlobRef.h | 8 ++------ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/dash/include/dash/GlobPtr.h b/dash/include/dash/GlobPtr.h index 031385303..a0d6c15c8 100644 --- a/dash/include/dash/GlobPtr.h +++ b/dash/include/dash/GlobPtr.h @@ -173,6 +173,7 @@ class GlobPtr { _dart_gptr = other._dart_gptr; _mem_space = reinterpret_cast(other._mem_space); + return *this; } /** diff --git a/dash/include/dash/GlobRef.h b/dash/include/dash/GlobRef.h index cdfe4c403..d9fdc958e 100644 --- a/dash/include/dash/GlobRef.h +++ b/dash/include/dash/GlobRef.h @@ -3,6 +3,7 @@ #include #include +#include namespace dash { @@ -326,11 +327,6 @@ class GlobRef operator=(val); return *this; } - -// template -// explicit constexpr operator GlobPtr() const { -// return GlobPtr(_gptr); -// } constexpr dart_gptr_t dart_gptr() const noexcept { return _gptr; @@ -399,7 +395,7 @@ std::ostream & operator<<( gref._gptr.segid, gref._gptr.teamid, gref._gptr.addr_or_offs.offset); - os << "dash::GlobRef<" << typeid(T).name() << ">" << buf; + os << dash::typestr(gref) << buf; return os; } From 6f59c68648bca09626bd6558dedca4a0a9ae72b4 Mon Sep 17 00:00:00 2001 From: Tobias Fuchs Date: Sat, 18 Mar 2017 09:01:42 +0100 Subject: [PATCH 05/12] Added dash::GlobUnitMem for shared local memory spaces --- dash/examples/bench.04.histo/main.cpp | 9 +- dash/include/dash/GlobDynamicMem.h | 165 ++++---- dash/include/dash/GlobMem.h | 162 +++++--- dash/include/dash/GlobPtr.h | 39 +- dash/include/dash/GlobSharedRef.h | 12 +- dash/include/dash/GlobUnitMem.h | 490 +++++++++++++++++++++++ dash/include/dash/util/UniversalMember.h | 4 + dash/test/dart/ThreadsafetyTest.cc | 6 +- 8 files changed, 713 insertions(+), 174 deletions(-) create mode 100644 dash/include/dash/GlobUnitMem.h diff --git a/dash/examples/bench.04.histo/main.cpp b/dash/examples/bench.04.histo/main.cpp index 01380e5d3..5b6803527 100644 --- a/dash/examples/bench.04.histo/main.cpp +++ b/dash/examples/bench.04.histo/main.cpp @@ -29,10 +29,13 @@ int main(int argc, char **argv) dash::Array key_array(NUM_KEYS, dash::BLOCKED); dash::Array key_histo(MAX_KEY, dash::BLOCKED); - dash::Array> work_buffers(size, dash::CYCLIC); + using glob_ptr_t = dash::GlobPtr< int, dash::GlobUnitMem >; + + dash::Array work_buffers(size, dash::CYCLIC); + work_buffers[myid] = dash::memalloc(MAX_KEY); - dash::GlobConstPtr gptr = work_buffers[myid]; + glob_ptr_t gptr = work_buffers[myid]; int * work_buf = static_cast(gptr); if(myid==0) { @@ -72,7 +75,7 @@ int main(int argc, char **argv) } for(int unit=1; unit remote = work_buffers[(myid+unit)%size]; + glob_ptr_t remote = work_buffers[(myid+unit)%size]; for(int i=0; i(remote)[goffs+i]; diff --git a/dash/include/dash/GlobDynamicMem.h b/dash/include/dash/GlobDynamicMem.h index 7c8143457..aada04579 100644 --- a/dash/include/dash/GlobDynamicMem.h +++ b/dash/include/dash/GlobDynamicMem.h @@ -202,17 +202,26 @@ class GlobDynamicMem public: typedef AllocatorType allocator_type; - typedef ElementType value_type; + typedef typename std::decay::type value_type; + typedef typename AllocatorType::size_type size_type; typedef typename AllocatorType::difference_type difference_type; typedef typename AllocatorType::difference_type index_type; + typedef typename AllocatorType::pointer raw_pointer; +#if 0 + typedef typename AllocatorType::pointer pointer; + typedef typename AllocatorType::const_pointer const_pointer; typedef typename AllocatorType::void_pointer void_pointer; typedef typename AllocatorType::const_void_pointer const_void_pointer; - typedef GlobPtr pointer; - typedef GlobPtr const_pointer; - typedef GlobSharedRef reference; - typedef GlobSharedRef const_reference; +#else + typedef GlobPtr< value_type, self_t> pointer; + typedef GlobPtr const_pointer; + typedef GlobPtr< void, self_t> void_pointer; + typedef GlobPtr const_void_pointer; +#endif + typedef GlobSharedRef< value_type, pointer> reference; + typedef GlobSharedRef const_reference; typedef value_type & local_reference; typedef const value_type & const_local_reference; @@ -260,6 +269,44 @@ class GlobDynamicMem template friend class dash::GlobBucketIter; +private: + allocator_type _allocator; + dash::Team * _team; + dart_team_t _teamid; + size_type _nunits = 0; + local_iterator _lbegin = nullptr; + local_iterator _lend = nullptr; + team_unit_t _myid { DART_UNDEFINED_UNIT_ID }; + /// Buckets in local memory space, partitioned by allocated state: + /// [ attached buckets, ... , unattached buckets, ... ] + /// Buckets in this list represent the local iteration- and memory space. + bucket_list _buckets; + /// List of buckets marked for detach. + bucket_list _detach_buckets; + /// Iterator to first unattached bucket. + bucket_iterator _attach_buckets_first; + /// Mapping unit id to number of elements in the unit's attached local + /// memory space. + local_sizes_map _local_sizes; + /// An array mapping units to a list of their cumulative bucket sizes + /// (i.e. postfix sum) which is required to iterate over the + /// non-contigous global dynamic memory space. + /// For example, if unit 2 allocated buckets with sizes 1,3,5, the + /// list at _bucket_cumul_sizes[2] has values 1,4,9. + bucket_cumul_sizes_map _bucket_cumul_sizes; + /// Mapping unit id to number of buckets marked for attach in the unit's + /// memory space. + local_sizes_map _num_attach_buckets; + /// Mapping unit id to number of buckets marked for detach in the unit's + /// memory space. + local_sizes_map _num_detach_buckets; + /// Total number of elements in attached memory space of remote units. + size_type _remote_size = 0; + /// Global iterator referencing start of global memory space. + global_iterator _begin; + /// Global iterator referencing the final position in global memory space. + global_iterator _end; + public: /** * Constructor, collectively allocates the given number of elements in @@ -306,28 +353,24 @@ class GlobDynamicMem ~GlobDynamicMem() { DASH_LOG_TRACE("GlobDynamicMem.~GlobDynamicMem()"); - DASH_LOG_TRACE("GlobDynamicMem.~GlobDynamicMem >"); } - GlobDynamicMem() = delete; + GlobDynamicMem() = delete; /** * Copy constructor. */ - GlobDynamicMem(const self_t & other) - = default; + GlobDynamicMem(const self_t & other) = default; /** * Assignment operator. */ - self_t & operator=(const self_t & rhs) - = default; + self_t & operator=(const self_t & rhs) = default; /** * Equality comparison operator. */ - constexpr bool - operator==(const self_t & rhs) const noexcept + constexpr bool operator==(const self_t & rhs) const noexcept { return (_teamid == rhs._teamid && _nunits == rhs._nunits && @@ -337,11 +380,19 @@ class GlobDynamicMem _detach_buckets == rhs._detach_buckets); } + /** + * Inequality comparison operator. + */ + constexpr bool operator!=(const self_t & rhs) const noexcept + { + return !(*this == rhs); + } + /** * Total number of elements in attached memory space, including size of * local unattached memory segments. */ - constexpr size_type size() const + constexpr size_type size() const noexcept { return _remote_size + local_size(); } @@ -349,8 +400,7 @@ class GlobDynamicMem /** * Number of elements in local memory space. */ - constexpr size_type - local_size() const noexcept + constexpr size_type local_size() const noexcept { return _local_sizes.local[0]; } @@ -379,23 +429,13 @@ class GlobDynamicMem return unit_local_size; } - /** - * Inequality comparison operator. - */ - constexpr - bool operator!=(const self_t & rhs) const noexcept - { - return !(*this == rhs); - } - /** * The team containing all units accessing the global memory space. * * \return A reference to the Team containing the units associated with * the global dynamic memory space. */ - constexpr - dash::Team & team() const noexcept + constexpr dash::Team & team() const noexcept { return (_team != nullptr) ? *_team : dash::Team::Null(); } @@ -715,7 +755,7 @@ class GlobDynamicMem /** * Global pointer of the initial address of the global memory. */ - global_iterator & begin() + global_iterator & begin() noexcept { return _begin; } @@ -723,7 +763,7 @@ class GlobDynamicMem /** * Global pointer of the initial address of the global memory. */ - const_global_iterator & begin() const + constexpr const_global_iterator & begin() const noexcept { return _begin; } @@ -731,7 +771,7 @@ class GlobDynamicMem /** * Global pointer of the initial address of the global memory. */ - reverse_global_iterator rbegin() + reverse_global_iterator rbegin() noexcept { return reverse_global_iterator(_end); } @@ -739,7 +779,7 @@ class GlobDynamicMem /** * Global pointer of the initial address of the global memory. */ - const_reverse_global_iterator rbegin() const + constexpr const_reverse_global_iterator rbegin() const noexcept { return reverse_global_iterator(_end); } @@ -747,7 +787,7 @@ class GlobDynamicMem /** * Global pointer of the initial address of the global memory. */ - global_iterator & end() + global_iterator & end() noexcept { return _end; } @@ -755,7 +795,7 @@ class GlobDynamicMem /** * Global pointer of the initial address of the global memory. */ - const_global_iterator & end() const + const_global_iterator & end() const noexcept { return _end; } @@ -763,7 +803,7 @@ class GlobDynamicMem /** * Global pointer of the initial address of the global memory. */ - reverse_global_iterator rend() + reverse_global_iterator rend() noexcept { return reverse_global_iterator(_begin); } @@ -771,7 +811,7 @@ class GlobDynamicMem /** * Global pointer of the initial address of the global memory. */ - const_reverse_global_iterator rend() const + constexpr const_reverse_global_iterator rend() const noexcept { return reverse_global_iterator(_begin); } @@ -780,7 +820,7 @@ class GlobDynamicMem * Native pointer of the initial address of the local memory of * the unit that initialized this GlobDynamicMem instance. */ - inline local_iterator & lbegin() + inline local_iterator & lbegin() noexcept { return _lbegin; } @@ -789,7 +829,7 @@ class GlobDynamicMem * Native pointer of the initial address of the local memory of * the unit that initialized this GlobDynamicMem instance. */ - inline const_local_iterator lbegin() const + inline const_local_iterator lbegin() const noexcept { return _lbegin; } @@ -798,7 +838,7 @@ class GlobDynamicMem * Native pointer of the initial address of the local memory of * the unit that initialized this GlobDynamicMem instance. */ - inline local_iterator & lend() + inline local_iterator & lend() noexcept { return _lend; } @@ -807,7 +847,7 @@ class GlobDynamicMem * Native pointer of the initial address of the local memory of * the unit that initialized this GlobDynamicMem instance. */ - inline const_local_iterator & lend() const + inline const_local_iterator & lend() const noexcept { return _lend; } @@ -1079,14 +1119,13 @@ class GlobDynamicMem // TODO: Unoptimized, use dash::min_max_element once it is available // DASH_LOG_TRACE("GlobDynamicMem.gather_min_max()"); - size_type * lcopy = new ValueType[dash::distance(first, last)]; - size_type * lcopy_end = dash::copy(first, last, lcopy); - auto min_lptr = std::min_element(lcopy, lcopy_end); - auto max_lptr = std::max_element(lcopy, lcopy_end); + std::vector lcopy(dash::distance(first, last)); + auto lcopy_end = dash::copy(first, last, lcopy.data()); + auto min_lptr = std::min_element(lcopy.data(), lcopy_end); + auto max_lptr = std::max_element(lcopy.data(), lcopy_end); std::pair min_max; min_max.first = *min_lptr; min_max.second = *max_lptr; - delete[] lcopy; DASH_LOG_TRACE("GlobDynamicMem.gather_min_max >", "min:", min_max.first, "max:", min_max.second); @@ -1285,44 +1324,6 @@ class GlobDynamicMem return dart_gptr; } -private: - allocator_type _allocator; - dash::Team * _team; - dart_team_t _teamid; - size_type _nunits = 0; - local_iterator _lbegin = nullptr; - local_iterator _lend = nullptr; - team_unit_t _myid{DART_UNDEFINED_UNIT_ID}; - /// Buckets in local memory space, partitioned by allocated state: - /// [ attached buckets, ... , unattached buckets, ... ] - /// Buckets in this list represent the local iteration- and memory space. - bucket_list _buckets; - /// List of buckets marked for detach. - bucket_list _detach_buckets; - /// Iterator to first unattached bucket. - bucket_iterator _attach_buckets_first; - /// Mapping unit id to number of elements in the unit's attached local - /// memory space. - local_sizes_map _local_sizes; - /// An array mapping units to a list of their cumulative bucket sizes - /// (i.e. postfix sum) which is required to iterate over the - /// non-contigous global dynamic memory space. - /// For example, if unit 2 allocated buckets with sizes 1,3,5, the - /// list at _bucket_cumul_sizes[2] has values 1,4,9. - bucket_cumul_sizes_map _bucket_cumul_sizes; - /// Mapping unit id to number of buckets marked for attach in the unit's - /// memory space. - local_sizes_map _num_attach_buckets; - /// Mapping unit id to number of buckets marked for detach in the unit's - /// memory space. - local_sizes_map _num_detach_buckets; - /// Total number of elements in attached memory space of remote units. - size_type _remote_size = 0; - /// Global iterator referencing start of global memory space. - global_iterator _begin; - /// Global iterator referencing the final position in global memory space. - global_iterator _end; - }; // class GlobDynamicMem } // namespace dash diff --git a/dash/include/dash/GlobMem.h b/dash/include/dash/GlobMem.h index 5f5902c64..f45725ec9 100644 --- a/dash/include/dash/GlobMem.h +++ b/dash/include/dash/GlobMem.h @@ -1,5 +1,5 @@ -#ifndef DASH__GLOBMEM_H_ -#define DASH__GLOBMEM_H_ +#ifndef DASH__GLOB_MEM_H__INCLUDED +#define DASH__GLOB_MEM_H__INCLUDED #include @@ -86,6 +86,7 @@ class GlobMem public: typedef AllocatorType allocator_type; typedef typename std::decay::type value_type; + typedef typename allocator_type::size_type size_type; typedef typename allocator_type::difference_type difference_type; typedef typename allocator_type::difference_type index_type; @@ -104,7 +105,45 @@ class GlobMem typedef value_type * local_pointer; typedef const value_type * const_local_pointer; +private: + allocator_type _allocator; + dart_gptr_t _begptr = DART_GPTR_NULL; + dash::Team * _team = nullptr; + dart_team_t _teamid; + size_type _nunits = 0; + team_unit_t _myid { DART_UNDEFINED_UNIT_ID }; + size_type _nlelem = 0; + local_pointer _lbegin = nullptr; + local_pointer _lend = nullptr; + public: + /** + * Constructor, creates instance of GlobMem with pre-allocated + * memory space. + */ + GlobMem( + dart_gptr_t gbegin, + /// Number of local elements to allocate in global memory space + size_type n_local_elem, + /// Team containing all units operating on the global memory region + Team & team = dash::Team::All()) + : _allocator(team), + _begptr(gbegin), + _team(&team), + _teamid(team.dart_id()), + _nunits(team.size()), + _myid(team.myid()), + _nlelem(n_local_elem) + { + DASH_LOG_TRACE("GlobMem(gbegin,nlocal,team)", + "preallocated at:", _begptr, + "number of local values:", _nlelem, + "team size:", team.size()); + update_lbegin(); + update_lend(); + DASH_LOG_TRACE("GlobMem(gbegin,nlocal,team) >"); + } + /** * Constructor, collectively allocates the given number of elements in * local memory of every unit in a team. @@ -120,9 +159,11 @@ class GlobMem /// Team containing all units operating on the global memory region Team & team = dash::Team::All()) : _allocator(team), - _team(team), - _nlelem(n_local_elem), - _nunits(team.size()) + _team(&team), + _teamid(team.dart_id()), + _nunits(team.size()), + _myid(team.myid()), + _nlelem(n_local_elem) { DASH_LOG_TRACE("GlobMem(nlocal,team)", "number of local values:", _nlelem, @@ -151,9 +192,11 @@ class GlobMem /// Team containing all units operating on the global memory region Team & team = dash::Team::All()) : _allocator(team), - _team(team), - _nlelem(local_elements.size()), - _nunits(team.size()) + _team(&team), + _teamid(team.dart_id()), + _nunits(team.size()), + _myid(team.myid()), + _nlelem(local_elements.size()) { DASH_LOG_DEBUG("GlobMem(lvals,team)", "number of local values:", _nlelem, @@ -183,7 +226,7 @@ class GlobMem // TODO: Should depend on allocator trait // dash::allocator_traits::is_collective() DASH_LOG_DEBUG("GlobMem(lvals,team)", "barrier"); - team.barrier(); + barrier(); } DASH_LOG_DEBUG("GlobMem(lvals,team) >", @@ -215,7 +258,7 @@ class GlobMem /** * Equality comparison operator. */ - inline bool operator==(const self_t & rhs) const + inline bool operator==(const self_t & rhs) const noexcept { return (_begptr == rhs._begptr && _team == rhs._team && @@ -228,15 +271,40 @@ class GlobMem /** * Inequality comparison operator. */ - constexpr bool operator!=(const self_t & rhs) const + constexpr bool operator!=(const self_t & rhs) const noexcept { return !(*this == rhs); } + /** + * Total number of elements in the global memory space. + */ + constexpr size_type size() const noexcept + { + return _nlelem * _nunits; + } + + constexpr size_type local_size( + dash::team_unit_t unit = DART_UNDEFINED_UNIT_ID) const noexcept + { + return _nlelem; + } + + /** + * The team containing all units accessing the global memory space. + * + * \return A reference to the Team containing the units associated with + * the global dynamic memory space. + */ + constexpr dash::Team & team() const noexcept + { + return (_team != nullptr) ? *_team : dash::Team::Null(); + } + /** * Global pointer of the initial address of the global memory. */ - constexpr const_pointer begin() const + constexpr const_pointer begin() const noexcept { return const_pointer(*this, _begptr); } @@ -244,7 +312,7 @@ class GlobMem /** * Global pointer of the initial address of the global memory. */ - inline pointer begin() + inline pointer begin() noexcept { return pointer(*this, _begptr); } @@ -253,7 +321,7 @@ class GlobMem * Native pointer of the initial address of the local memory of * the unit that initialized this GlobMem instance. */ - constexpr const_local_pointer lbegin() const + constexpr const_local_pointer lbegin() const noexcept { return _lbegin; } @@ -262,7 +330,7 @@ class GlobMem * Native pointer of the initial address of the local memory of * the unit that initialized this GlobMem instance. */ - inline local_pointer lbegin() + inline local_pointer lbegin() noexcept { return _lbegin; } @@ -272,7 +340,7 @@ class GlobMem * Native pointer of the initial address of the local memory of * the unit that initialized this GlobMem instance. */ - constexpr const_local_pointer lend() const + constexpr const_local_pointer lend() const noexcept { return _lend; } @@ -281,7 +349,7 @@ class GlobMem * Native pointer of the initial address of the local memory of * the unit that initialized this GlobMem instance. */ - inline local_pointer lend() + inline local_pointer lend() noexcept { return _lend; } @@ -323,16 +391,18 @@ class GlobMem /** * Synchronize all units associated with this global memory instance. */ - void barrier() const + void barrier() const noexcept { - _team.barrier(); + DASH_ASSERT_RETURNS( + dart_barrier(_teamid), + DART_OK); } /** * Complete all outstanding asynchronous operations on the referenced * global memory on all units. */ - void flush() + void flush() noexcept { dart_flush(_begptr); } @@ -341,17 +411,17 @@ class GlobMem * Complete all outstanding asynchronous operations on the referenced * global memory on all units. */ - void flush_all() + void flush_all() noexcept { dart_flush_all(_begptr); } - void flush_local() + void flush_local() noexcept { dart_flush_local(_begptr); } - void flush_local_all() + void flush_local_all() noexcept { dart_flush_local_all(_begptr); } @@ -392,7 +462,6 @@ class GlobMem } private: - /** * Native pointer of the initial address of the local memory of * a unit. @@ -405,7 +474,7 @@ class GlobMem DASH_LOG_TRACE_VAR("GlobMem.update_lbegin", pointer(*this, gptr)); DASH_ASSERT_RETURNS( - dart_gptr_setunit(&gptr, _team.myid()), + dart_gptr_setunit(&gptr, _myid), DART_OK); DASH_ASSERT_RETURNS( dart_gptr_getaddr(gptr, &addr), @@ -423,7 +492,7 @@ class GlobMem void *addr; dart_gptr_t gptr = _begptr; DASH_ASSERT_RETURNS( - dart_gptr_setunit(&gptr, _team.myid()), + dart_gptr_setunit(&gptr, _myid), DART_OK); DASH_ASSERT_RETURNS( dart_gptr_incaddr(&gptr, _nlelem * sizeof(value_type)), @@ -433,45 +502,10 @@ class GlobMem DART_OK); _lend = static_cast(addr); } - -private: - allocator_type _allocator; - dart_gptr_t _begptr = DART_GPTR_NULL; - dash::Team& _team; - size_type _nlelem = 0; - size_type _nunits = 0; - local_pointer _lbegin = nullptr; - local_pointer _lend = nullptr; }; -template -GlobPtr memalloc(const MemSpaceT & mspace, size_t nelem) -{ - dart_gptr_t gptr; - dart_storage_t ds = dart_storage(nelem); - if (dart_memalloc(ds.nelem, ds.dtype, &gptr) != DART_OK) { - return GlobPtr(nullptr); - } - return GlobPtr(mspace, gptr); -} - -template -GlobConstPtr memalloc(size_t nelem) -{ - dart_gptr_t gptr; - dart_storage_t ds = dart_storage(nelem); - if (dart_memalloc(ds.nelem, ds.dtype, &gptr) != DART_OK) { - return GlobConstPtr(nullptr); - } - return GlobConstPtr(gptr); -} - -template -void memfree(GlobPtrT gptr) -{ - dart_memfree(gptr.dart_gptr()); -} - } // namespace dash -#endif // DASH__GLOBMEM_H_ +#include + +#endif // DASH__GLOB_MEM_H__INCLUDED diff --git a/dash/include/dash/GlobPtr.h b/dash/include/dash/GlobPtr.h index a0d6c15c8..8f24724ea 100644 --- a/dash/include/dash/GlobPtr.h +++ b/dash/include/dash/GlobPtr.h @@ -1,17 +1,19 @@ #ifndef DASH__GLOB_PTR_H_ #define DASH__GLOB_PTR_H_ -#include -#include -#include - #include + #include + #include #include #include #include +#include +#include +#include + std::ostream & operator<<( std::ostream & os, @@ -30,22 +32,9 @@ namespace dash { // Forward-declarations template class GlobRef; template - > class GlobMem; -#if 0 + class AllocT> class GlobMem; template::type, - dash::allocator::CollectiveAllocator< - typename std::remove_const::type > > - > class GlobPtr; - -template -std::ostream & operator<<( - std::ostream & os, - const GlobPtr & it); -#endif + class AllocT> class GlobDynamicMem; template class GlobConstPtr; /** @@ -133,11 +122,21 @@ class GlobPtr */ constexpr GlobPtr( const MemorySpace & mem_space, - dart_gptr_t gptr) + dart_gptr_t gptr) : _dart_gptr(gptr) , _mem_space(reinterpret_cast(&mem_space)) { } + /** + * Constructor, specifies underlying global address. + */ + constexpr GlobPtr( + MemorySpace && mem_space, + dart_gptr_t gptr) + : _dart_gptr(gptr) + , _mem_space(nullptr) + { } + /** * Constructor for conversion of std::nullptr_t. */ diff --git a/dash/include/dash/GlobSharedRef.h b/dash/include/dash/GlobSharedRef.h index 1ae08902e..bb2f7400d 100644 --- a/dash/include/dash/GlobSharedRef.h +++ b/dash/include/dash/GlobSharedRef.h @@ -29,12 +29,10 @@ class GlobSharedRef const GlobSharedRef & gref); private: - typedef GlobSharedRef self_t; public: - typedef GlobalPointerType global_pointer; typedef GlobalPointerType const_global_pointer; typedef T * local_pointer; @@ -133,6 +131,16 @@ class GlobSharedRef _lptr(other._lptr) { } +#if 0 + /** + * Like native references, global reference types cannot be copied. + * + * Default definition of copy constructor would conflict with semantics + * of \c operator=(const self_t &). + */ + GlobSharedRef(const self_t & other) = delete; +#endif + /** * Assignment operator. */ diff --git a/dash/include/dash/GlobUnitMem.h b/dash/include/dash/GlobUnitMem.h new file mode 100644 index 000000000..73f632877 --- /dev/null +++ b/dash/include/dash/GlobUnitMem.h @@ -0,0 +1,490 @@ +#ifndef DASH__GLOB_UNIT_MEM_H__INCLUDED +#define DASH__GLOB_UNIT_MEM_H__INCLUDED + +#include + +#include +#include +#include +#include +#include + +#include + +namespace dash { + +/** + * Global memory at a single unit with address space of static size. + * + * \concept{DashGlobalMemoryConcept} + */ +template< + /// Type of elements maintained in the global memory space + typename ElementType, + /// Type implementing the DASH allocator concept used to allocate and + /// deallocate physical memory + class AllocatorType = + dash::allocator::LocalAllocator > +class GlobUnitMem +{ +private: + typedef GlobUnitMem + self_t; + +public: + typedef AllocatorType allocator_type; + typedef typename std::decay::type value_type; + + typedef typename allocator_type::size_type size_type; + typedef typename allocator_type::difference_type difference_type; + typedef typename allocator_type::difference_type index_type; + +#if 0 + typedef typename allocator_type::pointer pointer; + typedef typename allocator_type::const_pointer const_pointer; + typedef typename allocator_type::void_pointer void_pointer; + typedef typename allocator_type::const_void_pointer const_void_pointer; +#else + typedef GlobPtr< value_type, self_t> pointer; + typedef GlobPtr const_pointer; + typedef GlobPtr< void, self_t> void_pointer; + typedef GlobPtr const_void_pointer; +#endif + typedef value_type * local_pointer; + typedef const value_type * const_local_pointer; + +private: + allocator_type _allocator; + dart_gptr_t _begptr = DART_GPTR_NULL; + dash::Team * _team = nullptr; + dart_team_t _teamid; + size_type _nunits = 0; + team_unit_t _myid { DART_UNDEFINED_UNIT_ID }; + size_type _nlelem = 0; + local_pointer _lbegin = nullptr; + local_pointer _lend = nullptr; + +public: + /** + * Constructor, creates instance of GlobUnitMem with pre-allocated + * memory space. + */ + GlobUnitMem( + dart_gptr_t gbegin, + /// Number of local elements to allocate in global memory space + size_type n_local_elem, + /// Team containing all units operating on the global memory region + Team & team = dash::Team::All()) + : _allocator(team), + _begptr(gbegin), + _team(&team), + _teamid(team.dart_id()), + _nunits(team.size()), + _myid(team.myid()), + _nlelem(n_local_elem) + { + DASH_LOG_TRACE("GlobUnitMem(gbegin,nlocal,team)", + "preallocated at:", _begptr, + "number of local values:", _nlelem, + "team size:", team.size()); + update_lbegin(); + update_lend(); + DASH_LOG_TRACE("GlobUnitMem(gbegin,nlocal,team) >"); + } + + /** + * Constructor, collectively allocates the given number of elements in + * local memory of every unit in a team. + * + * \note Must not lead to implicit barrier: + * Synchronization depends on underlying allocator. + * For example, \c dash::LocalAllocator is used in \c dash::Shared + * and only called at owner unit. + */ + explicit GlobUnitMem( + /// Number of local elements to allocate in global memory space + size_type n_local_elem, + /// Team containing all units operating on the global memory region + Team & team = dash::Team::All()) + : _allocator(team), + _team(&team), + _teamid(team.dart_id()), + _nunits(team.size()), + _myid(team.myid()), + _nlelem(n_local_elem) + { + DASH_LOG_TRACE("GlobUnitMem(nlocal,team)", + "number of local values:", _nlelem, + "team size:", team.size()); + _begptr = _allocator.allocate(_nlelem); + DASH_ASSERT_MSG(!DART_GPTR_ISNULL(_begptr), "allocation failed"); + + // Use id's of team all + update_lbegin(); + update_lend(); + DASH_LOG_TRACE("GlobUnitMem(nlocal,team) >"); + } + + /** + * Constructor, collectively allocates the given number of elements in + * local memory of every unit in a team. + * + * \note Must not lead to implicit barrier: + * Synchronization depends on underlying allocator. + * For example, \c dash::LocalAllocator is used in \c dash::Shared + * and only called at owner unit. + */ + explicit GlobUnitMem( + /// Local elements to allocate in global memory space + std::initializer_list local_elements, + /// Team containing all units operating on the global memory region + Team & team = dash::Team::All()) + : _allocator(team), + _team(&team), + _teamid(team.dart_id()), + _nunits(team.size()), + _myid(team.myid()), + _nlelem(local_elements.size()) + { + DASH_LOG_DEBUG("GlobUnitMem(lvals,team)", + "number of local values:", _nlelem, + "team size:", team.size()); + _begptr = _allocator.allocate(_nlelem); + DASH_ASSERT_MSG(!DART_GPTR_ISNULL(_begptr), "allocation failed"); + + // Use id's of team all + update_lbegin(); + update_lend(); + DASH_ASSERT_EQ(std::distance(_lbegin, _lend), local_elements.size(), + "Capacity of local memory range differs from number " + "of specified local elements"); + + // Initialize allocated local elements with specified values: + auto copy_end = std::copy(local_elements.begin(), + local_elements.end(), + _lbegin); + DASH_ASSERT_EQ(_lend, copy_end, + "Initialization of specified local values failed"); + + if (_nunits > 1) { + // Wait for initialization of local values at all units. + // Barrier synchronization is okay here as multiple units are + // involved in initialization of values in global memory: + // + // TODO: Should depend on allocator trait + // dash::allocator_traits::is_collective() + DASH_LOG_DEBUG("GlobUnitMem(lvals,team)", "barrier"); + barrier(); + } + + DASH_LOG_DEBUG("GlobUnitMem(lvals,team) >", + "_lbegin:", _lbegin, "_lend:", _lend); + } + + /** + * Destructor, collectively frees underlying global memory. + */ + ~GlobUnitMem() + { + DASH_LOG_TRACE_VAR("GlobUnitMem.~GlobUnitMem()", _begptr); + _allocator.deallocate(_begptr); + DASH_LOG_TRACE("GlobUnitMem.~GlobUnitMem >"); + } + + /** + * Copy constructor. + */ + GlobUnitMem(const self_t & other) + = default; + + /** + * Assignment operator. + */ + self_t & operator=(const self_t & rhs) + = default; + + /** + * Equality comparison operator. + */ + inline bool operator==(const self_t & rhs) const noexcept + { + return (_begptr == rhs._begptr && + _team == rhs._team && + _nunits == rhs._nunits && + _nlelem == rhs._nlelem && + _lbegin == rhs._lbegin && + _lend == rhs._lend); + } + + /** + * Inequality comparison operator. + */ + constexpr bool operator!=(const self_t & rhs) const noexcept + { + return !(*this == rhs); + } + + /** + * Total number of elements in the global memory space. + */ + constexpr size_type size() const noexcept + { + return _nlelem; + } + + constexpr size_type local_size( + dash::team_unit_t unit = DART_UNDEFINED_UNIT_ID) const noexcept + { + return _nlelem; + } + + /** + * The team containing all units accessing the global memory space. + * + * \return A reference to the Team containing the units associated with + * the global dynamic memory space. + */ + constexpr dash::Team & team() const noexcept + { + return (_team != nullptr) ? *_team : dash::Team::Null(); + } + + /** + * Global pointer of the initial address of the global memory. + */ + constexpr const_pointer begin() const noexcept + { + return const_pointer(*this, _begptr); + } + + /** + * Global pointer of the initial address of the global memory. + */ + inline pointer begin() noexcept + { + return pointer(*this, _begptr); + } + + /** + * Native pointer of the initial address of the local memory of + * the unit that initialized this GlobUnitMem instance. + */ + constexpr const_local_pointer lbegin() const noexcept + { + return _lbegin; + } + + /** + * Native pointer of the initial address of the local memory of + * the unit that initialized this GlobUnitMem instance. + */ + inline local_pointer lbegin() noexcept + { + return _lbegin; + } + + + /** + * Native pointer of the initial address of the local memory of + * the unit that initialized this GlobUnitMem instance. + */ + constexpr const_local_pointer lend() const noexcept + { + return _lend; + } + + /** + * Native pointer of the initial address of the local memory of + * the unit that initialized this GlobUnitMem instance. + */ + inline local_pointer lend() noexcept + { + return _lend; + } + + /** + * Write value to global memory at given offset. + * + * \see dash::put_value + */ + template + inline void put_value( + const ValueType & newval, + index_type global_index) + { + DASH_LOG_TRACE("GlobUnitMem.put_value(newval, gidx = %d)", global_index); + dash::put_value(newval, + GlobPtr( + *this, _begptr + ) + global_index); + } + + /** + * Read value from global memory at given offset. + * + * \see dash::get_value + */ + template + inline void get_value( + ValueType * ptr, + index_type global_index) const + { + DASH_LOG_TRACE("GlobUnitMem.get_value(newval, gidx = %d)", global_index); + dash::get_value(ptr, + GlobPtr( + *this, _begptr + ) + global_index); + } + + /** + * Synchronize all units associated with this global memory instance. + */ + void barrier() const noexcept + { + DASH_ASSERT_RETURNS( + dart_barrier(_teamid), + DART_OK); + } + + /** + * Complete all outstanding asynchronous operations on the referenced + * global memory on all units. + */ + void flush() noexcept + { + dart_flush(_begptr); + } + + /** + * Complete all outstanding asynchronous operations on the referenced + * global memory on all units. + */ + void flush_all() noexcept + { + dart_flush_all(_begptr); + } + + void flush_local() noexcept + { + dart_flush_local(_begptr); + } + + void flush_local_all() noexcept + { + dart_flush_local_all(_begptr); + } + + /** + * Resolve the global pointer from an element position in a unit's + * local memory. + */ + template + pointer at( + /// The unit id + team_unit_t unit, + /// The unit's local address offset + IndexType local_index) const + { + DASH_LOG_DEBUG("GlobUnitMem.at(unit,l_idx)", unit, local_index); + if (_nunits == 0 || DART_GPTR_ISNULL(_begptr)) { + DASH_LOG_DEBUG("GlobUnitMem.at(unit,l_idx) >", + "global memory not allocated"); + return pointer(nullptr); + } + // Initialize with global pointer to start address: + dart_gptr_t gptr = _begptr; + // Resolve global unit id + DASH_LOG_TRACE_VAR("GlobUnitMem.at (=g_begptr)", gptr); + DASH_LOG_TRACE_VAR("GlobUnitMem.at", gptr.unitid); + team_unit_t lunit{gptr.unitid}; + DASH_LOG_TRACE_VAR("GlobUnitMem.at", lunit); + lunit = (lunit + unit) % _nunits; + DASH_LOG_TRACE_VAR("GlobUnitMem.at", lunit); + // Apply global unit to global pointer: + dart_gptr_setunit(&gptr, lunit); + // Apply local offset to global pointer: + pointer res_gptr(*this, gptr); + res_gptr += local_index; + DASH_LOG_DEBUG("GlobUnitMem.at (+g_unit) >", res_gptr); + return res_gptr; + } + +private: + + /** + * Native pointer of the initial address of the local memory of + * a unit. + * \param team_unit_id id of unit in \c dash::Team::All() + */ + void update_lbegin() + { + void *addr; + dart_gptr_t gptr = _begptr; + DASH_LOG_TRACE_VAR("GlobUnitMem.update_lbegin", + pointer(*this, gptr)); + DASH_ASSERT_RETURNS( + dart_gptr_setunit(&gptr, _myid), + DART_OK); + DASH_ASSERT_RETURNS( + dart_gptr_getaddr(gptr, &addr), + DART_OK); + DASH_LOG_TRACE_VAR("GlobUnitMem.update_lbegin >", addr); + _lbegin = static_cast(addr); + } + + /** + * Native pointer of the final address of the local memory of + * a unit. + */ + void update_lend() + { + void *addr; + dart_gptr_t gptr = _begptr; + DASH_ASSERT_RETURNS( + dart_gptr_setunit(&gptr, _myid), + DART_OK); + DASH_ASSERT_RETURNS( + dart_gptr_incaddr(&gptr, _nlelem * sizeof(value_type)), + DART_OK); + DASH_ASSERT_RETURNS( + dart_gptr_getaddr(gptr, &addr), + DART_OK); + _lend = static_cast(addr); + } +}; + +template< + typename T, + class MemSpaceT > +GlobPtr memalloc(const MemSpaceT & mspace, size_t nelem) +{ + dart_gptr_t gptr; + dart_storage_t ds = dart_storage(nelem); + if (dart_memalloc(ds.nelem, ds.dtype, &gptr) != DART_OK) { + return GlobPtr(nullptr); + } + return GlobPtr(mspace, gptr); +} + +template< + typename T, + class MemSpaceT = dash::GlobUnitMem > +GlobPtr memalloc(size_t nelem) +{ + dart_gptr_t gptr; + dart_storage_t ds = dart_storage(nelem); + if (dart_memalloc(ds.nelem, ds.dtype, &gptr) != DART_OK) { + return GlobPtr(nullptr); + } + return GlobPtr(MemSpaceT(gptr, nelem), gptr); +} + +template +void memfree(GlobPtrT gptr) +{ + dart_memfree(gptr.dart_gptr()); +} + +} // namespace dash + +#endif // DASH__GLOB_UNIT_MEM_H__INCLUDED diff --git a/dash/include/dash/util/UniversalMember.h b/dash/include/dash/util/UniversalMember.h index fcf3e9970..bf8b510de 100644 --- a/dash/include/dash/util/UniversalMember.h +++ b/dash/include/dash/util/UniversalMember.h @@ -78,6 +78,10 @@ class UniversalMember { : _value(&const_cast(value), [](ValueType *) { /* no deleter */ }) { } + constexpr explicit UniversalMember(const ValueType * value) + : _value(const_cast(value), + [](ValueType *) { /* no deleter */ }) + { } operator ValueType & () { return *(_value.get()); } constexpr operator const ValueType & () const { return *(_value.get()); } diff --git a/dash/test/dart/ThreadsafetyTest.cc b/dash/test/dart/ThreadsafetyTest.cc index 59758a522..d9469b03b 100644 --- a/dash/test/dart/ThreadsafetyTest.cc +++ b/dash/test/dart/ThreadsafetyTest.cc @@ -219,8 +219,8 @@ TEST_F(ThreadsafetyTest, ConcurrentAttach) { TEST_F(ThreadsafetyTest, ConcurrentMemAlloc) { - using elem_t = int; - using pointer_t = dash::GlobPtr; + using elem_t = int; + using pointer_t = dash::GlobPtr< elem_t, dash::GlobUnitMem >; if (!dash::is_multithreaded()) { SKIP_TEST_MSG("requires support for multi-threading"); @@ -250,7 +250,7 @@ TEST_F(ThreadsafetyTest, ConcurrentMemAlloc) { dash::Team *team = (thread_id == 0) ? &team_all : &team_split; dash::Array arr; arr.allocate(team->size(), - dash::DistributionSpec<1>(), *team); + dash::DistributionSpec<1>(), *team); for (int i = 0; i < thread_iterations; ++i) { #pragma omp barrier From 26127d360423536944a47da19ebb0cd762d4a0bb Mon Sep 17 00:00:00 2001 From: Tobias Fuchs Date: Sat, 18 Mar 2017 09:34:52 +0100 Subject: [PATCH 06/12] Integrating dash::GlobUnitMem --- dash/include/dash/GlobMem.h | 23 +++++++++++++++++++- dash/include/dash/GlobPtr.h | 6 ++++++ dash/include/dash/GlobUnitMem.h | 38 ++++++--------------------------- 3 files changed, 35 insertions(+), 32 deletions(-) diff --git a/dash/include/dash/GlobMem.h b/dash/include/dash/GlobMem.h index f45725ec9..5ff8f40e4 100644 --- a/dash/include/dash/GlobMem.h +++ b/dash/include/dash/GlobMem.h @@ -335,7 +335,6 @@ class GlobMem return _lbegin; } - /** * Native pointer of the initial address of the local memory of * the unit that initialized this GlobMem instance. @@ -504,6 +503,28 @@ class GlobMem } }; +template< + typename T, + class MemSpaceT > +GlobPtr memalloc(const MemSpaceT & mspace, size_t nelem) +{ + dart_gptr_t gptr; + dart_storage_t ds = dart_storage(nelem); + if (dart_memalloc(ds.nelem, ds.dtype, &gptr) != DART_OK) { + return GlobPtr(nullptr); + } + return GlobPtr(mspace, gptr); +} + +template +void memfree(GlobPtrT gptr) +{ + // TODO: Should notify GlobPtrT instance gptr of this deallocation + // as it might be owner of its referenced global memory space + // (see GlobUnitMem). + dart_memfree(gptr.dart_gptr()); +} + } // namespace dash #include diff --git a/dash/include/dash/GlobPtr.h b/dash/include/dash/GlobPtr.h index 8f24724ea..ace1aeefd 100644 --- a/dash/include/dash/GlobPtr.h +++ b/dash/include/dash/GlobPtr.h @@ -134,6 +134,8 @@ class GlobPtr MemorySpace && mem_space, dart_gptr_t gptr) : _dart_gptr(gptr) + // TODO: Should bind temporary, see dash::memalloc in + // dash/GlobUnitMem.h , _mem_space(nullptr) { } @@ -564,6 +566,10 @@ std::ostream & operator<<( * * As pointer arithmetics are inaccessible for const pointer types, * no coupling to global memory space is required. + * + * TODO: Will be replaced by specialization of GlobPtr for global + * memory space tagged as unit-scope address space + * (see GlobUnitMem). */ template class GlobConstPtr diff --git a/dash/include/dash/GlobUnitMem.h b/dash/include/dash/GlobUnitMem.h index 73f632877..1ccd12e6a 100644 --- a/dash/include/dash/GlobUnitMem.h +++ b/dash/include/dash/GlobUnitMem.h @@ -283,7 +283,6 @@ class GlobUnitMem return _lbegin; } - /** * Native pointer of the initial address of the local memory of * the unit that initialized this GlobUnitMem instance. @@ -387,21 +386,18 @@ class GlobUnitMem { DASH_LOG_DEBUG("GlobUnitMem.at(unit,l_idx)", unit, local_index); if (_nunits == 0 || DART_GPTR_ISNULL(_begptr)) { - DASH_LOG_DEBUG("GlobUnitMem.at(unit,l_idx) >", + DASH_LOG_ERROR("GlobUnitMem.at(unit,l_idx) >", "global memory not allocated"); return pointer(nullptr); } + if (unit.id != _begptr.unitid) { + DASH_LOG_ERROR("GlobUnitMem.at(unit,l_idx) >", + "address in global unit memory requested for", unit, + "but only allocated at unit", _begptr.unitid); + return pointer(nullptr); + } // Initialize with global pointer to start address: dart_gptr_t gptr = _begptr; - // Resolve global unit id - DASH_LOG_TRACE_VAR("GlobUnitMem.at (=g_begptr)", gptr); - DASH_LOG_TRACE_VAR("GlobUnitMem.at", gptr.unitid); - team_unit_t lunit{gptr.unitid}; - DASH_LOG_TRACE_VAR("GlobUnitMem.at", lunit); - lunit = (lunit + unit) % _nunits; - DASH_LOG_TRACE_VAR("GlobUnitMem.at", lunit); - // Apply global unit to global pointer: - dart_gptr_setunit(&gptr, lunit); // Apply local offset to global pointer: pointer res_gptr(*this, gptr); res_gptr += local_index; @@ -410,7 +406,6 @@ class GlobUnitMem } private: - /** * Native pointer of the initial address of the local memory of * a unit. @@ -453,19 +448,6 @@ class GlobUnitMem } }; -template< - typename T, - class MemSpaceT > -GlobPtr memalloc(const MemSpaceT & mspace, size_t nelem) -{ - dart_gptr_t gptr; - dart_storage_t ds = dart_storage(nelem); - if (dart_memalloc(ds.nelem, ds.dtype, &gptr) != DART_OK) { - return GlobPtr(nullptr); - } - return GlobPtr(mspace, gptr); -} - template< typename T, class MemSpaceT = dash::GlobUnitMem > @@ -479,12 +461,6 @@ GlobPtr memalloc(size_t nelem) return GlobPtr(MemSpaceT(gptr, nelem), gptr); } -template -void memfree(GlobPtrT gptr) -{ - dart_memfree(gptr.dart_gptr()); -} - } // namespace dash #endif // DASH__GLOB_UNIT_MEM_H__INCLUDED From ecbfe7045a90f9ff98d1793391b8dfc9aa09f959 Mon Sep 17 00:00:00 2001 From: Tobias Fuchs Date: Sat, 18 Mar 2017 09:38:32 +0100 Subject: [PATCH 07/12] Fixed clang compiler errors --- dash/include/dash/GlobMem.h | 8 ++++++-- dash/include/dash/GlobUnitMem.h | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/dash/include/dash/GlobMem.h b/dash/include/dash/GlobMem.h index 5ff8f40e4..53e088b24 100644 --- a/dash/include/dash/GlobMem.h +++ b/dash/include/dash/GlobMem.h @@ -284,8 +284,12 @@ class GlobMem return _nlelem * _nunits; } - constexpr size_type local_size( - dash::team_unit_t unit = DART_UNDEFINED_UNIT_ID) const noexcept + constexpr size_type local_size(dash::team_unit_t) const noexcept + { + return _nlelem; + } + + constexpr size_type local_size() const noexcept { return _nlelem; } diff --git a/dash/include/dash/GlobUnitMem.h b/dash/include/dash/GlobUnitMem.h index 1ccd12e6a..eb8b85588 100644 --- a/dash/include/dash/GlobUnitMem.h +++ b/dash/include/dash/GlobUnitMem.h @@ -232,8 +232,12 @@ class GlobUnitMem return _nlelem; } - constexpr size_type local_size( - dash::team_unit_t unit = DART_UNDEFINED_UNIT_ID) const noexcept + constexpr size_type local_size(dash::team_unit_t) const noexcept + { + return _nlelem; + } + + constexpr size_type local_size() const noexcept { return _nlelem; } From b24a316ffa80ff87a1d97ee2805411d2cca3dcdb Mon Sep 17 00:00:00 2001 From: Tobias Fuchs Date: Sat, 18 Mar 2017 18:48:06 +0100 Subject: [PATCH 08/12] Renamed GlobMem, GlobDynamicMem to GlobStaticHeap, GlobHeap --- dash/examples/bench.04.histo/main.cpp | 2 +- dash/include/dash/Array.h | 8 +- dash/include/dash/GlobAsyncRef.h | 26 +-- .../dash/{GlobDynamicMem.h => GlobHeap.h} | 216 +++++++++--------- dash/include/dash/GlobPtr.h | 10 +- dash/include/dash/GlobRef.h | 4 +- dash/include/dash/GlobSharedRef.h | 4 +- .../dash/{GlobMem.h => GlobStaticHeap.h} | 74 +++--- .../dash/{GlobUnitMem.h => GlobUnitHeap.h} | 60 ++--- dash/include/dash/Halo.h | 26 +-- dash/include/dash/Iterator.h | 6 +- dash/include/dash/List.h | 4 +- dash/include/dash/Matrix.h | 8 +- dash/include/dash/Shared.h | 10 +- dash/include/dash/UnorderedMap.h | 4 +- .../dash/allocator/CollectiveAllocator.h | 6 - dash/include/dash/allocator/GlobBucketIter.h | 40 ++-- dash/include/dash/allocator/LocalBucketIter.h | 2 +- .../dash/allocator/internal/GlobBucketIter.h | 46 ++-- ...{GlobDynamicMemTypes.h => GlobHeapTypes.h} | 6 +- dash/include/dash/experimental/Halo.h | 24 +- dash/include/dash/experimental/HaloMatrix.h | 2 +- .../experimental/iterator/GlobStencilIter.h | 32 +-- .../iterator/HaloMatrixIterator.h | 2 +- dash/include/dash/iterator/GlobIter.h | 34 +-- dash/include/dash/iterator/GlobStencilIter.h | 32 +-- dash/include/dash/iterator/GlobViewIter.h | 56 ++--- dash/include/dash/list/GlobListIter.h | 18 +- dash/include/dash/list/ListRef.h | 4 +- dash/include/dash/list/LocalListRef.h | 2 +- dash/include/dash/map/UnorderedMap.h | 4 +- .../include/dash/matrix/internal/Matrix-inl.h | 4 +- dash/include/libdash.h | 2 +- dash/test/dart/ThreadsafetyTest.cc | 2 +- dash/test/memory/GlobDynamicMemTest.h | 26 --- ...{GlobDynamicMemTest.cc => GlobHeapTest.cc} | 120 +++++----- dash/test/memory/GlobHeapTest.h | 26 +++ dash/test/memory/GlobMemTest.h | 21 -- .../{GlobMemTest.cc => GlobStaticHeapTest.cc} | 14 +- dash/test/memory/GlobStaticHeapTest.h | 21 ++ 40 files changed, 501 insertions(+), 507 deletions(-) rename dash/include/dash/{GlobDynamicMem.h => GlobHeap.h} (88%) rename dash/include/dash/{GlobMem.h => GlobStaticHeap.h} (89%) rename dash/include/dash/{GlobUnitMem.h => GlobUnitHeap.h} (88%) rename dash/include/dash/allocator/internal/{GlobDynamicMemTypes.h => GlobHeapTypes.h} (56%) delete mode 100644 dash/test/memory/GlobDynamicMemTest.h rename dash/test/memory/{GlobDynamicMemTest.cc => GlobHeapTest.cc} (83%) create mode 100644 dash/test/memory/GlobHeapTest.h delete mode 100644 dash/test/memory/GlobMemTest.h rename dash/test/memory/{GlobMemTest.cc => GlobStaticHeapTest.cc} (72%) create mode 100644 dash/test/memory/GlobStaticHeapTest.h diff --git a/dash/examples/bench.04.histo/main.cpp b/dash/examples/bench.04.histo/main.cpp index 5b6803527..4d542e48a 100644 --- a/dash/examples/bench.04.histo/main.cpp +++ b/dash/examples/bench.04.histo/main.cpp @@ -29,7 +29,7 @@ int main(int argc, char **argv) dash::Array key_array(NUM_KEYS, dash::BLOCKED); dash::Array key_histo(MAX_KEY, dash::BLOCKED); - using glob_ptr_t = dash::GlobPtr< int, dash::GlobUnitMem >; + using glob_ptr_t = dash::GlobPtr< int, dash::GlobUnitHeap >; dash::Array work_buffers(size, dash::CYCLIC); diff --git a/dash/include/dash/Array.h b/dash/include/dash/Array.h index b46c9600b..0d58a8503 100644 --- a/dash/include/dash/Array.h +++ b/dash/include/dash/Array.h @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include @@ -621,7 +621,7 @@ class ArrayRef * \concept{DashArrayConcept} * * \todo Add template parameter: - * class GlobMemType = dash::GlobMem + * class GlobStaticHeapType = dash::GlobStaticHeap * * \note: Template parameter IndexType could be deduced from pattern * type PatternT::index_type @@ -662,7 +662,7 @@ class Array typedef GlobIter< value_type, PatternType> pointer; typedef GlobIter const_pointer; - typedef dash::GlobMem glob_mem_type; + typedef dash::GlobStaticHeap glob_mem_type; public: template< @@ -929,7 +929,7 @@ class Array } /** - * The instance of \c GlobMem used by this iterator to resolve addresses + * The instance of \c GlobStaticHeap used by this iterator to resolve addresses * in global memory. */ constexpr const glob_mem_type & globmem() const noexcept diff --git a/dash/include/dash/GlobAsyncRef.h b/dash/include/dash/GlobAsyncRef.h index 90400810f..855045a5a 100644 --- a/dash/include/dash/GlobAsyncRef.h +++ b/dash/include/dash/GlobAsyncRef.h @@ -3,7 +3,7 @@ #include #include -#include +#include #include @@ -47,12 +47,12 @@ class GlobAsyncRef private: typedef GlobAsyncRef self_t; - typedef GlobMem > - GlobMem_t; + typedef GlobStaticHeap > + GlobStaticHeap_t; private: - /// Instance of GlobMem that issued this global reference - GlobMem_t * _globmem; + /// Instance of GlobStaticHeap that issued this global reference + GlobStaticHeap_t * _globmem; /// Value of the referenced element, initially not loaded mutable T _value; /// Pointer to referenced element in global memory @@ -72,8 +72,8 @@ class GlobAsyncRef * global memory. */ GlobAsyncRef( - /// Instance of GlobMem that issued this global reference - GlobMem_t * globmem, + /// Instance of GlobStaticHeap that issued this global reference + GlobStaticHeap_t * globmem, /// Pointer to referenced object in global memory T * lptr) : _value(*lptr), @@ -101,8 +101,8 @@ class GlobAsyncRef */ template GlobAsyncRef( - /// Instance of GlobMem that issued this global reference - GlobMem_t * globmem, + /// Instance of GlobStaticHeap that issued this global reference + GlobStaticHeap_t * globmem, /// Pointer to referenced object in global memory GlobPtr & gptr) : _gptr(gptr.dart_gptr()) @@ -138,8 +138,8 @@ class GlobAsyncRef * global memory. */ GlobAsyncRef( - /// Instance of GlobMem that issued this global reference - GlobMem_t * globmem, + /// Instance of GlobStaticHeap that issued this global reference + GlobStaticHeap_t * globmem, /// Pointer to referenced object in global memory dart_gptr_t dart_gptr) : _gptr(dart_gptr) @@ -176,8 +176,8 @@ class GlobAsyncRef * global memory. */ GlobAsyncRef( - /// Instance of GlobMem that issued this global reference - GlobMem_t * globmem, + /// Instance of GlobStaticHeap that issued this global reference + GlobStaticHeap_t * globmem, /// Pointer to referenced object in global memory GlobRef & gref) : GlobAsyncRef(globmem, gref.gptr()) diff --git a/dash/include/dash/GlobDynamicMem.h b/dash/include/dash/GlobHeap.h similarity index 88% rename from dash/include/dash/GlobDynamicMem.h rename to dash/include/dash/GlobHeap.h index aada04579..0a29064d3 100644 --- a/dash/include/dash/GlobDynamicMem.h +++ b/dash/include/dash/GlobHeap.h @@ -1,5 +1,5 @@ -#ifndef DASH__GLOB_DYNAMIC_MEM_H_ -#define DASH__GLOB_DYNAMIC_MEM_H_ +#ifndef DASH__GLOB_HEAP_H__INCLUDED +#define DASH__GLOB_HEAP_H__INCLUDED #include @@ -16,7 +16,7 @@ #include #include -#include +#include #include @@ -103,7 +103,7 @@ namespace dash { /** * Global memory region with dynamic size. * - * Conventional global memory (see \c dash::GlobMem) allocates a single + * Conventional global memory (see \c dash::GlobStaticHeap) allocates a single * contiguous range of fixed size in local memory at every unit. * Iterating static memory space is trivial as native pointer arithmetics * can be used to traverse elements in canonical storage order. @@ -119,7 +119,7 @@ namespace dash { * * \code * size_t initial_local_capacity = 1024; - * GlobDynamicMem gdmem(initial_local_capacity); + * GlobHeap gdmem(initial_local_capacity); * * size_t initial_global_capacity = dash::size() * initial_local_capacity; * @@ -194,10 +194,10 @@ template< /// global memory class AllocatorType = dash::allocator::DynamicAllocator > -class GlobDynamicMem +class GlobHeap { private: - typedef GlobDynamicMem + typedef GlobHeap self_t; public: @@ -315,7 +315,7 @@ class GlobDynamicMem * \concept{DashDynamicMemorySpaceConcept} * \concept{DashMemorySpaceConcept} */ - explicit GlobDynamicMem( + explicit GlobHeap( /// Initial number of local elements to allocate in global memory space size_type n_local_elem = 0, /// Team containing all units operating on the global memory region @@ -332,35 +332,35 @@ class GlobDynamicMem _num_detach_buckets(team.size(), team), _remote_size(0) { - DASH_LOG_TRACE("GlobDynamicMem.(ninit,nunits)", + DASH_LOG_TRACE("GlobHeap.(ninit,nunits)", n_local_elem, team.size()); _local_sizes.local[0] = 0; _num_attach_buckets.local[0] = 0; _num_detach_buckets.local[0] = 0; - DASH_LOG_TRACE("GlobDynamicMem.GlobDynamicMem", + DASH_LOG_TRACE("GlobHeap.GlobHeap", "allocating initial memory space"); grow(n_local_elem); commit(); - DASH_LOG_TRACE("GlobDynamicMem.GlobDynamicMem >"); + DASH_LOG_TRACE("GlobHeap.GlobHeap >"); } /** * Destructor, collectively frees underlying global memory. */ - ~GlobDynamicMem() + ~GlobHeap() { - DASH_LOG_TRACE("GlobDynamicMem.~GlobDynamicMem()"); + DASH_LOG_TRACE("GlobHeap.~GlobHeap()"); } - GlobDynamicMem() = delete; + GlobHeap() = delete; /** * Copy constructor. */ - GlobDynamicMem(const self_t & other) = default; + GlobHeap(const self_t & other) = default; /** * Assignment operator. @@ -413,9 +413,9 @@ class GlobDynamicMem */ inline size_type local_size(team_unit_t unit) const { - DASH_LOG_TRACE("GlobDynamicMem.local_size(u)", "unit:", unit); + DASH_LOG_TRACE("GlobHeap.local_size(u)", "unit:", unit); DASH_ASSERT_RANGE(0, unit, _nunits-1, "unit id out of range"); - DASH_LOG_TRACE_VAR("GlobDynamicMem.local_size", + DASH_LOG_TRACE_VAR("GlobHeap.local_size", _bucket_cumul_sizes[unit]); size_type unit_local_size; if (unit == _myid) { @@ -425,7 +425,7 @@ class GlobDynamicMem } else { unit_local_size = _bucket_cumul_sizes[unit].back(); } - DASH_LOG_TRACE("GlobDynamicMem.local_size >", unit_local_size); + DASH_LOG_TRACE("GlobHeap.local_size >", unit_local_size); return unit_local_size; } @@ -457,12 +457,12 @@ class GlobDynamicMem */ local_iterator grow(size_type num_elements) { - DASH_LOG_DEBUG_VAR("GlobDynamicMem.grow()", num_elements); + DASH_LOG_DEBUG_VAR("GlobHeap.grow()", num_elements); size_type local_size_old = _local_sizes.local[0]; - DASH_LOG_TRACE("GlobDynamicMem.grow", + DASH_LOG_TRACE("GlobHeap.grow", "current local size:", local_size_old); if (num_elements == 0) { - DASH_LOG_DEBUG("GlobDynamicMem.grow >", "no grow"); + DASH_LOG_DEBUG("GlobHeap.grow >", "no grow"); return _lend; } // Update size of local memory space: @@ -471,7 +471,7 @@ class GlobDynamicMem _num_attach_buckets.local[0] += 1; // Create new unattached bucket: - DASH_LOG_TRACE("GlobDynamicMem.grow", "creating new unattached bucket:", + DASH_LOG_TRACE("GlobHeap.grow", "creating new unattached bucket:", "size:", num_elements); bucket_type bucket; bucket.size = num_elements; @@ -486,7 +486,7 @@ class GlobDynamicMem std::advance(_attach_buckets_first, _buckets.size() - 1); } _bucket_cumul_sizes[_myid].push_back(_local_sizes.local[0]); - DASH_LOG_TRACE("GlobDynamicMem.grow", "added unattached bucket:", + DASH_LOG_TRACE("GlobHeap.grow", "added unattached bucket:", "size:", bucket.size, "lptr:", bucket.lptr); // Update local iteration space: @@ -494,12 +494,12 @@ class GlobDynamicMem update_lend(); DASH_ASSERT_EQ(_local_sizes.local[0], _lend - _lbegin, "local size differs from local iteration space size"); - DASH_LOG_TRACE("GlobDynamicMem.grow", + DASH_LOG_TRACE("GlobHeap.grow", "new local size:", _local_sizes.local[0]); - DASH_LOG_TRACE("GlobDynamicMem.grow", + DASH_LOG_TRACE("GlobHeap.grow", "local buckets:", _buckets.size(), "unattached buckets:", _num_attach_buckets.local[0]); - DASH_LOG_TRACE("GlobDynamicMem.grow >"); + DASH_LOG_TRACE("GlobHeap.grow >"); // Return local iterator to start of allocated memory: return _lbegin + local_size_old; } @@ -555,22 +555,22 @@ class GlobDynamicMem // - the remote unit's current local size (including unattached buckets) // - the number of the remote unit's unattached buckets and their size - DASH_LOG_DEBUG_VAR("GlobDynamicMem.shrink()", num_elements); + DASH_LOG_DEBUG_VAR("GlobHeap.shrink()", num_elements); DASH_ASSERT_LT(num_elements, local_size() + 1, "cannot shrink size " << local_size() << " " "by " << num_elements << " elements"); if (num_elements == 0) { - DASH_LOG_DEBUG("GlobDynamicMem.shrink >", "no shrink"); + DASH_LOG_DEBUG("GlobHeap.shrink >", "no shrink"); return; } - DASH_LOG_TRACE("GlobDynamicMem.shrink", + DASH_LOG_TRACE("GlobHeap.shrink", "current local size:", _local_sizes.local[0]); - DASH_LOG_TRACE("GlobDynamicMem.shrink", + DASH_LOG_TRACE("GlobHeap.shrink", "current local buckets:", _buckets.size()); // Position of iterator to first unattached bucket: auto attach_buckets_first_pos = std::distance(_buckets.begin(), _attach_buckets_first); - DASH_LOG_TRACE_VAR("GlobDynamicMem.shrink", attach_buckets_first_pos); + DASH_LOG_TRACE_VAR("GlobHeap.shrink", attach_buckets_first_pos); // Number of elements left to deallocate: auto num_dealloc = num_elements; // Try to reduce local capacity by deallocating un-attached local buckets @@ -581,7 +581,7 @@ class GlobDynamicMem bucket_type & bucket_last = _buckets.back(); // Shrink / remove unattached buckets starting at newest bucket: if (bucket_last.size <= num_dealloc) { - DASH_LOG_TRACE("GlobDynamicMem.shrink", "remove unattached bucket:", + DASH_LOG_TRACE("GlobHeap.shrink", "remove unattached bucket:", "size:", bucket_last.size); // Mark entire bucket for deallocation below: num_dealloc -= bucket_last.size; @@ -593,7 +593,7 @@ class GlobDynamicMem if (attach_buckets_first_it != _buckets.end() && ++attach_buckets_first_it == _buckets.end()) { // Iterator to first unattached bucket references last bucket: - DASH_LOG_TRACE("GlobDynamicMem.shrink", + DASH_LOG_TRACE("GlobHeap.shrink", "updating iterator to first unattached bucket"); _attach_buckets_first--; } @@ -610,7 +610,7 @@ class GlobDynamicMem _num_attach_buckets.local[0] -= 1; } else if (bucket_last.size > num_dealloc) { // TODO: Clarify if shrinking unattached buckets is allowed - DASH_LOG_TRACE("GlobDynamicMem.shrink", "shrink unattached bucket:", + DASH_LOG_TRACE("GlobHeap.shrink", "shrink unattached bucket:", "old size:", bucket_last.size, "new size:", bucket_last.size - num_dealloc); bucket_last.size -= num_dealloc; @@ -640,7 +640,7 @@ class GlobDynamicMem _bucket_cumul_sizes[_myid].back() -= bucket_it->size; num_dealloc -= bucket_it->size; } else if (bucket_it->size > num_dealloc) { - DASH_LOG_TRACE("GlobDynamicMem.shrink", "shrink attached bucket:", + DASH_LOG_TRACE("GlobHeap.shrink", "shrink attached bucket:", "old size:", bucket_it->size, "new size:", bucket_it->size - num_dealloc); bucket_it->size -= num_dealloc; @@ -651,10 +651,10 @@ class GlobDynamicMem } // Mark attached buckets for deallocation. // Requires separate loop as iterators on _buckets could be invalidated. - DASH_LOG_DEBUG_VAR("GlobDynamicMem.shrink", num_dealloc_gbuckets); + DASH_LOG_DEBUG_VAR("GlobHeap.shrink", num_dealloc_gbuckets); while (num_dealloc_gbuckets-- > 0) { auto dealloc_bucket = _buckets.back(); - DASH_LOG_TRACE("GlobDynamicMem.shrink", "deallocate attached bucket:" + DASH_LOG_TRACE("GlobHeap.shrink", "deallocate attached bucket:" "size:", dealloc_bucket.size, "lptr:", dealloc_bucket.lptr); // Mark bucket to be detached in next call of commit(): @@ -666,18 +666,18 @@ class GlobDynamicMem update_lbegin(); update_lend(); - DASH_LOG_TRACE("GlobDynamicMem.shrink", + DASH_LOG_TRACE("GlobHeap.shrink", "cumulative bucket sizes:", _bucket_cumul_sizes[_myid]); - DASH_LOG_TRACE("GlobDynamicMem.shrink", + DASH_LOG_TRACE("GlobHeap.shrink", "new local size:", _local_sizes.local[0], "new iteration space size:", std::distance( _lbegin, _lend)); - DASH_LOG_TRACE("GlobDynamicMem.shrink", + DASH_LOG_TRACE("GlobHeap.shrink", "total number of buckets:", _buckets.size(), "unattached buckets:", std::distance( _attach_buckets_first, _buckets.end())); - DASH_LOG_DEBUG("GlobDynamicMem.shrink >"); + DASH_LOG_DEBUG("GlobHeap.shrink >"); } /** @@ -698,8 +698,8 @@ class GlobDynamicMem */ void commit() { - DASH_LOG_DEBUG("GlobDynamicMem.commit()"); - DASH_LOG_TRACE_VAR("GlobDynamicMem.commit", _buckets.size()); + DASH_LOG_DEBUG("GlobHeap.commit()"); + DASH_LOG_TRACE_VAR("GlobHeap.commit", _buckets.size()); // First detach, then attach to minimize number of elements allocated // at the same time: @@ -708,17 +708,17 @@ class GlobDynamicMem if (num_detached_elem > 0 || num_attached_elem > 0) { // Update _begin iterator: - DASH_LOG_TRACE("GlobDynamicMem.commit", "updating _begin"); + DASH_LOG_TRACE("GlobHeap.commit", "updating _begin"); _begin = global_iterator(this, 0); - DASH_LOG_TRACE("GlobDynamicMem.commit", "updating _end"); + DASH_LOG_TRACE("GlobHeap.commit", "updating _end"); _end = _begin + size(); } // Update local iterators as bucket iterators might have changed: - DASH_LOG_TRACE("GlobDynamicMem.commit", "updating _lbegin"); + DASH_LOG_TRACE("GlobHeap.commit", "updating _lbegin"); update_lbegin(); - DASH_LOG_TRACE("GlobDynamicMem.commit", "updating _lend"); + DASH_LOG_TRACE("GlobHeap.commit", "updating _lend"); update_lend(); - DASH_LOG_DEBUG("GlobDynamicMem.commit >", "finished"); + DASH_LOG_DEBUG("GlobHeap.commit >", "finished"); } /** @@ -742,14 +742,14 @@ class GlobDynamicMem */ void resize(size_type num_elements) { - DASH_LOG_DEBUG("GlobDynamicMem.resize()", "new size:", num_elements); + DASH_LOG_DEBUG("GlobHeap.resize()", "new size:", num_elements); index_type diff_capacity = num_elements - size(); if (diff_capacity > 0) { grow(diff_capacity); } else if (diff_capacity < 0) { shrink(-diff_capacity); } - DASH_LOG_DEBUG("GlobDynamicMem.resize >"); + DASH_LOG_DEBUG("GlobHeap.resize >"); } /** @@ -818,7 +818,7 @@ class GlobDynamicMem /** * Native pointer of the initial address of the local memory of - * the unit that initialized this GlobDynamicMem instance. + * the unit that initialized this GlobHeap instance. */ inline local_iterator & lbegin() noexcept { @@ -827,7 +827,7 @@ class GlobDynamicMem /** * Native pointer of the initial address of the local memory of - * the unit that initialized this GlobDynamicMem instance. + * the unit that initialized this GlobHeap instance. */ inline const_local_iterator lbegin() const noexcept { @@ -836,7 +836,7 @@ class GlobDynamicMem /** * Native pointer of the initial address of the local memory of - * the unit that initialized this GlobDynamicMem instance. + * the unit that initialized this GlobHeap instance. */ inline local_iterator & lend() noexcept { @@ -845,7 +845,7 @@ class GlobDynamicMem /** * Native pointer of the initial address of the local memory of - * the unit that initialized this GlobDynamicMem instance. + * the unit that initialized this GlobHeap instance. */ inline const_local_iterator & lend() const noexcept { @@ -862,7 +862,7 @@ class GlobDynamicMem const ValueType & newval, index_type global_index) { - DASH_LOG_TRACE("GlobDynamicMem.put_value(newval, gidx = %d)", + DASH_LOG_TRACE("GlobHeap.put_value(newval, gidx = %d)", global_index); auto git = const_global_iterator(this, global_index); dash::put_value(newval, git); @@ -878,7 +878,7 @@ class GlobDynamicMem ValueType * ptr, index_type global_index) const { - DASH_LOG_TRACE("GlobDynamicMem.get_value(newval, gidx = %d)", + DASH_LOG_TRACE("GlobHeap.get_value(newval, gidx = %d)", global_index); auto git = const_global_iterator(this, global_index); dash::get_value(ptr, git); @@ -908,13 +908,13 @@ class GlobDynamicMem /// The unit's local address offset IndexT local_index) { - DASH_LOG_DEBUG("GlobDynamicMem.at()", + DASH_LOG_DEBUG("GlobHeap.at()", "unit:", unit, "lidx:", local_index); if (_nunits == 0) { DASH_THROW(dash::exception::RuntimeError, "No units in team"); } global_iterator git(this, unit, local_index); - DASH_LOG_DEBUG_VAR("GlobDynamicMem.at >", git); + DASH_LOG_DEBUG_VAR("GlobHeap.at >", git); return git; } @@ -929,14 +929,14 @@ class GlobDynamicMem /// The unit's local address offset IndexT local_index) const { - DASH_LOG_DEBUG("GlobDynamicMem.at() const", + DASH_LOG_DEBUG("GlobHeap.at() const", "unit:", unit, "lidx:", local_index); if (_nunits == 0) { DASH_THROW(dash::exception::RuntimeError, "No units in team"); } // TODO const_global_iterator git(this, unit, local_index); - DASH_LOG_DEBUG_VAR("GlobDynamicMem.at const >", git); + DASH_LOG_DEBUG_VAR("GlobHeap.at const >", git); return git; } @@ -954,7 +954,7 @@ class GlobDynamicMem */ void update_lbegin() noexcept { - DASH_LOG_TRACE("GlobDynamicMem.update_lbegin()"); + DASH_LOG_TRACE("GlobHeap.update_lbegin()"); local_iterator unit_lbegin( // iteration space _buckets.begin(), _buckets.end(), @@ -963,7 +963,7 @@ class GlobDynamicMem // bucket at position in iteration space, // offset in bucket _buckets.begin(), 0); - DASH_LOG_TRACE("GlobDynamicMem.update_lbegin >", unit_lbegin); + DASH_LOG_TRACE("GlobHeap.update_lbegin >", unit_lbegin); _lbegin = unit_lbegin; } @@ -973,7 +973,7 @@ class GlobDynamicMem */ void update_lend() noexcept { - DASH_LOG_TRACE("GlobDynamicMem.update_lend()"); + DASH_LOG_TRACE("GlobHeap.update_lend()"); local_iterator unit_lend( // iteration space _buckets.begin(), _buckets.end(), @@ -982,7 +982,7 @@ class GlobDynamicMem // bucket at position in iteration space, // offset in bucket _buckets.end(), 0); - DASH_LOG_TRACE("GlobDynamicMem.update_lend >", unit_lend); + DASH_LOG_TRACE("GlobHeap.update_lend >", unit_lend); _lend = unit_lend; } @@ -992,15 +992,15 @@ class GlobDynamicMem */ size_type commit_detach() { - DASH_LOG_TRACE("GlobDynamicMem.commit_detach()"); - DASH_LOG_TRACE("GlobDynamicMem.commit_detach", + DASH_LOG_TRACE("GlobHeap.commit_detach()"); + DASH_LOG_TRACE("GlobHeap.commit_detach", "local buckets to detach:", _num_detach_buckets.local[0]); // Number of elements successfully deallocated from global memory in // this commit: size_type num_detached_elem = 0; for (auto bucket_it = _detach_buckets.begin(); bucket_it != _detach_buckets.cend(); ++bucket_it) { - DASH_LOG_TRACE("GlobDynamicMem.commit_detach", "detaching bucket:", + DASH_LOG_TRACE("GlobHeap.commit_detach", "detaching bucket:", "size:", bucket_it->size, "lptr:", bucket_it->lptr, "gptr:", bucket_it->gptr); @@ -1013,7 +1013,7 @@ class GlobDynamicMem } } _detach_buckets.clear(); - DASH_LOG_TRACE("GlobDynamicMem.commit_detach >", + DASH_LOG_TRACE("GlobHeap.commit_detach >", "globally deallocated elements:", num_detached_elem); return num_detached_elem; } @@ -1023,8 +1023,8 @@ class GlobDynamicMem */ size_type commit_attach() { - DASH_LOG_TRACE("GlobDynamicMem.commit_attach()"); - DASH_LOG_TRACE("GlobDynamicMem.commit_attach", + DASH_LOG_TRACE("GlobHeap.commit_attach()"); + DASH_LOG_TRACE("GlobHeap.commit_attach", "local buckets to attach:", _num_attach_buckets.local[0]); // Unregister buckets marked for detach in global memory: _num_attach_buckets.barrier(); @@ -1033,9 +1033,9 @@ class GlobDynamicMem _num_attach_buckets.end()); auto min_attach_buckets = min_max_attach.first; auto max_attach_buckets = min_max_attach.second; - DASH_LOG_TRACE("GlobDynamicMem.commit_attach", + DASH_LOG_TRACE("GlobHeap.commit_attach", "min. attach buckets:", min_attach_buckets); - DASH_LOG_TRACE("GlobDynamicMem.commit_attach", + DASH_LOG_TRACE("GlobHeap.commit_attach", "max. attach buckets:", max_attach_buckets); // Number of buckets successfully attached in this commit: size_type num_attached_buckets = 0; @@ -1047,10 +1047,10 @@ class GlobDynamicMem // Whether at least one remote unit needs to attach additional global // memory: bool has_remote_attach = _remote_size > old_remote_size; - DASH_LOG_TRACE_VAR("GlobDynamicMem.commit_attach", old_remote_size); - DASH_LOG_TRACE_VAR("GlobDynamicMem.commit_attach", _remote_size); - DASH_LOG_TRACE_VAR("GlobDynamicMem.commit_attach", size()); - DASH_LOG_TRACE_VAR("GlobDynamicMem.commit_attach", has_remote_attach); + DASH_LOG_TRACE_VAR("GlobHeap.commit_attach", old_remote_size); + DASH_LOG_TRACE_VAR("GlobHeap.commit_attach", _remote_size); + DASH_LOG_TRACE_VAR("GlobHeap.commit_attach", size()); + DASH_LOG_TRACE_VAR("GlobHeap.commit_attach", has_remote_attach); // Plausibility check: DASH_ASSERT(!has_remote_attach || max_attach_buckets > 0); @@ -1060,23 +1060,23 @@ class GlobDynamicMem // them locally so a remote unit's local index can be mapped to the // remote unit's bucket. if (min_attach_buckets == 0 && max_attach_buckets == 0) { - DASH_LOG_TRACE("GlobDynamicMem.commit_attach", "no attach"); + DASH_LOG_TRACE("GlobHeap.commit_attach", "no attach"); DASH_ASSERT(_attach_buckets_first == _buckets.end()); DASH_ASSERT(_buckets.empty() || _buckets.back().attached); } - DASH_LOG_TRACE("GlobDynamicMem.commit_attach", "attaching", + DASH_LOG_TRACE("GlobHeap.commit_attach", "attaching", std::distance(_attach_buckets_first, _buckets.end()), "buckets"); for (; _attach_buckets_first != _buckets.end(); ++_attach_buckets_first) { bucket_type & bucket = *_attach_buckets_first; DASH_ASSERT(!bucket.attached); - DASH_LOG_TRACE("GlobDynamicMem.commit_attach", "attaching bucket"); - DASH_LOG_TRACE_VAR("GlobDynamicMem.commit_attach", bucket.size); - DASH_LOG_TRACE_VAR("GlobDynamicMem.commit_attach", bucket.lptr); + DASH_LOG_TRACE("GlobHeap.commit_attach", "attaching bucket"); + DASH_LOG_TRACE_VAR("GlobHeap.commit_attach", bucket.size); + DASH_LOG_TRACE_VAR("GlobHeap.commit_attach", bucket.lptr); // Attach bucket's local memory segment in global memory: bucket.gptr = _allocator.attach(bucket.lptr, bucket.size); bucket.attached = true; - DASH_LOG_TRACE("GlobDynamicMem.commit_attach", "attached bucket:", + DASH_LOG_TRACE("GlobHeap.commit_attach", "attached bucket:", "gptr:", bucket.gptr); num_attached_elem += bucket.size; _num_attach_buckets.local[0] -= 1; @@ -1086,12 +1086,12 @@ class GlobDynamicMem // All units must attach the same number of buckets collectively. // Attach empty buckets if this unit attached less than the maximum // number of buckets attached by any other unit in this commit: - DASH_LOG_TRACE("GlobDynamicMem.commit_attach", + DASH_LOG_TRACE("GlobHeap.commit_attach", "local buckets attached:", num_attached_buckets); - DASH_LOG_TRACE("GlobDynamicMem.commit_attach", + DASH_LOG_TRACE("GlobHeap.commit_attach", "buckets required to attach:", max_attach_buckets); while (num_attached_buckets < max_attach_buckets) { - DASH_LOG_TRACE("GlobDynamicMem.commit_attach", "attaching null bucket"); + DASH_LOG_TRACE("GlobHeap.commit_attach", "attaching null bucket"); bucket_type bucket; bucket.size = 0; bucket.lptr = nullptr; @@ -1100,11 +1100,11 @@ class GlobDynamicMem DASH_ASSERT(!DART_GPTR_ISNULL(bucket.gptr)); _buckets.push_back(bucket); num_attached_buckets++; - DASH_LOG_TRACE("GlobDynamicMem.commit_attach", "attached null bucket:", + DASH_LOG_TRACE("GlobHeap.commit_attach", "attached null bucket:", "gptr:", bucket.gptr, "left:", max_attach_buckets - num_attached_buckets); } - DASH_LOG_TRACE("GlobDynamicMem.commit_attach >", + DASH_LOG_TRACE("GlobHeap.commit_attach >", "globally allocated elements:", num_attached_elem); return num_attached_elem; } @@ -1118,7 +1118,7 @@ class GlobDynamicMem { // TODO: Unoptimized, use dash::min_max_element once it is available // - DASH_LOG_TRACE("GlobDynamicMem.gather_min_max()"); + DASH_LOG_TRACE("GlobHeap.gather_min_max()"); std::vector lcopy(dash::distance(first, last)); auto lcopy_end = dash::copy(first, last, lcopy.data()); auto min_lptr = std::min_element(lcopy.data(), lcopy_end); @@ -1126,7 +1126,7 @@ class GlobDynamicMem std::pair min_max; min_max.first = *min_lptr; min_max.second = *max_lptr; - DASH_LOG_TRACE("GlobDynamicMem.gather_min_max >", + DASH_LOG_TRACE("GlobHeap.gather_min_max >", "min:", min_max.first, "max:", min_max.second); return min_max; @@ -1171,7 +1171,7 @@ class GlobDynamicMem // attach_bucket_sizes temporarily attached by u in step 1. // 5. Detach vector attach_bucket_sizes. - DASH_LOG_TRACE("GlobDynamicMem.update_remote_size()"); + DASH_LOG_TRACE("GlobHeap.update_remote_size()"); size_type new_remote_size = 0; // Number of unattached buckets of every unit: std::vector num_unattached_buckets(_nunits, 0); @@ -1185,7 +1185,7 @@ class GlobDynamicMem for (auto bit = _attach_buckets_first; bit != _buckets.end(); ++bit) { attach_buckets_sizes.push_back((*bit).size); } - DASH_LOG_TRACE_VAR("GlobDynamicMem.update_remote_size", + DASH_LOG_TRACE_VAR("GlobHeap.update_remote_size", attach_buckets_sizes); // Use same allocator type as used for values in global memory: typedef typename allocator_type::template rebind::other @@ -1196,13 +1196,13 @@ class GlobDynamicMem attach_buckets_sizes.size()); _team->barrier(); // Implicit barrier in allocator.attach - DASH_LOG_TRACE_VAR("GlobDynamicMem.update_remote_size", + DASH_LOG_TRACE_VAR("GlobHeap.update_remote_size", attach_buckets_sizes_gptr); for (int u = 0; u < _nunits; ++u) { if (u == _myid) { continue; } - DASH_LOG_TRACE("GlobDynamicMem.update_remote_size", + DASH_LOG_TRACE("GlobHeap.update_remote_size", "collecting local bucket sizes of unit", u); // Last known local attached capacity of remote unit: auto & u_bucket_cumul_sizes = _bucket_cumul_sizes[u]; @@ -1211,15 +1211,15 @@ class GlobDynamicMem ? 0 : u_bucket_cumul_sizes.back(); size_type u_local_size_new = _local_sizes[u]; - DASH_LOG_TRACE_VAR("GlobDynamicMem.update_remote_size", + DASH_LOG_TRACE_VAR("GlobHeap.update_remote_size", u_local_size_old); - DASH_LOG_TRACE_VAR("GlobDynamicMem.update_remote_size", + DASH_LOG_TRACE_VAR("GlobHeap.update_remote_size", u_local_size_old); int u_local_size_diff = u_local_size_new - u_local_size_old; new_remote_size += u_local_size_new; // Number of unattached buckets of unit u: size_type u_num_attach_buckets = num_unattached_buckets[u]; - DASH_LOG_TRACE_VAR("GlobDynamicMem.update_remote_size", + DASH_LOG_TRACE_VAR("GlobHeap.update_remote_size", u_num_attach_buckets); if (u_num_attach_buckets == 0) { // No unattached buckets at unit u. @@ -1248,7 +1248,7 @@ class GlobDynamicMem for (int bi = 0; bi < u_num_attach_buckets; ++bi) { size_type single_bkt_size = u_attach_buckets_sizes[bi]; size_type cumul_bkt_size = single_bkt_size; - DASH_LOG_TRACE_VAR("GlobDynamicMem.update_remote_size", + DASH_LOG_TRACE_VAR("GlobHeap.update_remote_size", single_bkt_size); if (u_bucket_cumul_sizes.size() > 0) { cumul_bkt_size += u_bucket_cumul_sizes.back(); @@ -1267,12 +1267,12 @@ class GlobDynamicMem _team->barrier(); #if DASH_ENABLE_TRACE_LOGGING for (int u = 0; u < _nunits; ++u) { - DASH_LOG_TRACE("GlobDynamicMem.update_remote_size", + DASH_LOG_TRACE("GlobHeap.update_remote_size", "unit", u, "cumulative bucket sizes:", _bucket_cumul_sizes[u]); } #endif - DASH_LOG_TRACE("GlobDynamicMem.update_remote_size >", new_remote_size); + DASH_LOG_TRACE("GlobHeap.update_remote_size >", new_remote_size); _remote_size = new_remote_size; return _remote_size; } @@ -1288,7 +1288,7 @@ class GlobDynamicMem /// Offset of the referenced address in the bucket's memory space. index_type bucket_phase) const { - DASH_LOG_DEBUG("GlobDynamicMem.dart_gptr_at(u,bi,bp)", + DASH_LOG_DEBUG("GlobHeap.dart_gptr_at(u,bi,bp)", unit, bucket_index, bucket_phase); if (_nunits == 0) { DASH_THROW(dash::exception::RuntimeError, "No units in team"); @@ -1297,16 +1297,16 @@ class GlobDynamicMem auto bucket_it = _buckets.begin(); std::advance(bucket_it, bucket_index); auto dart_gptr = bucket_it->gptr; - DASH_LOG_TRACE_VAR("GlobDynamicMem.dart_gptr_at", bucket_it->attached); - DASH_LOG_TRACE_VAR("GlobDynamicMem.dart_gptr_at", bucket_it->gptr); + DASH_LOG_TRACE_VAR("GlobHeap.dart_gptr_at", bucket_it->attached); + DASH_LOG_TRACE_VAR("GlobHeap.dart_gptr_at", bucket_it->gptr); if (unit == _myid) { - DASH_LOG_TRACE_VAR("GlobDynamicMem.dart_gptr_at", bucket_it->lptr); - DASH_LOG_TRACE_VAR("GlobDynamicMem.dart_gptr_at", bucket_it->size); + DASH_LOG_TRACE_VAR("GlobHeap.dart_gptr_at", bucket_it->lptr); + DASH_LOG_TRACE_VAR("GlobHeap.dart_gptr_at", bucket_it->size); DASH_ASSERT_LT(bucket_phase, bucket_it->size, "bucket phase out of bounds"); } if (DART_GPTR_ISNULL(dart_gptr)) { - DASH_LOG_TRACE("GlobDynamicMem.dart_gptr_at", + DASH_LOG_TRACE("GlobHeap.dart_gptr_at", "bucket.gptr is DART_GPTR_NULL"); dart_gptr = DART_GPTR_NULL; } else { @@ -1320,12 +1320,12 @@ class GlobDynamicMem bucket_phase * sizeof(value_type)), DART_OK); } - DASH_LOG_DEBUG("GlobDynamicMem.dart_gptr_at >", dart_gptr); + DASH_LOG_DEBUG("GlobHeap.dart_gptr_at >", dart_gptr); return dart_gptr; } -}; // class GlobDynamicMem +}; // class GlobHeap } // namespace dash -#endif // DASH__GLOB_DYNAMIC_MEM_H_ +#endif // DASH__GLOB_HEAP_H__INCLUDED diff --git a/dash/include/dash/GlobPtr.h b/dash/include/dash/GlobPtr.h index ace1aeefd..9e243a5a7 100644 --- a/dash/include/dash/GlobPtr.h +++ b/dash/include/dash/GlobPtr.h @@ -32,9 +32,9 @@ namespace dash { // Forward-declarations template class GlobRef; template class GlobMem; + class AllocT> class GlobStaticHeap; template class GlobDynamicMem; + class AllocT> class GlobHeap; template class GlobConstPtr; /** @@ -59,7 +59,7 @@ template class GlobConstPtr; */ template< typename ElementType, - class MemorySpace = GlobMem< + class MemorySpace = GlobStaticHeap< typename std::remove_const::type, dash::allocator::CollectiveAllocator< typename std::remove_const::type @@ -135,7 +135,7 @@ class GlobPtr dart_gptr_t gptr) : _dart_gptr(gptr) // TODO: Should bind temporary, see dash::memalloc in - // dash/GlobUnitMem.h + // dash/GlobUnitHeap.h , _mem_space(nullptr) { } @@ -569,7 +569,7 @@ std::ostream & operator<<( * * TODO: Will be replaced by specialization of GlobPtr for global * memory space tagged as unit-scope address space - * (see GlobUnitMem). + * (see GlobUnitHeap). */ template class GlobConstPtr diff --git a/dash/include/dash/GlobRef.h b/dash/include/dash/GlobRef.h index d9fdc958e..35e468105 100644 --- a/dash/include/dash/GlobRef.h +++ b/dash/include/dash/GlobRef.h @@ -1,7 +1,7 @@ #ifndef DASH__GLOBREF_H_ #define DASH__GLOBREF_H_ -#include +#include #include #include @@ -9,7 +9,7 @@ namespace dash { // Forward declarations -template class GlobMem; +template class GlobStaticHeap; template class GlobConstPtr; template class GlobPtr; diff --git a/dash/include/dash/GlobSharedRef.h b/dash/include/dash/GlobSharedRef.h index bb2f7400d..9e2b14eb9 100644 --- a/dash/include/dash/GlobSharedRef.h +++ b/dash/include/dash/GlobSharedRef.h @@ -1,14 +1,14 @@ #ifndef DASH__GLOB_SHARED_EF_H_ #define DASH__GLOB_SHARED_EF_H_ -#include +#include #include #include namespace dash { // Forward declaration -template class GlobMem; +template class GlobStaticHeap; // Forward declaration template class GlobPtr; // Forward declaration diff --git a/dash/include/dash/GlobMem.h b/dash/include/dash/GlobStaticHeap.h similarity index 89% rename from dash/include/dash/GlobMem.h rename to dash/include/dash/GlobStaticHeap.h index 53e088b24..eeb87f49a 100644 --- a/dash/include/dash/GlobMem.h +++ b/dash/include/dash/GlobStaticHeap.h @@ -1,5 +1,5 @@ -#ifndef DASH__GLOB_MEM_H__INCLUDED -#define DASH__GLOB_MEM_H__INCLUDED +#ifndef DASH__GLOB_STATIC_HEAP_H__INCLUDED +#define DASH__GLOB_STATIC_HEAP_H__INCLUDED #include @@ -77,10 +77,10 @@ template< /// deallocate physical memory class AllocatorType = dash::allocator::CollectiveAllocator > -class GlobMem +class GlobStaticHeap { private: - typedef GlobMem + typedef GlobStaticHeap self_t; public: @@ -118,10 +118,10 @@ class GlobMem public: /** - * Constructor, creates instance of GlobMem with pre-allocated + * Constructor, creates instance of GlobStaticHeap with pre-allocated * memory space. */ - GlobMem( + GlobStaticHeap( dart_gptr_t gbegin, /// Number of local elements to allocate in global memory space size_type n_local_elem, @@ -135,13 +135,13 @@ class GlobMem _myid(team.myid()), _nlelem(n_local_elem) { - DASH_LOG_TRACE("GlobMem(gbegin,nlocal,team)", + DASH_LOG_TRACE("GlobStaticHeap(gbegin,nlocal,team)", "preallocated at:", _begptr, "number of local values:", _nlelem, "team size:", team.size()); update_lbegin(); update_lend(); - DASH_LOG_TRACE("GlobMem(gbegin,nlocal,team) >"); + DASH_LOG_TRACE("GlobStaticHeap(gbegin,nlocal,team) >"); } /** @@ -153,7 +153,7 @@ class GlobMem * For example, \c dash::LocalAllocator is used in \c dash::Shared * and only called at owner unit. */ - explicit GlobMem( + explicit GlobStaticHeap( /// Number of local elements to allocate in global memory space size_type n_local_elem, /// Team containing all units operating on the global memory region @@ -165,7 +165,7 @@ class GlobMem _myid(team.myid()), _nlelem(n_local_elem) { - DASH_LOG_TRACE("GlobMem(nlocal,team)", + DASH_LOG_TRACE("GlobStaticHeap(nlocal,team)", "number of local values:", _nlelem, "team size:", team.size()); _begptr = _allocator.allocate(_nlelem); @@ -174,7 +174,7 @@ class GlobMem // Use id's of team all update_lbegin(); update_lend(); - DASH_LOG_TRACE("GlobMem(nlocal,team) >"); + DASH_LOG_TRACE("GlobStaticHeap(nlocal,team) >"); } /** @@ -186,7 +186,7 @@ class GlobMem * For example, \c dash::LocalAllocator is used in \c dash::Shared * and only called at owner unit. */ - explicit GlobMem( + explicit GlobStaticHeap( /// Local elements to allocate in global memory space std::initializer_list local_elements, /// Team containing all units operating on the global memory region @@ -198,7 +198,7 @@ class GlobMem _myid(team.myid()), _nlelem(local_elements.size()) { - DASH_LOG_DEBUG("GlobMem(lvals,team)", + DASH_LOG_DEBUG("GlobStaticHeap(lvals,team)", "number of local values:", _nlelem, "team size:", team.size()); _begptr = _allocator.allocate(_nlelem); @@ -225,28 +225,28 @@ class GlobMem // // TODO: Should depend on allocator trait // dash::allocator_traits::is_collective() - DASH_LOG_DEBUG("GlobMem(lvals,team)", "barrier"); + DASH_LOG_DEBUG("GlobStaticHeap(lvals,team)", "barrier"); barrier(); } - DASH_LOG_DEBUG("GlobMem(lvals,team) >", + DASH_LOG_DEBUG("GlobStaticHeap(lvals,team) >", "_lbegin:", _lbegin, "_lend:", _lend); } /** * Destructor, collectively frees underlying global memory. */ - ~GlobMem() + ~GlobStaticHeap() { - DASH_LOG_TRACE_VAR("GlobMem.~GlobMem()", _begptr); + DASH_LOG_TRACE_VAR("GlobStaticHeap.~GlobStaticHeap()", _begptr); _allocator.deallocate(_begptr); - DASH_LOG_TRACE("GlobMem.~GlobMem >"); + DASH_LOG_TRACE("GlobStaticHeap.~GlobStaticHeap >"); } /** * Copy constructor. */ - GlobMem(const self_t & other) + GlobStaticHeap(const self_t & other) = default; /** @@ -323,7 +323,7 @@ class GlobMem /** * Native pointer of the initial address of the local memory of - * the unit that initialized this GlobMem instance. + * the unit that initialized this GlobStaticHeap instance. */ constexpr const_local_pointer lbegin() const noexcept { @@ -332,7 +332,7 @@ class GlobMem /** * Native pointer of the initial address of the local memory of - * the unit that initialized this GlobMem instance. + * the unit that initialized this GlobStaticHeap instance. */ inline local_pointer lbegin() noexcept { @@ -341,7 +341,7 @@ class GlobMem /** * Native pointer of the initial address of the local memory of - * the unit that initialized this GlobMem instance. + * the unit that initialized this GlobStaticHeap instance. */ constexpr const_local_pointer lend() const noexcept { @@ -350,7 +350,7 @@ class GlobMem /** * Native pointer of the initial address of the local memory of - * the unit that initialized this GlobMem instance. + * the unit that initialized this GlobStaticHeap instance. */ inline local_pointer lend() noexcept { @@ -367,7 +367,7 @@ class GlobMem const ValueType & newval, index_type global_index) { - DASH_LOG_TRACE("GlobMem.put_value(newval, gidx = %d)", global_index); + DASH_LOG_TRACE("GlobStaticHeap.put_value(newval, gidx = %d)", global_index); dash::put_value(newval, GlobPtr( *this, _begptr @@ -384,7 +384,7 @@ class GlobMem ValueType * ptr, index_type global_index) const { - DASH_LOG_TRACE("GlobMem.get_value(newval, gidx = %d)", global_index); + DASH_LOG_TRACE("GlobStaticHeap.get_value(newval, gidx = %d)", global_index); dash::get_value(ptr, GlobPtr( *this, _begptr @@ -440,27 +440,27 @@ class GlobMem /// The unit's local address offset IndexType local_index) const { - DASH_LOG_DEBUG("GlobMem.at(unit,l_idx)", unit, local_index); + DASH_LOG_DEBUG("GlobStaticHeap.at(unit,l_idx)", unit, local_index); if (_nunits == 0 || DART_GPTR_ISNULL(_begptr)) { - DASH_LOG_DEBUG("GlobMem.at(unit,l_idx) >", + DASH_LOG_DEBUG("GlobStaticHeap.at(unit,l_idx) >", "global memory not allocated"); return pointer(nullptr); } // Initialize with global pointer to start address: dart_gptr_t gptr = _begptr; // Resolve global unit id - DASH_LOG_TRACE_VAR("GlobMem.at (=g_begptr)", gptr); - DASH_LOG_TRACE_VAR("GlobMem.at", gptr.unitid); + DASH_LOG_TRACE_VAR("GlobStaticHeap.at (=g_begptr)", gptr); + DASH_LOG_TRACE_VAR("GlobStaticHeap.at", gptr.unitid); team_unit_t lunit{gptr.unitid}; - DASH_LOG_TRACE_VAR("GlobMem.at", lunit); + DASH_LOG_TRACE_VAR("GlobStaticHeap.at", lunit); lunit = (lunit + unit) % _nunits; - DASH_LOG_TRACE_VAR("GlobMem.at", lunit); + DASH_LOG_TRACE_VAR("GlobStaticHeap.at", lunit); // Apply global unit to global pointer: dart_gptr_setunit(&gptr, lunit); // Apply local offset to global pointer: pointer res_gptr(*this, gptr); res_gptr += local_index; - DASH_LOG_DEBUG("GlobMem.at (+g_unit) >", res_gptr); + DASH_LOG_DEBUG("GlobStaticHeap.at (+g_unit) >", res_gptr); return res_gptr; } @@ -474,7 +474,7 @@ class GlobMem { void *addr; dart_gptr_t gptr = _begptr; - DASH_LOG_TRACE_VAR("GlobMem.update_lbegin", + DASH_LOG_TRACE_VAR("GlobStaticHeap.update_lbegin", pointer(*this, gptr)); DASH_ASSERT_RETURNS( dart_gptr_setunit(&gptr, _myid), @@ -482,7 +482,7 @@ class GlobMem DASH_ASSERT_RETURNS( dart_gptr_getaddr(gptr, &addr), DART_OK); - DASH_LOG_TRACE_VAR("GlobMem.update_lbegin >", addr); + DASH_LOG_TRACE_VAR("GlobStaticHeap.update_lbegin >", addr); _lbegin = static_cast(addr); } @@ -525,12 +525,12 @@ void memfree(GlobPtrT gptr) { // TODO: Should notify GlobPtrT instance gptr of this deallocation // as it might be owner of its referenced global memory space - // (see GlobUnitMem). + // (see GlobUnitHeap). dart_memfree(gptr.dart_gptr()); } } // namespace dash -#include +#include -#endif // DASH__GLOB_MEM_H__INCLUDED +#endif // DASH__GLOB_STATIC_HEAP_H__INCLUDED diff --git a/dash/include/dash/GlobUnitMem.h b/dash/include/dash/GlobUnitHeap.h similarity index 88% rename from dash/include/dash/GlobUnitMem.h rename to dash/include/dash/GlobUnitHeap.h index eb8b85588..61d120c28 100644 --- a/dash/include/dash/GlobUnitMem.h +++ b/dash/include/dash/GlobUnitHeap.h @@ -25,10 +25,10 @@ template< /// deallocate physical memory class AllocatorType = dash::allocator::LocalAllocator > -class GlobUnitMem +class GlobUnitHeap { private: - typedef GlobUnitMem + typedef GlobUnitHeap self_t; public: @@ -66,10 +66,10 @@ class GlobUnitMem public: /** - * Constructor, creates instance of GlobUnitMem with pre-allocated + * Constructor, creates instance of GlobUnitHeap with pre-allocated * memory space. */ - GlobUnitMem( + GlobUnitHeap( dart_gptr_t gbegin, /// Number of local elements to allocate in global memory space size_type n_local_elem, @@ -83,13 +83,13 @@ class GlobUnitMem _myid(team.myid()), _nlelem(n_local_elem) { - DASH_LOG_TRACE("GlobUnitMem(gbegin,nlocal,team)", + DASH_LOG_TRACE("GlobUnitHeap(gbegin,nlocal,team)", "preallocated at:", _begptr, "number of local values:", _nlelem, "team size:", team.size()); update_lbegin(); update_lend(); - DASH_LOG_TRACE("GlobUnitMem(gbegin,nlocal,team) >"); + DASH_LOG_TRACE("GlobUnitHeap(gbegin,nlocal,team) >"); } /** @@ -101,7 +101,7 @@ class GlobUnitMem * For example, \c dash::LocalAllocator is used in \c dash::Shared * and only called at owner unit. */ - explicit GlobUnitMem( + explicit GlobUnitHeap( /// Number of local elements to allocate in global memory space size_type n_local_elem, /// Team containing all units operating on the global memory region @@ -113,7 +113,7 @@ class GlobUnitMem _myid(team.myid()), _nlelem(n_local_elem) { - DASH_LOG_TRACE("GlobUnitMem(nlocal,team)", + DASH_LOG_TRACE("GlobUnitHeap(nlocal,team)", "number of local values:", _nlelem, "team size:", team.size()); _begptr = _allocator.allocate(_nlelem); @@ -122,7 +122,7 @@ class GlobUnitMem // Use id's of team all update_lbegin(); update_lend(); - DASH_LOG_TRACE("GlobUnitMem(nlocal,team) >"); + DASH_LOG_TRACE("GlobUnitHeap(nlocal,team) >"); } /** @@ -134,7 +134,7 @@ class GlobUnitMem * For example, \c dash::LocalAllocator is used in \c dash::Shared * and only called at owner unit. */ - explicit GlobUnitMem( + explicit GlobUnitHeap( /// Local elements to allocate in global memory space std::initializer_list local_elements, /// Team containing all units operating on the global memory region @@ -146,7 +146,7 @@ class GlobUnitMem _myid(team.myid()), _nlelem(local_elements.size()) { - DASH_LOG_DEBUG("GlobUnitMem(lvals,team)", + DASH_LOG_DEBUG("GlobUnitHeap(lvals,team)", "number of local values:", _nlelem, "team size:", team.size()); _begptr = _allocator.allocate(_nlelem); @@ -173,28 +173,28 @@ class GlobUnitMem // // TODO: Should depend on allocator trait // dash::allocator_traits::is_collective() - DASH_LOG_DEBUG("GlobUnitMem(lvals,team)", "barrier"); + DASH_LOG_DEBUG("GlobUnitHeap(lvals,team)", "barrier"); barrier(); } - DASH_LOG_DEBUG("GlobUnitMem(lvals,team) >", + DASH_LOG_DEBUG("GlobUnitHeap(lvals,team) >", "_lbegin:", _lbegin, "_lend:", _lend); } /** * Destructor, collectively frees underlying global memory. */ - ~GlobUnitMem() + ~GlobUnitHeap() { - DASH_LOG_TRACE_VAR("GlobUnitMem.~GlobUnitMem()", _begptr); + DASH_LOG_TRACE_VAR("GlobUnitHeap.~GlobUnitHeap()", _begptr); _allocator.deallocate(_begptr); - DASH_LOG_TRACE("GlobUnitMem.~GlobUnitMem >"); + DASH_LOG_TRACE("GlobUnitHeap.~GlobUnitHeap >"); } /** * Copy constructor. */ - GlobUnitMem(const self_t & other) + GlobUnitHeap(const self_t & other) = default; /** @@ -271,7 +271,7 @@ class GlobUnitMem /** * Native pointer of the initial address of the local memory of - * the unit that initialized this GlobUnitMem instance. + * the unit that initialized this GlobUnitHeap instance. */ constexpr const_local_pointer lbegin() const noexcept { @@ -280,7 +280,7 @@ class GlobUnitMem /** * Native pointer of the initial address of the local memory of - * the unit that initialized this GlobUnitMem instance. + * the unit that initialized this GlobUnitHeap instance. */ inline local_pointer lbegin() noexcept { @@ -289,7 +289,7 @@ class GlobUnitMem /** * Native pointer of the initial address of the local memory of - * the unit that initialized this GlobUnitMem instance. + * the unit that initialized this GlobUnitHeap instance. */ constexpr const_local_pointer lend() const noexcept { @@ -298,7 +298,7 @@ class GlobUnitMem /** * Native pointer of the initial address of the local memory of - * the unit that initialized this GlobUnitMem instance. + * the unit that initialized this GlobUnitHeap instance. */ inline local_pointer lend() noexcept { @@ -315,7 +315,7 @@ class GlobUnitMem const ValueType & newval, index_type global_index) { - DASH_LOG_TRACE("GlobUnitMem.put_value(newval, gidx = %d)", global_index); + DASH_LOG_TRACE("GlobUnitHeap.put_value(newval, gidx = %d)", global_index); dash::put_value(newval, GlobPtr( *this, _begptr @@ -332,7 +332,7 @@ class GlobUnitMem ValueType * ptr, index_type global_index) const { - DASH_LOG_TRACE("GlobUnitMem.get_value(newval, gidx = %d)", global_index); + DASH_LOG_TRACE("GlobUnitHeap.get_value(newval, gidx = %d)", global_index); dash::get_value(ptr, GlobPtr( *this, _begptr @@ -388,14 +388,14 @@ class GlobUnitMem /// The unit's local address offset IndexType local_index) const { - DASH_LOG_DEBUG("GlobUnitMem.at(unit,l_idx)", unit, local_index); + DASH_LOG_DEBUG("GlobUnitHeap.at(unit,l_idx)", unit, local_index); if (_nunits == 0 || DART_GPTR_ISNULL(_begptr)) { - DASH_LOG_ERROR("GlobUnitMem.at(unit,l_idx) >", + DASH_LOG_ERROR("GlobUnitHeap.at(unit,l_idx) >", "global memory not allocated"); return pointer(nullptr); } if (unit.id != _begptr.unitid) { - DASH_LOG_ERROR("GlobUnitMem.at(unit,l_idx) >", + DASH_LOG_ERROR("GlobUnitHeap.at(unit,l_idx) >", "address in global unit memory requested for", unit, "but only allocated at unit", _begptr.unitid); return pointer(nullptr); @@ -405,7 +405,7 @@ class GlobUnitMem // Apply local offset to global pointer: pointer res_gptr(*this, gptr); res_gptr += local_index; - DASH_LOG_DEBUG("GlobUnitMem.at (+g_unit) >", res_gptr); + DASH_LOG_DEBUG("GlobUnitHeap.at (+g_unit) >", res_gptr); return res_gptr; } @@ -419,7 +419,7 @@ class GlobUnitMem { void *addr; dart_gptr_t gptr = _begptr; - DASH_LOG_TRACE_VAR("GlobUnitMem.update_lbegin", + DASH_LOG_TRACE_VAR("GlobUnitHeap.update_lbegin", pointer(*this, gptr)); DASH_ASSERT_RETURNS( dart_gptr_setunit(&gptr, _myid), @@ -427,7 +427,7 @@ class GlobUnitMem DASH_ASSERT_RETURNS( dart_gptr_getaddr(gptr, &addr), DART_OK); - DASH_LOG_TRACE_VAR("GlobUnitMem.update_lbegin >", addr); + DASH_LOG_TRACE_VAR("GlobUnitHeap.update_lbegin >", addr); _lbegin = static_cast(addr); } @@ -454,7 +454,7 @@ class GlobUnitMem template< typename T, - class MemSpaceT = dash::GlobUnitMem > + class MemSpaceT = dash::GlobUnitHeap > GlobPtr memalloc(size_t nelem) { dart_gptr_t gptr; diff --git a/dash/include/dash/Halo.h b/dash/include/dash/Halo.h index 79b857824..60687dfb4 100644 --- a/dash/include/dash/Halo.h +++ b/dash/include/dash/Halo.h @@ -2,7 +2,7 @@ #define DASH__HALO_H__ #include -#include +#include #include @@ -249,10 +249,10 @@ class BlockBoundaryIter ReferenceType> self_t; - typedef GlobMem< + typedef GlobStaticHeap< ElementType, dash::allocator::CollectiveAllocator > - GlobMem_t; + GlobStaticHeap_t; private: static const dim_t NumDimensions = PatternType::ndim(); @@ -699,23 +699,23 @@ class BlockBoundaryIter } /** - * The instance of \c GlobMem used by this iterator to resolve addresses + * The instance of \c GlobStaticHeap used by this iterator to resolve addresses * in global memory. * * \see DashGlobalIteratorConcept */ - inline const GlobMem_t & globmem() const + inline const GlobStaticHeap_t & globmem() const { return *_globmem; } /** - * The instance of \c GlobMem used by this iterator to resolve addresses + * The instance of \c GlobStaticHeap used by this iterator to resolve addresses * in global memory. * * \see DashGlobalIteratorConcept */ - inline GlobMem_t & globmem() + inline GlobStaticHeap_t & globmem() { return *_globmem; } @@ -995,7 +995,7 @@ class BlockBoundaryIter private: /// Global memory used to dereference iterated values. - GlobMem_t * _globmem = nullptr; + GlobStaticHeap_t * _globmem = nullptr; /// View specifying the block region. Iteration space contains the view /// elements within the boundary defined by the halo spec. const viewspec_type * _viewspec = nullptr; @@ -1249,10 +1249,10 @@ class HaloBlock typedef HaloBlock self_t; - typedef GlobMem< + typedef GlobStaticHeap< ElementType, dash::allocator::CollectiveAllocator > - GlobMem_t; + GlobStaticHeap_t; public: typedef PatternType pattern_type; @@ -1275,7 +1275,7 @@ class HaloBlock */ HaloBlock( /// Global memory used to dereference iterated values. - GlobMem_t * globmem, + GlobStaticHeap_t * globmem, // Pattern that created the encapsulated block. const pattern_type & pattern, // View specifying the inner block region. @@ -1323,7 +1323,7 @@ class HaloBlock /** * Global memory accessor used to dereference iterated values. */ - inline GlobMem_t & globmem() + inline GlobStaticHeap_t & globmem() { return *_globmem; } @@ -1548,7 +1548,7 @@ class HaloBlock private: /// Global memory accessor used to dereference iterated values. - GlobMem_t * _globmem = nullptr; + GlobStaticHeap_t * _globmem = nullptr; /// The pattern that created the encapsulated block. const pattern_type * _pattern = nullptr; diff --git a/dash/include/dash/Iterator.h b/dash/include/dash/Iterator.h index 226ea6196..d05f04fa7 100644 --- a/dash/include/dash/Iterator.h +++ b/dash/include/dash/Iterator.h @@ -131,16 +131,16 @@ distance( template< typename ElementType, class Pattern, - class GlobMem, + class GlobStaticHeap, class Pointer, class Reference > typename Pattern::index_type distance( /// Global pointer to the initial position in the global sequence - const GlobIter & + const GlobIter & first, /// Global iterator to the final position in the global sequence - const GlobIter & + const GlobIter & last) { return last - first; diff --git a/dash/include/dash/List.h b/dash/include/dash/List.h index 3e9d9b96a..5934cb623 100644 --- a/dash/include/dash/List.h +++ b/dash/include/dash/List.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include @@ -197,7 +197,7 @@ class List internal::ListNode >::other node_allocator_type; - typedef dash::GlobDynamicMem + typedef dash::GlobHeap glob_mem_type; typedef dash::Array< diff --git a/dash/include/dash/Matrix.h b/dash/include/dash/Matrix.h index b22da371c..37149ec96 100644 --- a/dash/include/dash/Matrix.h +++ b/dash/include/dash/Matrix.h @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include @@ -156,8 +156,8 @@ class Matrix LocalRef_const_t; typedef PatternT Pattern_t; - typedef GlobMem> - GlobMem_t; + typedef GlobStaticHeap> + GlobStaticHeap_t; typedef DistributionSpec DistributionSpec_t; typedef SizeSpec @@ -618,7 +618,7 @@ class Matrix /// The matrix elements' distribution pattern Pattern_t _pattern; /// Global memory allocation and -access - GlobMem_t * _glob_mem; + GlobStaticHeap_t * _glob_mem; /// Native pointer to first local element in the array ElementT * _lbegin; /// Native pointer past last local element in the array diff --git a/dash/include/dash/Shared.h b/dash/include/dash/Shared.h index 3bd21bc70..84717c7ff 100644 --- a/dash/include/dash/Shared.h +++ b/dash/include/dash/Shared.h @@ -3,7 +3,7 @@ #include -#include +#include #include #include @@ -41,10 +41,10 @@ class Shared { typedef GlobRef> atomic_ref_type; private: - typedef dash::GlobMem< + typedef dash::GlobStaticHeap< value_type, dash::allocator::LocalAllocator > - GlobMem_t; + GlobStaticHeap_t; template friend void swap(Shared & a, Shared & b); @@ -70,7 +70,7 @@ class Shared { if (_team->myid() == _owner) { DASH_LOG_DEBUG("Shared.Shared(team,owner)", "allocating shared value in local memory"); - _globmem = std::make_shared(1, team); + _globmem = std::make_shared(1, team); _ptr = _globmem->begin(); } // Broadcast global pointer of shared value at unit 0 to all units: @@ -187,7 +187,7 @@ class Shared { private: dash::Team * _team = nullptr; team_unit_t _owner; - std::shared_ptr _globmem = nullptr; + std::shared_ptr _globmem = nullptr; pointer _ptr; }; diff --git a/dash/include/dash/UnorderedMap.h b/dash/include/dash/UnorderedMap.h index d0459dceb..c0115eeb9 100644 --- a/dash/include/dash/UnorderedMap.h +++ b/dash/include/dash/UnorderedMap.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include @@ -155,7 +155,7 @@ class UnorderedMap typedef typename dash::container_traits::local_type local_type; - typedef dash::GlobDynamicMem glob_mem_type; + typedef dash::GlobHeap glob_mem_type; typedef typename glob_mem_type::reference reference; typedef typename glob_mem_type::const_reference const_reference; diff --git a/dash/include/dash/allocator/CollectiveAllocator.h b/dash/include/dash/allocator/CollectiveAllocator.h index eb6d079de..b2528874d 100644 --- a/dash/include/dash/allocator/CollectiveAllocator.h +++ b/dash/include/dash/allocator/CollectiveAllocator.h @@ -118,12 +118,6 @@ class CollectiveAllocator * \see DashAllocatorConcept */ self_t & operator=(const self_t & other) = delete; -#if 0 - { - // noop - return *this; - } -#endif /** * Move-assignment operator. diff --git a/dash/include/dash/allocator/GlobBucketIter.h b/dash/include/dash/allocator/GlobBucketIter.h index 4494894b0..38d5f5aa9 100644 --- a/dash/include/dash/allocator/GlobBucketIter.h +++ b/dash/include/dash/allocator/GlobBucketIter.h @@ -11,7 +11,7 @@ #include #include -#include +#include #include @@ -29,44 +29,44 @@ namespace dash { template< typename ElementType, class AllocatorType > -class GlobDynamicMem; +class GlobHeap; /** * Iterator on global buckets. Represents global pointer type. */ template< typename ElementType, - class GlobMemType, + class GlobStaticHeapType, class PointerType = dash::GlobPtr, class ReferenceType = dash::GlobSharedRef > class GlobBucketIter : public std::iterator< std::random_access_iterator_tag, ElementType, - typename GlobMemType::index_type, + typename GlobStaticHeapType::index_type, PointerType, ReferenceType > { template< typename ElementType_, - class GlobMemType_, + class GlobStaticHeapType_, class Pointer_, class Reference_> friend std::ostream & dash::operator<<( std::ostream & os, const dash::GlobBucketIter< - ElementType_, GlobMemType_, Pointer_, Reference_> & it); + ElementType_, GlobStaticHeapType_, Pointer_, Reference_> & it); private: typedef GlobBucketIter< ElementType, - GlobMemType, + GlobStaticHeapType, PointerType, ReferenceType> self_t; public: - typedef typename GlobMemType::index_type index_type; + typedef typename GlobStaticHeapType::index_type index_type; typedef typename std::make_unsigned::type size_type; typedef ElementType value_type; @@ -80,16 +80,16 @@ class GlobBucketIter typedef typename std::conditional< std::is_const::value, - const GlobMemType, - GlobMemType + const GlobStaticHeapType, + GlobStaticHeapType >::type globmem_type; typedef typename std::conditional< std::is_const::value, - typename GlobMemType::const_local_pointer, - typename GlobMemType::local_pointer + typename GlobStaticHeapType::const_local_pointer, + typename GlobStaticHeapType::local_pointer >::type local_pointer; @@ -367,7 +367,7 @@ class GlobBucketIter } /** - * The instance of \c GlobMem used by this iterator to resolve addresses + * The instance of \c GlobStaticHeap used by this iterator to resolve addresses * in global memory. */ inline const globmem_type & globmem() const @@ -376,7 +376,7 @@ class GlobBucketIter } /** - * The instance of \c GlobMem used by this iterator to resolve addresses + * The instance of \c GlobStaticHeap used by this iterator to resolve addresses * in global memory. */ inline globmem_type & globmem() @@ -693,30 +693,30 @@ class GlobBucketIter */ template< typename ElementType, - class GlobMemType, + class GlobStaticHeapType, class Pointer, class Reference> auto distance( /// Global iterator to the first position in the global sequence const dash::GlobBucketIter< - ElementType, GlobMemType, Pointer, Reference> & first, + ElementType, GlobStaticHeapType, Pointer, Reference> & first, /// Global iterator to the final position in the global sequence const dash::GlobBucketIter< - ElementType, GlobMemType, Pointer, Reference> & last) --> typename GlobMemType::index_type + ElementType, GlobStaticHeapType, Pointer, Reference> & last) +-> typename GlobStaticHeapType::index_type { return last - first; } template< typename ElementType, - class GlobMemType, + class GlobStaticHeapType, class Pointer, class Reference> std::ostream & operator<<( std::ostream & os, const dash::GlobBucketIter< - ElementType, GlobMemType, Pointer, Reference> & it) + ElementType, GlobStaticHeapType, Pointer, Reference> & it) { std::ostringstream ss; ss << "dash::GlobBucketIter<" diff --git a/dash/include/dash/allocator/LocalBucketIter.h b/dash/include/dash/allocator/LocalBucketIter.h index ca70832a2..ff690344e 100644 --- a/dash/include/dash/allocator/LocalBucketIter.h +++ b/dash/include/dash/allocator/LocalBucketIter.h @@ -6,7 +6,7 @@ #include -#include +#include #include #include diff --git a/dash/include/dash/allocator/internal/GlobBucketIter.h b/dash/include/dash/allocator/internal/GlobBucketIter.h index 3460f90f4..9ae1a2fd9 100644 --- a/dash/include/dash/allocator/internal/GlobBucketIter.h +++ b/dash/include/dash/allocator/internal/GlobBucketIter.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include @@ -27,7 +27,7 @@ namespace dash { template< typename ElementType, class AllocatorType > -class GlobDynamicMem; +class GlobHeap; namespace internal { @@ -36,37 +36,37 @@ namespace internal { */ template< typename ElementType, - class GlobMemType, + class GlobStaticHeapType, class PointerType = dash::GlobPtr, class ReferenceType = dash::GlobRef > class GlobBucketIter : public std::iterator< std::random_access_iterator_tag, ElementType, - typename GlobMemType::index_type, + typename GlobStaticHeapType::index_type, PointerType, ReferenceType > { template< typename ElementType_, - class GlobMemType_, + class GlobStaticHeapType_, class Pointer_, class Reference_> friend std::ostream & dash::operator<<( std::ostream & os, const dash::internal::GlobBucketIter< - ElementType_, GlobMemType_, Pointer_, Reference_> & it); + ElementType_, GlobStaticHeapType_, Pointer_, Reference_> & it); private: typedef GlobBucketIter< ElementType, - GlobMemType, + GlobStaticHeapType, PointerType, ReferenceType> self_t; public: - typedef typename GlobMemType::index_type index_type; + typedef typename GlobStaticHeapType::index_type index_type; typedef typename std::make_unsigned::type size_type; typedef ElementType value_type; @@ -78,8 +78,8 @@ class GlobBucketIter typedef typename std::conditional< std::is_const::value, - typename GlobMemType::const_local_pointer, - typename GlobMemType::local_pointer + typename GlobStaticHeapType::const_local_pointer, + typename GlobStaticHeapType::local_pointer >::type local_pointer; @@ -116,7 +116,7 @@ class GlobBucketIter * offset in logical storage order. */ GlobBucketIter( - GlobMemType * gmem, + GlobStaticHeapType * gmem, index_type position = 0) : _globmem(gmem), _bucket_cumul_sizes(&_globmem->_bucket_cumul_sizes), @@ -158,7 +158,7 @@ class GlobBucketIter * local offset in logical storage order. */ GlobBucketIter( - GlobMemType * gmem, + GlobStaticHeapType * gmem, team_unit_t unit, index_type local_index) : _globmem(gmem), @@ -311,19 +311,19 @@ class GlobBucketIter } /** - * The instance of \c GlobMem used by this iterator to resolve addresses + * The instance of \c GlobStaticHeap used by this iterator to resolve addresses * in global memory. */ - inline const GlobMemType & globmem() const + inline const GlobStaticHeapType & globmem() const { return *_globmem; } /** - * The instance of \c GlobMem used by this iterator to resolve addresses + * The instance of \c GlobStaticHeap used by this iterator to resolve addresses * in global memory. */ - inline GlobMemType & globmem() + inline GlobStaticHeapType & globmem() { return *_globmem; } @@ -594,7 +594,7 @@ class GlobBucketIter private: /// Global memory used to dereference iterated values. - GlobMemType * _globmem = nullptr; + GlobStaticHeapType * _globmem = nullptr; /// Mapping unit id to buckets in the unit's attached local storage. bucket_cumul_sizes_map * _bucket_cumul_sizes = nullptr; /// Pointer to first element in local data space. @@ -625,17 +625,17 @@ class GlobBucketIter */ template< typename ElementType, - class GlobMemType, + class GlobStaticHeapType, class Pointer, class Reference> auto distance( /// Global iterator to the first position in the global sequence const dash::internal::GlobBucketIter< - ElementType, GlobMemType, Pointer, Reference> & first, + ElementType, GlobStaticHeapType, Pointer, Reference> & first, /// Global iterator to the final position in the global sequence const dash::internal::GlobBucketIter< - ElementType, GlobMemType, Pointer, Reference> & last) --> typename GlobMemType::index_type + ElementType, GlobStaticHeapType, Pointer, Reference> & last) +-> typename GlobStaticHeapType::index_type { return last - first; } @@ -644,13 +644,13 @@ auto distance( template< typename ElementType, - class GlobMemType, + class GlobStaticHeapType, class Pointer, class Reference> std::ostream & operator<<( std::ostream & os, const dash::internal::GlobBucketIter< - ElementType, GlobMemType, Pointer, Reference> & it) + ElementType, GlobStaticHeapType, Pointer, Reference> & it) { std::ostringstream ss; ss << "dash::internal::GlobBucketIter<" diff --git a/dash/include/dash/allocator/internal/GlobDynamicMemTypes.h b/dash/include/dash/allocator/internal/GlobHeapTypes.h similarity index 56% rename from dash/include/dash/allocator/internal/GlobDynamicMemTypes.h rename to dash/include/dash/allocator/internal/GlobHeapTypes.h index 66f0af184..39214b314 100644 --- a/dash/include/dash/allocator/internal/GlobDynamicMemTypes.h +++ b/dash/include/dash/allocator/internal/GlobHeapTypes.h @@ -1,5 +1,5 @@ -#ifndef DASH__INTERNAL__ALLOCATOR__GLOB_DYNAMIC_MEM_TYPES_H__INCLUDED -#define DASH__INTERNAL__ALLOCATOR__GLOB_DYNAMIC_MEM_TYPES_H__INCLUDED +#ifndef DASH__INTERNAL__ALLOCATOR__GLOB_HEAP_TYPES_H__INCLUDED +#define DASH__INTERNAL__ALLOCATOR__GLOB_HEAP_TYPES_H__INCLUDED namespace dash { namespace internal { @@ -18,4 +18,4 @@ struct glob_dynamic_mem_bucket_type } // namespace internal } // namespace dash -#endif // DASH__INTERNAL__ALLOCATOR__GLOB_DYNAMIC_MEM_TYPES_H__INCLUDED +#endif // DASH__INTERNAL__ALLOCATOR__GLOB_HEAP_TYPES_H__INCLUDED diff --git a/dash/include/dash/experimental/Halo.h b/dash/include/dash/experimental/Halo.h index 0c451588c..6fef2cc42 100644 --- a/dash/include/dash/experimental/Halo.h +++ b/dash/include/dash/experimental/Halo.h @@ -1,7 +1,7 @@ #ifndef DASH__EXPERIMENTAL__HALO_H__ #define DASH__EXPERIMENTAL__HALO_H__ -#include +#include #include #include @@ -243,7 +243,7 @@ class HaloBlockIter { private: using self_t = HaloBlockIter; - using GlobMem_t = GlobMem>; + using GlobStaticHeap_t = GlobStaticHeap>; static const dim_t NumDimensions = PatternT::ndim(); //static const MemArrange Arrangement = PatternT::memory_order(); @@ -269,7 +269,7 @@ class HaloBlockIter * Constructor, creates a block boundary iterator on multiple boundary * regions. */ - HaloBlockIter(GlobMem_t & globmem, const PatternT & pattern, + HaloBlockIter(GlobStaticHeap_t & globmem, const PatternT & pattern, const viewspec_t & halo_region, index_type pos, index_type size) : _globmem(globmem), _pattern(pattern), @@ -410,12 +410,12 @@ class HaloBlockIter } /** - * The instance of \c GlobMem used by this iterator to resolve addresses + * The instance of \c GlobStaticHeap used by this iterator to resolve addresses * in global memory. * * \see DashGlobalIteratorConcept */ - const GlobMem_t & globmem() const + const GlobStaticHeap_t & globmem() const { return _globmem; } @@ -562,7 +562,7 @@ class HaloBlockIter private: /// Global memory used to dereference iterated values. - GlobMem_t & _globmem; + GlobStaticHeap_t & _globmem; /// Pattern that created the encapsulated block. const PatternT & _pattern; @@ -611,7 +611,7 @@ class HaloBlockView { private: using self_t = HaloBlockView; - using GlobMem_t = GlobMem>; + using GlobStaticHeap_t = GlobStaticHeap>; static const dim_t NumDimensions = PatternT::ndim(); @@ -624,7 +624,7 @@ class HaloBlockView using viewspec_t = typename PatternT::viewspec_type; public: - HaloBlockView(GlobMem_t & globmem, const PatternT & pattern, const viewspec_t & halo_region) + HaloBlockView(GlobStaticHeap_t & globmem, const PatternT & pattern, const viewspec_t & halo_region) : _halo_region(halo_region), _size(_halo_region.size()), _beg(globmem, pattern, halo_region, 0, _size), _end(globmem, pattern, halo_region, _size, _size) @@ -687,7 +687,7 @@ class HaloBlock { private: using self_t = HaloBlock; - using GlobMem_t = GlobMem>; + using GlobStaticHeap_t = GlobStaticHeap>; public: static constexpr dim_t NumDimensions = PatternT::ndim(); @@ -704,7 +704,7 @@ class HaloBlock * Creates a new instance of HaloBlock that extends a given pattern block * by halo semantics. */ - HaloBlock(GlobMem_t & globmem, const PatternT & pattern, const viewspec_t & view, + HaloBlock(GlobStaticHeap_t & globmem, const PatternT & pattern, const viewspec_t & view, const halospec_t & halospec) : _globmem(globmem), _pattern(pattern), _view(view), _halospec(halospec) { @@ -806,7 +806,7 @@ class HaloBlock return _pattern; } - const GlobMem_t & globmem() const + const GlobStaticHeap_t & globmem() const { return _globmem; } @@ -922,7 +922,7 @@ class HaloBlock } private: - GlobMem_t & _globmem; + GlobStaticHeap_t & _globmem; const PatternT & _pattern; diff --git a/dash/include/dash/experimental/HaloMatrix.h b/dash/include/dash/experimental/HaloMatrix.h index 398df12e4..dca2807de 100644 --- a/dash/include/dash/experimental/HaloMatrix.h +++ b/dash/include/dash/experimental/HaloMatrix.h @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include diff --git a/dash/include/dash/experimental/iterator/GlobStencilIter.h b/dash/include/dash/experimental/iterator/GlobStencilIter.h index aa43f77e3..3fb3de244 100644 --- a/dash/include/dash/experimental/iterator/GlobStencilIter.h +++ b/dash/include/dash/experimental/iterator/GlobStencilIter.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include @@ -125,7 +125,7 @@ class IteratorHalo template< typename ElementType, class PatternType, - class GlobMemType = GlobMem, + class GlobStaticHeapType = GlobStaticHeap, class PointerType = GlobPtr, class ReferenceType = GlobRef > class GlobStencilIter @@ -144,7 +144,7 @@ class GlobStencilIter typedef GlobStencilIter< ElementType, PatternType, - GlobMemType, + GlobStaticHeapType, PointerType, ReferenceType> self_t; @@ -191,7 +191,7 @@ class GlobStencilIter protected: /// Global memory used to dereference iterated values. - GlobMemType * _globmem = nullptr; + GlobStaticHeapType * _globmem = nullptr; /// Pattern that specifies the iteration order (access pattern). const PatternType * _pattern = nullptr; /// View that specifies the iterator's index range relative to the global @@ -233,7 +233,7 @@ class GlobStencilIter * the element order specified by the given pattern and view spec. */ GlobStencilIter( - GlobMemType * gmem, + GlobStaticHeapType * gmem, const PatternType & pat, const ViewSpecType & viewspec, const HaloSpecType & halospec, @@ -261,7 +261,7 @@ class GlobStencilIter * the element order specified by the given pattern and view spec. */ GlobStencilIter( - GlobMemType * gmem, + GlobStaticHeapType * gmem, const PatternType & pat, const HaloSpecType & halospec, IndexType position = 0, @@ -315,7 +315,7 @@ class GlobStencilIter GlobStencilIter( const GlobViewIter & other, const HaloSpecType & halospec) @@ -845,23 +845,23 @@ class GlobStencilIter } /** - * The instance of \c GlobMem used by this iterator to resolve addresses + * The instance of \c GlobStaticHeap used by this iterator to resolve addresses * in global memory. * * \see DashGlobalIteratorConcept */ - inline const GlobMemType & globmem() const + inline const GlobStaticHeapType & globmem() const { return *_globmem; } /** - * The instance of \c GlobMem used by this iterator to resolve addresses + * The instance of \c GlobStaticHeap used by this iterator to resolve addresses * in global memory. * * \see DashGlobalIteratorConcept */ - inline GlobMemType & globmem() + inline GlobStaticHeapType & globmem() { return *_globmem; } @@ -1163,15 +1163,15 @@ class GlobStencilIter template < typename ElementType, class Pattern, - class GlobMem, + class GlobStaticHeap, class Pointer, class Reference > auto distance( /// Global iterator to the initial position in the global sequence - const GlobStencilIter & + const GlobStencilIter & first, /// Global iterator to the final position in the global sequence - const GlobStencilIter & + const GlobStencilIter & last ) -> typename Pattern::index_type { @@ -1181,13 +1181,13 @@ auto distance( template < typename ElementType, class Pattern, - class GlobMem, + class GlobStaticHeap, class Pointer, class Reference > std::ostream & operator<<( std::ostream & os, const dash::experimental::GlobStencilIter< - ElementType, Pattern, GlobMem, Pointer, Reference> & it) + ElementType, Pattern, GlobStaticHeap, Pointer, Reference> & it) { std::ostringstream ss; dash::GlobPtr ptr(it); diff --git a/dash/include/dash/experimental/iterator/HaloMatrixIterator.h b/dash/include/dash/experimental/iterator/HaloMatrixIterator.h index 92be78be4..a3eb3139b 100644 --- a/dash/include/dash/experimental/iterator/HaloMatrixIterator.h +++ b/dash/include/dash/experimental/iterator/HaloMatrixIterator.h @@ -43,7 +43,7 @@ class HaloMatrixIterator static constexpr MemArrange MemoryArrange = PatternT::memory_order(); using self_t = HaloMatrixIterator; - using GlobMem_t = GlobMem>; + using GlobStaticHeap_t = GlobStaticHeap>; using HaloBlock_t = HaloBlock; using HaloSpec_t = HaloSpec; using HaloMemory_t = HaloMemory; diff --git a/dash/include/dash/iterator/GlobIter.h b/dash/include/dash/iterator/GlobIter.h index b066636ca..9105fc8b0 100644 --- a/dash/include/dash/iterator/GlobIter.h +++ b/dash/include/dash/iterator/GlobIter.h @@ -16,7 +16,7 @@ namespace dash { template< typename ElementType, class PatternType, - class GlobMemType, + class GlobStaticHeapType, class PointerType, class ReferenceType > class GlobStencilIter; @@ -24,7 +24,7 @@ class GlobStencilIter; template< typename ElementType, class PatternType, - class GlobMemType, + class GlobStaticHeapType, class PointerType, class ReferenceType > class GlobViewIter; @@ -56,10 +56,10 @@ class GlobViewIter; template< typename ElementType, class PatternType, - class GlobMemType = GlobMem< + class GlobStaticHeapType = GlobStaticHeap< typename std::decay::type >, - class PointerType = typename GlobMemType::pointer, + class PointerType = typename GlobStaticHeapType::pointer, class ReferenceType = GlobRef > class GlobIter : public std::iterator< @@ -73,7 +73,7 @@ class GlobIter typedef GlobIter< ElementType, PatternType, - GlobMemType, + GlobStaticHeapType, PointerType, ReferenceType> self_t; @@ -89,8 +89,8 @@ class GlobIter typedef PointerType pointer; typedef typename PointerType::const_type const_pointer; - typedef typename GlobMemType::local_pointer local_pointer; - typedef typename GlobMemType::local_pointer local_type; + typedef typename GlobStaticHeapType::local_pointer local_pointer; + typedef typename GlobStaticHeapType::local_pointer local_type; typedef PatternType pattern_type; typedef typename PatternType::index_type index_type; @@ -99,7 +99,7 @@ class GlobIter typedef GlobIter< const ElementType, PatternType, - GlobMemType, + GlobStaticHeapType, const_pointer, const_reference > self_const_t; @@ -152,7 +152,7 @@ class GlobIter protected: /// Global memory used to dereference iterated values. - GlobMemType * _globmem; + GlobStaticHeapType * _globmem; /// Pattern that specifies the iteration order (access pattern). const PatternType * _pattern; /// Current position of the iterator in global canonical index space. @@ -182,7 +182,7 @@ class GlobIter * the element order specified by the given pattern. */ constexpr GlobIter( - GlobMemType * gmem, + GlobStaticHeapType * gmem, const PatternType & pat, index_type position = 0) : _globmem(gmem), @@ -563,19 +563,19 @@ class GlobIter } /** - * The instance of \c GlobMem used by this iterator to resolve addresses + * The instance of \c GlobStaticHeap used by this iterator to resolve addresses * in global memory. */ - constexpr const GlobMemType & globmem() const noexcept + constexpr const GlobStaticHeapType & globmem() const noexcept { return *_globmem; } /** - * The instance of \c GlobMem used by this iterator to resolve addresses + * The instance of \c GlobStaticHeap used by this iterator to resolve addresses * in global memory. */ - inline GlobMemType & globmem() + inline GlobStaticHeapType & globmem() { return *_globmem; } @@ -720,16 +720,16 @@ class GlobIter template < typename ElementType, class Pattern, - class GlobMem, + class GlobStaticHeap, class Pointer, class Reference > std::ostream & operator<<( std::ostream & os, const dash::GlobIter< - ElementType, Pattern, GlobMem, Pointer, Reference> & it) + ElementType, Pattern, GlobStaticHeap, Pointer, Reference> & it) { std::ostringstream ss; - dash::GlobPtr ptr(*it._globmem, + dash::GlobPtr ptr(*it._globmem, it.dart_gptr()); ss << "dash::GlobIter<" << typeid(ElementType).name() << ">(" << "idx:" << it._idx << ", " diff --git a/dash/include/dash/iterator/GlobStencilIter.h b/dash/include/dash/iterator/GlobStencilIter.h index 4ea3ce41c..06f3aa4c4 100644 --- a/dash/include/dash/iterator/GlobStencilIter.h +++ b/dash/include/dash/iterator/GlobStencilIter.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include @@ -121,7 +121,7 @@ class IteratorHalo template< typename ElementType, class PatternType, - class GlobMemType = GlobMem, + class GlobStaticHeapType = GlobStaticHeap, class PointerType = GlobPtr, class ReferenceType = GlobRef > class GlobStencilIter @@ -140,7 +140,7 @@ class GlobStencilIter typedef GlobStencilIter< ElementType, PatternType, - GlobMemType, + GlobStaticHeapType, PointerType, ReferenceType> self_t; @@ -187,7 +187,7 @@ class GlobStencilIter protected: /// Global memory used to dereference iterated values. - GlobMemType * _globmem = nullptr; + GlobStaticHeapType * _globmem = nullptr; /// Pattern that specifies the iteration order (access pattern). const PatternType * _pattern = nullptr; /// View that specifies the iterator's index range relative to the global @@ -229,7 +229,7 @@ class GlobStencilIter * the element order specified by the given pattern and view spec. */ GlobStencilIter( - GlobMemType * gmem, + GlobStaticHeapType * gmem, const PatternType & pat, const ViewSpecType & viewspec, const HaloSpecType & halospec, @@ -257,7 +257,7 @@ class GlobStencilIter * the element order specified by the given pattern and view spec. */ GlobStencilIter( - GlobMemType * gmem, + GlobStaticHeapType * gmem, const PatternType & pat, const HaloSpecType & halospec, IndexType position = 0, @@ -311,7 +311,7 @@ class GlobStencilIter GlobStencilIter( const GlobViewIter & other, const HaloSpecType & halospec) @@ -841,23 +841,23 @@ class GlobStencilIter } /** - * The instance of \c GlobMem used by this iterator to resolve addresses + * The instance of \c GlobStaticHeap used by this iterator to resolve addresses * in global memory. * * \see DashGlobalIteratorConcept */ - inline const GlobMemType & globmem() const + inline const GlobStaticHeapType & globmem() const { return *_globmem; } /** - * The instance of \c GlobMem used by this iterator to resolve addresses + * The instance of \c GlobStaticHeap used by this iterator to resolve addresses * in global memory. * * \see DashGlobalIteratorConcept */ - inline GlobMemType & globmem() + inline GlobStaticHeapType & globmem() { return *_globmem; } @@ -1159,15 +1159,15 @@ class GlobStencilIter template < typename ElementType, class Pattern, - class GlobMem, + class GlobStaticHeap, class Pointer, class Reference > auto distance( /// Global iterator to the initial position in the global sequence - const GlobStencilIter & + const GlobStencilIter & first, /// Global iterator to the final position in the global sequence - const GlobStencilIter & + const GlobStencilIter & last ) -> typename Pattern::index_type { @@ -1177,13 +1177,13 @@ auto distance( template < typename ElementType, class Pattern, - class GlobMem, + class GlobStaticHeap, class Pointer, class Reference > std::ostream & operator<<( std::ostream & os, const dash::GlobStencilIter< - ElementType, Pattern, GlobMem, Pointer, Reference> & it) + ElementType, Pattern, GlobStaticHeap, Pointer, Reference> & it) { std::ostringstream ss; dash::GlobPtr ptr(it); diff --git a/dash/include/dash/iterator/GlobViewIter.h b/dash/include/dash/iterator/GlobViewIter.h index 89ca3f95d..429f6006f 100644 --- a/dash/include/dash/iterator/GlobViewIter.h +++ b/dash/include/dash/iterator/GlobViewIter.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include @@ -21,7 +21,7 @@ namespace dash { template< typename ElementType, class PatternType, - class GlobMemType, + class GlobStaticHeapType, class PointerType, class ReferenceType > class GlobIter; @@ -29,7 +29,7 @@ class GlobIter; template< typename ElementType, class PatternType, - class GlobMemType, + class GlobStaticHeapType, class PointerType, class ReferenceType > class GlobStencilIter; @@ -43,10 +43,10 @@ class GlobStencilIter; template< typename ElementType, class PatternType, - class GlobMemType = GlobMem< + class GlobStaticHeapType = GlobStaticHeap< typename std::decay::type >, - class PointerType = typename GlobMemType::pointer, + class PointerType = typename GlobStaticHeapType::pointer, class ReferenceType = GlobRef > class GlobViewIter : public std::iterator< @@ -59,7 +59,7 @@ class GlobViewIter typedef GlobViewIter< ElementType, PatternType, - GlobMemType, + GlobStaticHeapType, PointerType, ReferenceType> self_t; @@ -67,7 +67,7 @@ class GlobViewIter typedef GlobIter< ElementType, PatternType, - GlobMemType, + GlobStaticHeapType, PointerType, ReferenceType> global_type; @@ -75,7 +75,7 @@ class GlobViewIter typedef GlobIter< const ElementType, PatternType, - GlobMemType, + GlobStaticHeapType, PointerType, ReferenceType> const_global_type; @@ -97,8 +97,8 @@ class GlobViewIter typedef PointerType pointer; typedef typename PointerType::const_type const_pointer; - typedef typename GlobMemType::local_pointer local_pointer; - typedef typename GlobMemType::local_pointer local_type; + typedef typename GlobStaticHeapType::local_pointer local_pointer; + typedef typename GlobStaticHeapType::local_pointer local_type; typedef PatternType pattern_type; typedef typename PatternType::index_type index_type; @@ -107,7 +107,7 @@ class GlobViewIter typedef GlobViewIter< const ElementType, PatternType, - GlobMemType, + GlobStaticHeapType, const_pointer, const_reference > self_const_t; @@ -158,7 +158,7 @@ class GlobViewIter protected: /// Global memory used to dereference iterated values. - GlobMemType * _globmem; + GlobStaticHeapType * _globmem; /// Pattern that specifies the iteration order (access pattern). const PatternType * _pattern; /// View that specifies the iterator's index range relative to the global @@ -194,14 +194,14 @@ class GlobViewIter * Constructor, creates a global iterator on global memory following * the element order specified by the given pattern and view spec. */ - template + template constexpr GlobViewIter( - GlobMemT_ * gmem, + GlobStaticHeapT_ * gmem, const PatternType & pat, const ViewSpecType & viewspec, IndexType position = 0, IndexType view_index_offset = 0) - : _globmem(reinterpret_cast(gmem)) + : _globmem(reinterpret_cast(gmem)) , _pattern(&pat) , _viewspec(&viewspec) , _idx(position) @@ -215,13 +215,13 @@ class GlobViewIter * Constructor, creates a global iterator on global memory following * the element order specified by the given pattern and view spec. */ - template + template constexpr GlobViewIter( - GlobMemT_ * gmem, + GlobStaticHeapT_ * gmem, const PatternType & pat, IndexType position = 0, IndexType view_index_offset = 0) - : _globmem(reinterpret_cast(gmem)) + : _globmem(reinterpret_cast(gmem)) , _pattern(&pat) , _viewspec(nullptr) , _idx(position) @@ -749,19 +749,19 @@ class GlobViewIter } /** - * The instance of \c GlobMem used by this iterator to resolve addresses + * The instance of \c GlobStaticHeap used by this iterator to resolve addresses * in global memory. */ - constexpr const GlobMemType & globmem() const noexcept + constexpr const GlobStaticHeapType & globmem() const noexcept { return *_globmem; } /** - * The instance of \c GlobMem used by this iterator to resolve addresses + * The instance of \c GlobStaticHeap used by this iterator to resolve addresses * in global memory. */ - inline GlobMemType & globmem() noexcept + inline GlobStaticHeapType & globmem() noexcept { return *_globmem; } @@ -1065,14 +1065,14 @@ class GlobViewIter template< typename ElementType, class Pattern, - class GlobMem, + class GlobStaticHeap, class Pointer, class Reference > auto distance( - const GlobViewIter & + const GlobViewIter & first, /// Global iterator to the final position in the global sequence - const GlobViewIter & + const GlobViewIter & last) -> typename Pattern::index_type { @@ -1082,16 +1082,16 @@ auto distance( template < typename ElementType, class Pattern, - class GlobMem, + class GlobStaticHeap, class Pointer, class Reference > std::ostream & operator<<( std::ostream & os, const dash::GlobViewIter< - ElementType, Pattern, GlobMem, Pointer, Reference> & it) + ElementType, Pattern, GlobStaticHeap, Pointer, Reference> & it) { std::ostringstream ss; - dash::GlobPtr ptr(it); + dash::GlobPtr ptr(it); ss << "dash::GlobViewIter<" << typeid(ElementType).name() << ">(" << "idx:" << it._idx << ", " << "gptr:" << ptr << ")"; diff --git a/dash/include/dash/list/GlobListIter.h b/dash/include/dash/list/GlobListIter.h index 8575cc035..c2f493ef0 100644 --- a/dash/include/dash/list/GlobListIter.h +++ b/dash/include/dash/list/GlobListIter.h @@ -19,7 +19,7 @@ namespace dash { */ template< typename ElementType, - class GlobMemType, + class GlobStaticHeapType, class PointerType = GlobPtr, class ReferenceType = GlobRef > class GlobListIter @@ -33,7 +33,7 @@ class GlobListIter private: typedef GlobListIter< ElementType, - GlobMemType, + GlobStaticHeapType, PointerType, ReferenceType> self_t; @@ -45,7 +45,7 @@ class GlobListIter typedef PointerType pointer; typedef const PointerType const_pointer; - typedef typename GlobMemType::local_pointer local_pointer; + typedef typename GlobStaticHeapType::local_pointer local_pointer; typedef internal::ListNode node_type; @@ -62,7 +62,7 @@ class GlobListIter * Constructor, creates a global iterator on a \c dash::List instance. */ GlobListIter( - GlobMemType * gmem, + GlobStaticHeapType * gmem, node_type & node) : _globmem(gmem), _node(&node), @@ -136,19 +136,19 @@ class GlobListIter } /** - * The instance of \c GlobMem used by this iterator to resolve addresses + * The instance of \c GlobStaticHeap used by this iterator to resolve addresses * in global memory. */ - inline const GlobMemType & globmem() const + inline const GlobStaticHeapType & globmem() const { return *_globmem; } /** - * The instance of \c GlobMem used by this iterator to resolve addresses + * The instance of \c GlobStaticHeap used by this iterator to resolve addresses * in global memory. */ - inline GlobMemType & globmem() + inline GlobStaticHeapType & globmem() { return *_globmem; } @@ -219,7 +219,7 @@ class GlobListIter private: /// Global memory used to dereference iterated values. - GlobMemType * _globmem; + GlobStaticHeapType * _globmem; /// The node element referenced at the iterator's position. node_type * _node = nullptr; /// Unit id of the active unit diff --git a/dash/include/dash/list/ListRef.h b/dash/include/dash/list/ListRef.h index 6d256d98a..a7b1d56e7 100644 --- a/dash/include/dash/list/ListRef.h +++ b/dash/include/dash/list/ListRef.h @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include @@ -64,7 +64,7 @@ class ListRef ListNode_t; typedef typename allocator_type::template rebind::other node_allocator_type; - typedef dash::GlobDynamicMem + typedef dash::GlobHeap glob_mem_type; /// Public types as required by STL list concept: diff --git a/dash/include/dash/list/LocalListRef.h b/dash/include/dash/list/LocalListRef.h index 6adf0bc71..1e6054d1d 100644 --- a/dash/include/dash/list/LocalListRef.h +++ b/dash/include/dash/list/LocalListRef.h @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include diff --git a/dash/include/dash/map/UnorderedMap.h b/dash/include/dash/map/UnorderedMap.h index 4b4dae851..95f5ac1d7 100644 --- a/dash/include/dash/map/UnorderedMap.h +++ b/dash/include/dash/map/UnorderedMap.h @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include @@ -111,7 +111,7 @@ class UnorderedMap typedef UnorderedMapLocalRef local_type; - typedef dash::GlobDynamicMem glob_mem_type; + typedef dash::GlobHeap glob_mem_type; typedef typename glob_mem_type::reference reference; typedef typename glob_mem_type::const_reference const_reference; diff --git a/dash/include/dash/matrix/internal/Matrix-inl.h b/dash/include/dash/matrix/internal/Matrix-inl.h index 5878003c2..e2d6c10e0 100644 --- a/dash/include/dash/matrix/internal/Matrix-inl.h +++ b/dash/include/dash/matrix/internal/Matrix-inl.h @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include #include @@ -153,7 +153,7 @@ ::allocate( DASH_LOG_TRACE_VAR("Matrix.allocate", _lcapacity); // Allocate and initialize memory // use _lcapacity as tje collective allocator requires symmetric allocations - _glob_mem = new GlobMem_t(_lcapacity, _pattern.team()); + _glob_mem = new GlobStaticHeap_t(_lcapacity, _pattern.team()); _begin = iterator(_glob_mem, _pattern); _lbegin = _glob_mem->lbegin(); _lend = _lbegin + _lsize; diff --git a/dash/include/libdash.h b/dash/include/libdash.h index f0fe6993b..58a122bda 100644 --- a/dash/include/libdash.h +++ b/dash/include/libdash.h @@ -27,7 +27,7 @@ namespace dash { #include #include -#include +#include #include #include #include diff --git a/dash/test/dart/ThreadsafetyTest.cc b/dash/test/dart/ThreadsafetyTest.cc index d9469b03b..b71e2bf58 100644 --- a/dash/test/dart/ThreadsafetyTest.cc +++ b/dash/test/dart/ThreadsafetyTest.cc @@ -220,7 +220,7 @@ TEST_F(ThreadsafetyTest, ConcurrentAttach) { TEST_F(ThreadsafetyTest, ConcurrentMemAlloc) { using elem_t = int; - using pointer_t = dash::GlobPtr< elem_t, dash::GlobUnitMem >; + using pointer_t = dash::GlobPtr< elem_t, dash::GlobUnitHeap >; if (!dash::is_multithreaded()) { SKIP_TEST_MSG("requires support for multi-threading"); diff --git a/dash/test/memory/GlobDynamicMemTest.h b/dash/test/memory/GlobDynamicMemTest.h deleted file mode 100644 index eb6b981e2..000000000 --- a/dash/test/memory/GlobDynamicMemTest.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef DASH__TEST__GLOB_DYNAMIC_MEM_TEST_H_ -#define DASH__TEST__GLOB_DYNAMIC_MEM_TEST_H_ - -#include "../TestBase.h" - -/** - * Test fixture for class dash::GlobDynamicMem - */ -class GlobDynamicMemTest : public dash::test::TestBase { -protected: - size_t _dash_id; - size_t _dash_size; - - GlobDynamicMemTest() - : _dash_id(0), - _dash_size(0) - { - LOG_MESSAGE(">>> Test suite: GlobDynamicMemTest"); - } - - virtual ~GlobDynamicMemTest() { - LOG_MESSAGE("<<< Closing test suite: GlobDynamicMemTest"); - } -}; - -#endif // DASH__TEST__GLOB_DYNAMIC_MEM_TEST_H_ diff --git a/dash/test/memory/GlobDynamicMemTest.cc b/dash/test/memory/GlobHeapTest.cc similarity index 83% rename from dash/test/memory/GlobDynamicMemTest.cc rename to dash/test/memory/GlobHeapTest.cc index 264cd3921..613b8dcf9 100644 --- a/dash/test/memory/GlobDynamicMemTest.cc +++ b/dash/test/memory/GlobHeapTest.cc @@ -1,10 +1,10 @@ -#include "GlobDynamicMemTest.h" +#include "GlobHeapTest.h" -#include +#include -TEST_F(GlobDynamicMemTest, BalancedAlloc) +TEST_F(GlobHeapTest, BalancedAlloc) { typedef int value_t; @@ -12,11 +12,11 @@ TEST_F(GlobDynamicMemTest, BalancedAlloc) SKIP_TEST_MSG("Test case requires at least two units"); } - LOG_MESSAGE("initializing GlobDynamicMem"); + LOG_MESSAGE("initializing GlobHeap"); size_t initial_local_capacity = 10; size_t initial_global_capacity = dash::size() * initial_local_capacity; - dash::GlobDynamicMem gdmem(initial_local_capacity); + dash::GlobHeap gdmem(initial_local_capacity); LOG_MESSAGE("initial global capacity: %ld, initial local capacity: %ld", initial_global_capacity, initial_local_capacity); @@ -26,9 +26,9 @@ TEST_F(GlobDynamicMemTest, BalancedAlloc) gdmem.lbegin()); EXPECT_EQ_U(initial_global_capacity, gdmem.size()); - DASH_LOG_TRACE("GlobDynamicMemTest.BalancedAlloc", "initial local:", + DASH_LOG_TRACE("GlobHeapTest.BalancedAlloc", "initial local:", gdmem.local_size()); - DASH_LOG_TRACE("GlobDynamicMemTest.BalancedAlloc", "initial global:", + DASH_LOG_TRACE("GlobHeapTest.BalancedAlloc", "initial global:", gdmem.size()); // Wait for validation of initial capacity at all units: dash::barrier(); @@ -50,18 +50,18 @@ TEST_F(GlobDynamicMemTest, BalancedAlloc) gdmem.lbegin()); EXPECT_EQ_U(precommit_global_capacity, gdmem.size()); - DASH_LOG_TRACE("GlobDynamicMemTest.BalancedAlloc", "pre-commit local:", + DASH_LOG_TRACE("GlobHeapTest.BalancedAlloc", "pre-commit local:", gdmem.local_size()); - DASH_LOG_TRACE("GlobDynamicMemTest.BalancedAlloc", "pre-commit global:", + DASH_LOG_TRACE("GlobHeapTest.BalancedAlloc", "pre-commit global:", gdmem.size()); // Wait for validation of changes of local capacity at all units: dash::barrier(); gdmem.commit(); - DASH_LOG_TRACE("GlobDynamicMemTest.BalancedAlloc", "post-commit local:", + DASH_LOG_TRACE("GlobHeapTest.BalancedAlloc", "post-commit local:", gdmem.local_size()); - DASH_LOG_TRACE("GlobDynamicMemTest.BalancedAlloc", "post-commit global:", + DASH_LOG_TRACE("GlobHeapTest.BalancedAlloc", "post-commit global:", gdmem.size()); size_t postcommit_local_capacity = precommit_local_capacity; size_t postcommit_global_capacity = dash::size() * @@ -72,7 +72,7 @@ TEST_F(GlobDynamicMemTest, BalancedAlloc) EXPECT_EQ_U(postcommit_global_capacity, gdmem.size()); } -TEST_F(GlobDynamicMemTest, UnbalancedRealloc) +TEST_F(GlobHeapTest, UnbalancedRealloc) { typedef int value_t; @@ -80,11 +80,11 @@ TEST_F(GlobDynamicMemTest, UnbalancedRealloc) SKIP_TEST_MSG("Test case requires at least two units"); } - LOG_MESSAGE("initializing GlobDynamicMem"); + LOG_MESSAGE("initializing GlobHeap"); size_t initial_local_capacity = 10; size_t initial_global_capacity = dash::size() * initial_local_capacity; - dash::GlobDynamicMem gdmem(initial_local_capacity); + dash::GlobHeap gdmem(initial_local_capacity); LOG_MESSAGE("initial global capacity: %ld, initial local capacity: %ld", initial_global_capacity, initial_local_capacity); @@ -104,7 +104,7 @@ TEST_F(GlobDynamicMemTest, UnbalancedRealloc) unit_1_lsize_diff + (dash::size() - 2) * unit_x_lsize_diff; - DASH_LOG_TRACE("GlobDynamicMemTest.UnbalancedRealloc", + DASH_LOG_TRACE("GlobHeapTest.UnbalancedRealloc", "begin local reallocation"); // Extend local size, changes should be locally visible immediately: if (dash::myid() == 0) { @@ -147,7 +147,7 @@ TEST_F(GlobDynamicMemTest, UnbalancedRealloc) gdmem.local_size()); } dash::barrier(); - DASH_LOG_TRACE("GlobDynamicMemTest.UnbalancedRealloc", + DASH_LOG_TRACE("GlobHeapTest.UnbalancedRealloc", "size checks after commit completed"); // Initialize values in reallocated memory: @@ -155,28 +155,28 @@ TEST_F(GlobDynamicMemTest, UnbalancedRealloc) auto lcap = gdmem.local_size(); for (size_t li = 0; li < lcap; ++li) { auto value = 1000 * (dash::myid() + 1) + li; - DASH_LOG_TRACE("GlobDynamicMemTest.UnbalancedRealloc", + DASH_LOG_TRACE("GlobHeapTest.UnbalancedRealloc", "setting local offset", li, "at unit", dash::myid(), "value:", value); lmem[li] = value; } dash::barrier(); - DASH_LOG_TRACE("GlobDynamicMemTest.UnbalancedRealloc", + DASH_LOG_TRACE("GlobHeapTest.UnbalancedRealloc", "initialization of local values completed"); if (dash::myid() == 0) { - DASH_LOG_TRACE("GlobDynamicMemTest.UnbalancedRealloc", + DASH_LOG_TRACE("GlobHeapTest.UnbalancedRealloc", "testing basic iterator arithmetic"); - DASH_LOG_TRACE("GlobDynamicMemTest.UnbalancedRealloc", "git_first"); + DASH_LOG_TRACE("GlobHeapTest.UnbalancedRealloc", "git_first"); auto git_first = gdmem.begin(); - DASH_LOG_TRACE("GlobDynamicMemTest.UnbalancedRealloc", "git_second"); + DASH_LOG_TRACE("GlobHeapTest.UnbalancedRealloc", "git_second"); auto git_second = git_first + 1; - DASH_LOG_TRACE("GlobDynamicMemTest.UnbalancedRealloc", "git_remote"); + DASH_LOG_TRACE("GlobHeapTest.UnbalancedRealloc", "git_remote"); auto git_remote = git_first + gdmem.local_size() + 1; - DASH_LOG_TRACE("GlobDynamicMemTest.UnbalancedRealloc", "git_last"); + DASH_LOG_TRACE("GlobHeapTest.UnbalancedRealloc", "git_last"); auto git_last = git_first + gdmem.size() - 1; - DASH_LOG_TRACE("GlobDynamicMemTest.UnbalancedRealloc", "git_end"); + DASH_LOG_TRACE("GlobHeapTest.UnbalancedRealloc", "git_end"); auto git_end = git_first + gdmem.size(); dash__unused(git_second); @@ -185,7 +185,7 @@ TEST_F(GlobDynamicMemTest, UnbalancedRealloc) dash__unused(git_end); } dash::barrier(); - DASH_LOG_TRACE("GlobDynamicMemTest.UnbalancedRealloc", + DASH_LOG_TRACE("GlobHeapTest.UnbalancedRealloc", "testing basic iterator arithmetic completed"); // Test memory space of units separately: @@ -202,7 +202,7 @@ TEST_F(GlobDynamicMemTest, UnbalancedRealloc) } else { exp_l_capacity += unit_x_lsize_diff; } - DASH_LOG_TRACE("GlobDynamicMemTest.UnbalancedRealloc", + DASH_LOG_TRACE("GlobHeapTest.UnbalancedRealloc", "remote unit:", unit, "expected local size:", exp_l_capacity, "gdm.local_size(unit):", gdmem.local_size(unit), @@ -211,23 +211,23 @@ TEST_F(GlobDynamicMemTest, UnbalancedRealloc) EXPECT_EQ_U(exp_l_capacity, unit_git_end - unit_git_begin); int l_idx = 0; for(auto it = unit_git_begin; it != unit_git_end; ++it, ++l_idx) { - DASH_LOG_TRACE("GlobDynamicMemTest.UnbalancedRealloc", + DASH_LOG_TRACE("GlobHeapTest.UnbalancedRealloc", "requesting element at", "local offset", l_idx, "from unit", unit); auto gptr = it.dart_gptr(); - DASH_LOG_TRACE_VAR("GlobDynamicMemTest.UnbalancedRealloc", gptr); + DASH_LOG_TRACE_VAR("GlobHeapTest.UnbalancedRealloc", gptr); // request value via DART global pointer: value_t dart_gptr_value; dart_storage_t ds = dash::dart_storage(1); dart_get_blocking(&dart_gptr_value, gptr, ds.nelem, ds.dtype); - DASH_LOG_TRACE_VAR("GlobDynamicMemTest.UnbalancedRealloc", + DASH_LOG_TRACE_VAR("GlobHeapTest.UnbalancedRealloc", dart_gptr_value); // request value via DASH global iterator: value_t git_value = *it; - DASH_LOG_TRACE_VAR("GlobDynamicMemTest.UnbalancedRealloc", + DASH_LOG_TRACE_VAR("GlobHeapTest.UnbalancedRealloc", git_value); value_t expected = 1000 * (unit + 1) + l_idx; @@ -238,7 +238,7 @@ TEST_F(GlobDynamicMemTest, UnbalancedRealloc) } dash::barrier(); - DASH_LOG_TRACE("GlobDynamicMemTest.UnbalancedRealloc", + DASH_LOG_TRACE("GlobHeapTest.UnbalancedRealloc", "testing reverse iteration"); // Test memory space of all units by iterating global index space: @@ -248,15 +248,15 @@ TEST_F(GlobDynamicMemTest, UnbalancedRealloc) auto rgend = gdmem.rend(); EXPECT_EQ_U(gdmem.size(), gdmem.rend() - gdmem.rbegin()); for (auto rgit = gdmem.rbegin(); rgit != rgend; ++rgit) { - DASH_LOG_TRACE("GlobDynamicMemTest.UnbalancedRealloc", + DASH_LOG_TRACE("GlobHeapTest.UnbalancedRealloc", "requesting element at", "local offset", local_offset, "from unit", unit); value_t expected = 1000 * (unit + 1) + local_offset; value_t rgit_value = *rgit; - DASH_LOG_TRACE_VAR("GlobDynamicMemTest.UnbalancedRealloc", rgit_value); + DASH_LOG_TRACE_VAR("GlobHeapTest.UnbalancedRealloc", rgit_value); value_t git_value = *gdmem.at(unit, local_offset); - DASH_LOG_TRACE_VAR("GlobDynamicMemTest.UnbalancedRealloc", git_value); + DASH_LOG_TRACE_VAR("GlobHeapTest.UnbalancedRealloc", git_value); EXPECT_EQ_U(expected, rgit_value); EXPECT_EQ_U(expected, git_value); @@ -267,11 +267,11 @@ TEST_F(GlobDynamicMemTest, UnbalancedRealloc) --local_offset; } - DASH_LOG_TRACE("GlobDynamicMemTest.UnbalancedRealloc", + DASH_LOG_TRACE("GlobHeapTest.UnbalancedRealloc", "testing reverse iteration completed"); } -TEST_F(GlobDynamicMemTest, LocalVisibility) +TEST_F(GlobHeapTest, LocalVisibility) { typedef int value_t; @@ -279,11 +279,11 @@ TEST_F(GlobDynamicMemTest, LocalVisibility) SKIP_TEST_MSG("Test case requires at least two units"); } - LOG_MESSAGE("initializing GlobDynamicMem"); + LOG_MESSAGE("initializing GlobHeap"); size_t initial_local_capacity = 10; size_t initial_global_capacity = dash::size() * initial_local_capacity; - dash::GlobDynamicMem gdmem(initial_local_capacity); + dash::GlobHeap gdmem(initial_local_capacity); LOG_MESSAGE("initial global capacity: %ld, initial local capacity: %ld", initial_global_capacity, initial_local_capacity); @@ -356,10 +356,10 @@ TEST_F(GlobDynamicMemTest, LocalVisibility) } dash::barrier(); - DASH_LOG_TRACE("GlobDynamicMemTest.LocalVisibility", + DASH_LOG_TRACE("GlobHeapTest.LocalVisibility", "tests of visible memory size before commit passed"); - DASH_LOG_TRACE("GlobDynamicMemTest.LocalVisibility", + DASH_LOG_TRACE("GlobHeapTest.LocalVisibility", "testing local capacities after grow/shrink"); auto local_size = gdmem.lend() - gdmem.lbegin(); EXPECT_EQ_U(local_size, gdmem.local_size()); @@ -376,33 +376,33 @@ TEST_F(GlobDynamicMemTest, LocalVisibility) auto lbegin = gdmem.lbegin(); for (size_t li = 0; li < gdmem.local_size(); ++li) { value_t value = 100 * (dash::myid() + 1) + li; - DASH_LOG_TRACE("GlobDynamicMemTest.LocalVisibility", + DASH_LOG_TRACE("GlobHeapTest.LocalVisibility", "local[", li, "] =", value); *(lbegin + li) = value; } dash::barrier(); - DASH_LOG_TRACE("GlobDynamicMemTest.LocalVisibility", + DASH_LOG_TRACE("GlobHeapTest.LocalVisibility", "tests of local capacities after grow/shrink passed"); // Memory marked for deallocation is still accessible by other units: - DASH_LOG_TRACE("GlobDynamicMemTest.LocalVisibility", + DASH_LOG_TRACE("GlobHeapTest.LocalVisibility", "committing global memory"); - DASH_LOG_TRACE("GlobDynamicMemTest.LocalVisibility", + DASH_LOG_TRACE("GlobHeapTest.LocalVisibility", "local capacity before commit:", gdmem.local_size()); - DASH_LOG_TRACE("GlobDynamicMemTest.LocalVisibility", + DASH_LOG_TRACE("GlobHeapTest.LocalVisibility", "global capacity before commit:", gdmem.size()); // Collectively commit changes of local memory allocation to global // memory space: // register newly allocated local memory and remove local memory marked // for deallocation. gdmem.commit(); - DASH_LOG_TRACE("GlobDynamicMemTest.LocalVisibility", "commit completed"); + DASH_LOG_TRACE("GlobHeapTest.LocalVisibility", "commit completed"); - DASH_LOG_TRACE("GlobDynamicMemTest.LocalVisibility", + DASH_LOG_TRACE("GlobHeapTest.LocalVisibility", "local capacity after commit:", gdmem.local_size()); - DASH_LOG_TRACE("GlobDynamicMemTest.LocalVisibility", + DASH_LOG_TRACE("GlobHeapTest.LocalVisibility", "global capacity after commit:", gdmem.size()); // Changes are globally visible now: @@ -411,15 +411,15 @@ TEST_F(GlobDynamicMemTest, LocalVisibility) EXPECT_EQ_U(expected_global_capacity, gdmem.size()); if (dash::myid() == 0) { - DASH_LOG_TRACE("GlobDynamicMemTest.LocalVisibility", "grow(30)"); + DASH_LOG_TRACE("GlobHeapTest.LocalVisibility", "grow(30)"); LOG_MESSAGE("grow(30)"); gdmem.grow(30); } if (dash::myid() == 1) { - DASH_LOG_TRACE("GlobDynamicMemTest.LocalVisibility", "grow(30)"); + DASH_LOG_TRACE("GlobHeapTest.LocalVisibility", "grow(30)"); gdmem.grow(30); } - DASH_LOG_TRACE("GlobDynamicMemTest.LocalVisibility", + DASH_LOG_TRACE("GlobHeapTest.LocalVisibility", "commit, balanced attach"); gdmem.commit(); // Capacity changes have been published globally: @@ -428,15 +428,15 @@ TEST_F(GlobDynamicMemTest, LocalVisibility) if (dash::myid() == 0) { // resizes attached bucket: - DASH_LOG_TRACE("GlobDynamicMemTest.LocalVisibility", "shrink(29)"); + DASH_LOG_TRACE("GlobHeapTest.LocalVisibility", "shrink(29)"); gdmem.shrink(29); } if (dash::myid() == 1) { // marks bucket for detach: - DASH_LOG_TRACE("GlobDynamicMemTest.LocalVisibility", "shrink(30)"); + DASH_LOG_TRACE("GlobHeapTest.LocalVisibility", "shrink(30)"); gdmem.shrink(30); } - DASH_LOG_TRACE("GlobDynamicMemTest.LocalVisibility", + DASH_LOG_TRACE("GlobHeapTest.LocalVisibility", "commit, unbalanced detach"); gdmem.commit(); // Capacity changes have been published globally: @@ -444,7 +444,7 @@ TEST_F(GlobDynamicMemTest, LocalVisibility) EXPECT_EQ(expected_global_capacity, gdmem.size()); } -TEST_F(GlobDynamicMemTest, RemoteAccess) +TEST_F(GlobHeapTest, RemoteAccess) { typedef int value_t; @@ -492,7 +492,7 @@ TEST_F(GlobDynamicMemTest, RemoteAccess) */ size_t initial_local_capacity = 10; size_t initial_global_capacity = dash::size() * initial_local_capacity; - dash::GlobDynamicMem gdmem(initial_local_capacity); + dash::GlobHeap gdmem(initial_local_capacity); int unit_0_num_grow = 5; int unit_1_num_shrink = 2; @@ -506,11 +506,11 @@ TEST_F(GlobDynamicMemTest, RemoteAccess) // Initialize values in local memory: auto lbegin = gdmem.lbegin(); - DASH_LOG_TRACE("GlobDynamicMemTest.RemoteAccess", + DASH_LOG_TRACE("GlobHeapTest.RemoteAccess", "globmem.lbegin():", lbegin); for (size_t li = 0; li < gdmem.local_size(); ++li) { value_t value = (100 * (dash::myid() + 1)) + li; - DASH_LOG_TRACE("GlobDynamicMemTest.RemoteAccess", + DASH_LOG_TRACE("GlobHeapTest.RemoteAccess", "local[", li, "] =", value); *(lbegin + li) = value; } @@ -529,7 +529,7 @@ TEST_F(GlobDynamicMemTest, RemoteAccess) size_t nlocal_elem = gdmem.local_size(u); EXPECT_EQ_U(nlocal_expect, nlocal_elem); - DASH_LOG_DEBUG("GlobDynamicMemTest.RemoteAccess", + DASH_LOG_DEBUG("GlobHeapTest.RemoteAccess", "requesting element from unit", u, "before commit,", "local capacity:", nlocal_elem); for (size_t lidx = 0; lidx < nlocal_elem; ++lidx) { @@ -562,7 +562,7 @@ TEST_F(GlobDynamicMemTest, RemoteAccess) if (u == 1) { nlocal_expect -= unit_1_num_shrink; } EXPECT_EQ_U(nlocal_expect, nlocal_elem); - DASH_LOG_DEBUG("GlobDynamicMemTest.RemoteAccess", + DASH_LOG_DEBUG("GlobHeapTest.RemoteAccess", "requesting element from unit", u, "after commit,", "local capacity:", nlocal_elem); for (size_t lidx = 0; lidx < nlocal_elem; ++lidx) { diff --git a/dash/test/memory/GlobHeapTest.h b/dash/test/memory/GlobHeapTest.h new file mode 100644 index 000000000..a77746faa --- /dev/null +++ b/dash/test/memory/GlobHeapTest.h @@ -0,0 +1,26 @@ +#ifndef DASH__TEST__GLOB_HEAP_TEST_H__INCLUDED +#define DASH__TEST__GLOB_HEAP_TEST_H__INCLUDED + +#include "../TestBase.h" + +/** + * Test fixture for class dash::GlobHeap + */ +class GlobHeapTest : public dash::test::TestBase { +protected: + size_t _dash_id; + size_t _dash_size; + + GlobHeapTest() + : _dash_id(0), + _dash_size(0) + { + LOG_MESSAGE(">>> Test suite: GlobHeapTest"); + } + + virtual ~GlobHeapTest() { + LOG_MESSAGE("<<< Closing test suite: GlobHeapTest"); + } +}; + +#endif // DASH__TEST__GLOB_HEAP_TEST_H__INCLUDED diff --git a/dash/test/memory/GlobMemTest.h b/dash/test/memory/GlobMemTest.h deleted file mode 100644 index bb6fb7d46..000000000 --- a/dash/test/memory/GlobMemTest.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef DASH__TEST__GLOBMEM_TEST_H_ -#define DASH__TEST__GLOBMEM_TEST_H_ - -#include "../TestBase.h" - -/** - * Test fixture for class dash::GlobMem - */ -class GlobMemTest : public dash::test::TestBase { -protected: - - GlobMemTest() { - LOG_MESSAGE(">>> Test suite: GlobMemTest"); - } - - virtual ~GlobMemTest() { - LOG_MESSAGE("<<< Closing test suite: GlobMemTest"); - } -}; - -#endif // DASH__TEST__GLOBMEM_TEST_H_ diff --git a/dash/test/memory/GlobMemTest.cc b/dash/test/memory/GlobStaticHeapTest.cc similarity index 72% rename from dash/test/memory/GlobMemTest.cc rename to dash/test/memory/GlobStaticHeapTest.cc index 0df6cd723..48de1501c 100644 --- a/dash/test/memory/GlobMemTest.cc +++ b/dash/test/memory/GlobStaticHeapTest.cc @@ -1,15 +1,15 @@ -#include "GlobMemTest.h" +#include "GlobStaticHeapTest.h" -#include +#include #include #include -TEST_F(GlobMemTest, ConstructorInitializerList) +TEST_F(GlobStaticHeapTest, ConstructorInitializerList) { auto target_local_elements = { 1, 2, 3, 4, 5, 6 }; - auto target = dash::GlobMem(target_local_elements); + auto target = dash::GlobStaticHeap(target_local_elements); std::vector glob_values; for (dash::team_unit_t u{0}; u < dash::size(); u++) { @@ -20,7 +20,7 @@ TEST_F(GlobMemTest, ConstructorInitializerList) } } for (auto val : glob_values) { - DASH_LOG_DEBUG_VAR("GlobMemTest.ConstructorInitializerList", val); + DASH_LOG_DEBUG_VAR("GlobStaticHeapTest.ConstructorInitializerList", val); } int target_element; @@ -30,7 +30,7 @@ TEST_F(GlobMemTest, ConstructorInitializerList) } } -TEST_F(GlobMemTest, LocalBegin) +TEST_F(GlobStaticHeapTest, LocalBegin) { auto target_local_elements = { 1, 2, 3, 4 }; @@ -42,7 +42,7 @@ TEST_F(GlobMemTest, LocalBegin) ? dash::Team::All() : dash::Team::All().split(2); - auto target = dash::GlobMem(target_local_elements, sub_team); + auto target = dash::GlobStaticHeap(target_local_elements, sub_team); for (int l = 0; l < target_local_elements.size(); l++) { EXPECT_EQ_U(*(target_local_elements.begin() + l), target.lbegin()[l]); diff --git a/dash/test/memory/GlobStaticHeapTest.h b/dash/test/memory/GlobStaticHeapTest.h new file mode 100644 index 000000000..fd7ffb73e --- /dev/null +++ b/dash/test/memory/GlobStaticHeapTest.h @@ -0,0 +1,21 @@ +#ifndef DASH__TEST__GLOBMEM_TEST_H_ +#define DASH__TEST__GLOBMEM_TEST_H_ + +#include "../TestBase.h" + +/** + * Test fixture for class dash::GlobStaticHeap + */ +class GlobStaticHeapTest : public dash::test::TestBase { +protected: + + GlobStaticHeapTest() { + LOG_MESSAGE(">>> Test suite: GlobStaticHeapTest"); + } + + virtual ~GlobStaticHeapTest() { + LOG_MESSAGE("<<< Closing test suite: GlobStaticHeapTest"); + } +}; + +#endif // DASH__TEST__GLOBMEM_TEST_H_ From 9bbec00e2b63701ec914a0abc7d2028922d344b9 Mon Sep 17 00:00:00 2001 From: Tobias Fuchs Date: Sat, 18 Mar 2017 20:06:53 +0100 Subject: [PATCH 09/12] Renamed global allocator types --- dash/include/dash/Allocator.h | 4 +- dash/include/dash/Array.h | 8 +- dash/include/dash/GlobAsyncRef.h | 26 +-- .../dash/{GlobHeap.h => GlobHeapMem.h} | 212 +++++++++--------- dash/include/dash/GlobPtr.h | 8 +- dash/include/dash/GlobRef.h | 4 +- dash/include/dash/GlobSharedRef.h | 4 +- .../{GlobStaticHeap.h => GlobStaticMem.h} | 66 +++--- dash/include/dash/Halo.h | 30 +-- dash/include/dash/Iterator.h | 6 +- dash/include/dash/List.h | 66 +++--- dash/include/dash/Matrix.h | 8 +- dash/include/dash/Shared.h | 10 +- dash/include/dash/UnorderedMap.h | 6 +- ...locator.h => EpochSynchronizedAllocator.h} | 86 +++---- dash/include/dash/allocator/GlobBucketIter.h | 40 ++-- dash/include/dash/allocator/LocalBucketIter.h | 2 +- ...ectiveAllocator.h => SymmetricAllocator.h} | 54 ++--- .../dash/allocator/internal/GlobBucketIter.h | 46 ++-- .../{GlobHeapTypes.h => GlobHeapMemTypes.h} | 0 dash/include/dash/experimental/Halo.h | 24 +- dash/include/dash/experimental/HaloMatrix.h | 2 +- .../experimental/iterator/GlobStencilIter.h | 32 +-- .../iterator/HaloMatrixIterator.h | 2 +- dash/include/dash/iterator/GlobIter.h | 34 +-- dash/include/dash/iterator/GlobStencilIter.h | 32 +-- dash/include/dash/iterator/GlobViewIter.h | 56 ++--- dash/include/dash/list/GlobListIter.h | 18 +- dash/include/dash/list/ListRef.h | 4 +- dash/include/dash/list/LocalListRef.h | 2 +- dash/include/dash/map/UnorderedMap.h | 6 +- .../include/dash/matrix/internal/Matrix-inl.h | 4 +- dash/include/libdash.h | 2 +- dash/test/dart/ThreadsafetyTest.cc | 4 +- .../{GlobHeapTest.cc => GlobHeapMemTest.cc} | 120 +++++----- .../{GlobHeapTest.h => GlobHeapMemTest.h} | 12 +- dash/test/memory/GlobStaticHeapTest.h | 21 -- ...StaticHeapTest.cc => GlobStaticMemTest.cc} | 14 +- dash/test/memory/GlobStaticMemTest.h | 21 ++ dash/test/memory/LocalAllocatorTest.h | 2 +- ...catorTest.cc => SymmetricAllocatorTest.cc} | 20 +- ...locatorTest.h => SymmetricAllocatorTest.h} | 4 +- 42 files changed, 561 insertions(+), 561 deletions(-) rename dash/include/dash/{GlobHeap.h => GlobHeapMem.h} (88%) rename dash/include/dash/{GlobStaticHeap.h => GlobStaticMem.h} (89%) rename dash/include/dash/allocator/{DynamicAllocator.h => EpochSynchronizedAllocator.h} (77%) rename dash/include/dash/allocator/{CollectiveAllocator.h => SymmetricAllocator.h} (81%) rename dash/include/dash/allocator/internal/{GlobHeapTypes.h => GlobHeapMemTypes.h} (100%) rename dash/test/memory/{GlobHeapTest.cc => GlobHeapMemTest.cc} (84%) rename dash/test/memory/{GlobHeapTest.h => GlobHeapMemTest.h} (51%) delete mode 100644 dash/test/memory/GlobStaticHeapTest.h rename dash/test/memory/{GlobStaticHeapTest.cc => GlobStaticMemTest.cc} (72%) create mode 100644 dash/test/memory/GlobStaticMemTest.h rename dash/test/memory/{CollectiveAllocatorTest.cc => SymmetricAllocatorTest.cc} (77%) rename dash/test/memory/{CollectiveAllocatorTest.h => SymmetricAllocatorTest.h} (75%) diff --git a/dash/include/dash/Allocator.h b/dash/include/dash/Allocator.h index d136c0ef7..01b024f0f 100644 --- a/dash/include/dash/Allocator.h +++ b/dash/include/dash/Allocator.h @@ -2,8 +2,8 @@ #define DASH__ALLOCATOR_H__INCLUDED #include -#include -#include +#include +#include namespace dash { diff --git a/dash/include/dash/Array.h b/dash/include/dash/Array.h index 0d58a8503..608430b57 100644 --- a/dash/include/dash/Array.h +++ b/dash/include/dash/Array.h @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include @@ -621,7 +621,7 @@ class ArrayRef * \concept{DashArrayConcept} * * \todo Add template parameter: - * class GlobStaticHeapType = dash::GlobStaticHeap + * class GlobStaticMemType = dash::GlobStaticMem * * \note: Template parameter IndexType could be deduced from pattern * type PatternT::index_type @@ -662,7 +662,7 @@ class Array typedef GlobIter< value_type, PatternType> pointer; typedef GlobIter const_pointer; - typedef dash::GlobStaticHeap glob_mem_type; + typedef dash::GlobStaticMem glob_mem_type; public: template< @@ -929,7 +929,7 @@ class Array } /** - * The instance of \c GlobStaticHeap used by this iterator to resolve addresses + * The instance of \c GlobStaticMem used by this iterator to resolve addresses * in global memory. */ constexpr const glob_mem_type & globmem() const noexcept diff --git a/dash/include/dash/GlobAsyncRef.h b/dash/include/dash/GlobAsyncRef.h index 855045a5a..90e10dfab 100644 --- a/dash/include/dash/GlobAsyncRef.h +++ b/dash/include/dash/GlobAsyncRef.h @@ -3,7 +3,7 @@ #include #include -#include +#include #include @@ -47,12 +47,12 @@ class GlobAsyncRef private: typedef GlobAsyncRef self_t; - typedef GlobStaticHeap > - GlobStaticHeap_t; + typedef GlobStaticMem > + GlobStaticMem_t; private: - /// Instance of GlobStaticHeap that issued this global reference - GlobStaticHeap_t * _globmem; + /// Instance of GlobStaticMem that issued this global reference + GlobStaticMem_t * _globmem; /// Value of the referenced element, initially not loaded mutable T _value; /// Pointer to referenced element in global memory @@ -72,8 +72,8 @@ class GlobAsyncRef * global memory. */ GlobAsyncRef( - /// Instance of GlobStaticHeap that issued this global reference - GlobStaticHeap_t * globmem, + /// Instance of GlobStaticMem that issued this global reference + GlobStaticMem_t * globmem, /// Pointer to referenced object in global memory T * lptr) : _value(*lptr), @@ -101,8 +101,8 @@ class GlobAsyncRef */ template GlobAsyncRef( - /// Instance of GlobStaticHeap that issued this global reference - GlobStaticHeap_t * globmem, + /// Instance of GlobStaticMem that issued this global reference + GlobStaticMem_t * globmem, /// Pointer to referenced object in global memory GlobPtr & gptr) : _gptr(gptr.dart_gptr()) @@ -138,8 +138,8 @@ class GlobAsyncRef * global memory. */ GlobAsyncRef( - /// Instance of GlobStaticHeap that issued this global reference - GlobStaticHeap_t * globmem, + /// Instance of GlobStaticMem that issued this global reference + GlobStaticMem_t * globmem, /// Pointer to referenced object in global memory dart_gptr_t dart_gptr) : _gptr(dart_gptr) @@ -176,8 +176,8 @@ class GlobAsyncRef * global memory. */ GlobAsyncRef( - /// Instance of GlobStaticHeap that issued this global reference - GlobStaticHeap_t * globmem, + /// Instance of GlobStaticMem that issued this global reference + GlobStaticMem_t * globmem, /// Pointer to referenced object in global memory GlobRef & gref) : GlobAsyncRef(globmem, gref.gptr()) diff --git a/dash/include/dash/GlobHeap.h b/dash/include/dash/GlobHeapMem.h similarity index 88% rename from dash/include/dash/GlobHeap.h rename to dash/include/dash/GlobHeapMem.h index 0a29064d3..3caf9303c 100644 --- a/dash/include/dash/GlobHeap.h +++ b/dash/include/dash/GlobHeapMem.h @@ -16,7 +16,7 @@ #include #include -#include +#include #include @@ -103,7 +103,7 @@ namespace dash { /** * Global memory region with dynamic size. * - * Conventional global memory (see \c dash::GlobStaticHeap) allocates a single + * Conventional global memory (see \c dash::GlobStaticMem) allocates a single * contiguous range of fixed size in local memory at every unit. * Iterating static memory space is trivial as native pointer arithmetics * can be used to traverse elements in canonical storage order. @@ -119,7 +119,7 @@ namespace dash { * * \code * size_t initial_local_capacity = 1024; - * GlobHeap gdmem(initial_local_capacity); + * GlobHeapMem gdmem(initial_local_capacity); * * size_t initial_global_capacity = dash::size() * initial_local_capacity; * @@ -193,11 +193,11 @@ template< /// Type of allocator implementation used to allocate and deallocate /// global memory class AllocatorType = - dash::allocator::DynamicAllocator > -class GlobHeap + dash::allocator::EpochSynchronizedAllocator > +class GlobHeapMem { private: - typedef GlobHeap + typedef GlobHeapMem self_t; public: @@ -315,7 +315,7 @@ class GlobHeap * \concept{DashDynamicMemorySpaceConcept} * \concept{DashMemorySpaceConcept} */ - explicit GlobHeap( + explicit GlobHeapMem( /// Initial number of local elements to allocate in global memory space size_type n_local_elem = 0, /// Team containing all units operating on the global memory region @@ -332,35 +332,35 @@ class GlobHeap _num_detach_buckets(team.size(), team), _remote_size(0) { - DASH_LOG_TRACE("GlobHeap.(ninit,nunits)", + DASH_LOG_TRACE("GlobHeapMem.(ninit,nunits)", n_local_elem, team.size()); _local_sizes.local[0] = 0; _num_attach_buckets.local[0] = 0; _num_detach_buckets.local[0] = 0; - DASH_LOG_TRACE("GlobHeap.GlobHeap", + DASH_LOG_TRACE("GlobHeapMem.GlobHeapMem", "allocating initial memory space"); grow(n_local_elem); commit(); - DASH_LOG_TRACE("GlobHeap.GlobHeap >"); + DASH_LOG_TRACE("GlobHeapMem.GlobHeapMem >"); } /** * Destructor, collectively frees underlying global memory. */ - ~GlobHeap() + ~GlobHeapMem() { - DASH_LOG_TRACE("GlobHeap.~GlobHeap()"); + DASH_LOG_TRACE("GlobHeapMem.~GlobHeapMem()"); } - GlobHeap() = delete; + GlobHeapMem() = delete; /** * Copy constructor. */ - GlobHeap(const self_t & other) = default; + GlobHeapMem(const self_t & other) = default; /** * Assignment operator. @@ -413,9 +413,9 @@ class GlobHeap */ inline size_type local_size(team_unit_t unit) const { - DASH_LOG_TRACE("GlobHeap.local_size(u)", "unit:", unit); + DASH_LOG_TRACE("GlobHeapMem.local_size(u)", "unit:", unit); DASH_ASSERT_RANGE(0, unit, _nunits-1, "unit id out of range"); - DASH_LOG_TRACE_VAR("GlobHeap.local_size", + DASH_LOG_TRACE_VAR("GlobHeapMem.local_size", _bucket_cumul_sizes[unit]); size_type unit_local_size; if (unit == _myid) { @@ -425,7 +425,7 @@ class GlobHeap } else { unit_local_size = _bucket_cumul_sizes[unit].back(); } - DASH_LOG_TRACE("GlobHeap.local_size >", unit_local_size); + DASH_LOG_TRACE("GlobHeapMem.local_size >", unit_local_size); return unit_local_size; } @@ -457,12 +457,12 @@ class GlobHeap */ local_iterator grow(size_type num_elements) { - DASH_LOG_DEBUG_VAR("GlobHeap.grow()", num_elements); + DASH_LOG_DEBUG_VAR("GlobHeapMem.grow()", num_elements); size_type local_size_old = _local_sizes.local[0]; - DASH_LOG_TRACE("GlobHeap.grow", + DASH_LOG_TRACE("GlobHeapMem.grow", "current local size:", local_size_old); if (num_elements == 0) { - DASH_LOG_DEBUG("GlobHeap.grow >", "no grow"); + DASH_LOG_DEBUG("GlobHeapMem.grow >", "no grow"); return _lend; } // Update size of local memory space: @@ -471,7 +471,7 @@ class GlobHeap _num_attach_buckets.local[0] += 1; // Create new unattached bucket: - DASH_LOG_TRACE("GlobHeap.grow", "creating new unattached bucket:", + DASH_LOG_TRACE("GlobHeapMem.grow", "creating new unattached bucket:", "size:", num_elements); bucket_type bucket; bucket.size = num_elements; @@ -486,7 +486,7 @@ class GlobHeap std::advance(_attach_buckets_first, _buckets.size() - 1); } _bucket_cumul_sizes[_myid].push_back(_local_sizes.local[0]); - DASH_LOG_TRACE("GlobHeap.grow", "added unattached bucket:", + DASH_LOG_TRACE("GlobHeapMem.grow", "added unattached bucket:", "size:", bucket.size, "lptr:", bucket.lptr); // Update local iteration space: @@ -494,12 +494,12 @@ class GlobHeap update_lend(); DASH_ASSERT_EQ(_local_sizes.local[0], _lend - _lbegin, "local size differs from local iteration space size"); - DASH_LOG_TRACE("GlobHeap.grow", + DASH_LOG_TRACE("GlobHeapMem.grow", "new local size:", _local_sizes.local[0]); - DASH_LOG_TRACE("GlobHeap.grow", + DASH_LOG_TRACE("GlobHeapMem.grow", "local buckets:", _buckets.size(), "unattached buckets:", _num_attach_buckets.local[0]); - DASH_LOG_TRACE("GlobHeap.grow >"); + DASH_LOG_TRACE("GlobHeapMem.grow >"); // Return local iterator to start of allocated memory: return _lbegin + local_size_old; } @@ -555,22 +555,22 @@ class GlobHeap // - the remote unit's current local size (including unattached buckets) // - the number of the remote unit's unattached buckets and their size - DASH_LOG_DEBUG_VAR("GlobHeap.shrink()", num_elements); + DASH_LOG_DEBUG_VAR("GlobHeapMem.shrink()", num_elements); DASH_ASSERT_LT(num_elements, local_size() + 1, "cannot shrink size " << local_size() << " " "by " << num_elements << " elements"); if (num_elements == 0) { - DASH_LOG_DEBUG("GlobHeap.shrink >", "no shrink"); + DASH_LOG_DEBUG("GlobHeapMem.shrink >", "no shrink"); return; } - DASH_LOG_TRACE("GlobHeap.shrink", + DASH_LOG_TRACE("GlobHeapMem.shrink", "current local size:", _local_sizes.local[0]); - DASH_LOG_TRACE("GlobHeap.shrink", + DASH_LOG_TRACE("GlobHeapMem.shrink", "current local buckets:", _buckets.size()); // Position of iterator to first unattached bucket: auto attach_buckets_first_pos = std::distance(_buckets.begin(), _attach_buckets_first); - DASH_LOG_TRACE_VAR("GlobHeap.shrink", attach_buckets_first_pos); + DASH_LOG_TRACE_VAR("GlobHeapMem.shrink", attach_buckets_first_pos); // Number of elements left to deallocate: auto num_dealloc = num_elements; // Try to reduce local capacity by deallocating un-attached local buckets @@ -581,7 +581,7 @@ class GlobHeap bucket_type & bucket_last = _buckets.back(); // Shrink / remove unattached buckets starting at newest bucket: if (bucket_last.size <= num_dealloc) { - DASH_LOG_TRACE("GlobHeap.shrink", "remove unattached bucket:", + DASH_LOG_TRACE("GlobHeapMem.shrink", "remove unattached bucket:", "size:", bucket_last.size); // Mark entire bucket for deallocation below: num_dealloc -= bucket_last.size; @@ -593,7 +593,7 @@ class GlobHeap if (attach_buckets_first_it != _buckets.end() && ++attach_buckets_first_it == _buckets.end()) { // Iterator to first unattached bucket references last bucket: - DASH_LOG_TRACE("GlobHeap.shrink", + DASH_LOG_TRACE("GlobHeapMem.shrink", "updating iterator to first unattached bucket"); _attach_buckets_first--; } @@ -610,7 +610,7 @@ class GlobHeap _num_attach_buckets.local[0] -= 1; } else if (bucket_last.size > num_dealloc) { // TODO: Clarify if shrinking unattached buckets is allowed - DASH_LOG_TRACE("GlobHeap.shrink", "shrink unattached bucket:", + DASH_LOG_TRACE("GlobHeapMem.shrink", "shrink unattached bucket:", "old size:", bucket_last.size, "new size:", bucket_last.size - num_dealloc); bucket_last.size -= num_dealloc; @@ -640,7 +640,7 @@ class GlobHeap _bucket_cumul_sizes[_myid].back() -= bucket_it->size; num_dealloc -= bucket_it->size; } else if (bucket_it->size > num_dealloc) { - DASH_LOG_TRACE("GlobHeap.shrink", "shrink attached bucket:", + DASH_LOG_TRACE("GlobHeapMem.shrink", "shrink attached bucket:", "old size:", bucket_it->size, "new size:", bucket_it->size - num_dealloc); bucket_it->size -= num_dealloc; @@ -651,10 +651,10 @@ class GlobHeap } // Mark attached buckets for deallocation. // Requires separate loop as iterators on _buckets could be invalidated. - DASH_LOG_DEBUG_VAR("GlobHeap.shrink", num_dealloc_gbuckets); + DASH_LOG_DEBUG_VAR("GlobHeapMem.shrink", num_dealloc_gbuckets); while (num_dealloc_gbuckets-- > 0) { auto dealloc_bucket = _buckets.back(); - DASH_LOG_TRACE("GlobHeap.shrink", "deallocate attached bucket:" + DASH_LOG_TRACE("GlobHeapMem.shrink", "deallocate attached bucket:" "size:", dealloc_bucket.size, "lptr:", dealloc_bucket.lptr); // Mark bucket to be detached in next call of commit(): @@ -666,18 +666,18 @@ class GlobHeap update_lbegin(); update_lend(); - DASH_LOG_TRACE("GlobHeap.shrink", + DASH_LOG_TRACE("GlobHeapMem.shrink", "cumulative bucket sizes:", _bucket_cumul_sizes[_myid]); - DASH_LOG_TRACE("GlobHeap.shrink", + DASH_LOG_TRACE("GlobHeapMem.shrink", "new local size:", _local_sizes.local[0], "new iteration space size:", std::distance( _lbegin, _lend)); - DASH_LOG_TRACE("GlobHeap.shrink", + DASH_LOG_TRACE("GlobHeapMem.shrink", "total number of buckets:", _buckets.size(), "unattached buckets:", std::distance( _attach_buckets_first, _buckets.end())); - DASH_LOG_DEBUG("GlobHeap.shrink >"); + DASH_LOG_DEBUG("GlobHeapMem.shrink >"); } /** @@ -698,8 +698,8 @@ class GlobHeap */ void commit() { - DASH_LOG_DEBUG("GlobHeap.commit()"); - DASH_LOG_TRACE_VAR("GlobHeap.commit", _buckets.size()); + DASH_LOG_DEBUG("GlobHeapMem.commit()"); + DASH_LOG_TRACE_VAR("GlobHeapMem.commit", _buckets.size()); // First detach, then attach to minimize number of elements allocated // at the same time: @@ -708,17 +708,17 @@ class GlobHeap if (num_detached_elem > 0 || num_attached_elem > 0) { // Update _begin iterator: - DASH_LOG_TRACE("GlobHeap.commit", "updating _begin"); + DASH_LOG_TRACE("GlobHeapMem.commit", "updating _begin"); _begin = global_iterator(this, 0); - DASH_LOG_TRACE("GlobHeap.commit", "updating _end"); + DASH_LOG_TRACE("GlobHeapMem.commit", "updating _end"); _end = _begin + size(); } // Update local iterators as bucket iterators might have changed: - DASH_LOG_TRACE("GlobHeap.commit", "updating _lbegin"); + DASH_LOG_TRACE("GlobHeapMem.commit", "updating _lbegin"); update_lbegin(); - DASH_LOG_TRACE("GlobHeap.commit", "updating _lend"); + DASH_LOG_TRACE("GlobHeapMem.commit", "updating _lend"); update_lend(); - DASH_LOG_DEBUG("GlobHeap.commit >", "finished"); + DASH_LOG_DEBUG("GlobHeapMem.commit >", "finished"); } /** @@ -742,14 +742,14 @@ class GlobHeap */ void resize(size_type num_elements) { - DASH_LOG_DEBUG("GlobHeap.resize()", "new size:", num_elements); + DASH_LOG_DEBUG("GlobHeapMem.resize()", "new size:", num_elements); index_type diff_capacity = num_elements - size(); if (diff_capacity > 0) { grow(diff_capacity); } else if (diff_capacity < 0) { shrink(-diff_capacity); } - DASH_LOG_DEBUG("GlobHeap.resize >"); + DASH_LOG_DEBUG("GlobHeapMem.resize >"); } /** @@ -818,7 +818,7 @@ class GlobHeap /** * Native pointer of the initial address of the local memory of - * the unit that initialized this GlobHeap instance. + * the unit that initialized this GlobHeapMem instance. */ inline local_iterator & lbegin() noexcept { @@ -827,7 +827,7 @@ class GlobHeap /** * Native pointer of the initial address of the local memory of - * the unit that initialized this GlobHeap instance. + * the unit that initialized this GlobHeapMem instance. */ inline const_local_iterator lbegin() const noexcept { @@ -836,7 +836,7 @@ class GlobHeap /** * Native pointer of the initial address of the local memory of - * the unit that initialized this GlobHeap instance. + * the unit that initialized this GlobHeapMem instance. */ inline local_iterator & lend() noexcept { @@ -845,7 +845,7 @@ class GlobHeap /** * Native pointer of the initial address of the local memory of - * the unit that initialized this GlobHeap instance. + * the unit that initialized this GlobHeapMem instance. */ inline const_local_iterator & lend() const noexcept { @@ -862,7 +862,7 @@ class GlobHeap const ValueType & newval, index_type global_index) { - DASH_LOG_TRACE("GlobHeap.put_value(newval, gidx = %d)", + DASH_LOG_TRACE("GlobHeapMem.put_value(newval, gidx = %d)", global_index); auto git = const_global_iterator(this, global_index); dash::put_value(newval, git); @@ -878,7 +878,7 @@ class GlobHeap ValueType * ptr, index_type global_index) const { - DASH_LOG_TRACE("GlobHeap.get_value(newval, gidx = %d)", + DASH_LOG_TRACE("GlobHeapMem.get_value(newval, gidx = %d)", global_index); auto git = const_global_iterator(this, global_index); dash::get_value(ptr, git); @@ -908,13 +908,13 @@ class GlobHeap /// The unit's local address offset IndexT local_index) { - DASH_LOG_DEBUG("GlobHeap.at()", + DASH_LOG_DEBUG("GlobHeapMem.at()", "unit:", unit, "lidx:", local_index); if (_nunits == 0) { DASH_THROW(dash::exception::RuntimeError, "No units in team"); } global_iterator git(this, unit, local_index); - DASH_LOG_DEBUG_VAR("GlobHeap.at >", git); + DASH_LOG_DEBUG_VAR("GlobHeapMem.at >", git); return git; } @@ -929,14 +929,14 @@ class GlobHeap /// The unit's local address offset IndexT local_index) const { - DASH_LOG_DEBUG("GlobHeap.at() const", + DASH_LOG_DEBUG("GlobHeapMem.at() const", "unit:", unit, "lidx:", local_index); if (_nunits == 0) { DASH_THROW(dash::exception::RuntimeError, "No units in team"); } // TODO const_global_iterator git(this, unit, local_index); - DASH_LOG_DEBUG_VAR("GlobHeap.at const >", git); + DASH_LOG_DEBUG_VAR("GlobHeapMem.at const >", git); return git; } @@ -954,7 +954,7 @@ class GlobHeap */ void update_lbegin() noexcept { - DASH_LOG_TRACE("GlobHeap.update_lbegin()"); + DASH_LOG_TRACE("GlobHeapMem.update_lbegin()"); local_iterator unit_lbegin( // iteration space _buckets.begin(), _buckets.end(), @@ -963,7 +963,7 @@ class GlobHeap // bucket at position in iteration space, // offset in bucket _buckets.begin(), 0); - DASH_LOG_TRACE("GlobHeap.update_lbegin >", unit_lbegin); + DASH_LOG_TRACE("GlobHeapMem.update_lbegin >", unit_lbegin); _lbegin = unit_lbegin; } @@ -973,7 +973,7 @@ class GlobHeap */ void update_lend() noexcept { - DASH_LOG_TRACE("GlobHeap.update_lend()"); + DASH_LOG_TRACE("GlobHeapMem.update_lend()"); local_iterator unit_lend( // iteration space _buckets.begin(), _buckets.end(), @@ -982,7 +982,7 @@ class GlobHeap // bucket at position in iteration space, // offset in bucket _buckets.end(), 0); - DASH_LOG_TRACE("GlobHeap.update_lend >", unit_lend); + DASH_LOG_TRACE("GlobHeapMem.update_lend >", unit_lend); _lend = unit_lend; } @@ -992,15 +992,15 @@ class GlobHeap */ size_type commit_detach() { - DASH_LOG_TRACE("GlobHeap.commit_detach()"); - DASH_LOG_TRACE("GlobHeap.commit_detach", + DASH_LOG_TRACE("GlobHeapMem.commit_detach()"); + DASH_LOG_TRACE("GlobHeapMem.commit_detach", "local buckets to detach:", _num_detach_buckets.local[0]); // Number of elements successfully deallocated from global memory in // this commit: size_type num_detached_elem = 0; for (auto bucket_it = _detach_buckets.begin(); bucket_it != _detach_buckets.cend(); ++bucket_it) { - DASH_LOG_TRACE("GlobHeap.commit_detach", "detaching bucket:", + DASH_LOG_TRACE("GlobHeapMem.commit_detach", "detaching bucket:", "size:", bucket_it->size, "lptr:", bucket_it->lptr, "gptr:", bucket_it->gptr); @@ -1013,7 +1013,7 @@ class GlobHeap } } _detach_buckets.clear(); - DASH_LOG_TRACE("GlobHeap.commit_detach >", + DASH_LOG_TRACE("GlobHeapMem.commit_detach >", "globally deallocated elements:", num_detached_elem); return num_detached_elem; } @@ -1023,8 +1023,8 @@ class GlobHeap */ size_type commit_attach() { - DASH_LOG_TRACE("GlobHeap.commit_attach()"); - DASH_LOG_TRACE("GlobHeap.commit_attach", + DASH_LOG_TRACE("GlobHeapMem.commit_attach()"); + DASH_LOG_TRACE("GlobHeapMem.commit_attach", "local buckets to attach:", _num_attach_buckets.local[0]); // Unregister buckets marked for detach in global memory: _num_attach_buckets.barrier(); @@ -1033,9 +1033,9 @@ class GlobHeap _num_attach_buckets.end()); auto min_attach_buckets = min_max_attach.first; auto max_attach_buckets = min_max_attach.second; - DASH_LOG_TRACE("GlobHeap.commit_attach", + DASH_LOG_TRACE("GlobHeapMem.commit_attach", "min. attach buckets:", min_attach_buckets); - DASH_LOG_TRACE("GlobHeap.commit_attach", + DASH_LOG_TRACE("GlobHeapMem.commit_attach", "max. attach buckets:", max_attach_buckets); // Number of buckets successfully attached in this commit: size_type num_attached_buckets = 0; @@ -1047,10 +1047,10 @@ class GlobHeap // Whether at least one remote unit needs to attach additional global // memory: bool has_remote_attach = _remote_size > old_remote_size; - DASH_LOG_TRACE_VAR("GlobHeap.commit_attach", old_remote_size); - DASH_LOG_TRACE_VAR("GlobHeap.commit_attach", _remote_size); - DASH_LOG_TRACE_VAR("GlobHeap.commit_attach", size()); - DASH_LOG_TRACE_VAR("GlobHeap.commit_attach", has_remote_attach); + DASH_LOG_TRACE_VAR("GlobHeapMem.commit_attach", old_remote_size); + DASH_LOG_TRACE_VAR("GlobHeapMem.commit_attach", _remote_size); + DASH_LOG_TRACE_VAR("GlobHeapMem.commit_attach", size()); + DASH_LOG_TRACE_VAR("GlobHeapMem.commit_attach", has_remote_attach); // Plausibility check: DASH_ASSERT(!has_remote_attach || max_attach_buckets > 0); @@ -1060,23 +1060,23 @@ class GlobHeap // them locally so a remote unit's local index can be mapped to the // remote unit's bucket. if (min_attach_buckets == 0 && max_attach_buckets == 0) { - DASH_LOG_TRACE("GlobHeap.commit_attach", "no attach"); + DASH_LOG_TRACE("GlobHeapMem.commit_attach", "no attach"); DASH_ASSERT(_attach_buckets_first == _buckets.end()); DASH_ASSERT(_buckets.empty() || _buckets.back().attached); } - DASH_LOG_TRACE("GlobHeap.commit_attach", "attaching", + DASH_LOG_TRACE("GlobHeapMem.commit_attach", "attaching", std::distance(_attach_buckets_first, _buckets.end()), "buckets"); for (; _attach_buckets_first != _buckets.end(); ++_attach_buckets_first) { bucket_type & bucket = *_attach_buckets_first; DASH_ASSERT(!bucket.attached); - DASH_LOG_TRACE("GlobHeap.commit_attach", "attaching bucket"); - DASH_LOG_TRACE_VAR("GlobHeap.commit_attach", bucket.size); - DASH_LOG_TRACE_VAR("GlobHeap.commit_attach", bucket.lptr); + DASH_LOG_TRACE("GlobHeapMem.commit_attach", "attaching bucket"); + DASH_LOG_TRACE_VAR("GlobHeapMem.commit_attach", bucket.size); + DASH_LOG_TRACE_VAR("GlobHeapMem.commit_attach", bucket.lptr); // Attach bucket's local memory segment in global memory: bucket.gptr = _allocator.attach(bucket.lptr, bucket.size); bucket.attached = true; - DASH_LOG_TRACE("GlobHeap.commit_attach", "attached bucket:", + DASH_LOG_TRACE("GlobHeapMem.commit_attach", "attached bucket:", "gptr:", bucket.gptr); num_attached_elem += bucket.size; _num_attach_buckets.local[0] -= 1; @@ -1086,12 +1086,12 @@ class GlobHeap // All units must attach the same number of buckets collectively. // Attach empty buckets if this unit attached less than the maximum // number of buckets attached by any other unit in this commit: - DASH_LOG_TRACE("GlobHeap.commit_attach", + DASH_LOG_TRACE("GlobHeapMem.commit_attach", "local buckets attached:", num_attached_buckets); - DASH_LOG_TRACE("GlobHeap.commit_attach", + DASH_LOG_TRACE("GlobHeapMem.commit_attach", "buckets required to attach:", max_attach_buckets); while (num_attached_buckets < max_attach_buckets) { - DASH_LOG_TRACE("GlobHeap.commit_attach", "attaching null bucket"); + DASH_LOG_TRACE("GlobHeapMem.commit_attach", "attaching null bucket"); bucket_type bucket; bucket.size = 0; bucket.lptr = nullptr; @@ -1100,11 +1100,11 @@ class GlobHeap DASH_ASSERT(!DART_GPTR_ISNULL(bucket.gptr)); _buckets.push_back(bucket); num_attached_buckets++; - DASH_LOG_TRACE("GlobHeap.commit_attach", "attached null bucket:", + DASH_LOG_TRACE("GlobHeapMem.commit_attach", "attached null bucket:", "gptr:", bucket.gptr, "left:", max_attach_buckets - num_attached_buckets); } - DASH_LOG_TRACE("GlobHeap.commit_attach >", + DASH_LOG_TRACE("GlobHeapMem.commit_attach >", "globally allocated elements:", num_attached_elem); return num_attached_elem; } @@ -1118,7 +1118,7 @@ class GlobHeap { // TODO: Unoptimized, use dash::min_max_element once it is available // - DASH_LOG_TRACE("GlobHeap.gather_min_max()"); + DASH_LOG_TRACE("GlobHeapMem.gather_min_max()"); std::vector lcopy(dash::distance(first, last)); auto lcopy_end = dash::copy(first, last, lcopy.data()); auto min_lptr = std::min_element(lcopy.data(), lcopy_end); @@ -1126,7 +1126,7 @@ class GlobHeap std::pair min_max; min_max.first = *min_lptr; min_max.second = *max_lptr; - DASH_LOG_TRACE("GlobHeap.gather_min_max >", + DASH_LOG_TRACE("GlobHeapMem.gather_min_max >", "min:", min_max.first, "max:", min_max.second); return min_max; @@ -1171,7 +1171,7 @@ class GlobHeap // attach_bucket_sizes temporarily attached by u in step 1. // 5. Detach vector attach_bucket_sizes. - DASH_LOG_TRACE("GlobHeap.update_remote_size()"); + DASH_LOG_TRACE("GlobHeapMem.update_remote_size()"); size_type new_remote_size = 0; // Number of unattached buckets of every unit: std::vector num_unattached_buckets(_nunits, 0); @@ -1185,7 +1185,7 @@ class GlobHeap for (auto bit = _attach_buckets_first; bit != _buckets.end(); ++bit) { attach_buckets_sizes.push_back((*bit).size); } - DASH_LOG_TRACE_VAR("GlobHeap.update_remote_size", + DASH_LOG_TRACE_VAR("GlobHeapMem.update_remote_size", attach_buckets_sizes); // Use same allocator type as used for values in global memory: typedef typename allocator_type::template rebind::other @@ -1196,13 +1196,13 @@ class GlobHeap attach_buckets_sizes.size()); _team->barrier(); // Implicit barrier in allocator.attach - DASH_LOG_TRACE_VAR("GlobHeap.update_remote_size", + DASH_LOG_TRACE_VAR("GlobHeapMem.update_remote_size", attach_buckets_sizes_gptr); for (int u = 0; u < _nunits; ++u) { if (u == _myid) { continue; } - DASH_LOG_TRACE("GlobHeap.update_remote_size", + DASH_LOG_TRACE("GlobHeapMem.update_remote_size", "collecting local bucket sizes of unit", u); // Last known local attached capacity of remote unit: auto & u_bucket_cumul_sizes = _bucket_cumul_sizes[u]; @@ -1211,15 +1211,15 @@ class GlobHeap ? 0 : u_bucket_cumul_sizes.back(); size_type u_local_size_new = _local_sizes[u]; - DASH_LOG_TRACE_VAR("GlobHeap.update_remote_size", + DASH_LOG_TRACE_VAR("GlobHeapMem.update_remote_size", u_local_size_old); - DASH_LOG_TRACE_VAR("GlobHeap.update_remote_size", + DASH_LOG_TRACE_VAR("GlobHeapMem.update_remote_size", u_local_size_old); int u_local_size_diff = u_local_size_new - u_local_size_old; new_remote_size += u_local_size_new; // Number of unattached buckets of unit u: size_type u_num_attach_buckets = num_unattached_buckets[u]; - DASH_LOG_TRACE_VAR("GlobHeap.update_remote_size", + DASH_LOG_TRACE_VAR("GlobHeapMem.update_remote_size", u_num_attach_buckets); if (u_num_attach_buckets == 0) { // No unattached buckets at unit u. @@ -1248,7 +1248,7 @@ class GlobHeap for (int bi = 0; bi < u_num_attach_buckets; ++bi) { size_type single_bkt_size = u_attach_buckets_sizes[bi]; size_type cumul_bkt_size = single_bkt_size; - DASH_LOG_TRACE_VAR("GlobHeap.update_remote_size", + DASH_LOG_TRACE_VAR("GlobHeapMem.update_remote_size", single_bkt_size); if (u_bucket_cumul_sizes.size() > 0) { cumul_bkt_size += u_bucket_cumul_sizes.back(); @@ -1267,12 +1267,12 @@ class GlobHeap _team->barrier(); #if DASH_ENABLE_TRACE_LOGGING for (int u = 0; u < _nunits; ++u) { - DASH_LOG_TRACE("GlobHeap.update_remote_size", + DASH_LOG_TRACE("GlobHeapMem.update_remote_size", "unit", u, "cumulative bucket sizes:", _bucket_cumul_sizes[u]); } #endif - DASH_LOG_TRACE("GlobHeap.update_remote_size >", new_remote_size); + DASH_LOG_TRACE("GlobHeapMem.update_remote_size >", new_remote_size); _remote_size = new_remote_size; return _remote_size; } @@ -1288,7 +1288,7 @@ class GlobHeap /// Offset of the referenced address in the bucket's memory space. index_type bucket_phase) const { - DASH_LOG_DEBUG("GlobHeap.dart_gptr_at(u,bi,bp)", + DASH_LOG_DEBUG("GlobHeapMem.dart_gptr_at(u,bi,bp)", unit, bucket_index, bucket_phase); if (_nunits == 0) { DASH_THROW(dash::exception::RuntimeError, "No units in team"); @@ -1297,16 +1297,16 @@ class GlobHeap auto bucket_it = _buckets.begin(); std::advance(bucket_it, bucket_index); auto dart_gptr = bucket_it->gptr; - DASH_LOG_TRACE_VAR("GlobHeap.dart_gptr_at", bucket_it->attached); - DASH_LOG_TRACE_VAR("GlobHeap.dart_gptr_at", bucket_it->gptr); + DASH_LOG_TRACE_VAR("GlobHeapMem.dart_gptr_at", bucket_it->attached); + DASH_LOG_TRACE_VAR("GlobHeapMem.dart_gptr_at", bucket_it->gptr); if (unit == _myid) { - DASH_LOG_TRACE_VAR("GlobHeap.dart_gptr_at", bucket_it->lptr); - DASH_LOG_TRACE_VAR("GlobHeap.dart_gptr_at", bucket_it->size); + DASH_LOG_TRACE_VAR("GlobHeapMem.dart_gptr_at", bucket_it->lptr); + DASH_LOG_TRACE_VAR("GlobHeapMem.dart_gptr_at", bucket_it->size); DASH_ASSERT_LT(bucket_phase, bucket_it->size, "bucket phase out of bounds"); } if (DART_GPTR_ISNULL(dart_gptr)) { - DASH_LOG_TRACE("GlobHeap.dart_gptr_at", + DASH_LOG_TRACE("GlobHeapMem.dart_gptr_at", "bucket.gptr is DART_GPTR_NULL"); dart_gptr = DART_GPTR_NULL; } else { @@ -1320,11 +1320,11 @@ class GlobHeap bucket_phase * sizeof(value_type)), DART_OK); } - DASH_LOG_DEBUG("GlobHeap.dart_gptr_at >", dart_gptr); + DASH_LOG_DEBUG("GlobHeapMem.dart_gptr_at >", dart_gptr); return dart_gptr; } -}; // class GlobHeap +}; // class GlobHeapMem } // namespace dash diff --git a/dash/include/dash/GlobPtr.h b/dash/include/dash/GlobPtr.h index 9e243a5a7..77dad0a6b 100644 --- a/dash/include/dash/GlobPtr.h +++ b/dash/include/dash/GlobPtr.h @@ -32,9 +32,9 @@ namespace dash { // Forward-declarations template class GlobRef; template class GlobStaticHeap; + class AllocT> class GlobStaticMem; template class GlobHeap; + class AllocT> class GlobHeapMem; template class GlobConstPtr; /** @@ -59,9 +59,9 @@ template class GlobConstPtr; */ template< typename ElementType, - class MemorySpace = GlobStaticHeap< + class MemorySpace = GlobStaticMem< typename std::remove_const::type, - dash::allocator::CollectiveAllocator< + dash::allocator::SymmetricAllocator< typename std::remove_const::type > > > diff --git a/dash/include/dash/GlobRef.h b/dash/include/dash/GlobRef.h index 35e468105..92098d569 100644 --- a/dash/include/dash/GlobRef.h +++ b/dash/include/dash/GlobRef.h @@ -1,7 +1,7 @@ #ifndef DASH__GLOBREF_H_ #define DASH__GLOBREF_H_ -#include +#include #include #include @@ -9,7 +9,7 @@ namespace dash { // Forward declarations -template class GlobStaticHeap; +template class GlobStaticMem; template class GlobConstPtr; template class GlobPtr; diff --git a/dash/include/dash/GlobSharedRef.h b/dash/include/dash/GlobSharedRef.h index 9e2b14eb9..39e2259ae 100644 --- a/dash/include/dash/GlobSharedRef.h +++ b/dash/include/dash/GlobSharedRef.h @@ -1,14 +1,14 @@ #ifndef DASH__GLOB_SHARED_EF_H_ #define DASH__GLOB_SHARED_EF_H_ -#include +#include #include #include namespace dash { // Forward declaration -template class GlobStaticHeap; +template class GlobStaticMem; // Forward declaration template class GlobPtr; // Forward declaration diff --git a/dash/include/dash/GlobStaticHeap.h b/dash/include/dash/GlobStaticMem.h similarity index 89% rename from dash/include/dash/GlobStaticHeap.h rename to dash/include/dash/GlobStaticMem.h index eeb87f49a..949f4cce4 100644 --- a/dash/include/dash/GlobStaticHeap.h +++ b/dash/include/dash/GlobStaticMem.h @@ -76,11 +76,11 @@ template< /// Type implementing the DASH allocator concept used to allocate and /// deallocate physical memory class AllocatorType = - dash::allocator::CollectiveAllocator > -class GlobStaticHeap + dash::allocator::SymmetricAllocator > +class GlobStaticMem { private: - typedef GlobStaticHeap + typedef GlobStaticMem self_t; public: @@ -118,10 +118,10 @@ class GlobStaticHeap public: /** - * Constructor, creates instance of GlobStaticHeap with pre-allocated + * Constructor, creates instance of GlobStaticMem with pre-allocated * memory space. */ - GlobStaticHeap( + GlobStaticMem( dart_gptr_t gbegin, /// Number of local elements to allocate in global memory space size_type n_local_elem, @@ -135,13 +135,13 @@ class GlobStaticHeap _myid(team.myid()), _nlelem(n_local_elem) { - DASH_LOG_TRACE("GlobStaticHeap(gbegin,nlocal,team)", + DASH_LOG_TRACE("GlobStaticMem(gbegin,nlocal,team)", "preallocated at:", _begptr, "number of local values:", _nlelem, "team size:", team.size()); update_lbegin(); update_lend(); - DASH_LOG_TRACE("GlobStaticHeap(gbegin,nlocal,team) >"); + DASH_LOG_TRACE("GlobStaticMem(gbegin,nlocal,team) >"); } /** @@ -153,7 +153,7 @@ class GlobStaticHeap * For example, \c dash::LocalAllocator is used in \c dash::Shared * and only called at owner unit. */ - explicit GlobStaticHeap( + explicit GlobStaticMem( /// Number of local elements to allocate in global memory space size_type n_local_elem, /// Team containing all units operating on the global memory region @@ -165,7 +165,7 @@ class GlobStaticHeap _myid(team.myid()), _nlelem(n_local_elem) { - DASH_LOG_TRACE("GlobStaticHeap(nlocal,team)", + DASH_LOG_TRACE("GlobStaticMem(nlocal,team)", "number of local values:", _nlelem, "team size:", team.size()); _begptr = _allocator.allocate(_nlelem); @@ -174,7 +174,7 @@ class GlobStaticHeap // Use id's of team all update_lbegin(); update_lend(); - DASH_LOG_TRACE("GlobStaticHeap(nlocal,team) >"); + DASH_LOG_TRACE("GlobStaticMem(nlocal,team) >"); } /** @@ -186,7 +186,7 @@ class GlobStaticHeap * For example, \c dash::LocalAllocator is used in \c dash::Shared * and only called at owner unit. */ - explicit GlobStaticHeap( + explicit GlobStaticMem( /// Local elements to allocate in global memory space std::initializer_list local_elements, /// Team containing all units operating on the global memory region @@ -198,7 +198,7 @@ class GlobStaticHeap _myid(team.myid()), _nlelem(local_elements.size()) { - DASH_LOG_DEBUG("GlobStaticHeap(lvals,team)", + DASH_LOG_DEBUG("GlobStaticMem(lvals,team)", "number of local values:", _nlelem, "team size:", team.size()); _begptr = _allocator.allocate(_nlelem); @@ -225,28 +225,28 @@ class GlobStaticHeap // // TODO: Should depend on allocator trait // dash::allocator_traits::is_collective() - DASH_LOG_DEBUG("GlobStaticHeap(lvals,team)", "barrier"); + DASH_LOG_DEBUG("GlobStaticMem(lvals,team)", "barrier"); barrier(); } - DASH_LOG_DEBUG("GlobStaticHeap(lvals,team) >", + DASH_LOG_DEBUG("GlobStaticMem(lvals,team) >", "_lbegin:", _lbegin, "_lend:", _lend); } /** * Destructor, collectively frees underlying global memory. */ - ~GlobStaticHeap() + ~GlobStaticMem() { - DASH_LOG_TRACE_VAR("GlobStaticHeap.~GlobStaticHeap()", _begptr); + DASH_LOG_TRACE_VAR("GlobStaticMem.~GlobStaticMem()", _begptr); _allocator.deallocate(_begptr); - DASH_LOG_TRACE("GlobStaticHeap.~GlobStaticHeap >"); + DASH_LOG_TRACE("GlobStaticMem.~GlobStaticMem >"); } /** * Copy constructor. */ - GlobStaticHeap(const self_t & other) + GlobStaticMem(const self_t & other) = default; /** @@ -323,7 +323,7 @@ class GlobStaticHeap /** * Native pointer of the initial address of the local memory of - * the unit that initialized this GlobStaticHeap instance. + * the unit that initialized this GlobStaticMem instance. */ constexpr const_local_pointer lbegin() const noexcept { @@ -332,7 +332,7 @@ class GlobStaticHeap /** * Native pointer of the initial address of the local memory of - * the unit that initialized this GlobStaticHeap instance. + * the unit that initialized this GlobStaticMem instance. */ inline local_pointer lbegin() noexcept { @@ -341,7 +341,7 @@ class GlobStaticHeap /** * Native pointer of the initial address of the local memory of - * the unit that initialized this GlobStaticHeap instance. + * the unit that initialized this GlobStaticMem instance. */ constexpr const_local_pointer lend() const noexcept { @@ -350,7 +350,7 @@ class GlobStaticHeap /** * Native pointer of the initial address of the local memory of - * the unit that initialized this GlobStaticHeap instance. + * the unit that initialized this GlobStaticMem instance. */ inline local_pointer lend() noexcept { @@ -367,7 +367,7 @@ class GlobStaticHeap const ValueType & newval, index_type global_index) { - DASH_LOG_TRACE("GlobStaticHeap.put_value(newval, gidx = %d)", global_index); + DASH_LOG_TRACE("GlobStaticMem.put_value(newval, gidx = %d)", global_index); dash::put_value(newval, GlobPtr( *this, _begptr @@ -384,7 +384,7 @@ class GlobStaticHeap ValueType * ptr, index_type global_index) const { - DASH_LOG_TRACE("GlobStaticHeap.get_value(newval, gidx = %d)", global_index); + DASH_LOG_TRACE("GlobStaticMem.get_value(newval, gidx = %d)", global_index); dash::get_value(ptr, GlobPtr( *this, _begptr @@ -440,27 +440,27 @@ class GlobStaticHeap /// The unit's local address offset IndexType local_index) const { - DASH_LOG_DEBUG("GlobStaticHeap.at(unit,l_idx)", unit, local_index); + DASH_LOG_DEBUG("GlobStaticMem.at(unit,l_idx)", unit, local_index); if (_nunits == 0 || DART_GPTR_ISNULL(_begptr)) { - DASH_LOG_DEBUG("GlobStaticHeap.at(unit,l_idx) >", + DASH_LOG_DEBUG("GlobStaticMem.at(unit,l_idx) >", "global memory not allocated"); return pointer(nullptr); } // Initialize with global pointer to start address: dart_gptr_t gptr = _begptr; // Resolve global unit id - DASH_LOG_TRACE_VAR("GlobStaticHeap.at (=g_begptr)", gptr); - DASH_LOG_TRACE_VAR("GlobStaticHeap.at", gptr.unitid); + DASH_LOG_TRACE_VAR("GlobStaticMem.at (=g_begptr)", gptr); + DASH_LOG_TRACE_VAR("GlobStaticMem.at", gptr.unitid); team_unit_t lunit{gptr.unitid}; - DASH_LOG_TRACE_VAR("GlobStaticHeap.at", lunit); + DASH_LOG_TRACE_VAR("GlobStaticMem.at", lunit); lunit = (lunit + unit) % _nunits; - DASH_LOG_TRACE_VAR("GlobStaticHeap.at", lunit); + DASH_LOG_TRACE_VAR("GlobStaticMem.at", lunit); // Apply global unit to global pointer: dart_gptr_setunit(&gptr, lunit); // Apply local offset to global pointer: pointer res_gptr(*this, gptr); res_gptr += local_index; - DASH_LOG_DEBUG("GlobStaticHeap.at (+g_unit) >", res_gptr); + DASH_LOG_DEBUG("GlobStaticMem.at (+g_unit) >", res_gptr); return res_gptr; } @@ -474,7 +474,7 @@ class GlobStaticHeap { void *addr; dart_gptr_t gptr = _begptr; - DASH_LOG_TRACE_VAR("GlobStaticHeap.update_lbegin", + DASH_LOG_TRACE_VAR("GlobStaticMem.update_lbegin", pointer(*this, gptr)); DASH_ASSERT_RETURNS( dart_gptr_setunit(&gptr, _myid), @@ -482,7 +482,7 @@ class GlobStaticHeap DASH_ASSERT_RETURNS( dart_gptr_getaddr(gptr, &addr), DART_OK); - DASH_LOG_TRACE_VAR("GlobStaticHeap.update_lbegin >", addr); + DASH_LOG_TRACE_VAR("GlobStaticMem.update_lbegin >", addr); _lbegin = static_cast(addr); } diff --git a/dash/include/dash/Halo.h b/dash/include/dash/Halo.h index 60687dfb4..993ea5cd0 100644 --- a/dash/include/dash/Halo.h +++ b/dash/include/dash/Halo.h @@ -2,7 +2,7 @@ #define DASH__HALO_H__ #include -#include +#include #include @@ -249,10 +249,10 @@ class BlockBoundaryIter ReferenceType> self_t; - typedef GlobStaticHeap< + typedef GlobStaticMem< ElementType, - dash::allocator::CollectiveAllocator > - GlobStaticHeap_t; + dash::allocator::SymmetricAllocator > + GlobStaticMem_t; private: static const dim_t NumDimensions = PatternType::ndim(); @@ -699,23 +699,23 @@ class BlockBoundaryIter } /** - * The instance of \c GlobStaticHeap used by this iterator to resolve addresses + * The instance of \c GlobStaticMem used by this iterator to resolve addresses * in global memory. * * \see DashGlobalIteratorConcept */ - inline const GlobStaticHeap_t & globmem() const + inline const GlobStaticMem_t & globmem() const { return *_globmem; } /** - * The instance of \c GlobStaticHeap used by this iterator to resolve addresses + * The instance of \c GlobStaticMem used by this iterator to resolve addresses * in global memory. * * \see DashGlobalIteratorConcept */ - inline GlobStaticHeap_t & globmem() + inline GlobStaticMem_t & globmem() { return *_globmem; } @@ -995,7 +995,7 @@ class BlockBoundaryIter private: /// Global memory used to dereference iterated values. - GlobStaticHeap_t * _globmem = nullptr; + GlobStaticMem_t * _globmem = nullptr; /// View specifying the block region. Iteration space contains the view /// elements within the boundary defined by the halo spec. const viewspec_type * _viewspec = nullptr; @@ -1249,10 +1249,10 @@ class HaloBlock typedef HaloBlock self_t; - typedef GlobStaticHeap< + typedef GlobStaticMem< ElementType, - dash::allocator::CollectiveAllocator > - GlobStaticHeap_t; + dash::allocator::SymmetricAllocator > + GlobStaticMem_t; public: typedef PatternType pattern_type; @@ -1275,7 +1275,7 @@ class HaloBlock */ HaloBlock( /// Global memory used to dereference iterated values. - GlobStaticHeap_t * globmem, + GlobStaticMem_t * globmem, // Pattern that created the encapsulated block. const pattern_type & pattern, // View specifying the inner block region. @@ -1323,7 +1323,7 @@ class HaloBlock /** * Global memory accessor used to dereference iterated values. */ - inline GlobStaticHeap_t & globmem() + inline GlobStaticMem_t & globmem() { return *_globmem; } @@ -1548,7 +1548,7 @@ class HaloBlock private: /// Global memory accessor used to dereference iterated values. - GlobStaticHeap_t * _globmem = nullptr; + GlobStaticMem_t * _globmem = nullptr; /// The pattern that created the encapsulated block. const pattern_type * _pattern = nullptr; diff --git a/dash/include/dash/Iterator.h b/dash/include/dash/Iterator.h index d05f04fa7..0994ba3ef 100644 --- a/dash/include/dash/Iterator.h +++ b/dash/include/dash/Iterator.h @@ -131,16 +131,16 @@ distance( template< typename ElementType, class Pattern, - class GlobStaticHeap, + class GlobStaticMem, class Pointer, class Reference > typename Pattern::index_type distance( /// Global pointer to the initial position in the global sequence - const GlobIter & + const GlobIter & first, /// Global iterator to the final position in the global sequence - const GlobIter & + const GlobIter & last) { return last - first; diff --git a/dash/include/dash/List.h b/dash/include/dash/List.h index 5934cb623..8ddc0f09b 100644 --- a/dash/include/dash/List.h +++ b/dash/include/dash/List.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include @@ -166,7 +166,7 @@ namespace dash { */ template< typename ElementType, - class AllocatorType = dash::allocator::DynamicAllocator > + class AllocatorType = dash::allocator::EpochSynchronizedAllocator > class List { static_assert( @@ -197,7 +197,7 @@ class List internal::ListNode >::other node_allocator_type; - typedef dash::GlobHeap + typedef dash::GlobHeapMem glob_mem_type; typedef dash::Array< @@ -247,6 +247,36 @@ class List /// Local proxy object, allows use in range-based for loops. local_type local; +private: + /// Team containing all units interacting with the list. + dash::Team * _team + = nullptr; + /// DART id of the unit that created the list. + team_unit_t _myid; + /// Global memory allocation and -access. + glob_mem_type * _globmem + = nullptr; + /// Iterator to initial element in the list. + iterator _begin; + /// Iterator past the last element in the list. + iterator _end; + /// Number of elements in the list. + size_type _remote_size + = 0; + /// Native pointer to first local element in the list. + local_iterator _lbegin; + /// Native pointer past the last local element in the list. + local_iterator _lend; + /// Sentinel node in empty list. + node_type _nil_node; + /// Mapping units to their number of local list elements. + local_sizes_map _local_sizes; + /// Capacity of local buffer containing locally added node elements that + /// have not been committed to global memory yet. + /// Default is 4 KB. + size_type _local_buffer_size + = 4096 / sizeof(value_type); + public: /** * Default constructor, for delayed allocation. @@ -671,36 +701,6 @@ class List DASH_LOG_TRACE_VAR("List.deallocate >", this); } -private: - /// Team containing all units interacting with the list. - dash::Team * _team - = nullptr; - /// DART id of the unit that created the list. - team_unit_t _myid; - /// Global memory allocation and -access. - glob_mem_type * _globmem - = nullptr; - /// Iterator to initial element in the list. - iterator _begin; - /// Iterator past the last element in the list. - iterator _end; - /// Number of elements in the list. - size_type _remote_size - = 0; - /// Native pointer to first local element in the list. - local_iterator _lbegin; - /// Native pointer past the last local element in the list. - local_iterator _lend; - /// Sentinel node in empty list. - node_type _nil_node; - /// Mapping units to their number of local list elements. - local_sizes_map _local_sizes; - /// Capacity of local buffer containing locally added node elements that - /// have not been committed to global memory yet. - /// Default is 4 KB. - size_type _local_buffer_size - = 4096 / sizeof(value_type); - }; } // namespace dash diff --git a/dash/include/dash/Matrix.h b/dash/include/dash/Matrix.h index 37149ec96..119e1bad8 100644 --- a/dash/include/dash/Matrix.h +++ b/dash/include/dash/Matrix.h @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include @@ -156,8 +156,8 @@ class Matrix LocalRef_const_t; typedef PatternT Pattern_t; - typedef GlobStaticHeap> - GlobStaticHeap_t; + typedef GlobStaticMem> + GlobStaticMem_t; typedef DistributionSpec DistributionSpec_t; typedef SizeSpec @@ -618,7 +618,7 @@ class Matrix /// The matrix elements' distribution pattern Pattern_t _pattern; /// Global memory allocation and -access - GlobStaticHeap_t * _glob_mem; + GlobStaticMem_t * _glob_mem; /// Native pointer to first local element in the array ElementT * _lbegin; /// Native pointer past last local element in the array diff --git a/dash/include/dash/Shared.h b/dash/include/dash/Shared.h index 84717c7ff..7e3912255 100644 --- a/dash/include/dash/Shared.h +++ b/dash/include/dash/Shared.h @@ -3,7 +3,7 @@ #include -#include +#include #include #include @@ -41,10 +41,10 @@ class Shared { typedef GlobRef> atomic_ref_type; private: - typedef dash::GlobStaticHeap< + typedef dash::GlobStaticMem< value_type, dash::allocator::LocalAllocator > - GlobStaticHeap_t; + GlobStaticMem_t; template friend void swap(Shared & a, Shared & b); @@ -70,7 +70,7 @@ class Shared { if (_team->myid() == _owner) { DASH_LOG_DEBUG("Shared.Shared(team,owner)", "allocating shared value in local memory"); - _globmem = std::make_shared(1, team); + _globmem = std::make_shared(1, team); _ptr = _globmem->begin(); } // Broadcast global pointer of shared value at unit 0 to all units: @@ -187,7 +187,7 @@ class Shared { private: dash::Team * _team = nullptr; team_unit_t _owner; - std::shared_ptr _globmem = nullptr; + std::shared_ptr _globmem = nullptr; pointer _ptr; }; diff --git a/dash/include/dash/UnorderedMap.h b/dash/include/dash/UnorderedMap.h index c0115eeb9..20608a581 100644 --- a/dash/include/dash/UnorderedMap.h +++ b/dash/include/dash/UnorderedMap.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include @@ -135,7 +135,7 @@ template< typename Mapped, typename Hash = dash::HashLocal, typename Pred = std::equal_to, - typename Alloc = dash::allocator::DynamicAllocator< + typename Alloc = dash::allocator::EpochSynchronizedAllocator< std::pair > > class UnorderedMap { @@ -155,7 +155,7 @@ class UnorderedMap typedef typename dash::container_traits::local_type local_type; - typedef dash::GlobHeap glob_mem_type; + typedef dash::GlobHeapMem glob_mem_type; typedef typename glob_mem_type::reference reference; typedef typename glob_mem_type::const_reference const_reference; diff --git a/dash/include/dash/allocator/DynamicAllocator.h b/dash/include/dash/allocator/EpochSynchronizedAllocator.h similarity index 77% rename from dash/include/dash/allocator/DynamicAllocator.h rename to dash/include/dash/allocator/EpochSynchronizedAllocator.h index 93e4ddb80..752a022c2 100644 --- a/dash/include/dash/allocator/DynamicAllocator.h +++ b/dash/include/dash/allocator/EpochSynchronizedAllocator.h @@ -1,5 +1,5 @@ -#ifndef DASH__ALLOCATOR__DYNAMIC_ALLOCATOR_H__INCLUDED -#define DASH__ALLOCATOR__DYNAMIC_ALLOCATOR_H__INCLUDED +#ifndef DASH__ALLOCATOR__EPOCH_SYNCHRONIZED_ALLOCATOR_H__INCLUDED +#define DASH__ALLOCATOR__EPOCH_SYNCHRONIZED_ALLOCATOR_H__INCLUDED #include @@ -28,20 +28,20 @@ namespace allocator { * \concept{DashAllocatorConcept} */ template -class DynamicAllocator +class EpochSynchronizedAllocator { template friend bool operator==( - const DynamicAllocator & lhs, - const DynamicAllocator & rhs); + const EpochSynchronizedAllocator & lhs, + const EpochSynchronizedAllocator & rhs); template friend bool operator!=( - const DynamicAllocator & lhs, - const DynamicAllocator & rhs); + const EpochSynchronizedAllocator & lhs, + const EpochSynchronizedAllocator & rhs); private: - typedef DynamicAllocator self_t; + typedef EpochSynchronizedAllocator self_t; /// Type definitions required for std::allocator concept: public: @@ -60,18 +60,18 @@ class DynamicAllocator typedef const value_type * const_local_pointer; public: - /// Convert DynamicAllocator to DynamicAllocator. + /// Convert EpochSynchronizedAllocator to EpochSynchronizedAllocator. template struct rebind { - typedef DynamicAllocator other; + typedef EpochSynchronizedAllocator other; }; public: /** * Constructor. - * Creates a new instance of \c dash::DynamicAllocator for a given team. + * Creates a new instance of \c dash::EpochSynchronizedAllocator for a given team. */ - DynamicAllocator( + EpochSynchronizedAllocator( Team & team = dash::Team::All()) noexcept : _team(&team), _nunits(team.size()) @@ -81,7 +81,7 @@ class DynamicAllocator * Move-constructor. * Takes ownership of the moved instance's allocation. */ - DynamicAllocator(self_t && other) noexcept + EpochSynchronizedAllocator(self_t && other) noexcept : _team(nullptr) { std::swap(_allocated, other._allocated); @@ -91,7 +91,7 @@ class DynamicAllocator /** * Default constructor, deleted. */ - DynamicAllocator() noexcept + EpochSynchronizedAllocator() noexcept = delete; /** @@ -101,7 +101,7 @@ class DynamicAllocator * * \see DashAllocatorConcept */ - DynamicAllocator(const self_t & other) noexcept + EpochSynchronizedAllocator(const self_t & other) noexcept : _team(other._team), _nunits(other._nunits) { } @@ -111,7 +111,7 @@ class DynamicAllocator * Does not take ownership of the copied instance's allocation. */ template - DynamicAllocator(const DynamicAllocator & other) noexcept + EpochSynchronizedAllocator(const EpochSynchronizedAllocator & other) noexcept : _team(other._team), _nunits(other._nunits) { } @@ -120,7 +120,7 @@ class DynamicAllocator * Destructor. * Frees all global memory regions allocated by this allocator instance. */ - ~DynamicAllocator() noexcept + ~EpochSynchronizedAllocator() noexcept { clear(); } @@ -143,12 +143,12 @@ class DynamicAllocator */ self_t & operator=(const self_t && other) noexcept { - DASH_LOG_DEBUG("DynamicAllocator.=(&&)()"); + DASH_LOG_DEBUG("EpochSynchronizedAllocator.=(&&)()"); if (this != &other) { // Take ownership of other instance's allocation vector: std::swap(_allocated, other._allocated); } - DASH_LOG_DEBUG("DynamicAllocator.=(&&) >"); + DASH_LOG_DEBUG("EpochSynchronizedAllocator.=(&&) >"); return *this; } @@ -203,11 +203,11 @@ class DynamicAllocator * Collective operation. * The number of allocated elements may differ between units. * - * \see DashDynamicAllocatorConcept + * \see DashEpochSynchronizedAllocatorConcept */ pointer attach(local_pointer lptr, size_type num_local_elem) { - DASH_LOG_DEBUG("DynamicAllocator.allocate(nlocal)", + DASH_LOG_DEBUG("EpochSynchronizedAllocator.allocate(nlocal)", "number of local values:", num_local_elem); pointer gptr = DART_GPTR_NULL; dart_storage_t ds = dart_storage(num_local_elem); @@ -217,7 +217,7 @@ class DynamicAllocator } else { gptr = DART_GPTR_NULL; } - DASH_LOG_DEBUG("DynamicAllocator.allocate > ", gptr); + DASH_LOG_DEBUG("EpochSynchronizedAllocator.allocate > ", gptr); return gptr; } @@ -227,16 +227,16 @@ class DynamicAllocator * * Collective operation. * - * \see DashDynamicAllocatorConcept + * \see DashEpochSynchronizedAllocatorConcept */ void detach(pointer gptr) { - DASH_LOG_DEBUG("DynamicAllocator.detach()", "gptr:", gptr); + DASH_LOG_DEBUG("EpochSynchronizedAllocator.detach()", "gptr:", gptr); if (!dash::is_initialized()) { // If a DASH container is deleted after dash::finalize(), global // memory has already been freed by dart_exit() and must not be // deallocated again. - DASH_LOG_DEBUG("DynamicAllocator.detach >", + DASH_LOG_DEBUG("EpochSynchronizedAllocator.detach >", "DASH not initialized, abort"); return; } @@ -251,7 +251,7 @@ class DynamicAllocator return e.second == gptr; }), _allocated.end()); - DASH_LOG_DEBUG("DynamicAllocator.detach >"); + DASH_LOG_DEBUG("EpochSynchronizedAllocator.detach >"); } /** @@ -260,7 +260,7 @@ class DynamicAllocator * * Local operation. * - * \see DashDynamicAllocatorConcept + * \see DashEpochSynchronizedAllocatorConcept */ local_pointer allocate_local(size_type num_local_elem) { @@ -272,7 +272,7 @@ class DynamicAllocator * * Local operation. * - * \see DashDynamicAllocatorConcept + * \see DashEpochSynchronizedAllocatorConcept */ void deallocate_local(local_pointer lptr) { @@ -311,17 +311,17 @@ class DynamicAllocator */ void deallocate(pointer gptr) { - DASH_LOG_DEBUG("DynamicAllocator.deallocate()", "gptr:", gptr); + DASH_LOG_DEBUG("EpochSynchronizedAllocator.deallocate()", "gptr:", gptr); if (!dash::is_initialized()) { // If a DASH container is deleted after dash::finalize(), global // memory has already been freed by dart_exit() and must not be // deallocated again. - DASH_LOG_DEBUG("DynamicAllocator.deallocate >", + DASH_LOG_DEBUG("EpochSynchronizedAllocator.deallocate >", "DASH not initialized, abort"); return; } // Free local memory: - DASH_LOG_DEBUG("DynamicAllocator.deallocate", "deallocate local memory"); + DASH_LOG_DEBUG("EpochSynchronizedAllocator.deallocate", "deallocate local memory"); bool do_detach = false; std::for_each( _allocated.begin(), @@ -331,7 +331,7 @@ class DynamicAllocator delete[] e.first; e.first = nullptr; do_detach = true; - DASH_LOG_DEBUG("DynamicAllocator.deallocate", + DASH_LOG_DEBUG("EpochSynchronizedAllocator.deallocate", "gptr", e.second, "marked for detach"); } }); @@ -339,7 +339,7 @@ class DynamicAllocator if (do_detach) { detach(gptr); } - DASH_LOG_DEBUG("DynamicAllocator.deallocate >"); + DASH_LOG_DEBUG("EpochSynchronizedAllocator.deallocate >"); } private: @@ -349,17 +349,17 @@ class DynamicAllocator */ void clear() noexcept { - DASH_LOG_DEBUG("DynamicAllocator.clear()"); + DASH_LOG_DEBUG("EpochSynchronizedAllocator.clear()"); for (auto & e : _allocated) { // Null-buckets have lptr set to nullptr if (e.first != nullptr) { - DASH_LOG_DEBUG("DynamicAllocator.clear", "deallocate local memory:", + DASH_LOG_DEBUG("EpochSynchronizedAllocator.clear", "deallocate local memory:", e.first); delete[] e.first; e.first = nullptr; } if (!DART_GPTR_ISNULL(e.second)) { - DASH_LOG_DEBUG("DynamicAllocator.clear", "detach global memory:", + DASH_LOG_DEBUG("EpochSynchronizedAllocator.clear", "detach global memory:", e.second); // Cannot use DASH_ASSERT due to noexcept qualifier: dart_ret_t ret = dart_team_memderegister(e.second); @@ -367,7 +367,7 @@ class DynamicAllocator } } _allocated.clear(); - DASH_LOG_DEBUG("DynamicAllocator.clear >"); + DASH_LOG_DEBUG("EpochSynchronizedAllocator.clear >"); } private: @@ -375,12 +375,12 @@ class DynamicAllocator size_t _nunits = 0; std::vector< std::pair > _allocated; -}; // class DynamicAllocator +}; // class EpochSynchronizedAllocator template bool operator==( - const DynamicAllocator & lhs, - const DynamicAllocator & rhs) + const EpochSynchronizedAllocator & lhs, + const EpochSynchronizedAllocator & rhs) { return (sizeof(T) == sizeof(U) && lhs._team->dart_id() == rhs._team->dart_id() && @@ -389,8 +389,8 @@ bool operator==( template bool operator!=( - const DynamicAllocator & lhs, - const DynamicAllocator & rhs) + const EpochSynchronizedAllocator & lhs, + const EpochSynchronizedAllocator & rhs) { return !(lhs == rhs); } @@ -398,4 +398,4 @@ bool operator!=( } // namespace allocator } // namespace dash -#endif // DASH__ALLOCATOR__DYNAMIC_ALLOCATOR_H__INCLUDED +#endif // DASH__ALLOCATOR__EPOCH_SYNCHRONIZED_ALLOCATOR_H__INCLUDED diff --git a/dash/include/dash/allocator/GlobBucketIter.h b/dash/include/dash/allocator/GlobBucketIter.h index 38d5f5aa9..0c879358d 100644 --- a/dash/include/dash/allocator/GlobBucketIter.h +++ b/dash/include/dash/allocator/GlobBucketIter.h @@ -11,7 +11,7 @@ #include #include -#include +#include #include @@ -29,44 +29,44 @@ namespace dash { template< typename ElementType, class AllocatorType > -class GlobHeap; +class GlobHeapMem; /** * Iterator on global buckets. Represents global pointer type. */ template< typename ElementType, - class GlobStaticHeapType, + class GlobStaticMemType, class PointerType = dash::GlobPtr, class ReferenceType = dash::GlobSharedRef > class GlobBucketIter : public std::iterator< std::random_access_iterator_tag, ElementType, - typename GlobStaticHeapType::index_type, + typename GlobStaticMemType::index_type, PointerType, ReferenceType > { template< typename ElementType_, - class GlobStaticHeapType_, + class GlobStaticMemType_, class Pointer_, class Reference_> friend std::ostream & dash::operator<<( std::ostream & os, const dash::GlobBucketIter< - ElementType_, GlobStaticHeapType_, Pointer_, Reference_> & it); + ElementType_, GlobStaticMemType_, Pointer_, Reference_> & it); private: typedef GlobBucketIter< ElementType, - GlobStaticHeapType, + GlobStaticMemType, PointerType, ReferenceType> self_t; public: - typedef typename GlobStaticHeapType::index_type index_type; + typedef typename GlobStaticMemType::index_type index_type; typedef typename std::make_unsigned::type size_type; typedef ElementType value_type; @@ -80,16 +80,16 @@ class GlobBucketIter typedef typename std::conditional< std::is_const::value, - const GlobStaticHeapType, - GlobStaticHeapType + const GlobStaticMemType, + GlobStaticMemType >::type globmem_type; typedef typename std::conditional< std::is_const::value, - typename GlobStaticHeapType::const_local_pointer, - typename GlobStaticHeapType::local_pointer + typename GlobStaticMemType::const_local_pointer, + typename GlobStaticMemType::local_pointer >::type local_pointer; @@ -367,7 +367,7 @@ class GlobBucketIter } /** - * The instance of \c GlobStaticHeap used by this iterator to resolve addresses + * The instance of \c GlobStaticMem used by this iterator to resolve addresses * in global memory. */ inline const globmem_type & globmem() const @@ -376,7 +376,7 @@ class GlobBucketIter } /** - * The instance of \c GlobStaticHeap used by this iterator to resolve addresses + * The instance of \c GlobStaticMem used by this iterator to resolve addresses * in global memory. */ inline globmem_type & globmem() @@ -693,30 +693,30 @@ class GlobBucketIter */ template< typename ElementType, - class GlobStaticHeapType, + class GlobStaticMemType, class Pointer, class Reference> auto distance( /// Global iterator to the first position in the global sequence const dash::GlobBucketIter< - ElementType, GlobStaticHeapType, Pointer, Reference> & first, + ElementType, GlobStaticMemType, Pointer, Reference> & first, /// Global iterator to the final position in the global sequence const dash::GlobBucketIter< - ElementType, GlobStaticHeapType, Pointer, Reference> & last) --> typename GlobStaticHeapType::index_type + ElementType, GlobStaticMemType, Pointer, Reference> & last) +-> typename GlobStaticMemType::index_type { return last - first; } template< typename ElementType, - class GlobStaticHeapType, + class GlobStaticMemType, class Pointer, class Reference> std::ostream & operator<<( std::ostream & os, const dash::GlobBucketIter< - ElementType, GlobStaticHeapType, Pointer, Reference> & it) + ElementType, GlobStaticMemType, Pointer, Reference> & it) { std::ostringstream ss; ss << "dash::GlobBucketIter<" diff --git a/dash/include/dash/allocator/LocalBucketIter.h b/dash/include/dash/allocator/LocalBucketIter.h index ff690344e..500838f5c 100644 --- a/dash/include/dash/allocator/LocalBucketIter.h +++ b/dash/include/dash/allocator/LocalBucketIter.h @@ -6,7 +6,7 @@ #include -#include +#include #include #include diff --git a/dash/include/dash/allocator/CollectiveAllocator.h b/dash/include/dash/allocator/SymmetricAllocator.h similarity index 81% rename from dash/include/dash/allocator/CollectiveAllocator.h rename to dash/include/dash/allocator/SymmetricAllocator.h index b2528874d..ce984487e 100644 --- a/dash/include/dash/allocator/CollectiveAllocator.h +++ b/dash/include/dash/allocator/SymmetricAllocator.h @@ -1,5 +1,5 @@ -#ifndef DASH__ALLOCATOR__COLLECTIVE_ALLOCATOR_H__INCLUDED -#define DASH__ALLOCATOR__COLLECTIVE_ALLOCATOR_H__INCLUDED +#ifndef DASH__ALLOCATOR__SYMMETRIC_ALLOCATOR_H__INCLUDED +#define DASH__ALLOCATOR__SYMMETRIC_ALLOCATOR_H__INCLUDED #include @@ -34,20 +34,20 @@ namespace allocator { * \concept{DashAllocatorConcept} */ template -class CollectiveAllocator +class SymmetricAllocator { template friend bool operator==( - const CollectiveAllocator & lhs, - const CollectiveAllocator & rhs); + const SymmetricAllocator & lhs, + const SymmetricAllocator & rhs); template friend bool operator!=( - const CollectiveAllocator & lhs, - const CollectiveAllocator & rhs); + const SymmetricAllocator & lhs, + const SymmetricAllocator & rhs); private: - typedef CollectiveAllocator self_t; + typedef SymmetricAllocator self_t; /// Type definitions required for std::allocator concept: public: @@ -66,9 +66,9 @@ class CollectiveAllocator public: /** * Constructor. - * Creates a new instance of \c dash::CollectiveAllocator for a given team. + * Creates a new instance of \c dash::SymmetricAllocator for a given team. */ - explicit CollectiveAllocator( + explicit SymmetricAllocator( Team & team = dash::Team::All()) noexcept : _team_id(team.dart_id()) { } @@ -77,7 +77,7 @@ class CollectiveAllocator * Move-constructor. * Takes ownership of the moved instance's allocation. */ - CollectiveAllocator(self_t && other) noexcept + SymmetricAllocator(self_t && other) noexcept : _team_id(other._team_id), _allocated(std::move(other._allocated)) { @@ -90,7 +90,7 @@ class CollectiveAllocator * * \see DashAllocatorConcept */ - CollectiveAllocator(const self_t & other) noexcept + SymmetricAllocator(const self_t & other) noexcept : _team_id(other._team_id) { } @@ -99,7 +99,7 @@ class CollectiveAllocator * Does not take ownership of the copied instance's allocation. */ template - CollectiveAllocator(const CollectiveAllocator & other) noexcept + SymmetricAllocator(const SymmetricAllocator & other) noexcept : _team_id(other._team_id) { } @@ -107,7 +107,7 @@ class CollectiveAllocator * Destructor. * Frees all global memory regions allocated by this allocator instance. */ - ~CollectiveAllocator() noexcept + ~SymmetricAllocator() noexcept { clear(); } @@ -182,7 +182,7 @@ class CollectiveAllocator */ pointer allocate(size_type num_local_elem) { - DASH_LOG_DEBUG("CollectiveAllocator.allocate(nlocal)", + DASH_LOG_DEBUG("SymmetricAllocator.allocate(nlocal)", "number of local values:", num_local_elem); pointer gptr = DART_GPTR_NULL; dart_storage_t ds = dart_storage(num_local_elem); @@ -192,7 +192,7 @@ class CollectiveAllocator } else { gptr = DART_GPTR_NULL; } - DASH_LOG_DEBUG_VAR("CollectiveAllocator.allocate >", gptr); + DASH_LOG_DEBUG_VAR("SymmetricAllocator.allocate >", gptr); return gptr; } @@ -234,38 +234,38 @@ class CollectiveAllocator // If a DASH container is deleted after dash::finalize(), global // memory has already been freed by dart_exit() and must not be // deallocated again. - DASH_LOG_DEBUG("CollectiveAllocator.deallocate >", + DASH_LOG_DEBUG("SymmetricAllocator.deallocate >", "DASH not initialized, abort"); return; } - DASH_LOG_DEBUG("CollectiveAllocator.deallocate", "barrier"); + DASH_LOG_DEBUG("SymmetricAllocator.deallocate", "barrier"); DASH_ASSERT_RETURNS( dart_barrier(_team_id), DART_OK); - DASH_LOG_DEBUG("CollectiveAllocator.deallocate", "dart_team_memfree"); + DASH_LOG_DEBUG("SymmetricAllocator.deallocate", "dart_team_memfree"); DASH_ASSERT_RETURNS( dart_team_memfree(gptr), DART_OK); - DASH_LOG_DEBUG("CollectiveAllocator.deallocate", "_allocated.erase"); + DASH_LOG_DEBUG("SymmetricAllocator.deallocate", "_allocated.erase"); if(!keep_reference){ _allocated.erase( std::remove(_allocated.begin(), _allocated.end(), gptr), _allocated.end()); } - DASH_LOG_DEBUG("CollectiveAllocator.deallocate >"); + DASH_LOG_DEBUG("SymmetricAllocator.deallocate >"); } private: dart_team_t _team_id; std::vector _allocated; -}; // class CollectiveAllocator +}; // class SymmetricAllocator template bool operator==( - const CollectiveAllocator & lhs, - const CollectiveAllocator & rhs) + const SymmetricAllocator & lhs, + const SymmetricAllocator & rhs) { return (sizeof(T) == sizeof(U) && lhs._team_id == rhs._team_id ); @@ -273,8 +273,8 @@ bool operator==( template bool operator!=( - const CollectiveAllocator & lhs, - const CollectiveAllocator & rhs) + const SymmetricAllocator & lhs, + const SymmetricAllocator & rhs) { return !(lhs == rhs); } @@ -282,4 +282,4 @@ bool operator!=( } // namespace allocator } // namespace dash -#endif // DASH__ALLOCATOR__COLLECTIVE_ALLOCATOR_H__INCLUDED +#endif // DASH__ALLOCATOR__SYMMETRIC_ALLOCATOR_H__INCLUDED diff --git a/dash/include/dash/allocator/internal/GlobBucketIter.h b/dash/include/dash/allocator/internal/GlobBucketIter.h index 9ae1a2fd9..c3c5c2ffa 100644 --- a/dash/include/dash/allocator/internal/GlobBucketIter.h +++ b/dash/include/dash/allocator/internal/GlobBucketIter.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include @@ -27,7 +27,7 @@ namespace dash { template< typename ElementType, class AllocatorType > -class GlobHeap; +class GlobHeapMem; namespace internal { @@ -36,37 +36,37 @@ namespace internal { */ template< typename ElementType, - class GlobStaticHeapType, + class GlobStaticMemType, class PointerType = dash::GlobPtr, class ReferenceType = dash::GlobRef > class GlobBucketIter : public std::iterator< std::random_access_iterator_tag, ElementType, - typename GlobStaticHeapType::index_type, + typename GlobStaticMemType::index_type, PointerType, ReferenceType > { template< typename ElementType_, - class GlobStaticHeapType_, + class GlobStaticMemType_, class Pointer_, class Reference_> friend std::ostream & dash::operator<<( std::ostream & os, const dash::internal::GlobBucketIter< - ElementType_, GlobStaticHeapType_, Pointer_, Reference_> & it); + ElementType_, GlobStaticMemType_, Pointer_, Reference_> & it); private: typedef GlobBucketIter< ElementType, - GlobStaticHeapType, + GlobStaticMemType, PointerType, ReferenceType> self_t; public: - typedef typename GlobStaticHeapType::index_type index_type; + typedef typename GlobStaticMemType::index_type index_type; typedef typename std::make_unsigned::type size_type; typedef ElementType value_type; @@ -78,8 +78,8 @@ class GlobBucketIter typedef typename std::conditional< std::is_const::value, - typename GlobStaticHeapType::const_local_pointer, - typename GlobStaticHeapType::local_pointer + typename GlobStaticMemType::const_local_pointer, + typename GlobStaticMemType::local_pointer >::type local_pointer; @@ -116,7 +116,7 @@ class GlobBucketIter * offset in logical storage order. */ GlobBucketIter( - GlobStaticHeapType * gmem, + GlobStaticMemType * gmem, index_type position = 0) : _globmem(gmem), _bucket_cumul_sizes(&_globmem->_bucket_cumul_sizes), @@ -158,7 +158,7 @@ class GlobBucketIter * local offset in logical storage order. */ GlobBucketIter( - GlobStaticHeapType * gmem, + GlobStaticMemType * gmem, team_unit_t unit, index_type local_index) : _globmem(gmem), @@ -311,19 +311,19 @@ class GlobBucketIter } /** - * The instance of \c GlobStaticHeap used by this iterator to resolve addresses + * The instance of \c GlobStaticMem used by this iterator to resolve addresses * in global memory. */ - inline const GlobStaticHeapType & globmem() const + inline const GlobStaticMemType & globmem() const { return *_globmem; } /** - * The instance of \c GlobStaticHeap used by this iterator to resolve addresses + * The instance of \c GlobStaticMem used by this iterator to resolve addresses * in global memory. */ - inline GlobStaticHeapType & globmem() + inline GlobStaticMemType & globmem() { return *_globmem; } @@ -594,7 +594,7 @@ class GlobBucketIter private: /// Global memory used to dereference iterated values. - GlobStaticHeapType * _globmem = nullptr; + GlobStaticMemType * _globmem = nullptr; /// Mapping unit id to buckets in the unit's attached local storage. bucket_cumul_sizes_map * _bucket_cumul_sizes = nullptr; /// Pointer to first element in local data space. @@ -625,17 +625,17 @@ class GlobBucketIter */ template< typename ElementType, - class GlobStaticHeapType, + class GlobStaticMemType, class Pointer, class Reference> auto distance( /// Global iterator to the first position in the global sequence const dash::internal::GlobBucketIter< - ElementType, GlobStaticHeapType, Pointer, Reference> & first, + ElementType, GlobStaticMemType, Pointer, Reference> & first, /// Global iterator to the final position in the global sequence const dash::internal::GlobBucketIter< - ElementType, GlobStaticHeapType, Pointer, Reference> & last) --> typename GlobStaticHeapType::index_type + ElementType, GlobStaticMemType, Pointer, Reference> & last) +-> typename GlobStaticMemType::index_type { return last - first; } @@ -644,13 +644,13 @@ auto distance( template< typename ElementType, - class GlobStaticHeapType, + class GlobStaticMemType, class Pointer, class Reference> std::ostream & operator<<( std::ostream & os, const dash::internal::GlobBucketIter< - ElementType, GlobStaticHeapType, Pointer, Reference> & it) + ElementType, GlobStaticMemType, Pointer, Reference> & it) { std::ostringstream ss; ss << "dash::internal::GlobBucketIter<" diff --git a/dash/include/dash/allocator/internal/GlobHeapTypes.h b/dash/include/dash/allocator/internal/GlobHeapMemTypes.h similarity index 100% rename from dash/include/dash/allocator/internal/GlobHeapTypes.h rename to dash/include/dash/allocator/internal/GlobHeapMemTypes.h diff --git a/dash/include/dash/experimental/Halo.h b/dash/include/dash/experimental/Halo.h index 6fef2cc42..4dbc08ca1 100644 --- a/dash/include/dash/experimental/Halo.h +++ b/dash/include/dash/experimental/Halo.h @@ -1,7 +1,7 @@ #ifndef DASH__EXPERIMENTAL__HALO_H__ #define DASH__EXPERIMENTAL__HALO_H__ -#include +#include #include #include @@ -243,7 +243,7 @@ class HaloBlockIter { private: using self_t = HaloBlockIter; - using GlobStaticHeap_t = GlobStaticHeap>; + using GlobStaticMem_t = GlobStaticMem>; static const dim_t NumDimensions = PatternT::ndim(); //static const MemArrange Arrangement = PatternT::memory_order(); @@ -269,7 +269,7 @@ class HaloBlockIter * Constructor, creates a block boundary iterator on multiple boundary * regions. */ - HaloBlockIter(GlobStaticHeap_t & globmem, const PatternT & pattern, + HaloBlockIter(GlobStaticMem_t & globmem, const PatternT & pattern, const viewspec_t & halo_region, index_type pos, index_type size) : _globmem(globmem), _pattern(pattern), @@ -410,12 +410,12 @@ class HaloBlockIter } /** - * The instance of \c GlobStaticHeap used by this iterator to resolve addresses + * The instance of \c GlobStaticMem used by this iterator to resolve addresses * in global memory. * * \see DashGlobalIteratorConcept */ - const GlobStaticHeap_t & globmem() const + const GlobStaticMem_t & globmem() const { return _globmem; } @@ -562,7 +562,7 @@ class HaloBlockIter private: /// Global memory used to dereference iterated values. - GlobStaticHeap_t & _globmem; + GlobStaticMem_t & _globmem; /// Pattern that created the encapsulated block. const PatternT & _pattern; @@ -611,7 +611,7 @@ class HaloBlockView { private: using self_t = HaloBlockView; - using GlobStaticHeap_t = GlobStaticHeap>; + using GlobStaticMem_t = GlobStaticMem>; static const dim_t NumDimensions = PatternT::ndim(); @@ -624,7 +624,7 @@ class HaloBlockView using viewspec_t = typename PatternT::viewspec_type; public: - HaloBlockView(GlobStaticHeap_t & globmem, const PatternT & pattern, const viewspec_t & halo_region) + HaloBlockView(GlobStaticMem_t & globmem, const PatternT & pattern, const viewspec_t & halo_region) : _halo_region(halo_region), _size(_halo_region.size()), _beg(globmem, pattern, halo_region, 0, _size), _end(globmem, pattern, halo_region, _size, _size) @@ -687,7 +687,7 @@ class HaloBlock { private: using self_t = HaloBlock; - using GlobStaticHeap_t = GlobStaticHeap>; + using GlobStaticMem_t = GlobStaticMem>; public: static constexpr dim_t NumDimensions = PatternT::ndim(); @@ -704,7 +704,7 @@ class HaloBlock * Creates a new instance of HaloBlock that extends a given pattern block * by halo semantics. */ - HaloBlock(GlobStaticHeap_t & globmem, const PatternT & pattern, const viewspec_t & view, + HaloBlock(GlobStaticMem_t & globmem, const PatternT & pattern, const viewspec_t & view, const halospec_t & halospec) : _globmem(globmem), _pattern(pattern), _view(view), _halospec(halospec) { @@ -806,7 +806,7 @@ class HaloBlock return _pattern; } - const GlobStaticHeap_t & globmem() const + const GlobStaticMem_t & globmem() const { return _globmem; } @@ -922,7 +922,7 @@ class HaloBlock } private: - GlobStaticHeap_t & _globmem; + GlobStaticMem_t & _globmem; const PatternT & _pattern; diff --git a/dash/include/dash/experimental/HaloMatrix.h b/dash/include/dash/experimental/HaloMatrix.h index dca2807de..89c711f3f 100644 --- a/dash/include/dash/experimental/HaloMatrix.h +++ b/dash/include/dash/experimental/HaloMatrix.h @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include diff --git a/dash/include/dash/experimental/iterator/GlobStencilIter.h b/dash/include/dash/experimental/iterator/GlobStencilIter.h index 3fb3de244..f9115dd5f 100644 --- a/dash/include/dash/experimental/iterator/GlobStencilIter.h +++ b/dash/include/dash/experimental/iterator/GlobStencilIter.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include @@ -125,7 +125,7 @@ class IteratorHalo template< typename ElementType, class PatternType, - class GlobStaticHeapType = GlobStaticHeap, + class GlobStaticMemType = GlobStaticMem, class PointerType = GlobPtr, class ReferenceType = GlobRef > class GlobStencilIter @@ -144,7 +144,7 @@ class GlobStencilIter typedef GlobStencilIter< ElementType, PatternType, - GlobStaticHeapType, + GlobStaticMemType, PointerType, ReferenceType> self_t; @@ -191,7 +191,7 @@ class GlobStencilIter protected: /// Global memory used to dereference iterated values. - GlobStaticHeapType * _globmem = nullptr; + GlobStaticMemType * _globmem = nullptr; /// Pattern that specifies the iteration order (access pattern). const PatternType * _pattern = nullptr; /// View that specifies the iterator's index range relative to the global @@ -233,7 +233,7 @@ class GlobStencilIter * the element order specified by the given pattern and view spec. */ GlobStencilIter( - GlobStaticHeapType * gmem, + GlobStaticMemType * gmem, const PatternType & pat, const ViewSpecType & viewspec, const HaloSpecType & halospec, @@ -261,7 +261,7 @@ class GlobStencilIter * the element order specified by the given pattern and view spec. */ GlobStencilIter( - GlobStaticHeapType * gmem, + GlobStaticMemType * gmem, const PatternType & pat, const HaloSpecType & halospec, IndexType position = 0, @@ -315,7 +315,7 @@ class GlobStencilIter GlobStencilIter( const GlobViewIter & other, const HaloSpecType & halospec) @@ -845,23 +845,23 @@ class GlobStencilIter } /** - * The instance of \c GlobStaticHeap used by this iterator to resolve addresses + * The instance of \c GlobStaticMem used by this iterator to resolve addresses * in global memory. * * \see DashGlobalIteratorConcept */ - inline const GlobStaticHeapType & globmem() const + inline const GlobStaticMemType & globmem() const { return *_globmem; } /** - * The instance of \c GlobStaticHeap used by this iterator to resolve addresses + * The instance of \c GlobStaticMem used by this iterator to resolve addresses * in global memory. * * \see DashGlobalIteratorConcept */ - inline GlobStaticHeapType & globmem() + inline GlobStaticMemType & globmem() { return *_globmem; } @@ -1163,15 +1163,15 @@ class GlobStencilIter template < typename ElementType, class Pattern, - class GlobStaticHeap, + class GlobStaticMem, class Pointer, class Reference > auto distance( /// Global iterator to the initial position in the global sequence - const GlobStencilIter & + const GlobStencilIter & first, /// Global iterator to the final position in the global sequence - const GlobStencilIter & + const GlobStencilIter & last ) -> typename Pattern::index_type { @@ -1181,13 +1181,13 @@ auto distance( template < typename ElementType, class Pattern, - class GlobStaticHeap, + class GlobStaticMem, class Pointer, class Reference > std::ostream & operator<<( std::ostream & os, const dash::experimental::GlobStencilIter< - ElementType, Pattern, GlobStaticHeap, Pointer, Reference> & it) + ElementType, Pattern, GlobStaticMem, Pointer, Reference> & it) { std::ostringstream ss; dash::GlobPtr ptr(it); diff --git a/dash/include/dash/experimental/iterator/HaloMatrixIterator.h b/dash/include/dash/experimental/iterator/HaloMatrixIterator.h index a3eb3139b..7f640d974 100644 --- a/dash/include/dash/experimental/iterator/HaloMatrixIterator.h +++ b/dash/include/dash/experimental/iterator/HaloMatrixIterator.h @@ -43,7 +43,7 @@ class HaloMatrixIterator static constexpr MemArrange MemoryArrange = PatternT::memory_order(); using self_t = HaloMatrixIterator; - using GlobStaticHeap_t = GlobStaticHeap>; + using GlobStaticMem_t = GlobStaticMem>; using HaloBlock_t = HaloBlock; using HaloSpec_t = HaloSpec; using HaloMemory_t = HaloMemory; diff --git a/dash/include/dash/iterator/GlobIter.h b/dash/include/dash/iterator/GlobIter.h index 9105fc8b0..16e4be5f5 100644 --- a/dash/include/dash/iterator/GlobIter.h +++ b/dash/include/dash/iterator/GlobIter.h @@ -16,7 +16,7 @@ namespace dash { template< typename ElementType, class PatternType, - class GlobStaticHeapType, + class GlobStaticMemType, class PointerType, class ReferenceType > class GlobStencilIter; @@ -24,7 +24,7 @@ class GlobStencilIter; template< typename ElementType, class PatternType, - class GlobStaticHeapType, + class GlobStaticMemType, class PointerType, class ReferenceType > class GlobViewIter; @@ -56,10 +56,10 @@ class GlobViewIter; template< typename ElementType, class PatternType, - class GlobStaticHeapType = GlobStaticHeap< + class GlobStaticMemType = GlobStaticMem< typename std::decay::type >, - class PointerType = typename GlobStaticHeapType::pointer, + class PointerType = typename GlobStaticMemType::pointer, class ReferenceType = GlobRef > class GlobIter : public std::iterator< @@ -73,7 +73,7 @@ class GlobIter typedef GlobIter< ElementType, PatternType, - GlobStaticHeapType, + GlobStaticMemType, PointerType, ReferenceType> self_t; @@ -89,8 +89,8 @@ class GlobIter typedef PointerType pointer; typedef typename PointerType::const_type const_pointer; - typedef typename GlobStaticHeapType::local_pointer local_pointer; - typedef typename GlobStaticHeapType::local_pointer local_type; + typedef typename GlobStaticMemType::local_pointer local_pointer; + typedef typename GlobStaticMemType::local_pointer local_type; typedef PatternType pattern_type; typedef typename PatternType::index_type index_type; @@ -99,7 +99,7 @@ class GlobIter typedef GlobIter< const ElementType, PatternType, - GlobStaticHeapType, + GlobStaticMemType, const_pointer, const_reference > self_const_t; @@ -152,7 +152,7 @@ class GlobIter protected: /// Global memory used to dereference iterated values. - GlobStaticHeapType * _globmem; + GlobStaticMemType * _globmem; /// Pattern that specifies the iteration order (access pattern). const PatternType * _pattern; /// Current position of the iterator in global canonical index space. @@ -182,7 +182,7 @@ class GlobIter * the element order specified by the given pattern. */ constexpr GlobIter( - GlobStaticHeapType * gmem, + GlobStaticMemType * gmem, const PatternType & pat, index_type position = 0) : _globmem(gmem), @@ -563,19 +563,19 @@ class GlobIter } /** - * The instance of \c GlobStaticHeap used by this iterator to resolve addresses + * The instance of \c GlobStaticMem used by this iterator to resolve addresses * in global memory. */ - constexpr const GlobStaticHeapType & globmem() const noexcept + constexpr const GlobStaticMemType & globmem() const noexcept { return *_globmem; } /** - * The instance of \c GlobStaticHeap used by this iterator to resolve addresses + * The instance of \c GlobStaticMem used by this iterator to resolve addresses * in global memory. */ - inline GlobStaticHeapType & globmem() + inline GlobStaticMemType & globmem() { return *_globmem; } @@ -720,16 +720,16 @@ class GlobIter template < typename ElementType, class Pattern, - class GlobStaticHeap, + class GlobStaticMem, class Pointer, class Reference > std::ostream & operator<<( std::ostream & os, const dash::GlobIter< - ElementType, Pattern, GlobStaticHeap, Pointer, Reference> & it) + ElementType, Pattern, GlobStaticMem, Pointer, Reference> & it) { std::ostringstream ss; - dash::GlobPtr ptr(*it._globmem, + dash::GlobPtr ptr(*it._globmem, it.dart_gptr()); ss << "dash::GlobIter<" << typeid(ElementType).name() << ">(" << "idx:" << it._idx << ", " diff --git a/dash/include/dash/iterator/GlobStencilIter.h b/dash/include/dash/iterator/GlobStencilIter.h index 06f3aa4c4..5ae870bab 100644 --- a/dash/include/dash/iterator/GlobStencilIter.h +++ b/dash/include/dash/iterator/GlobStencilIter.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include @@ -121,7 +121,7 @@ class IteratorHalo template< typename ElementType, class PatternType, - class GlobStaticHeapType = GlobStaticHeap, + class GlobStaticMemType = GlobStaticMem, class PointerType = GlobPtr, class ReferenceType = GlobRef > class GlobStencilIter @@ -140,7 +140,7 @@ class GlobStencilIter typedef GlobStencilIter< ElementType, PatternType, - GlobStaticHeapType, + GlobStaticMemType, PointerType, ReferenceType> self_t; @@ -187,7 +187,7 @@ class GlobStencilIter protected: /// Global memory used to dereference iterated values. - GlobStaticHeapType * _globmem = nullptr; + GlobStaticMemType * _globmem = nullptr; /// Pattern that specifies the iteration order (access pattern). const PatternType * _pattern = nullptr; /// View that specifies the iterator's index range relative to the global @@ -229,7 +229,7 @@ class GlobStencilIter * the element order specified by the given pattern and view spec. */ GlobStencilIter( - GlobStaticHeapType * gmem, + GlobStaticMemType * gmem, const PatternType & pat, const ViewSpecType & viewspec, const HaloSpecType & halospec, @@ -257,7 +257,7 @@ class GlobStencilIter * the element order specified by the given pattern and view spec. */ GlobStencilIter( - GlobStaticHeapType * gmem, + GlobStaticMemType * gmem, const PatternType & pat, const HaloSpecType & halospec, IndexType position = 0, @@ -311,7 +311,7 @@ class GlobStencilIter GlobStencilIter( const GlobViewIter & other, const HaloSpecType & halospec) @@ -841,23 +841,23 @@ class GlobStencilIter } /** - * The instance of \c GlobStaticHeap used by this iterator to resolve addresses + * The instance of \c GlobStaticMem used by this iterator to resolve addresses * in global memory. * * \see DashGlobalIteratorConcept */ - inline const GlobStaticHeapType & globmem() const + inline const GlobStaticMemType & globmem() const { return *_globmem; } /** - * The instance of \c GlobStaticHeap used by this iterator to resolve addresses + * The instance of \c GlobStaticMem used by this iterator to resolve addresses * in global memory. * * \see DashGlobalIteratorConcept */ - inline GlobStaticHeapType & globmem() + inline GlobStaticMemType & globmem() { return *_globmem; } @@ -1159,15 +1159,15 @@ class GlobStencilIter template < typename ElementType, class Pattern, - class GlobStaticHeap, + class GlobStaticMem, class Pointer, class Reference > auto distance( /// Global iterator to the initial position in the global sequence - const GlobStencilIter & + const GlobStencilIter & first, /// Global iterator to the final position in the global sequence - const GlobStencilIter & + const GlobStencilIter & last ) -> typename Pattern::index_type { @@ -1177,13 +1177,13 @@ auto distance( template < typename ElementType, class Pattern, - class GlobStaticHeap, + class GlobStaticMem, class Pointer, class Reference > std::ostream & operator<<( std::ostream & os, const dash::GlobStencilIter< - ElementType, Pattern, GlobStaticHeap, Pointer, Reference> & it) + ElementType, Pattern, GlobStaticMem, Pointer, Reference> & it) { std::ostringstream ss; dash::GlobPtr ptr(it); diff --git a/dash/include/dash/iterator/GlobViewIter.h b/dash/include/dash/iterator/GlobViewIter.h index 429f6006f..e4212526c 100644 --- a/dash/include/dash/iterator/GlobViewIter.h +++ b/dash/include/dash/iterator/GlobViewIter.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include @@ -21,7 +21,7 @@ namespace dash { template< typename ElementType, class PatternType, - class GlobStaticHeapType, + class GlobStaticMemType, class PointerType, class ReferenceType > class GlobIter; @@ -29,7 +29,7 @@ class GlobIter; template< typename ElementType, class PatternType, - class GlobStaticHeapType, + class GlobStaticMemType, class PointerType, class ReferenceType > class GlobStencilIter; @@ -43,10 +43,10 @@ class GlobStencilIter; template< typename ElementType, class PatternType, - class GlobStaticHeapType = GlobStaticHeap< + class GlobStaticMemType = GlobStaticMem< typename std::decay::type >, - class PointerType = typename GlobStaticHeapType::pointer, + class PointerType = typename GlobStaticMemType::pointer, class ReferenceType = GlobRef > class GlobViewIter : public std::iterator< @@ -59,7 +59,7 @@ class GlobViewIter typedef GlobViewIter< ElementType, PatternType, - GlobStaticHeapType, + GlobStaticMemType, PointerType, ReferenceType> self_t; @@ -67,7 +67,7 @@ class GlobViewIter typedef GlobIter< ElementType, PatternType, - GlobStaticHeapType, + GlobStaticMemType, PointerType, ReferenceType> global_type; @@ -75,7 +75,7 @@ class GlobViewIter typedef GlobIter< const ElementType, PatternType, - GlobStaticHeapType, + GlobStaticMemType, PointerType, ReferenceType> const_global_type; @@ -97,8 +97,8 @@ class GlobViewIter typedef PointerType pointer; typedef typename PointerType::const_type const_pointer; - typedef typename GlobStaticHeapType::local_pointer local_pointer; - typedef typename GlobStaticHeapType::local_pointer local_type; + typedef typename GlobStaticMemType::local_pointer local_pointer; + typedef typename GlobStaticMemType::local_pointer local_type; typedef PatternType pattern_type; typedef typename PatternType::index_type index_type; @@ -107,7 +107,7 @@ class GlobViewIter typedef GlobViewIter< const ElementType, PatternType, - GlobStaticHeapType, + GlobStaticMemType, const_pointer, const_reference > self_const_t; @@ -158,7 +158,7 @@ class GlobViewIter protected: /// Global memory used to dereference iterated values. - GlobStaticHeapType * _globmem; + GlobStaticMemType * _globmem; /// Pattern that specifies the iteration order (access pattern). const PatternType * _pattern; /// View that specifies the iterator's index range relative to the global @@ -194,14 +194,14 @@ class GlobViewIter * Constructor, creates a global iterator on global memory following * the element order specified by the given pattern and view spec. */ - template + template constexpr GlobViewIter( - GlobStaticHeapT_ * gmem, + GlobStaticMemT_ * gmem, const PatternType & pat, const ViewSpecType & viewspec, IndexType position = 0, IndexType view_index_offset = 0) - : _globmem(reinterpret_cast(gmem)) + : _globmem(reinterpret_cast(gmem)) , _pattern(&pat) , _viewspec(&viewspec) , _idx(position) @@ -215,13 +215,13 @@ class GlobViewIter * Constructor, creates a global iterator on global memory following * the element order specified by the given pattern and view spec. */ - template + template constexpr GlobViewIter( - GlobStaticHeapT_ * gmem, + GlobStaticMemT_ * gmem, const PatternType & pat, IndexType position = 0, IndexType view_index_offset = 0) - : _globmem(reinterpret_cast(gmem)) + : _globmem(reinterpret_cast(gmem)) , _pattern(&pat) , _viewspec(nullptr) , _idx(position) @@ -749,19 +749,19 @@ class GlobViewIter } /** - * The instance of \c GlobStaticHeap used by this iterator to resolve addresses + * The instance of \c GlobStaticMem used by this iterator to resolve addresses * in global memory. */ - constexpr const GlobStaticHeapType & globmem() const noexcept + constexpr const GlobStaticMemType & globmem() const noexcept { return *_globmem; } /** - * The instance of \c GlobStaticHeap used by this iterator to resolve addresses + * The instance of \c GlobStaticMem used by this iterator to resolve addresses * in global memory. */ - inline GlobStaticHeapType & globmem() noexcept + inline GlobStaticMemType & globmem() noexcept { return *_globmem; } @@ -1065,14 +1065,14 @@ class GlobViewIter template< typename ElementType, class Pattern, - class GlobStaticHeap, + class GlobStaticMem, class Pointer, class Reference > auto distance( - const GlobViewIter & + const GlobViewIter & first, /// Global iterator to the final position in the global sequence - const GlobViewIter & + const GlobViewIter & last) -> typename Pattern::index_type { @@ -1082,16 +1082,16 @@ auto distance( template < typename ElementType, class Pattern, - class GlobStaticHeap, + class GlobStaticMem, class Pointer, class Reference > std::ostream & operator<<( std::ostream & os, const dash::GlobViewIter< - ElementType, Pattern, GlobStaticHeap, Pointer, Reference> & it) + ElementType, Pattern, GlobStaticMem, Pointer, Reference> & it) { std::ostringstream ss; - dash::GlobPtr ptr(it); + dash::GlobPtr ptr(it); ss << "dash::GlobViewIter<" << typeid(ElementType).name() << ">(" << "idx:" << it._idx << ", " << "gptr:" << ptr << ")"; diff --git a/dash/include/dash/list/GlobListIter.h b/dash/include/dash/list/GlobListIter.h index c2f493ef0..5681336c3 100644 --- a/dash/include/dash/list/GlobListIter.h +++ b/dash/include/dash/list/GlobListIter.h @@ -19,7 +19,7 @@ namespace dash { */ template< typename ElementType, - class GlobStaticHeapType, + class GlobStaticMemType, class PointerType = GlobPtr, class ReferenceType = GlobRef > class GlobListIter @@ -33,7 +33,7 @@ class GlobListIter private: typedef GlobListIter< ElementType, - GlobStaticHeapType, + GlobStaticMemType, PointerType, ReferenceType> self_t; @@ -45,7 +45,7 @@ class GlobListIter typedef PointerType pointer; typedef const PointerType const_pointer; - typedef typename GlobStaticHeapType::local_pointer local_pointer; + typedef typename GlobStaticMemType::local_pointer local_pointer; typedef internal::ListNode node_type; @@ -62,7 +62,7 @@ class GlobListIter * Constructor, creates a global iterator on a \c dash::List instance. */ GlobListIter( - GlobStaticHeapType * gmem, + GlobStaticMemType * gmem, node_type & node) : _globmem(gmem), _node(&node), @@ -136,19 +136,19 @@ class GlobListIter } /** - * The instance of \c GlobStaticHeap used by this iterator to resolve addresses + * The instance of \c GlobStaticMem used by this iterator to resolve addresses * in global memory. */ - inline const GlobStaticHeapType & globmem() const + inline const GlobStaticMemType & globmem() const { return *_globmem; } /** - * The instance of \c GlobStaticHeap used by this iterator to resolve addresses + * The instance of \c GlobStaticMem used by this iterator to resolve addresses * in global memory. */ - inline GlobStaticHeapType & globmem() + inline GlobStaticMemType & globmem() { return *_globmem; } @@ -219,7 +219,7 @@ class GlobListIter private: /// Global memory used to dereference iterated values. - GlobStaticHeapType * _globmem; + GlobStaticMemType * _globmem; /// The node element referenced at the iterator's position. node_type * _node = nullptr; /// Unit id of the active unit diff --git a/dash/include/dash/list/ListRef.h b/dash/include/dash/list/ListRef.h index a7b1d56e7..1207b151f 100644 --- a/dash/include/dash/list/ListRef.h +++ b/dash/include/dash/list/ListRef.h @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include @@ -64,7 +64,7 @@ class ListRef ListNode_t; typedef typename allocator_type::template rebind::other node_allocator_type; - typedef dash::GlobHeap + typedef dash::GlobHeapMem glob_mem_type; /// Public types as required by STL list concept: diff --git a/dash/include/dash/list/LocalListRef.h b/dash/include/dash/list/LocalListRef.h index 1e6054d1d..0b81195f5 100644 --- a/dash/include/dash/list/LocalListRef.h +++ b/dash/include/dash/list/LocalListRef.h @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include diff --git a/dash/include/dash/map/UnorderedMap.h b/dash/include/dash/map/UnorderedMap.h index 95f5ac1d7..fc1711ca5 100644 --- a/dash/include/dash/map/UnorderedMap.h +++ b/dash/include/dash/map/UnorderedMap.h @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include @@ -75,7 +75,7 @@ template< typename Mapped, typename Hash = dash::HashLocal, typename Pred = std::equal_to, - typename Alloc = dash::allocator::DynamicAllocator< + typename Alloc = dash::allocator::EpochSynchronizedAllocator< std::pair > > class UnorderedMap { @@ -111,7 +111,7 @@ class UnorderedMap typedef UnorderedMapLocalRef local_type; - typedef dash::GlobHeap glob_mem_type; + typedef dash::GlobHeapMem glob_mem_type; typedef typename glob_mem_type::reference reference; typedef typename glob_mem_type::const_reference const_reference; diff --git a/dash/include/dash/matrix/internal/Matrix-inl.h b/dash/include/dash/matrix/internal/Matrix-inl.h index e2d6c10e0..310a9cfe2 100644 --- a/dash/include/dash/matrix/internal/Matrix-inl.h +++ b/dash/include/dash/matrix/internal/Matrix-inl.h @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include #include @@ -153,7 +153,7 @@ ::allocate( DASH_LOG_TRACE_VAR("Matrix.allocate", _lcapacity); // Allocate and initialize memory // use _lcapacity as tje collective allocator requires symmetric allocations - _glob_mem = new GlobStaticHeap_t(_lcapacity, _pattern.team()); + _glob_mem = new GlobStaticMem_t(_lcapacity, _pattern.team()); _begin = iterator(_glob_mem, _pattern); _lbegin = _glob_mem->lbegin(); _lend = _lbegin + _lsize; diff --git a/dash/include/libdash.h b/dash/include/libdash.h index 58a122bda..1ac267cee 100644 --- a/dash/include/libdash.h +++ b/dash/include/libdash.h @@ -27,7 +27,7 @@ namespace dash { #include #include -#include +#include #include #include #include diff --git a/dash/test/dart/ThreadsafetyTest.cc b/dash/test/dart/ThreadsafetyTest.cc index b71e2bf58..3e01c77c6 100644 --- a/dash/test/dart/ThreadsafetyTest.cc +++ b/dash/test/dart/ThreadsafetyTest.cc @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include @@ -161,7 +161,7 @@ TEST_F(ThreadsafetyTest, ConcurrentAlloc) { TEST_F(ThreadsafetyTest, ConcurrentAttach) { using elem_t = int; - using allocator_t = dash::allocator::DynamicAllocator; + using allocator_t = dash::allocator::EpochSynchronizedAllocator; if (!dash::is_multithreaded()) { SKIP_TEST_MSG("requires support for multi-threading"); diff --git a/dash/test/memory/GlobHeapTest.cc b/dash/test/memory/GlobHeapMemTest.cc similarity index 84% rename from dash/test/memory/GlobHeapTest.cc rename to dash/test/memory/GlobHeapMemTest.cc index 613b8dcf9..80c3124a1 100644 --- a/dash/test/memory/GlobHeapTest.cc +++ b/dash/test/memory/GlobHeapMemTest.cc @@ -1,10 +1,10 @@ -#include "GlobHeapTest.h" +#include "GlobHeapMemTest.h" -#include +#include -TEST_F(GlobHeapTest, BalancedAlloc) +TEST_F(GlobHeapMemTest, BalancedAlloc) { typedef int value_t; @@ -12,11 +12,11 @@ TEST_F(GlobHeapTest, BalancedAlloc) SKIP_TEST_MSG("Test case requires at least two units"); } - LOG_MESSAGE("initializing GlobHeap"); + LOG_MESSAGE("initializing GlobHeapMem"); size_t initial_local_capacity = 10; size_t initial_global_capacity = dash::size() * initial_local_capacity; - dash::GlobHeap gdmem(initial_local_capacity); + dash::GlobHeapMem gdmem(initial_local_capacity); LOG_MESSAGE("initial global capacity: %ld, initial local capacity: %ld", initial_global_capacity, initial_local_capacity); @@ -26,9 +26,9 @@ TEST_F(GlobHeapTest, BalancedAlloc) gdmem.lbegin()); EXPECT_EQ_U(initial_global_capacity, gdmem.size()); - DASH_LOG_TRACE("GlobHeapTest.BalancedAlloc", "initial local:", + DASH_LOG_TRACE("GlobHeapMemTest.BalancedAlloc", "initial local:", gdmem.local_size()); - DASH_LOG_TRACE("GlobHeapTest.BalancedAlloc", "initial global:", + DASH_LOG_TRACE("GlobHeapMemTest.BalancedAlloc", "initial global:", gdmem.size()); // Wait for validation of initial capacity at all units: dash::barrier(); @@ -50,18 +50,18 @@ TEST_F(GlobHeapTest, BalancedAlloc) gdmem.lbegin()); EXPECT_EQ_U(precommit_global_capacity, gdmem.size()); - DASH_LOG_TRACE("GlobHeapTest.BalancedAlloc", "pre-commit local:", + DASH_LOG_TRACE("GlobHeapMemTest.BalancedAlloc", "pre-commit local:", gdmem.local_size()); - DASH_LOG_TRACE("GlobHeapTest.BalancedAlloc", "pre-commit global:", + DASH_LOG_TRACE("GlobHeapMemTest.BalancedAlloc", "pre-commit global:", gdmem.size()); // Wait for validation of changes of local capacity at all units: dash::barrier(); gdmem.commit(); - DASH_LOG_TRACE("GlobHeapTest.BalancedAlloc", "post-commit local:", + DASH_LOG_TRACE("GlobHeapMemTest.BalancedAlloc", "post-commit local:", gdmem.local_size()); - DASH_LOG_TRACE("GlobHeapTest.BalancedAlloc", "post-commit global:", + DASH_LOG_TRACE("GlobHeapMemTest.BalancedAlloc", "post-commit global:", gdmem.size()); size_t postcommit_local_capacity = precommit_local_capacity; size_t postcommit_global_capacity = dash::size() * @@ -72,7 +72,7 @@ TEST_F(GlobHeapTest, BalancedAlloc) EXPECT_EQ_U(postcommit_global_capacity, gdmem.size()); } -TEST_F(GlobHeapTest, UnbalancedRealloc) +TEST_F(GlobHeapMemTest, UnbalancedRealloc) { typedef int value_t; @@ -80,11 +80,11 @@ TEST_F(GlobHeapTest, UnbalancedRealloc) SKIP_TEST_MSG("Test case requires at least two units"); } - LOG_MESSAGE("initializing GlobHeap"); + LOG_MESSAGE("initializing GlobHeapMem"); size_t initial_local_capacity = 10; size_t initial_global_capacity = dash::size() * initial_local_capacity; - dash::GlobHeap gdmem(initial_local_capacity); + dash::GlobHeapMem gdmem(initial_local_capacity); LOG_MESSAGE("initial global capacity: %ld, initial local capacity: %ld", initial_global_capacity, initial_local_capacity); @@ -104,7 +104,7 @@ TEST_F(GlobHeapTest, UnbalancedRealloc) unit_1_lsize_diff + (dash::size() - 2) * unit_x_lsize_diff; - DASH_LOG_TRACE("GlobHeapTest.UnbalancedRealloc", + DASH_LOG_TRACE("GlobHeapMemTest.UnbalancedRealloc", "begin local reallocation"); // Extend local size, changes should be locally visible immediately: if (dash::myid() == 0) { @@ -147,7 +147,7 @@ TEST_F(GlobHeapTest, UnbalancedRealloc) gdmem.local_size()); } dash::barrier(); - DASH_LOG_TRACE("GlobHeapTest.UnbalancedRealloc", + DASH_LOG_TRACE("GlobHeapMemTest.UnbalancedRealloc", "size checks after commit completed"); // Initialize values in reallocated memory: @@ -155,28 +155,28 @@ TEST_F(GlobHeapTest, UnbalancedRealloc) auto lcap = gdmem.local_size(); for (size_t li = 0; li < lcap; ++li) { auto value = 1000 * (dash::myid() + 1) + li; - DASH_LOG_TRACE("GlobHeapTest.UnbalancedRealloc", + DASH_LOG_TRACE("GlobHeapMemTest.UnbalancedRealloc", "setting local offset", li, "at unit", dash::myid(), "value:", value); lmem[li] = value; } dash::barrier(); - DASH_LOG_TRACE("GlobHeapTest.UnbalancedRealloc", + DASH_LOG_TRACE("GlobHeapMemTest.UnbalancedRealloc", "initialization of local values completed"); if (dash::myid() == 0) { - DASH_LOG_TRACE("GlobHeapTest.UnbalancedRealloc", + DASH_LOG_TRACE("GlobHeapMemTest.UnbalancedRealloc", "testing basic iterator arithmetic"); - DASH_LOG_TRACE("GlobHeapTest.UnbalancedRealloc", "git_first"); + DASH_LOG_TRACE("GlobHeapMemTest.UnbalancedRealloc", "git_first"); auto git_first = gdmem.begin(); - DASH_LOG_TRACE("GlobHeapTest.UnbalancedRealloc", "git_second"); + DASH_LOG_TRACE("GlobHeapMemTest.UnbalancedRealloc", "git_second"); auto git_second = git_first + 1; - DASH_LOG_TRACE("GlobHeapTest.UnbalancedRealloc", "git_remote"); + DASH_LOG_TRACE("GlobHeapMemTest.UnbalancedRealloc", "git_remote"); auto git_remote = git_first + gdmem.local_size() + 1; - DASH_LOG_TRACE("GlobHeapTest.UnbalancedRealloc", "git_last"); + DASH_LOG_TRACE("GlobHeapMemTest.UnbalancedRealloc", "git_last"); auto git_last = git_first + gdmem.size() - 1; - DASH_LOG_TRACE("GlobHeapTest.UnbalancedRealloc", "git_end"); + DASH_LOG_TRACE("GlobHeapMemTest.UnbalancedRealloc", "git_end"); auto git_end = git_first + gdmem.size(); dash__unused(git_second); @@ -185,7 +185,7 @@ TEST_F(GlobHeapTest, UnbalancedRealloc) dash__unused(git_end); } dash::barrier(); - DASH_LOG_TRACE("GlobHeapTest.UnbalancedRealloc", + DASH_LOG_TRACE("GlobHeapMemTest.UnbalancedRealloc", "testing basic iterator arithmetic completed"); // Test memory space of units separately: @@ -202,7 +202,7 @@ TEST_F(GlobHeapTest, UnbalancedRealloc) } else { exp_l_capacity += unit_x_lsize_diff; } - DASH_LOG_TRACE("GlobHeapTest.UnbalancedRealloc", + DASH_LOG_TRACE("GlobHeapMemTest.UnbalancedRealloc", "remote unit:", unit, "expected local size:", exp_l_capacity, "gdm.local_size(unit):", gdmem.local_size(unit), @@ -211,23 +211,23 @@ TEST_F(GlobHeapTest, UnbalancedRealloc) EXPECT_EQ_U(exp_l_capacity, unit_git_end - unit_git_begin); int l_idx = 0; for(auto it = unit_git_begin; it != unit_git_end; ++it, ++l_idx) { - DASH_LOG_TRACE("GlobHeapTest.UnbalancedRealloc", + DASH_LOG_TRACE("GlobHeapMemTest.UnbalancedRealloc", "requesting element at", "local offset", l_idx, "from unit", unit); auto gptr = it.dart_gptr(); - DASH_LOG_TRACE_VAR("GlobHeapTest.UnbalancedRealloc", gptr); + DASH_LOG_TRACE_VAR("GlobHeapMemTest.UnbalancedRealloc", gptr); // request value via DART global pointer: value_t dart_gptr_value; dart_storage_t ds = dash::dart_storage(1); dart_get_blocking(&dart_gptr_value, gptr, ds.nelem, ds.dtype); - DASH_LOG_TRACE_VAR("GlobHeapTest.UnbalancedRealloc", + DASH_LOG_TRACE_VAR("GlobHeapMemTest.UnbalancedRealloc", dart_gptr_value); // request value via DASH global iterator: value_t git_value = *it; - DASH_LOG_TRACE_VAR("GlobHeapTest.UnbalancedRealloc", + DASH_LOG_TRACE_VAR("GlobHeapMemTest.UnbalancedRealloc", git_value); value_t expected = 1000 * (unit + 1) + l_idx; @@ -238,7 +238,7 @@ TEST_F(GlobHeapTest, UnbalancedRealloc) } dash::barrier(); - DASH_LOG_TRACE("GlobHeapTest.UnbalancedRealloc", + DASH_LOG_TRACE("GlobHeapMemTest.UnbalancedRealloc", "testing reverse iteration"); // Test memory space of all units by iterating global index space: @@ -248,15 +248,15 @@ TEST_F(GlobHeapTest, UnbalancedRealloc) auto rgend = gdmem.rend(); EXPECT_EQ_U(gdmem.size(), gdmem.rend() - gdmem.rbegin()); for (auto rgit = gdmem.rbegin(); rgit != rgend; ++rgit) { - DASH_LOG_TRACE("GlobHeapTest.UnbalancedRealloc", + DASH_LOG_TRACE("GlobHeapMemTest.UnbalancedRealloc", "requesting element at", "local offset", local_offset, "from unit", unit); value_t expected = 1000 * (unit + 1) + local_offset; value_t rgit_value = *rgit; - DASH_LOG_TRACE_VAR("GlobHeapTest.UnbalancedRealloc", rgit_value); + DASH_LOG_TRACE_VAR("GlobHeapMemTest.UnbalancedRealloc", rgit_value); value_t git_value = *gdmem.at(unit, local_offset); - DASH_LOG_TRACE_VAR("GlobHeapTest.UnbalancedRealloc", git_value); + DASH_LOG_TRACE_VAR("GlobHeapMemTest.UnbalancedRealloc", git_value); EXPECT_EQ_U(expected, rgit_value); EXPECT_EQ_U(expected, git_value); @@ -267,11 +267,11 @@ TEST_F(GlobHeapTest, UnbalancedRealloc) --local_offset; } - DASH_LOG_TRACE("GlobHeapTest.UnbalancedRealloc", + DASH_LOG_TRACE("GlobHeapMemTest.UnbalancedRealloc", "testing reverse iteration completed"); } -TEST_F(GlobHeapTest, LocalVisibility) +TEST_F(GlobHeapMemTest, LocalVisibility) { typedef int value_t; @@ -279,11 +279,11 @@ TEST_F(GlobHeapTest, LocalVisibility) SKIP_TEST_MSG("Test case requires at least two units"); } - LOG_MESSAGE("initializing GlobHeap"); + LOG_MESSAGE("initializing GlobHeapMem"); size_t initial_local_capacity = 10; size_t initial_global_capacity = dash::size() * initial_local_capacity; - dash::GlobHeap gdmem(initial_local_capacity); + dash::GlobHeapMem gdmem(initial_local_capacity); LOG_MESSAGE("initial global capacity: %ld, initial local capacity: %ld", initial_global_capacity, initial_local_capacity); @@ -356,10 +356,10 @@ TEST_F(GlobHeapTest, LocalVisibility) } dash::barrier(); - DASH_LOG_TRACE("GlobHeapTest.LocalVisibility", + DASH_LOG_TRACE("GlobHeapMemTest.LocalVisibility", "tests of visible memory size before commit passed"); - DASH_LOG_TRACE("GlobHeapTest.LocalVisibility", + DASH_LOG_TRACE("GlobHeapMemTest.LocalVisibility", "testing local capacities after grow/shrink"); auto local_size = gdmem.lend() - gdmem.lbegin(); EXPECT_EQ_U(local_size, gdmem.local_size()); @@ -376,33 +376,33 @@ TEST_F(GlobHeapTest, LocalVisibility) auto lbegin = gdmem.lbegin(); for (size_t li = 0; li < gdmem.local_size(); ++li) { value_t value = 100 * (dash::myid() + 1) + li; - DASH_LOG_TRACE("GlobHeapTest.LocalVisibility", + DASH_LOG_TRACE("GlobHeapMemTest.LocalVisibility", "local[", li, "] =", value); *(lbegin + li) = value; } dash::barrier(); - DASH_LOG_TRACE("GlobHeapTest.LocalVisibility", + DASH_LOG_TRACE("GlobHeapMemTest.LocalVisibility", "tests of local capacities after grow/shrink passed"); // Memory marked for deallocation is still accessible by other units: - DASH_LOG_TRACE("GlobHeapTest.LocalVisibility", + DASH_LOG_TRACE("GlobHeapMemTest.LocalVisibility", "committing global memory"); - DASH_LOG_TRACE("GlobHeapTest.LocalVisibility", + DASH_LOG_TRACE("GlobHeapMemTest.LocalVisibility", "local capacity before commit:", gdmem.local_size()); - DASH_LOG_TRACE("GlobHeapTest.LocalVisibility", + DASH_LOG_TRACE("GlobHeapMemTest.LocalVisibility", "global capacity before commit:", gdmem.size()); // Collectively commit changes of local memory allocation to global // memory space: // register newly allocated local memory and remove local memory marked // for deallocation. gdmem.commit(); - DASH_LOG_TRACE("GlobHeapTest.LocalVisibility", "commit completed"); + DASH_LOG_TRACE("GlobHeapMemTest.LocalVisibility", "commit completed"); - DASH_LOG_TRACE("GlobHeapTest.LocalVisibility", + DASH_LOG_TRACE("GlobHeapMemTest.LocalVisibility", "local capacity after commit:", gdmem.local_size()); - DASH_LOG_TRACE("GlobHeapTest.LocalVisibility", + DASH_LOG_TRACE("GlobHeapMemTest.LocalVisibility", "global capacity after commit:", gdmem.size()); // Changes are globally visible now: @@ -411,15 +411,15 @@ TEST_F(GlobHeapTest, LocalVisibility) EXPECT_EQ_U(expected_global_capacity, gdmem.size()); if (dash::myid() == 0) { - DASH_LOG_TRACE("GlobHeapTest.LocalVisibility", "grow(30)"); + DASH_LOG_TRACE("GlobHeapMemTest.LocalVisibility", "grow(30)"); LOG_MESSAGE("grow(30)"); gdmem.grow(30); } if (dash::myid() == 1) { - DASH_LOG_TRACE("GlobHeapTest.LocalVisibility", "grow(30)"); + DASH_LOG_TRACE("GlobHeapMemTest.LocalVisibility", "grow(30)"); gdmem.grow(30); } - DASH_LOG_TRACE("GlobHeapTest.LocalVisibility", + DASH_LOG_TRACE("GlobHeapMemTest.LocalVisibility", "commit, balanced attach"); gdmem.commit(); // Capacity changes have been published globally: @@ -428,15 +428,15 @@ TEST_F(GlobHeapTest, LocalVisibility) if (dash::myid() == 0) { // resizes attached bucket: - DASH_LOG_TRACE("GlobHeapTest.LocalVisibility", "shrink(29)"); + DASH_LOG_TRACE("GlobHeapMemTest.LocalVisibility", "shrink(29)"); gdmem.shrink(29); } if (dash::myid() == 1) { // marks bucket for detach: - DASH_LOG_TRACE("GlobHeapTest.LocalVisibility", "shrink(30)"); + DASH_LOG_TRACE("GlobHeapMemTest.LocalVisibility", "shrink(30)"); gdmem.shrink(30); } - DASH_LOG_TRACE("GlobHeapTest.LocalVisibility", + DASH_LOG_TRACE("GlobHeapMemTest.LocalVisibility", "commit, unbalanced detach"); gdmem.commit(); // Capacity changes have been published globally: @@ -444,7 +444,7 @@ TEST_F(GlobHeapTest, LocalVisibility) EXPECT_EQ(expected_global_capacity, gdmem.size()); } -TEST_F(GlobHeapTest, RemoteAccess) +TEST_F(GlobHeapMemTest, RemoteAccess) { typedef int value_t; @@ -492,7 +492,7 @@ TEST_F(GlobHeapTest, RemoteAccess) */ size_t initial_local_capacity = 10; size_t initial_global_capacity = dash::size() * initial_local_capacity; - dash::GlobHeap gdmem(initial_local_capacity); + dash::GlobHeapMem gdmem(initial_local_capacity); int unit_0_num_grow = 5; int unit_1_num_shrink = 2; @@ -506,11 +506,11 @@ TEST_F(GlobHeapTest, RemoteAccess) // Initialize values in local memory: auto lbegin = gdmem.lbegin(); - DASH_LOG_TRACE("GlobHeapTest.RemoteAccess", + DASH_LOG_TRACE("GlobHeapMemTest.RemoteAccess", "globmem.lbegin():", lbegin); for (size_t li = 0; li < gdmem.local_size(); ++li) { value_t value = (100 * (dash::myid() + 1)) + li; - DASH_LOG_TRACE("GlobHeapTest.RemoteAccess", + DASH_LOG_TRACE("GlobHeapMemTest.RemoteAccess", "local[", li, "] =", value); *(lbegin + li) = value; } @@ -529,7 +529,7 @@ TEST_F(GlobHeapTest, RemoteAccess) size_t nlocal_elem = gdmem.local_size(u); EXPECT_EQ_U(nlocal_expect, nlocal_elem); - DASH_LOG_DEBUG("GlobHeapTest.RemoteAccess", + DASH_LOG_DEBUG("GlobHeapMemTest.RemoteAccess", "requesting element from unit", u, "before commit,", "local capacity:", nlocal_elem); for (size_t lidx = 0; lidx < nlocal_elem; ++lidx) { @@ -562,7 +562,7 @@ TEST_F(GlobHeapTest, RemoteAccess) if (u == 1) { nlocal_expect -= unit_1_num_shrink; } EXPECT_EQ_U(nlocal_expect, nlocal_elem); - DASH_LOG_DEBUG("GlobHeapTest.RemoteAccess", + DASH_LOG_DEBUG("GlobHeapMemTest.RemoteAccess", "requesting element from unit", u, "after commit,", "local capacity:", nlocal_elem); for (size_t lidx = 0; lidx < nlocal_elem; ++lidx) { diff --git a/dash/test/memory/GlobHeapTest.h b/dash/test/memory/GlobHeapMemTest.h similarity index 51% rename from dash/test/memory/GlobHeapTest.h rename to dash/test/memory/GlobHeapMemTest.h index a77746faa..ea384e785 100644 --- a/dash/test/memory/GlobHeapTest.h +++ b/dash/test/memory/GlobHeapMemTest.h @@ -4,22 +4,22 @@ #include "../TestBase.h" /** - * Test fixture for class dash::GlobHeap + * Test fixture for class dash::GlobHeapMem */ -class GlobHeapTest : public dash::test::TestBase { +class GlobHeapMemTest : public dash::test::TestBase { protected: size_t _dash_id; size_t _dash_size; - GlobHeapTest() + GlobHeapMemTest() : _dash_id(0), _dash_size(0) { - LOG_MESSAGE(">>> Test suite: GlobHeapTest"); + LOG_MESSAGE(">>> Test suite: GlobHeapMemTest"); } - virtual ~GlobHeapTest() { - LOG_MESSAGE("<<< Closing test suite: GlobHeapTest"); + virtual ~GlobHeapMemTest() { + LOG_MESSAGE("<<< Closing test suite: GlobHeapMemTest"); } }; diff --git a/dash/test/memory/GlobStaticHeapTest.h b/dash/test/memory/GlobStaticHeapTest.h deleted file mode 100644 index fd7ffb73e..000000000 --- a/dash/test/memory/GlobStaticHeapTest.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef DASH__TEST__GLOBMEM_TEST_H_ -#define DASH__TEST__GLOBMEM_TEST_H_ - -#include "../TestBase.h" - -/** - * Test fixture for class dash::GlobStaticHeap - */ -class GlobStaticHeapTest : public dash::test::TestBase { -protected: - - GlobStaticHeapTest() { - LOG_MESSAGE(">>> Test suite: GlobStaticHeapTest"); - } - - virtual ~GlobStaticHeapTest() { - LOG_MESSAGE("<<< Closing test suite: GlobStaticHeapTest"); - } -}; - -#endif // DASH__TEST__GLOBMEM_TEST_H_ diff --git a/dash/test/memory/GlobStaticHeapTest.cc b/dash/test/memory/GlobStaticMemTest.cc similarity index 72% rename from dash/test/memory/GlobStaticHeapTest.cc rename to dash/test/memory/GlobStaticMemTest.cc index 48de1501c..1b9716b58 100644 --- a/dash/test/memory/GlobStaticHeapTest.cc +++ b/dash/test/memory/GlobStaticMemTest.cc @@ -1,15 +1,15 @@ -#include "GlobStaticHeapTest.h" +#include "GlobStaticMemTest.h" -#include +#include #include #include -TEST_F(GlobStaticHeapTest, ConstructorInitializerList) +TEST_F(GlobStaticMemTest, ConstructorInitializerList) { auto target_local_elements = { 1, 2, 3, 4, 5, 6 }; - auto target = dash::GlobStaticHeap(target_local_elements); + auto target = dash::GlobStaticMem(target_local_elements); std::vector glob_values; for (dash::team_unit_t u{0}; u < dash::size(); u++) { @@ -20,7 +20,7 @@ TEST_F(GlobStaticHeapTest, ConstructorInitializerList) } } for (auto val : glob_values) { - DASH_LOG_DEBUG_VAR("GlobStaticHeapTest.ConstructorInitializerList", val); + DASH_LOG_DEBUG_VAR("GlobStaticMemTest.ConstructorInitializerList", val); } int target_element; @@ -30,7 +30,7 @@ TEST_F(GlobStaticHeapTest, ConstructorInitializerList) } } -TEST_F(GlobStaticHeapTest, LocalBegin) +TEST_F(GlobStaticMemTest, LocalBegin) { auto target_local_elements = { 1, 2, 3, 4 }; @@ -42,7 +42,7 @@ TEST_F(GlobStaticHeapTest, LocalBegin) ? dash::Team::All() : dash::Team::All().split(2); - auto target = dash::GlobStaticHeap(target_local_elements, sub_team); + auto target = dash::GlobStaticMem(target_local_elements, sub_team); for (int l = 0; l < target_local_elements.size(); l++) { EXPECT_EQ_U(*(target_local_elements.begin() + l), target.lbegin()[l]); diff --git a/dash/test/memory/GlobStaticMemTest.h b/dash/test/memory/GlobStaticMemTest.h new file mode 100644 index 000000000..ed15faeb9 --- /dev/null +++ b/dash/test/memory/GlobStaticMemTest.h @@ -0,0 +1,21 @@ +#ifndef DASH__TEST__GLOBMEM_TEST_H_ +#define DASH__TEST__GLOBMEM_TEST_H_ + +#include "../TestBase.h" + +/** + * Test fixture for class dash::GlobStaticMem + */ +class GlobStaticMemTest : public dash::test::TestBase { +protected: + + GlobStaticMemTest() { + LOG_MESSAGE(">>> Test suite: GlobStaticMemTest"); + } + + virtual ~GlobStaticMemTest() { + LOG_MESSAGE("<<< Closing test suite: GlobStaticMemTest"); + } +}; + +#endif // DASH__TEST__GLOBMEM_TEST_H_ diff --git a/dash/test/memory/LocalAllocatorTest.h b/dash/test/memory/LocalAllocatorTest.h index c10cf81dd..de192c08e 100644 --- a/dash/test/memory/LocalAllocatorTest.h +++ b/dash/test/memory/LocalAllocatorTest.h @@ -13,7 +13,7 @@ class LocalAllocatorTest : public dash::test::TestBase { } virtual ~LocalAllocatorTest() { - LOG_MESSAGE("<<< Closing test suite: CollectiveAllocatorTest"); + LOG_MESSAGE("<<< Closing test suite: SymmetricAllocatorTest"); } }; diff --git a/dash/test/memory/CollectiveAllocatorTest.cc b/dash/test/memory/SymmetricAllocatorTest.cc similarity index 77% rename from dash/test/memory/CollectiveAllocatorTest.cc rename to dash/test/memory/SymmetricAllocatorTest.cc index 834e7c5ba..afd7153c2 100644 --- a/dash/test/memory/CollectiveAllocatorTest.cc +++ b/dash/test/memory/SymmetricAllocatorTest.cc @@ -1,28 +1,28 @@ -#include "CollectiveAllocatorTest.h" +#include "SymmetricAllocatorTest.h" -#include +#include #include #include #include -TEST_F(CollectiveAllocatorTest, Constructor) +TEST_F(SymmetricAllocatorTest, Constructor) { - auto target = dash::allocator::CollectiveAllocator(); + auto target = dash::allocator::SymmetricAllocator(); dart_gptr_t requested = target.allocate(sizeof(int) * 10); ASSERT_EQ(0, requested.unitid); ASSERT_EQ(DART_TEAM_ALL, requested.teamid); } -TEST_F(CollectiveAllocatorTest, TeamAlloc) +TEST_F(SymmetricAllocatorTest, TeamAlloc) { if (_dash_size < 2) { SKIP_TEST_MSG("Test case requires at least two units"); } dash::Team& subteam = dash::Team::All().split(2); - auto target = dash::allocator::CollectiveAllocator(subteam); + auto target = dash::allocator::SymmetricAllocator(subteam); dart_gptr_t requested = target.allocate(sizeof(int) * 10); // make sure the unitid in the gptr is @@ -31,10 +31,10 @@ TEST_F(CollectiveAllocatorTest, TeamAlloc) ASSERT_EQ(subteam.dart_id(), requested.teamid); } -TEST_F(CollectiveAllocatorTest, MoveAssignment) +TEST_F(SymmetricAllocatorTest, MoveAssignment) { using GlobPtr_t = dash::GlobConstPtr; - using Alloc_t = dash::allocator::CollectiveAllocator; + using Alloc_t = dash::allocator::SymmetricAllocator; GlobPtr_t gptr; Alloc_t target_new; @@ -63,10 +63,10 @@ TEST_F(CollectiveAllocatorTest, MoveAssignment) target_new.deallocate(gptr.dart_gptr()); } -TEST_F(CollectiveAllocatorTest, MoveCtor) +TEST_F(SymmetricAllocatorTest, MoveCtor) { using GlobPtr_t = dash::GlobConstPtr; - using Alloc_t = dash::allocator::CollectiveAllocator; + using Alloc_t = dash::allocator::SymmetricAllocator; GlobPtr_t gptr; Alloc_t target_new; diff --git a/dash/test/memory/CollectiveAllocatorTest.h b/dash/test/memory/SymmetricAllocatorTest.h similarity index 75% rename from dash/test/memory/CollectiveAllocatorTest.h rename to dash/test/memory/SymmetricAllocatorTest.h index 011cbad56..9937e21b5 100644 --- a/dash/test/memory/CollectiveAllocatorTest.h +++ b/dash/test/memory/SymmetricAllocatorTest.h @@ -4,9 +4,9 @@ #include "../TestBase.h" /** - * Test fixture for class dash::CollectiveAllocator + * Test fixture for class dash::SymmetricAllocator */ -class CollectiveAllocatorTest : public dash::test::TestBase { +class SymmetricAllocatorTest : public dash::test::TestBase { protected: size_t _dash_id = 0; size_t _dash_size = 0; From 567e4df60b103646c992094a04920a33012cd586 Mon Sep 17 00:00:00 2001 From: Tobias Fuchs Date: Sat, 18 Mar 2017 20:59:27 +0100 Subject: [PATCH 10/12] Moved memory space types to include dir dash/memory --- dash/examples/bench.04.histo/main.cpp | 2 +- dash/include/dash/Array.h | 2 +- dash/include/dash/GlobAsyncRef.h | 2 +- dash/include/dash/GlobPtr.h | 4 +- dash/include/dash/GlobRef.h | 2 +- dash/include/dash/GlobSharedRef.h | 2 +- dash/include/dash/Halo.h | 2 +- dash/include/dash/List.h | 2 +- dash/include/dash/Matrix.h | 2 +- dash/include/dash/Shared.h | 2 +- dash/include/dash/UnorderedMap.h | 2 +- dash/include/dash/experimental/Halo.h | 2 +- dash/include/dash/experimental/HaloMatrix.h | 2 +- .../experimental/iterator/GlobStencilIter.h | 2 +- dash/include/dash/iterator/GlobStencilIter.h | 2 +- dash/include/dash/iterator/GlobViewIter.h | 2 +- dash/include/dash/list/ListRef.h | 2 +- dash/include/dash/list/LocalListRef.h | 2 +- dash/include/dash/map/UnorderedMap.h | 2 +- .../include/dash/matrix/internal/Matrix-inl.h | 2 +- dash/include/dash/{ => memory}/GlobHeapMem.h | 0 .../include/dash/{ => memory}/GlobStaticMem.h | 4 +- .../{GlobUnitHeap.h => memory/GlobUnitMem.h} | 60 +++++++++---------- dash/include/libdash.h | 2 +- dash/test/dart/ThreadsafetyTest.cc | 2 +- dash/test/memory/GlobHeapMemTest.cc | 2 +- dash/test/memory/GlobStaticMemTest.cc | 2 +- 27 files changed, 57 insertions(+), 57 deletions(-) rename dash/include/dash/{ => memory}/GlobHeapMem.h (100%) rename dash/include/dash/{ => memory}/GlobStaticMem.h (99%) rename dash/include/dash/{GlobUnitHeap.h => memory/GlobUnitMem.h} (88%) diff --git a/dash/examples/bench.04.histo/main.cpp b/dash/examples/bench.04.histo/main.cpp index 4d542e48a..5b6803527 100644 --- a/dash/examples/bench.04.histo/main.cpp +++ b/dash/examples/bench.04.histo/main.cpp @@ -29,7 +29,7 @@ int main(int argc, char **argv) dash::Array key_array(NUM_KEYS, dash::BLOCKED); dash::Array key_histo(MAX_KEY, dash::BLOCKED); - using glob_ptr_t = dash::GlobPtr< int, dash::GlobUnitHeap >; + using glob_ptr_t = dash::GlobPtr< int, dash::GlobUnitMem >; dash::Array work_buffers(size, dash::CYCLIC); diff --git a/dash/include/dash/Array.h b/dash/include/dash/Array.h index 608430b57..04c74f7c1 100644 --- a/dash/include/dash/Array.h +++ b/dash/include/dash/Array.h @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/dash/include/dash/GlobAsyncRef.h b/dash/include/dash/GlobAsyncRef.h index 90e10dfab..f7e8b0686 100644 --- a/dash/include/dash/GlobAsyncRef.h +++ b/dash/include/dash/GlobAsyncRef.h @@ -3,7 +3,7 @@ #include #include -#include +#include #include diff --git a/dash/include/dash/GlobPtr.h b/dash/include/dash/GlobPtr.h index 77dad0a6b..785dc4ed7 100644 --- a/dash/include/dash/GlobPtr.h +++ b/dash/include/dash/GlobPtr.h @@ -135,7 +135,7 @@ class GlobPtr dart_gptr_t gptr) : _dart_gptr(gptr) // TODO: Should bind temporary, see dash::memalloc in - // dash/GlobUnitHeap.h + // dash/memory/GlobUnitMem.h , _mem_space(nullptr) { } @@ -569,7 +569,7 @@ std::ostream & operator<<( * * TODO: Will be replaced by specialization of GlobPtr for global * memory space tagged as unit-scope address space - * (see GlobUnitHeap). + * (see GlobUnitMem). */ template class GlobConstPtr diff --git a/dash/include/dash/GlobRef.h b/dash/include/dash/GlobRef.h index 92098d569..4cbfd9dd6 100644 --- a/dash/include/dash/GlobRef.h +++ b/dash/include/dash/GlobRef.h @@ -1,7 +1,7 @@ #ifndef DASH__GLOBREF_H_ #define DASH__GLOBREF_H_ -#include +#include #include #include diff --git a/dash/include/dash/GlobSharedRef.h b/dash/include/dash/GlobSharedRef.h index 39e2259ae..890bd386f 100644 --- a/dash/include/dash/GlobSharedRef.h +++ b/dash/include/dash/GlobSharedRef.h @@ -1,7 +1,7 @@ #ifndef DASH__GLOB_SHARED_EF_H_ #define DASH__GLOB_SHARED_EF_H_ -#include +#include #include #include diff --git a/dash/include/dash/Halo.h b/dash/include/dash/Halo.h index 993ea5cd0..dfc29beae 100644 --- a/dash/include/dash/Halo.h +++ b/dash/include/dash/Halo.h @@ -2,7 +2,7 @@ #define DASH__HALO_H__ #include -#include +#include #include diff --git a/dash/include/dash/List.h b/dash/include/dash/List.h index 8ddc0f09b..d046ad205 100644 --- a/dash/include/dash/List.h +++ b/dash/include/dash/List.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/dash/include/dash/Matrix.h b/dash/include/dash/Matrix.h index 119e1bad8..5f0ac68a9 100644 --- a/dash/include/dash/Matrix.h +++ b/dash/include/dash/Matrix.h @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/dash/include/dash/Shared.h b/dash/include/dash/Shared.h index 7e3912255..370d9149f 100644 --- a/dash/include/dash/Shared.h +++ b/dash/include/dash/Shared.h @@ -3,7 +3,7 @@ #include -#include +#include #include #include diff --git a/dash/include/dash/UnorderedMap.h b/dash/include/dash/UnorderedMap.h index 20608a581..918220e7f 100644 --- a/dash/include/dash/UnorderedMap.h +++ b/dash/include/dash/UnorderedMap.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include diff --git a/dash/include/dash/experimental/Halo.h b/dash/include/dash/experimental/Halo.h index 4dbc08ca1..daca7010f 100644 --- a/dash/include/dash/experimental/Halo.h +++ b/dash/include/dash/experimental/Halo.h @@ -1,7 +1,7 @@ #ifndef DASH__EXPERIMENTAL__HALO_H__ #define DASH__EXPERIMENTAL__HALO_H__ -#include +#include #include #include diff --git a/dash/include/dash/experimental/HaloMatrix.h b/dash/include/dash/experimental/HaloMatrix.h index 89c711f3f..9ed752cb3 100644 --- a/dash/include/dash/experimental/HaloMatrix.h +++ b/dash/include/dash/experimental/HaloMatrix.h @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include diff --git a/dash/include/dash/experimental/iterator/GlobStencilIter.h b/dash/include/dash/experimental/iterator/GlobStencilIter.h index f9115dd5f..2374bbb62 100644 --- a/dash/include/dash/experimental/iterator/GlobStencilIter.h +++ b/dash/include/dash/experimental/iterator/GlobStencilIter.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include diff --git a/dash/include/dash/iterator/GlobStencilIter.h b/dash/include/dash/iterator/GlobStencilIter.h index 5ae870bab..fea816b25 100644 --- a/dash/include/dash/iterator/GlobStencilIter.h +++ b/dash/include/dash/iterator/GlobStencilIter.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include diff --git a/dash/include/dash/iterator/GlobViewIter.h b/dash/include/dash/iterator/GlobViewIter.h index e4212526c..b83e88c31 100644 --- a/dash/include/dash/iterator/GlobViewIter.h +++ b/dash/include/dash/iterator/GlobViewIter.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include diff --git a/dash/include/dash/list/ListRef.h b/dash/include/dash/list/ListRef.h index 1207b151f..b0482cf8a 100644 --- a/dash/include/dash/list/ListRef.h +++ b/dash/include/dash/list/ListRef.h @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include diff --git a/dash/include/dash/list/LocalListRef.h b/dash/include/dash/list/LocalListRef.h index 0b81195f5..4462acb6e 100644 --- a/dash/include/dash/list/LocalListRef.h +++ b/dash/include/dash/list/LocalListRef.h @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include diff --git a/dash/include/dash/map/UnorderedMap.h b/dash/include/dash/map/UnorderedMap.h index fc1711ca5..cdd252554 100644 --- a/dash/include/dash/map/UnorderedMap.h +++ b/dash/include/dash/map/UnorderedMap.h @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include diff --git a/dash/include/dash/matrix/internal/Matrix-inl.h b/dash/include/dash/matrix/internal/Matrix-inl.h index 310a9cfe2..3915ef280 100644 --- a/dash/include/dash/matrix/internal/Matrix-inl.h +++ b/dash/include/dash/matrix/internal/Matrix-inl.h @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include #include diff --git a/dash/include/dash/GlobHeapMem.h b/dash/include/dash/memory/GlobHeapMem.h similarity index 100% rename from dash/include/dash/GlobHeapMem.h rename to dash/include/dash/memory/GlobHeapMem.h diff --git a/dash/include/dash/GlobStaticMem.h b/dash/include/dash/memory/GlobStaticMem.h similarity index 99% rename from dash/include/dash/GlobStaticMem.h rename to dash/include/dash/memory/GlobStaticMem.h index 949f4cce4..d057959b6 100644 --- a/dash/include/dash/GlobStaticMem.h +++ b/dash/include/dash/memory/GlobStaticMem.h @@ -525,12 +525,12 @@ void memfree(GlobPtrT gptr) { // TODO: Should notify GlobPtrT instance gptr of this deallocation // as it might be owner of its referenced global memory space - // (see GlobUnitHeap). + // (see GlobUnitMem). dart_memfree(gptr.dart_gptr()); } } // namespace dash -#include +#include #endif // DASH__GLOB_STATIC_HEAP_H__INCLUDED diff --git a/dash/include/dash/GlobUnitHeap.h b/dash/include/dash/memory/GlobUnitMem.h similarity index 88% rename from dash/include/dash/GlobUnitHeap.h rename to dash/include/dash/memory/GlobUnitMem.h index 61d120c28..eb8b85588 100644 --- a/dash/include/dash/GlobUnitHeap.h +++ b/dash/include/dash/memory/GlobUnitMem.h @@ -25,10 +25,10 @@ template< /// deallocate physical memory class AllocatorType = dash::allocator::LocalAllocator > -class GlobUnitHeap +class GlobUnitMem { private: - typedef GlobUnitHeap + typedef GlobUnitMem self_t; public: @@ -66,10 +66,10 @@ class GlobUnitHeap public: /** - * Constructor, creates instance of GlobUnitHeap with pre-allocated + * Constructor, creates instance of GlobUnitMem with pre-allocated * memory space. */ - GlobUnitHeap( + GlobUnitMem( dart_gptr_t gbegin, /// Number of local elements to allocate in global memory space size_type n_local_elem, @@ -83,13 +83,13 @@ class GlobUnitHeap _myid(team.myid()), _nlelem(n_local_elem) { - DASH_LOG_TRACE("GlobUnitHeap(gbegin,nlocal,team)", + DASH_LOG_TRACE("GlobUnitMem(gbegin,nlocal,team)", "preallocated at:", _begptr, "number of local values:", _nlelem, "team size:", team.size()); update_lbegin(); update_lend(); - DASH_LOG_TRACE("GlobUnitHeap(gbegin,nlocal,team) >"); + DASH_LOG_TRACE("GlobUnitMem(gbegin,nlocal,team) >"); } /** @@ -101,7 +101,7 @@ class GlobUnitHeap * For example, \c dash::LocalAllocator is used in \c dash::Shared * and only called at owner unit. */ - explicit GlobUnitHeap( + explicit GlobUnitMem( /// Number of local elements to allocate in global memory space size_type n_local_elem, /// Team containing all units operating on the global memory region @@ -113,7 +113,7 @@ class GlobUnitHeap _myid(team.myid()), _nlelem(n_local_elem) { - DASH_LOG_TRACE("GlobUnitHeap(nlocal,team)", + DASH_LOG_TRACE("GlobUnitMem(nlocal,team)", "number of local values:", _nlelem, "team size:", team.size()); _begptr = _allocator.allocate(_nlelem); @@ -122,7 +122,7 @@ class GlobUnitHeap // Use id's of team all update_lbegin(); update_lend(); - DASH_LOG_TRACE("GlobUnitHeap(nlocal,team) >"); + DASH_LOG_TRACE("GlobUnitMem(nlocal,team) >"); } /** @@ -134,7 +134,7 @@ class GlobUnitHeap * For example, \c dash::LocalAllocator is used in \c dash::Shared * and only called at owner unit. */ - explicit GlobUnitHeap( + explicit GlobUnitMem( /// Local elements to allocate in global memory space std::initializer_list local_elements, /// Team containing all units operating on the global memory region @@ -146,7 +146,7 @@ class GlobUnitHeap _myid(team.myid()), _nlelem(local_elements.size()) { - DASH_LOG_DEBUG("GlobUnitHeap(lvals,team)", + DASH_LOG_DEBUG("GlobUnitMem(lvals,team)", "number of local values:", _nlelem, "team size:", team.size()); _begptr = _allocator.allocate(_nlelem); @@ -173,28 +173,28 @@ class GlobUnitHeap // // TODO: Should depend on allocator trait // dash::allocator_traits::is_collective() - DASH_LOG_DEBUG("GlobUnitHeap(lvals,team)", "barrier"); + DASH_LOG_DEBUG("GlobUnitMem(lvals,team)", "barrier"); barrier(); } - DASH_LOG_DEBUG("GlobUnitHeap(lvals,team) >", + DASH_LOG_DEBUG("GlobUnitMem(lvals,team) >", "_lbegin:", _lbegin, "_lend:", _lend); } /** * Destructor, collectively frees underlying global memory. */ - ~GlobUnitHeap() + ~GlobUnitMem() { - DASH_LOG_TRACE_VAR("GlobUnitHeap.~GlobUnitHeap()", _begptr); + DASH_LOG_TRACE_VAR("GlobUnitMem.~GlobUnitMem()", _begptr); _allocator.deallocate(_begptr); - DASH_LOG_TRACE("GlobUnitHeap.~GlobUnitHeap >"); + DASH_LOG_TRACE("GlobUnitMem.~GlobUnitMem >"); } /** * Copy constructor. */ - GlobUnitHeap(const self_t & other) + GlobUnitMem(const self_t & other) = default; /** @@ -271,7 +271,7 @@ class GlobUnitHeap /** * Native pointer of the initial address of the local memory of - * the unit that initialized this GlobUnitHeap instance. + * the unit that initialized this GlobUnitMem instance. */ constexpr const_local_pointer lbegin() const noexcept { @@ -280,7 +280,7 @@ class GlobUnitHeap /** * Native pointer of the initial address of the local memory of - * the unit that initialized this GlobUnitHeap instance. + * the unit that initialized this GlobUnitMem instance. */ inline local_pointer lbegin() noexcept { @@ -289,7 +289,7 @@ class GlobUnitHeap /** * Native pointer of the initial address of the local memory of - * the unit that initialized this GlobUnitHeap instance. + * the unit that initialized this GlobUnitMem instance. */ constexpr const_local_pointer lend() const noexcept { @@ -298,7 +298,7 @@ class GlobUnitHeap /** * Native pointer of the initial address of the local memory of - * the unit that initialized this GlobUnitHeap instance. + * the unit that initialized this GlobUnitMem instance. */ inline local_pointer lend() noexcept { @@ -315,7 +315,7 @@ class GlobUnitHeap const ValueType & newval, index_type global_index) { - DASH_LOG_TRACE("GlobUnitHeap.put_value(newval, gidx = %d)", global_index); + DASH_LOG_TRACE("GlobUnitMem.put_value(newval, gidx = %d)", global_index); dash::put_value(newval, GlobPtr( *this, _begptr @@ -332,7 +332,7 @@ class GlobUnitHeap ValueType * ptr, index_type global_index) const { - DASH_LOG_TRACE("GlobUnitHeap.get_value(newval, gidx = %d)", global_index); + DASH_LOG_TRACE("GlobUnitMem.get_value(newval, gidx = %d)", global_index); dash::get_value(ptr, GlobPtr( *this, _begptr @@ -388,14 +388,14 @@ class GlobUnitHeap /// The unit's local address offset IndexType local_index) const { - DASH_LOG_DEBUG("GlobUnitHeap.at(unit,l_idx)", unit, local_index); + DASH_LOG_DEBUG("GlobUnitMem.at(unit,l_idx)", unit, local_index); if (_nunits == 0 || DART_GPTR_ISNULL(_begptr)) { - DASH_LOG_ERROR("GlobUnitHeap.at(unit,l_idx) >", + DASH_LOG_ERROR("GlobUnitMem.at(unit,l_idx) >", "global memory not allocated"); return pointer(nullptr); } if (unit.id != _begptr.unitid) { - DASH_LOG_ERROR("GlobUnitHeap.at(unit,l_idx) >", + DASH_LOG_ERROR("GlobUnitMem.at(unit,l_idx) >", "address in global unit memory requested for", unit, "but only allocated at unit", _begptr.unitid); return pointer(nullptr); @@ -405,7 +405,7 @@ class GlobUnitHeap // Apply local offset to global pointer: pointer res_gptr(*this, gptr); res_gptr += local_index; - DASH_LOG_DEBUG("GlobUnitHeap.at (+g_unit) >", res_gptr); + DASH_LOG_DEBUG("GlobUnitMem.at (+g_unit) >", res_gptr); return res_gptr; } @@ -419,7 +419,7 @@ class GlobUnitHeap { void *addr; dart_gptr_t gptr = _begptr; - DASH_LOG_TRACE_VAR("GlobUnitHeap.update_lbegin", + DASH_LOG_TRACE_VAR("GlobUnitMem.update_lbegin", pointer(*this, gptr)); DASH_ASSERT_RETURNS( dart_gptr_setunit(&gptr, _myid), @@ -427,7 +427,7 @@ class GlobUnitHeap DASH_ASSERT_RETURNS( dart_gptr_getaddr(gptr, &addr), DART_OK); - DASH_LOG_TRACE_VAR("GlobUnitHeap.update_lbegin >", addr); + DASH_LOG_TRACE_VAR("GlobUnitMem.update_lbegin >", addr); _lbegin = static_cast(addr); } @@ -454,7 +454,7 @@ class GlobUnitHeap template< typename T, - class MemSpaceT = dash::GlobUnitHeap > + class MemSpaceT = dash::GlobUnitMem > GlobPtr memalloc(size_t nelem) { dart_gptr_t gptr; diff --git a/dash/include/libdash.h b/dash/include/libdash.h index 1ac267cee..f06a7b40d 100644 --- a/dash/include/libdash.h +++ b/dash/include/libdash.h @@ -27,7 +27,7 @@ namespace dash { #include #include -#include +#include #include #include #include diff --git a/dash/test/dart/ThreadsafetyTest.cc b/dash/test/dart/ThreadsafetyTest.cc index 3e01c77c6..aadc2a665 100644 --- a/dash/test/dart/ThreadsafetyTest.cc +++ b/dash/test/dart/ThreadsafetyTest.cc @@ -220,7 +220,7 @@ TEST_F(ThreadsafetyTest, ConcurrentAttach) { TEST_F(ThreadsafetyTest, ConcurrentMemAlloc) { using elem_t = int; - using pointer_t = dash::GlobPtr< elem_t, dash::GlobUnitHeap >; + using pointer_t = dash::GlobPtr< elem_t, dash::GlobUnitMem >; if (!dash::is_multithreaded()) { SKIP_TEST_MSG("requires support for multi-threading"); diff --git a/dash/test/memory/GlobHeapMemTest.cc b/dash/test/memory/GlobHeapMemTest.cc index 80c3124a1..0faae5516 100644 --- a/dash/test/memory/GlobHeapMemTest.cc +++ b/dash/test/memory/GlobHeapMemTest.cc @@ -1,7 +1,7 @@ #include "GlobHeapMemTest.h" -#include +#include TEST_F(GlobHeapMemTest, BalancedAlloc) diff --git a/dash/test/memory/GlobStaticMemTest.cc b/dash/test/memory/GlobStaticMemTest.cc index 1b9716b58..c426cc03b 100644 --- a/dash/test/memory/GlobStaticMemTest.cc +++ b/dash/test/memory/GlobStaticMemTest.cc @@ -1,7 +1,7 @@ #include "GlobStaticMemTest.h" -#include +#include #include #include From ec9fb2af69864f5bf87ca37d3508f424241996c1 Mon Sep 17 00:00:00 2001 From: Tobias Fuchs Date: Sat, 18 Mar 2017 21:03:52 +0100 Subject: [PATCH 11/12] Added dash/Memory.h --- dash/include/dash/Memory.h | 8 ++++++++ dash/include/libdash.h | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 dash/include/dash/Memory.h diff --git a/dash/include/dash/Memory.h b/dash/include/dash/Memory.h new file mode 100644 index 000000000..d12120efe --- /dev/null +++ b/dash/include/dash/Memory.h @@ -0,0 +1,8 @@ +#ifndef DASH__MEMORY_H__INCLUDED +#define DASH__MEMORY_H__INCLUDED + +#include +#include +#include + +#endif // DASH__MEMORY_H__INCLUDED diff --git a/dash/include/libdash.h b/dash/include/libdash.h index f06a7b40d..37c3cc63a 100644 --- a/dash/include/libdash.h +++ b/dash/include/libdash.h @@ -27,7 +27,9 @@ namespace dash { #include #include -#include +#include +#include + #include #include #include @@ -41,7 +43,6 @@ namespace dash { #include #include #include -#include #include #include From 5749b1c0bfa8c06cb059c09e3627a8ad839bc2dd Mon Sep 17 00:00:00 2001 From: Tobias Fuchs Date: Thu, 23 Mar 2017 12:24:43 +0100 Subject: [PATCH 12/12] Fixed zealot type renamings --- dash/include/dash/Array.h | 2 +- dash/include/dash/allocator/GlobBucketIter.h | 32 ++++++++-------- .../dash/allocator/internal/GlobBucketIter.h | 38 +++++++++---------- .../experimental/iterator/GlobStencilIter.h | 16 ++++---- dash/include/dash/iterator/GlobIter.h | 24 ++++++------ dash/include/dash/iterator/GlobStencilIter.h | 16 ++++---- dash/include/dash/iterator/GlobViewIter.h | 30 +++++++-------- dash/include/dash/list/GlobListIter.h | 14 +++---- 8 files changed, 86 insertions(+), 86 deletions(-) diff --git a/dash/include/dash/Array.h b/dash/include/dash/Array.h index 04c74f7c1..ac04e83e9 100644 --- a/dash/include/dash/Array.h +++ b/dash/include/dash/Array.h @@ -621,7 +621,7 @@ class ArrayRef * \concept{DashArrayConcept} * * \todo Add template parameter: - * class GlobStaticMemType = dash::GlobStaticMem + * class GlobMemType = dash::GlobStaticMem * * \note: Template parameter IndexType could be deduced from pattern * type PatternT::index_type diff --git a/dash/include/dash/allocator/GlobBucketIter.h b/dash/include/dash/allocator/GlobBucketIter.h index 0c879358d..7df872cb8 100644 --- a/dash/include/dash/allocator/GlobBucketIter.h +++ b/dash/include/dash/allocator/GlobBucketIter.h @@ -36,37 +36,37 @@ class GlobHeapMem; */ template< typename ElementType, - class GlobStaticMemType, + class GlobMemType, class PointerType = dash::GlobPtr, class ReferenceType = dash::GlobSharedRef > class GlobBucketIter : public std::iterator< std::random_access_iterator_tag, ElementType, - typename GlobStaticMemType::index_type, + typename GlobMemType::index_type, PointerType, ReferenceType > { template< typename ElementType_, - class GlobStaticMemType_, + class GlobMemType_, class Pointer_, class Reference_> friend std::ostream & dash::operator<<( std::ostream & os, const dash::GlobBucketIter< - ElementType_, GlobStaticMemType_, Pointer_, Reference_> & it); + ElementType_, GlobMemType_, Pointer_, Reference_> & it); private: typedef GlobBucketIter< ElementType, - GlobStaticMemType, + GlobMemType, PointerType, ReferenceType> self_t; public: - typedef typename GlobStaticMemType::index_type index_type; + typedef typename GlobMemType::index_type index_type; typedef typename std::make_unsigned::type size_type; typedef ElementType value_type; @@ -80,16 +80,16 @@ class GlobBucketIter typedef typename std::conditional< std::is_const::value, - const GlobStaticMemType, - GlobStaticMemType + const GlobMemType, + GlobMemType >::type globmem_type; typedef typename std::conditional< std::is_const::value, - typename GlobStaticMemType::const_local_pointer, - typename GlobStaticMemType::local_pointer + typename GlobMemType::const_local_pointer, + typename GlobMemType::local_pointer >::type local_pointer; @@ -693,30 +693,30 @@ class GlobBucketIter */ template< typename ElementType, - class GlobStaticMemType, + class GlobMemType, class Pointer, class Reference> auto distance( /// Global iterator to the first position in the global sequence const dash::GlobBucketIter< - ElementType, GlobStaticMemType, Pointer, Reference> & first, + ElementType, GlobMemType, Pointer, Reference> & first, /// Global iterator to the final position in the global sequence const dash::GlobBucketIter< - ElementType, GlobStaticMemType, Pointer, Reference> & last) --> typename GlobStaticMemType::index_type + ElementType, GlobMemType, Pointer, Reference> & last) +-> typename GlobMemType::index_type { return last - first; } template< typename ElementType, - class GlobStaticMemType, + class GlobMemType, class Pointer, class Reference> std::ostream & operator<<( std::ostream & os, const dash::GlobBucketIter< - ElementType, GlobStaticMemType, Pointer, Reference> & it) + ElementType, GlobMemType, Pointer, Reference> & it) { std::ostringstream ss; ss << "dash::GlobBucketIter<" diff --git a/dash/include/dash/allocator/internal/GlobBucketIter.h b/dash/include/dash/allocator/internal/GlobBucketIter.h index c3c5c2ffa..b37982b73 100644 --- a/dash/include/dash/allocator/internal/GlobBucketIter.h +++ b/dash/include/dash/allocator/internal/GlobBucketIter.h @@ -36,37 +36,37 @@ namespace internal { */ template< typename ElementType, - class GlobStaticMemType, + class GlobMemType, class PointerType = dash::GlobPtr, class ReferenceType = dash::GlobRef > class GlobBucketIter : public std::iterator< std::random_access_iterator_tag, ElementType, - typename GlobStaticMemType::index_type, + typename GlobMemType::index_type, PointerType, ReferenceType > { template< typename ElementType_, - class GlobStaticMemType_, + class GlobMemType_, class Pointer_, class Reference_> friend std::ostream & dash::operator<<( std::ostream & os, const dash::internal::GlobBucketIter< - ElementType_, GlobStaticMemType_, Pointer_, Reference_> & it); + ElementType_, GlobMemType_, Pointer_, Reference_> & it); private: typedef GlobBucketIter< ElementType, - GlobStaticMemType, + GlobMemType, PointerType, ReferenceType> self_t; public: - typedef typename GlobStaticMemType::index_type index_type; + typedef typename GlobMemType::index_type index_type; typedef typename std::make_unsigned::type size_type; typedef ElementType value_type; @@ -78,8 +78,8 @@ class GlobBucketIter typedef typename std::conditional< std::is_const::value, - typename GlobStaticMemType::const_local_pointer, - typename GlobStaticMemType::local_pointer + typename GlobMemType::const_local_pointer, + typename GlobMemType::local_pointer >::type local_pointer; @@ -116,7 +116,7 @@ class GlobBucketIter * offset in logical storage order. */ GlobBucketIter( - GlobStaticMemType * gmem, + GlobMemType * gmem, index_type position = 0) : _globmem(gmem), _bucket_cumul_sizes(&_globmem->_bucket_cumul_sizes), @@ -158,7 +158,7 @@ class GlobBucketIter * local offset in logical storage order. */ GlobBucketIter( - GlobStaticMemType * gmem, + GlobMemType * gmem, team_unit_t unit, index_type local_index) : _globmem(gmem), @@ -314,7 +314,7 @@ class GlobBucketIter * The instance of \c GlobStaticMem used by this iterator to resolve addresses * in global memory. */ - inline const GlobStaticMemType & globmem() const + inline const GlobMemType & globmem() const { return *_globmem; } @@ -323,7 +323,7 @@ class GlobBucketIter * The instance of \c GlobStaticMem used by this iterator to resolve addresses * in global memory. */ - inline GlobStaticMemType & globmem() + inline GlobMemType & globmem() { return *_globmem; } @@ -594,7 +594,7 @@ class GlobBucketIter private: /// Global memory used to dereference iterated values. - GlobStaticMemType * _globmem = nullptr; + GlobMemType * _globmem = nullptr; /// Mapping unit id to buckets in the unit's attached local storage. bucket_cumul_sizes_map * _bucket_cumul_sizes = nullptr; /// Pointer to first element in local data space. @@ -625,17 +625,17 @@ class GlobBucketIter */ template< typename ElementType, - class GlobStaticMemType, + class GlobMemType, class Pointer, class Reference> auto distance( /// Global iterator to the first position in the global sequence const dash::internal::GlobBucketIter< - ElementType, GlobStaticMemType, Pointer, Reference> & first, + ElementType, GlobMemType, Pointer, Reference> & first, /// Global iterator to the final position in the global sequence const dash::internal::GlobBucketIter< - ElementType, GlobStaticMemType, Pointer, Reference> & last) --> typename GlobStaticMemType::index_type + ElementType, GlobMemType, Pointer, Reference> & last) +-> typename GlobMemType::index_type { return last - first; } @@ -644,13 +644,13 @@ auto distance( template< typename ElementType, - class GlobStaticMemType, + class GlobMemType, class Pointer, class Reference> std::ostream & operator<<( std::ostream & os, const dash::internal::GlobBucketIter< - ElementType, GlobStaticMemType, Pointer, Reference> & it) + ElementType, GlobMemType, Pointer, Reference> & it) { std::ostringstream ss; ss << "dash::internal::GlobBucketIter<" diff --git a/dash/include/dash/experimental/iterator/GlobStencilIter.h b/dash/include/dash/experimental/iterator/GlobStencilIter.h index 2374bbb62..38a798adf 100644 --- a/dash/include/dash/experimental/iterator/GlobStencilIter.h +++ b/dash/include/dash/experimental/iterator/GlobStencilIter.h @@ -125,7 +125,7 @@ class IteratorHalo template< typename ElementType, class PatternType, - class GlobStaticMemType = GlobStaticMem, + class GlobMemType = GlobStaticMem, class PointerType = GlobPtr, class ReferenceType = GlobRef > class GlobStencilIter @@ -144,7 +144,7 @@ class GlobStencilIter typedef GlobStencilIter< ElementType, PatternType, - GlobStaticMemType, + GlobMemType, PointerType, ReferenceType> self_t; @@ -191,7 +191,7 @@ class GlobStencilIter protected: /// Global memory used to dereference iterated values. - GlobStaticMemType * _globmem = nullptr; + GlobMemType * _globmem = nullptr; /// Pattern that specifies the iteration order (access pattern). const PatternType * _pattern = nullptr; /// View that specifies the iterator's index range relative to the global @@ -233,7 +233,7 @@ class GlobStencilIter * the element order specified by the given pattern and view spec. */ GlobStencilIter( - GlobStaticMemType * gmem, + GlobMemType * gmem, const PatternType & pat, const ViewSpecType & viewspec, const HaloSpecType & halospec, @@ -261,7 +261,7 @@ class GlobStencilIter * the element order specified by the given pattern and view spec. */ GlobStencilIter( - GlobStaticMemType * gmem, + GlobMemType * gmem, const PatternType & pat, const HaloSpecType & halospec, IndexType position = 0, @@ -315,7 +315,7 @@ class GlobStencilIter GlobStencilIter( const GlobViewIter & other, const HaloSpecType & halospec) @@ -850,7 +850,7 @@ class GlobStencilIter * * \see DashGlobalIteratorConcept */ - inline const GlobStaticMemType & globmem() const + inline const GlobMemType & globmem() const { return *_globmem; } @@ -861,7 +861,7 @@ class GlobStencilIter * * \see DashGlobalIteratorConcept */ - inline GlobStaticMemType & globmem() + inline GlobMemType & globmem() { return *_globmem; } diff --git a/dash/include/dash/iterator/GlobIter.h b/dash/include/dash/iterator/GlobIter.h index 16e4be5f5..38a1c640c 100644 --- a/dash/include/dash/iterator/GlobIter.h +++ b/dash/include/dash/iterator/GlobIter.h @@ -16,7 +16,7 @@ namespace dash { template< typename ElementType, class PatternType, - class GlobStaticMemType, + class GlobMemType, class PointerType, class ReferenceType > class GlobStencilIter; @@ -24,7 +24,7 @@ class GlobStencilIter; template< typename ElementType, class PatternType, - class GlobStaticMemType, + class GlobMemType, class PointerType, class ReferenceType > class GlobViewIter; @@ -56,10 +56,10 @@ class GlobViewIter; template< typename ElementType, class PatternType, - class GlobStaticMemType = GlobStaticMem< + class GlobMemType = GlobStaticMem< typename std::decay::type >, - class PointerType = typename GlobStaticMemType::pointer, + class PointerType = typename GlobMemType::pointer, class ReferenceType = GlobRef > class GlobIter : public std::iterator< @@ -73,7 +73,7 @@ class GlobIter typedef GlobIter< ElementType, PatternType, - GlobStaticMemType, + GlobMemType, PointerType, ReferenceType> self_t; @@ -89,8 +89,8 @@ class GlobIter typedef PointerType pointer; typedef typename PointerType::const_type const_pointer; - typedef typename GlobStaticMemType::local_pointer local_pointer; - typedef typename GlobStaticMemType::local_pointer local_type; + typedef typename GlobMemType::local_pointer local_pointer; + typedef typename GlobMemType::local_pointer local_type; typedef PatternType pattern_type; typedef typename PatternType::index_type index_type; @@ -99,7 +99,7 @@ class GlobIter typedef GlobIter< const ElementType, PatternType, - GlobStaticMemType, + GlobMemType, const_pointer, const_reference > self_const_t; @@ -152,7 +152,7 @@ class GlobIter protected: /// Global memory used to dereference iterated values. - GlobStaticMemType * _globmem; + GlobMemType * _globmem; /// Pattern that specifies the iteration order (access pattern). const PatternType * _pattern; /// Current position of the iterator in global canonical index space. @@ -182,7 +182,7 @@ class GlobIter * the element order specified by the given pattern. */ constexpr GlobIter( - GlobStaticMemType * gmem, + GlobMemType * gmem, const PatternType & pat, index_type position = 0) : _globmem(gmem), @@ -566,7 +566,7 @@ class GlobIter * The instance of \c GlobStaticMem used by this iterator to resolve addresses * in global memory. */ - constexpr const GlobStaticMemType & globmem() const noexcept + constexpr const GlobMemType & globmem() const noexcept { return *_globmem; } @@ -575,7 +575,7 @@ class GlobIter * The instance of \c GlobStaticMem used by this iterator to resolve addresses * in global memory. */ - inline GlobStaticMemType & globmem() + inline GlobMemType & globmem() { return *_globmem; } diff --git a/dash/include/dash/iterator/GlobStencilIter.h b/dash/include/dash/iterator/GlobStencilIter.h index fea816b25..91bbb71b0 100644 --- a/dash/include/dash/iterator/GlobStencilIter.h +++ b/dash/include/dash/iterator/GlobStencilIter.h @@ -121,7 +121,7 @@ class IteratorHalo template< typename ElementType, class PatternType, - class GlobStaticMemType = GlobStaticMem, + class GlobMemType = GlobStaticMem, class PointerType = GlobPtr, class ReferenceType = GlobRef > class GlobStencilIter @@ -140,7 +140,7 @@ class GlobStencilIter typedef GlobStencilIter< ElementType, PatternType, - GlobStaticMemType, + GlobMemType, PointerType, ReferenceType> self_t; @@ -187,7 +187,7 @@ class GlobStencilIter protected: /// Global memory used to dereference iterated values. - GlobStaticMemType * _globmem = nullptr; + GlobMemType * _globmem = nullptr; /// Pattern that specifies the iteration order (access pattern). const PatternType * _pattern = nullptr; /// View that specifies the iterator's index range relative to the global @@ -229,7 +229,7 @@ class GlobStencilIter * the element order specified by the given pattern and view spec. */ GlobStencilIter( - GlobStaticMemType * gmem, + GlobMemType * gmem, const PatternType & pat, const ViewSpecType & viewspec, const HaloSpecType & halospec, @@ -257,7 +257,7 @@ class GlobStencilIter * the element order specified by the given pattern and view spec. */ GlobStencilIter( - GlobStaticMemType * gmem, + GlobMemType * gmem, const PatternType & pat, const HaloSpecType & halospec, IndexType position = 0, @@ -311,7 +311,7 @@ class GlobStencilIter GlobStencilIter( const GlobViewIter & other, const HaloSpecType & halospec) @@ -846,7 +846,7 @@ class GlobStencilIter * * \see DashGlobalIteratorConcept */ - inline const GlobStaticMemType & globmem() const + inline const GlobMemType & globmem() const { return *_globmem; } @@ -857,7 +857,7 @@ class GlobStencilIter * * \see DashGlobalIteratorConcept */ - inline GlobStaticMemType & globmem() + inline GlobMemType & globmem() { return *_globmem; } diff --git a/dash/include/dash/iterator/GlobViewIter.h b/dash/include/dash/iterator/GlobViewIter.h index b83e88c31..e568719aa 100644 --- a/dash/include/dash/iterator/GlobViewIter.h +++ b/dash/include/dash/iterator/GlobViewIter.h @@ -21,7 +21,7 @@ namespace dash { template< typename ElementType, class PatternType, - class GlobStaticMemType, + class GlobMemType, class PointerType, class ReferenceType > class GlobIter; @@ -29,7 +29,7 @@ class GlobIter; template< typename ElementType, class PatternType, - class GlobStaticMemType, + class GlobMemType, class PointerType, class ReferenceType > class GlobStencilIter; @@ -43,10 +43,10 @@ class GlobStencilIter; template< typename ElementType, class PatternType, - class GlobStaticMemType = GlobStaticMem< + class GlobMemType = GlobStaticMem< typename std::decay::type >, - class PointerType = typename GlobStaticMemType::pointer, + class PointerType = typename GlobMemType::pointer, class ReferenceType = GlobRef > class GlobViewIter : public std::iterator< @@ -59,7 +59,7 @@ class GlobViewIter typedef GlobViewIter< ElementType, PatternType, - GlobStaticMemType, + GlobMemType, PointerType, ReferenceType> self_t; @@ -67,7 +67,7 @@ class GlobViewIter typedef GlobIter< ElementType, PatternType, - GlobStaticMemType, + GlobMemType, PointerType, ReferenceType> global_type; @@ -75,7 +75,7 @@ class GlobViewIter typedef GlobIter< const ElementType, PatternType, - GlobStaticMemType, + GlobMemType, PointerType, ReferenceType> const_global_type; @@ -97,8 +97,8 @@ class GlobViewIter typedef PointerType pointer; typedef typename PointerType::const_type const_pointer; - typedef typename GlobStaticMemType::local_pointer local_pointer; - typedef typename GlobStaticMemType::local_pointer local_type; + typedef typename GlobMemType::local_pointer local_pointer; + typedef typename GlobMemType::local_pointer local_type; typedef PatternType pattern_type; typedef typename PatternType::index_type index_type; @@ -107,7 +107,7 @@ class GlobViewIter typedef GlobViewIter< const ElementType, PatternType, - GlobStaticMemType, + GlobMemType, const_pointer, const_reference > self_const_t; @@ -158,7 +158,7 @@ class GlobViewIter protected: /// Global memory used to dereference iterated values. - GlobStaticMemType * _globmem; + GlobMemType * _globmem; /// Pattern that specifies the iteration order (access pattern). const PatternType * _pattern; /// View that specifies the iterator's index range relative to the global @@ -201,7 +201,7 @@ class GlobViewIter const ViewSpecType & viewspec, IndexType position = 0, IndexType view_index_offset = 0) - : _globmem(reinterpret_cast(gmem)) + : _globmem(reinterpret_cast(gmem)) , _pattern(&pat) , _viewspec(&viewspec) , _idx(position) @@ -221,7 +221,7 @@ class GlobViewIter const PatternType & pat, IndexType position = 0, IndexType view_index_offset = 0) - : _globmem(reinterpret_cast(gmem)) + : _globmem(reinterpret_cast(gmem)) , _pattern(&pat) , _viewspec(nullptr) , _idx(position) @@ -752,7 +752,7 @@ class GlobViewIter * The instance of \c GlobStaticMem used by this iterator to resolve addresses * in global memory. */ - constexpr const GlobStaticMemType & globmem() const noexcept + constexpr const GlobMemType & globmem() const noexcept { return *_globmem; } @@ -761,7 +761,7 @@ class GlobViewIter * The instance of \c GlobStaticMem used by this iterator to resolve addresses * in global memory. */ - inline GlobStaticMemType & globmem() noexcept + inline GlobMemType & globmem() noexcept { return *_globmem; } diff --git a/dash/include/dash/list/GlobListIter.h b/dash/include/dash/list/GlobListIter.h index 5681336c3..15ef3c8e2 100644 --- a/dash/include/dash/list/GlobListIter.h +++ b/dash/include/dash/list/GlobListIter.h @@ -19,7 +19,7 @@ namespace dash { */ template< typename ElementType, - class GlobStaticMemType, + class GlobMemType, class PointerType = GlobPtr, class ReferenceType = GlobRef > class GlobListIter @@ -33,7 +33,7 @@ class GlobListIter private: typedef GlobListIter< ElementType, - GlobStaticMemType, + GlobMemType, PointerType, ReferenceType> self_t; @@ -45,7 +45,7 @@ class GlobListIter typedef PointerType pointer; typedef const PointerType const_pointer; - typedef typename GlobStaticMemType::local_pointer local_pointer; + typedef typename GlobMemType::local_pointer local_pointer; typedef internal::ListNode node_type; @@ -62,7 +62,7 @@ class GlobListIter * Constructor, creates a global iterator on a \c dash::List instance. */ GlobListIter( - GlobStaticMemType * gmem, + GlobMemType * gmem, node_type & node) : _globmem(gmem), _node(&node), @@ -139,7 +139,7 @@ class GlobListIter * The instance of \c GlobStaticMem used by this iterator to resolve addresses * in global memory. */ - inline const GlobStaticMemType & globmem() const + inline const GlobMemType & globmem() const { return *_globmem; } @@ -148,7 +148,7 @@ class GlobListIter * The instance of \c GlobStaticMem used by this iterator to resolve addresses * in global memory. */ - inline GlobStaticMemType & globmem() + inline GlobMemType & globmem() { return *_globmem; } @@ -219,7 +219,7 @@ class GlobListIter private: /// Global memory used to dereference iterated values. - GlobStaticMemType * _globmem; + GlobMemType * _globmem; /// The node element referenced at the iterator's position. node_type * _node = nullptr; /// Unit id of the active unit