DASH  0.3.0
dash::allocator::GlobalAllocationPolicy< allocation_static, synchronization_collective, LMemSpaceTag > Class Template Reference

Public Member Functions

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. More...
 
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. More...
 

Private Member Functions

dart_gptr_t do_global_attach (dart_team_t teamid, void *ptr, std::size_t nbytes)
 
bool do_global_detach (dart_gptr_t gptr)
 

Detailed Description

template<class LMemSpaceTag>
class dash::allocator::GlobalAllocationPolicy< allocation_static, synchronization_collective, LMemSpaceTag >

Definition at line 74 of file AllocationPolicy.h.

Member Function Documentation

◆ allocate_segment()

template<class LMemSpaceTag >
dart_gptr_t dash::allocator::GlobalAllocationPolicy< allocation_static, synchronization_collective, LMemSpaceTag >::allocate_segment ( dart_team_t  teamid,
LocalMemorySpaceBase< memory_space_tag > *  res,
std::size_t  nbytes,
std::size_t  alignment 
)
inline

Variant to allocate symmetrically in global memory space if we allocate in the default Host Space.

In this case DART can allocate symmatrically.

Definition at line 84 of file AllocationPolicy.h.

References DART_GPTR_ISNULL.

89  {
90  DASH_LOG_DEBUG(
91  "GlobalAllocationPolicy.do_global_allocate(nlocal)",
92  "number of local values:",
93  nbytes);
94 
95  auto lp = res->allocate(nbytes, alignment);
96 
97  if (!lp && nbytes > 0) {
98  throw std::bad_alloc{};
99  }
100 
101  DASH_LOG_DEBUG_VAR(
102  "GlobalAllocationPolicy.do_global_allocate(nlocal)", lp);
103 
104  // Here, we attach the allocated global pointer. DART internally stores
105  // this pointer in such a way that we can retrieve it by looking up the
106  // local address (teamid <- my_id, addr_or_offset.offset <- 0)
107  auto gptr = AttachDetachPolicy::do_global_attach(
108  teamid, lp, nbytes);
109 
110  if (DART_GPTR_ISNULL(gptr)) {
111  res->deallocate(lp, nbytes, alignment);
112  throw std::bad_alloc{};
113  }
114 
115  DASH_LOG_DEBUG_VAR(
116  "GlobalAllocationPolicy.do_global_allocate(nlocal)", gptr);
117 
118  DASH_LOG_DEBUG("GlobalAllocationPolicy.do_global_allocate(nlocal) >");
119 
120  return gptr;
121  }
#define DART_GPTR_ISNULL(gptr_)
Test for NULL global pointer.
Definition: dart_globmem.h:118

◆ deallocate_segment()

template<class LMemSpaceTag >
bool dash::allocator::GlobalAllocationPolicy< allocation_static, synchronization_collective, LMemSpaceTag >::deallocate_segment ( dart_gptr_t  gptr,
LocalMemorySpaceBase< memory_space_tag > *  res,
void *  lptr,
size_t  nbytes,
size_t  alignment 
)
inline

Similar to the allocation case above global memory is deallocated symmetrically in DART.

Definition at line 125 of file AllocationPolicy.h.

131  {
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);
136 
137  DASH_ASSERT_RETURNS(AttachDetachPolicy::do_global_detach(gptr), true);
138 
139  res->deallocate(lptr, nbytes, alignment);
140 
141  DASH_LOG_DEBUG("GlobalAllocationPolicy.do_global_deallocate >");
142  return true;
143  }

The documentation for this class was generated from the following file: