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

Public Member Functions

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

Detailed Description

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

Definition at line 147 of file AllocationPolicy.h.

Member Function Documentation

◆ allocate_segment()

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 157 of file AllocationPolicy.h.

References DART_GPTR_ISNULL, DART_GPTR_NULL, DART_OK, and dart_team_memalloc_aligned().

162  {
163  DASH_LOG_DEBUG(
164  "GlobalAllocationPolicy.do_global_allocate(nlocal)",
165  "number of local values:",
166  nbytes);
167 
168  dart_gptr_t gptr;
169 
170  dash::dart_storage<uint8_t> ds(nbytes);
171  if (dart_team_memalloc_aligned(teamid, ds.nelem, ds.dtype, &gptr) !=
172  DART_OK) {
173  DASH_LOG_ERROR(
174  "GlobalAllocationPolicy.do_global_allocate(nlocal)",
175  "cannot allocate global memory segment",
176  nbytes);
177  gptr = DART_GPTR_NULL;
178  }
179 
180  if (DART_GPTR_ISNULL(gptr)) {
181  throw std::bad_alloc{};
182  }
183 
184  return gptr;
185  }
Signals success.
Definition: dart_types.h:33
#define DART_GPTR_NULL
A NULL global pointer.
Definition: dart_globmem.h:105
DART Global pointer type.
Definition: dart_globmem.h:77
#define DART_GPTR_ISNULL(gptr_)
Test for NULL global pointer.
Definition: dart_globmem.h:118
Convencience wrapper to determine the DART type and number of elements required for the given templat...
Definition: Types.h:295
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 ...

◆ deallocate_segment()

bool dash::allocator::GlobalAllocationPolicy< allocation_static, synchronization_collective, memory_space_host_tag >::deallocate_segment ( dart_gptr_t  gptr,
LocalMemorySpaceBase< memory_space_tag > *  ,
void *  ,
size_t  ,
size_t   
)
inline

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

Definition at line 189 of file AllocationPolicy.h.

References DART_GPTR_ISNULL, DART_OK, and dart_team_memfree().

195  {
196  DASH_LOG_TRACE(
197  "GlobalAllocationPolicy.do_global_deallocate",
198  "deallocating memory segment",
199  gptr);
200 
201  if (DART_GPTR_ISNULL(gptr)) {
202  return true;
203  }
204 
205  auto ret = dart_team_memfree(gptr) == DART_OK;
206 
207  return ret;
208  }
Signals success.
Definition: dart_types.h:33
dart_ret_t dart_team_memfree(dart_gptr_t gptr)
Collective function to free global memory previously allocated using dart_team_memalloc_aligned.
#define DART_GPTR_ISNULL(gptr_)
Test for NULL global pointer.
Definition: dart_globmem.h:118

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