Gromacs  2018.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Static Public Member Functions
gmx::PageAlignedAllocationPolicy Class Reference

#include <gromacs/utility/alignedallocator.h>


Policy class for configuring gmx::Allocator, to manage allocations of page-aligned memory that can be locked for asynchronous transfer to GPU devices.

Static Public Member Functions

static std::size_t alignment ()
 Return the alignment size of memory pages on this system. More...
static void * malloc (std::size_t bytes)
 Allocate memory aligned to alignment() bytes. More...
static void free (void *p)
 Free aligned memory. More...

Member Function Documentation

std::size_t gmx::PageAlignedAllocationPolicy::alignment ( )

Return the alignment size of memory pages on this system.

Queries sysconf/WinAPI, otherwise guesses 4096.

void gmx::PageAlignedAllocationPolicy::free ( void *  p)

Free aligned memory.

pMemory pointer previously returned from malloc()
This routine should only be called with pointers obtained from gmx::PageAlignedAllocationPolicy::malloc(), and absolutely not any pointers obtained the system malloc().
void * gmx::PageAlignedAllocationPolicy::malloc ( std::size_t  bytes)

Allocate memory aligned to alignment() bytes.

bytesAmount of memory (bytes) to allocate. It is valid to ask for 0 bytes, which will return a non-null pointer that is properly aligned and padded (but that you should not use).
Valid pointer if the allocation worked, otherwise nullptr.
Memory allocated with this routine must be released with gmx::PageAlignedAllocationPolicy::free(), and absolutely not the system free().

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