1 #ifndef DASH__ALLOCATOR__POLICY_H__INCLUDED 2 #define DASH__ALLOCATOR__POLICY_H__INCLUDED 6 #include <dash/Types.h> 9 #include <dash/allocator/internal/Types.h> 10 #include <dash/internal/Logging.h> 11 #include <dash/memory/MemorySpaceBase.h> 13 std::ostream& operator<<(std::ostream& os,
const dart_gptr_t& dartptr);
41 "AttachDetachPolicy.global_attach",
"cannot attach pointer", ptr);
50 "AttachDetachPolicy.global_detach",
51 "cannot detach global pointer",
68 class AllocationPolicy,
69 class SynchronizationPolicy,
73 template <
class LMemSpaceTag>
78 using memory_space_tag = LMemSpaceTag;
88 std::size_t alignment)
91 "GlobalAllocationPolicy.do_global_allocate(nlocal)",
92 "number of local values:",
95 auto lp = res->allocate(nbytes, alignment);
97 if (!lp && nbytes > 0) {
98 throw std::bad_alloc{};
102 "GlobalAllocationPolicy.do_global_allocate(nlocal)", lp);
107 auto gptr = AttachDetachPolicy::do_global_attach(
111 res->deallocate(lp, nbytes, alignment);
112 throw std::bad_alloc{};
116 "GlobalAllocationPolicy.do_global_allocate(nlocal)", gptr);
118 DASH_LOG_DEBUG(
"GlobalAllocationPolicy.do_global_allocate(nlocal) >");
132 DASH_LOG_DEBUG(
"< GlobalAllocationPolicy.do_global_deallocate");
133 DASH_LOG_DEBUG_VAR(
"GlobalAllocationPolicy.do_global_deallocate", gptr);
134 DASH_LOG_DEBUG_VAR(
"GlobalAllocationPolicy.do_global_deallocate", lptr);
135 DASH_LOG_DEBUG_VAR(
"GlobalAllocationPolicy.do_global_deallocate", nbytes);
137 DASH_ASSERT_RETURNS(AttachDetachPolicy::do_global_detach(gptr),
true);
139 res->deallocate(lptr, nbytes, alignment);
141 DASH_LOG_DEBUG(
"GlobalAllocationPolicy.do_global_deallocate >");
164 "GlobalAllocationPolicy.do_global_allocate(nlocal)",
165 "number of local values:",
174 "GlobalAllocationPolicy.do_global_allocate(nlocal)",
175 "cannot allocate global memory segment",
181 throw std::bad_alloc{};
197 "GlobalAllocationPolicy.do_global_deallocate",
198 "deallocating memory segment",
249 "LocalAllocationPolicy.do_global_allocate",
250 "cannot allocate local memory",
252 throw std::bad_alloc{};
254 DASH_LOG_DEBUG_VAR(
"LocalAllocator.allocate >", gptr);
bool deallocate_segment(dart_gptr_t gptr, LocalMemorySpaceBase< memory_space_tag > *, void *, size_t, size_t)
Similar to the allocation case above global memory is deallocated symmetrically in DART...
dart_ret_t dart_team_memregister(dart_team_t teamid, size_t nlelem, dart_datatype_t dtype, void *addr, dart_gptr_t *gptr)
Collective function, attaches external memory previously allocated by the user.
only one unit allocates in global memory
This class is a simple memory pool which holds allocates elements of size ValueType.
bool deallocate_segment(dart_gptr_t gptr, LocalMemorySpaceBase< memory_space_tag > *res, void *lptr, size_t nbytes, size_t alignment)
Similar to the allocation case above global memory is deallocated symmetrically in DART...
dart_ret_t dart_memfree(dart_gptr_t gptr)
Frees memory in the global address space allocated by a previous call of dart_memalloc.
dart_ret_t dart_memalloc(size_t nelem, dart_datatype_t dtype, dart_gptr_t *gptr)
Allocates memory for nelem elements of type dtype in the global address space of the calling unit and...
dart_gptr_t allocate_segment(dart_team_t teamid, LocalMemorySpaceBase< memory_space_tag > *res, std::size_t nbytes, std::size_t alignment)
Variant to allocate symmetrically in global memory space if we allocate in the default Host Space...
dart_gptr_t allocate_segment(LocalMemorySpaceBase< memory_space_tag > *, std::size_t nbytes, std::size_t)
Variant to allocate only locally in global memory space if we allocate in the default Host Space...
#define DART_TYPE_BYTE
integral data types
#define DART_GPTR_NULL
A NULL global pointer.
all units allocate invdividually in local memory and synchronize in epochs
Collective AllocationPolicy: Implements the mechanisms to allocate symmetrically from the global memo...
dart_ret_t dart_team_memfree(dart_gptr_t gptr)
Collective function to free global memory previously allocated using dart_team_memalloc_aligned.
DART Global pointer type.
dart_gptr_t allocate_segment(dart_team_t teamid, LocalMemorySpaceBase< memory_space_tag > *, std::size_t nbytes, std::size_t)
Variant to allocate symmetrically in global memory space if we allocate in the default Host Space...
#define DART_GPTR_ISNULL(gptr_)
Test for NULL global pointer.
int16_t dart_team_t
Data type for storing a team ID.
All units collectively allocate global memory.
bool deallocate_segment(dart_gptr_t gptr, LocalMemorySpaceBase< memory_space_tag > *, void *, size_t, size_t)
Similar to the allocation case above global memory is deallocated symmetrically in DART...
Convencience wrapper to determine the DART type and number of elements required for the given templat...
dart_ret_t dart_team_memderegister(dart_gptr_t gptr)
Collective function similar to dart_team_memfree() but on previously externally allocated memory...
dart_ret_t dart_team_memalloc_aligned(dart_team_t teamid, size_t nelem, dart_datatype_t dtype, dart_gptr_t *gptr)
Collective function on the specified team to allocate nelem elements of type dtype of memory in each ...