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

#include <gromacs/utility/alignedallocator.h>


Policy class for configuring gmx::Allocator, to manage allocations of aligned memory for SIMD code.

Static Public Member Functions

static std::size_t alignment ()
 Return the alignment size.
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

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

Free aligned memory.

pMemory pointer previously returned from malloc()
This routine should only be called with pointers obtained from gmx::AlignedAllocationPolicy::malloc(), and absolutely not any pointers obtained the system malloc().
void * gmx::AlignedAllocationPolicy::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.

The memory will always be aligned to 128 bytes, which is our estimate of the longest cache lines on architectures currently in use. It will also be padded by the same amount at the end of the area, to help avoid false cache sharing.

Memory allocated with this routine must be released with gmx::AlignedAllocationPolicy::free(), and absolutely not the system free().

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